ezmlmx 0.68
ezmlmx
Loading...
Searching...
No Matches
ezmlm-issubn.c
Go to the documentation of this file.
1#include <unistd.h>
2#include "logmsg.h"
3#include "env.h"
4#include "subscribe.h"
5#include "getoptb.h"
6#include "errtxt.h"
7#include "idx.h"
8#include "auto_version.h"
9
10#define WHO "ezmlm-issubn"
11
17
18static void die_nomem() { logmsg(WHO,111,FATAL,ERR_NOMEM); }
19static void die_usage() { logmsg(WHO,100,USAGE,"ezmlm-issubn [-nN] dir [dir1 ...]"); }
20static void die_sender() { logmsg(WHO,100,FATAL,ERR_NOSENDER); }
21
22int main(int argc,char **argv)
23{
24 char *dir;
25 char *addr;
26 int flagsub = 0;
27 int opt;
28
29 addr = env_get("SENDER");
30 if (!addr) die_sender(); /* REQUIRE sender */
31
32 while ((opt = getoptb(argc,argv,"nNvV")) != opteof)
33 switch(opt) {
34 case 'n': flagsub = 99; break;
35 case 'N': flagsub = 0; break;
36 case 'v':
37 case 'V': logmsg(WHO,0,VERSION,auto_version);
38 default: die_usage();
39 }
40
41 dir = argv[optind];
42 if (chdir(dir) == -1)
43 logmsg(WHO,111,FATAL,B(ERR_SWITCH,dir));
44
45 while ((dir = argv[optind++])) {
46 if (dir[0] != '/')
47 logmsg(WHO,100,FATAL,B(ERR_SLASH,dir));
48 if (issub(dir,addr,(char *) 0)) {
49 closesql();
50 _exit(flagsub); /* subscriber */
51 }
52 }
53 closesql();
54 if (flagsub) /* not subscriber anywhere */
55 _exit(0);
56 else
57 _exit(99);
58
59 return 0;
60}
int issub()
Returns (char *) to match if userhost is in the subscriber database dbname, 0 otherwise....
const char auto_version[]
Error messages. If you translate these, I would urge you to keep the English version as well....
#define ERR_NOMEM
Definition errtxt.h:14
#define ERR_SWITCH
Definition errtxt.h:42
#define ERR_SLASH
Definition errtxt.h:118
#define ERR_NOSENDER
Definition errtxt.h:37
void closesql(void)
close connection to SQL server, if open
Definition opensql.c:21
void die_nomem()
Definition getconf.c:17
#define WHO
Definition author.c:1
int flagsub
Definition ezmlm-get.c:54
char * dir
int main()
Definition ezmlm-weed.c:69
int opt
Definition ezmlm-cron.c:53
stralloc addr
Definition ezmlm-cron.c:45
const char * logmsg(const char *dir, unsigned long num, unsigned long listno, unsigned long subs, int done)
Definition loginfo.c:32