aboutsummaryrefslogtreecommitdiff
path: root/src/espik_irc.c
diff options
context:
space:
mode:
authorbeber <beber>2005-10-08 23:41:12 +0000
committerbeber <beber>2005-10-08 23:41:12 +0000
commit0522028e875e10ca2c6c009db07094afba6b7e6d (patch)
tree2099e51ccc20199f3346c365493dd46c23c77546 /src/espik_irc.c
parentindent (diff)
downloadespik-0522028e875e10ca2c6c009db07094afba6b7e6d.tar.xz
indent
Diffstat (limited to 'src/espik_irc.c')
-rw-r--r--src/espik_irc.c212
1 files changed, 106 insertions, 106 deletions
diff --git a/src/espik_irc.c b/src/espik_irc.c
index 83412dc..8d62c29 100644
--- a/src/espik_irc.c
+++ b/src/espik_irc.c
@@ -21,147 +21,147 @@ typedef struct
} cmd_t;
cmd_t cmd_tab[] = {
- { "JOIN", irc_join },
- { "PART", irc_part },
- { "PRIVMSG", irc_privmsg },
- { "QUIT", irc_quit },
- { "RAW", irc_raw },
+ { "JOIN", irc_join },
+ { "PART", irc_part },
+ { "PRIVMSG", irc_privmsg },
+ { "QUIT", irc_quit },
+ { "RAW", irc_raw },
{ "NICK", irc_nick },
/* { "ACTION", irc_action }, */
- { 0, 0 }
+ { 0, 0 }
};
char** separate_commandline (char *msg)
{
- unsigned int len;
- char** two_words;
+ unsigned int len;
+ char** two_words;
- /* Yes, do nothing, just get len ! */
+ /* Yes, do nothing, just get len ! */
for (len = 0; msg[len] != ' '; len++);
- two_words = malloc (sizeof(char*) * 2);
+ two_words = malloc (sizeof(char*) * 2);
- msg[len] = '\0';
- two_words[0] = msg;
- two_words[1] = msg + len + 1;
+ msg[len] = '\0';
+ two_words[0] = msg;
+ two_words[1] = msg + len + 1;
- return (two_words);
+ return (two_words);
}
void string_upper (char *str)
{
- unsigned int len, i;
+ unsigned int len, i;
- len = strlen (str);
+ len = strlen (str);
- for (i = 0; i < len; i++)
- {
- if (str[i] >= 0x61 && str[i] <= 0x7A)
- str[i] -= 0x20;
- }
+ for (i = 0; i < len; i++)
+ {
+ if (str[i] >= 0x61 && str[i] <= 0x7A)
+ str[i] -= 0x20;
+ }
printf("string_upper: %s\n", str);
}
unsigned short sendmsg_len (char* msg)
{
- return (strlen (msg) + 2);
+ return (strlen (msg) + 2);
}
char* irc_privmsg (char* chan, char* msg)
{
- char* out;
- unsigned int len;
+ char* out;
+ unsigned int len;
- len = strlen ("PRIVMSG") + 1 /* space */
+ len = strlen ("PRIVMSG") + 1 /* space */
+ strlen (chan) + 2 /* space: */
+ strlen (msg) + 1; /* EOF */
- out = malloc (sizeof(char) * len);
+ out = malloc (sizeof(char) * len);
- snprintf (out, len, "PRIVMSG %s :%s", chan, msg);
+ snprintf (out, len, "PRIVMSG %s :%s", chan, msg);
- return (out);
+ return (out);
}
char* irc_join (char* chan __UNUSED__, char* msg)
{
- char* out;
- int len;
+ char* out;
+ int len;
/* COuld also by '&' and so one ...
* have to look on RFC, dev will be done with # only */
- if (msg[0] != '#')
- {
- printf ("%s is not a channel\n", msg);
- printf ("Usage: /JOIN #channel\n");
- return (0);
- }
-
- len = strlen ("JOIN") + 1
+ if (msg[0] != '#')
+ {
+ printf ("%s is not a channel\n", msg);
+ printf ("Usage: /JOIN #channel\n");
+ return (0);
+ }
+
+ len = strlen ("JOIN") + 1
+ strlen (msg) + 1;
- out = malloc (sizeof(char) * len);
+ out = malloc (sizeof(char) * len);
- snprintf (out, len, "JOIN %s", msg);
+ snprintf (out, len, "JOIN %s", msg);
- return (out);
+ return (out);
}
char* irc_part (char* chan, char* msg)
{
- char* out;
- int len;
+ char* out;
+ int len;
- if (msg[0] != '#')
- {
- len = strlen ("PART") + 1
+ if (msg[0] != '#')
+ {
+ len = strlen ("PART") + 1
+ strlen (chan) + 2
+ strlen (msg) + 1;
- printf ("irc_part: len: %d\n", len);
- out = malloc (sizeof(char) * len);
- snprintf (out, len, "PART %s :%s", chan, msg);
- }
- else
- {
- char** sep;
-
- sep = separate_commandline (msg);
- len = strlen ("PART") + 1
+ printf ("irc_part: len: %d\n", len);
+ out = malloc (sizeof(char) * len);
+ snprintf (out, len, "PART %s :%s", chan, msg);
+ }
+ else
+ {
+ char** sep;
+
+ sep = separate_commandline (msg);
+ len = strlen ("PART") + 1
+ strlen (sep[0]) + 2
+ strlen (sep[1]) + 1;
- out = malloc (sizeof(char) * len);
- snprintf (out, len, "PART %s :%s", sep[0], sep[1]);
- }
+ out = malloc (sizeof(char) * len);
+ snprintf (out, len, "PART %s :%s", sep[0], sep[1]);
+ }
- return (out);
+ return (out);
}
char* irc_quit (char* chan __UNUSED__, char* msg)
{
- char* out;
- int len;
+ char* out;
+ int len;
- len = strlen ("QUIT") + 2
+ len = strlen ("QUIT") + 2
+ strlen (msg) + 1;
- out = malloc (sizeof (char) * len);
+ out = malloc (sizeof (char) * len);
- snprintf (out, len, "QUIT :%s", msg);
+ snprintf (out, len, "QUIT :%s", msg);
- printf ("msg : %s\nout: %s\n", msg, out);
+ printf ("msg : %s\nout: %s\n", msg, out);
-/*
- espik_raw_send (out);
- espik_con_shutdown ();
+ /*
+ espik_raw_send (out);
+ espik_con_shutdown ();
- irc_disconnect(sock);
-*/
+ irc_disconnect(sock);
+ */
- return (out);
+ return (out);
}
char* irc_raw (char* chan __UNUSED__, char* msg)
{
- return (msg);
+ return (msg);
}
char* irc_nick (char* chan __UNUSED__, char* nick)
@@ -199,53 +199,53 @@ void irc_disconnect (Ecore_Con_Server *sock)
char* irc_send (char* msg)
{
- char* out;
+ char* out;
- out = NULL;
+ out = NULL;
- current_chan = "#test";
+ current_chan = "#test";
- if (msg[0] == '/')
- {
+ if (msg[0] == '/')
+ {
#if 1
printf ("irc_send: msg[0] == '/'\n");
#endif
- char** cmd_and_message;
+ char** cmd_and_message;
- cmd_t* cmd;
+ cmd_t* cmd;
- cmd_and_message = separate_commandline (msg + 1);
+ cmd_and_message = separate_commandline (msg + 1);
#if 1
printf ("irc_send: <separate_commandline\n");
#endif
- string_upper (cmd_and_message[0]);
+ string_upper (cmd_and_message[0]);
- for (cmd = cmd_tab; cmd->cmd_name != 0; cmd++)
- {
- if ((strcmp (cmd_and_message[0], cmd->cmd_name)) == 0)
+ for (cmd = cmd_tab; cmd->cmd_name != 0; cmd++)
+ {
+ if ((strcmp (cmd_and_message[0], cmd->cmd_name)) == 0)
{
- out = cmd->format (current_chan, cmd_and_message[1]);
- /* WHy do job after found the good to do ? */
- break;
+ out = cmd->format (current_chan, cmd_and_message[1]);
+ /* WHy do job after found the good to do ? */
+ break;
}
- }
- if (!out)
- {
- printf ("%s is not a know command\n", cmd_and_message[0]);
- return (0);
- }
- }
- else
- {
- out = irc_privmsg (current_chan, msg);
- }
-
- if (!out)
- return (0);
-
- printf ("%s\n", out);
-
- return (out);
+ }
+ if (!out)
+ {
+ printf ("%s is not a know command\n", cmd_and_message[0]);
+ return (0);
+ }
+ }
+ else
+ {
+ out = irc_privmsg (current_chan, msg);
+ }
+
+ if (!out)
+ return (0);
+
+ printf ("%s\n", out);
+
+ return (out);
}