summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrand Jacquin (Beber) <beber@setibzh.com>2006-01-23 02:39:49 +0100
committerBertrand Jacquin (Beber) <beber@setibzh.com>2006-01-23 02:39:49 +0100
commitf9aeaea57306b88e8a7507a3873f0313dec1a061 (patch)
treee24d2b8a30e2ec07d9f0a15c46b84d6a021f79a8
parent753787de54eb7e9ec27eee2dfc6e24d42a15971e (diff)
More back to home
-rw-r--r--src/Makefile.am4
-rw-r--r--src/espik.c13
-rw-r--r--src/espik.h1
-rw-r--r--src/espik_common_handler.c26
-rw-r--r--src/espik_config.c5
-rw-r--r--src/espik_debug.h10
6 files changed, 33 insertions, 26 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 13b6393..1172360 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,8 +12,6 @@ ESPIKHEADERS = \
12 espik_error.h \ 12 espik_error.h \
13 espik_debug.h \ 13 espik_debug.h \
14 espik_global.h 14 espik_global.h
15## espik_net.h \
16## espik_irc.h \
17 15
18espik_SOURCES = \ 16espik_SOURCES = \
19 espik.c \ 17 espik.c \
@@ -22,8 +20,6 @@ espik_SOURCES = \
22 espik_error.c \ 20 espik_error.c \
23 espik_debug.c \ 21 espik_debug.c \
24 $(ESPIKHEADERS) 22 $(ESPIKHEADERS)
25## espik_irc.c \
26## espik_net.c \
27 23
28espik_LDADD = \ 24espik_LDADD = \
29 $(DEBUG_LDFLAGS) \ 25 $(DEBUG_LDFLAGS) \
diff --git a/src/espik.c b/src/espik.c
index f4fce5a..b851fb0 100644
--- a/src/espik.c
+++ b/src/espik.c
@@ -39,7 +39,14 @@ static void espik_destroy_ptr(void *ptr)
39 39
40void espik_free (void *ptr) 40void espik_free (void *ptr)
41{ 41{
42 espik_enter();
42 ecore_list_append (ptr_list, ptr); 43 ecore_list_append (ptr_list, ptr);
44 espik_leave();
45}
46
47void espik_shutdown()
48{
49 ecore_main_loop_quit();
43} 50}
44 51
45/* Use to replace EOL ('\n') with NULL ('\0') */ 52/* Use to replace EOL ('\n') with NULL ('\0') */
@@ -64,6 +71,7 @@ int del_backslash (char *msg)
64int main (int argc, char **argv) 71int main (int argc, char **argv)
65{ 72{
66 Ecore_Fd_Handler *fd_kb; 73 Ecore_Fd_Handler *fd_kb;
74 __indent_level = 0;
67 espik_enter(); 75 espik_enter();
68 76
69 printf ("Welcome to %s %s\n", APPS_NAME, ESPIK_VERSION); 77 printf ("Welcome to %s %s\n", APPS_NAME, ESPIK_VERSION);
@@ -102,7 +110,7 @@ int main (int argc, char **argv)
102 /* Handler Keyboard */ 110 /* Handler Keyboard */
103 fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get, 111 fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get,
104 NULL, NULL, NULL); 112 NULL, NULL, NULL);
105 espik_free(kb_get); 113 espik_free (fd_kb);
106 if (!fd_kb) 114 if (!fd_kb)
107 { 115 {
108 printf ("Cannot ecore_main_fd_handler_add\n"); 116 printf ("Cannot ecore_main_fd_handler_add\n");
@@ -113,8 +121,7 @@ int main (int argc, char **argv)
113 121
114 ecore_main_loop_begin (); 122 ecore_main_loop_begin ();
115 123
116 ecore_main_fd_handler_del (fd_kb); 124 espik_shutdown();
117
118 espik_debug_print ("end"); 125 espik_debug_print ("end");
119 126
120 espik_config_shutdown (a_infos); 127 espik_config_shutdown (a_infos);
diff --git a/src/espik.h b/src/espik.h
index 2c4f84d..fba8283 100644
--- a/src/espik.h
+++ b/src/espik.h
@@ -27,6 +27,7 @@ Ecore_List *ptr_list;
27 27
28void espik_free (void*); 28void espik_free (void*);
29int del_backslash (char*); 29int del_backslash (char*);
30void espik_shutdown();
30int main (int, char**); 31int main (int, char**);
31 32
32#endif /* HAVE_ESPIK_H */ 33#endif /* HAVE_ESPIK_H */
diff --git a/src/espik_common_handler.c b/src/espik_common_handler.c
index b5b2432..2dcb47f 100644
--- a/src/espik_common_handler.c
+++ b/src/espik_common_handler.c
@@ -4,9 +4,6 @@
4#include <unistd.h> 4#include <unistd.h>
5 5
6#include <Ecore.h> 6#include <Ecore.h>
7#include <Ecore_Con.h>
8
9#include <wchar.h>
10 7
11#include "espik_global.h" 8#include "espik_global.h"
12#include "espik_common_handler.h" 9#include "espik_common_handler.h"
@@ -14,31 +11,40 @@
14#include "espik_error.h" 11#include "espik_error.h"
15#include "espik_debug.h" 12#include "espik_debug.h"
16 13
14#define INPUT_LENGHT 200
15
17int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler) 16int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
18{ 17{
19 char* kb; 18 char kb[INPUT_LENGHT];
20 int count; 19 int count;
21 espik_enter(); 20 espik_enter();
22 21
23 kb = malloc (200);
24
25 do 22 do
26 { 23 {
27 memset (kb, 0, 200); 24 memset (kb, 0, INPUT_LENGHT);
28 count = read (ecore_main_fd_handler_fd_get (fd_handler), kb, 25 count = read (ecore_main_fd_handler_fd_get (fd_handler), kb,
29 198); 26 INPUT_LENGHT - 2);
30 27
31 if (count > 1) 28 if (count > 1)
32 { 29 {
33 del_backslash (kb); 30 del_backslash (kb);
34
35 espik_debug_print ("%s", kb); 31 espik_debug_print ("%s", kb);
36 } 32 }
37 } 33 }
38 while (count >= 198); 34 while (count >= INPUT_LENGHT - 2);
39 35
40 if (count == -1) 36 if (count == -1)
37 {
41 perror ("read"); 38 perror ("read");
39 espik_shutdown();
40 return (0);
41 }
42
43 if (count == 0)
44 {
45 espik_shutdown();
46 return (0);
47 }
42 48
43 espik_leave(); 49 espik_leave();
44 return (1); 50 return (1);
diff --git a/src/espik_config.c b/src/espik_config.c
index b8f7f71..234954a 100644
--- a/src/espik_config.c
+++ b/src/espik_config.c
@@ -21,9 +21,10 @@ t_servinfo* espik_server_config_set (char* server, unsigned short port)
21 21
22 s_info = malloc (sizeof (t_servinfo)); 22 s_info = malloc (sizeof (t_servinfo));
23 23
24 s_info->host = server; 24 s_info->host = strdup (server);
25 s_info->port = port; 25 s_info->port = port;
26 26
27 espik_free (server);
27 espik_leave(); 28 espik_leave();
28 return (s_info); 29 return (s_info);
29} 30}
@@ -107,8 +108,6 @@ void espik_config_init ()
107 108
108void espik_config_shutdown (t_info s_info) 109void espik_config_shutdown (t_info s_info)
109{ 110{
110 espik_free (s_info.server->host);
111// free (s_info->server->port);
112 espik_free (s_info.server); 111 espik_free (s_info.server);
113 espik_free (s_info.client); 112 espik_free (s_info.client);
114// free (s_info); 113// free (s_info);
diff --git a/src/espik_debug.h b/src/espik_debug.h
index 52c8ce0..99be3fe 100644
--- a/src/espik_debug.h
+++ b/src/espik_debug.h
@@ -6,6 +6,7 @@
6#define DEBUG_PRINT_FILENO stdout 6#define DEBUG_PRINT_FILENO stdout
7#define DEBUG_ENTLEV_FILENO stderr 7#define DEBUG_ENTLEV_FILENO stderr
8 8
9
9#if defined (_ESPIK_DEBUG_) && defined (__GNUC__) 10#if defined (_ESPIK_DEBUG_) && defined (__GNUC__)
10#define espik_debug_print(fmt, ...) \ 11#define espik_debug_print(fmt, ...) \
11{ \ 12{ \
@@ -21,26 +22,23 @@
21#endif /* _ESPIK_DEBUG_ && __GNUC__ */ 22#endif /* _ESPIK_DEBUG_ && __GNUC__ */
22 23
23#ifdef _ESPIK_DEBUG_ 24#ifdef _ESPIK_DEBUG_
25int __indent_level;
24 26
25/*
26#define espik_enter() \ 27#define espik_enter() \
27{ \ 28{ \
28 __indent_level++; \ 29 __indent_level++; \
29 fprintf (DEBUG_ENTLEV_FILENO, ">%*c%s +%i @%s\n", __indent_level, ' ', \ 30 fprintf (DEBUG_ENTLEV_FILENO, ">%*c%s +%i @%s\n", __indent_level, ' ', \
30 __FILE__, __LINE__, __func__); \ 31 __FILE__, __LINE__, __func__); \
31} 32}
32*/ 33//#define espik_enter() {}
33#define espik_enter() {}
34 34
35/*
36#define espik_leave() \ 35#define espik_leave() \
37{ \ 36{ \
38 fprintf (DEBUG_ENTLEV_FILENO, "<%*c%s +%i @%s\n", __indent_level, ' ', \ 37 fprintf (DEBUG_ENTLEV_FILENO, "<%*c%s +%i @%s\n", __indent_level, ' ', \
39 __FILE__, __LINE__, __func__); \ 38 __FILE__, __LINE__, __func__); \
40 __indent_level--; \ 39 __indent_level--; \
41} 40}
42*/ 41//#define espik_leave() {}
43#define espik_leave() {}
44 42
45#else 43#else
46 44