Import ezmlm-idx 0.40
[ezmlm] / sub_std / checktag.c
CommitLineData
f8beb284
MW
1/*$Id: checktag.c,v 1.4 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 "cookie.h"
7#include "makehash.h"
8#include "strerr.h"
9#include "errtxt.h"
10#include "subscribe.h"
11
12static stralloc key = {0};
13static stralloc line = {0};
14static stralloc quoted = {0};
15static char strnum[FMT_ULONG];
16static char newcookie[COOKIE];
17
18char *checktag (dir,num,listno,action,seed,hash)
19/* reads dir/sql. If not present, checks that the hash of seed matches */
20/* hash and returns success (NULL). If not match returns "". If error, */
21/* returns error string */
22
23char *dir; /* the db base dir */
24unsigned long num; /* message number */
25unsigned long listno; /* bottom of range => slave */
26char *action;
27char *seed; /* cookie base */
28char *hash; /* cookie */
29{
30
31 if (!seed) return (char *) 0; /* no data - accept */
32
33 strnum[fmt_ulong(strnum,num)] = '\0'; /* message nr ->string*/
34
35 switch(slurp("key",&key,32)) {
36 case -1:
37 return ERR_READ_KEY;
38 case 0:
39 return ERR_NOEXIST_KEY;
40 }
41
42 cookie(newcookie,key.s,key.len,strnum,seed,action);
43 if (byte_diff(hash,COOKIE,newcookie)) return "";
44 else return (char *) 0;
45
46}