47 char *
hashout,
unsigned long bodysize,
unsigned long chunk)
51 const char *table = (
char *) 0;
55 strnum[fmt_ulong(strnum,
msgnum)] =
'\0';
57 switch (openreadclose(
"key",&key,32)) {
58 case -1:
logmsg(
WHO,111,FATAL,B(
"ERR_READ :",
"key: "));
59 case 0:
logmsg(
WHO,100,FATAL,B(
"key",
" ERR_NOEXIST"));
63 for (i = 0; i <
COOKIE; i++)
70 if (chunk >= 53L) chunk = 0L;
76 if (!stralloc_copys(&line,
"INSERT INTO "))
die_nomem();
77 if (!stralloc_cats(&line,table))
die_nomem();
78 if (!stralloc_cats(&line,
"_cookie (msgnum,cookie,bodysize,chunk) VALUES ("))
die_nomem();
79 if (!stralloc_cats(&line,strnum))
die_nomem();
80 if (!stralloc_cats(&line,
",'"))
die_nomem();
82 if (!stralloc_cats(&line,
"',"))
die_nomem();
83 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,bodysize)))
die_nomem();
84 if (!stralloc_cats(&line,
","))
die_nomem();
85 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,chunk)))
die_nomem();
86 if (!stralloc_cats(&line,
")"))
die_nomem();
89 result = PQexec(
pgsql,line.s);
93 if (PQresultStatus(result) != PGRES_COMMAND_OK) {
94 if (!stralloc_copys(&line,
"SELECT msgnum FROM "))
die_nomem();
95 if (!stralloc_cats(&line,table))
die_nomem();
96 if (!stralloc_cats(&line,
"_cookie WHERE msgnum = "))
die_nomem();
102 result2 = PQexec(
pgsql,line.s);
105 if (PQresultStatus(result2) != PGRES_TUPLES_OK)
106 logmsg(
WHO,111,FATAL,PQresultErrorMessage(result2));
110 if (PQntuples(result2) < 1)
111 logmsg(
WHO,111,FATAL,PQresultErrorMessage(result));
void cookie(char *hash, const char *key, unsigned int keylen, const char *date, const char *addr, const char *action)
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)
void tagmsg(const char *dir, unsigned long msgnum, const char *seed, const char *action, char *hashout, unsigned long bodysize, unsigned long chunk)