minor fixes to extras
This commit is contained in:
parent
61d76e1a14
commit
45c6276727
|
@ -3,10 +3,10 @@
|
|||
KANNELCONF = /usr/local/bin/gw-config
|
||||
PGCONF = /usr/local/pgsql/bin/pg_config
|
||||
CC = gcc
|
||||
MBUNIDIR = ../mbuni
|
||||
MBUNIDIR = ../..
|
||||
LIBTOOL = libtool
|
||||
ARCH = $(shell uname -s)
|
||||
CFLAGS = -Wall -g -fPIC -I$(MBUNIDIR) -g -I$(MBUNIDIR)/mmlib `$(KANNELCONF) --cflags` -I`$(PGCONF) --includedir`
|
||||
CFLAGS = -Wall -g -fPIC -I$(MBUNIDIR) -g -I$(MBUNIDIR)/mmlib `$(KANNELCONF) --cflags | sed 's/-O2//g'` -I`$(PGCONF) --includedir`
|
||||
|
||||
ifeq ($(ARCH),Darwin)
|
||||
XLDFLAGS=-dynamiclib -Wl,-flat_namespace,-undefined,suppress -arch i386 -arch ppc
|
||||
|
|
|
@ -93,7 +93,7 @@ struct pgfile_t {
|
|||
PGconn *conn;
|
||||
char dir[256+1];
|
||||
char _pad[4]; /* paranoia */
|
||||
long qid; /* internal key into table (if any) */
|
||||
int64_t qid; /* internal key into table (if any) */
|
||||
};
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@ static int pgq_free_envelope(MmsEnvelope *e, int removefromqueue)
|
|||
/* copy to separate table. */
|
||||
PGresult *res;
|
||||
sprintf(cmd, "INSERT INTO archived_mms_messages SELECT "
|
||||
" * from mms_messages WHERE id = %ld", qfs->qid);
|
||||
" * from mms_messages WHERE id = %lld", qfs->qid);
|
||||
res = PQexec(qfs->conn, cmd);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
|
@ -132,7 +132,7 @@ static int pgq_free_envelope(MmsEnvelope *e, int removefromqueue)
|
|||
PQclear(res);
|
||||
|
||||
sprintf(cmd, "INSERT INTO archived_mms_message_headers SELECT "
|
||||
" * from mms_message_headers WHERE qid = %ld", qfs->qid);
|
||||
" * from mms_message_headers WHERE qid = %lld", qfs->qid);
|
||||
res = PQexec(qfs->conn, cmd);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
|
||||
|
@ -142,7 +142,7 @@ static int pgq_free_envelope(MmsEnvelope *e, int removefromqueue)
|
|||
} else
|
||||
PQclear(res);
|
||||
|
||||
sprintf(cmd, "DELETE from mms_messages WHERE id = %ld", qfs->qid);
|
||||
sprintf(cmd, "DELETE from mms_messages WHERE id = %lld", qfs->qid);
|
||||
res = PQexec(qfs->conn, cmd);
|
||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||
ret = -1;
|
||||
|
@ -268,7 +268,7 @@ static MmsEnvelope *pgq_queue_readenvelope(char *qf, char *mms_queuedir, int sho
|
|||
NULL,
|
||||
NULL,
|
||||
qf,
|
||||
sizeof (struct pgfile_t));
|
||||
sizeof (struct pgfile_t), NULL);
|
||||
|
||||
/* set the private data. */
|
||||
pgs = e->qfs_data;
|
||||
|
@ -427,7 +427,7 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
|
|||
gw_assert(e);
|
||||
|
||||
if (!newenv) {
|
||||
sprintf(cmd, "DELETE FROM mms_message_headers WHERE qid = %ld", qfs->qid);
|
||||
sprintf(cmd, "DELETE FROM mms_message_headers WHERE qid = %lld", qfs->qid);
|
||||
r = PQexec(qfs->conn, cmd);
|
||||
PQclear(r);
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ static int writeenvelope(MmsEnvelope *e, int newenv)
|
|||
|
||||
xfrom = gw_malloc(2*octstr_len(e->from)+1);
|
||||
PQescapeStringConn(qfs->conn, xfrom, octstr_get_cstr(e->from), octstr_len(e->from), NULL);
|
||||
sprintf(cmd, "UPDATE mms_messages SET num_attempts = %ld, sender='%s' %s %s %s WHERE id = %ld",
|
||||
sprintf(cmd, "UPDATE mms_messages SET num_attempts = %ld, sender='%s' %s %s %s WHERE id = %lld",
|
||||
e->attempts, xfrom, lastt, sendt, expiryt, qfs->qid);
|
||||
gw_free(xfrom);
|
||||
|
||||
|
@ -571,8 +571,8 @@ static Octstr *pgq_queue_add(Octstr *from, List *to,
|
|||
int dlr,
|
||||
char *directory, Octstr *mmscname)
|
||||
{
|
||||
char qf[QFNAMEMAX];
|
||||
long qid;
|
||||
char qf[QFNAMEMAX], xqid[128];
|
||||
int64_t qid;
|
||||
MmsEnvelope *e;
|
||||
Octstr *ms = NULL, *res = NULL, *xcmd = NULL;
|
||||
struct pgfile_t *qfs = NULL;
|
||||
|
@ -595,11 +595,11 @@ static Octstr *pgq_queue_add(Octstr *from, List *to,
|
|||
s = PQgetvalue(r, 0, 0);
|
||||
gw_assert(s);
|
||||
|
||||
qid = strtoul(s, NULL, 10);
|
||||
qid = strtoull(s, NULL, 10);
|
||||
PQclear(r);
|
||||
|
||||
/* make the long queue id. Including the integer qid ensures uniqueness.*/
|
||||
sprintf(qf, "%cf%ld-%ld.%d.x%d.%ld",
|
||||
sprintf(qf, "%cf%lld-%ld.%d.x%d.%ld",
|
||||
MQF,
|
||||
qid,
|
||||
(long)time(NULL) % 10000,
|
||||
|
@ -611,9 +611,7 @@ static Octstr *pgq_queue_add(Octstr *from, List *to,
|
|||
senddate,expirydate,token,vaspid,vasid,
|
||||
url1,url2,hdrs,dlr,mmscname,m,
|
||||
qf,
|
||||
sizeof(struct pgfile_t));
|
||||
|
||||
ms = mms_tobinary(m); /* Convert message to string. */
|
||||
sizeof(struct pgfile_t), &ms);
|
||||
|
||||
qfs = e->qfs_data;
|
||||
qfs->conn = conn;
|
||||
|
@ -626,9 +624,10 @@ static Octstr *pgq_queue_add(Octstr *from, List *to,
|
|||
PQescapeStringConn(qfs->conn, xfrom, octstr_get_cstr(from), octstr_len(from), NULL);
|
||||
data = (void *)PQescapeByteaConn(qfs->conn, (void *)octstr_get_cstr(ms), octstr_len(ms), &dlen);
|
||||
|
||||
sprintf(xqid, "%lld", qid);
|
||||
xcmd = octstr_format("INSERT INTO mms_messages (id, qdir, qfname, sender, data,expire_date) VALUES "
|
||||
" (%ld, '%s', '%s', '%s', E'%s'::bytea, current_timestamp)",
|
||||
qid, directory, qf, xfrom, data);
|
||||
" (%s, '%s', '%s', '%s', E'%s'::bytea, current_timestamp)",
|
||||
xqid, directory, qf, xfrom, data);
|
||||
PQfreemem(data);
|
||||
gw_free(xfrom);
|
||||
|
||||
|
@ -696,7 +695,7 @@ static int pgq_queue_update(MmsEnvelope *e)
|
|||
|
||||
static int pgq_queue_replacedata(MmsEnvelope *e, MmsMsg *m)
|
||||
{
|
||||
char *data;
|
||||
char *data, xqid[128];
|
||||
size_t dlen;
|
||||
struct pgfile_t *qfs;
|
||||
int ret = 0;
|
||||
|
@ -709,8 +708,9 @@ static int pgq_queue_replacedata(MmsEnvelope *e, MmsMsg *m)
|
|||
ms = mms_tobinary(m);
|
||||
|
||||
data = (void *)PQescapeByteaConn(qfs->conn, (void *)octstr_get_cstr(ms), octstr_len(ms), &dlen);
|
||||
xcmd = octstr_format("UPDATE mms_messages SET data=E'%s' WHERE id = %ld",
|
||||
data, qfs->qid);
|
||||
sprintf(xqid, "%lld", qfs->qid);
|
||||
xcmd = octstr_format("UPDATE mms_messages SET data=E'%s' WHERE id = %s",
|
||||
data, xqid);
|
||||
r = PQexec(qfs->conn, octstr_get_cstr(xcmd));
|
||||
ret = (PQresultStatus(r) != PGRES_COMMAND_OK) ? -1 : 0; /* do nothing about error. we are in a transaction.*/
|
||||
PQclear(r);
|
||||
|
@ -735,7 +735,7 @@ static MmsMsg *pgq_queue_getdata(MmsEnvelope *e)
|
|||
|
||||
qfs = e->qfs_data;
|
||||
|
||||
sprintf(cmd, "SELECT data from mms_messages WHERE id = %ld", qfs->qid);
|
||||
sprintf(cmd, "SELECT data from mms_messages WHERE id = %lld", qfs->qid);
|
||||
r = PQexec(qfs->conn, cmd);
|
||||
|
||||
if (PQresultStatus(r) != PGRES_TUPLES_OK ||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
-- Master messages table
|
||||
CREATE TABLE mms_messages (
|
||||
id serial PRIMARY KEY,
|
||||
id bigserial PRIMARY KEY,
|
||||
qdir varchar(256) NOT NULL,
|
||||
qfname varchar(256) NOT NULL,
|
||||
sender varchar(256) NOT NULL,
|
||||
|
@ -33,7 +33,7 @@ CREATE VIEW mms_messages_view AS SELECT
|
|||
|
||||
-- Table for envelope headers.
|
||||
CREATE TABLE mms_message_headers (
|
||||
id serial PRIMARY KEY,
|
||||
id bigserial PRIMARY KEY,
|
||||
qid int REFERENCES mms_messages ON UPDATE CASCADE ON DELETE CASCADE,
|
||||
|
||||
item varchar(64) NOT NULL,
|
||||
|
|
|
@ -219,7 +219,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho
|
|||
NULL,
|
||||
NULL,
|
||||
qf,
|
||||
sizeof (struct qfile_t));
|
||||
sizeof (struct qfile_t), NULL);
|
||||
|
||||
e->to = gwlist_create();
|
||||
qfs = e->qfs_data;
|
||||
|
@ -721,7 +721,7 @@ static Octstr *mms_queue_add(Octstr *from, List *to,
|
|||
char qf[QFNAMEMAX], subdir[64];
|
||||
int fd;
|
||||
MmsEnvelope *e;
|
||||
Octstr *ms, *res = NULL;
|
||||
Octstr *ms = NULL, *res = NULL;
|
||||
struct qfile_t *qfs = NULL;
|
||||
|
||||
fd = mkqf(qf, subdir, directory);
|
||||
|
@ -736,10 +736,7 @@ static Octstr *mms_queue_add(Octstr *from, List *to,
|
|||
senddate,expirydate,token,vaspid,vasid,
|
||||
url1,url2,hdrs,dlr,mmscname,m,
|
||||
octstr_get_cstr(res),
|
||||
sizeof(struct qfile_t));
|
||||
|
||||
ms = mms_tobinary(m); /* Convert message to string. */
|
||||
|
||||
sizeof(struct qfile_t), &ms);
|
||||
qfs = e->qfs_data;
|
||||
strncpy(qfs->name, qf, sizeof qfs->name);
|
||||
strncpy(qfs->subdir, subdir, sizeof qfs->subdir);
|
||||
|
@ -833,7 +830,8 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
|
|||
Octstr *mmscname,
|
||||
MmsMsg *m,
|
||||
char *xqfname,
|
||||
int extra_space)
|
||||
int extra_space,
|
||||
Octstr **binary_mms)
|
||||
{
|
||||
MmsEnvelope *e;
|
||||
Octstr *msgid = NULL, *ms = NULL, *r, *xfrom;
|
||||
|
@ -892,7 +890,10 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
|
|||
t->process = 1;
|
||||
gwlist_append(e->to, t);
|
||||
}
|
||||
octstr_destroy(ms);
|
||||
if (binary_mms)
|
||||
*binary_mms = ms;
|
||||
else
|
||||
octstr_destroy(ms);
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ typedef struct MmsQueueHandlerFuncs {
|
|||
|
||||
extern MmsQueueHandlerFuncs default_qfuncs; /* default queue handler module, file-based */
|
||||
/* Utility functions, generally defined. */
|
||||
/* Creates the queue envelope object, returns it. */
|
||||
/* Creates the queue envelope object, returns it. Returns the binary MMS in 'binary_mms' if NOT NULL */
|
||||
MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
|
||||
Octstr *subject,
|
||||
Octstr *fromproxy, Octstr *viaproxy,
|
||||
|
@ -166,7 +166,8 @@ MmsEnvelope *mms_queue_create_envelope(Octstr *from, List *to,
|
|||
Octstr *mmscname,
|
||||
MmsMsg *m,
|
||||
char *xqfname,
|
||||
int extra_space);
|
||||
int extra_space,
|
||||
Octstr **binary_mms);
|
||||
/* Get rid of memory used by this. */
|
||||
void mms_queue_free_envelope(MmsEnvelope *e);
|
||||
|
||||
|
|
Loading…
Reference in New Issue