[msn-proxy-devel] SF.net SVN: msn-proxy:[182] trunk/msn-proxy
Brought to you by:
loos-br
|
From: <lo...@us...> - 2012-06-29 12:20:08
|
Revision: 182
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=182&view=rev
Author: loos-br
Date: 2012-06-29 12:19:57 +0000 (Fri, 29 Jun 2012)
Log Message:
-----------
add more debug information on failed memory allocations. kind of incorrect implementation in general, but probably helpful for the case i want to fix.
Modified Paths:
--------------
trunk/msn-proxy/client.c
trunk/msn-proxy/command.c
trunk/msn-proxy/configure.c
trunk/msn-proxy/contacts.c
trunk/msn-proxy/ctl.c
trunk/msn-proxy/db.c
trunk/msn-proxy/msg.c
trunk/msn-proxy/msn-proxy.c
trunk/msn-proxy/msn-proxy.h
trunk/msn-proxy/msnp21.c
trunk/msn-proxy/net-io.c
trunk/msn-proxy/ns.c
trunk/msn-proxy/protocol.c
trunk/msn-proxy/sb.c
trunk/msn-proxy/server.c
trunk/msn-proxy/user.c
Modified: trunk/msn-proxy/client.c
===================================================================
--- trunk/msn-proxy/client.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/client.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -50,7 +50,7 @@
struct client_ *client;
client = (struct client_ *)malloc(sizeof(*client));
- if (client == NULL) die_nomem();
+ if (client == NULL) DIE_NOMEM();
memset(client, 0, sizeof(*client));
client->read.ev_fd = -1;
client->write.ev_fd = -1;
@@ -73,7 +73,7 @@
struct client_ *client;
client = (struct client_ *)malloc(sizeof(*client));
- if (client == NULL) die_nomem();
+ if (client == NULL) DIE_NOMEM();
memset(client, 0, sizeof(*client));
client->fd = -1;
Modified: trunk/msn-proxy/command.c
===================================================================
--- trunk/msn-proxy/command.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/command.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -33,7 +33,7 @@
/* alloc a new command storage */
rtrn = (command *)malloc(sizeof(command));
if (rtrn == (command *)0)
- die_nomem();
+ DIE_NOMEM();
/* zero everything */
memset(rtrn, 0, sizeof(command));
@@ -123,13 +123,13 @@
/* alloc string */
arg = str_alloc();
if (arg == (string *)0)
- die_nomem();
+ DIE_NOMEM();
/* increase args size and realloc */
cmd->args_len++;
cmd->args = args_alloc(cmd->args, cmd->args_len);
if (cmd->args == (string **)0)
- die_nomem();
+ DIE_NOMEM();
cmd->args[cmd->args_len - 1] = arg;
cmd->args[cmd->args_len] = (string *)0;
@@ -230,7 +230,7 @@
}
if (str_cat(&cmd->cmd, buf->p, 1) == 0)
- die_nomem();
+ DIE_NOMEM();
break;
@@ -248,7 +248,7 @@
cmds->arg = command_add_arg(cmd);
if (str_cat(cmds->arg, buf->p, 1) == 0)
- die_nomem();
+ DIE_NOMEM();
break;
}
@@ -281,7 +281,7 @@
return(ROK);
if (str_ready(&cmd->payload, cmds->payload_size + 1) == 0)
- die_nomem();
+ DIE_NOMEM();
cmds->state &= ~RECVMASK;
cmds->state |= PAYLOAD;
@@ -299,7 +299,7 @@
len = buf->len;
if (str_cat(&cmd->payload, buf->p, len) == 0)
- die_nomem();
+ DIE_NOMEM();
cmds->payload_size -= len;
buf->len -= len;
@@ -446,33 +446,33 @@
/* put command on buffer */
str_zero(&buf);
if (str_copy(&buf, cmd->cmd.s, cmd->cmd.len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* send args */
while (arg && *arg) {
if (str_cat(&buf, (unsigned char *)" ", 1) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_cat(&buf, (*arg)->s, (*arg)->len) == 0)
- die_nomem();
+ DIE_NOMEM();
++arg;
}
/* end of line */
if (str_cat(&buf, (unsigned char *)"\r\n", 2) == 0)
- die_nomem();
+ DIE_NOMEM();
if (cmd->payload.len > 0 &&
str_cat(&buf, cmd->payload.s, cmd->payload.len) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
log->protocol("[%s] send to %S ==> %s", email, to, &buf);
log->protocol("\n");
if (buf.len > 0 && str_cat(obuf, buf.s, buf.len) == 0)
- die_nomem();
+ DIE_NOMEM();
str_free(&buf);
}
@@ -494,7 +494,7 @@
commands_init(commands *cmds) {
/* alloc buffer */
if (str_ready(&cmds->buf, CMD_BUF) == 0)
- die_nomem();
+ DIE_NOMEM();
/* zero everything */
memset(cmds->buf.s, 0, cmds->buf.a);
Modified: trunk/msn-proxy/configure.c
===================================================================
--- trunk/msn-proxy/configure.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/configure.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -65,7 +65,7 @@
/* set the default config file path */
if (strlen(DEFAULT_CONFIG_FILE) > 0 &&
str_copys(&config->file, (unsigned char *)DEFAULT_CONFIG_FILE) == 0)
- die_nomem();
+ DIE_NOMEM();
/* setup the configuration parameters */
config->confkey = confKeys;
@@ -109,7 +109,7 @@
/* alloc buf */
if (str_ready(&buf, MAX_BUF) == 0)
- die_nomem();
+ DIE_NOMEM();
tmp.a = buf.a;
@@ -196,7 +196,7 @@
void
set_string(const unsigned char *val, string *conf) {
if (!val || strlen((char *)val) == 0 || !conf) return;
- if (str_copys(conf, val) == 0) die_nomem();
+ if (str_copys(conf, val) == 0) DIE_NOMEM();
}
void
Modified: trunk/msn-proxy/contacts.c
===================================================================
--- trunk/msn-proxy/contacts.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/contacts.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -133,11 +133,11 @@
struct contact_ *tmp;
contact = (struct contact_ *)malloc(sizeof(struct contact_));
- if (contact == NULL) die_nomem();
+ if (contact == NULL) DIE_NOMEM();
memset(contact, 0, sizeof (struct contact_));
if (c->len > 0 && str_copy(&contact->c, c->s, c->len) == 0)
- die_nomem();
+ DIE_NOMEM();
contact->updated = NONE;
tmp = RB_INSERT(contacts, &user->contacts, contact);
@@ -170,9 +170,9 @@
if (contact == NULL) {
contact = (struct contact_ *)malloc(sizeof(struct contact_));
- if (contact == NULL) die_nomem();
+ if (contact == NULL) DIE_NOMEM();
memset(contact, 0, sizeof (struct contact_));
- if (str_copy(&contact->c, c->s, c->len) == 0) die_nomem();
+ if (str_copy(&contact->c, c->s, c->len) == 0) DIE_NOMEM();
RB_INSERT(contacts, &user->contacts, contact);
contact->chat = NO;
contact->updated = NEW;
@@ -181,9 +181,9 @@
return (contact);
} else {
save = (struct contact_ *)malloc(sizeof(struct contact_));
- if (save == NULL) die_nomem();
+ if (save == NULL) DIE_NOMEM();
memset(save, 0, sizeof (struct contact_));
- if (str_copy(&save->c, contact->c.s, contact->c.len) == 0) die_nomem();
+ if (str_copy(&save->c, contact->c.s, contact->c.len) == 0) DIE_NOMEM();
save->deny = contact->deny;
save->chat = NO;
save->updated = NEW;
@@ -199,7 +199,7 @@
struct contact_ f;
memset(&f, 0, sizeof (struct contact_));
- if (c->len > 0 && str_copy(&f.c, c->s, c->len) == 0) die_nomem();
+ if (c->len > 0 && str_copy(&f.c, c->s, c->len) == 0) DIE_NOMEM();
contact = RB_FIND(contacts, &user->contacts, &f);
str_free(&f.c);
@@ -275,7 +275,7 @@
/* get contact e-mail */
str_zero(&c);
c.len = fmt_printf(NULL, "%s@%s", &name, &domain);
- if (str_ready(&c, c.len + 1) == 0) die_nomem();
+ if (str_ready(&c, c.len + 1) == 0) DIE_NOMEM();
c.len = fmt_printf(c.s, "%s@%s", &name, &domain);
if (c.len == 0) { str_free(&c); continue; }
@@ -299,13 +299,13 @@
contact->lists = lists | RL;
if (str_copy(&contact->dn, contact->c.s, contact->c.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_copys(&contact->status, (unsigned char *)"OFF") == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_copys(&contact->group, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_copys(&contact->uid, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
}
}
xml_free(&xml_tag_head);
@@ -415,11 +415,11 @@
}
if (c.dn.len > 0 && str_copy(&save->dn, c.dn.s, c.dn.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (c.uid.len > 0 && str_copy(&save->uid, c.uid.s, c.uid.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (c.group.len > 0 && str_copy(&save->group, c.group.s, c.group.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (c.lists > 0)
save->lists = c.lists;
@@ -479,9 +479,9 @@
}
if (c.dn.len > 0 && str_copy(&save->dn, c.dn.s, c.dn.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (c.group.len > 0 && str_copy(&save->group, c.group.s, c.group.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (c.lists > 0)
save->lists = c.lists;
@@ -566,9 +566,9 @@
msn_tok_epdata(c, &save->c);
o = get_arg(cmd, 6);
if (o && o->len > 0 && str_copy(&save->o, o->s, o->len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (s->len > 0 && str_copy(&save->status, s->s, s->len) == 0)
- die_nomem();
+ DIE_NOMEM();
save->capab = (get_arg(cmd, 5) == NULL) ? 0 : atoll((char *)cmd->args[5]->s);
/* check for blocked contacts */
@@ -580,7 +580,7 @@
switch (user->version) {
case MSNP15:
case MSNP18:
- if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(o, (unsigned char *)"0") == 0) DIE_NOMEM();
break;
default:
str_free(o);
@@ -621,7 +621,7 @@
}
memset(&find, 0, sizeof (struct contact_));
- if (str_copy(&find.c, c->s, c->len) == 0) die_nomem();
+ if (str_copy(&find.c, c->s, c->len) == 0) DIE_NOMEM();
contact = RB_FIND(contacts, &user->contacts, &find);
contact_free(&find);
@@ -639,12 +639,12 @@
return(ROK);
}
if (c->len > 0 && str_copy(&save->c, c->s, c->len) == 0)
- die_nomem();
+ DIE_NOMEM();
o = get_arg(cmd, 6);
if (o && o->len > 0 && str_copy(&save->o, o->s, o->len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (s->len > 0 && str_copy(&save->status, s->s, s->len) == 0)
- die_nomem();
+ DIE_NOMEM();
save->capab = (get_arg(cmd, 4) == NULL) ? 0 : atoll((char *)cmd->args[4]->s);
/* check for blocked contacts */
@@ -697,7 +697,7 @@
if (save == NULL)
return(ROK);
- if (str_copys(&save->status, (unsigned char *)"OFF") == 0) die_nomem();
+ if (str_copys(&save->status, (unsigned char *)"OFF") == 0) DIE_NOMEM();
save->deny &= ~CONTACT_BLOCKED;
(void)db.sql_contact_save(user, save);
@@ -750,11 +750,11 @@
return(ROK);
}
if (contact->c.len > 0 && str_copy(&save->c, contact->c.s, contact->c.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (o->len > 0 && str_copy(&save->o, o->s, o->len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (s->len > 0 && str_copy(&save->status, s->s, s->len) == 0)
- die_nomem();
+ DIE_NOMEM();
f = (get_arg(cmd, 3) == NULL) ? "" : (char *)cmd->args[3]->s;
save->capab = strtoul(f, &ep, 10);
@@ -767,7 +767,7 @@
/* SEEIMG */
if (o && (user->commands & SEEIMG)) {
- if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(o, (unsigned char *)"0") == 0) DIE_NOMEM();
}
if (db.sql_contact_save(user, save) == RFAIL)
@@ -819,12 +819,12 @@
return(ROK);
}
if (c->len > 0 && str_copy(&save->c, c->s, c->len) == 0)
- die_nomem();
+ DIE_NOMEM();
o = get_arg(cmd, 5);
if (o && o->len > 0 && str_copy(&save->o, o->s, o->len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (s->len > 0 && str_copy(&save->status, s->s, s->len) == 0)
- die_nomem();
+ DIE_NOMEM();
save->capab = (get_arg(cmd, 4) == NULL) ? 0 : atoll((char *)cmd->args[4]->s);
/* check for blocked contacts */
@@ -836,7 +836,7 @@
switch (user->version) {
case MSNP15:
case MSNP18:
- if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(o, (unsigned char *)"0") == 0) DIE_NOMEM();
break;
default:
str_free(o);
@@ -895,12 +895,12 @@
return(ROK);
}
if (c->len > 0 && str_copy(&save->c, c->s, c->len) == 0)
- die_nomem();
+ DIE_NOMEM();
o = get_arg(cmd, 4);
if (o && o->len > 0 && str_copy(&save->o, o->s, o->len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (s->len > 0 && str_copy(&save->status, s->s, s->len) == 0)
- die_nomem();
+ DIE_NOMEM();
save->capab = (get_arg(cmd, 3) == NULL) ? 0 : atoll((char *)cmd->args[3]->s);
/* check for blocked contacts */
@@ -959,16 +959,16 @@
/* alloc new arg */
arg1 = str_alloc();
if (arg1 == (string *)0)
- die_nomem();
+ DIE_NOMEM();
arg2 = str_alloc();
if (arg2 == (string *)0)
- die_nomem();
+ DIE_NOMEM();
/* rewrite arg */
if (str_copys(arg1, (unsigned char *)"0") == 0 ||
str_copys(arg2, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
/* set pointer arg */
cmd->args[1] = arg1;
@@ -1008,11 +1008,11 @@
/* alloc new arg */
arg1 = str_alloc();
if (arg1 == (string *)0)
- die_nomem();
+ DIE_NOMEM();
/* rewrite arg */
if (str_copys(arg1, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
/* set pointer arg */
cmd->args[1] = arg1;
@@ -1035,11 +1035,11 @@
/* alloc new arg */
arg1 = str_alloc();
if (arg1 == (string *)0)
- die_nomem();
+ DIE_NOMEM();
arg1->len = fmt_printf(NULL, "%d", user->msnp8_syn_bug);
if (str_ready(arg1, arg1->len + 1) == 0)
- die_nomem();
+ DIE_NOMEM();
arg1->len = fmt_printf(arg1->s, "%d", user->msnp8_syn_bug);
/* set pointer arg */
@@ -1138,7 +1138,7 @@
/* find contact in db if exist */
memset(&cfind, 0, sizeof(struct contact_));
- if (str_copy(&cfind.c, c->data.s, c->data.len) == 0) die_nomem();
+ if (str_copy(&cfind.c, c->data.s, c->data.len) == 0) DIE_NOMEM();
contact = RB_FIND(contacts, &user->contacts, &cfind);
contact_free(&cfind);
Modified: trunk/msn-proxy/ctl.c
===================================================================
--- trunk/msn-proxy/ctl.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/ctl.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -81,7 +81,7 @@
/* alloc new ctl */
ctl = (struct ctl_ *)malloc(sizeof(struct ctl_));
- if (ctl == NULL) die_nomem();
+ if (ctl == NULL) DIE_NOMEM();
memset(ctl, 0, sizeof(struct ctl_));
/* misc set */
@@ -162,7 +162,7 @@
str_free(&ctl->buf);
ctl->end = 0;
}
- if (*p && str_cat(&ctl->buf, p, 1) == 0) die_nomem();
+ if (*p && str_cat(&ctl->buf, p, 1) == 0) DIE_NOMEM();
len--; p++;
}
Modified: trunk/msn-proxy/db.c
===================================================================
--- trunk/msn-proxy/db.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/db.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -93,7 +93,7 @@
}
if (db_mod->len > 0 && str_copy(&db.modPath, db_mod->s, db_mod->len) == 0)
- die_nomem();
+ DIE_NOMEM();
log->debug("loading db module.....: [%s]\n", &db.modPath);
db.data = dlopen((char *)db.modPath.s, RTLD_LAZY);
Modified: trunk/msn-proxy/msg.c
===================================================================
--- trunk/msn-proxy/msg.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/msg.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -39,7 +39,7 @@
return(ROK);
memset(&f, 0, sizeof(f));
- if (str_copy(&f.c, c->s, c->len) == 0) die_nomem();
+ if (str_copy(&f.c, c->s, c->len) == 0) DIE_NOMEM();
contact = RB_FIND(contacts, &user->contacts, &f);
contact_free(&f);
@@ -78,7 +78,7 @@
if (tmp->header.len > 0 &&
strcasecmp((char *)tmp->header.s, header) == 0) {
if (str_copy(value, tmp->value.s, tmp->value.len) == 0)
- die_nomem();
+ DIE_NOMEM();
return(ROK);
}
}
@@ -152,7 +152,7 @@
header = (header_ *)malloc(sizeof(header_));
if (!header)
- die_nomem();
+ DIE_NOMEM();
header->next = (header_ *)0;
str_zero(&header->header);
@@ -223,10 +223,10 @@
if (state == HEADER) {
if (str_cat(&header->header, msg->body.s, 1) == 0)
- die_nomem();
+ DIE_NOMEM();
} else if (state == VALUE) {
if (str_cat(&header->value, msg->body.s, 1) == 0)
- die_nomem();
+ DIE_NOMEM();
}
msg->body.len -= 1;
msg->body.s += 1;
@@ -479,7 +479,7 @@
strncmp((char *)mimev->value.s, "1.0", mimev->value.len) == 0) {
if (str_copy(&user->dn, nick->value.s, nick->value.len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* update the sql database */
if (db.sql_update_user_dn(user) == RFAIL)
Modified: trunk/msn-proxy/msn-proxy.c
===================================================================
--- trunk/msn-proxy/msn-proxy.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/msn-proxy.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -100,7 +100,18 @@
}
}
-void die_nomem(void) { perror("malloc"); cleanup(); exit(51); }
+void
+die_nomem(const char *func, int line) {
+
+ /*
+ * The following function isn't safe to used here, since it tries to
+ * allocate more memory... not really useful in the case we are really
+ * running out of memory! beware!
+ */
+ io_printf(2, "%S: line %d: malloc: %S\n", func, line, strerror(errno));
+ cleanup();
+ exit(51);
+}
void die_bug(void) { io_printf(1, "oops bug here ! call my doctor !\n"); exit(2); }
void die(char *msg) { if (msg) { io_printf(1, "%S\n", msg); } cleanup(); exit(1); }
@@ -238,7 +249,7 @@
/* path to config */
if (strlen(optarg) > 0 &&
str_copys(&config.file, (unsigned char *)optarg) == 0)
- die_nomem();
+ DIE_NOMEM();
break;
case 'd':
Modified: trunk/msn-proxy/msn-proxy.h
===================================================================
--- trunk/msn-proxy/msn-proxy.h 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/msn-proxy.h 2012-06-29 12:19:57 UTC (rev 182)
@@ -79,6 +79,8 @@
#define P2P_ACK 0x00000002
#define P2P_FILE 0x00002000
+#define DIE_NOMEM() die_nomem(__func__, __LINE__)
+
#ifndef MSNPROXY_VERSION
#define MSNPROXY_VERSION "0.8.1-beta"
#endif
@@ -102,7 +104,7 @@
#include "configure.h"
#include "syslog.h"
-void die_nomem(void);
+void die_nomem(const char *, int);
void die_err(char *msg);
void die_bug(void);
void die_suc(char *msg);
Modified: trunk/msn-proxy/msnp21.c
===================================================================
--- trunk/msn-proxy/msnp21.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/msnp21.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -224,7 +224,7 @@
#if 0
/* SEEIMG */
if (o && (user->commands & SEEIMG)) {
- if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(o, (unsigned char *)"0") == 0) DIE_NOMEM();
}
#endif
@@ -352,7 +352,7 @@
/* get contact e-mail */
str_zero(&c);
c.len = fmt_printf(NULL, "%s@%s", &name, &domain);
- if (str_ready(&c, c.len + 1) == 0) die_nomem();
+ if (str_ready(&c, c.len + 1) == 0) DIE_NOMEM();
c.len = fmt_printf(c.s, "%s@%s", &name, &domain);
if (c.len == 0) { str_free(&c); continue; }
@@ -376,13 +376,13 @@
contact->lists = lists | RL;
if (str_copy(&contact->dn, contact->c.s, contact->c.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_copys(&contact->status, (unsigned char *)"OFF") == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_copys(&contact->group, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_copys(&contact->uid, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
}
}
Modified: trunk/msn-proxy/net-io.c
===================================================================
--- trunk/msn-proxy/net-io.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/net-io.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -210,7 +210,7 @@
/* alloc new string */
port = str_alloc();
- if (port == NULL) die_nomem();
+ if (port == NULL) DIE_NOMEM();
/* find unused port in range */
for (count = 0; count < 10; count++) {
@@ -227,7 +227,7 @@
/* fmt port */
port->len = fmt_printf(NULL, "%d", random_port);
if (str_ready(port, port->len + 1) == 0)
- die_nomem();
+ DIE_NOMEM();
port->len = fmt_printf(port->s, "%d", random_port);
*listenfd = net_listen((char *)host->s, (char *)port->s, 1);
@@ -247,7 +247,7 @@
/* fmt return [IP:PORT] */
port->len = fmt_printf(NULL, "%s:%d", host, random_port);
- if (str_ready(port, port->len + 1) == 0) die_nomem();
+ if (str_ready(port, port->len + 1) == 0) DIE_NOMEM();
port->len = fmt_printf(port->s, "%s:%d", host, random_port);
return(port);
@@ -267,7 +267,7 @@
if ((strlen(host) > 0 && str_copys(str_host, (unsigned char *)host) == 0) ||
(strlen(port) > 0 && str_copys(str_port, (unsigned char *)port) == 0)) {
- die_nomem();
+ DIE_NOMEM();
}
return(ROK);
Modified: trunk/msn-proxy/ns.c
===================================================================
--- trunk/msn-proxy/ns.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/ns.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -311,7 +311,7 @@
string *port;
proxy = (struct client_ *)malloc(sizeof(*proxy));
- if (proxy == NULL) die_nomem();
+ if (proxy == NULL) DIE_NOMEM();
memset(proxy, 0, sizeof(*proxy));
proxy->fd = -1;
@@ -334,7 +334,7 @@
/* copy the host address */
if (port->len > 0 && str_copy(&proxy->host, port->s, port->len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* event set */
event_set(&proxy->listen, proxy->fd, EV_READ, ns_proxy_client, user);
@@ -359,7 +359,7 @@
return(RFAIL);
proxy = (struct client_ *)malloc(sizeof(*proxy));
- if (proxy == NULL) die_nomem();
+ if (proxy == NULL) DIE_NOMEM();
memset(proxy, 0, sizeof(*proxy));
proxy->fd = -1;
@@ -382,7 +382,7 @@
/* copy the host address */
if (port->len > 0 && str_copy(&proxy->host, port->s, port->len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* event set */
event_set(&proxy->listen, proxy->fd, EV_READ, ns_proxy_client, user);
@@ -487,7 +487,7 @@
/* copy the host address */
if (proxy->host.len > 0 &&
str_copy(&user->ns.client->host, proxy->host.s, proxy->host.len) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
/* did we have any data to push to the client ? */
Modified: trunk/msn-proxy/protocol.c
===================================================================
--- trunk/msn-proxy/protocol.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/protocol.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -828,7 +828,7 @@
return(ROK);
if (str_copy(&user->email, email->s, email->len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* update database */
if (db.sql_users_update(user) == RFAIL)
@@ -932,7 +932,7 @@
return(RFAIL);
if (str_copys(&user->status, (unsigned char *)"HDN") == 0)
- die_nomem();
+ DIE_NOMEM();
/* update sql */
if (db.sql_set_status(user) == RFAIL) {
@@ -1068,16 +1068,16 @@
/* fake command */
cmd = command_alloc();
- if (str_copy(&cmd->cmd, (unsigned char *)"MSG", 3) == 0) die_nomem();
+ if (str_copy(&cmd->cmd, (unsigned char *)"MSG", 3) == 0) DIE_NOMEM();
arg = command_add_arg(cmd);
if (warnemail.len > 0 && str_copy(arg, warnemail.s, warnemail.len) == 0)
- die_nomem();
+ DIE_NOMEM();
str_free(&warnemail);
arg = command_add_arg(cmd);
if (warndn.len > 0 && str_copy(arg, warndn.s, warndn.len) == 0)
- die_nomem();
+ DIE_NOMEM();
str_free(&warndn);
/* format msg payload */
@@ -1086,7 +1086,7 @@
"Content-Type: text/plain; charset=UTF-8\r\n"
"X-MMS-IM-Format: FN=%s; EF=; CO=%s; CS=0; PF=0\r\n\r\n%s",
&msgfont, &msgcolor, &warnmsg);
- if (str_ready(&cmd->payload, cmd->payload.len + 1) == 0) die_nomem();
+ if (str_ready(&cmd->payload, cmd->payload.len + 1) == 0) DIE_NOMEM();
cmd->payload.len = fmt_printf(cmd->payload.s,
"MIME-Version: 1.0\r\n"
"Content-Type: text/plain; charset=UTF-8\r\n"
@@ -1099,7 +1099,7 @@
/* add payload size */
arg = command_add_arg(cmd);
arg->len = fmt_printf(NULL, "%d", cmd->payload.len);
- if (str_ready(arg, arg->len + 1) == 0) die_nomem();
+ if (str_ready(arg, arg->len + 1) == 0) DIE_NOMEM();
arg->len = fmt_printf(arg->s, "%d", cmd->payload.len);
/* don't insert in database */
@@ -1137,17 +1137,17 @@
/* fake command */
cmd = command_alloc();
if (str_copy(&cmd->cmd, (unsigned char *)"MSG", 3) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
arg = command_add_arg(cmd);
if (str_copy(arg, (unsigned char *)"99999", 6) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
arg = command_add_arg(cmd);
if (str_copy(arg, (unsigned char *)"N", 1) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
/* format msg payload */
@@ -1156,7 +1156,7 @@
"Content-Type: text/plain; charset=UTF-8\r\n"
"X-MMS-IM-Format: FN=%s; EF=; CO=%s; CS=0; PF=0\r\n\r\n%s: %s",
&msgfont, &msgcolor, &warnemail, &warnmsg);
- if (str_ready(&cmd->payload, cmd->payload.len + 1) == 0) die_nomem();
+ if (str_ready(&cmd->payload, cmd->payload.len + 1) == 0) DIE_NOMEM();
cmd->payload.len = fmt_printf(cmd->payload.s,
"MIME-Version: 1.0\r\n"
"Content-Type: text/plain; charset=UTF-8\r\n"
@@ -1171,7 +1171,7 @@
/* add payload size */
arg = command_add_arg(cmd);
arg->len = fmt_printf(NULL, "%d", cmd->payload.len);
- if (str_ready(arg, arg->len + 1) == 0) die_nomem();
+ if (str_ready(arg, arg->len + 1) == 0) DIE_NOMEM();
arg->len = fmt_printf(arg->s, "%d", cmd->payload.len);
/* don't insert in database */
@@ -1198,7 +1198,7 @@
/* fake command */
cmd = command_alloc();
cmd->ignore = 1;
- if (str_copy(&cmd->cmd, (unsigned char *)"FLN", 3) == 0) die_nomem();
+ if (str_copy(&cmd->cmd, (unsigned char *)"FLN", 3) == 0) DIE_NOMEM();
arg = command_add_arg(cmd);
if (user->version == MSNP18) {
@@ -1206,13 +1206,13 @@
(str_copys(arg, (unsigned char *)"1:") == 0 ||
str_cat(arg, contact->c.s, contact->c.len) == 0)) {
- die_nomem();
+ DIE_NOMEM();
}
} else {
if (contact->c.len > 0 &&
str_copy(arg, contact->c.s, contact->c.len) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
}
@@ -1222,10 +1222,10 @@
case MSNP15:
case MSNP18:
arg = command_add_arg(cmd);
- if (str_copys(arg, (unsigned char *)"1") == 0) die_nomem();
+ if (str_copys(arg, (unsigned char *)"1") == 0) DIE_NOMEM();
arg = command_add_arg(cmd);
- if (str_copys(arg, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(arg, (unsigned char *)"0") == 0) DIE_NOMEM();
break;
}
@@ -1251,13 +1251,13 @@
/* fake command */
cmd = command_alloc();
cmd->ignore = 1;
- if (str_copy(&cmd->cmd, (unsigned char *)"NLN", 3) == 0) die_nomem();
+ if (str_copy(&cmd->cmd, (unsigned char *)"NLN", 3) == 0) DIE_NOMEM();
/* status */
arg = command_add_arg(cmd);
if (contact->status.len > 0 &&
str_copy(arg, contact->status.s, contact->status.len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* contact email */
arg = command_add_arg(cmd);
@@ -1266,13 +1266,13 @@
(str_copys(arg, (unsigned char *)"1:") == 0 ||
str_cat(arg, contact->c.s, contact->c.len) == 0)) {
- die_nomem();
+ DIE_NOMEM();
}
} else {
if (contact->c.len > 0 &&
str_copy(arg, contact->c.s, contact->c.len) == 0) {
- die_nomem();
+ DIE_NOMEM();
}
}
@@ -1280,7 +1280,7 @@
if (user->version == MSNP13 || user->version == MSNP15) {
arg = command_add_arg(cmd);
- if (str_copys(arg, (unsigned char *)"1") == 0) die_nomem();
+ if (str_copys(arg, (unsigned char *)"1") == 0) DIE_NOMEM();
}
/* display name */
@@ -1290,7 +1290,7 @@
str_zero(&dn);
(void)msn_encode(&contact->dn, &dn);
if (dn.len > 0 && str_copy(arg, dn.s, dn.len) == 0)
- die_nomem();
+ DIE_NOMEM();
}
str_free(&dn);
@@ -1298,11 +1298,11 @@
arg = command_add_arg(cmd);
if (user->version == MSNP18) {
arg->len = fmt_printf(NULL, "%l:%l", contact->capab, contact->excapab);
- if (str_ready(arg, arg->len + 1) == 0) die_nomem();
+ if (str_ready(arg, arg->len + 1) == 0) DIE_NOMEM();
arg->len = fmt_printf(arg->s, "%l:%l", contact->capab, contact->excapab);
} else {
arg->len = fmt_printf(NULL, "%l", contact->capab);
- if (str_ready(arg, arg->len + 1) == 0) die_nomem();
+ if (str_ready(arg, arg->len + 1) == 0) DIE_NOMEM();
arg->len = fmt_printf(arg->s, "%l", contact->capab);
}
@@ -1310,10 +1310,10 @@
arg = command_add_arg(cmd);
if (contact->o.len > 0) {
if (str_copy(arg, contact->o.s, contact->o.len) == 0)
- die_nomem();
+ DIE_NOMEM();
} else {
if (str_copys(arg, (unsigned char *)"0") == 0)
- die_nomem();
+ DIE_NOMEM();
}
/* add command to queue */
@@ -1325,7 +1325,7 @@
/* fake command */
cmd = command_alloc();
cmd->ignore = 1;
- if (str_copys(&cmd->cmd, (unsigned char *)"UBX") == 0) die_nomem();
+ if (str_copys(&cmd->cmd, (unsigned char *)"UBX") == 0) DIE_NOMEM();
/* user */
arg = command_add_arg(cmd);
@@ -1333,11 +1333,11 @@
(str_copys(arg, (unsigned char *)"1:") == 0 ||
str_cat(arg, contact->c.s, contact->c.len) == 0)) {
- die_nomem();
+ DIE_NOMEM();
}
arg = command_add_arg(cmd);
- if (str_copys(arg, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(arg, (unsigned char *)"0") == 0) DIE_NOMEM();
/* add command to queue */
commands_add_command(&user->ns.server->commands, cmd);
@@ -1368,7 +1368,7 @@
/* add the fake out command */
cmd = command_alloc();
if (str_copy(&cmd->cmd, (unsigned char *)"OUT", 3) == 0)
- die_nomem();
+ DIE_NOMEM();
/* add command to queue */
commands_add_command(&user->ns.client->commands, cmd);
@@ -1395,7 +1395,7 @@
end = str->len - (str->p - str->s);
}
- if (str_copy(out, str->s + start, (str->len - start - end)) == 0) die_nomem();
+ if (str_copy(out, str->s + start, (str->len - start - end)) == 0) DIE_NOMEM();
}
#define ISVALID(m) (m >= 33 && m <= 125)
Modified: trunk/msn-proxy/sb.c
===================================================================
--- trunk/msn-proxy/sb.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/sb.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -86,7 +86,7 @@
struct sb_ *sb;
sb = (struct sb_ *)malloc(sizeof(struct sb_));
- if (sb == NULL) die_nomem();
+ if (sb == NULL) DIE_NOMEM();
memset(sb, 0, sizeof(struct sb_));
sb->user = user;
@@ -118,11 +118,11 @@
struct sb_user_ *tmp;
sb_user = (struct sb_user_ *)malloc(sizeof(struct sb_user_));
- if (sb_user == NULL) die_nomem();
+ if (sb_user == NULL) DIE_NOMEM();
memset(sb_user, 0, sizeof(struct sb_user_));
if (email->len > 0 && str_copy(&sb_user->email, email->s, email->len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* insert/very the rb list */
tmp = RB_INSERT(sb_users_, &sb->sb_users, sb_user);
@@ -161,17 +161,17 @@
if (type == SERVER && email && email->len > 0 &&
strcmp((char *)sb_user->email.s, (char *)email->s) == 0) {
if (to_start && str_cats(to, (unsigned char *)", ") == 0)
- die_nomem();
+ DIE_NOMEM();
if (user->dn.len > 0 &&
str_cat(to, user->dn.s, user->dn.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_cats(to, (unsigned char *)" (") == 0)
- die_nomem();
+ DIE_NOMEM();
if (user->email.len > 0 &&
str_cat(to, user->email.s, user->email.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_cats(to, (unsigned char *)")") == 0)
- die_nomem();
+ DIE_NOMEM();
if (!to_start) to_start = 1;
@@ -179,7 +179,7 @@
memset(&f, 0, sizeof(f));
if (str_copy(&f.c, sb_user->email.s, sb_user->email.len) == 0)
- die_nomem();
+ DIE_NOMEM();
contact = RB_FIND(contacts, &user->contacts, &f);
contact_free(&f);
@@ -200,17 +200,17 @@
}
if (to_start && str_cats(to, (unsigned char *)", ") == 0)
- die_nomem();
+ DIE_NOMEM();
if (contact && contact->dn.len > 0 &&
str_cat(to, contact->dn.s, contact->dn.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_cats(to, (unsigned char *)" (") == 0)
- die_nomem();
+ DIE_NOMEM();
if (sb_user->email.len > 0 &&
str_cat(to, sb_user->email.s, sb_user->email.len) == 0)
- die_nomem();
+ DIE_NOMEM();
if (str_cats(to, (unsigned char *)")") == 0)
- die_nomem();
+ DIE_NOMEM();
if (!to_start) to_start = 1;
}
@@ -581,7 +581,7 @@
/* save the proxy address */
if (port->len > 0 && str_copy(&client->host, port->s, port->len) == 0)
- die_nomem();
+ DIE_NOMEM();
/* event set */
event_set(&client->listen, client->fd, EV_READ, sb_connect, sb);
Modified: trunk/msn-proxy/server.c
===================================================================
--- trunk/msn-proxy/server.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/server.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -101,7 +101,7 @@
/* alloc */
server = (struct server_ *)malloc(sizeof(*server));
- if (server == NULL) die_nomem();
+ if (server == NULL) DIE_NOMEM();
/* zero everything */
memset(server, 0, sizeof(*server));
@@ -139,7 +139,7 @@
return(server);
server = server_alloc();
- if (server == NULL) die_nomem();
+ if (server == NULL) DIE_NOMEM();
/* XXX */
str_zero(&tmp);
Modified: trunk/msn-proxy/user.c
===================================================================
--- trunk/msn-proxy/user.c 2012-06-03 19:11:41 UTC (rev 181)
+++ trunk/msn-proxy/user.c 2012-06-29 12:19:57 UTC (rev 182)
@@ -77,7 +77,7 @@
/* save user status */
if (str_copy(&user->status, status->s, status->len) == 0)
- die_nomem();
+ DIE_NOMEM();
//user->flags = arg[2];
@@ -98,7 +98,7 @@
switch (user->version) {
case MSNP15:
case MSNP18:
- if (str_copys(o, (unsigned char *)"0") == 0) die_nomem();
+ if (str_copys(o, (unsigned char *)"0") == 0) DIE_NOMEM();
break;
default:
str_free(o);
@@ -195,7 +195,7 @@
/* alloc new user */
user = (struct user_ *)malloc(sizeof(struct user_));
- if (user == NULL) die_nomem();
+ if (user == NULL) DIE_NOMEM();
/* zero everything */
memset(user, 0, sizeof(struct user_));
@@ -206,7 +206,7 @@
user->state = PRE_AUTH;
RB_INIT(&user->contacts);
LIST_INIT(&user->sbs);
- if (str_copys(&user->status, (unsigned char *)"OFF") == 0) die_nomem();
+ if (str_copys(&user->status, (unsigned char *)"OFF") == 0) DIE_NOMEM();
/* get the user ip address */
if (resolve_client(&user->host, &user->port, sa, sa_len) == RFAIL) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|