ze-filter  (ze-filter-0.8.0-develop-180218)
ze-inet-test.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * ze-filter - Mail Server Filter for sendmail
5  *
6  * Copyright (c) 2001-2018 - Jose-Marcio Martins da Cruz
7  *
8  * Auteur : Jose Marcio Martins da Cruz
9  * jose.marcio.mc@gmail.org
10  *
11  * Historique :
12  * Creation : janvier 2002
13  *
14  * This program is free software, but with restricted license :
15  *
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * More details about ze-filter license can be found at ze-filter
22  * web site : http://foss.jose-marcio.org
23  */
24 
25 #include <ze-sys.h>
26 #include <ze-filter.h>
27 
28 int
29 main(argc, argv)
30  int argc;
31  char **argv;
32 {
33  int res = 0;
34  extern int ze_logLevel;
35 
36  configure("ze-inet-test", conf_file, FALSE);
37 
39  ze_logLevel = 10;
40 
41  {
42  char *ip, *name;
43  int netclass;
44  char class[64];
45 
46  iprbwl_T rbwl;
47 
48  int flag = 0;
49  char *result = NULL;
50  int c;
51 
52  const char *args = "i:h:t:l:v";
53 
54  ip = "0.0.0.0";
55  name = "localhost";
56 
57  while ((c = getopt(argc, argv, args)) != -1) {
58  switch (c) {
59  case 'i':
60  ip = optarg;
61  break;
62  case 'h':
63  name = optarg;
64  break;
65  case 'v':
66  ze_logLevel++;
67  break;
68  case 'l':
69  ze_logLevel = atoi(optarg);
70  break;
71  default:
72  (void) fprintf(stderr, "-> Unknown command line option : %c\n", c);
73  exit(1);
74  }
75  }
76  }
77 
78  {
79  int i;
80 
81  argc--;
82  argv++;
83 
84  for (i = 0; i < argc; i++) {
85  char buf[256];
86 
87  memset(buf, 0, sizeof (buf));
88  if (get_hostbyaddr(argv[i], buf, sizeof (buf))) {
89  ZE_MessageInfo(10, " %3d TONAME : %-30s %s", i, argv[i], buf);
90  }
91  memset(buf, 0, sizeof (buf));
92  if (get_hostbyname(argv[i], buf, sizeof (buf))) {
93  ZE_MessageInfo(10, " %3d TOADDR : %-30s %s", i, argv[i], buf);
94  }
95  }
96  }
97 
98  return 0;
99 }
int main(int argc, char **argv)
Definition: ze-inet-test.c:29
int ze_logLevel
Definition: zeSyslog.c:34
void zeLog_SetOutput(bool, bool)
Definition: zeSyslog.c:490
#define FALSE
Definition: macros.h:160
bool get_hostbyaddr(char *ip, char *name, int len)
Definition: ze-inet.c:323
#define ZE_MessageInfo(level,...)
Definition: zeSyslog.h:90
#define TRUE
Definition: macros.h:157
char * conf_file
Definition: ze-cf.c:38
int configure(char *, char *, bool)
Definition: ze-cf.c:1203
bool get_hostbyname(char *name, char *ip, int len)
Definition: ze-inet.c:336