-Version 0.5
+Version 0.5,
. Added proper install target to main Makefile
. Corrected multiple fields code
. Reworked offline parser, thanks to Mikko
. Improved test suite
+ . Added cgiGetVariables() to return a list of all variables
. Fixed problem with name being a prefix of another
. Also decode HTTP strings for multiple fields
. Added cgiSetType() and cgiSetHeader() with documentation
. Added cgiFree() to free internal datastructures
. Internal reorganization
. CAUTION: s_cgi **cgi is now s_cgi *cgi in programs
+ . Added cgiFreeList() to free zero terminated lists of arrays
+Version 0.4, 1998/03/20
+ . Initial and fixed versions.
+ . Corrected html code in redirection
+ . Corrected number of bytes in redirection
-Version 0.4
+Version 0.3, 1998/02/23
- . Initial and fixed versions.
- . For details refer to debian/changelog
+ . Fixed little mistake in offline mode
+ . Included another example, jumpto
+
+Version 0.2, 1998/02/18
+
+ . Corrected debugging
+ . Added cgiRedirect()
+ . Added cgiRedirect(3) manpage
+ . Added call to cgiRedirect() to example cgitest.c
+ . Added compile notice to cgitest.c
+ . Added support for the GET method
+ . Reorganized POST/GET/stdin support
+ . Implemented support for multiple fields and updated manpage
+
+Version 0.1, 1998/02/15
+ . Initial version
+ . DFSG Free CGI library
+ . Very small package
+ . Contains all important manpages
This is a list of people who have helped me working on this CGI
library.
+Martin Schulze <joey@infodrom.north.de>
+ - Design, Implementation, Maintenance
+
Mikko Torni <mtorni@mail.freenet.hut.fi>
- Cookie support (abandoned though)
-# Copyright (c) 1998,9 Martin Schulze <joey@infodrom.north.de>
+# Copyright (c) 1998,9 by Martin Schulze <joey@infodrom.north.de>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
install -m 755 cgitest /usr/lib/cgi-bin
clean:
- rm -f cgitest cgitest.o jumpto jumpto.o libcgi.a $(OBJS)
+ rm -f cgitest cgitest.o jumpto jumpto.o libcgi.a $(OBJS) *.[35].html
+
+htmlman:
+ for f in *.[35]; do \
+ man -l $$f|rman -f HTML --title $$f -r "%s.%s.html" > $$f.html; \
+ done
}
}
+void cgiFreeList (char **list)
+{
+ int i;
+
+ for (i=0; list[i] != NULL; i++)
+ free (list[i]);
+ free (list);
+}
+
void cgiFree (s_cgi *parms)
{
int i;
/* cgiInit
*
- * Reads in variables set via POST or stdin
+ * Reads in variables set via POST or stdin, reads HTTP Cookies.
*/
s_cgi *cgiInit ();
/* cgiGetCookies
*
- * Returns the name of all cookies.
+ * Returns a list of name of all cookies.
*/
char **cgiGetCookies (s_cgi *parms);
+/* cgiFreeList
+ *
+ * Frees a list as returned by cgiGetVariables() and cgiGetCookies()
+ */
+void cgiFreeList (char **list);
+
/* cgiFree
*
* Frees the internal data structures
--- /dev/null
+.\" cgiFreeList - Frees memory used by a list
+.\" Copyright (c) 1999 by Martin Schulze <joey@infodrom.north.de>
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program; if not, write to the Free Software
+.\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+.\"
+.TH cgiFreeList 3 "20 August 1999" "CGI Library" "Programmer's Manual"
+.SH NAME
+cgiFreeList \- Frees memory used by a list
+.SH SYNOPSYS
+.nf
+.B #include <cgi.h>
+.sp
+.BI "void cgiFreeList (char **" list );
+.fi
+.SH DESCRIPTION
+A zero terminated list of characters is returned by the routines
+.BR cgiGetVariables (3)
+and
+.BR cgiGetCookies (3).
+This routine frees memory allocated by these routines.
+
+.SH "AUTHOR"
+This CGI library is written by Martin Schulze
+<joey@infodrom.north.de>. If you have additions or improvements
+please get in touch with him.
+
+.SH "SEE ALSO"
+.BR cgiGetVariables (3),
+.BR cgiGetCookies (3).
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
.\"
-.TH cgiGetCookie 3 "17 August 1999" "CGI Library" "Programmer's Manual"
+.TH cgiGetCookie 3 "20 August 1999" "CGI Library" "Programmer's Manual"
.SH NAME
cgiGetCookie \- Return a cookie
.SH SYNOPSYS
You must NOT free this structure since it is only a pointer to
internal data.
+To set a cookie in your program you'll need to manually add additional
+header lines. Please take a look at
+.IR cgitest.c .
+Basically, you'll need to add the following code:
+
+.nf
+ cgiSetHeader ("Set-Cookie", "Version=1; name=value; Path=/");
+ cgiHeader();
+.fi
+
+Please read the included file
+.I cookies.txt
+as well.
+
.SH "RETURN VALUE"
On success a pointer to a s_cookie structure is returned. If no
cookie was set or no cookie with a given name exists NULL is returned.
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
.\"
-.TH cgiGetCookies 3 "17 August 1999" "CGI Library" "Programmer's Manual"
+.TH cgiGetCookies 3 "20 August 1999" "CGI Library" "Programmer's Manual"
.SH NAME
cgiGetCookies \- Returns a list of cookies
.SH SYNOPSYS
transmitted by the client. To get the value of a cookie you'll have
to use
.BR cgiGetCookie (3).
-
-You have to free the array on your own. You can use the
-following code fragment:
-.nf
- char **vars;
- int i;
- s_cgi *cgi;
-
- cgi = cgiInit();
-
- vars = cgiGetCookies (cgi);
- if (!vars)
- return;
-
- for (i=0; vars[i] != NULL; i++)
- free (vars[i]);
-
- free (vars);
-.fi
+To free the allocated memory, use
+.BR cgiFreeList (3).
.SH "RETURN VALUE"
On success a NULL terminated array of strings is returned. The last
.BR cgiGetValue (3),
.BR cgiGetVariables (3),
.BR cgiGetCookie (3),
+.BR cgiFreeList (3),
.BR cgiDebug (3),
.BR cgiHeader (3),
.BR cgiInit (3).
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
.\"
-.TH cgiGetVariables 3 "17 August 1999" "CGI Library" "Programmer's Manual"
+.TH cgiGetVariables 3 "20 August 1999" "CGI Library" "Programmer's Manual"
.SH NAME
cgiGetVariables \- Returns a list of CGI variables
.SH SYNOPSYS
This routine returns a NULL terminated array of CGI variables that are
available. To get the value of a variable you'll have to use
.BR cgiGetValue (3).
-
-You have to free the array on your own. You can use the
-following code fragment:
-.nf
- char **vars;
- int i;
- s_cgi *cgi;
-
- cgi = cgiInit();
-
- vars = cgiGetVariables (cgi);
- if (!vars)
- return;
-
- for (i=0; vars[i] != NULL; i++)
- free (vars[i]);
-
- free (vars);
-.fi
+To free the memory allocated use
+.BR cgiFreeList (3).
.SH "RETURN VALUE"
On success a NULL terminated array of strings is returned. The last
.BR cgiGetValue (3),
.BR cgiGetCookie (3),
.BR cgiGetCookies (3),
+.BR cgiFreeList (3),
.BR cgiDebug (3),
.BR cgiHeader (3),
.BR cgiInit (3).
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
.\"
-.TH cgiSetHeader 3 "15 August 1999" "CGI Library" "Programmer's Manual"
+.TH cgiSetHeader 3 "20 August 1999" "CGI Library" "Programmer's Manual"
.SH NAME
cgiSetHeader \- Specify an additional HTTP header
.SH SYNOPSYS
.I value
must not contain any newline, otherwise it will be truncated as well.
+To set a cookie in your program you'll need to manually add additional
+header lines. Please take a look at
+.IR cgitest.c .
+Basically, you'll need to add the following code:
+
+.nf
+ cgiSetHeader ("Set-Cookie", "Version=1; name=value; Path=/");
+ cgiHeader();
+.fi
+
+Please read the included file
+.I cookies.txt
+as well.
+
.SH "RETURN VALUE"
On success 1 is returned, otherwise 0.
.SH "SEE ALSO"
.BR cgiHeader (3),
+.BR cgiGetCookies (3),
+.BR cgiGetCookie (3),
.BR cgiInit (3).
#include <stdio.h>
#include <cgi.h>
-s_cgi **cgiArg;
+s_cgi *cgiArg;
void main()
{