Skip to content

Commit

Permalink
Massive rewrite of the internals. The code to deal with parsing incom…
Browse files Browse the repository at this point in the history
…ing data

has been completely rewritten, although relies very heavily on the old code.

The plugin api has had large chunks rewritten as well, but still needs a lot
of work before it can be finalised.

The command api has been rewritten, however at the moment it has issues that
commands are not parsed correctly.  Thats to be fixed next.



git-svn-id: svn://red.pomac.com/rage@3 55c13d69-e7e2-0310-b639-a4a306287c42
  • Loading branch information
isomer committed Sep 1, 2004
1 parent 8169695 commit 76a5014
Show file tree
Hide file tree
Showing 21 changed files with 1,555 additions and 1,052 deletions.
12 changes: 6 additions & 6 deletions trunk/src/common/cfgfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,29 +865,29 @@ cfg_get_bool (char *var)
}

int
cmd_set (struct session *sess, char *tbuf, char *word[], char *word_eol[])
cmd_set (struct session *sess, char *tbuf, int parc, char *parv[])
{
int wild = FALSE;
int quiet = FALSE;
int erase = FALSE;
int i = 0, finds = 0, found;
int idx = 2;
int idx = 1;
char *var, *val;

if (strcasecmp (word[2], "-quiet") == 0)
if (strcasecmp (parv[1], "-quiet") == 0)
{
idx++;
quiet = TRUE;
}

if (strcasecmp (word[2], "-e") == 0)
if (strcasecmp (parv[1], "-e") == 0)
{
idx++;
erase = TRUE;
}

var = word[idx];
val = word_eol[idx+1];
var = parv[idx];
var = parv[idx];

if (!*var)
{
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/common/cfgfiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void list_free (GSList ** list);
void list_loadconf (char *file, GSList ** list, char *defaultconf);
int list_delentry (GSList ** list, char *name);
void list_addentry (GSList ** list, char *cmd, char *name);
int cmd_set (session *sess, char *tbuf, char *word[], char *word_eol[]);
int cmd_set (session *sess, char *tbuf, int parc, char *parv[]);
int mkdir_utf8 (char *dir);

#define STRUCT_OFFSET_STR(type,field) \
Expand Down
38 changes: 19 additions & 19 deletions trunk/src/common/ctcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@


static void
ctcp_reply (session *sess, char *tbuf, char *nick, char *word[],
char *word_eol[], char *conf)
ctcp_reply (session *sess, char *tbuf, char *nick, int parc, char *parv[],
char *conf)
{
conf = strdup (conf);
/* process %C %B etc */
check_special_chars (conf, TRUE);
auto_insert (tbuf, 2048, conf, word, word_eol, "", "", word_eol[5], "", "", nick);
auto_insert (tbuf, 2048, conf, parc,parv, "","", parv[5], "","", nick);
free (conf);
handle_command (sess, tbuf, FALSE);
}

static int
ctcp_check (session *sess, char *tbuf, char *nick, char *word[],
char *word_eol[], char *ctcp)
ctcp_check (session *sess, char *tbuf, char *nick, int parc, char *parv[],
char *ctcp)
{
int ret = 0;
char *po;
Expand All @@ -60,7 +60,7 @@ ctcp_check (session *sess, char *tbuf, char *nick, char *word[],
if (po)
*po = 0;

po = strchr (word_eol[5], '\001');
po = strchr (parv[4], '\001');
if (po)
*po = 0;

Expand All @@ -69,7 +69,7 @@ ctcp_check (session *sess, char *tbuf, char *nick, char *word[],
pop = (struct popup *) list->data;
if (!strcasecmp (ctcp, pop->name))
{
ctcp_reply (sess, tbuf, nick, word, word_eol, pop->cmd);
ctcp_reply (sess, tbuf, nick, parc, parv, pop->cmd);
ret = 1;
}
list = list->next;
Expand All @@ -79,7 +79,7 @@ ctcp_check (session *sess, char *tbuf, char *nick, char *word[],

void
ctcp_handle (session *sess, char *to, char *nick,
char *msg, char *word[], char *word_eol[])
char *msg, int parc, char *parv[])
{
char *po;
session *chansess;
Expand All @@ -90,25 +90,25 @@ ctcp_handle (session *sess, char *to, char *nick,
if (!strncasecmp (msg, "DCC", 3))
{
/* but still let CTCP replies override it */
if (!ctcp_check (sess, outbuf, nick, word, word_eol, word[4] + 2))
if (!ctcp_check (sess, outbuf, nick, parc, parv, parv[3] + 2))
{
if (!ignore_check (word[1], IG_DCC))
handle_dcc (sess, nick, word, word_eol);
if (!ignore_check (parv[0], IG_DCC))
handle_dcc (sess, nick, parc, parv);
}
return;
}

if (ignore_check (word[1], IG_CTCP))
if (ignore_check (parv[0], IG_CTCP))
return;

if (!strcasecmp (msg, "VERSION") && !prefs.hidever)
{
snprintf (outbuf, sizeof (outbuf), "VERSION xchat "VERSION" %s",
snprintf (outbuf, sizeof (outbuf), "VERSION Rage "VERSION" %s",
get_cpu_str ());
serv->p_nctcp (serv, nick, outbuf);
}

if (!ctcp_check (sess, outbuf, nick, word, word_eol, word[4] + 2))
if (!ctcp_check (sess, outbuf, nick, parc, parv, parv[3] + 2))
{
if (!strncasecmp (msg, "ACTION", 6))
{
Expand All @@ -117,16 +117,16 @@ ctcp_handle (session *sess, char *to, char *nick,
}
if (!strncasecmp (msg, "SOUND", 5))
{
po = strchr (word[5], '\001');
po = strchr (parv[4], '\001');
if (po)
po[0] = 0;
EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, word[5],
EMIT_SIGNAL (XP_TE_CTCPSND, sess->server->front_session, parv[4],
nick, NULL, NULL, 0);
snprintf (outbuf, sizeof (outbuf), "%s/%s", prefs.sounddir, word[5]);
if (strchr (word[5], '/') == 0 && access (outbuf, R_OK) == 0)
snprintf (outbuf, sizeof (outbuf), "%s/%s", prefs.sounddir, parv[4]);
if (strchr (parv[3], '/') == 0 && access (outbuf, R_OK) == 0)
{
snprintf (outbuf, sizeof (outbuf), "%s %s/%s", prefs.soundcmd,
prefs.sounddir, word[5]);
prefs.sounddir, parv[4]);
xchat_exec (outbuf);
}
return;
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/common/ctcp.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef XCHAT_CTCP_H
#define XCHAT_CTCP_H

void ctcp_handle (session *sess, char *to, char *nick, char *msg, char *word[], char *word_eol[]);
void ctcp_handle (session *sess, char *to, char *nick, char *msg, int parc, char * parv[]);

#endif
47 changes: 23 additions & 24 deletions trunk/src/common/dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ dcc_chat_line (struct DCC *dcc, char *line, char *tbuf)
for (i = 5; i < PDIWORDS; i++)
word[i] = "\000";

ret = plugin_emit_print (sess, word);
ret = plugin_emit_print (sess, 5, word);

/* did the plugin close it? */
if (!g_slist_find (dcc_list, dcc))
Expand Down Expand Up @@ -1607,27 +1607,26 @@ dcc_deny_chat (void *ud)
}

void
handle_dcc (struct session *sess, char *nick, char *word[],
char *word_eol[])
handle_dcc (struct session *sess, char *nick, int parc, char *parv[])
{
char tbuf[512];
struct DCC *dcc;
char *type = word[5];
char *type = parv[4];
int port, pasvid = 0;
unsigned long size, addr;

if (!strcasecmp (type, "CHAT"))
{
port = atoi (word[8]);
addr = strtoul (word[7], NULL, 10);
port = atoi (parv[7]);
addr = strtoul (parv[6], NULL, 10);

if (port == 0)
pasvid = atoi (word[9]);
pasvid = atoi (parv[8]);

if (!addr /*|| (port < 1024 && port != 0)*/
|| port > 0xffff || (port == 0 && pasvid == 0))
{
dcc_malformed (sess, nick, word_eol[4] + 2);
dcc_malformed (sess, nick, parv[3] + 2);
return;
}
dcc = find_dcc (nick, "", TYPE_CHATSEND);
Expand Down Expand Up @@ -1673,21 +1672,21 @@ handle_dcc (struct session *sess, char *nick, char *word[],
}
if (!strcasecmp (type, "RESUME"))
{
port = atoi (word[7]);
port = atoi (parv[6]);

if (port == 0)
{ /* PASSIVE */
pasvid = atoi(word[9]);
pasvid = atoi(parv[8]);
dcc = find_dcc_from_id(pasvid, TYPE_SEND);
} else
{
dcc = find_dcc_from_port (port, TYPE_SEND);
}
if (!dcc)
dcc = find_dcc (nick, word[6], TYPE_SEND);
dcc = find_dcc (nick, parv[5], TYPE_SEND);
if (dcc)
{
size = strtoul (word[8], NULL, 10);
size = strtoul (parv[7], NULL, 10);
dcc->resumable = size;
if (dcc->resumable < dcc->size)
{
Expand Down Expand Up @@ -1717,7 +1716,7 @@ handle_dcc (struct session *sess, char *nick, char *word[],
}
if (!strcasecmp (type, "ACCEPT"))
{
port = atoi (word[7]);
port = atoi (parv[6]);
dcc = find_dcc_from_port (port, TYPE_RECV);
if (dcc && dcc->dccstat == STAT_QUEUED)
{
Expand All @@ -1727,35 +1726,35 @@ handle_dcc (struct session *sess, char *nick, char *word[],
}
if (!strcasecmp (type, "SEND"))
{
char *file = file_part (word[6]);
char *file = file_part (parv[5]);
int psend = 0;

port = atoi (word[8]);
addr = strtoul (word[7], NULL, 10);
size = strtoul (word[9], NULL, 10);
port = atoi (parv[7]);
addr = strtoul (parv[6], NULL, 10);
size = strtoul (parv[8], NULL, 10);

if (port == 0) /* Passive dcc requested */
pasvid = atoi (word[10]);
else if (word[10][0] != 0)
pasvid = atoi (parv[9]);
else if (parv[9][0] != 0)
{
/* Requesting passive dcc.
* Destination user of an active dcc is giving his
* TRUE address/port/pasvid data.
* This information will be used later to
* establish the connection to the user.
* We can recognize this type of dcc using word[10]
* We can recognize this type of dcc using parv[9]
* because this field is always null (no pasvid)
* in normal dcc sends.
*/
pasvid = atoi (word[10]);
pasvid = atoi (parv[9]);
psend = 1;
}


if (!addr || !size /*|| (port < 1024 && port != 0)*/
|| port > 0xffff || (port == 0 && pasvid == 0))
{
dcc_malformed (sess, nick, word_eol[4] + 2);
dcc_malformed (sess, nick, parv[3] + 2);
return;
}

Expand All @@ -1773,7 +1772,7 @@ handle_dcc (struct session *sess, char *nick, char *word[],
dcc_connect (dcc);
} else
{
dcc_malformed (sess, nick, word_eol[4] + 2);
dcc_malformed (sess, nick, parv[3] + 2);
}
return;
}
Expand Down Expand Up @@ -1849,7 +1848,7 @@ handle_dcc (struct session *sess, char *nick, char *word[],
file, tbuf, tbuf + 24, 0);
} else
EMIT_SIGNAL (XP_TE_DCCGENERICOFFER, sess->server->front_session,
word_eol[4] + 2, nick, NULL, NULL, 0);
parv[3] + 2, nick, NULL, NULL, 0);
}

void
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/common/dcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void dcc_send (struct session *sess, char *to, char *file, int maxcps, int passi
struct DCC *find_dcc (char *nick, char *file, int type);
void dcc_get_nick (struct session *sess, char *nick);
void dcc_chat (session *sess, char *nick);
void handle_dcc (session *sess, char *nick, char *word[], char *word_eol[]);
void handle_dcc (session *sess, char *nick, int parc, char *parv[]);
void dcc_show_list (session *sess);
void open_dcc_recv_window (void);
void open_dcc_send_window (void);
Expand Down
Loading

0 comments on commit 76a5014

Please sign in to comment.