12#include <mysqld_error.h>
24static stralloc line = {0};
25static stralloc key = {0};
27static char strnum[FMT_ULONG];
46 char *
hashout,
unsigned long bodysize,
unsigned long chunk)
48 const char *table = (
char *) 0;
52 strnum[fmt_ulong(strnum,
msgnum)] =
'\0';
54 switch (
slurp(
"key",&key,32)) {
55 case -1:
logmsg(
WHO,111,FATAL,B(
"ERR_READ :",
"key");
56 case 0:
logmsg(
WHO,100,FATAL,B(
"key",
"ERR_NOEXIST"));
61 for (i = 0; i <
COOKIE; i++)
68 if (chunk >= 53L) chunk = 0L;
74 if (!stralloc_copys(&line,
"INSERT INTO "))
die_nomem();
75 if (!stralloc_cats(&line,table))
die_nomem();
76 if (!stralloc_cats(&line,
"_cookie (msgnum,cookie,bodysize,chunk) VALUES ("))
die_nomem();
77 if (!stralloc_cats(&line,strnum))
die_nomem();
78 if (!stralloc_cats(&line,
",'"))
die_nomem();
80 if (!stralloc_cats(&line,
"',"))
die_nomem();
81 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,bodysize)))
die_nomem();
82 if (!stralloc_cats(&line,
","))
die_nomem();
83 if (!stralloc_catb(&line,strnum,fmt_ulong(strnum,chunk)))
die_nomem();
84 if (!stralloc_cats(&line,
")"))
die_nomem();
85 if (mysql_real_query(
mysql,line.s,line.len) != 0)
86 if (mysql_errno(
mysql) != ER_DUP_ENTRY)
int slurp(const char *fn, struct stralloc *sa, int bufsize)
Error messages. If you translate these, I would urge you to keep the English version as well....
const char * opensql(const char *dir, const char **table)
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)