Querying libiptc HOWTO
Prev |  | Next

# 10. How to create your program(s)

Create your program(s) in `/usr/local/src`; this way you will not have problems with gcc looking for files in the "include" section.

Your program(s) would be something like this:

    /* My program */

    #include <getopt.h>
    #include <sys/errno.h>
    #include <stdio.h>
    #include <fcntl.h>
    #include <stdlib.h>
    #include <string.h>
    #include <dlfcn.h>
    #include <time.h>
    #include "libiptc/libiptc.h"
    #include "iptables.h"

    int main(void)
    {
      /* Use always this part for your programs .... From here ... **** */
      iptc_handle_t h;
      const char *chain = NULL;
      const char *tablename = NULL;

      program_name = "my_program";
      program_version = NETFILTER_VERSION;
      /* .... To here .... ******************************************** */

      /* From here you write your own code */
      .... your code ...
      ....
      ....

    } /* main */

- The "include" section is a must in your c/c++ program(s).

- If you are using c++ do not forget to write extern "C" for these include.

Prev | Home | Next
Installing iptables + libiptc |  | Functions to query libiptc