summaryrefslogtreecommitdiffstats
path: root/iptables-multi.c
blob: 7ade3335ec137e7fcbdbb6989db10350978ed367 (plain)
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libgen.h>

int iptables_main(int argc, char **argv);
int iptables_save_main(int argc, char **argv);
int iptables_restore_main(int argc, char **argv);
int iptables_xml_main(int argc, char **argv);

int main(int argc, char **argv) {
  char *progname;

  if (argc == 0) {
    fprintf(stderr, "no argv[0]?");
    exit(1);
  } else {
    progname = basename(argv[0]);

    if (!strcmp(progname, "iptables"))
      return iptables_main(argc, argv);
    
    if (!strcmp(progname, "iptables-save"))
      return iptables_save_main(argc, argv);
    
    if (!strcmp(progname, "iptables-restore"))
      return iptables_restore_main(argc, argv);
    
    if (!strcmp(progname, "iptables-xml"))
      return iptables_xml_main(argc, argv);
    
    fprintf(stderr, "iptables multi-purpose version: unknown applet name %s\n", progname);
    exit(1);
  }
}