-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmybadenvelope.c
55 lines (45 loc) · 1.38 KB
/
mybadenvelope.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************************
* *
* This file is part of quser. http://projects.standblue.net/software/quser *
* *
* $Id: mybadenvelope.c,v 1.1 2002/10/01 04:01:20 cwright Exp $ *
* *
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "quser.h"
#ifdef MAILFROM
#define QUSERPROG "mybadmailfrom"
#define ENVVAR "SENDER"
#endif
#ifdef RCPTTO
#define QUSERPROG "mybadrcptto"
#define ENVVAR "RECIPIENT"
#endif
int main(int argc, char **argv) {
FILE *fp;
char match[MAX_ADDRESS];
char *address;
int accept=1;
if(argc < 2) {
fprintf(stderr,"%s: No address file given",QUSERPROG);
exit(100);
}
if((address=getenv(ENVVAR))==NULL) {
fprintf(stderr,"%s: No %s set",QUSERPROG,ENVVAR);
exit(100);
}
if((fp=fopen(*++argv,"r"))==NULL) {
fprintf(stderr,"%s: Could not open %s",QUSERPROG,*argv);
exit(111);
}
while(fgets(match,MAX_ADDRESS,fp)) {
if(addressmatch(address,match)) {
accept=0;
break;
}
}
fclose(fp);
return (accept==1) ? 0 : 100;
}