aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbeber <beber>2005-12-10 22:19:52 +0000
committerbeber <beber>2005-12-10 22:19:52 +0000
commitbc2de318263e5fc7da07cd1dd6a2b28e87c416ed (patch)
treebc150e617c1c22d0ce98c8118c3a6ddf0e9c127b
parentdel protection (diff)
downloadespik-bc2de318263e5fc7da07cd1dd6a2b28e87c416ed.tar.xz
ident to 80 chars
Diffstat (limited to '')
-rw-r--r--src/espik.c19
-rw-r--r--src/espik_common_handler.c7
-rw-r--r--src/espik_common_handler.h3
-rw-r--r--src/espik_config.c47
-rw-r--r--src/espik_config.h6
-rw-r--r--src/espik_debug.c3
-rw-r--r--src/espik_debug.h29
-rw-r--r--src/espik_irc.c21
-rw-r--r--src/espik_net.c28
9 files changed, 100 insertions, 63 deletions
diff --git a/src/espik.c b/src/espik.c
index 852d0b0..e93beea 100644
--- a/src/espik.c
+++ b/src/espik.c
@@ -18,9 +18,9 @@
#include "espik_net.h"
#include "espik_debug.h"
-typedef int (*Handler_Func) (void *data, int ev_type, void *ev);
+typedef int (*Handler_Func) (void *data, int ev_type, void *ev);
-/* typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler); */
+/*typedef int (*Handler_Fd_Func) (void *data, Ecore_Fd_Handler * fd_handler);*/
/* Use to replace EOL ('\n') with NULL ('\0') */
@@ -64,7 +64,8 @@ int main (int argc, char **argv)
{
printf ("Connecting to %s:%s\n", argv[1], argv[2]);
a_infos.client = espik_user_sysinfo_get ();
- a_infos.server = espik_server_config_set (argv[1], (unsigned short)atoi (argv[2]));
+ a_infos.server = espik_server_config_set (argv[1],
+ (unsigned short)atoi (argv[2]));
}
espik_config_set (a_infos);
@@ -83,8 +84,10 @@ int main (int argc, char **argv)
/*
* con_sock =
- * ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM, a_infos.server->host,
- * (int)a_infos.server->port, NULL);
+ * 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");
@@ -93,13 +96,15 @@ int main (int argc, char **argv)
*/
/* Handler Network & Keyboard */
- fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get, NULL, NULL, NULL);
+ fd_kb = ecore_main_fd_handler_add (STDIN_FILENO, ECORE_FD_READ, kb_get,
+ NULL, NULL, NULL);
if (!fd_kb)
{
printf ("Cannot ecore_main_fd_handler_add\n");
exit (-1);
}
- /* ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA, (Handler_Func) server_data, NULL); */
+ /* ecore_event_handler_add (ECORE_CON_EVENT_SERVER_DATA,
+ * (Handler_Func) server_data, NULL); */
espik_con_init (a_infos);
diff --git a/src/espik_common_handler.c b/src/espik_common_handler.c
index 2e91757..accd2b8 100644
--- a/src/espik_common_handler.c
+++ b/src/espik_common_handler.c
@@ -15,10 +15,10 @@
#include "espik_debug.h"
int server_data (void* data __UNUSED__, int ev_type __UNUSED__,
- Ecore_Con_Event_Server_Data* ev)
+ Ecore_Con_Event_Server_Data* ev)
{
unsigned int i;
- char* msg;
+ char* msg;
espik_enter();
msg = strdup((char*)ev->data);
@@ -54,7 +54,8 @@ int kb_get (void* data __UNUSED__, Ecore_Fd_Handler* fd_handler)
do
{
memset (kb, 0, 200);
- count = read (ecore_main_fd_handler_fd_get (fd_handler), kb, 198);
+ count = read (ecore_main_fd_handler_fd_get (fd_handler), kb,
+ 198);
if (count > 1)
{
diff --git a/src/espik_common_handler.h b/src/espik_common_handler.h
index 0aa5d92..c46ab6c 100644
--- a/src/espik_common_handler.h
+++ b/src/espik_common_handler.h
@@ -6,7 +6,8 @@
#include "espik_global.h"
-int server_data (void *__UNUSED__, int __UNUSED__, Ecore_Con_Event_Server_Data * __UNUSED__);
+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_config.c b/src/espik_config.c
index 3964902..954874b 100644
--- a/src/espik_config.c
+++ b/src/espik_config.c
@@ -31,7 +31,7 @@ t_servinfo* espik_server_config_set (char* server, unsigned short port)
t_userinfo* espik_user_sysinfo_get ()
{
struct passwd* pw;
- t_userinfo* u_info;
+ t_userinfo* u_info;
espik_enter();
pw = getpwuid (getuid ());
@@ -57,14 +57,17 @@ void espik_config_default_set ()
t_userinfo* user_sysinfo;
espik_enter();
- ecore_config_string_default ("/config/server/0/host", "beber.melee");
- ecore_config_int_default ("/config/server/0/port", 6667);
+ ecore_config_string_default ("/config/server/0/host", "beber.melee");
+ ecore_config_int_default ("/config/server/0/port", 6667);
user_sysinfo = espik_user_sysinfo_get ();
- ecore_config_string_default ("/config/user/nickname", user_sysinfo->nickname);
- ecore_config_string_default ("/config/user/username", user_sysinfo->username);
- ecore_config_string_default ("/config/user/realname", user_sysinfo->realname);
+ ecore_config_string_default ("/config/user/nickname",
+ user_sysinfo->nickname);
+ ecore_config_string_default ("/config/user/username",
+ user_sysinfo->username);
+ ecore_config_string_default ("/config/user/realname",
+ user_sysinfo->realname);
ecore_config_string_default ("/espik/version", ESPIK_VERSION);
@@ -85,7 +88,8 @@ void espik_config_init ()
if ((ret = ecore_config_load ()) != ECORE_CONFIG_ERR_SUCC)
{
- /* If an config option is not present, this will force it to a value */
+ /* If an config option is not present,
+ * this will force it to a value */
espik_debug_print ("Load ecore_config failed (%d)", ret);
espik_config_default_set ();
/*kill_me (2);*/
@@ -101,12 +105,17 @@ void espik_config_get (t_info *s_info)
s_info->server = malloc (sizeof (t_servinfo));
s_info->client = malloc (sizeof (t_userinfo));
- s_info->server->host = ecore_config_string_get ("/config/server/0/host");
- s_info->server->port = (unsigned short)ecore_config_int_get ("/config/server/0/port");
-
- s_info->client->nickname = ecore_config_string_get ("/config/user/nickname");
- s_info->client->username = ecore_config_string_get ("/config/user/username");
- s_info->client->realname = ecore_config_string_get ("/config/user/realname");
+ s_info->server->host =
+ ecore_config_string_get ("/config/server/0/host");
+ s_info->server->port =
+ (unsigned short)ecore_config_int_get ("/config/server/0/port");
+
+ s_info->client->nickname =
+ ecore_config_string_get ("/config/user/nickname");
+ s_info->client->username =
+ ecore_config_string_get ("/config/user/username");
+ s_info->client->realname =
+ ecore_config_string_get ("/config/user/realname");
if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC)
{
@@ -122,12 +131,16 @@ void espik_config_set (t_info config)
ecore_config_int_set ("/config/server/len", 1);
ecore_config_string_set ("/config/server/0/host", config.server->host);
- ecore_config_int_set ("/config/server/0/port", (int)config.server->port);
+ ecore_config_int_set ("/config/server/0/port",
+ (int)config.server->port);
ecore_config_int_set ("/config/server/0/autoconnect", 1);
- ecore_config_string_set ("/config/user/nickname", config.client->nickname);
- ecore_config_string_set ("/config/user/username", config.client->username);
- ecore_config_string_set ("/config/user/realname", config.client->realname);
+ ecore_config_string_set ("/config/user/nickname",
+ config.client->nickname);
+ ecore_config_string_set ("/config/user/username",
+ config.client->username);
+ ecore_config_string_set ("/config/user/realname",
+ config.client->realname);
if (ecore_config_save () != ECORE_CONFIG_ERR_SUCC)
{
diff --git a/src/espik_config.h b/src/espik_config.h
index cc52771..58246ff 100644
--- a/src/espik_config.h
+++ b/src/espik_config.h
@@ -4,12 +4,12 @@
#include "espik.h"
#include "espik_global.h"
-t_servinfo *espik_server_config_set (char *, unsigned short);
+t_servinfo *espik_server_config_set (char*, unsigned short);
t_userinfo *espik_user_sysinfo_get ();
void espik_config_default_set ();
void espik_config_init ();
-void espik_config_get (t_info * s_info);
-void espik_config_set (t_info config);
+void espik_config_get (t_info*);
+void espik_config_set (t_info);
#define ESPIK_CONFIG_VERSION 1
diff --git a/src/espik_debug.c b/src/espik_debug.c
index 7d2aee1..57298ef 100644
--- a/src/espik_debug.c
+++ b/src/espik_debug.c
@@ -38,7 +38,8 @@ inline void espik_debug_bt (int num)
#endif /* __GLIBC__ */
#ifndef __GLIBC__
- fprintf(stderr, "Your system doesn't have glibc. Backtraces disabled. But program receive signal %d.\n", num);
+ fprintf(stderr, "Your system doesn't have glibc. Backtraces disabled."
+ "But program receive signal %d.\n", num);
#endif /* __GLIBC__ */
}
diff --git a/src/espik_debug.h b/src/espik_debug.h
index 968b948..fed2486 100644
--- a/src/espik_debug.h
+++ b/src/espik_debug.h
@@ -7,11 +7,12 @@
#define DEBUG_ENTLEV_FILENO stderr
#if defined (_ESPIK_DEBUG_) && defined (__GNUC__)
-#define espik_debug_print(fmt, ...) \
-{ \
- fprintf (DEBUG_PRINT_FILENO, "%s +%i @%s: '", __FILE__, __LINE__, __func__); \
- fprintf (DEBUG_PRINT_FILENO, fmt, ##__VA_ARGS__); \
- fprintf (DEBUG_PRINT_FILENO, "'\n"); \
+#define espik_debug_print(fmt, ...) \
+{ \
+ fprintf (DEBUG_PRINT_FILENO, "%s +%i @%s: '", __FILE__, __LINE__, \
+ __func__); \
+ fprintf (DEBUG_PRINT_FILENO, fmt, ##__VA_ARGS__); \
+ fprintf (DEBUG_PRINT_FILENO, "'\n"); \
}
#else
#define espik_debug_print(fmt, ...) \
@@ -22,16 +23,18 @@
#ifdef _ESPIK_DEBUG_
int __indent_level;
-#define espik_enter() \
-{ \
- __indent_level++; \
- fprintf (DEBUG_ENTLEV_FILENO, ">(%d)%*c%s +%i @%s\n", __indent_level, __indent_level, ' ', __FILE__, __LINE__, __func__); \
+#define espik_enter() \
+{ \
+ __indent_level++; \
+ fprintf (DEBUG_ENTLEV_FILENO, ">(%d)%*c%s +%i @%s\n", __indent_level, \
+ __indent_level, ' ', __FILE__, __LINE__, __func__); \
}
-#define espik_leave() \
-{ \
- fprintf (DEBUG_ENTLEV_FILENO, "<(%d)%*c%s +%i @%s\n", __indent_level, __indent_level, ' ', __FILE__, __LINE__, __func__); \
- __indent_level--; \
+#define espik_leave() \
+{ \
+ fprintf (DEBUG_ENTLEV_FILENO, "<(%d)%*c%s +%i @%s\n", __indent_level, \
+ __indent_level, ' ', __FILE__, __LINE__, __func__); \
+ __indent_level--; \
}
#else
diff --git a/src/espik_irc.c b/src/espik_irc.c
index cd3a572..d0e0a07 100644
--- a/src/espik_irc.c
+++ b/src/espik_irc.c
@@ -108,9 +108,9 @@ 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) + 1); /* "<msg>EOF" */
+ out = make_buffer (strlen ("PRIVMSG") + 1 /* "PRIVMSG " */
+ + strlen (chan) + 2 /* ":<channel> "*/
+ + strlen (msg) + 1); /* "<msg>EOF" */
snprintf (out.buf, out.len, "PRIVMSG %s :%s", chan, msg);
@@ -161,9 +161,9 @@ char* irc_part (char* chan, char* msg)
sep = separate_commandline (msg);
- out = make_buffer (strlen ("PART") + 1 /* "PART " */
- + strlen (sep[0]) + 2 /* ":<chan> " */
- + strlen (sep[1]) + 1); /* "<msg>EOF" */
+ out = make_buffer (strlen ("PART") + 1 /* "PART " */
+ + strlen (sep[0]) + 2 /* ":<chan> "*/
+ + strlen (sep[1]) + 1); /* "<msg>EOF"*/
snprintf (out.buf, out.len, "PART %s :%s", sep[0], sep[1]);
}
@@ -258,16 +258,19 @@ char* irc_send (char* msg)
for (cmd = cmd_tab; cmd->cmd_name != 0; cmd++)
{
- if ((strcasecmp (cmd_and_message[0], cmd->cmd_name)) == 0)
+ if ((strcasecmp (cmd_and_message[0], cmd->cmd_name)) ==
+ 0)
{
- out = cmd->format (current_chan, cmd_and_message[1]);
+ out = cmd->format (current_chan,
+ cmd_and_message[1]);
/* 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_debug_print ("%s is not a know command",
+ cmd_and_message[0]);
espik_leave();
return (0);
}
diff --git a/src/espik_net.c b/src/espik_net.c
index 219e262..2731165 100644
--- a/src/espik_net.c
+++ b/src/espik_net.c
@@ -30,31 +30,36 @@ void espik_con_init (t_info serv_info)
/* 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);
+ 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)");
+ espik_debug_print ("ecore_con_server_connect failed "
+ "(ECORE_CON_REMOTE_SYSTEM)");
exit (-1);
}
if (! (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)");
+ espik_debug_print ("ecore_event_handler_add "
+ "(ECORE_CON_EVENT_SERVER_DATA)");
exit (-1);
}
if (! (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)");
+ espik_debug_print ("ecore_event_handler_add "
+ "(ECORE_CON_EVENT_SERVER_ADD)");
exit (-1);
}
if (! (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)");
+ espik_debug_print ("ecore_event_handler_add "
+ "(ECORE_CON_EVENT_SERVER_DEL)");
exit (-1);
}
espik_leave();
@@ -69,11 +74,15 @@ void espik_con_up()
char *tmp, *tmp2;
- tmp = malloc (sizeof(char)* (strlen("NICK ") + strlen (a_infos.client->nickname)));
- tmp2 = malloc (sizeof(char)* (strlen("USER localhost:") + strlen(a_infos.client->nickname)*2 + strlen (a_infos.client->realname)));
+ tmp = malloc (sizeof(char)*(strlen("NICK ")
+ + strlen (a_infos.client->nickname)));
+ tmp2 = malloc (sizeof(char)*(strlen("USER localhost:")
+ + strlen(a_infos.client->nickname)*2
+ + strlen (a_infos.client->realname)));
sprintf (tmp, "NICK %s", a_infos.client->nickname);
- sprintf (tmp2, "USER %s %s localhost: %s", a_infos.client->nickname, a_infos.client->nickname, a_infos.client->realname);
+ sprintf (tmp2, "USER %s %s localhost: %s", a_infos.client->nickname,
+ a_infos.client->nickname, a_infos.client->realname);
espik_raw_send (tmp);
espik_raw_send (tmp2);
@@ -93,7 +102,8 @@ void espik_con_shutdown ()
if (!connected)
espik_debug_print ("Unable to connect to server");
- espik_debug_print ("ecore_con_server_del: %p", ecore_con_server_del (con_sock));
+ espik_debug_print ("ecore_con_server_del: %p",
+ ecore_con_server_del (con_sock));
ecore_con_shutdown ();
/* espik_debug_print ("< espik_con_shutdown"); */