aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBertrand Jacquin (Beber) <beber@setibzh.com>2006-01-23 01:40:14 +0100
committerBertrand Jacquin (Beber) <beber@setibzh.com>2006-01-23 01:40:14 +0100
commit753787de54eb7e9ec27eee2dfc6e24d42a15971e (patch)
tree911379ba4a6e59e9dccdc945a3abb48f0b6b443b /src
parentStart reorganise all things (diff)
downloadespik-753787de54eb7e9ec27eee2dfc6e24d42a15971e.tar.xz
del unused files and code
Diffstat (limited to 'src')
-rw-r--r--src/espik.c41
-rw-r--r--src/espik_common_handler.c102
-rw-r--r--src/espik_common_handler.h5
-rw-r--r--src/espik_irc.c296
-rw-r--r--src/espik_irc.h29
-rw-r--r--src/espik_net.c181
-rw-r--r--src/espik_net.h12
7 files changed, 1 insertions, 665 deletions
diff --git a/src/espik.c b/src/espik.c
index 0628de2..f4fce5a 100644
--- a/src/espik.c
+++ b/src/espik.c
@@ -14,9 +14,7 @@
#include "espik.h"
#include "espik_global.h"
#include "espik_config.h"
-#include "espik_irc.h"
#include "espik_common_handler.h"
-#include "espik_net.h"
#include "espik_debug.h"
typedef int (*Handler_Func) (void *data, int ev_type, void *ev);
@@ -101,20 +99,7 @@ int main (int argc, char **argv)
printf ("user: %s\n", a_infos.client->username);
printf ("real: %s\n", a_infos.client->realname);
-#if 0
- con_sock =
- ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
- a_infos.server->host,
- (int)a_infos.server->port,
- NULL);
- if (!con_sock)
- {
- fprintf (stderr, "Baaa\n");
- exit (-1);
- }
-#endif
-
- /* Handler Network & Keyboard */
+ /* Handler Keyboard */
fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get,
NULL, NULL, NULL);
espik_free(kb_get);
@@ -123,41 +108,17 @@ int main (int argc, char **argv)
printf ("Cannot ecore_main_fd_handler_add\n");
exit (-1);
}
- /*
- ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
- (Handler_Func) server_data, NULL);
- */
- /*
- espik_con_init (a_infos);
- */
-
/* Init IRC connection */
ecore_main_loop_begin ();
ecore_main_fd_handler_del (fd_kb);
- /*
- ecore_con_server_del (con_sock);
-
- free (a_infos.server->host);
- free (a_infos.server);
-
- free (a_infos.client->nickname);
- free (a_infos.client->username);
- free (a_infos.client->realname);
- free (a_infos.client);
- */
-
espik_debug_print ("end");
espik_config_shutdown (a_infos);
- /*
- espik_con_shutdown ();
- */
-
ecore_shutdown ();
ecore_list_destroy(ptr_list);
diff --git a/src/espik_common_handler.c b/src/espik_common_handler.c
index 3f3ee2e..b5b2432 100644
--- a/src/espik_common_handler.c
+++ b/src/espik_common_handler.c
@@ -10,112 +10,10 @@
#include "espik_global.h"
#include "espik_common_handler.h"
-#include "espik_irc.h"
-#include "espik_net.h"
#include "espik.h"
#include "espik_error.h"
#include "espik_debug.h"
-#if 0
-static char* convert_utf_unicode(char* putf)
-{
- int len;
- wchar_t* punicode;
- espik_enter();
-
- len = strlen(putf)+ 1;
-
- punicode = (wchar_t *)malloc(len * sizeof(wchar_t));
-
- if (punicode == NULL)
- return NULL;
-
-#ifdef UNICODE
- strcpy(punicode,putf);
-#else
- if (mbstowcs(punicode,putf,len) < 0)
- {
- free(punicode);
- return NULL;
- }
-#endif
-
- espik_leave();
- return punicode;
-}
-
-
-static char* convert_unicode_utf(const wchar_t *punicode)
-{
- int len;
- char* putf;
- espik_enter();
-
- len = wcslen(punicode) + 1;
-
- putf = (char *)malloc(len * sizeof(wchar_t));
-
- if (!putf)
- return NULL;
-#ifdef UNICODE
- strcpy(putf, punicode);
-#else
- if (wcstombs(putf,punicode,len) < 0)
- {
- free (putf);
- return NULL;
- }
-#endif
- espik_leave();
- return putf;
-}
-#endif
-
-#if 0
-int server_data (void* data __UNUSED__, int ev_type __UNUSED__,
- Ecore_Con_Event_Server_Data* ev)
-{
- unsigned int i;
- char* msg;
- espik_enter();
- static int count_num_recv = 0;
-
- msg = strdup((char*)ev->data);
- //msg = convert_unicode_utf((const wchar_t*)ev->data);
- //msg = convert_utf_unicode((char*)ev->data);
-
- if (!msg)
- return 0;
-
- count_num_recv++;
-
- espik_debug_print ("%s", msg);
-
- for (i=0 ; i < strlen(msg) ; i++)
- {
- if (msg[i] == ' ')
- msg[i] = '\0';
- }
-
- if (count_num_recv >= 1 && !com_active)
- {
- server_dns = strdup (msg+1);
- send_login();
- }
-
- if (! (strcmp (msg, "PING")))
- {
- espik_raw_send ("PONG guybrush.melee");
- }
-
- memset (msg, 0, strlen(msg));
- free (msg);
-
- espik_leave();
- return (0);
-}
-#endif
-
int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
{
char* kb;
diff --git a/src/espik_common_handler.h b/src/espik_common_handler.h
index fddece4..49f411d 100644
--- a/src/espik_common_handler.h
+++ b/src/espik_common_handler.h
@@ -6,11 +6,6 @@
#include "espik_global.h"
-int com_active;
-char* server_dns;
-
-int server_data (void *__UNUSED__, int __UNUSED__,
- Ecore_Con_Event_Server_Data * __UNUSED__);
int kb_get (void *__UNUSED__, Ecore_Fd_Handler *);
#endif /* HAVE_ESPIK_COMMON_HANDLER_H */
diff --git a/src/espik_irc.c b/src/espik_irc.c
deleted file mode 100644
index dbe962d..0000000
--- a/src/espik_irc.c
+++ /dev/null
@@ -1,296 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <Ecore.h>
-/*#include <Ecore_Con.h>*/
-
-#include "espik_global.h"
-#include "espik_irc.h"
-#include "espik_error.h"
-/*#include "espik_common_handler.h"*/
-#include "espik_net.h"
-#include "espik_debug.h"
-#include "espik.h"
-
-char* current_chan;
-
-typedef struct
-{
- char* cmd_name;
- char* (*format) (char *dest, char *msg);
-} cmd_t;
-
-cmd_t cmd_tab[] = {
- { "JOIN", irc_join },
- { "PART", irc_part },
- { "PRIVMSG", irc_privmsg },
- { "QUIT", irc_quit },
- { "RAW", irc_raw },
- { "NICK", irc_nick },
-/* { "ACTION", irc_action }, */
- { 0, 0 }
-};
-
-/* Cut the commandline in two string
- * 1: The first word
- * 2: The rest (without any trailer whitespace between firt and rest).
- */
-char** separate_commandline (char *msg)
-{
- unsigned int len;
- char** two_words;
- espik_enter();
-
- /* Yes, do nothing, just get len ! */
- for (len = 0 ; msg[len] != ' ' && msg[len] != '\t' ; len++);
-
- two_words = malloc (2 * sizeof(char*));
-
- msg[len] = '\0';
- two_words[0] = msg;
-
- do
- {
- two_words[1] = msg + ++len;
- }
- while (*two_words[1] == ' ' || *two_words[1] == '\t');
-
- espik_leave();
- return (two_words);
-}
-
-#if 0
-void string_upper (char *str)
-{
- unsigned int len, i;
- espik_enter();
-
- len = strlen (str);
-
- for (i = 0; i < len; i++)
- {
- if (str[i] >= 0x61 && str[i] <= 0x7A)
- str[i] -= 0x20;
- }
- espik_debug_print ("string_upper: %s", str);
- espik_leave();
-}
-#endif
-
-unsigned short sendmsg_len (char* msg)
-{
- espik_enter();
- espik_leave();
- return (strlen (msg) + 2);
-}
-
-buf_t make_buffer(int len)
-{
- buf_t buf;
- espik_enter();
-
- buf.buf = malloc (len);
- buf.len = len + 1; /* Alloc trailing \0 */
-
- espik_leave();
- return (buf);
-}
-
-char* irc_privmsg (char* chan, char* msg)
-{
- buf_t out;
- espik_enter();
-
- out = make_buffer (strlen ("PRIVMSG") + 1 /* "PRIVMSG " */
- + strlen (chan) + 2 /* ":<channel> "*/
- + strlen (msg)); /* "<msg>EOF" */
-
- snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, msg);
-
- free (msg);
- espik_leave();
- return (out.buf);
-}
-
-char* irc_join (char* chan __UNUSED__, char* msg)
-{
- buf_t out;
- espik_enter();
-
- /* Could also by '&' and so one ...
- * have to look on RFC, dev will be done with # only */
- if (msg[0] != '#')
- {
- espik_debug_print ("%s is not a channel", msg);
- espik_debug_print ("Usage: /JOIN #channel");
- espik_leave();
- return (0);
- }
-
- out = make_buffer (strlen ("JOIN") + 1 /* "JOIN " */
- + strlen (msg)); /* "<msg>EOF" */
-
- snprintf (out.buf, out.len, "JOIN %s", msg);
-
- free (msg);
- espik_leave();
- return (out.buf);
-}
-
-char* irc_part (char* chan, char* msg)
-{
- buf_t out;
- espik_enter();
-
- if (msg[0] != '#')
- {
- out = make_buffer (strlen ("PART") + 1 /* "PART " */
- + strlen (chan) + 2 /* ":<chan> " */
- + strlen (msg)); /* "<msg>EOF" */
-
- snprintf (out.buf, out.len, "PART %s :%s", chan, msg);
- }
- else
- {
- char** sep;
-
- sep = separate_commandline (msg);
-
- out = make_buffer (strlen ("PART") + 1 /* "PART " */
- + strlen (sep[0]) + 2 /* ":<chan> "*/
- + strlen (sep[1])); /* "<msg>EOF"*/
-
- snprintf (out.buf, out.len, "PART %s :%s", sep[0], sep[1]);
- }
-
- free (msg);
- espik_leave();
- return (out.buf);
-}
-
-char* irc_quit (char* chan __UNUSED__, char* msg)
-{
- buf_t out;
- espik_enter();
-
- out = make_buffer (strlen ("QUIT") + 2 /* "QUIT :" */
- + strlen (msg)); /* "<msg>EOF" */
-
- snprintf (out.buf, out.len, "QUIT :%s", msg);
-
- espik_debug_print ("msg : %s\nout: %s", msg, out.buf);
-
- /*
- espik_raw_send (out);
- espik_con_shutdown ();
-
- irc_disconnect(sock);
- */
- free (msg);
-
- espik_leave();
- return (out.buf);
-}
-
-char* irc_raw (char* chan __UNUSED__, char* msg)
-{
- espik_enter();
- espik_leave();
- return (msg);
-}
-
-char* irc_nick (char* chan __UNUSED__, char* nick)
-{
- espik_enter();
- buf_t out;
-
- out = make_buffer (strlen ("NICK") + 1 /* "NICK " */
- + strlen (nick)); /* "<nick>EOF" */
-
- snprintf (out.buf, out.len, "NICK %s", nick);
-
- espik_debug_print ("NICK CHANGED REQUEST: %s", nick);
-
- espik_leave();
- return (out.buf);
-}
-
-#if 0
-Ecore_Con_Server* irc_connect (char* host __UNUSED__, int port __UNUSED__)
-{
- espik_enter();
- espik_leave();
- return (NULL);
-}
-
-void irc_disconnect (Ecore_Con_Server *sock)
-{
- espik_enter();
- espik_debug_print ("> irc_disconnect");
- ecore_main_loop_quit ();
- espik_debug_print ("< irc_disconnect");
- espik_leave();
-}
-#endif
-
-char* irc_send (char* msg)
-{
- char* out;
- espik_enter();
-
- out = NULL;
-
- current_chan = "#e.fr";
-
- if (msg[0] == '/')
- {
- char** cmd_and_message;
- cmd_t* cmd;
-
- cmd_and_message = separate_commandline (msg + 1);
-
- /*
- espik_debug_print ("irc_send: <separate_commandline");
- */
-
- /*
- string_upper (cmd_and_message[0]);
- */
-
- for (cmd = cmd_tab; cmd->cmd_name != 0; cmd++)
- {
- if ((strcasecmp (cmd_and_message[0], cmd->cmd_name)) == 0)
- {
- out = cmd->format (current_chan,
- cmd_and_message[1]);
- free (msg);
- /* Why do job after found the good to do ? */
- break;
- }
- }
- if (!out)
- {
- espik_debug_print ("%s is not a know command",
- cmd_and_message[0]);
- espik_leave();
- return (0);
- }
- }
- else
- {
- out = irc_privmsg (current_chan, msg);
- }
-
- if (!out)
- {
- free (msg);
- espik_leave();
- return (0);
- }
-
- espik_debug_print ("%s", out);
-
- espik_leave();
- return (out);
-}
diff --git a/src/espik_irc.h b/src/espik_irc.h
deleted file mode 100644
index 5d72095..0000000
--- a/src/espik_irc.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef HAVE_ESPIK_IRC_H
-#define HAVE_ESPIK_IRC_H
-
-typedef struct
-{
- char* buf;
- int len;
-} buf_t;
-
-unsigned short sendmsg_len (char*);
-char* irc_send (char*);
-char* irc_privmsg (char*, char *);
-
-/*char* irc_action (char *, char *);*/
-char* irc_join (char*, char*);
-char* irc_part (char*, char*);
-char* irc_quit (char*, char*);
-char* irc_raw (char*, char*);
-char* irc_nick(char*, char*);
-
-char** separate_commandline (char*);
-buf_t make_buffer(int);
-/*void string_upper (char*);*/
-
-/*Ecore_Con_Server* irc_connect (char*, int);*/
-/*void irc_disconnect (Ecore_Con_Server*);*/
-
-
-#endif /* HAVE_ESPIK_IRC_H */
diff --git a/src/espik_net.c b/src/espik_net.c
deleted file mode 100644
index d56f070..0000000
--- a/src/espik_net.c
+++ /dev/null
@@ -1,181 +0,0 @@
-#include <string.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "espik_global.h"
-#include "espik_net.h"
-#include "espik_common_handler.h"
-#include "espik_error.h"
-#include "espik_debug.h"
-#include "espik_irc.h"
-#include "espik.h"
-
-#include <Ecore.h>
-#include <Ecore_Con.h>
-
-typedef int (*Handler_Func) (void* data, int ev_type, void* ev);
-
-static int ret_int; /* For debug */
-char connected = 0;
-
-Ecore_Con_Server* con_sock;
-
-Ecore_Event_Handler* ret;
-
-void espik_con_init (t_info serv_info)
-{
- int nb_launch;
- espik_enter();
-
- nb_launch = ecore_con_init ();
-
- com_active = 0;
-
- /*
- espik_debug_printf ("nb_launch = %d", nb_launch);
- */
-
- con_sock = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
- serv_info.server->host,
- (int)serv_info.server->port, NULL);
- if (!con_sock)
- {
- espik_debug_print ("ecore_con_server_connect failed "
- "(ECORE_CON_REMOTE_SYSTEM)");
- exit (-1);
- }
- espik_free (con_sock);
-
- if (! (ret = ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
- (Handler_Func) server_data, NULL)))
- {
- espik_debug_print ("ecore_event_handler_add "
- "(ECORE_CON_EVENT_SERVER_DATA)");
- exit (-1);
- }
- espik_free (ret);
-
- if (! (ret = ecore_event_handler_add (ECORE_CON_EVENT_SERVER_ADD,
- (Handler_Func) espik_con_up, NULL)))
- {
- espik_debug_print ("ecore_event_handler_add "
- "(ECORE_CON_EVENT_SERVER_ADD)");
- exit (-1);
- }
- espik_free (ret);
-
- if (! (ret = ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DEL,
- (Handler_Func) espik_con_shutdown, NULL)))
- {
- espik_debug_print ("ecore_event_handler_add "
- "(ECORE_CON_EVENT_SERVER_DEL)");
- exit (-1);
- }
- espik_free (ret);
-
- espik_leave();
-}
-
-void send_login()
-{
- espik_enter();
-// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>");
-
- char *tmp, *tmp2;
-
- tmp = malloc ( strlen("NICK ")
- + strlen (a_infos.client->nickname));
- tmp2 = malloc ( strlen("USER :")
- + strlen(a_infos.client->nickname)*2
- + strlen (a_infos.client->realname)
- + strlen (a_infos.server->host));
-
- sprintf (tmp, "NICK %s", a_infos.client->nickname);
- sprintf (tmp2, "USER %s %s %s: %s", a_infos.client->nickname,
- a_infos.client->nickname, a_infos.server->host,
- a_infos.client->realname);
-
- espik_debug_print("tmp: %s", tmp);
- espik_raw_send (tmp);
- espik_debug_print("tmp2: %s", tmp2);
- espik_raw_send (tmp2);
- espik_raw_send ("JOIN #e.fr");
-
- com_active = 1;
-
-// espik_debug_print ("<<<<<<<< DUMMMMY CODE >>>>>>>");
-
- free (tmp);
- free (tmp2);
-
- connected++;
- espik_leave();
-}
-
-void espik_con_up()
-{
- espik_enter();
- printf ("Connected\n");
- espik_leave();
-}
-
-void espik_con_shutdown ()
-{
- espik_enter();
-
- if (!connected)
- espik_debug_print ("Unable to connect to server");
-
- espik_debug_print ("ecore_con_server_del: %p",
- ecore_con_server_del (con_sock));
-
- ecore_con_shutdown ();
-
- /*
- ecore_event_handler_del (handler_list.data);
- ecore_event_handler_del (handler_list.up);
- ecore_event_handler_del (handler_list.down);
- */
-
- ecore_main_loop_quit ();
- espik_free (server_dns);
-
- espik_leave();
-}
-
-void espik_raw_send (const char *msg)
-{
- buf_t buf;
- espik_enter();
-
- buf = make_buffer (strlen(msg) + 1); /* <MESSAGE>\r\n\0" */
-
- snprintf (buf.buf, buf.len, "%s\r\n", msg);
- /* Override trailing \0 */
- espik_debug_print("strlen(msg): %d", strlen(msg));
- espik_debug_print("buf.len: %d", buf.len);
- buf.buf[buf.len-1] = '\n';
-// buf.buf[buf.len] = '\0';
-
- espik_debug_print ("\n\nmsg(%d): %s\n\nout(%d-%d): %s\n", strlen(msg), msg, strlen(buf.buf), buf.len, buf.buf);
- /*
- printf ("out[len-3]: 0x%X\n", out[len - 3]);
- printf ("out[len-2]: 0x%X\n", out[len - 2]);
- printf ("out[len-1]: 0x%X\n", out[len - 1]);
- */
-
- int i;
- for (i = 0 ; buf.buf[i] != 0 ; i++)
- {
- espik_debug_print ("buf.buf[%d]: '%d'", i, buf.buf[i]);
- }
-
-
- ret_int = ecore_con_server_send (con_sock, buf.buf, buf.len);
-
- espik_debug_print ("ret_int: %d", ret_int);
- free (buf.buf);
-// free (msg);
- espik_leave();
-}
diff --git a/src/espik_net.h b/src/espik_net.h
deleted file mode 100644
index a095ba9..0000000
--- a/src/espik_net.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef HAVE_ESPIK_NET_H
-#define HAVE_ESPIK_NET_H
-
-#include "espik.h"
-
-void espik_raw_send (const char*);
-void espik_con_init (t_info);
-void espik_con_up();
-void espik_con_shutdown ();
-void send_login();
-
-#endif /* HAVE_ESPIK_NET_H */