|
Revision 154, 0.8 KB
(checked in by malte, 2 years ago)
|
|
|
| Line | |
|---|
| 1 | |
|---|
| 2 | #include "helo_syntax.h" |
|---|
| 3 | |
|---|
| 4 | int helo_syntax(int fd, license_data_type *ld, char *buff) |
|---|
| 5 | { |
|---|
| 6 | char *ptr; |
|---|
| 7 | |
|---|
| 8 | ptr = strstr(buff, message(MSG_HELO_CMD)); |
|---|
| 9 | |
|---|
| 10 | if (ptr != buff || strlen(buff) == 7) { |
|---|
| 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 | char *helo_ans = calloc(MAX_MSG_SIZE, sizeof(char)); |
|---|
| 20 | memset(ld -> ip, '\0', MAX_MSG_SIZE); |
|---|
| 21 | |
|---|
| 22 | memset(ld -> host, '\0', MAX_MSG_SIZE); |
|---|
| 23 | |
|---|
| 24 | strcat(ld -> ip, client_ip); |
|---|
| 25 | |
|---|
| 26 | ptr = strstr(buff, " "); |
|---|
| 27 | |
|---|
| 28 | strncat(ld -> host, ptr + 1, strlen(ptr + 1) - 2); |
|---|
| 29 | |
|---|
| 30 | strcat(helo_ans, message(MSG_CMD_OK)); |
|---|
| 31 | strcat(helo_ans, ld -> host); |
|---|
| 32 | strcat(helo_ans, "\r\n"); |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | if (send_line(fd, helo_ans, strlen(helo_ans)) < 0) { |
|---|
| 36 | free(helo_ans); |
|---|
| 37 | return (-1); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | free(helo_ans); |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | return (NO_ERROR); |
|---|
| 44 | } |
|---|