0
私は少しのFTPサーバーを作成し、いくつかのコマンドを用意しました。ここで私のFTPサーバーの<CRLF>を確認する方法
は、私はそれが私のリンクリストの私のコマンドのいずれかと一致するかどうかを確認するために、ユーザーからの入力をチェックする方法は次のとおりです。
int check_cmd(char *buff, char *cmd)
{
int end;
if (strstr(buff, cmd) != buff)
return (-1);
end = strlen(cmd);
if (buff[end] != '\0' && buff[end] != ' ' && buff[end] != '\n')
return (-1);
return (0);
}
void read_command(t_client *client, t_cmd *lexer)
{
t_cmd *current;
bzero(client->buff, MAX_READ + 1);
server_read(client);
current = lexer;
while (current != NULL) // Go through the linked list, checking if it matches
{
if (check_cmd(client->buff, current->cmd) == 0) // It matches a command !
{
current->ptr(client); // Calls the appropriate function
return ;
}
current = current->next;
}
server_write(client, "Invalid command.\n");
}
しかしnetcat
ため-C
オプションを使用すると、すべてのコマンドにデフォルトで\r\n
をお送りしますまだ、私はそれをチェックしていません。
<CRLF>
がコマンドラインで渡されるかどうかを確認するにはどうすればよいですか?