- got my plumbers suit on and added the plumbing for FTP file xfers
This commit is contained in:
parent
ba995d1131
commit
6e88e4be4c
|
@ -59,7 +59,7 @@
|
|||
<Add directory="../../source/shared_lib/include/platform/common" />
|
||||
<Add directory="../../source/win32_deps/curl-7.20.1/include" />
|
||||
<Add directory="../../source/shared_lib/include/map" />
|
||||
<Add directory="$(NOINHERIT)" />
|
||||
<Add directory="../../source/win32_deps/libircclient/include" />
|
||||
</Compiler>
|
||||
<ResourceCompiler>
|
||||
<Add directory="../../source/shared_lib/include/graphics" />
|
||||
|
@ -126,9 +126,11 @@
|
|||
<Add library="lua5.1" />
|
||||
<Add library="streflop" />
|
||||
<Add library="glest" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="../../source/win32_deps/lib" />
|
||||
<Add directory="../../source/win32_deps/xerces-c-src_2_8_0/lib" />
|
||||
<Add directory="../../data/glest_game/" />
|
||||
<Add directory="../../source/win32_deps/libircclient/build/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
|
@ -186,7 +188,7 @@
|
|||
<Add directory="../../source/win32_deps/curl-7.20.1/include" />
|
||||
<Add directory="../../source/shared_lib/include/map" />
|
||||
<Add directory="../../source/win32_deps/xerces-c-src_2_8_0/include" />
|
||||
<Add directory="$(NOINHERIT)" />
|
||||
<Add directory="../../source/win32_deps/libircclient/include" />
|
||||
</Compiler>
|
||||
<ResourceCompiler>
|
||||
<Add directory="../../source/shared_lib/include/graphics" />
|
||||
|
@ -253,9 +255,11 @@
|
|||
<Add library="lua5.1" />
|
||||
<Add library="streflop" />
|
||||
<Add library="glest" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="../../source/win32_deps/lib" />
|
||||
<Add directory="../../source/win32_deps/xerces-c-src_2_8_0/lib" />
|
||||
<Add directory="../../data/glest_game/" />
|
||||
<Add directory="../../source/win32_deps/libircclient/build/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release Linux">
|
||||
|
@ -351,6 +355,7 @@
|
|||
<Add library="lua5.1" />
|
||||
<Add library="glest" />
|
||||
<Add library="streflop" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="../../source/linux_deps/lib" />
|
||||
</Linker>
|
||||
<Environment>
|
||||
|
@ -452,6 +457,7 @@
|
|||
<Add library="lua5.1" />
|
||||
<Add library="glest" />
|
||||
<Add library="streflop" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="../../source/linux_deps/lib" />
|
||||
</Linker>
|
||||
<Environment>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4,44 +4,56 @@
|
|||
<File name="../../source/glest_game/ai/ai.cpp" open="0" top="0" tabpos="10">
|
||||
<Cursor position="12418" topLine="415" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/ai/ai_interface.cpp" open="1" top="0" tabpos="23">
|
||||
<Cursor position="3148" topLine="87" />
|
||||
<File name="../../source/glest_game/ai/ai_interface.cpp" open="1" top="0" tabpos="7">
|
||||
<Cursor position="15132" topLine="347" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/ai/cartographer.cpp" open="0" top="0" tabpos="0">
|
||||
<Cursor position="8456" topLine="266" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/facilities/components.cpp" open="1" top="0" tabpos="43">
|
||||
<File name="../../source/glest_game/facilities/components.cpp" open="0" top="0" tabpos="33">
|
||||
<Cursor position="2395" topLine="56" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/facilities/game_util.cpp" open="1" top="0" tabpos="42">
|
||||
<Cursor position="5576" topLine="196" />
|
||||
<File name="../../source/glest_game/facilities/game_util.cpp" open="0" top="0" tabpos="32">
|
||||
<Cursor position="5576" topLine="184" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/facilities/game_util.h" open="1" top="0" tabpos="8">
|
||||
<Cursor position="837" topLine="15" />
|
||||
<File name="../../source/glest_game/facilities/game_util.h" open="0" top="0" tabpos="8">
|
||||
<Cursor position="837" topLine="4" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/facilities/logger.cpp" open="0" top="0" tabpos="0">
|
||||
<Cursor position="1195" topLine="115" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/game.cpp" open="1" top="0" tabpos="4">
|
||||
<Cursor position="31605" topLine="788" />
|
||||
<File name="../../source/glest_game/game/chat_manager.cpp" open="1" top="0" tabpos="5">
|
||||
<Cursor position="4130" topLine="108" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/game.h" open="1" top="0" tabpos="34">
|
||||
<File name="../../source/glest_game/game/chat_manager.h" open="1" top="0" tabpos="6">
|
||||
<Cursor position="1009" topLine="27" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/console.cpp" open="1" top="0" tabpos="3">
|
||||
<Cursor position="2942" topLine="75" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/console.h" open="1" top="0" tabpos="4">
|
||||
<Cursor position="1790" topLine="50" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/game.cpp" open="1" top="0" tabpos="26">
|
||||
<Cursor position="62364" topLine="1627" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/game.h" open="0" top="0" tabpos="27">
|
||||
<Cursor position="2770" topLine="103" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/game_constants.h" open="1" top="0" tabpos="7">
|
||||
<File name="../../source/glest_game/game/game_constants.h" open="0" top="0" tabpos="7">
|
||||
<Cursor position="3016" topLine="112" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/game/game_settings.h" open="1" top="0" tabpos="35">
|
||||
<Cursor position="893" topLine="15" />
|
||||
<File name="../../source/glest_game/game/game_settings.h" open="1" top="0" tabpos="20">
|
||||
<Cursor position="4937" topLine="132" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/global/config.cpp" open="1" top="0" tabpos="2">
|
||||
<Cursor position="13640" topLine="389" />
|
||||
<File name="../../source/glest_game/global/config.cpp" open="0" top="0" tabpos="2">
|
||||
<Cursor position="3309" topLine="80" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/global/config.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="1037" topLine="35" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/global/core_data.cpp" open="1" top="0" tabpos="3">
|
||||
<Cursor position="2143" topLine="167" />
|
||||
<File name="../../source/glest_game/global/core_data.cpp" open="0" top="0" tabpos="3">
|
||||
<Cursor position="2143" topLine="156" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/global/core_data.h" open="0" top="0" tabpos="14">
|
||||
<Cursor position="603" topLine="1" />
|
||||
|
@ -55,109 +67,121 @@
|
|||
<File name="../../source/glest_game/graphics/particle_type.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="654" topLine="2" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/graphics/renderer.cpp" open="1" top="0" tabpos="6">
|
||||
<Cursor position="66001" topLine="2259" />
|
||||
<File name="../../source/glest_game/graphics/renderer.cpp" open="1" top="0" tabpos="8">
|
||||
<Cursor position="101237" topLine="3435" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/main/main.cpp" open="1" top="1" tabpos="1">
|
||||
<Cursor position="27852" topLine="759" />
|
||||
<File name="../../source/glest_game/main/main.cpp" open="0" top="0" tabpos="1">
|
||||
<Cursor position="28455" topLine="770" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/main/program.cpp" open="1" top="0" tabpos="5">
|
||||
<File name="../../source/glest_game/main/program.cpp" open="0" top="0" tabpos="5">
|
||||
<Cursor position="17186" topLine="504" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/main_menu.cpp" open="1" top="0" tabpos="9">
|
||||
<Cursor position="739" topLine="10" />
|
||||
<File name="../../source/glest_game/menu/main_menu.cpp" open="0" top="0" tabpos="9">
|
||||
<Cursor position="4661" topLine="158" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_background.cpp" open="1" top="0" tabpos="10">
|
||||
<File name="../../source/glest_game/menu/menu_background.cpp" open="0" top="0" tabpos="10">
|
||||
<Cursor position="1052" topLine="28" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_connected_game.cpp" open="1" top="0" tabpos="11">
|
||||
<Cursor position="0" topLine="0" />
|
||||
<File name="../../source/glest_game/menu/menu_state_connected_game.cpp" open="1" top="0" tabpos="21">
|
||||
<Cursor position="38856" topLine="936" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_custom_game.cpp" open="1" top="0" tabpos="14">
|
||||
<Cursor position="104039" topLine="2533" />
|
||||
<File name="../../source/glest_game/menu/menu_state_custom_game.cpp" open="0" top="0" tabpos="14">
|
||||
<Cursor position="22810" topLine="566" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_custom_game.h" open="1" top="0" tabpos="39">
|
||||
<Cursor position="4170" topLine="137" />
|
||||
<File name="../../source/glest_game/menu/menu_state_custom_game.h" open="0" top="0" tabpos="40">
|
||||
<Cursor position="960" topLine="129" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_join_game.cpp" open="1" top="0" tabpos="15">
|
||||
<Cursor position="7274" topLine="216" />
|
||||
<File name="../../source/glest_game/menu/menu_state_join_game.cpp" open="0" top="0" tabpos="15">
|
||||
<Cursor position="7351" topLine="216" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_masterserver.cpp" open="1" top="0" tabpos="22">
|
||||
<Cursor position="23842" topLine="656" />
|
||||
<File name="../../source/glest_game/menu/menu_state_masterserver.cpp" open="1" top="0" tabpos="1">
|
||||
<Cursor position="25214" topLine="663" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_options.cpp" open="1" top="0" tabpos="13">
|
||||
<File name="../../source/glest_game/menu/menu_state_masterserver.h" open="1" top="0" tabpos="2">
|
||||
<Cursor position="3370" topLine="94" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_options.cpp" open="0" top="0" tabpos="13">
|
||||
<Cursor position="4623" topLine="113" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/menu/menu_state_root.cpp" open="1" top="0" tabpos="17">
|
||||
<Cursor position="785" topLine="9" />
|
||||
<File name="../../source/glest_game/menu/menu_state_root.cpp" open="0" top="0" tabpos="16">
|
||||
<Cursor position="3513" topLine="86" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/client_interface.cpp" open="1" top="0" tabpos="25">
|
||||
<Cursor position="38271" topLine="901" />
|
||||
<File name="../../source/glest_game/network/client_interface.cpp" open="1" top="0" tabpos="13">
|
||||
<Cursor position="1139" topLine="29" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/connection_slot.cpp" open="1" top="0" tabpos="20">
|
||||
<Cursor position="7431" topLine="199" />
|
||||
<File name="../../source/glest_game/network/connection_slot.cpp" open="1" top="0" tabpos="11">
|
||||
<Cursor position="31095" topLine="647" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/connection_slot.h" open="1" top="0" tabpos="24">
|
||||
<Cursor position="2906" topLine="102" />
|
||||
<File name="../../source/glest_game/network/connection_slot.h" open="1" top="0" tabpos="12">
|
||||
<Cursor position="2843" topLine="100" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/network_manager.cpp" open="1" top="0" tabpos="21">
|
||||
<File name="../../source/glest_game/network/network_interface.cpp" open="0" top="0" tabpos="35">
|
||||
<Cursor position="0" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/network_manager.cpp" open="0" top="0" tabpos="21">
|
||||
<Cursor position="777" topLine="15" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/network_message.cpp" open="1" top="0" tabpos="38">
|
||||
<Cursor position="8307" topLine="219" />
|
||||
<File name="../../source/glest_game/network/network_message.cpp" open="1" top="0" tabpos="22">
|
||||
<Cursor position="8089" topLine="219" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/network_message.h" open="1" top="0" tabpos="37">
|
||||
<File name="../../source/glest_game/network/network_message.h" open="0" top="0" tabpos="30">
|
||||
<Cursor position="5699" topLine="207" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/network_types.cpp" open="1" top="0" tabpos="36">
|
||||
<File name="../../source/glest_game/network/network_types.cpp" open="0" top="0" tabpos="29">
|
||||
<Cursor position="517" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/network_types.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="628" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/server_interface.cpp" open="1" top="0" tabpos="19">
|
||||
<Cursor position="65329" topLine="1509" />
|
||||
<File name="../../source/glest_game/network/server_interface.cpp" open="1" top="0" tabpos="9">
|
||||
<Cursor position="3765" topLine="72" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/network/server_interface.h" open="1" top="0" tabpos="26">
|
||||
<Cursor position="2147" topLine="60" />
|
||||
<File name="../../source/glest_game/network/server_interface.h" open="1" top="0" tabpos="10">
|
||||
<Cursor position="663" topLine="6" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/type_instances/faction.cpp" open="1" top="0" tabpos="12">
|
||||
<Cursor position="2803" topLine="71" />
|
||||
<File name="../../source/glest_game/type_instances/faction.cpp" open="1" top="0" tabpos="14">
|
||||
<Cursor position="30798" topLine="865" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/type_instances/unit.cpp" open="1" top="0" tabpos="27">
|
||||
<Cursor position="26630" topLine="882" />
|
||||
<File name="../../source/glest_game/type_instances/unit.cpp" open="1" top="0" tabpos="15">
|
||||
<Cursor position="53649" topLine="1782" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/type_instances/unit.h" open="1" top="0" tabpos="31">
|
||||
<File name="../../source/glest_game/type_instances/unit.h" open="0" top="0" tabpos="24">
|
||||
<Cursor position="9749" topLine="330" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/types/command_type.cpp" open="1" top="0" tabpos="29">
|
||||
<File name="../../source/glest_game/types/command_type.cpp" open="0" top="0" tabpos="22">
|
||||
<Cursor position="3996" topLine="101" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/types/command_type.h" open="1" top="0" tabpos="30">
|
||||
<File name="../../source/glest_game/types/command_type.h" open="0" top="0" tabpos="23">
|
||||
<Cursor position="2449" topLine="86" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/types/skill_type.h" open="1" top="0" tabpos="32">
|
||||
<File name="../../source/glest_game/types/skill_type.h" open="0" top="0" tabpos="25">
|
||||
<Cursor position="1236" topLine="37" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/map.cpp" open="1" top="0" tabpos="18">
|
||||
<Cursor position="24070" topLine="832" />
|
||||
<File name="../../source/glest_game/types/unit_type.cpp" open="1" top="0" tabpos="18">
|
||||
<Cursor position="589" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/map.h" open="0" top="0" tabpos="20">
|
||||
<Cursor position="1066" topLine="24" />
|
||||
<File name="../../source/glest_game/types/unit_type.h" open="1" top="0" tabpos="19">
|
||||
<Cursor position="4730" topLine="152" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/minimap.cpp" open="1" top="0" tabpos="33">
|
||||
<Cursor position="3587" topLine="108" />
|
||||
<File name="../../source/glest_game/world/map.cpp" open="1" top="0" tabpos="25">
|
||||
<Cursor position="10892" topLine="388" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/map.h" open="1" top="0" tabpos="24">
|
||||
<Cursor position="3852" topLine="105" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/minimap.cpp" open="1" top="0" tabpos="23">
|
||||
<Cursor position="2625" topLine="101" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/minimap.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="1287" topLine="21" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/unit_updater.cpp" open="1" top="0" tabpos="28">
|
||||
<Cursor position="6300" topLine="170" />
|
||||
<File name="../../source/glest_game/world/unit_updater.cpp" open="1" top="0" tabpos="27">
|
||||
<Cursor position="64308" topLine="1581" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/world.cpp" open="1" top="0" tabpos="16">
|
||||
<Cursor position="27958" topLine="863" />
|
||||
<Cursor position="43867" topLine="1286" />
|
||||
</File>
|
||||
<File name="../../source/glest_game/world/world.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="6259" topLine="184" />
|
||||
<File name="../../source/glest_game/world/world.h" open="1" top="0" tabpos="17">
|
||||
<Cursor position="6990" topLine="193" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
@ -1 +1,320 @@
|
|||
# depslib dependency file v1.0
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_acosf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/headers/SMath.h
|
||||
"../streflop_libm_bridge.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/streflop_libm_bridge.h
|
||||
"../streflop.h"
|
||||
"../System.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/streflop.h
|
||||
"X87DenormalSquasher.h"
|
||||
"SoftFloatWrapper.h"
|
||||
"FPUSettings.h"
|
||||
"SMath.h"
|
||||
"Random.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/X87DenormalSquasher.h
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/FPUSettings.h
|
||||
"softfloat/softfloat.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/SMath.h
|
||||
"streflop.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/Random.h
|
||||
"IntegerTypes.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/IntegerTypes.h
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/System.h
|
||||
<endian.h>
|
||||
"IntegerTypes.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/headers/endian.h
|
||||
"features.h"
|
||||
"../streflop_libm_bridge.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/headers/features.h
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/headers/math_private.h
|
||||
"../streflop_libm_bridge.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_acoshf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_asinf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_atan2f.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_atanhf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_coshf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_exp2f.cpp
|
||||
"../streflop_libm_bridge.h"
|
||||
"../streflop_libm_bridge.h"
|
||||
"ieee754.h"
|
||||
"SMath.h"
|
||||
"../streflop_libm_bridge.h"
|
||||
"../streflop_libm_bridge.h"
|
||||
"math_private.h"
|
||||
"t_exp2f.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/headers/ieee754.h
|
||||
"../streflop_libm_bridge.h"
|
||||
"features.h"
|
||||
"endian.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/flt-32/t_exp2f.h
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_expf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_fmodf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_gammaf_r.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_hypotf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_j0f.cpp
|
||||
"math.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 /home/softcoder/Code/megaglest/trunk/source/shared_lib/include/streflop/libm/headers/math.h
|
||||
"../streflop_libm_bridge.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_j1f.cpp
|
||||
"math.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_jnf.cpp
|
||||
"math.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_lgammaf_r.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_log10f.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_log2f.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_logf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_powf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_rem_pio2f.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_remainderf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_sinhf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/e_sqrtf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/k_cosf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/k_rem_pio2f.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/k_sinf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/k_tanf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_asinhf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_atanf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_cbrtf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_ceilf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_copysignf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_cosf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_erff.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_expm1f.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_fabsf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_finitef.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_floorf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_fpclassifyf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_frexpf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_ilogbf.cpp
|
||||
"../streflop_libm_bridge.h"
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_isinff.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_isnanf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_ldexpf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
"../streflop_libm_bridge.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_llrintf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_llroundf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_log1pf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_logbf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_lrintf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_lroundf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_modff.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_nearbyintf.cpp
|
||||
"../streflop_libm_bridge.h"
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_nextafterf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
"../streflop_libm_bridge.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_remquof.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_rintf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_roundf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_scalblnf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_scalbnf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_signbitf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_sincosf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_sinf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_tanf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_tanhf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/s_truncf.cpp
|
||||
"SMath.h"
|
||||
"math_private.h"
|
||||
|
||||
1268772031 source:/home/softcoder/Code/megaglest/trunk/source/shared_lib/sources/streflop/libm/flt-32/w_expf.cpp
|
||||
"math_private.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Release Win32" />
|
||||
<ActiveTarget name="Release Linux" />
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_file>
|
||||
<Workspace title="Workspace">
|
||||
<Project filename="libstreflop.cbp" active="1" />
|
||||
<Project filename="libstreflop.cbp" />
|
||||
<Project filename="shared_lib.cbp" />
|
||||
<Project filename="glest_game.cbp" />
|
||||
<Project filename="glest_game.cbp" active="1" />
|
||||
<Project filename="glest_editor.cbp" />
|
||||
<Project filename="g3d_viewer.cbp" />
|
||||
<Project filename="glest_configurator.cbp" />
|
||||
|
|
|
@ -55,6 +55,8 @@
|
|||
<Add directory="../../source/win32_deps/curl-7.20.1/include" />
|
||||
<Add directory="../../source/shared_lib/include/map" />
|
||||
<Add directory="../../source/shared_lib/include/platform/miniupnpc" />
|
||||
<Add directory="../../source/win32_deps/libircclient/include" />
|
||||
<Add directory="../../source/shared_lib/include/feathery_ftp" />
|
||||
</Compiler>
|
||||
<ResourceCompiler>
|
||||
<Add directory="../../source/shared_lib/include" />
|
||||
|
@ -100,10 +102,12 @@
|
|||
<Add library="liblibvorbis" />
|
||||
<Add library="liblibvorbisfile" />
|
||||
<Add library="liblibvorbisenc" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="./" />
|
||||
<Add directory="../../source/win32_deps/lib" />
|
||||
<Add directory="../../source/win32_deps/xerces-c-src_2_8_0/lib" />
|
||||
<Add directory="../../data/glest_game/" />
|
||||
<Add directory="../../source/win32_deps/libircclient/build/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
|
@ -154,6 +158,8 @@
|
|||
<Add directory="../../source/win32_deps/curl-7.20.1/include" />
|
||||
<Add directory="../../source/shared_lib/include/map" />
|
||||
<Add directory="../../source/shared_lib/include/platform/miniupnpc" />
|
||||
<Add directory="../../source/win32_deps/libircclient/include" />
|
||||
<Add directory="../../source/shared_lib/include/feathery_ftp" />
|
||||
</Compiler>
|
||||
<ResourceCompiler>
|
||||
<Add directory="../../source/shared_lib/include" />
|
||||
|
@ -199,10 +205,12 @@
|
|||
<Add library="liblibvorbis" />
|
||||
<Add library="liblibvorbisfile" />
|
||||
<Add library="liblibvorbisenc" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="./" />
|
||||
<Add directory="../../source/win32_deps/lib" />
|
||||
<Add directory="../../source/win32_deps/xerces-c-src_2_8_0/lib" />
|
||||
<Add directory="../../data/glest_game/" />
|
||||
<Add directory="../../source/win32_deps/libircclient/build/lib" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Release Linux">
|
||||
|
@ -241,6 +249,8 @@
|
|||
<Add directory="../../source/shared_lib/include/map" />
|
||||
<Add directory="$(THIRDPARTY_INCLUDE_DIR)/lua5.1" />
|
||||
<Add directory="../../source/shared_lib/include/platform/miniupnpc" />
|
||||
<Add directory="../../source/shared_lib/include/feathery_ftp" />
|
||||
<Add directory="../../source/shared_lib/include/libircclient/include" />
|
||||
</Compiler>
|
||||
<ResourceCompiler>
|
||||
<Add directory="../../source/shared_lib/include" />
|
||||
|
@ -273,6 +283,7 @@
|
|||
<Add library="vorbisfile" />
|
||||
<Add library="vorbisenc" />
|
||||
<Add library="streflop" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="./" />
|
||||
<Add directory="../../source/linux_deps/lib" />
|
||||
</Linker>
|
||||
|
@ -330,6 +341,8 @@
|
|||
<Add directory="../../source/shared_lib/include/map" />
|
||||
<Add directory="$(THIRDPARTY_INCLUDE_DIR)/lua5.1" />
|
||||
<Add directory="../../source/shared_lib/include/platform/miniupnpc" />
|
||||
<Add directory="../../source/shared_lib/include/feathery_ftp" />
|
||||
<Add directory="../../source/shared_lib/include/libircclient/include" />
|
||||
</Compiler>
|
||||
<ResourceCompiler>
|
||||
<Add directory="../../source/shared_lib/include" />
|
||||
|
@ -362,6 +375,7 @@
|
|||
<Add library="vorbisfile" />
|
||||
<Add library="vorbisenc" />
|
||||
<Add library="streflop" />
|
||||
<Add library="ircclient" />
|
||||
<Add directory="./" />
|
||||
<Add directory="../../source/linux_deps/lib" />
|
||||
</Linker>
|
||||
|
@ -371,6 +385,11 @@
|
|||
</Environment>
|
||||
</Target>
|
||||
</Build>
|
||||
<Unit filename="../../source/shared_lib/include/feathery_ftp/ftp.h" />
|
||||
<Unit filename="../../source/shared_lib/include/feathery_ftp/ftpConfig.h" />
|
||||
<Unit filename="../../source/shared_lib/include/feathery_ftp/ftpIfc.h" />
|
||||
<Unit filename="../../source/shared_lib/include/feathery_ftp/ftpMessages.h" />
|
||||
<Unit filename="../../source/shared_lib/include/feathery_ftp/ftpTypes.h" />
|
||||
<Unit filename="../../source/shared_lib/include/graphics/BMPReader.h" />
|
||||
<Unit filename="../../source/shared_lib/include/graphics/FileReader.h" />
|
||||
<Unit filename="../../source/shared_lib/include/graphics/ImageReaders.h" />
|
||||
|
@ -433,6 +452,8 @@
|
|||
<Unit filename="../../source/shared_lib/include/platform/miniupnpc/upnpcommands.h" />
|
||||
<Unit filename="../../source/shared_lib/include/platform/miniupnpc/upnperrors.h" />
|
||||
<Unit filename="../../source/shared_lib/include/platform/miniupnpc/upnpreplyparse.h" />
|
||||
<Unit filename="../../source/shared_lib/include/platform/posix/ftpserver.h" />
|
||||
<Unit filename="../../source/shared_lib/include/platform/posix/ircclient.h" />
|
||||
<Unit filename="../../source/shared_lib/include/platform/posix/socket.h" />
|
||||
<Unit filename="../../source/shared_lib/include/platform/sdl/factory_repository.h">
|
||||
<Option target="Release Linux" />
|
||||
|
@ -478,6 +499,33 @@
|
|||
<Unit filename="../../source/shared_lib/include/util/randomgen.h" />
|
||||
<Unit filename="../../source/shared_lib/include/util/util.h" />
|
||||
<Unit filename="../../source/shared_lib/include/xml/xml_parser.h" />
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpAccount.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpCmds.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpLib.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpMessages.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpRuntime.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpServer.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpSession.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/graphics/BMPReader.cpp" />
|
||||
<Unit filename="../../source/shared_lib/sources/graphics/FileReader.cpp" />
|
||||
<Unit filename="../../source/shared_lib/sources/graphics/ImageReaders.cpp" />
|
||||
|
@ -543,21 +591,6 @@
|
|||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/minixml.h" />
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/minixmlvalid.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/testigddescparse.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/testminixml.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/testupnpreplyparse.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/upnpc.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/upnpcommands.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
|
@ -570,6 +603,8 @@
|
|||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="../../source/shared_lib/sources/platform/miniupnpc/upnpreplyparse.h" />
|
||||
<Unit filename="../../source/shared_lib/sources/platform/posix/ftpserver.cpp" />
|
||||
<Unit filename="../../source/shared_lib/sources/platform/posix/ircclient.cpp" />
|
||||
<Unit filename="../../source/shared_lib/sources/platform/posix/socket.cpp" />
|
||||
<Unit filename="../../source/shared_lib/sources/platform/sdl/factory_repository.cpp">
|
||||
<Option target="Release Linux" />
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,38 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Release Linux" />
|
||||
<File name="../../source/shared_lib/include/graphics/context.h" open="1" top="0" tabpos="15">
|
||||
<Cursor position="924" topLine="20" />
|
||||
<File name="../../source/shared_lib/include/feathery_ftp/ftpIfc.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="1235" topLine="10" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/graphics/gl/base_renderer.h" open="1" top="0" tabpos="13">
|
||||
<Cursor position="830" topLine="5" />
|
||||
<File name="../../source/shared_lib/include/graphics/context.h" open="0" top="0" tabpos="15">
|
||||
<Cursor position="924" topLine="17" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/graphics/gl/shader_gl.h" open="1" top="0" tabpos="9">
|
||||
<Cursor position="2402" topLine="73" />
|
||||
<File name="../../source/shared_lib/include/graphics/gl/base_renderer.h" open="0" top="0" tabpos="13">
|
||||
<Cursor position="830" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/graphics/gl/shader_gl.h" open="0" top="0" tabpos="9">
|
||||
<Cursor position="2402" topLine="67" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/graphics/graphics_interface.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="566" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/graphics/model.h" open="1" top="0" tabpos="12">
|
||||
<File name="../../source/shared_lib/include/graphics/model.h" open="0" top="0" tabpos="12">
|
||||
<Cursor position="1691" topLine="66" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/lua/lua_script.h" open="1" top="0" tabpos="7">
|
||||
<File name="../../source/shared_lib/include/lua/lua_script.h" open="0" top="0" tabpos="7">
|
||||
<Cursor position="558" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/map/map_preview.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="2164" topLine="66" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/common/base_thread.h" open="1" top="0" tabpos="20">
|
||||
<Cursor position="2072" topLine="60" />
|
||||
<File name="../../source/shared_lib/include/platform/common/base_thread.h" open="0" top="0" tabpos="19">
|
||||
<Cursor position="1528" topLine="34" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/common/platform_common.h" open="1" top="0" tabpos="6">
|
||||
<Cursor position="747" topLine="9" />
|
||||
<File name="../../source/shared_lib/include/platform/common/platform_common.h" open="0" top="0" tabpos="6">
|
||||
<Cursor position="2329" topLine="94" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/miniupnpc/upnpcommands.h" open="1" top="0" tabpos="68">
|
||||
<File name="../../source/shared_lib/include/platform/common/simple_threads.h" open="1" top="0" tabpos="5">
|
||||
<Cursor position="2615" topLine="70" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/miniupnpc/upnpcommands.h" open="0" top="0" tabpos="25">
|
||||
<Cursor position="4213" topLine="106" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/posix/socket.h" open="1" top="0" tabpos="66">
|
||||
<Cursor position="5486" topLine="209" />
|
||||
<File name="../../source/shared_lib/include/platform/posix/ftpserver.h" open="1" top="0" tabpos="0">
|
||||
<Cursor position="0" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/posix/ircclient.h" open="1" top="0" tabpos="2">
|
||||
<Cursor position="0" topLine="45" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/posix/socket.h" open="0" top="0" tabpos="24">
|
||||
<Cursor position="5486" topLine="198" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/sdl/gl_wrap.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="621" topLine="0" />
|
||||
|
@ -40,13 +52,13 @@
|
|||
<File name="../../source/shared_lib/include/platform/sdl/platform_main.h" open="0" top="0" tabpos="3">
|
||||
<Cursor position="696" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/sdl/thread.h" open="1" top="0" tabpos="19">
|
||||
<Cursor position="1173" topLine="38" />
|
||||
<File name="../../source/shared_lib/include/platform/sdl/thread.h" open="1" top="0" tabpos="6">
|
||||
<Cursor position="2223" topLine="90" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/platform/sdl/window.h" open="1" top="0" tabpos="22">
|
||||
<File name="../../source/shared_lib/include/platform/sdl/window.h" open="0" top="0" tabpos="21">
|
||||
<Cursor position="4768" topLine="171" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/streflop/FPUSettings.h" open="1" top="0" tabpos="4">
|
||||
<File name="../../source/shared_lib/include/streflop/FPUSettings.h" open="0" top="0" tabpos="4">
|
||||
<Cursor position="6002" topLine="172" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/streflop/Random.h" open="0" top="0" tabpos="0">
|
||||
|
@ -58,12 +70,21 @@
|
|||
<File name="../../source/shared_lib/include/util/properties.h" open="0" top="0" tabpos="5">
|
||||
<Cursor position="1476" topLine="23" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/util/util.h" open="0" top="0" tabpos="0">
|
||||
<Cursor position="601" topLine="0" />
|
||||
<File name="../../source/shared_lib/include/util/util.h" open="0" top="0" tabpos="26">
|
||||
<Cursor position="498" topLine="2" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/include/xml/xml_parser.h" open="0" top="0" tabpos="1">
|
||||
<Cursor position="576" topLine="1" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/feathery_ftp/ftpAccount.c" open="1" top="0" tabpos="40">
|
||||
<Cursor position="2358" topLine="53" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/feathery_ftp/ftpServer.c" open="1" top="0" tabpos="37">
|
||||
<Cursor position="1302" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/feathery_ftp/ftpSession.c" open="1" top="0" tabpos="36">
|
||||
<Cursor position="0" topLine="57" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/graphics/BMPReader.cpp" open="0" top="0" tabpos="0">
|
||||
<Cursor position="0" topLine="6" />
|
||||
</File>
|
||||
|
@ -76,55 +97,58 @@
|
|||
<File name="../../source/shared_lib/sources/graphics/model.cpp" open="0" top="0" tabpos="0">
|
||||
<Cursor position="12079" topLine="424" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/common/base_thread.cpp" open="1" top="0" tabpos="18">
|
||||
<Cursor position="5495" topLine="135" />
|
||||
<File name="../../source/shared_lib/sources/platform/common/base_thread.cpp" open="1" top="0" tabpos="7">
|
||||
<Cursor position="5175" topLine="120" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/common/platform_common.cpp" open="1" top="0" tabpos="14">
|
||||
<Cursor position="7636" topLine="291" />
|
||||
<File name="../../source/shared_lib/sources/platform/common/platform_common.cpp" open="0" top="0" tabpos="14">
|
||||
<Cursor position="3512" topLine="176" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/common/simple_threads.cpp" open="1" top="0" tabpos="21">
|
||||
<Cursor position="3961" topLine="82" />
|
||||
<File name="../../source/shared_lib/sources/platform/common/simple_threads.cpp" open="1" top="0" tabpos="4">
|
||||
<Cursor position="10781" topLine="238" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/miniupnpc/minisoap.c" open="1" top="0" tabpos="63">
|
||||
<File name="../../source/shared_lib/sources/platform/miniupnpc/minisoap.c" open="0" top="0" tabpos="22">
|
||||
<Cursor position="547" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/miniupnpc/miniupnpc.c" open="1" top="0" tabpos="64">
|
||||
<File name="../../source/shared_lib/sources/platform/miniupnpc/miniupnpc.c" open="0" top="0" tabpos="23">
|
||||
<Cursor position="506" topLine="39" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/miniupnpc/miniupnpcstrings.h" open="1" top="0" tabpos="62">
|
||||
<Cursor position="442" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/miniupnpc/testigddescparse.c" open="1" top="0" tabpos="71">
|
||||
<Cursor position="1193" topLine="32" />
|
||||
<File name="../../source/shared_lib/sources/platform/posix/ftpserver.cpp" open="1" top="0" tabpos="0">
|
||||
<Cursor position="0" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/posix/ircclient.cpp" open="1" top="0" tabpos="1">
|
||||
<Cursor position="0" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/posix/socket.cpp" open="1" top="0" tabpos="8">
|
||||
<Cursor position="1637" topLine="66" />
|
||||
<Cursor position="33763" topLine="1022" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/sdl/thread.cpp" open="1" top="0" tabpos="11">
|
||||
<File name="../../source/shared_lib/sources/platform/sdl/thread.cpp" open="0" top="0" tabpos="11">
|
||||
<Cursor position="2340" topLine="90" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/sdl/window.cpp" open="1" top="0" tabpos="17">
|
||||
<File name="../../source/shared_lib/sources/platform/sdl/window.cpp" open="0" top="0" tabpos="17">
|
||||
<Cursor position="12531" topLine="359" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/platform/sdl/window_gl.cpp" open="1" top="0" tabpos="16">
|
||||
<Cursor position="1087" topLine="14" />
|
||||
<File name="../../source/shared_lib/sources/platform/sdl/window_gl.cpp" open="0" top="0" tabpos="16">
|
||||
<Cursor position="1087" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp" open="1" top="0" tabpos="10">
|
||||
<File name="../../source/shared_lib/sources/sound/ds8/sound_player_ds8.cpp" open="0" top="0" tabpos="10">
|
||||
<Cursor position="490" topLine="0" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/sound/openal/sound_player_openal.cpp" open="1" top="0" tabpos="2">
|
||||
<File name="../../source/shared_lib/sources/sound/openal/sound_player_openal.cpp" open="0" top="0" tabpos="2">
|
||||
<Cursor position="8638" topLine="291" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/util/conversion.cpp" open="0" top="0" tabpos="6">
|
||||
<Cursor position="2757" topLine="112" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/util/profiler.cpp" open="1" top="0" tabpos="5">
|
||||
<File name="../../source/shared_lib/sources/util/profiler.cpp" open="0" top="0" tabpos="5">
|
||||
<Cursor position="2078" topLine="59" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/util/properties.cpp" open="1" top="0" tabpos="1">
|
||||
<File name="../../source/shared_lib/sources/util/properties.cpp" open="0" top="0" tabpos="1">
|
||||
<Cursor position="4900" topLine="115" />
|
||||
</File>
|
||||
<File name="../../source/shared_lib/sources/util/util.cpp" open="1" top="0" tabpos="3">
|
||||
<Cursor position="0" topLine="0" />
|
||||
<Cursor position="9094" topLine="273" />
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
@ -54,6 +54,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
|
||||
currentTechName_factionPreview="";
|
||||
currentFactionName_factionPreview="";
|
||||
ftpClientThread = NULL;
|
||||
|
||||
currentFactionLogo = "";
|
||||
factionTexture=NULL;
|
||||
|
@ -97,7 +98,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
int networkHeadPos=700;
|
||||
int networkPos=networkHeadPos-30;
|
||||
int xoffset=0;
|
||||
|
||||
|
||||
//state
|
||||
labelStatus.registerGraphicComponent(containerName,"labelStatus");
|
||||
labelStatus.init(350, networkHeadPos+30);
|
||||
|
@ -107,7 +108,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
labelInfo.init(30, networkHeadPos+30);
|
||||
labelInfo.setText("");
|
||||
labelInfo.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
|
||||
|
||||
//create
|
||||
buttonDisconnect.registerGraphicComponent(containerName,"buttonDisconnect");
|
||||
buttonDisconnect.init(450, 180, 125);
|
||||
|
@ -236,7 +237,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
labelTileset.registerGraphicComponent(containerName,"labelTileset");
|
||||
labelTileset.init(xoffset+350, mapHeadPos);
|
||||
labelTileset.setText(lang.get("Tileset"));
|
||||
|
||||
|
||||
|
||||
//tech Tree listBox
|
||||
//listBoxTechTree.init(700, 260, 150);
|
||||
|
@ -250,7 +251,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
labelTechTree.registerGraphicComponent(containerName,"labelTechTree");
|
||||
labelTechTree.init(xoffset+550, mapHeadPos);
|
||||
labelTechTree.setText(lang.get("TechTree"));
|
||||
|
||||
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//list boxes
|
||||
|
@ -291,15 +292,15 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
labelControl.registerGraphicComponent(containerName,"labelControl");
|
||||
labelControl.init(xoffset+210, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||
labelControl.setText(lang.get("Control"));
|
||||
|
||||
|
||||
labelRMultiplier.registerGraphicComponent(containerName,"labelRMultiplier");
|
||||
labelRMultiplier.init(xoffset+350, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||
//labelRMultiplier.setText(lang.get("RMultiplier"));
|
||||
|
||||
|
||||
labelFaction.registerGraphicComponent(containerName,"labelFaction");
|
||||
labelFaction.init(xoffset+430, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||
labelFaction.setText(lang.get("Faction"));
|
||||
|
||||
|
||||
labelTeam.registerGraphicComponent(containerName,"labelTeam");
|
||||
labelTeam.init(xoffset+590, setupPos, 60, GraphicListBox::defH, true);
|
||||
labelTeam.setText(lang.get("Team"));
|
||||
|
@ -347,7 +348,7 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
listBoxControls[i].setItems(controlItems);
|
||||
listBoxRMultiplier[i].setItems(rMultiplier);
|
||||
listBoxRMultiplier[i].setSelectedItemIndex(5);
|
||||
|
||||
|
||||
labelNetStatus[i].setText("V");
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -368,11 +369,35 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM
|
|||
//tileset listBox
|
||||
findDirs(config.getPathListForType(ptTilesets), tileSets);
|
||||
|
||||
|
||||
if(config.getBool("EnableFTPXfer") == true) {
|
||||
ClientInterface *clientInterface = networkManager.getClientInterface();
|
||||
string serverUrl = clientInterface->getServerIpAddress() + ":61358";
|
||||
|
||||
vector<string> mapPathList = config.getPathListForType(ptMaps);
|
||||
std::pair<string,string> mapsPath;
|
||||
if(mapPathList.size() > 0) {
|
||||
mapsPath.first = mapPathList[0];
|
||||
}
|
||||
if(mapPathList.size() > 1) {
|
||||
mapsPath.second = mapPathList[1];
|
||||
}
|
||||
|
||||
ftpClientThread = new FTPClientThread(serverUrl,mapsPath, this);
|
||||
ftpClientThread->start();
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
MenuStateConnectedGame::~MenuStateConnectedGame() {
|
||||
cleanupFactionTexture();
|
||||
|
||||
if(ftpClientThread != NULL) {
|
||||
ftpClientThread->shutdownAndWait();
|
||||
delete ftpClientThread;
|
||||
ftpClientThread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
@ -609,7 +634,7 @@ void MenuStateConnectedGame::render() {
|
|||
renderer.renderListBox(&listBoxFactions[i]);
|
||||
renderer.renderListBox(&listBoxTeams[i]);
|
||||
//renderer.renderLabel(&labelNetStatus[i]);
|
||||
|
||||
|
||||
if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) &&
|
||||
(labelNetStatus[i].getText() == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)) {
|
||||
renderer.renderButton(&grabSlotButton[i]);
|
||||
|
@ -676,7 +701,7 @@ void MenuStateConnectedGame::render() {
|
|||
}
|
||||
renderer.renderChatManager(&chatManager);
|
||||
renderer.renderConsole(&console,showFullConsole,true);
|
||||
|
||||
|
||||
}
|
||||
catch(const std::exception &ex) {
|
||||
char szBuf[1024]="";
|
||||
|
@ -866,7 +891,7 @@ void MenuStateConnectedGame::update() {
|
|||
|
||||
//process network messages
|
||||
if(clientInterface != NULL && clientInterface->isConnected()) {
|
||||
|
||||
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
if(chrono.getMillis() > 0) chrono.start();
|
||||
|
||||
|
@ -878,7 +903,7 @@ void MenuStateConnectedGame::update() {
|
|||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
vector<string> maps,tilesets,techtree;
|
||||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
||||
|
||||
|
||||
if(gameSettings == NULL) {
|
||||
throw runtime_error("gameSettings == NULL");
|
||||
}
|
||||
|
@ -906,11 +931,11 @@ void MenuStateConnectedGame::update() {
|
|||
}
|
||||
}
|
||||
listBoxTileset.setItems(tilesets);
|
||||
|
||||
|
||||
// techtree
|
||||
techtree.push_back(formatString(gameSettings->getTech()));
|
||||
listBoxTechTree.setItems(techtree);
|
||||
|
||||
|
||||
// factions
|
||||
bool hasFactions = true;
|
||||
if(currentFactionName != gameSettings->getTech())
|
||||
|
@ -923,7 +948,7 @@ void MenuStateConnectedGame::update() {
|
|||
// do this to process special faction types liek observers
|
||||
loadFactions(gameSettings,false);
|
||||
}
|
||||
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d, currentFactionName [%s]\n",__FILE__,__FUNCTION__,__LINE__,hasFactions,currentFactionName.c_str());
|
||||
|
||||
// map
|
||||
|
@ -937,11 +962,13 @@ void MenuStateConnectedGame::update() {
|
|||
maps.push_back(formatString(gameSettings->getMap()));
|
||||
}
|
||||
else {
|
||||
// try to get the map via ftp
|
||||
|
||||
maps.push_back("***missing***");
|
||||
}
|
||||
listBoxMap.setItems(maps);
|
||||
labelMapInfo.setText(mapInfo.desc);
|
||||
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// FogOfWar
|
||||
|
@ -954,7 +981,7 @@ void MenuStateConnectedGame::update() {
|
|||
listBoxFogOfWar.setSelectedItemIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Allow Observers
|
||||
if(gameSettings->getAllowObservers()) {
|
||||
listBoxAllowObservers.setSelectedItemIndex(1);
|
||||
|
@ -999,7 +1026,7 @@ void MenuStateConnectedGame::update() {
|
|||
listBoxFactions[i].setEditable(false);
|
||||
listBoxTeams[i].setEditable(false);
|
||||
}
|
||||
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(hasFactions == true) {
|
||||
|
@ -1021,7 +1048,7 @@ void MenuStateConnectedGame::update() {
|
|||
labelPlayerNames[slot].setText(gameSettings->getNetworkPlayerName(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(gameSettings->getFactionControl(i) == ctNetwork &&
|
||||
gameSettings->getThisFactionIndex() == i){
|
||||
// set my current slot to ctHuman
|
||||
|
@ -1035,7 +1062,7 @@ void MenuStateConnectedGame::update() {
|
|||
labelPlayerNames[slot].setText(gameSettings->getNetworkPlayerName(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
settingsReceivedFromServer=true;
|
||||
initialSettingsReceivedFromServer=true;
|
||||
|
||||
|
@ -1536,4 +1563,9 @@ void MenuStateConnectedGame::showMessageBox(const string &text, const string &he
|
|||
}
|
||||
}
|
||||
|
||||
void MenuStateConnectedGame::FTPClient_CallbackEvent(string mapFilename, FTP_Client_ResultType result) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
printf("Got FTP Callback for [%s] result = %d\n",mapFilename.c_str(),result);
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "main_menu.h"
|
||||
#include "chat_manager.h"
|
||||
#include "map_preview.h"
|
||||
#include "miniftpclient.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
namespace Glest { namespace Game {
|
||||
|
@ -31,7 +32,7 @@ enum JoinMenu {
|
|||
// class MenuStateConnectedGame
|
||||
// ===============================
|
||||
|
||||
class MenuStateConnectedGame: public MenuState {
|
||||
class MenuStateConnectedGame: public MenuState, public FTPClientCallbackInterface {
|
||||
private:
|
||||
GraphicButton buttonDisconnect;
|
||||
GraphicButton buttonPlayNow;
|
||||
|
@ -60,13 +61,13 @@ private:
|
|||
|
||||
GraphicLabel labelPathFinderType;
|
||||
GraphicListBox listBoxPathFinderType;
|
||||
|
||||
|
||||
GraphicLabel labelMapPlayerCount;
|
||||
GraphicListBox listBoxMapPlayerCount;
|
||||
|
||||
|
||||
GraphicLabel labelAdvanced;
|
||||
GraphicListBox listBoxAdvanced;
|
||||
|
||||
|
||||
|
||||
|
||||
GraphicListBox listBoxMap;
|
||||
|
@ -100,7 +101,7 @@ private:
|
|||
Console console;
|
||||
ChatManager chatManager;
|
||||
bool showFullConsole;
|
||||
|
||||
|
||||
string currentFactionName;
|
||||
string currentMap;
|
||||
JoinMenu returnMenuInfo;
|
||||
|
@ -108,11 +109,11 @@ private:
|
|||
time_t lastNetworkSendPing;
|
||||
int pingCount;
|
||||
bool initialSettingsReceivedFromServer;
|
||||
|
||||
|
||||
string lastMapDataSynchError;
|
||||
string lastTileDataSynchError;
|
||||
string lastTechtreeDataSynchError;
|
||||
|
||||
|
||||
int8 switchSetupRequestFlagType;
|
||||
string defaultPlayerName;
|
||||
|
||||
|
@ -132,9 +133,11 @@ private:
|
|||
std::string lastMissingMap;
|
||||
std::string lastMissingTechtree;
|
||||
std::string lastMissingTileSet;
|
||||
|
||||
|
||||
std::vector<std::string> tileSets;
|
||||
|
||||
FTPClientThread *ftpClientThread;
|
||||
|
||||
public:
|
||||
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||
|
@ -164,6 +167,7 @@ private:
|
|||
bool loadMapInfo(string file, MapInfo *mapInfo, bool loadMapPreview);
|
||||
void showMessageBox(const string &text, const string &header, bool toggle);
|
||||
|
||||
virtual void FTPClient_CallbackEvent(string mapFilename, FTP_Client_ResultType result);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <time.h>
|
||||
#include "util.h"
|
||||
#include "game_util.h"
|
||||
#include "miniftpserver.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
@ -67,6 +68,7 @@ ServerInterface::ServerInterface() {
|
|||
publishToMasterserverThread = NULL;
|
||||
lastMasterserverHeartbeatTime = 0;
|
||||
needToRepublishToMasterserver = false;
|
||||
ftpServer = NULL;
|
||||
|
||||
enabledThreadedClientCommandBroadcast = Config::getInstance().getBool("EnableThreadedClientCommandBroadcast","false");
|
||||
maxFrameCountLagAllowed = Config::getInstance().getInt("MaxFrameCountLagAllowed",intToStr(maxFrameCountLagAllowed).c_str());
|
||||
|
@ -83,6 +85,19 @@ ServerInterface::ServerInterface() {
|
|||
serverSocket.setBlock(false);
|
||||
//serverSocket.bind(Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str()));
|
||||
serverSocket.setBindPort(Config::getInstance().getInt("ServerPort",intToStr(GameConstants::serverPort).c_str()));
|
||||
|
||||
if(Config::getInstance().getBool("EnableFTPXfer") == true) {
|
||||
std::pair<string,string> mapsPath;
|
||||
vector<string> pathList = Config::getInstance().getPathListForType(ptMaps);
|
||||
if(pathList.size() > 0) {
|
||||
mapsPath.first = pathList[0];
|
||||
if(pathList.size() > 1) {
|
||||
mapsPath.second = pathList[1];
|
||||
}
|
||||
}
|
||||
ftpServer = new FTPServerThread(mapsPath);
|
||||
ftpServer->start();
|
||||
}
|
||||
}
|
||||
|
||||
ServerInterface::~ServerInterface() {
|
||||
|
@ -105,6 +120,12 @@ ServerInterface::~ServerInterface() {
|
|||
|
||||
close();
|
||||
|
||||
if(ftpServer != NULL) {
|
||||
ftpServer->shutdownAndWait();
|
||||
delete ftpServer;
|
||||
ftpServer = NULL;
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor,intToStr(__LINE__));
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
using std::vector;
|
||||
using Shared::Platform::ServerSocket;
|
||||
|
||||
namespace Shared { namespace PlatformCommon { class FTPServerThread; }}
|
||||
|
||||
//using Shared::PlatformCommon::FTPServerThread;
|
||||
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
// =====================================================
|
||||
|
@ -49,6 +53,8 @@ private:
|
|||
time_t lastMasterserverHeartbeatTime;
|
||||
bool needToRepublishToMasterserver;
|
||||
|
||||
Shared::PlatformCommon::FTPServerThread *ftpServer;
|
||||
|
||||
public:
|
||||
ServerInterface();
|
||||
virtual ~ServerInterface();
|
||||
|
|
|
@ -99,19 +99,20 @@ ENDIF()
|
|||
# glest lib
|
||||
|
||||
SET(DIRS_WITH_SRC
|
||||
platform/common
|
||||
platform/miniupnpc
|
||||
util
|
||||
feathery_ftp
|
||||
glew
|
||||
graphics
|
||||
graphics/gl
|
||||
lua
|
||||
map
|
||||
platform/common
|
||||
platform/miniupnpc
|
||||
sound
|
||||
sound/openal
|
||||
xml
|
||||
glew
|
||||
lua
|
||||
streflop
|
||||
streflop/libm_flt32_source
|
||||
map)
|
||||
streflop/libm_flt32_source
|
||||
util
|
||||
xml)
|
||||
|
||||
IF(APPLE)
|
||||
SET(DIRS_WITH_SRC ${DIRS_WITH_SRC} platform/sdl)
|
||||
|
@ -140,6 +141,8 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/libircclient
|
|||
IF(WIN32)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/posix/socket.cpp)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/posix/ircclient.cpp)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/posix/miniftpserver.cpp)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/posix/miniftpclient.cpp)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/sdl/gl_wrap.cpp)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/sdl/thread.cpp)
|
||||
SET(MG_SOURCE_FILES ${MG_SOURCE_FILES} ${PROJECT_SOURCE_DIR}/source/shared_lib/sources/platform/sdl/window.cpp)
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftp.h - ftp-server interface-header
|
||||
*
|
||||
* Contains all internal definitions and prototypes of feathery.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FTP_H_
|
||||
#define FTP_H_
|
||||
|
||||
|
||||
/**
|
||||
* @brief specifies the type of operation that is in progress
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
OP_NOP = 0, ///< no operation
|
||||
OP_RETR = 1, ///< RETR command
|
||||
OP_STOR = 2, ///< STOR command
|
||||
OP_LIST = 3 ///< LIST command
|
||||
}operation_E;
|
||||
|
||||
/**
|
||||
* @brief infos about a file/directory transmittion
|
||||
* @see ftpExecTransmission
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
operation_E op; ///< active transmission
|
||||
void* fsHandle; ///< file or directory handle of current transmission
|
||||
socket_t dataSocket; ///< data socket of current transmission
|
||||
uint32_t fileSize; ///< size of file to transmit
|
||||
|
||||
}transmission_S;
|
||||
|
||||
/**
|
||||
* @brief Data of a ftp session
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int open; ///< TRUE, if the session is open
|
||||
int authenticated; ///< TRUE, if user is authenticated via USER and PASS commands
|
||||
int userId; ///< id of the dedicated user account, is 0 until execution of USER command
|
||||
int rxBufWriteIdx; ///< currect write index of receive buffer rxBuf
|
||||
char rxBuf[LEN_RXBUF]; ///< receive buffer for ftp commands
|
||||
char workingDir[MAX_PATH_LEN]; ///< current working directory (absolute path which is relative to the root-path of the user account)
|
||||
ip_t remoteIp; ///< IP of connected ftp client
|
||||
port_t remotePort; ///< Port of connected ftp client for control connection
|
||||
port_t remoteDataPort; ///< Port of connected ftp client for data connection
|
||||
int passive; ///< TRUE, if passive-mode is activated via PSV command
|
||||
int binary; ///< TRUE, if binary-mode is active
|
||||
uint32_t timeLastCmd; ///< timestamp of last ftp activity (used for timeout generation)
|
||||
socket_t ctrlSocket; ///< socket for control connection
|
||||
socket_t passiveDataSocket; ///< listener socket for data connections in passive mode
|
||||
transmission_S activeTrans; ///< infos about a currently active file/directory-transmission
|
||||
|
||||
}ftpSession_S;
|
||||
|
||||
/**
|
||||
* @brief format in which a message is to be displayed
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MSG_NORMAL = 0, ///< normal message, no translation
|
||||
MSG_QUOTE = 1, ///< message will be displayed between doublequotes
|
||||
MSG_MULTILINE = 2 ///< message contains multiple lines
|
||||
}msgmode_E;
|
||||
|
||||
/**
|
||||
* @brief time-structure
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t year; ///< year 0000-9999
|
||||
uint8_t month; ///< month 1 - 12
|
||||
uint8_t day; ///< day 1 - 31
|
||||
uint8_t hour; ///< hour 0 - 23
|
||||
uint8_t minute; ///< minute 0 - 59
|
||||
uint8_t second; ///< second 0 - 59
|
||||
|
||||
}ftpTime_S;
|
||||
|
||||
/**
|
||||
* @brief type of a file
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
TYPE_FILE = 1, ///< regular file
|
||||
TYPE_DIR = 2, ///< directory
|
||||
TYPE_LINK = 4 ///< hard link
|
||||
|
||||
}ftpFileType_E;
|
||||
|
||||
/**
|
||||
* @brief infos about a file or directory similar to stat
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ftpFileType_E type; ///< filetype
|
||||
uint16_t mode; ///< access rights (currently unused)
|
||||
ftpTime_S cTime; ///< creation time (currently unused)
|
||||
ftpTime_S aTime; ///< last access time (currently unused)
|
||||
ftpTime_S mTime; ///< time of last modification
|
||||
uint32_t size; ///< size
|
||||
int links; ///< count of hard links
|
||||
char user[20]; ///< owner
|
||||
char group[20]; ///< group
|
||||
|
||||
}ftpPathInfo_S;
|
||||
|
||||
extern int ftpOpenSession(socket_t ctrlSocket, ip_t remoteIp, port_t remotePort);
|
||||
extern int ftpCloseSession(int id);
|
||||
extern ftpSession_S* ftpGetSession(int id);
|
||||
extern int ftpAuthSession(int id);
|
||||
extern const char* ftpGetRealPath(int id, const char* path, int normalize);
|
||||
extern int ftpChangeDir(int id, const char* path);
|
||||
extern void ftpOpenTransmission(int id, operation_E op, void* fsHandle, socket_t dataSocket, uint32_t fileSize);
|
||||
extern void ftpCloseTransmission(int id);
|
||||
extern int ftpGetActiveTransCnt(void);
|
||||
|
||||
extern int ftpFindAccount(const char* name);
|
||||
extern int ftpCheckPassword(int userId, const char* passw);
|
||||
extern int ftpCheckAccRights(int userId, int accRights);
|
||||
extern const char* ftpGetRoot(int userId, int* len);
|
||||
|
||||
extern int ftpSendMsg(msgmode_E mode, int sessionId, int ret, const char* msg);
|
||||
extern int ftpExecTransmission(int sessionId);
|
||||
extern void ftpParseCmd(int sessionId);
|
||||
|
||||
extern int ftpRemoveTrailingSlash(char* path);
|
||||
extern void ftpRemoveDoubleSlash(char* path);
|
||||
extern char* ftpMergePaths(char* dest, ...);
|
||||
extern uint32_t ftpGetUnixTime(void);
|
||||
extern char *ftpStrcpy(char *dest, const char *src);
|
||||
|
||||
|
||||
extern void ftpArchInit(void);
|
||||
extern void ftpArchCleanup(void);
|
||||
extern int ftpGetLocalTime(ftpTime_S *t);
|
||||
extern void* ftpOpenDir(const char* path);
|
||||
extern const char* ftpReadDir(void* dirHandle);
|
||||
extern int ftpCloseDir(void* dirHandle);
|
||||
extern int ftpStat(const char* path, ftpPathInfo_S *info);
|
||||
#if ANSI_FILE_IO
|
||||
# define ftpOpenFile fopen
|
||||
# define ftpCloseFile fclose
|
||||
# define ftpReadFile fread
|
||||
# define ftpWriteFile fwrite
|
||||
# define ftpRemoveFile remove
|
||||
#else
|
||||
extern void* ftpOpenFile(const char *filename, const char *mode);
|
||||
extern int ftpCloseFile(void *stream );
|
||||
extern int ftpReadFile(void *buffer, size_t size, size_t count, void *stream);
|
||||
extern int ftpWriteFile(const void *buffer, size_t size, size_t count, void *stream);
|
||||
extern int ftpRemoveFile(const char* path);
|
||||
#endif
|
||||
extern int ftpMakeDir(const char* path);
|
||||
extern int ftpRemoveDir(const char* path);
|
||||
extern int ftpCloseSocket(socket_t s);
|
||||
extern int ftpSend(socket_t s, const void *data, int len);
|
||||
extern int ftpReceive(socket_t s, void *data, int len);
|
||||
extern socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port);
|
||||
extern socket_t ftpAcceptDataConnection(socket_t listner);
|
||||
extern socket_t ftpCreateServerSocket(void);
|
||||
extern socket_t ftpAcceptServerConnection(socket_t server, ip_t *remoteIP, port_t *remotePort);
|
||||
extern int ftpTrackSocket(socket_t s);
|
||||
extern int ftpUntrackSocket(socket_t s);
|
||||
extern int ftpTestSocket(socket_t s);
|
||||
extern int ftpSelect(int poll);
|
||||
|
||||
#endif /* FTP_H_ */
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpConfig.h - Compile time server configuration
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FTPCONFIG_H_
|
||||
#define FTPCONFIG_H_
|
||||
|
||||
/**
|
||||
* @brief max. possible simultaneous FTP client connections
|
||||
*/
|
||||
#define MAX_CONNECTIONS 10
|
||||
|
||||
/**
|
||||
* @brief max. possible user accounts
|
||||
*/
|
||||
#define MAX_USERS 10
|
||||
|
||||
/**
|
||||
* @brief max. length of a user account name
|
||||
*/
|
||||
#define MAXLEN_USERNAME 10
|
||||
|
||||
/**
|
||||
* @brief max. length of a user account password
|
||||
*/
|
||||
#define MAXLEN_PASSWORD 10
|
||||
|
||||
/**
|
||||
* @brief session timeout in seconds
|
||||
*/
|
||||
#define SESSION_TIMEOUT 600
|
||||
|
||||
/**
|
||||
* @brief maximum length of a complete directory path
|
||||
*/
|
||||
#define MAX_PATH_LEN 260
|
||||
|
||||
/**
|
||||
* @brief Size of the scratch buffer
|
||||
*
|
||||
* The scratch buffer is used for
|
||||
* send / receive of files and directory listings
|
||||
*/
|
||||
#define LEN_SCRATCHBUF 1024
|
||||
|
||||
/**
|
||||
* @brief Size of the receive buffer for ftp commands
|
||||
*
|
||||
* Buffer must be big enough to hold a complete ftp command.
|
||||
* command (4) + space (1) + path (MAX_PATH_LEN) + quotes (2) + CRLF (2) + end of string (1)
|
||||
*/
|
||||
#define LEN_RXBUF (MAX_PATH_LEN + 10)
|
||||
|
||||
/**
|
||||
* @brief activates ftp extentions according to RFC 3659
|
||||
*/
|
||||
#define RFC3659 1
|
||||
|
||||
/**
|
||||
* @brief set to 1 to activate debug messages on stdout
|
||||
*/
|
||||
#define DBG_LOG 1
|
||||
|
||||
/**
|
||||
* @brief set to 1 if target-plattform supports ANSI-C file-IO functions
|
||||
*/
|
||||
#define ANSI_FILE_IO 1
|
||||
|
||||
#endif /* FTPCONFIG_H_ */
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpIfc.h - ftp-server interface-header
|
||||
*
|
||||
* All exported functions and constants are defined in this header. This is
|
||||
* the only header-file that a application which uses feathery shall include.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FTPIFC_H_
|
||||
#define FTPIFC_H_
|
||||
|
||||
|
||||
#define FTP_ACC_RD 1
|
||||
#define FTP_ACC_WR 2
|
||||
#define FTP_ACC_LS 4
|
||||
#define FTP_ACC_DIR 8
|
||||
#define FTP_ACC_FULL (FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int ftpCreateAccount(const char* name, const char* passw, const char* root, int accRights);
|
||||
int ftpStart(void);
|
||||
int ftpShutdown(void);
|
||||
void ftpExecute(void);
|
||||
int ftpState(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FTPIFC_H_ */
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpMessages.h - FTP-Server messages
|
||||
*
|
||||
* This header exports the in ftpMessges.c defined messages.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FTPMESSAGES_H_
|
||||
#define FTPMESSAGES_H_
|
||||
|
||||
extern const char ftpMsg000[];
|
||||
extern const char ftpMsg001[];
|
||||
extern const char ftpMsg002[];
|
||||
extern const char ftpMsg003[];
|
||||
extern const char ftpMsg004[];
|
||||
extern const char ftpMsg005[];
|
||||
extern const char ftpMsg006[];
|
||||
extern const char ftpMsg007[];
|
||||
extern const char ftpMsg008[];
|
||||
extern const char ftpMsg009[];
|
||||
extern const char ftpMsg010[];
|
||||
extern const char ftpMsg011[];
|
||||
extern const char ftpMsg012[];
|
||||
extern const char ftpMsg013[];
|
||||
extern const char ftpMsg014[];
|
||||
extern const char ftpMsg015[];
|
||||
extern const char ftpMsg016[];
|
||||
extern const char ftpMsg018[];
|
||||
extern const char ftpMsg019[];
|
||||
extern const char ftpMsg020[];
|
||||
extern const char ftpMsg021[];
|
||||
extern const char ftpMsg022[];
|
||||
extern const char ftpMsg023[];
|
||||
extern const char ftpMsg024[];
|
||||
extern const char ftpMsg025[];
|
||||
extern const char ftpMsg026[];
|
||||
extern const char ftpMsg027[];
|
||||
extern const char ftpMsg028[];
|
||||
extern const char ftpMsg029[];
|
||||
extern const char ftpMsg030[];
|
||||
extern const char ftpMsg031[];
|
||||
extern const char ftpMsg032[];
|
||||
extern const char ftpMsg033[];
|
||||
extern const char ftpMsg034[];
|
||||
extern const char ftpMsg035[];
|
||||
extern const char ftpMsg036[];
|
||||
extern const char ftpMsg037[];
|
||||
extern const char ftpMsg038[];
|
||||
extern const char ftpMsg039[];
|
||||
extern const char ftpMsg040[];
|
||||
|
||||
|
||||
#endif /* FTPMESSAGES_H_ */
|
|
@ -0,0 +1,63 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpTypes.h - global type definitions
|
||||
*
|
||||
* Definitions of fixed size integers an helper macros.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FTPTYPES_H_
|
||||
#define FTPTYPES_H_
|
||||
|
||||
|
||||
// if the compiler is c99 complient, we don't need to define our own types
|
||||
#if __STDC_VERSION__ == 199901L
|
||||
# include <stdint.h>
|
||||
#else
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
|
||||
#endif
|
||||
|
||||
typedef int socket_t;
|
||||
typedef uint32_t ip_t;
|
||||
typedef uint16_t port_t;
|
||||
|
||||
/**
|
||||
* @brief returns the number of elements of an array
|
||||
*/
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
/**
|
||||
* @brief defines functions/variables local to a module
|
||||
*/
|
||||
#define LOCAL static
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,62 @@
|
|||
// ==============================================================
|
||||
// This file is part of MegaGlest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2009-2010 Titus Tscharntke (info@titusgames.de) and
|
||||
// Mark Vejvoda (mark_vejvoda@hotmail.com)
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORMCOMMON_MINIFTPCLIENTTHREAD_H_
|
||||
#define _SHARED_PLATFORMCOMMON_MINIFTPCLIENTTHREAD_H_
|
||||
|
||||
#include "base_thread.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
// =====================================================
|
||||
// class FTPClientThread
|
||||
// =====================================================
|
||||
|
||||
enum FTP_Client_ResultType {
|
||||
ftp_crt_SUCCESS = 0,
|
||||
ftp_crt_FAIL = 1
|
||||
};
|
||||
|
||||
class FTPClientCallbackInterface {
|
||||
public:
|
||||
virtual void FTPClient_CallbackEvent(string mapFilename, FTP_Client_ResultType result) = 0;
|
||||
};
|
||||
|
||||
class FTPClientThread : public BaseThread
|
||||
{
|
||||
protected:
|
||||
string serverUrl;
|
||||
FTPClientCallbackInterface *pCBObject;
|
||||
std::pair<string,string> mapsPath;
|
||||
|
||||
Mutex mutexMapFileList;
|
||||
vector<string> mapFileList;
|
||||
void getMapFromServer(string mapFilename);
|
||||
|
||||
public:
|
||||
|
||||
FTPClientThread(string serverUrl, std::pair<string,string> mapsPath, FTPClientCallbackInterface *pCBObject);
|
||||
virtual void execute();
|
||||
virtual void signalQuit();
|
||||
virtual bool shutdownAndWait();
|
||||
|
||||
void addMapToRequests(string mapFilename);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,44 @@
|
|||
// ==============================================================
|
||||
// This file is part of MegaGlest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2009-2010 Titus Tscharntke (info@titusgames.de) and
|
||||
// Mark Vejvoda (mark_vejvoda@hotmail.com)
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
#ifndef _SHARED_PLATFORMCOMMON_MINIFTPSERVERTHREAD_H_
|
||||
#define _SHARED_PLATFORMCOMMON_MINIFTPSERVERTHREAD_H_
|
||||
|
||||
#include "base_thread.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
// =====================================================
|
||||
// class FTPServerThread
|
||||
// =====================================================
|
||||
|
||||
class FTPServerThread : public BaseThread
|
||||
{
|
||||
protected:
|
||||
std::pair<string,string> mapsPath;
|
||||
|
||||
public:
|
||||
|
||||
FTPServerThread(std::pair<string,string> mapsPath);
|
||||
virtual void execute();
|
||||
virtual void signalQuit();
|
||||
virtual bool shutdownAndWait();
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
|
@ -0,0 +1,177 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpAccount.c - User account handling
|
||||
*
|
||||
* User account management is based on username, password and
|
||||
* access-rights. An account can be created with the function
|
||||
* ftpCreateAccount.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief User account data
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char name[MAXLEN_USERNAME]; ///< user name
|
||||
char passw[MAXLEN_PASSWORD]; ///< password of the account
|
||||
char ftpRoot[MAX_PATH_LEN]; ///< root path of the user account on the server
|
||||
int ftpRootLen; ///< length of ftpRoot
|
||||
int accRights; ///< access rights of a account
|
||||
|
||||
}ftpUserAccount_S;
|
||||
|
||||
/**
|
||||
* @brief Array which holds all registered user accounts
|
||||
*/
|
||||
LOCAL ftpUserAccount_S ftpUsers[MAX_USERS];
|
||||
|
||||
/**
|
||||
* @brief Creates a new user account
|
||||
*
|
||||
* The translated path depends on the current working directory of the
|
||||
* session and the root path of the session. In addition the path will
|
||||
* be normalized.
|
||||
* @todo normalize root and check if normalized path really exists
|
||||
*
|
||||
* @param name user name
|
||||
* @param passw account password
|
||||
* @param root root directory of the account
|
||||
* @param acc access rights, can be any combination of the following flags:
|
||||
* - FTP_ACC_RD read access
|
||||
* - FTP_ACC_WR write access
|
||||
* - FTP_ACC_LS access to directory listing
|
||||
* - FTP_ACC_DIR changing of working dir allowed
|
||||
*
|
||||
* @return 0 on success; -1 if MAX_USERS is reached
|
||||
*/
|
||||
int ftpCreateAccount(const char* name, const char* passw, const char* root, int acc)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = ftpFindAccount(name); // check if account already exists
|
||||
if(n > 0)
|
||||
{
|
||||
ftpUsers[n - 1].name[0] = '\0'; // delete account
|
||||
}
|
||||
|
||||
for(n = 0; n < MAX_USERS; n++)
|
||||
{
|
||||
if(ftpUsers[n].name[0] == '\0')
|
||||
{
|
||||
strncpy(ftpUsers[n].name, name, MAXLEN_USERNAME);
|
||||
strncpy(ftpUsers[n].passw, passw, MAXLEN_PASSWORD);
|
||||
strncpy(ftpUsers[n].ftpRoot, root, MAX_PATH_LEN);
|
||||
ftpUsers[n].ftpRootLen = strlen(root);
|
||||
ftpUsers[n].accRights = acc;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Return the account id for a user name
|
||||
*
|
||||
* The function searches ftpUsers for the passed user name.
|
||||
* The returned account id is the index + 1 in ftpUsers.
|
||||
*
|
||||
* @param name user name
|
||||
*
|
||||
* @return 0 if user is not found; 1 to MAX_USERS+1 if user is found
|
||||
*/
|
||||
int ftpFindAccount(const char* name)
|
||||
{
|
||||
int n;
|
||||
|
||||
if(name[0] != '\0')
|
||||
for(n = 0; n < MAX_USERS; n++)
|
||||
if(!strncmp(ftpUsers[n].name, name, MAXLEN_USERNAME))
|
||||
return n + 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks the password of a user account
|
||||
*
|
||||
* Compares the passed password to the saved password in ftpUsers
|
||||
*
|
||||
* @param userId user account id
|
||||
* @param passw password
|
||||
*
|
||||
* @return - 0: password is correct
|
||||
* - -1: invalid user account id
|
||||
* - else: incorrect password
|
||||
*/
|
||||
int ftpCheckPassword(int userId, const char* passw)
|
||||
{
|
||||
if(!userId)
|
||||
return -1;
|
||||
else if(ftpUsers[userId - 1].passw[0] == '\0')
|
||||
return 0;
|
||||
else
|
||||
return strncmp(ftpUsers[userId - 1].passw, passw, MAXLEN_PASSWORD);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if the account has the needed rights
|
||||
*
|
||||
* Compares the passed access rights to the saved rights in ftpUsers
|
||||
*
|
||||
* @param userId user account id
|
||||
* @param accRights needed access rights
|
||||
*
|
||||
* @return - 0: the needed access rights are fulfilled
|
||||
* - -1: invalid user account id
|
||||
*/
|
||||
int ftpCheckAccRights(int userId, int accRights)
|
||||
{
|
||||
if(!userId)
|
||||
return -1;
|
||||
|
||||
if((ftpUsers[userId - 1].accRights & accRights) == accRights)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the root directory of a account
|
||||
*
|
||||
* @param userId user account id
|
||||
* @param len length of the returned path
|
||||
*
|
||||
* @return root directory name or NULL if the user account id is invalid
|
||||
*/
|
||||
const char* ftpGetRoot(int userId, int* len)
|
||||
{
|
||||
if(!userId)
|
||||
return NULL;
|
||||
if(len)
|
||||
*len = ftpUsers[userId - 1].ftpRootLen;
|
||||
|
||||
return ftpUsers[userId - 1].ftpRoot;
|
||||
}
|
|
@ -0,0 +1,939 @@
|
|||
/* FEATHERY FTP-Server
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
* <https://sourceforge.net/projects/feathery>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
DECLARATIVE SPECIFICATIONS
|
||||
|
||||
5.1. MINIMUM IMPLEMENTATION
|
||||
|
||||
In order to make FTP workable without needless error messages, the
|
||||
following minimum implementation is required for all servers:
|
||||
|
||||
TYPE - ASCII Non-print
|
||||
MODE - Stream
|
||||
STRUCTURE - File, Record
|
||||
COMMANDS - USER, QUIT, PORT,
|
||||
TYPE, MODE, STRU,
|
||||
for the default values
|
||||
RETR, STOR,
|
||||
NOOP.
|
||||
|
||||
The default values for transfer parameters are:
|
||||
|
||||
TYPE - ASCII Non-print
|
||||
MODE - Stream
|
||||
STRU - File
|
||||
|
||||
All hosts must accept the above as the standard defaults.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
#include "ftpIfc.h"
|
||||
#include "ftpMessages.h"
|
||||
|
||||
|
||||
LOCAL uint8_t scratchBuf[LEN_SCRATCHBUF];
|
||||
|
||||
int ftpSendMsg(msgmode_E mode, int sessionId, int ret, const char* msg)
|
||||
{
|
||||
int sentlen = 0;
|
||||
int len = strlen(msg);
|
||||
char buf[6];
|
||||
|
||||
if(mode == MSG_QUOTE)
|
||||
{
|
||||
sprintf((char*)buf, "%03d \"", ret);
|
||||
sentlen += ftpSend(ftpGetSession(sessionId)->ctrlSocket, buf, 5);
|
||||
sentlen += ftpSend(ftpGetSession(sessionId)->ctrlSocket, msg, len);
|
||||
sentlen += ftpSend(ftpGetSession(sessionId)->ctrlSocket, "\"\r\n", 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf((char*)buf, "%03d ", ret);
|
||||
sentlen += ftpSend(ftpGetSession(sessionId)->ctrlSocket, buf, 4);
|
||||
sentlen += ftpSend(ftpGetSession(sessionId)->ctrlSocket, msg, len);
|
||||
sentlen += ftpSend(ftpGetSession(sessionId)->ctrlSocket, "\r\n", 2);
|
||||
}
|
||||
|
||||
#if DBG_LOG
|
||||
printf("%02d <-- %s%s\n", sessionId, buf, msg);
|
||||
#endif
|
||||
|
||||
return sentlen;
|
||||
}
|
||||
|
||||
int ftpExecTransmission(int sessionId)
|
||||
{
|
||||
int finished = FALSE;
|
||||
int len;
|
||||
ftpSession_S *pSession = ftpGetSession(sessionId);
|
||||
transmission_S *pTrans = &pSession->activeTrans;
|
||||
int rxLen;
|
||||
|
||||
|
||||
pSession->timeLastCmd = ftpGetUnixTime();
|
||||
switch(pTrans->op)
|
||||
{
|
||||
case OP_RETR:
|
||||
len = ftpReadFile(scratchBuf, 1, LEN_SCRATCHBUF, pTrans->fsHandle);
|
||||
if(len > 0)
|
||||
{
|
||||
pTrans->fileSize -= len;
|
||||
if(ftpSend(pTrans->dataSocket, scratchBuf, len))
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 426, ftpMsg000);
|
||||
finished = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 451, ftpMsg001);
|
||||
finished = TRUE;
|
||||
}
|
||||
|
||||
if(pTrans->fileSize == 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 226, ftpMsg002);
|
||||
finished = TRUE;
|
||||
}
|
||||
break;
|
||||
case OP_STOR:
|
||||
rxLen = 0;
|
||||
do
|
||||
{
|
||||
len = ftpReceive(pTrans->dataSocket, &scratchBuf[rxLen], LEN_SCRATCHBUF - rxLen);
|
||||
|
||||
if(len <= 0)
|
||||
break;
|
||||
|
||||
rxLen += len;
|
||||
}while(rxLen < LEN_SCRATCHBUF);
|
||||
|
||||
if(rxLen > 0)
|
||||
{
|
||||
if(ftpWriteFile(scratchBuf, 1, rxLen, pTrans->fsHandle) != rxLen)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 451, ftpMsg001);
|
||||
finished = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if(len <= 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 226, ftpMsg003);
|
||||
finished = TRUE;
|
||||
}
|
||||
|
||||
break;
|
||||
case OP_LIST:
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(finished)
|
||||
{
|
||||
ftpCloseTransmission(sessionId);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdUser(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 331, ftpMsg004);
|
||||
ftpGetSession(sessionId)->userId = ftpFindAccount(args);
|
||||
return 0;
|
||||
}
|
||||
LOCAL int ftpCmdPass(int sessionId, const char* args, int len)
|
||||
{
|
||||
if(!ftpCheckPassword(ftpGetSession(sessionId)->userId, args))
|
||||
{
|
||||
ftpAuthSession(sessionId);
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 230, ftpMsg005);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpGetSession(sessionId)->userId = 0;
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 530, ftpMsg006);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
LOCAL int ftpCmdSyst(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 215, "UNIX Type: L8");
|
||||
|
||||
return 0;
|
||||
}
|
||||
LOCAL int ftpCmdPort(int sessionId, const char* args, int len)
|
||||
{
|
||||
char clientIp[16];
|
||||
uint16_t clientPort;
|
||||
|
||||
int commaCnt = 0;
|
||||
int n;
|
||||
char* p;
|
||||
|
||||
for(n = 0; args[n] != '\0'; n++)
|
||||
{
|
||||
if(commaCnt <= 3) // Ip-Adresse
|
||||
{
|
||||
if(args[n] == ',')
|
||||
{
|
||||
commaCnt++;
|
||||
if(commaCnt < 4)
|
||||
clientIp[n] = '.';
|
||||
else
|
||||
clientIp[n] = '\0';
|
||||
}
|
||||
else
|
||||
clientIp[n] = args[n];
|
||||
}
|
||||
else // Port-Nummer
|
||||
{
|
||||
p = (char*)&args[n];
|
||||
clientPort = (uint16_t)(strtoul(p, &p, 0) << 8);
|
||||
p++;
|
||||
clientPort |= strtoul(p, &p, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO Derzeit wird die übergebene IP nicht beachtet, sondern nur die IP des Control-Sockets verwendet
|
||||
clientIp[0] = clientIp[0];
|
||||
if(ftpGetSession(sessionId)->passiveDataSocket >= 0)
|
||||
{
|
||||
ftpCloseSocket(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
ftpGetSession(sessionId)->passiveDataSocket = -1;
|
||||
}
|
||||
ftpGetSession(sessionId)->remoteDataPort = clientPort;
|
||||
ftpGetSession(sessionId)->passive = FALSE;
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 200, ftpMsg007);
|
||||
|
||||
return 0;
|
||||
}
|
||||
LOCAL int ftpCmdNoop(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 200, ftpMsg008);
|
||||
|
||||
return 0;
|
||||
}
|
||||
LOCAL int ftpCmdQuit(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 221, ftpMsg009);
|
||||
return -1;
|
||||
|
||||
}
|
||||
LOCAL int ftpCmdAbor(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpCloseTransmission(sessionId);
|
||||
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 226, ftpMsg040);
|
||||
return 0;
|
||||
|
||||
}
|
||||
#define ALL 0x80
|
||||
#define LIST 1
|
||||
#define NLST 2
|
||||
#define MLST 4
|
||||
#define MLSD 8
|
||||
LOCAL int sendListing(socket_t dataSocket, int sessionId, const char* path, int format)
|
||||
{
|
||||
void *dir;
|
||||
const char monName[12][4] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
|
||||
dir = ftpOpenDir(path);
|
||||
if(dir)
|
||||
{
|
||||
const char* dirEntry;
|
||||
int len;
|
||||
int err = 0;
|
||||
ftpTime_S currTime = {0};
|
||||
ftpPathInfo_S fileInfo;
|
||||
|
||||
ftpGetLocalTime(&currTime);
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 150, ftpMsg010);
|
||||
|
||||
#if DBG_LOG
|
||||
printf("about to read dir contents [%s]\n", path);
|
||||
#endif
|
||||
|
||||
int haveAnySuccessfulFiles = 0;
|
||||
while((dirEntry = ftpReadDir(dir)) != NULL)
|
||||
{
|
||||
char * realPath = ftpGetRealPath(sessionId, dirEntry, FALSE);
|
||||
int statResult = ftpStat(realPath, &fileInfo);
|
||||
#if DBG_LOG
|
||||
printf("ftpGetRealPath() returned [%s] stat() = %d\n", realPath, statResult);
|
||||
#endif
|
||||
|
||||
if(statResult == 0)
|
||||
{
|
||||
if((format & ALL) == 0)
|
||||
{
|
||||
if(dirEntry[0] == '.')
|
||||
continue;
|
||||
}
|
||||
if(format & LIST)
|
||||
{
|
||||
switch(fileInfo.type)
|
||||
{
|
||||
default:
|
||||
case TYPE_FILE:
|
||||
scratchBuf[0] = '-';
|
||||
break;
|
||||
case TYPE_DIR:
|
||||
scratchBuf[0] = 'd';
|
||||
break;
|
||||
case TYPE_LINK:
|
||||
scratchBuf[0] = 'l';
|
||||
break;
|
||||
}
|
||||
|
||||
if(currTime.year == fileInfo.mTime.year)
|
||||
{
|
||||
len = sprintf((char*)&scratchBuf[1], "rwxrwxrwx %4u %-8s %-8s %8u %s %02d %02d:%02d %s\r\n",
|
||||
fileInfo.links,
|
||||
fileInfo.user,
|
||||
fileInfo.group,
|
||||
fileInfo.size,
|
||||
monName[fileInfo.mTime.month - 1],
|
||||
fileInfo.mTime.day,
|
||||
fileInfo.mTime.hour,
|
||||
fileInfo.mTime.minute,
|
||||
dirEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = sprintf((char*)&scratchBuf[1], "rwxrwxrwx %4u %-8s %-8s %8u %s %02d %5d %s\r\n",
|
||||
fileInfo.links,
|
||||
fileInfo.user,
|
||||
fileInfo.group,
|
||||
fileInfo.size,
|
||||
monName[fileInfo.mTime.month - 1],
|
||||
fileInfo.mTime.day,
|
||||
fileInfo.mTime.year,
|
||||
dirEntry);
|
||||
}
|
||||
ftpSend(dataSocket, scratchBuf, len + 1);
|
||||
haveAnySuccessfulFiles = 1;
|
||||
}
|
||||
else if(format & NLST)
|
||||
{
|
||||
len = sprintf((char*)scratchBuf, "%s\r\n", dirEntry);
|
||||
ftpSend(dataSocket, scratchBuf, len);
|
||||
haveAnySuccessfulFiles = 1;
|
||||
}
|
||||
else if(format & MLSD)
|
||||
{
|
||||
if(!strcmp("..", dirEntry))
|
||||
len = sprintf((char*)scratchBuf, "Type=pdir");
|
||||
else
|
||||
{
|
||||
switch(fileInfo.type)
|
||||
{
|
||||
default:
|
||||
case TYPE_FILE:
|
||||
len = sprintf((char*)scratchBuf, "Type=file");
|
||||
break;
|
||||
case TYPE_DIR:
|
||||
len = sprintf((char*)scratchBuf, "Type=dir");
|
||||
break;
|
||||
case TYPE_LINK:
|
||||
len = sprintf((char*)scratchBuf, "Type=OS.unix=slink");
|
||||
break;
|
||||
}
|
||||
}
|
||||
ftpSend(dataSocket, scratchBuf, len);
|
||||
len = sprintf((char*)scratchBuf, ";Size=%u;Modify=%04d%02d%02d%02d%02d%02d;Perm=r; %s\r\n",
|
||||
fileInfo.size,
|
||||
fileInfo.mTime.year,
|
||||
fileInfo.mTime.month,
|
||||
fileInfo.mTime.day,
|
||||
fileInfo.mTime.hour,
|
||||
fileInfo.mTime.minute,
|
||||
fileInfo.mTime.second,
|
||||
dirEntry);
|
||||
ftpSend(dataSocket, scratchBuf, len);
|
||||
haveAnySuccessfulFiles = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
ftpCloseDir(dir);
|
||||
if(err && haveAnySuccessfulFiles == 0)
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 451, ftpMsg039);
|
||||
else
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 226, ftpMsg013);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DBG_LOG
|
||||
printf("opendir [%s] returned errno: %#x\n", path,errno);
|
||||
#endif
|
||||
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 451, ftpMsg038);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdList(int sessionId, const char* args, int len)
|
||||
{
|
||||
const char* realPath;
|
||||
socket_t s;
|
||||
//#### Funktioniert nicht wenn Pfad übergeben wird
|
||||
/* if(args[0] != '\0')
|
||||
{
|
||||
if(args[0] != '-')
|
||||
realPath = ftpGetRealPath(sessionId, args);
|
||||
}
|
||||
else*/
|
||||
realPath = ftpGetRealPath(sessionId, ftpGetSession(sessionId)->workingDir, TRUE);
|
||||
|
||||
if(ftpGetSession(sessionId)->passive == FALSE)
|
||||
{
|
||||
s = ftpEstablishDataConnection(FALSE, &ftpGetSession(sessionId)->remoteIp, &ftpGetSession(sessionId)->remoteDataPort);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg011);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = ftpAcceptDataConnection(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sendListing(s, sessionId, realPath, LIST);
|
||||
ftpCloseSocket(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdNlst(int sessionId, const char* args, int len)
|
||||
{
|
||||
//#### -List kann auch Argumente haben
|
||||
const char* realPath;
|
||||
socket_t s;
|
||||
|
||||
/* if(pfad übergeben)
|
||||
realPath = ftpGetRealPath(sessionId, args);
|
||||
else*/
|
||||
realPath = ftpGetRealPath(sessionId, ftpGetSession(sessionId)->workingDir, TRUE);
|
||||
|
||||
if(ftpGetSession(sessionId)->passive == FALSE)
|
||||
{
|
||||
s = ftpEstablishDataConnection(FALSE, &ftpGetSession(sessionId)->remoteIp, &ftpGetSession(sessionId)->remoteDataPort);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg011);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = ftpAcceptDataConnection(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sendListing(s, sessionId, realPath, NLST);
|
||||
ftpCloseSocket(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdRetr(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpPathInfo_S fileInfo;
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
socket_t s;
|
||||
void *fp;
|
||||
|
||||
if(ftpStat(realPath, &fileInfo) || (fileInfo.type != TYPE_FILE)) // file accessible?
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg032);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(ftpGetSession(sessionId)->passive == FALSE)
|
||||
{
|
||||
s = ftpEstablishDataConnection(FALSE, &ftpGetSession(sessionId)->remoteIp, &ftpGetSession(sessionId)->remoteDataPort);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg011);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = ftpAcceptDataConnection(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 150, ftpMsg014);
|
||||
|
||||
fp = ftpOpenFile(realPath, "rb");
|
||||
if(fp)
|
||||
{
|
||||
ftpOpenTransmission(sessionId, OP_RETR, fp, s, fileInfo.size);
|
||||
ftpExecTransmission(sessionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 451, ftpMsg015);
|
||||
ftpCloseSocket(s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdStor(int sessionId, const char* args, int len)
|
||||
{
|
||||
socket_t s;
|
||||
void* fp;
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
|
||||
if(ftpGetSession(sessionId)->passive == FALSE)
|
||||
{
|
||||
s = ftpEstablishDataConnection(FALSE, &ftpGetSession(sessionId)->remoteIp, &ftpGetSession(sessionId)->remoteDataPort);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg011);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = ftpAcceptDataConnection(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 150, ftpMsg016);
|
||||
|
||||
fp = ftpOpenFile(realPath, "wb");
|
||||
if(fp)
|
||||
{
|
||||
ftpOpenTransmission(sessionId, OP_STOR, fp, s, 0);
|
||||
ftpExecTransmission(sessionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 451, ftpMsg015);
|
||||
ftpCloseSocket(s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdDele(int sessionId, const char* args, int len)
|
||||
{
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
if(ftpRemoveFile(realPath))
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 450, ftpMsg018);
|
||||
else
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 250, ftpMsg019);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdMkd(int sessionId, const char* args, int len)
|
||||
{
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
if(ftpMakeDir(realPath))
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg020);
|
||||
else
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 250, ftpMsg021);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdRmd(int sessionId, const char* args, int len)
|
||||
{
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
if(ftpRemoveDir(realPath))
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg022);
|
||||
else
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 250, ftpMsg023);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdPwd(int sessionId, const char* args, int len)
|
||||
{
|
||||
if(ftpGetSession(sessionId)->workingDir[0])
|
||||
ftpSendMsg(MSG_QUOTE, sessionId, 257, ftpGetSession(sessionId)->workingDir);
|
||||
else
|
||||
ftpSendMsg(MSG_QUOTE, sessionId, 257, "/");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdCwd(int sessionId, const char* args, int len)
|
||||
{
|
||||
if(ftpChangeDir(sessionId, args) == 0)
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 250, ftpMsg024);
|
||||
else
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg025);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdType(int sessionId, const char* args, int len)
|
||||
{
|
||||
switch(args[0])
|
||||
{
|
||||
case 'I':
|
||||
case 'i':
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 200, ftpMsg026);
|
||||
ftpGetSession(sessionId)->binary = TRUE;
|
||||
break;
|
||||
case 'A':
|
||||
case 'a':
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 200, ftpMsg027);
|
||||
ftpGetSession(sessionId)->binary = FALSE;
|
||||
break;
|
||||
default:
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 504, ftpMsg028);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdPasv(int sessionId, const char* args, int len)
|
||||
{
|
||||
uint16_t port;
|
||||
uint32_t ip;
|
||||
char str[50];
|
||||
socket_t s;
|
||||
|
||||
if(ftpGetSession(sessionId)->passiveDataSocket >= 0)
|
||||
{
|
||||
ftpCloseSocket(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
ftpGetSession(sessionId)->passiveDataSocket = -1;
|
||||
}
|
||||
s = ftpEstablishDataConnection(TRUE, &ip, &port);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
ftpGetSession(sessionId)->passiveDataSocket = s;
|
||||
sprintf(str, "%s (%d,%d,%d,%d,%d,%d)",
|
||||
ftpMsg029,
|
||||
(ip >> 24) & 0xFF,
|
||||
(ip >> 16) & 0xFF,
|
||||
(ip >> 8) & 0xFF,
|
||||
ip & 0xFF,
|
||||
(port >> 8) & 0xFF,
|
||||
port & 0xFF);
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 227, str);
|
||||
ftpGetSession(sessionId)->passive = TRUE;
|
||||
return 0;
|
||||
}
|
||||
LOCAL int ftpCmdCdup(int sessionId, const char* args, int len)
|
||||
{
|
||||
return ftpCmdCwd(sessionId, "..", 2);
|
||||
}
|
||||
LOCAL int ftpCmdStru(int sessionId, const char* args, int len)
|
||||
{
|
||||
switch(args[0])
|
||||
{
|
||||
case 'F':
|
||||
case 'f':
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 200, ftpMsg030);
|
||||
break;
|
||||
default:
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 504, ftpMsg031);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if RFC3659
|
||||
LOCAL int ftpCmdSize(int sessionId, const char* args, int len)
|
||||
{
|
||||
int ret;
|
||||
char str[12];
|
||||
ftpPathInfo_S fileInfo;
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
|
||||
ret = ftpStat(realPath, &fileInfo);
|
||||
if(ret)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg032);
|
||||
return 2;
|
||||
}
|
||||
|
||||
sprintf(str, "%d", fileInfo.size);
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 213, str);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdMdtm(int sessionId, const char* args, int len)
|
||||
{
|
||||
int ret;
|
||||
char str[15];
|
||||
ftpPathInfo_S fileInfo;
|
||||
const char* realPath = ftpGetRealPath(sessionId, args, TRUE);
|
||||
|
||||
ret = ftpStat(realPath, &fileInfo);
|
||||
if(ret)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg032);
|
||||
return 2;
|
||||
}
|
||||
|
||||
sprintf(str, "%04d%02d%02d%02d%02d%02d", fileInfo.mTime.year,
|
||||
fileInfo.mTime.month,
|
||||
fileInfo.mTime.day,
|
||||
fileInfo.mTime.hour,
|
||||
fileInfo.mTime.minute,
|
||||
fileInfo.mTime.second);
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 213, str);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOCAL int ftpCmdMlst(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, "MLST command not implemented");
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*LOCAL int ftpCmdMlsd(int sessionId, const char* args, int len)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, "MLSD command not implemented");
|
||||
|
||||
return 0;
|
||||
}*/
|
||||
LOCAL int ftpCmdMlsd(int sessionId, const char* args, int len)
|
||||
{
|
||||
const char* realPath;
|
||||
socket_t s;
|
||||
//#### Funktioniert nicht wenn Pfad übergeben wird
|
||||
/* if(args[0] != '\0')
|
||||
{
|
||||
if(args[0] != '-')
|
||||
realPath = ftpGetRealPath(sessionId, args);
|
||||
}
|
||||
else*/
|
||||
realPath = ftpGetRealPath(sessionId, ftpGetSession(sessionId)->workingDir, TRUE);
|
||||
|
||||
if(ftpGetSession(sessionId)->passive == FALSE)
|
||||
{
|
||||
s = ftpEstablishDataConnection(FALSE, &ftpGetSession(sessionId)->remoteIp, &ftpGetSession(sessionId)->remoteDataPort);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg011);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s = ftpAcceptDataConnection(ftpGetSession(sessionId)->passiveDataSocket);
|
||||
if(s < 0)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 425, ftpMsg012);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
sendListing(s, sessionId, realPath, MLSD);
|
||||
ftpCloseSocket(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char cmdToken[5]; ///< command-string
|
||||
int tokLen; ///< len of cmdToken
|
||||
int neededRights; ///< required access rights for executing the command
|
||||
int needLogin; ///< if TRUE, command needs successful authentication via USER and PASS
|
||||
int reportFeat; ///< if TRUE, command is reported via FEAT
|
||||
int duringTransfer; ///< if TRUE, command can be executed during a file transfer
|
||||
int (*handler)(int, const char*, int); ///< handler function
|
||||
}ftpCommand_S;
|
||||
|
||||
static const ftpCommand_S cmds[] = {
|
||||
{"USER", 4, 0, FALSE, FALSE, FALSE, ftpCmdUser},
|
||||
{"PASS", 4, 0, FALSE, FALSE, FALSE, ftpCmdPass},
|
||||
{"SYST", 4, 0, TRUE, FALSE, FALSE, ftpCmdSyst},
|
||||
{"PORT", 4, 0, TRUE, FALSE, FALSE, ftpCmdPort},
|
||||
{"NOOP", 4, 0, TRUE, FALSE, FALSE, ftpCmdNoop},
|
||||
{"QUIT", 4, 0, FALSE, FALSE, TRUE, ftpCmdQuit},
|
||||
{"ABOR", 4, 0, FALSE, FALSE, TRUE, ftpCmdAbor},
|
||||
{"LIST", 4, FTP_ACC_LS, TRUE, FALSE, FALSE, ftpCmdList},
|
||||
{"NLST", 4, FTP_ACC_LS, TRUE, FALSE, FALSE, ftpCmdNlst},
|
||||
{"PWD", 3, FTP_ACC_RD, TRUE, FALSE, FALSE, ftpCmdPwd},
|
||||
{"XPWD", 4, FTP_ACC_DIR, TRUE, FALSE, FALSE, ftpCmdPwd},
|
||||
{"TYPE", 4, 0, TRUE, FALSE, FALSE, ftpCmdType},
|
||||
{"PASV", 4, 0, TRUE, FALSE, FALSE, ftpCmdPasv},
|
||||
{"CWD", 3, FTP_ACC_DIR, TRUE, FALSE, FALSE, ftpCmdCwd},
|
||||
{"CDUP", 4, FTP_ACC_DIR, TRUE, FALSE, FALSE, ftpCmdCdup},
|
||||
{"STRU", 4, 0, TRUE, FALSE, FALSE, ftpCmdStru},
|
||||
{"RETR", 4, FTP_ACC_RD, TRUE, FALSE, FALSE, ftpCmdRetr},
|
||||
{"STOR", 4, FTP_ACC_WR, TRUE, FALSE, FALSE, ftpCmdStor},
|
||||
{"DELE", 4, FTP_ACC_WR, TRUE, FALSE, FALSE, ftpCmdDele},
|
||||
{"MKD" , 3, FTP_ACC_WR, TRUE, FALSE, FALSE, ftpCmdMkd},
|
||||
{"XMKD", 4, FTP_ACC_WR, TRUE, FALSE, FALSE, ftpCmdMkd},
|
||||
{"RMD" , 3, FTP_ACC_WR, TRUE, FALSE, FALSE, ftpCmdRmd},
|
||||
{"XRMD", 4, FTP_ACC_WR, TRUE, FALSE, FALSE, ftpCmdRmd},
|
||||
#if RFC3659
|
||||
{"SIZE", 4, FTP_ACC_RD, TRUE, TRUE, FALSE, ftpCmdSize},
|
||||
{"MDTM", 4, FTP_ACC_RD, TRUE, TRUE, FALSE, ftpCmdMdtm},
|
||||
{"MLST", 4, FTP_ACC_RD, TRUE, TRUE, FALSE, ftpCmdMlst},
|
||||
{"MLSD", 4, FTP_ACC_LS, TRUE, TRUE, FALSE, ftpCmdMlsd}
|
||||
#endif
|
||||
};
|
||||
|
||||
int execFtpCmd(int sessionId, const char* cmd, int cmdlen)
|
||||
{
|
||||
int n;
|
||||
int ret = 0;
|
||||
|
||||
ftpSession_S *pSession = ftpGetSession(sessionId);
|
||||
|
||||
|
||||
for(n = 0; n < ARRAY_SIZE(cmds); n++)
|
||||
{
|
||||
if(!strncmp(cmds[n].cmdToken, cmd, cmds[n].tokLen))
|
||||
{
|
||||
int i = cmds[n].tokLen;
|
||||
|
||||
if(cmds[n].needLogin)
|
||||
{
|
||||
if((pSession->userId == 0) || (pSession->authenticated == FALSE))
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 530, ftpMsg033);
|
||||
return 0;
|
||||
}
|
||||
if(ftpCheckAccRights(pSession->userId, cmds[n].neededRights))
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 550, ftpMsg034);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if((pSession->activeTrans.op != OP_NOP)) // transfer in progress?
|
||||
{
|
||||
if(cmds[n].duringTransfer == FALSE) // command during transfer allowed?
|
||||
return 0; // no => silently discard command
|
||||
}
|
||||
|
||||
while(cmd[i] != '\0')
|
||||
{
|
||||
if((cmd[i] != ' ') && (cmd[i] != '\t'))
|
||||
break;
|
||||
|
||||
i++;
|
||||
}
|
||||
ret = cmds[n].handler(sessionId, &cmd[i], strlen(&cmd[i])); // execute command
|
||||
pSession->timeLastCmd = ftpGetUnixTime();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 500, cmd); // reject unknown commands
|
||||
pSession->timeLastCmd = ftpGetUnixTime();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ftpParseCmd(int sessionId)
|
||||
{
|
||||
ftpSession_S *pSession;
|
||||
int len;
|
||||
int c;
|
||||
socket_t ctrlSocket;
|
||||
|
||||
pSession = ftpGetSession(sessionId);
|
||||
len = pSession->rxBufWriteIdx;
|
||||
ctrlSocket = pSession->ctrlSocket;
|
||||
|
||||
if((pSession->rxBuf[len - 1] == '\n') &&
|
||||
(pSession->rxBuf[len - 2] == '\r') ) // command correctly terminated?
|
||||
{
|
||||
pSession->rxBuf[len - 2] = '\0';
|
||||
pSession->rxBufWriteIdx = 0;
|
||||
|
||||
for(c = 0; c < len; c++) // convert command token to uppercase
|
||||
{
|
||||
if(isspace(pSession->rxBuf[c]))
|
||||
break;
|
||||
pSession->rxBuf[c] = toupper(pSession->rxBuf[c]);
|
||||
}
|
||||
|
||||
#if DBG_LOG
|
||||
printf("%02d --> %s\n", sessionId, pSession->rxBuf);
|
||||
#endif
|
||||
|
||||
if(execFtpCmd(sessionId, pSession->rxBuf, len - 2) == -1)
|
||||
{
|
||||
ftpUntrackSocket(ctrlSocket);
|
||||
ftpCloseSession(sessionId);
|
||||
}
|
||||
}
|
||||
|
||||
if(pSession->rxBufWriteIdx >= LEN_RXBUF) // overflow of receive buffer?
|
||||
{
|
||||
pSession->rxBufWriteIdx = 0;
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 500, ftpMsg035);
|
||||
#if DBG_LOG
|
||||
printf("Receive buffer overflow. Received data discarded.\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpLib.c - Global helper functions
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
#include "ftpIfc.h"
|
||||
|
||||
/**
|
||||
* @brief Removes the trailing slash of a directory path
|
||||
*
|
||||
* @param path directory path
|
||||
*
|
||||
* @return len of path
|
||||
*/
|
||||
int ftpRemoveTrailingSlash(char* path)
|
||||
{
|
||||
int len = strlen(path);
|
||||
|
||||
if(len > 1)
|
||||
{
|
||||
len--;
|
||||
if(path[len] == '/')
|
||||
path[len] = '\0';
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Removes double slashes in a path
|
||||
*
|
||||
* e. g. "//a//b//c" will be converted to "a/b/c"
|
||||
*
|
||||
* @param path directory path
|
||||
*/
|
||||
void ftpRemoveDoubleSlash(char* path)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = path;
|
||||
|
||||
while(*p != '\0')
|
||||
{
|
||||
if((p[0] == '/') && (p[1] == '/'))
|
||||
ftpStrcpy(p, &p[1]);
|
||||
else
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Merges multiple path strings
|
||||
*
|
||||
* The function catenates all passed strings to a new string and assures that
|
||||
* the result does not exceed MAX_PATH_LEN. The last parameter has to be
|
||||
* NULL.
|
||||
* @todo Not all embedded environments support variadic functions, or they are
|
||||
* too expensive.
|
||||
*
|
||||
* @param dest user name
|
||||
*
|
||||
* @return Pointer to dest
|
||||
*/
|
||||
char* ftpMergePaths(char* dest, ...)
|
||||
{
|
||||
const char* src;
|
||||
char* dst = dest;
|
||||
int len = 0;
|
||||
va_list args;
|
||||
|
||||
va_start(args, dest);
|
||||
|
||||
while((src = va_arg(args, const char*)))
|
||||
{
|
||||
while((*src != '\0') && (len < MAX_PATH_LEN-1))
|
||||
{
|
||||
*dst++ = *src++;
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
*dst = '\0';
|
||||
va_end(args);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Determine the unix-time
|
||||
*
|
||||
* The function reads the clock from the target-layer and converts it to the
|
||||
* unix-time. The code is taken from http://de.wikipedia.org/wiki/Unixzeit
|
||||
*
|
||||
* @return seconds since 1. Januar 1970 00:00
|
||||
*/
|
||||
uint32_t ftpGetUnixTime(void)
|
||||
{
|
||||
ftpTime_S t;
|
||||
uint32_t unixTime = 0;
|
||||
int j;
|
||||
|
||||
ftpGetLocalTime(&t);
|
||||
|
||||
for(j=1970;j<t.year;j++) // leap years
|
||||
{
|
||||
if(j%4==0 && (j%100!=0 || j%400==0))
|
||||
unixTime+=(366*24*60*60);
|
||||
else
|
||||
unixTime+=(365*24*60*60);
|
||||
}
|
||||
for(j=1;j<t.month;j++) // days per month 31/30/29/28
|
||||
{
|
||||
if(j==1 || j==3 || j==5 || j==7 || j==8 || j==10 || j==12)
|
||||
unixTime+=(31*24*60*60); // months with 31 days
|
||||
if(j==4 || j==6 || j==9 || j==11)
|
||||
unixTime+=(30*24*60*60); // months with 30 days
|
||||
if( (j==2) && (t.year%4==0 && (t.year%100!=0 || t.year%400==0)) )
|
||||
unixTime+=(29*24*60*60);
|
||||
else
|
||||
unixTime+=(28*24*60*60);
|
||||
}
|
||||
unixTime+=((t.day-1)*24*60*60);
|
||||
unixTime+=(t.hour*60*60);
|
||||
unixTime+=t.minute*60;
|
||||
unixTime+=t.second;
|
||||
|
||||
return unixTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief copy a string
|
||||
*
|
||||
* The reason why feathery has its own strcpy is that in some cases src is
|
||||
* part of dest and src > dest. Because ANSI-C explicitly declares that case
|
||||
* as undefined our strcpy guarantees to copy from lower to higher
|
||||
* addresses.
|
||||
*
|
||||
* @param dest destination string
|
||||
* @param src Null-terminated source string
|
||||
*
|
||||
* @return destination string
|
||||
*/
|
||||
char *ftpStrcpy(char *dest, const char *src)
|
||||
{
|
||||
char *d = dest;
|
||||
const char *s = src;
|
||||
|
||||
while (*d++ = *s++);
|
||||
return dest;
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpMessages.c - FTP-Server messages
|
||||
*
|
||||
* This Module defines all message-strings the servers sends to
|
||||
* clients. If someone needs to translate the server user interface
|
||||
* to a different language this is the only file to be touched.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
const char ftpMsg000[] = "Data connection error";
|
||||
const char ftpMsg001[] = "File error";
|
||||
const char ftpMsg002[] = "File send OK";
|
||||
const char ftpMsg003[] = "File received OK";
|
||||
const char ftpMsg004[] = "Please specify the password";
|
||||
const char ftpMsg005[] = "Login successful";
|
||||
const char ftpMsg006[] = "Login failed";
|
||||
const char ftpMsg007[] = "PORT command successful. Consider using PASV.";
|
||||
const char ftpMsg008[] = "NOOP command successful";
|
||||
const char ftpMsg009[] = "Goodby";
|
||||
const char ftpMsg010[] = "Here comes the listing";
|
||||
const char ftpMsg011[] = "Could not establish data connection.";
|
||||
const char ftpMsg012[] = "Could not establish passive data connection.";
|
||||
const char ftpMsg013[] = "Directory send OK";
|
||||
const char ftpMsg014[] = "Sending file...";
|
||||
const char ftpMsg015[] = "Could not open file.";
|
||||
const char ftpMsg016[] = "Receiving file...";
|
||||
const char ftpMsg018[] = "Could not delete file";
|
||||
const char ftpMsg019[] = "File deleted";
|
||||
const char ftpMsg020[] = "Could create directory";
|
||||
const char ftpMsg021[] = "Directory created";
|
||||
const char ftpMsg022[] = "Could remove directory";
|
||||
const char ftpMsg023[] = "Directory removed";
|
||||
const char ftpMsg024[] = "Directory successfully changed";
|
||||
const char ftpMsg025[] = "Failed to change directory";
|
||||
const char ftpMsg026[] = "Switching to binary mode";
|
||||
const char ftpMsg027[] = "Switching to ascii mode";
|
||||
const char ftpMsg028[] = "Unknown type-code";
|
||||
const char ftpMsg029[] = "Entering passive mode";
|
||||
const char ftpMsg030[] = "Switching to file mode";
|
||||
const char ftpMsg031[] = "Only file mode supported";
|
||||
const char ftpMsg032[] = "Invalid path";
|
||||
const char ftpMsg033[] = "Please login with USER and PASS.";
|
||||
const char ftpMsg034[] = "Permission denied.";
|
||||
const char ftpMsg035[] = "Line too long.";
|
||||
const char ftpMsg036[] = "Timeout.";
|
||||
const char ftpMsg037[] = "Hi";
|
||||
const char ftpMsg038[] = "Could not open directory.";
|
||||
const char ftpMsg039[] = "Could not read directory.";
|
||||
const char ftpMsg040[] = "Aborted.";
|
|
@ -0,0 +1,217 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpRuntime.c - ftp-server runtime environment
|
||||
*
|
||||
* This is the central module of feathery. It defines all runtime functions
|
||||
* of feathery. That is startup, state, main-thread an shutdown.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
#include "ftpMessages.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief server-sockets that listens for incoming connections
|
||||
*/
|
||||
LOCAL socket_t server;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes and starts the server
|
||||
*
|
||||
*
|
||||
* @return - 0: server started successfully
|
||||
* - -1: could not create server socket
|
||||
*/
|
||||
int ftpStart(void)
|
||||
{
|
||||
server = -1; // set server socket to invalid value
|
||||
|
||||
#if DBG_LOG
|
||||
printf("Feathery FTP-Server\n");
|
||||
#endif
|
||||
|
||||
ftpArchInit();
|
||||
#if DBG_LOG
|
||||
printf(". Creating server socket");
|
||||
#endif
|
||||
|
||||
server = ftpCreateServerSocket(); // create main listener socket
|
||||
if(server < 0)
|
||||
{
|
||||
#if DBG_LOG
|
||||
printf("\t\terror\n");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if DBG_LOG
|
||||
printf("\t\tok\n");
|
||||
printf("Server successfully startet\n");
|
||||
#endif
|
||||
|
||||
ftpTrackSocket(server); // add socket to "watchlist"
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Checks if the server has something to do
|
||||
*
|
||||
* In order of avoid blocking of ftpExecute this function can be used to
|
||||
* determine if the server has something to do. You can call this function in
|
||||
* a loop and everytime it returns nonezero its time to call ftpExecute().
|
||||
* @todo implement me
|
||||
*
|
||||
* @return 0 noting to do; else server has received some data
|
||||
*/
|
||||
int ftpState(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Main server-thread
|
||||
*
|
||||
* Manages all client connections and active transmitions. In addtition
|
||||
* all received control-strings are dispatched to the command-module.
|
||||
* Note, the function blocks if there is nothing to do.
|
||||
*/
|
||||
void ftpExecute(void)
|
||||
{
|
||||
int n;
|
||||
int socksRdy;
|
||||
ftpSession_S *pSession;
|
||||
int sessionId;
|
||||
int activeJobs;
|
||||
|
||||
|
||||
activeJobs = ftpGetActiveTransCnt(); // are there any active transmitions?
|
||||
for(n = 0; (activeJobs > 0) && (n < MAX_CONNECTIONS); n++)
|
||||
{
|
||||
pSession = ftpGetSession(n);
|
||||
if(pSession->activeTrans.op) // has this session an active transmition?
|
||||
{
|
||||
ftpExecTransmission(n); // do the job
|
||||
activeJobs--;
|
||||
}
|
||||
}
|
||||
|
||||
//if(ftpGetActiveTransCnt()) // don't block if there's still something to do
|
||||
socksRdy = ftpSelect(TRUE);
|
||||
//else
|
||||
// socksRdy = ftpSelect(FALSE);
|
||||
if(socksRdy > 0)
|
||||
{
|
||||
if(ftpTestSocket(server)) // server listner-socket signaled?
|
||||
{
|
||||
socket_t clientSocket;
|
||||
ip_t remoteIP;
|
||||
port_t remotePort;
|
||||
|
||||
socksRdy--;
|
||||
clientSocket = ftpAcceptServerConnection(server, &remoteIP, &remotePort);
|
||||
if(clientSocket >= 0)
|
||||
{
|
||||
sessionId = ftpOpenSession(clientSocket, remoteIP, remotePort);
|
||||
if(sessionId >= 0)
|
||||
{
|
||||
ftpTrackSocket(clientSocket);
|
||||
ftpSendMsg(MSG_NORMAL, sessionId, 220, ftpMsg037);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if DBG_LOG
|
||||
printf("Connection refused; Session limit reached.\n");
|
||||
#endif
|
||||
ftpCloseSocket(clientSocket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(n = 0; (socksRdy > 0) && (n < MAX_CONNECTIONS); n++)
|
||||
{
|
||||
pSession = ftpGetSession(n);
|
||||
if(pSession->open)
|
||||
{
|
||||
socket_t ctrlSocket = pSession->ctrlSocket;
|
||||
|
||||
if(ftpTestSocket(ctrlSocket))
|
||||
{
|
||||
int len;
|
||||
socksRdy--;
|
||||
len = ftpReceive(ctrlSocket,
|
||||
&pSession->rxBuf[pSession->rxBufWriteIdx],
|
||||
LEN_RXBUF - pSession->rxBufWriteIdx);
|
||||
if(len <= 0) // has client shutdown the connection?
|
||||
{
|
||||
ftpUntrackSocket(ctrlSocket);
|
||||
ftpCloseSession(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
pSession->rxBufWriteIdx += len;
|
||||
ftpParseCmd(n);
|
||||
}
|
||||
}
|
||||
/// @bug Session-Timeout-Management doesn't work
|
||||
if((ftpGetUnixTime() - pSession->timeLastCmd) > SESSION_TIMEOUT)
|
||||
{
|
||||
ftpSendMsg(MSG_NORMAL, n, 421, ftpMsg036);
|
||||
ftpUntrackSocket(ctrlSocket);
|
||||
ftpCloseSession(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Shut down the server
|
||||
*
|
||||
* Cuts all tcp-connections and frees all used resources.
|
||||
|
||||
* @return 0
|
||||
*/
|
||||
int ftpShutdown(void)
|
||||
{
|
||||
int n;
|
||||
ftpUntrackSocket(server);
|
||||
ftpCloseSocket(server);
|
||||
|
||||
for(n = 0; n < MAX_CONNECTIONS; n++)
|
||||
{
|
||||
if(ftpGetSession(n)->open)
|
||||
{
|
||||
ftpUntrackSocket(ftpGetSession(n)->ctrlSocket);
|
||||
ftpCloseSession(n);
|
||||
}
|
||||
}
|
||||
|
||||
ftpArchCleanup();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/* FEATHERY FTP-Server
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
* <https://sourceforge.net/projects/feathery>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
|
||||
#include "ftpIfc.h"
|
||||
int main(void)
|
||||
{
|
||||
ftpCreateAccount("anonymous", "", "./", FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
ftpCreateAccount("nothing", "", "./", 0);
|
||||
ftpCreateAccount("reader", "", "./", FTP_ACC_RD);
|
||||
ftpCreateAccount("writer", "", "./", FTP_ACC_WR);
|
||||
ftpCreateAccount("lister", "", "./", FTP_ACC_LS);
|
||||
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
|
||||
ftpStart();
|
||||
while(1)
|
||||
ftpExecute();
|
||||
ftpShutdown();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,344 @@
|
|||
/**
|
||||
* Feathery FTP-Server <https://sourceforge.net/projects/feathery>
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
*
|
||||
* ftpSession.c - Session handling of connected clients
|
||||
*
|
||||
* A ftp session is a TCP connection between the server and a ftp client.
|
||||
* Each session has its own unique session id. The session id refers
|
||||
* (index in session[]) to a struct ftpSession_S which holds all
|
||||
* relevant data. The virtual chroot environment is also part of the
|
||||
* session management.
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief array that holds the data of all ftp sessions
|
||||
*
|
||||
* The index represents the session ID.
|
||||
*/
|
||||
LOCAL ftpSession_S sessions[MAX_CONNECTIONS];
|
||||
|
||||
/**
|
||||
* @brief number of active file or directory transmission
|
||||
*/
|
||||
LOCAL int actTransCnt;
|
||||
|
||||
/**
|
||||
* @brief Scratch-buffer for path manipulation
|
||||
*/
|
||||
LOCAL char pathScratchBuf[MAX_PATH_LEN];
|
||||
|
||||
|
||||
/**
|
||||
* @brief Opens a ftp session
|
||||
*
|
||||
* Searches in 'sessions' for an empty entry and inits the session data.
|
||||
* Call this function after accepting a tcp connection from a ftp client.
|
||||
*
|
||||
* @param ctrlSocket control socket which initiated the the ftp session
|
||||
* @param remoteIp IP address of the client
|
||||
* @param remotePort TCP-Port of the client
|
||||
*
|
||||
* @return session id or -1 if session limit is reached
|
||||
*/
|
||||
int ftpOpenSession(socket_t ctrlSocket, ip_t remoteIp, port_t remotePort)
|
||||
{
|
||||
int n;
|
||||
for(n = 0; n < MAX_CONNECTIONS; n++)
|
||||
{
|
||||
if(!sessions[n].open)
|
||||
{
|
||||
sessions[n].open = TRUE;
|
||||
sessions[n].authenticated = FALSE;
|
||||
sessions[n].userId = 0;
|
||||
sessions[n].workingDir[0] = '\0';
|
||||
sessions[n].remoteIp = remoteIp;
|
||||
sessions[n].remotePort = remotePort;
|
||||
sessions[n].remoteDataPort = 0;
|
||||
sessions[n].passive = FALSE;
|
||||
sessions[n].binary = TRUE;
|
||||
sessions[n].timeLastCmd = ftpGetUnixTime();
|
||||
sessions[n].ctrlSocket = ctrlSocket;
|
||||
sessions[n].passiveDataSocket = -1;
|
||||
sessions[n].rxBufWriteIdx = 0;
|
||||
sessions[n].activeTrans.op = OP_NOP;
|
||||
sessions[n].activeTrans.fsHandle = NULL;
|
||||
sessions[n].activeTrans.dataSocket = -1;
|
||||
sessions[n].activeTrans.fileSize = 0;
|
||||
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Marks the current ftp session as 'authenticated'
|
||||
*
|
||||
* @param id Session id
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int ftpAuthSession(int id)
|
||||
{
|
||||
sessions[id].authenticated = TRUE;
|
||||
strcpy(sessions[id].workingDir, "/");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Closes a ftp session
|
||||
*
|
||||
* Closes the TCP control connection and releases the session struct.
|
||||
*
|
||||
* @param id Session id
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int ftpCloseSession(int id)
|
||||
{
|
||||
ftpCloseSocket(sessions[id].ctrlSocket);
|
||||
ftpCloseTransmission(id);
|
||||
|
||||
sessions[id].open = FALSE;
|
||||
|
||||
#if DBG_LOG
|
||||
printf("Session %d closed\n", id);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns pointer to session struct
|
||||
*
|
||||
* @param id Session id
|
||||
*
|
||||
* @return pointer to session data
|
||||
*/
|
||||
ftpSession_S* ftpGetSession(int id)
|
||||
{
|
||||
return &sessions[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Normalizes a path string
|
||||
*
|
||||
* The function resolves all dot and doubledot directory entries in the
|
||||
* passed path. If the normalized path refers beyond root, root is returned.
|
||||
*
|
||||
* @param path string of an absolute path
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
LOCAL int normalizePath(char* path)
|
||||
{
|
||||
char *in;
|
||||
char *r = NULL;
|
||||
|
||||
r = path;
|
||||
in = path;
|
||||
|
||||
while((in = strchr(in, '/')))
|
||||
{
|
||||
if(!strncmp(in, "/./", 3))
|
||||
{
|
||||
ftpStrcpy(in, &in[2]);
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(in, "/."))
|
||||
{
|
||||
in[1] = '\0';
|
||||
continue;
|
||||
}
|
||||
if(!strncmp(in, "/../", 4))
|
||||
{
|
||||
*in = '\0';
|
||||
r = strrchr(path, '/');
|
||||
if(r == NULL)
|
||||
r = path;
|
||||
ftpStrcpy(r, &in[3]);
|
||||
in = r;
|
||||
continue;
|
||||
}
|
||||
if(!strcmp(in, "/.."))
|
||||
{
|
||||
*in = '\0';
|
||||
r = strrchr(path, '/');
|
||||
if(r)
|
||||
{
|
||||
if(r == path)
|
||||
r[1] = '\0';
|
||||
else
|
||||
*r = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
in[0] = '/';
|
||||
in[1] = '\0';
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
in++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Translate a ftp session path to server path
|
||||
*
|
||||
* The translated path depends on the current working directory of the
|
||||
* session and the root path of the session. In addition the path will
|
||||
* be normalized.
|
||||
* The server path is generated as followed:
|
||||
* passed path is relative => server path = ftp user root + session working dir + path
|
||||
* passed path is absolute => server path = ftp user root + path
|
||||
*
|
||||
* @param id Session id
|
||||
* @param path ftp session path (can be relative or absolute)
|
||||
* @param if != 0 dot and doubledot directories will be resolved
|
||||
*
|
||||
* @return translated absolute server path
|
||||
*/
|
||||
const char* ftpGetRealPath(int id, const char* path, int normalize)
|
||||
{
|
||||
const char* ftpRoot;
|
||||
int len;
|
||||
|
||||
ftpRoot = ftpGetRoot(sessions[id].userId, &len);
|
||||
|
||||
#if DBG_LOG
|
||||
printf("ftpGetRealPath path [%s] ftpRoot [%s] sessions[id].workingDir [%s]\n", path, ftpRoot, sessions[id].workingDir);
|
||||
#endif
|
||||
|
||||
pathScratchBuf[0]='\0';
|
||||
if(path[0] == '/' || strcmp(path,sessions[id].workingDir) == 0) // absolute path?
|
||||
{
|
||||
ftpMergePaths(pathScratchBuf, ftpRoot, path, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpMergePaths(pathScratchBuf, ftpRoot, sessions[id].workingDir, "/", path, NULL);
|
||||
//ftpMergePaths(pathScratchBuf, ftpRoot, path, NULL);
|
||||
}
|
||||
|
||||
#if DBG_LOG
|
||||
printf("#2 ftpGetRealPath path [%s] ftpRoot [%s]\n", path, ftpRoot);
|
||||
#endif
|
||||
|
||||
ftpRemoveDoubleSlash(pathScratchBuf);
|
||||
if(normalize) {
|
||||
normalizePath(pathScratchBuf);
|
||||
}
|
||||
ftpRemoveTrailingSlash(pathScratchBuf);
|
||||
|
||||
#if DBG_LOG
|
||||
printf("#2 ftpGetRealPath path [%s] ftpRoot [%s] pathScratchBuf [%s]\n", path, ftpRoot, pathScratchBuf);
|
||||
#endif
|
||||
|
||||
return pathScratchBuf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Change the current working directory of the session
|
||||
*
|
||||
* @param id Session id
|
||||
* @param path destination ftp path (can be relative or absolute)
|
||||
*
|
||||
* @return 0 on success; -2 if the directory doesn't exist
|
||||
*/
|
||||
int ftpChangeDir(int id, const char* path)
|
||||
{
|
||||
ftpPathInfo_S fileInfo;
|
||||
const char* realPath = ftpGetRealPath(id, path, TRUE);
|
||||
int len;
|
||||
|
||||
|
||||
ftpGetRoot(sessions[id].userId, &len); // determine len of root-path
|
||||
if(len == 1) // if len == 1 root-path == '/'
|
||||
len = 0;
|
||||
|
||||
#if DBG_LOG
|
||||
printf("ftpChangeDir path [%s] realPath [%s] sessions[id].workingDir [%s]\n", path, realPath, sessions[id].workingDir);
|
||||
#endif
|
||||
|
||||
if(ftpStat(realPath, &fileInfo) || (fileInfo.type != TYPE_DIR)) // directory accessible?
|
||||
return -2;
|
||||
|
||||
strncpy(sessions[id].workingDir, &realPath[len], MAX_PATH_LEN); // apply path
|
||||
if(sessions[id].workingDir[0] == '\0')
|
||||
strcpy(sessions[id].workingDir, "/");
|
||||
|
||||
#if DBG_LOG
|
||||
printf("ftpChangeDir path [%s] realPath [%s] NEW sessions[id].workingDir [%s]\n", path, realPath, sessions[id].workingDir);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo documentation
|
||||
*/
|
||||
void ftpOpenTransmission(int id, operation_E op, void* fsHandle, socket_t dataSocket, uint32_t fileSize)
|
||||
{
|
||||
actTransCnt++;
|
||||
sessions[id].activeTrans.op = op;
|
||||
sessions[id].activeTrans.fsHandle = fsHandle;
|
||||
sessions[id].activeTrans.dataSocket = dataSocket;
|
||||
sessions[id].activeTrans.fileSize = fileSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo documentation
|
||||
*/
|
||||
void ftpCloseTransmission(int id)
|
||||
{
|
||||
if(sessions[id].activeTrans.op != OP_NOP) // is thera an active transmission?
|
||||
{
|
||||
ftpCloseSocket(sessions[id].activeTrans.dataSocket);
|
||||
if(sessions[id].activeTrans.op == OP_LIST)
|
||||
{
|
||||
ftpCloseDir(sessions[id].activeTrans.fsHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
ftpCloseFile(sessions[id].activeTrans.fsHandle);
|
||||
}
|
||||
sessions[id].activeTrans.op = OP_NOP;
|
||||
actTransCnt--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo documentation
|
||||
*/
|
||||
int ftpGetActiveTransCnt(void)
|
||||
{
|
||||
return actTransCnt;
|
||||
}
|
|
@ -0,0 +1,383 @@
|
|||
/* FEATHERY FTP-Server
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
* <https://sourceforge.net/projects/feathery>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sendfile.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <dirent.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
|
||||
ip_t ownIp;
|
||||
|
||||
LOCAL fd_set watchedSockets;
|
||||
LOCAL fd_set signaledSockets;
|
||||
LOCAL int maxSockNr;
|
||||
|
||||
|
||||
void ftpArchInit(void)
|
||||
{
|
||||
ownIp = 0;
|
||||
maxSockNr = 0;
|
||||
FD_ZERO(&watchedSockets);
|
||||
FD_ZERO(&signaledSockets);
|
||||
}
|
||||
|
||||
void ftpArchCleanup(void)
|
||||
{
|
||||
}
|
||||
|
||||
int ftpGetLocalTime(ftpTime_S *t)
|
||||
{
|
||||
struct tm *pTime;
|
||||
time_t tim;
|
||||
|
||||
time(&tim);
|
||||
pTime = localtime(&tim);
|
||||
if(pTime)
|
||||
{
|
||||
t->year = (uint16_t)pTime->tm_year + 1900;
|
||||
t->month = (uint8_t)pTime->tm_mon + 1;
|
||||
t->day = (uint8_t)pTime->tm_mday;
|
||||
t->hour = (uint8_t)pTime->tm_hour;
|
||||
t->minute = (uint8_t)pTime->tm_min;
|
||||
t->second = (uint8_t)pTime->tm_sec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void* ftpOpenDir(const char* path)
|
||||
{
|
||||
return opendir(path);
|
||||
}
|
||||
|
||||
const char* ftpReadDir(void* dirHandle)
|
||||
{
|
||||
struct dirent* dirEntry;
|
||||
|
||||
dirEntry = readdir(dirHandle);
|
||||
if(dirEntry)
|
||||
return dirEntry->d_name;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int ftpCloseDir(void* dirHandle)
|
||||
{
|
||||
return closedir(dirHandle);
|
||||
}
|
||||
|
||||
int ftpStat(const char* path, ftpPathInfo_S *info)
|
||||
{
|
||||
struct stat fileInfo = {0};
|
||||
struct tm *pTime;
|
||||
struct passwd *pw;
|
||||
struct group *gr;
|
||||
|
||||
if(!stat(path, &fileInfo))
|
||||
{
|
||||
if(S_ISREG(fileInfo.st_mode))
|
||||
info->type = TYPE_FILE;
|
||||
else if(S_ISDIR(fileInfo.st_mode))
|
||||
info->type = TYPE_DIR;
|
||||
else
|
||||
info->type = TYPE_LINK;
|
||||
|
||||
pTime = localtime(&fileInfo.st_mtime);
|
||||
if(pTime)
|
||||
{
|
||||
info->mTime.year = (uint16_t)pTime->tm_year + 1900;
|
||||
info->mTime.month = (uint8_t)pTime->tm_mon + 1;
|
||||
info->mTime.day = (uint8_t)pTime->tm_mday;
|
||||
info->mTime.hour = (uint8_t)pTime->tm_hour;
|
||||
info->mTime.minute = (uint8_t)pTime->tm_min;
|
||||
info->mTime.second = (uint8_t)pTime->tm_sec;
|
||||
}
|
||||
pTime = localtime(&fileInfo.st_ctime);
|
||||
if(pTime)
|
||||
{
|
||||
info->cTime.year = (uint16_t)pTime->tm_year + 1900;
|
||||
info->cTime.month = (uint8_t)pTime->tm_mon + 1;
|
||||
info->cTime.day = (uint8_t)pTime->tm_mday;
|
||||
info->cTime.hour = (uint8_t)pTime->tm_hour;
|
||||
info->cTime.minute = (uint8_t)pTime->tm_min;
|
||||
info->cTime.second = (uint8_t)pTime->tm_sec;
|
||||
}
|
||||
pTime = localtime(&fileInfo.st_atime);
|
||||
if(pTime)
|
||||
{
|
||||
info->aTime.year = (uint16_t)pTime->tm_year + 1900;
|
||||
info->aTime.month = (uint8_t)pTime->tm_mon + 1;
|
||||
info->aTime.day = (uint8_t)pTime->tm_mday;
|
||||
info->aTime.hour = (uint8_t)pTime->tm_hour;
|
||||
info->aTime.minute = (uint8_t)pTime->tm_min;
|
||||
info->aTime.second = (uint8_t)pTime->tm_sec;
|
||||
}
|
||||
|
||||
info->size = (uint32_t)fileInfo.st_size;
|
||||
info->links = (int)fileInfo.st_nlink;
|
||||
|
||||
pw = getpwuid(fileInfo.st_uid);
|
||||
if(pw)
|
||||
strncpy(info->user, pw->pw_name, sizeof(info->user));
|
||||
else
|
||||
sprintf(info->user, "%04d", fileInfo.st_uid);
|
||||
|
||||
gr = getgrgid(fileInfo.st_gid);
|
||||
if(gr)
|
||||
strncpy(info->group, gr->gr_name, sizeof(info->group));
|
||||
else
|
||||
sprintf(info->group, "%04d", fileInfo.st_gid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ftpMakeDir(const char* path)
|
||||
{
|
||||
return mkdir(path, S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
int ftpRemoveDir(const char* path)
|
||||
{
|
||||
return rmdir(path);
|
||||
}
|
||||
|
||||
int ftpCloseSocket(socket_t s)
|
||||
{
|
||||
return close(s);
|
||||
}
|
||||
|
||||
int ftpSend(socket_t s, const void *data, int len)
|
||||
{
|
||||
int currLen = 0;
|
||||
|
||||
do
|
||||
{
|
||||
currLen = send(s, data, len, 0);
|
||||
if(currLen >= 0)
|
||||
{
|
||||
len -= currLen;
|
||||
data = (uint8_t*)data + currLen;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
}while(len > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpReceive(socket_t s, void *data, int len)
|
||||
{
|
||||
return recv(s, data, len, 0);
|
||||
}
|
||||
|
||||
socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port)
|
||||
{
|
||||
socket_t dataSocket;
|
||||
struct sockaddr_in clientAddr;
|
||||
struct sockaddr_in myAddr;
|
||||
int on = 1;
|
||||
unsigned len;
|
||||
dataSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(dataSocket < 0)
|
||||
return -1;
|
||||
|
||||
if(!passive)
|
||||
{
|
||||
if(setsockopt(dataSocket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
|
||||
{
|
||||
close(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
myAddr.sin_family = AF_INET;
|
||||
myAddr.sin_addr.s_addr = INADDR_ANY;
|
||||
myAddr.sin_port = htons(20);
|
||||
if(bind(dataSocket, (struct sockaddr *)&myAddr, sizeof(myAddr)))
|
||||
{
|
||||
close(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
clientAddr.sin_family = AF_INET;
|
||||
clientAddr.sin_addr.s_addr = htonl(*ip);
|
||||
clientAddr.sin_port = htons(*port);
|
||||
if(connect(dataSocket, (struct sockaddr *)&clientAddr, sizeof(clientAddr)))
|
||||
{
|
||||
close(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myAddr.sin_family = AF_INET;
|
||||
myAddr.sin_addr.s_addr = INADDR_ANY;
|
||||
myAddr.sin_port = htons(0);
|
||||
if(bind(dataSocket, (struct sockaddr *)&myAddr, sizeof(myAddr)))
|
||||
{
|
||||
close(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
len = sizeof(myAddr);
|
||||
if(getsockname(dataSocket, (struct sockaddr *)&myAddr, &len)) // Port des Server-Sockets ermitteln
|
||||
{
|
||||
close(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*port = ntohs(myAddr.sin_port);
|
||||
*ip = ownIp;
|
||||
|
||||
if(listen(dataSocket, 1))
|
||||
{
|
||||
close(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return dataSocket;
|
||||
}
|
||||
|
||||
socket_t ftpAcceptDataConnection(socket_t listner)
|
||||
{
|
||||
struct sockaddr_in clientinfo;
|
||||
unsigned len;
|
||||
socket_t dataSocket;
|
||||
|
||||
len = sizeof(clientinfo);
|
||||
|
||||
dataSocket = accept(listner, (struct sockaddr *)&clientinfo, &len);
|
||||
if(dataSocket < 0)
|
||||
dataSocket = -1;
|
||||
|
||||
close(listner); // Server-Socket wird nicht mehr gebrauch deshalb schließen
|
||||
return dataSocket;
|
||||
}
|
||||
|
||||
socket_t ftpCreateServerSocket(void)
|
||||
{
|
||||
int theServer;
|
||||
struct sockaddr_in serverinfo;
|
||||
unsigned len;
|
||||
|
||||
theServer = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(theServer < 0)
|
||||
return -1;
|
||||
|
||||
serverinfo.sin_family = AF_INET;
|
||||
serverinfo.sin_addr.s_addr = INADDR_ANY;
|
||||
serverinfo.sin_port = htons(61358);
|
||||
len = sizeof(serverinfo);
|
||||
|
||||
if(bind(theServer, (struct sockaddr *)&serverinfo, len))
|
||||
{
|
||||
ftpCloseSocket(theServer);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if(listen(theServer, 3))
|
||||
{
|
||||
ftpCloseSocket(theServer);
|
||||
return -3;
|
||||
}
|
||||
|
||||
return (socket_t)theServer;
|
||||
}
|
||||
|
||||
socket_t ftpAcceptServerConnection(socket_t server, ip_t *remoteIP, port_t *remotePort)
|
||||
{
|
||||
struct sockaddr_in sockinfo;
|
||||
socket_t clientSocket;
|
||||
unsigned len;
|
||||
|
||||
len = sizeof(sockinfo);
|
||||
|
||||
clientSocket = accept(server, (struct sockaddr *)&sockinfo, &len);
|
||||
*remoteIP = ntohl(sockinfo.sin_addr.s_addr);
|
||||
*remotePort = ntohs(sockinfo.sin_port);
|
||||
|
||||
if(!ownIp) // kennen wir schon die eigene IP?
|
||||
{
|
||||
len = sizeof(sockinfo);
|
||||
if(getsockname(clientSocket, (struct sockaddr *)&sockinfo, &len))
|
||||
{
|
||||
#if DBG_LOG
|
||||
printf("getsockname error\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
ownIp = ntohl(sockinfo.sin_addr.s_addr); // eigene IP-Adresse abspeichern (wird dir PASV benätigt)
|
||||
}
|
||||
#if DBG_LOG
|
||||
printf("Verbindung mit %s auf Port %d akzeptiert.\n", inet_ntoa(sockinfo.sin_addr), *remotePort);
|
||||
#endif
|
||||
return clientSocket;
|
||||
}
|
||||
|
||||
int ftpTrackSocket(socket_t s)
|
||||
{
|
||||
if(s > maxSockNr)
|
||||
maxSockNr = s;
|
||||
FD_SET(s, &watchedSockets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpUntrackSocket(socket_t s)
|
||||
{
|
||||
FD_CLR(s, &watchedSockets);
|
||||
// TODO hier sollte eine Möglichkeit geschaffen werden um maxSockNr anzupassen
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpTestSocket(socket_t s)
|
||||
{
|
||||
return FD_ISSET(s, &signaledSockets);
|
||||
}
|
||||
|
||||
int ftpSelect(int poll)
|
||||
{
|
||||
signaledSockets = watchedSockets;
|
||||
|
||||
if(poll)
|
||||
{
|
||||
struct timeval t = {0};
|
||||
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
|
||||
}
|
||||
else
|
||||
return select(maxSockNr+1, &signaledSockets, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,420 @@
|
|||
/* FEATHERY FTP-Server
|
||||
* Copyright (C) 2005-2010 Andreas Martin (andreas.martin@linuxmail.org)
|
||||
* <https://sourceforge.net/projects/feathery>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "ftpTypes.h"
|
||||
#include "ftpConfig.h"
|
||||
#include "ftp.h"
|
||||
|
||||
#pragma comment(lib, "ws2_32")
|
||||
#pragma comment(lib, "MSWSOCK")
|
||||
|
||||
ip_t ownIp;
|
||||
|
||||
LOCAL fd_set watchedSockets;
|
||||
LOCAL fd_set signaledSockets;
|
||||
LOCAL int maxSockNr;
|
||||
|
||||
void ftpArchInit(void)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
ownIp = 0;
|
||||
maxSockNr = 0;
|
||||
FD_ZERO(&watchedSockets);
|
||||
WSAStartup(MAKEWORD(2, 0),&wsaData);
|
||||
}
|
||||
|
||||
void ftpArchCleanup(void)
|
||||
{
|
||||
WSACleanup(); // WINSOCK freigeben
|
||||
}
|
||||
|
||||
int ftpGetLocalTime(ftpTime_S *t)
|
||||
{
|
||||
struct tm *pTime;
|
||||
time_t tim;
|
||||
|
||||
time(&tim);
|
||||
pTime = localtime(&tim);
|
||||
if(pTime)
|
||||
{
|
||||
t->year = (uint16_t)pTime->tm_year + 1900;
|
||||
t->month = (uint8_t)pTime->tm_mon + 1;
|
||||
t->day = (uint8_t)pTime->tm_mday;
|
||||
t->hour = (uint8_t)pTime->tm_hour;
|
||||
t->minute = (uint8_t)pTime->tm_min;
|
||||
t->second = (uint8_t)pTime->tm_sec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HANDLE findHandle;
|
||||
char path[MAX_PATH_LEN];
|
||||
}readDir_S;
|
||||
|
||||
void* ftpOpenDir(const char* path)
|
||||
{
|
||||
readDir_S* p = malloc(sizeof(readDir_S));
|
||||
|
||||
if(p)
|
||||
{
|
||||
p->findHandle = INVALID_HANDLE_VALUE;
|
||||
strcpy(p->path, path);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
const char* ftpReadDir(void* dirHandle)
|
||||
{
|
||||
WIN32_FIND_DATA findData;
|
||||
readDir_S* p = dirHandle;
|
||||
|
||||
if(dirHandle == NULL)
|
||||
return NULL;
|
||||
|
||||
if(p->findHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if(strcmp(p->path, "/"))
|
||||
strcat(p->path, "/*");
|
||||
else
|
||||
strcat(p->path, "*");
|
||||
|
||||
p->findHandle = FindFirstFile(p->path, &findData);
|
||||
if(p->findHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
strcpy(p->path, findData.cFileName);
|
||||
return p->path;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FindNextFile(p->findHandle, &findData))
|
||||
{
|
||||
strcpy(p->path, findData.cFileName);
|
||||
return p->path;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int ftpCloseDir(void* dirHandle)
|
||||
{
|
||||
readDir_S* p = dirHandle;
|
||||
|
||||
if(dirHandle)
|
||||
{
|
||||
FindClose(p->findHandle);
|
||||
free(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpStat(const char* path, ftpPathInfo_S *info)
|
||||
{
|
||||
struct stat fileInfo = {0};
|
||||
struct tm *pTime;
|
||||
|
||||
if(!stat(path, &fileInfo))
|
||||
{
|
||||
if(fileInfo.st_mode & _S_IFREG)
|
||||
info->type = TYPE_FILE;
|
||||
else if(fileInfo.st_mode & _S_IFDIR)
|
||||
info->type = TYPE_DIR;
|
||||
else
|
||||
info->type = TYPE_LINK;
|
||||
|
||||
pTime = localtime(&fileInfo.st_mtime);
|
||||
if(pTime)
|
||||
{
|
||||
info->mTime.year = (uint16_t)pTime->tm_year + 1900;
|
||||
info->mTime.month = (uint8_t)pTime->tm_mon + 1;
|
||||
info->mTime.day = (uint8_t)pTime->tm_mday;
|
||||
info->mTime.hour = (uint8_t)pTime->tm_hour;
|
||||
info->mTime.minute = (uint8_t)pTime->tm_min;
|
||||
info->mTime.second = (uint8_t)pTime->tm_sec;
|
||||
}
|
||||
pTime = localtime(&fileInfo.st_ctime);
|
||||
if(pTime)
|
||||
{
|
||||
info->cTime.year = (uint16_t)pTime->tm_year + 1900;
|
||||
info->cTime.month = (uint8_t)pTime->tm_mon + 1;
|
||||
info->cTime.day = (uint8_t)pTime->tm_mday;
|
||||
info->cTime.hour = (uint8_t)pTime->tm_hour;
|
||||
info->cTime.minute = (uint8_t)pTime->tm_min;
|
||||
info->cTime.second = (uint8_t)pTime->tm_sec;
|
||||
}
|
||||
pTime = localtime(&fileInfo.st_atime);
|
||||
if(pTime)
|
||||
{
|
||||
info->aTime.year = (uint16_t)pTime->tm_year + 1900;
|
||||
info->aTime.month = (uint8_t)pTime->tm_mon + 1;
|
||||
info->aTime.day = (uint8_t)pTime->tm_mday;
|
||||
info->aTime.hour = (uint8_t)pTime->tm_hour;
|
||||
info->aTime.minute = (uint8_t)pTime->tm_min;
|
||||
info->aTime.second = (uint8_t)pTime->tm_sec;
|
||||
}
|
||||
|
||||
info->size = (uint32_t)fileInfo.st_size;
|
||||
info->links = (int)fileInfo.st_nlink;
|
||||
|
||||
strncpy(info->user, "ftp", sizeof(info->user));
|
||||
strncpy(info->group, "ftp", sizeof(info->group));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ftpMakeDir(const char* path)
|
||||
{
|
||||
|
||||
return !CreateDirectory(path, NULL);
|
||||
}
|
||||
|
||||
int ftpRemoveDir(const char* path)
|
||||
{
|
||||
return !RemoveDirectory(path);
|
||||
}
|
||||
|
||||
|
||||
int ftpCloseSocket(socket_t s)
|
||||
{
|
||||
return closesocket((SOCKET)s);
|
||||
}
|
||||
|
||||
int ftpSend(socket_t s, const void *data, int len)
|
||||
{
|
||||
int currLen = 0;
|
||||
|
||||
do
|
||||
{
|
||||
currLen = send((SOCKET)s, data, len, 0);
|
||||
if(currLen >= 0)
|
||||
{
|
||||
len -= currLen;
|
||||
data = (uint8_t*)data + currLen;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
|
||||
}while(len > 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpReceive(socket_t s, void *data, int len)
|
||||
{
|
||||
return recv(s, data, len, 0);
|
||||
}
|
||||
|
||||
socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port)
|
||||
{
|
||||
SOCKET dataSocket;
|
||||
struct sockaddr_in clientAddr;
|
||||
struct sockaddr_in myAddr;
|
||||
BOOL on = 1;
|
||||
unsigned len;
|
||||
dataSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(dataSocket < 0)
|
||||
return -1;
|
||||
|
||||
if(!passive)
|
||||
{
|
||||
if(setsockopt(dataSocket, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)))
|
||||
{
|
||||
closesocket(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
myAddr.sin_family = AF_INET;
|
||||
myAddr.sin_addr.s_addr = INADDR_ANY;
|
||||
myAddr.sin_port = htons(20);
|
||||
if(bind(dataSocket, (struct sockaddr *)&myAddr, sizeof(myAddr)))
|
||||
{
|
||||
closesocket(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
clientAddr.sin_family = AF_INET;
|
||||
clientAddr.sin_addr.s_addr = htonl(*ip);
|
||||
clientAddr.sin_port = htons(*port);
|
||||
if(connect(dataSocket, (struct sockaddr *)&clientAddr, sizeof(clientAddr)))
|
||||
{
|
||||
closesocket(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myAddr.sin_family = AF_INET;
|
||||
myAddr.sin_addr.s_addr = INADDR_ANY;
|
||||
myAddr.sin_port = htons(0);
|
||||
if(bind(dataSocket, (struct sockaddr *)&myAddr, sizeof(myAddr)))
|
||||
{
|
||||
closesocket(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
len = sizeof(myAddr);
|
||||
if(getsockname(dataSocket, (struct sockaddr *)&myAddr, &len)) // Port des Server-Sockets ermitteln
|
||||
{
|
||||
closesocket(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
|
||||
*port = ntohs(myAddr.sin_port);
|
||||
*ip = ownIp;
|
||||
|
||||
if(listen(dataSocket, 1))
|
||||
{
|
||||
closesocket(dataSocket);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return (socket_t)dataSocket;
|
||||
}
|
||||
|
||||
socket_t ftpAcceptDataConnection(socket_t listner)
|
||||
{
|
||||
struct sockaddr_in clientinfo;
|
||||
unsigned len;
|
||||
SOCKET dataSocket;
|
||||
|
||||
len = sizeof(clientinfo);
|
||||
|
||||
dataSocket = accept(listner, (struct sockaddr *)&clientinfo, &len);
|
||||
if(dataSocket < 0)
|
||||
dataSocket = -1;
|
||||
|
||||
closesocket(listner); // Server-Socket wird nicht mehr gebrauch deshalb schließen
|
||||
return (socket_t)dataSocket;
|
||||
}
|
||||
|
||||
socket_t ftpCreateServerSocket(void)
|
||||
{
|
||||
SOCKET theServer;
|
||||
struct sockaddr_in serverinfo;
|
||||
unsigned len;
|
||||
|
||||
theServer = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(theServer < 0)
|
||||
return -1;
|
||||
|
||||
serverinfo.sin_family = AF_INET;
|
||||
serverinfo.sin_addr.s_addr = INADDR_ANY;
|
||||
serverinfo.sin_port = htons(21);
|
||||
len = sizeof(serverinfo);
|
||||
|
||||
int val = 1;
|
||||
#ifndef WIN32
|
||||
setsockopt(theServer, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
|
||||
#else
|
||||
setsockopt(theServer, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
|
||||
#endif
|
||||
|
||||
if(bind(theServer, (struct sockaddr *)&serverinfo, len))
|
||||
{
|
||||
ftpCloseSocket(theServer);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if(listen(theServer, 3))
|
||||
{
|
||||
ftpCloseSocket(theServer);
|
||||
return -3;
|
||||
}
|
||||
|
||||
return (socket_t)theServer;
|
||||
}
|
||||
|
||||
socket_t ftpAcceptServerConnection(socket_t server, ip_t *remoteIP, port_t *remotePort)
|
||||
{
|
||||
struct sockaddr_in sockinfo;
|
||||
socket_t clientSocket;
|
||||
int len;
|
||||
|
||||
len = sizeof(sockinfo);
|
||||
|
||||
clientSocket = accept(server, (struct sockaddr *)&sockinfo, &len);
|
||||
*remoteIP = ntohl(sockinfo.sin_addr.s_addr);
|
||||
*remotePort = ntohs(sockinfo.sin_port);
|
||||
|
||||
if(!ownIp) // kennen wir schon die eigene IP?
|
||||
{
|
||||
len = sizeof(sockinfo);
|
||||
if(getsockname(clientSocket, (struct sockaddr *)&sockinfo, &len))
|
||||
{
|
||||
#if DBG_LOG
|
||||
printf("getsockname error\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
ownIp = ntohl(sockinfo.sin_addr.s_addr); // eigene IP-Adresse abspeichern (wird dir PASV benätigt)
|
||||
}
|
||||
#if DBG_LOG
|
||||
printf("Verbindung mit %s auf Port %d akzeptiert.\n", inet_ntoa(sockinfo.sin_addr), *remotePort);
|
||||
#endif
|
||||
return clientSocket;
|
||||
}
|
||||
|
||||
int ftpTrackSocket(socket_t s)
|
||||
{
|
||||
if(s > maxSockNr)
|
||||
maxSockNr = s;
|
||||
FD_SET(s, &watchedSockets);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpUntrackSocket(socket_t s)
|
||||
{
|
||||
FD_CLR((SOCKET)s, &watchedSockets);
|
||||
// TODO hier sollte eine Möglichkeit geschaffen werden um maxSockNr anzupassen
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ftpTestSocket(socket_t s)
|
||||
{
|
||||
return FD_ISSET(s, &signaledSockets);
|
||||
}
|
||||
|
||||
int ftpSelect(int poll)
|
||||
{
|
||||
signaledSockets = watchedSockets;
|
||||
|
||||
if(poll)
|
||||
{
|
||||
struct timeval t = {0};
|
||||
return select(maxSockNr+1, &signaledSockets, NULL, NULL, &t);
|
||||
}
|
||||
else
|
||||
return select(maxSockNr+1, &signaledSockets, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,205 @@
|
|||
// ==============================================================
|
||||
// This file is part of MegaGlest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2009-2010 Titus Tscharntke (info@titusgames.de) and
|
||||
// Mark Vejvoda (mark_vejvoda@hotmail.com)
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "miniftpclient.h"
|
||||
#include "util.h"
|
||||
#include "platform_common.h"
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <curl/types.h>
|
||||
#include <curl/easy.h>
|
||||
|
||||
using namespace Shared::Util;
|
||||
using namespace Shared::PlatformCommon;
|
||||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
/*
|
||||
* This is an example showing how to get a single file from an FTP server.
|
||||
* It delays the actual destination file creation until the first write
|
||||
* callback so that it won't create an empty file in case the remote file
|
||||
* doesn't exist or something else fails.
|
||||
*/
|
||||
|
||||
struct FtpFile {
|
||||
const char *filename;
|
||||
FILE *stream;
|
||||
};
|
||||
|
||||
static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
|
||||
{
|
||||
struct FtpFile *out=(struct FtpFile *)stream;
|
||||
if(out && !out->stream) {
|
||||
/* open file for writing */
|
||||
out->stream=fopen(out->filename, "wb");
|
||||
if(!out->stream)
|
||||
return -1; /* failure, can't open file to write */
|
||||
}
|
||||
return fwrite(buffer, size, nmemb, out->stream);
|
||||
}
|
||||
|
||||
FTPClientThread::FTPClientThread(string serverUrl, std::pair<string,string> mapsPath, FTPClientCallbackInterface *pCBObject) : BaseThread() {
|
||||
this->serverUrl = serverUrl;
|
||||
this->mapsPath = mapsPath;
|
||||
this->pCBObject = pCBObject;
|
||||
}
|
||||
|
||||
void FTPClientThread::signalQuit() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client: signalQuit\n");
|
||||
BaseThread::signalQuit();
|
||||
}
|
||||
|
||||
bool FTPClientThread::shutdownAndWait() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client: shutdownAndWait\n");
|
||||
|
||||
signalQuit();
|
||||
return BaseThread::shutdownAndWait();
|
||||
}
|
||||
|
||||
void FTPClientThread::getMapFromServer(string mapFileName) {
|
||||
CURLcode res;
|
||||
|
||||
FTP_Client_ResultType result = ftp_crt_FAIL;
|
||||
|
||||
string destFile = this->mapsPath.second + mapFileName;
|
||||
|
||||
struct FtpFile ftpfile = {
|
||||
destFile.c_str(), /* name to store the file as if succesful */
|
||||
NULL
|
||||
};
|
||||
|
||||
//curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
CURL *curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/*
|
||||
* You better replace the URL with one that works!
|
||||
*/
|
||||
|
||||
char szBuf[1024]="";
|
||||
sprintf(szBuf,"ftp://maps:mg_ftp_server@%s/maps/%s",serverUrl.c_str(),mapFileName.c_str());
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL,szBuf);
|
||||
/* Define our callback to get called when there's data to be written */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
|
||||
/* Set a pointer to our struct to pass to the callback */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
|
||||
|
||||
/* Switch on full protocol/debug output */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
//curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != res) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", res);
|
||||
|
||||
sprintf(szBuf,"ftp://maps_custom:mg_ftp_server@%s/maps/%s",serverUrl.c_str(),mapFileName.c_str());
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL,szBuf);
|
||||
/* Define our callback to get called when there's data to be written */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
|
||||
/* Set a pointer to our struct to pass to the callback */
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile);
|
||||
|
||||
/* Switch on full protocol/debug output */
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* always cleanup */
|
||||
//curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != res) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", res);
|
||||
}
|
||||
else {
|
||||
result = ftp_crt_SUCCESS;
|
||||
}
|
||||
}
|
||||
else {
|
||||
result = ftp_crt_SUCCESS;
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
if(ftpfile.stream) {
|
||||
fclose(ftpfile.stream); /* close the local file */
|
||||
}
|
||||
|
||||
//curl_global_cleanup();
|
||||
|
||||
if(this->pCBObject != NULL) {
|
||||
this->pCBObject->FTPClient_CallbackEvent(mapFileName,result);
|
||||
}
|
||||
}
|
||||
|
||||
void FTPClientThread::addMapToRequests(string mapFilename) {
|
||||
MutexSafeWrapper safeMutex(&mutexMapFileList);
|
||||
mapFileList.push_back(mapFilename);
|
||||
}
|
||||
|
||||
|
||||
void FTPClientThread::execute() {
|
||||
{
|
||||
RunningStatusSafeWrapper runningStatus(this);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client thread is running\n");
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"FTP Client thread is running\n");
|
||||
|
||||
try {
|
||||
while(this->getQuitStatus() == false) {
|
||||
MutexSafeWrapper safeMutex(&mutexMapFileList);
|
||||
if(mapFileList.size() > 0) {
|
||||
string mapFilename = mapFileList[0];
|
||||
mapFileList.erase(mapFileList.begin() + 0);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
getMapFromServer(mapFilename);
|
||||
}
|
||||
else {
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
sleep(25);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Client exiting!\n");
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
}
|
||||
catch(...) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] unknown error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] FTP Client thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
// Delete ourself when the thread is done (no other actions can happen after this
|
||||
// such as the mutex which modifies the running status of this method
|
||||
//delete this;
|
||||
}
|
||||
|
||||
}}//end namespace
|
|
@ -0,0 +1,102 @@
|
|||
// ==============================================================
|
||||
// This file is part of MegaGlest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2009-2010 Titus Tscharntke (info@titusgames.de) and
|
||||
// Mark Vejvoda (mark_vejvoda@hotmail.com)
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
// by the Free Software Foundation; either version 2 of the
|
||||
// License, or (at your option) any later version
|
||||
// ==============================================================
|
||||
|
||||
#include "miniftpserver.h"
|
||||
#include "util.h"
|
||||
#include "platform_common.h"
|
||||
#include "ftpIfc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace Shared::Util;
|
||||
using namespace Shared::PlatformCommon;
|
||||
|
||||
namespace Shared { namespace PlatformCommon {
|
||||
|
||||
FTPServerThread::FTPServerThread(std::pair<string,string> mapsPath) : BaseThread() {
|
||||
this->mapsPath = mapsPath;
|
||||
}
|
||||
|
||||
void FTPServerThread::signalQuit() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server: signalQuit\n");
|
||||
BaseThread::signalQuit();
|
||||
}
|
||||
|
||||
bool FTPServerThread::shutdownAndWait() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server: shutdownAndWait\n");
|
||||
|
||||
signalQuit();
|
||||
return BaseThread::shutdownAndWait();
|
||||
}
|
||||
|
||||
void FTPServerThread::execute() {
|
||||
{
|
||||
RunningStatusSafeWrapper runningStatus(this);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server thread is running\n");
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"FTP Server thread is running\n");
|
||||
|
||||
try {
|
||||
//ftpCreateAccount("anonymous", "", mapsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
|
||||
if(mapsPath.first != "") {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] mapsPath #1 [%s]\n",__FILE__,__FUNCTION__,__LINE__,mapsPath.first.c_str());
|
||||
ftpCreateAccount("maps", "mg_ftp_server", mapsPath.first.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
}
|
||||
if(mapsPath.second != "") {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] mapsPath #2 [%s]\n",__FILE__,__FUNCTION__,__LINE__,mapsPath.second.c_str());
|
||||
ftpCreateAccount("maps_custom", "mg_ftp_server", mapsPath.second.c_str(), FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
}
|
||||
|
||||
/*
|
||||
ftpCreateAccount("anonymous", "", "./", FTP_ACC_RD | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
ftpCreateAccount("nothing", "", "./", 0);
|
||||
ftpCreateAccount("reader", "", "./", FTP_ACC_RD);
|
||||
ftpCreateAccount("writer", "", "./", FTP_ACC_WR);
|
||||
ftpCreateAccount("lister", "", "./", FTP_ACC_LS);
|
||||
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
*/
|
||||
ftpStart();
|
||||
while(this->getQuitStatus() == false) {
|
||||
ftpExecute();
|
||||
sleep(25);
|
||||
}
|
||||
ftpShutdown();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> FTP Server exiting!\n");
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
}
|
||||
catch(...) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] UNKNOWN Error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] unknown error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] FTP Server thread is exiting\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
// Delete ourself when the thread is done (no other actions can happen after this
|
||||
// such as the mutex which modifies the running status of this method
|
||||
//delete this;
|
||||
}
|
||||
|
||||
}}//end namespace
|
Loading…
Reference in New Issue