aboutsummaryrefslogtreecommitdiff
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
parentdel unused files and code (diff)
downloadespik-f9aeaea57306b88e8a7507a3873f0313dec1a061.tar.xz
More back to home
Diffstat (limited to '')
-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 = \
espik_error.h \
espik_debug.h \
espik_global.h
-## espik_net.h \
-## espik_irc.h \
espik_SOURCES = \
espik.c \
@@ -22,8 +20,6 @@ espik_SOURCES = \
espik_error.c \
espik_debug.c \
$(ESPIKHEADERS)
-## espik_irc.c \
-## espik_net.c \
espik_LDADD = \
$(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)
void espik_free (void *ptr)
{
+ espik_enter();
ecore_list_append (ptr_list, ptr);
+ espik_leave();
+}
+
+void espik_shutdown()
+{
+ ecore_main_loop_quit();
}
/* Use to replace EOL ('\n') with NULL ('\0') */
@@ -64,6 +71,7 @@ int del_backslash (char *msg)
int main (int argc, char **argv)
{
Ecore_Fd_Handler *fd_kb;
+ __indent_level = 0;
espik_enter();
printf ("Welcome to %s %s\n", APPS_NAME, ESPIK_VERSION);
@@ -102,7 +110,7 @@ int main (int argc, char **argv)
/* Handler Keyboard */
fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get,
NULL, NULL, NULL);
- espik_free(kb_get);
+ espik_free (fd_kb);
if (!fd_kb)
{
printf ("Cannot ecore_main_fd_handler_add\n");
@@ -113,8 +121,7 @@ int main (int argc, char **argv)
ecore_main_loop_begin ();
- ecore_main_fd_handler_del (fd_kb);
-
+ espik_shutdown();
espik_debug_print ("end");
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;
void espik_free (void*);
int del_backslash (char*);
+void espik_shutdown();
int main (int, char**);
#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 @@
#include <unistd.h>
#include <Ecore.h>
-#include <Ecore_Con.h>
-
-#include <wchar.h>
#include "espik_global.h"
#include "espik_common_handler.h"
@@ -14,31 +11,40 @@
#include "espik_error.h"
#include "espik_debug.h"
+#define INPUT_LENGHT 200
+
int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
{
- char* kb;
+ char kb[INPUT_LENGHT];
int count;
espik_enter();
- kb = malloc (200);
-
do
{
- memset (kb, 0, 200);
+ memset (kb, 0, INPUT_LENGHT);
count = read (ecore_main_fd_handler_fd_get (fd_handler), kb,
- 198);
+ INPUT_LENGHT - 2);
if (count > 1)
{
del_backslash (kb);
-
espik_debug_print ("%s", kb);
}
}
- while (count >= 198);
+ while (count >= INPUT_LENGHT - 2);
if (count == -1)
+ {
perror ("read");
+ espik_shutdown();
+ return (0);
+ }
+
+ if (count == 0)
+ {
+ espik_shutdown();
+ return (0);
+ }
espik_leave();
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)
s_info = malloc (sizeof (t_servinfo));
- s_info->host = server;
+ s_info->host = strdup (server);
s_info->port = port;
+ espik_free (server);
espik_leave();
return (s_info);
}
@@ -107,8 +108,6 @@ void espik_config_init ()
void espik_config_shutdown (t_info s_info)
{
- espik_free (s_info.server->host);
-// free (s_info->server->port);
espik_free (s_info.server);
espik_free (s_info.client);
// 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 @@
#define DEBUG_PRINT_FILENO stdout
#define DEBUG_ENTLEV_FILENO stderr
+
#if defined (_ESPIK_DEBUG_) && defined (__GNUC__)
#define espik_debug_print(fmt, ...) \
{ \
@@ -21,26 +22,23 @@
#endif /* _ESPIK_DEBUG_ && __GNUC__ */
#ifdef _ESPIK_DEBUG_
+int __indent_level;
-/*
#define espik_enter() \
{ \
__indent_level++; \
fprintf (DEBUG_ENTLEV_FILENO, ">%*c%s +%i @%s\n", __indent_level, ' ', \
__FILE__, __LINE__, __func__); \
}
-*/
-#define espik_enter() {}
+//#define espik_enter() {}
-/*
#define espik_leave() \
{ \
fprintf (DEBUG_ENTLEV_FILENO, "<%*c%s +%i @%s\n", __indent_level, ' ', \
__FILE__, __LINE__, __func__); \
__indent_level--; \
}
-*/
-#define espik_leave() {}
+//#define espik_leave() {}
#else