Rev 2581 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2581 | Rev 2585 | ||
---|---|---|---|
Line 99... | Line 99... | ||
99 | mov [socketnum], eax |
99 | mov [socketnum], eax |
Line 100... | Line 100... | ||
100 | 100 | ||
101 | push str2 |
101 | push str2 |
Line 102... | Line 102... | ||
102 | call [con_write_asciiz] |
102 | call [con_write_asciiz] |
103 | 103 | ||
104 | ;; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes, |
104 | ; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes, |
Line 105... | Line 105... | ||
105 | ;; cmp eax, -1 |
105 | ; cmp eax, -1 |
106 | ;; je opt_err |
106 | ; je opt_err |
107 | 107 | ||
Line 130... | Line 130... | ||
130 | 130 | ||
131 | mcall 51, 1, threadstart, 0 ; Start a new thread for every incoming connection |
131 | mcall 51, 1, threadstart, 0 ; Start a new thread for every incoming connection |
132 | ; NOTE: upon initialisation of the thread, stack will not be available! |
132 | ; NOTE: upon initialisation of the thread, stack will not be available! |
Line -... | Line 133... | ||
- | 133 | jmp mainloop |
|
133 | jmp mainloop |
134 | |
134 | 135 | diff16 "threadstart", 0, $ |
|
135 | threadstart: |
136 | threadstart: |
136 | mcall 68, 12, sizeof.thread_data ; allocate the thread data struct |
137 | mcall 68, 12, sizeof.thread_data ; allocate the thread data struct |
Line 137... | Line 138... | ||
137 | cmp eax, -1 |
138 | cmp eax, -1 |
138 | je exit |
139 | je exit |
Line 139... | Line 140... | ||
139 | 140 | ||
Line -... | Line 141... | ||
- | 141 | lea esp, [eax + thread_data.stack] ; init stack |
|
- | 142 | push eax ; save pointer to thread_data on stack |
|
140 | lea esp, [eax + thread_data.stack] ; init stack |
143 | |
141 | push eax ; save pointer to thread_data on stack |
144 | mcall 40, 1 shl 7 ; we only want network events for this thread |
- | 145 | ||
- | 146 | pushd 0x03 |
|
Line 142... | Line 147... | ||
142 | 147 | call [con_set_flags] |
|
143 | mcall 40, 1 shl 7 ; we only want network events for this thread |
148 | push str8 |
144 | 149 | call [con_write_asciiz] ; print on the console that we have created the new thread successfully |
|
145 | push str8 |
150 | pushd 0x07 |
Line 185... | Line 190... | ||
185 | push eax ; save number of bytes read on stack |
190 | push eax ; save number of bytes read on stack |
Line 186... | Line 191... | ||
186 | 191 | ||
187 | mov edx, [esp+4] ; pointer to thread_data |
192 | mov edx, [esp+4] ; pointer to thread_data |
Line 188... | Line 193... | ||
188 | mov byte [edx + thread_data.buffer + eax], 0 ; append received data with a 0 byte |
193 | mov byte [edx + thread_data.buffer + eax], 0 ; append received data with a 0 byte |
189 | 194 | ||
- | 195 | pushd 0x02 ; print received data to console (in green color) |
|
- | 196 | call [con_set_flags] |
|
190 | pushd 0x0a ; print received data to console (in green color) |
197 | push str_newline |
191 | call [con_set_flags] |
198 | call [con_write_asciiz] |
192 | lea eax, [edx + thread_data.buffer] |
199 | lea eax, [edx + thread_data.buffer] |
193 | push eax |
200 | push eax |
194 | call [con_write_asciiz] |
201 | call [con_write_asciiz] |
Line 242... | Line 249... | ||
242 | ; initialized data |
249 | ; initialized data |
Line 243... | Line 250... | ||
243 | 250 | ||
244 | title db 'KolibriOS FTP daemon 0.1', 0 |
251 | title db 'KolibriOS FTP daemon 0.1', 0 |
245 | str1 db 'Starting FTP daemon on port %u', 0 |
252 | str1 db 'Starting FTP daemon on port %u', 0 |
246 | str2 db '.', 0 |
253 | str2 db '.', 0 |
247 | str2b db ' OK!',10,10,0 |
254 | str2b db ' OK!',10,0 |
248 | str3 db 'Listen error',10,10,0 |
255 | str3 db 'Listen error',10,0 |
249 | str4 db 'Bind error',10,10,0 |
256 | str4 db 'Bind error',10,0 |
250 | ;str5 db 'Setsockopt error.',10,10,0 |
257 | ;str5 db 'Setsockopt error.',10,10,0 |
251 | str6 db 'Could not open socket',10,10,0 |
258 | str6 db 'Could not open socket',10,0 |
252 | str7 db 'Got data!',10,10,0 |
259 | str7 db 'Got data!',10,10,0 |
253 | str8 db 10,'New thread created!',10,10,0 |
260 | str8 db 10,'New thread created!',10,0 |
Line 254... | Line 261... | ||
254 | str_bye db 10,'Closing thread!',10,10,0 |
261 | str_bye db 10,'Closing thread!',10,0 |
255 | 262 | ||
256 | str_logged_in db 'Login ok',10,10,0 |
263 | str_logged_in db 'Login ok',10,0 |
257 | str_pass_ok db 'Password ok - Logged in',10,10,0 |
264 | str_pass_ok db 'Password ok - Logged in',10,0 |
258 | str_pwd db 'Current directory is "%s"\n',0 |
265 | str_pwd db 'Current directory is "%s"\n',0 |
259 | str_err2 db 'ERROR: cannot open directory',10,10,0 |
266 | str_err2 db 'ERROR: cannot open directory',10,0 |
260 | str_datasock db 'Passive data socket connected!',10,10,0 |
267 | str_datasock db 'Passive data socket connected!',10,0 |
Line 261... | Line 268... | ||
261 | str_notfound db 'ERROR: file not found',10,10,0 |
268 | str_notfound db 'ERROR: file not found',10,0 |
262 | str_sockerr db 'ERROR: socket error',10,10,0 |
269 | str_sockerr db 'ERROR: socket error',10,0 |
Line 263... | Line 270... | ||
263 | 270 |