|
Revision 154, 0.5 KB
(checked in by malte, 2 years ago)
|
|
|
| Line | |
|---|
| 1 | |
|---|
| 2 | #include "bye_syntax.h" |
|---|
| 3 | |
|---|
| 4 | int bye_syntax(int fd, char *buff) |
|---|
| 5 | { |
|---|
| 6 | char *ptr; |
|---|
| 7 | |
|---|
| 8 | ptr = strstr(buff, message(MSG_BYE_CMD)); |
|---|
| 9 | |
|---|
| 10 | if (ptr != buff) { |
|---|
| 11 | |
|---|
| 12 | if (send_line(fd, message(MSG_BAD_SYNTAX), strlen(message(MSG_BAD_SYNTAX))) < 0) { |
|---|
| 13 | return (-1); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | return (1); |
|---|
| 17 | |
|---|
| 18 | } else { |
|---|
| 19 | |
|---|
| 20 | char *bye_ans = calloc(MAX_MSG_SIZE, sizeof(char)); |
|---|
| 21 | |
|---|
| 22 | strcat(bye_ans, message(MSG_CMD_OK)); |
|---|
| 23 | |
|---|
| 24 | strcat(bye_ans, "Good Bye!\r\n"); |
|---|
| 25 | |
|---|
| 26 | if (send_line(fd, bye_ans, strlen(bye_ans)) < 0) { |
|---|
| 27 | |
|---|
| 28 | free(bye_ans); |
|---|
| 29 | |
|---|
| 30 | return (-1); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | free(bye_ans); |
|---|
| 34 | |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | return (NO_ERROR); |
|---|
| 38 | } |
|---|