old-www/HOWTO/Querying-libiptc-HOWTO/howtoprg.html

208 lines
3.0 KiB
HTML

<HTML
><HEAD
><TITLE
>How to create your program(s)</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="Querying libiptc HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Installing iptables + libiptc"
HREF="install.html"><LINK
REL="NEXT"
TITLE="Functions to query libiptc"
HREF="qfunction.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Querying libiptc HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="install.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="qfunction.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="HOWTOPRG">10. How to create your program(s)</H1
><P
>Create your program(s) in <TT
CLASS="FILENAME"
>/usr/local/src</TT
>;
this way you will not have problems with gcc looking for files in the "include" section.</P
><P
>Your program(s) would be something like this:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>/* My program */
#include &#60;getopt.h&#62;
#include &#60;sys/errno.h&#62;
#include &#60;stdio.h&#62;
#include &#60;fcntl.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;string.h&#62;
#include &#60;dlfcn.h&#62;
#include &#60;time.h&#62;
#include "libiptc/libiptc.h"
#include "iptables.h"
int main(void)
{
<EM
> /* Use always this part for your programs .... From here ... **** */</EM
>
iptc_handle_t h;
const char *chain = NULL;
const char *tablename = NULL;
program_name = "my_program";
program_version = NETFILTER_VERSION;
<EM
> /* .... To here .... ******************************************** */</EM
>
<EM
> /* From here you write your own code */</EM
>
.... your code ...
....
....
} /* main */</PRE
></FONT
></TD
></TR
></TABLE
><P
></P
><UL
><LI
><P
>The "include" section is <EM
>a must</EM
> in your c/c++ program(s).</P
></LI
><LI
><P
>If you are using c++ do not forget to write extern "C" for
these include.</P
></LI
></UL
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="install.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="qfunction.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Installing iptables + libiptc</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Functions to query libiptc</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>