diff --git a/mbuni/extras/pgsql-queue/mms_pgsql_queue.c b/mbuni/extras/pgsql-queue/mms_pgsql_queue.c index 93a0b8a..8eaff33 100644 --- a/mbuni/extras/pgsql-queue/mms_pgsql_queue.c +++ b/mbuni/extras/pgsql-queue/mms_pgsql_queue.c @@ -181,7 +181,8 @@ static int pgq_free_envelope(MmsEnvelope *e, int removefromqueue) static MmsEnvelope *pgq_queue_readenvelope(char *qf, char *mms_queuedir, int shouldblock) { - long qid, num_attempts, i, n; + int64_t qid; + long num_attempts, i, n; time_t sendt, created, lastt, edate; char cmd[4*QFNAMEMAX], _qf[QFNAMEMAX*2+1]; Octstr *from = NULL; @@ -212,7 +213,7 @@ static MmsEnvelope *pgq_queue_readenvelope(char *qf, char *mms_queuedir, int sho /* Get top-level values. */ if ((s = PQgetvalue(r, 0, PQfnumber(r, "id"))) != NULL) - qid = strtoul(s, NULL, 10); + qid = strtoull(s, NULL, 10); else qid = 0; @@ -247,7 +248,7 @@ static MmsEnvelope *pgq_queue_readenvelope(char *qf, char *mms_queuedir, int sho PQclear(r); - sprintf(cmd, "SELECT item,value,id FROM mms_message_headers WHERE qid=%ld FOR UPDATE", qid); + sprintf(cmd, "SELECT item,value,id FROM mms_message_headers WHERE qid=%lld FOR UPDATE", qid); r = PQexec(c, cmd); if (PQresultStatus(r) != PGRES_TUPLES_OK) { @@ -397,7 +398,7 @@ static MmsEnvelope *pgq_queue_readenvelope(char *qf, char *mms_queuedir, int sho } /* utility writer function. */ -static int _puthdr(PGconn *c, long qid, char *hname, char *val) +static int _puthdr(PGconn *c, int64_t qid, char *hname, char *val) { char cmd[QFNAMEMAX*4+1], vbuf[2*QFNAMEMAX+1]; PGresult *r; @@ -406,7 +407,7 @@ static int _puthdr(PGconn *c, long qid, char *hname, char *val) n = strlen(val); PQescapeStringConn(c, vbuf, val, n < QFNAMEMAX ? n : QFNAMEMAX, NULL); - sprintf(cmd, "INSERT INTO mms_message_headers (qid,item,value) VALUES (%ld, '%.128s', '%.128s')", + sprintf(cmd, "INSERT INTO mms_message_headers (qid,item,value) VALUES (%lld, '%.128s', '%.128s')", qid, hname, vbuf); r = PQexec(c, cmd); @@ -773,7 +774,7 @@ static MmsMsg *pgq_queue_getdata(MmsEnvelope *e) } struct Qthread_data_t { - long qid; + int64_t qid; char qf[QFNAMEMAX]; char dir[QFNAMEMAX]; /* item to load. */ @@ -853,7 +854,7 @@ static void pgq_queue_run(char *dir, struct Qthread_data_t *d = gw_malloc(sizeof *d); memset(d, 0, sizeof *d); - d->qid = strtoul(qid, NULL, 10); + d->qid = strtoull(qid, NULL, 10); strncpy(d->qf, qfname, sizeof d->qf); strncpy(d->dir, dir, sizeof d->dir); d->deliver = deliver;