#include <eggdrop/eggdrop.h>
Go to the source code of this file.
Functions | |
static void | add_arg (irc_msg_t *msg, char *text) |
void | irc_msg_parse (char *text, irc_msg_t *msg) |
void | irc_msg_restore (irc_msg_t *msg) |
void | irc_msg_cleanup (irc_msg_t *msg) |
Variables | |
static const char | rcsid [] = "$Id: ircparse.c,v 1.4 2004-10-17 05:14:06 stdarg Exp $" |
static void add_arg | ( | irc_msg_t * | msg, | |
char * | text | |||
) | [static] |
Definition at line 27 of file ircparse.c.
References irc_msg::args, IRC_MSG_NSTATIC_ARGS, irc_msg::nargs, and irc_msg::static_args.
Referenced by irc_msg_parse().
00028 { 00029 if (msg->nargs >= IRC_MSG_NSTATIC_ARGS) { 00030 if (msg->nargs > IRC_MSG_NSTATIC_ARGS) { 00031 msg->args = realloc(msg->args, sizeof(char *) * (msg->nargs+1)); 00032 } 00033 else { 00034 msg->args = malloc(sizeof(char *) * (IRC_MSG_NSTATIC_ARGS+1)); 00035 memcpy(msg->args, msg->static_args, sizeof(char *) * IRC_MSG_NSTATIC_ARGS); 00036 } 00037 } 00038 msg->args[msg->nargs] = text; 00039 msg->nargs++; 00040 }
void irc_msg_cleanup | ( | irc_msg_t * | msg | ) |
Definition at line 89 of file ircparse.c.
References irc_msg::args, irc_msg::nargs, and irc_msg::static_args.
Referenced by irc_on_read(), and server_parse_input().
00090 { 00091 if (msg->args && msg->args != msg->static_args) free(msg->args); 00092 msg->args = msg->static_args; 00093 msg->nargs = 0; 00094 }
void irc_msg_parse | ( | char * | text, | |
irc_msg_t * | msg | |||
) |
Definition at line 45 of file ircparse.c.
References add_arg(), irc_msg::args, irc_msg::cmd, irc_msg::nargs, NULL, irc_msg::prefix, and irc_msg::static_args.
Referenced by irc_on_read(), queue_entry_from_text(), and server_parse_input().
00046 { 00047 char *space; 00048 00049 memset(msg, 0, sizeof(*msg)); 00050 msg->args = msg->static_args; 00051 if (*text == ':') { 00052 msg->prefix = text+1; 00053 space = strchr(msg->prefix, ' '); 00054 if (!space) return; 00055 *space = 0; 00056 text = space+1; 00057 } 00058 msg->cmd = text; 00059 space = strchr(text, ' '); 00060 if (!space) return; 00061 *space = 0; 00062 text = space+1; 00063 00064 while (*text && (*text != ':')) { 00065 space = strchr(text, ' '); 00066 add_arg(msg, text); 00067 if (space) { 00068 *space = 0; 00069 text = space+1; 00070 } 00071 else break; 00072 } 00073 if (*text == ':') add_arg(msg, text+1); 00074 add_arg(msg, NULL); 00075 msg->nargs--; 00076 }
void irc_msg_restore | ( | irc_msg_t * | msg | ) |
Definition at line 79 of file ircparse.c.
References irc_msg::args, and irc_msg::nargs.
00080 { 00081 int i; 00082 for (i = 0; i < msg->nargs; i++) { 00083 if (msg->args[i][-1] == ':') msg->args[i][-2] = ' '; 00084 else msg->args[i][-1] = ' '; 00085 } 00086 }
const char rcsid[] = "$Id: ircparse.c,v 1.4 2004-10-17 05:14:06 stdarg Exp $" [static] |
Definition at line 21 of file ircparse.c.