00001 00006 #include <unistd.h> //for close(), write(), read(), fstat(), 00007 #include <stdio.h> //for fprintf(), perror(), snprintf(), 00008 #include <stdlib.h> //for exit(), atoi(), 00009 #include <string.h> //for strlen(),strcpy() 00010 #include <strings.h> //for bzero(), 00011 #include <sys/socket.h> //for socket(), bind(), listen(), accept(), 00012 #include <sys/types.h> //for socket(), bind(), accpet(), fstat(), open() 00013 #include <netinet/in.h> //for struct sockaddr_in, 00014 #include <time.h> //for time(), time_t, 00015 #include <signal.h> //for sigaction(), 00016 #include <sys/select.h> //for select(), 00017 #include <fcntl.h> //for open(), 00018 #include <sys/time.h> //for time(), 00019 #include <arpa/inet.h> //for inet_ntoa(), 00020 #include <pthread.h> //for pthread_create(), pthread_exit() 00021 #include <gtk/gtk.h> //for all gtk functions.. 00022 #include <time.h> //for time(), 00023 #include <mysql/mysql.h>// for mysql_real_connect(), mysql_query() 00024 00025 #define BUFFER 4096 00026 #define DATASIZE 100 00032 struct client_data{ 00033 int fd; 00034 char nick[DATASIZE]; 00035 char ip[DATASIZE]; 00036 }; 00037 00044 struct transmit_unit{ 00045 char nick[DATASIZE]; 00046 char time[DATASIZE]; 00047 char ip[DATASIZE]; 00048 char msg[BUFFER]; 00049 }; 00050 00051 00052 GtkWidget *entry_port; 00053 GtkTextBuffer *buffer; 00054 GtkTextIter iter; 00056 GtkListStore *list_store; 00057 GtkTreeIter t_iter; 00060 int listen_file_descriptor; 00062 struct client_data client[FD_SETSIZE]; 00064 int maxi; 00065 char err_msg[BUFFER]; 00066 char ip[BUFFER]; 00067 char nick[BUFFER]; 00068 int success; 00071 MYSQL *connection1;