Import ezmlm-idx 0.40
[ezmlm] / sub_std / tagmsg.c
CommitLineData
f8beb284
MW
1/*$Id: tagmsg.c,v 1.3 1999/10/12 23:38:36 lindberg Exp $*/
2/*$Name: ezmlm-idx-040 $*/
3#include "stralloc.h"
4#include "scan.h"
5#include "fmt.h"
6#include "strerr.h"
7#include "cookie.h"
8#include "slurp.h"
9#include "errtxt.h"
10#include "subscribe.h"
11#include "makehash.h"
12
13static stralloc line = {0};
14static stralloc key = {0};
15static char hash[COOKIE];
16static char strnum[FMT_ULONG]; /* message number as sz */
17
18static void die_nomem(fatal)
19char *fatal;
20{
21 strerr_die2x(100,fatal,ERR_NOMEM);
22}
23
24void tagmsg(dir,msgnum,seed,action,hashout,bodysize,chunk,fatal)
25/* This routine creates a cookie from num,seed and the */
26/* list key and returns that cookie in hashout. The use of sender/num and */
27/* first char of action is used to make cookie differ between messages, */
28/* the key is the secret list key. */
29
30char *dir; /* db base dir */
31unsigned long msgnum; /* number of this message */
32char *seed; /* seed. NULL ok, but less entropy */
33char *action; /* to make it certain the cookie differs from*/
34 /* one used for a digest */
35char *hashout; /* calculated hash goes here */
36unsigned long bodysize;
37unsigned long chunk;
38char *fatal;
39{
40 unsigned int i;
41
42 strnum[fmt_ulong(strnum,msgnum)] = '\0'; /* message nr ->string*/
43
44 switch(slurp("key",&key,32)) {
45 case -1:
46 strerr_die3sys(111,fatal,ERR_READ,"key: ");
47 case 0:
48 strerr_die3x(100,fatal,"key",ERR_NOEXIST);
49 }
50 cookie(hash,key.s,key.len,strnum,seed,action);
51 for (i = 0; i < COOKIE; i++)
52 hashout[i] = hash[i];
53
54 return;
55}