diff --git a/include/chat/misc.h b/include/chat/misc.h index c361be8..d158620 100644 --- a/include/chat/misc.h +++ b/include/chat/misc.h @@ -1,6 +1,6 @@ #ifndef WHY2_CHAT_MISC_H #define WHY2_CHAT_MISC_H - +void send_socket(char *text, int socket); //send socket.... wtf did you expect #endif \ No newline at end of file diff --git a/src/chat/main/client.c b/src/chat/main/client.c index bbe552b..797fc17 100644 --- a/src/chat/main/client.c +++ b/src/chat/main/client.c @@ -17,11 +17,10 @@ along with this program. If not, see . */ #include +#include #include -void send_socket(char *text, int socket); - int main(void) { int listen_socket = socket(AF_INET, SOCK_STREAM, 0); //CREATE SERVER SOCKET @@ -64,24 +63,4 @@ int main(void) free(line); return 0; -} - -void send_socket(char *text, int socket) -{ - unsigned short text_length = (unsigned short) strlen(text); - char *final = why2_calloc(strlen(text) + 2, sizeof(char)); - - //SPLIT LENGTH INTO TWO CHARS - final[0] = (unsigned) text_length & 0xff; - final[1] = (unsigned) text_length >> 8; - - for (int i = 2; i < text_length + 2; i++) //APPEND - { - final[i] = text[i - 2]; - } - - //SEND - send(socket, final, text_length + 2, 0); - - why2_deallocate(final); } \ No newline at end of file diff --git a/src/chat/misc.c b/src/chat/misc.c index e69de29..9c455eb 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -0,0 +1,26 @@ +#include + +#include +#include + +#include + +void send_socket(char *text, int socket) +{ + unsigned short text_length = (unsigned short) strlen(text); + char *final = why2_calloc(strlen(text) + 2, sizeof(char)); + + //SPLIT LENGTH INTO TWO CHARS + final[0] = (unsigned) text_length & 0xff; + final[1] = (unsigned) text_length >> 8; + + for (int i = 2; i < text_length + 2; i++) //APPEND + { + final[i] = text[i - 2]; + } + + //SEND + send(socket, final, text_length + 2, 0); + + why2_deallocate(final); +} \ No newline at end of file