forked from KolibriOS/kolibrios
Compare commits
2 Commits
add-thread
...
libc.obj--
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cf8126b97 | |||
|
|
f9425f5bd0 |
@@ -32,6 +32,7 @@ DLLAPI char* strrchr(const char* s, int c);
|
||||
DLLAPI size_t strspn(const char* s1, const char* s2);
|
||||
DLLAPI char* strstr(const char* s1, const char* s2);
|
||||
DLLAPI char* strtok(char* s1, const char* s2);
|
||||
DLLAPI char* strtok_r(char* s1, const char* s2, char** saveptr);
|
||||
DLLAPI char* strerror(int errnum);
|
||||
DLLAPI size_t strlen(const char* s);
|
||||
DLLAPI char* strrev(char* str);
|
||||
|
||||
@@ -203,6 +203,7 @@ ksys_dll_t EXPORTS[] = {
|
||||
{ "strspn", &strspn },
|
||||
{ "strstr", &strstr },
|
||||
{ "strtok", &strtok },
|
||||
{ "strtok_r", &strtok_r },
|
||||
{ "strxfrm", &strxfrm },
|
||||
{ "strpbrk", &strpbrk },
|
||||
{ "__errno", &__errno },
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
|
||||
#include <string.h>
|
||||
|
||||
char* strtok(char* s, const char* delim)
|
||||
char* strtok_r(char* s, const char* delim, char** last)
|
||||
{
|
||||
const char* spanp;
|
||||
char *spanp, *tok;
|
||||
int c, sc;
|
||||
char* tok;
|
||||
static char* last;
|
||||
|
||||
if (s == NULL && (s = last) == NULL)
|
||||
if (s == NULL && (s = *last) == NULL)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
@@ -16,13 +14,13 @@ char* strtok(char* s, const char* delim)
|
||||
*/
|
||||
cont:
|
||||
c = *s++;
|
||||
for (spanp = delim; (sc = *spanp++) != 0;) {
|
||||
for (spanp = (char*)delim; (sc = *spanp++) != 0;) {
|
||||
if (c == sc)
|
||||
goto cont;
|
||||
}
|
||||
|
||||
if (c == 0) { /* no non-delimiter characters */
|
||||
last = NULL;
|
||||
*last = NULL;
|
||||
return (NULL);
|
||||
}
|
||||
tok = s - 1;
|
||||
@@ -33,17 +31,24 @@ cont:
|
||||
*/
|
||||
for (;;) {
|
||||
c = *s++;
|
||||
spanp = delim;
|
||||
spanp = (char*)delim;
|
||||
do {
|
||||
if ((sc = *spanp++) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
last = s;
|
||||
s[-1] = '\0';
|
||||
*last = s;
|
||||
return (tok);
|
||||
}
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
char *strtok(char *s, const char *delim)
|
||||
{
|
||||
static char *last;
|
||||
|
||||
return (strtok_r(s, delim, &last));
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ commands: ; all commands must be in uppercase
|
||||
dd 'CWD', login_first, login_first, login_first, cmdCWD
|
||||
dd 'XCWD', login_first, login_first, login_first, cmdCWD
|
||||
dd 'DELE', login_first, login_first, login_first, cmdDELE
|
||||
; dd 'HELP', login_first, login_first, login_first, cmd_HELP
|
||||
dd 'HELP', login_first, login_first, login_first, cmdHELP
|
||||
dd 'LIST', login_first, login_first, login_first, cmdLIST
|
||||
; dd 'MDTM', login_first, login_first, login_first, cmd_MDTM
|
||||
; dd 'MKD', login_first, login_first, login_first, cmd_MKD
|
||||
@@ -1247,6 +1247,68 @@ cmdTYPE:
|
||||
sendFTP "200 Command ok"
|
||||
ret
|
||||
|
||||
;------------------------------------------------
|
||||
; "HELP"
|
||||
;
|
||||
; Provide help information.
|
||||
;
|
||||
;------------------------------------------------
|
||||
align 4
|
||||
cmdHELP:
|
||||
|
||||
lea edi, [ebp + thread_data.buffer]
|
||||
mov eax, '214 '
|
||||
stosd
|
||||
mov eax, 'Help'
|
||||
stosd
|
||||
mov ax, ': '
|
||||
stosw
|
||||
|
||||
mov esi, commands ; pointer to commands table
|
||||
|
||||
.next_command:
|
||||
cmp byte [esi], 0 ; end of table?
|
||||
je .list_done
|
||||
|
||||
; Copy command name (4 bytes), skip null bytes
|
||||
mov ecx, 4
|
||||
.copy_name:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .skip_null
|
||||
stosb
|
||||
.skip_null:
|
||||
inc esi
|
||||
loop .copy_name
|
||||
|
||||
; Add space after command name
|
||||
mov al, ' '
|
||||
stosb
|
||||
|
||||
; Skip the four address pointers (16 bytes)
|
||||
add esi, 16
|
||||
jmp .next_command
|
||||
|
||||
.list_done:
|
||||
; Remove trailing space (if any)
|
||||
dec edi
|
||||
; Add CRLF
|
||||
mov ax, 0x0a0d ; \r\n
|
||||
stosw
|
||||
xor al, al ; null terminator
|
||||
stosb
|
||||
|
||||
; Calculate length
|
||||
lea edx, [ebp + thread_data.buffer]
|
||||
sub edi, edx
|
||||
|
||||
; Send response
|
||||
mcall send, [ebp + thread_data.socketnum], edx, edi
|
||||
; Also log to console
|
||||
invoke con_write_asciiz, edx
|
||||
|
||||
ret
|
||||
|
||||
;------------------------------------------------
|
||||
; "USER"
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user