blob: 3d18f430a5a3ee333ed5618547ffb8a29eaf463a (
plain) (
blame)
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
56
57
58
59
60
61
62
63
64
65
66
|
--- nbsmtp.c.orig Sat Apr 7 02:09:01 2001
+++ nbsmtp.c Wed Apr 10 22:03:27 2002
@@ -19,6 +19,8 @@
*/
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -76,42 +78,45 @@
{
printf("Usage:\n");
printf("%s -d domain -f from@addr -h host [-p port] [-l debuglevel]\n", prog);
+ exit(EXIT_FAILURE);
}
int main(int argc, char *argv[])
{
- int i;
+ int ch;
- for(i=1; i<argc; i+=2){
- switch(*(argv[i]+1))
+ while ( (ch = getopt(argc, argv, "h:d:f:p:l:")) != -1){
+ switch (ch)
{
case 'h':
- host = (char *)strdup(argv[i+1]);
+ host = strdup(optarg);
break;
case 'd':
- domain = (char *)strdup(argv[i+1]);
+ domain = strdup(optarg);
break;
case 'f':
- fromaddr = (char *)strdup(argv[i+1]);
+ fromaddr = strdup(optarg);
break;
case 'p':
- port = atoi(argv[i+1]);
+ port = atoi(optarg);
break;
case 'l':
- debug_level = atoi(argv[i+1]);
+ debug_level = atoi(optarg);
if(debug_level > 1)
stdlog = fopen("nbsmtp.log", "w");
else
stdlog = stdout;
break;
+ case '?':
default:
print_usage(argv[0]);
+ break;
}
}
+ argc -= optind;
if(domain==NULL || fromaddr==NULL || host==NULL){
print_usage(argv[0]);
- return 1;
}
if(port==0)
|