cgi.h Source File

Main Page Modules File List

# cgi.h

    00001 /*
    00002     LibCGI - A library to make CGI programs using C
    00003     Copyright (C) 2001 Rafael Steil
    00004
    00005     This library is free software; you can redistribute it and/or
    00006     modify it under the terms of the GNU Lesser General Public
    00007     License as published by the Free Software Foundation; either
    00008     version 2.1 of the License, or (at your option) any later version.
    00009
    00010     This library is distributed in the hope that it will be useful,
    00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013     Lesser General Public License for more details.
    00014
    00015     You should have received a copy of the GNU Lesser General Public
    00016     License along with this library; if not, write to the Free Software
    00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018
    00019     You can contact the author by e-mail: rafael@insanecorp.com
    00020 */
    00021 #ifndef _CGI_H
    00022 #define _CGI_H  1
    00023
    00024 #ifdef __cplusplus
    00025 extern "C" {
    00026 #endif
    00027
    00028
    00029 // general purpose linked list. Actualy isn't very portable
    00030 // because uses only 'name' and 'value' variables to store data.
    00031 // Problably, in a future release, this will be replaced by
    00032 // another type of struct
    00033 typedef struct formvarsA {
    00034         char *name;
    00035         char *value;
    00036         struct formvarsA *next;
    00037 } formvars;
    00038
    00039 extern formvars *formvars_start;
    00040 extern formvars *formvars_last;
    00041 extern formvars *cookies_start;
    00042 extern formvars *cookies_last;
    00043
    00044 extern int cgi_display_errors;
    00045
    00046 // General purpose cgi functions
    00047 extern void cgi_init_headers();
    00048 extern void cgi_redirect(char *url);
    00049 extern void cgi_fatal(const char *error);
    00050 extern char *cgi_unescape_special_chars(char *str);
    00051 extern char *cgi_espace_special_chars(char *str);
    00052 extern char *cgi_param_multiple(const char *name);
    00053 extern char *htmlentities(const char *str);
    00054 extern int cgi_include(const char *filename);
    00055 extern formvars *cgi_process_form();
    00056 extern int cgi_init();
    00057 extern void cgi_end();
    00058 extern int cgi_send_header(const char *header);
    00059 #define cgi_param(var_name) List_item(var_name, formvars_start)
    00060 #define cgi_send_header(header) printf("%s\n\n", header)
    00061
    00062
    00063 // Cookie functions
    00064 extern int cgi_add_cookie(const char *name, const char *value, const char *max_age, const char *path, const char *domain, const int secure);
    00065 extern formvars *cgi_get_cookies();
    00066 #define cgi_cookie_value(cookie_name) List_item(cookie_name, cookies_start)
    00067
    00068 // General purpose string functions
    00069 extern int strnpos(char *s, char *ch, unsigned int count);
    00070 extern int strpos(char *s, char *ch);
    00071 extern char *strdel(char *s, int start, int count);
    00072 extern char **explode(char *src, const char *token, int *total);
    00073 extern char *substr(char *src, const int start, const int count);
    00074 extern char *stripnslashes(char *s, int n);
    00075 extern char *addnslashes(char *s, int n);
    00076 extern char *stripnslashes(char *s, int n);
    00077 extern char *str_nreplace(char *str, const char *delim, const char *with, int n);
    00078 extern char *str_replace(char *str, const char *delim, const char *with);
    00079 extern char *addslashes(char *str);
    00080 extern char *stripslashes(char *str);
    00081 extern char *str_base64_encode(char *str);
    00082 extern char *str_base64_decode(char *str);
    00083 extern char *recvline(FILE *fp);
    00084
    00085 #if HAVE_MD5
    00086 extern char *md5(const char *str);
    00087 #endif
    00088
    00089 // linked list functions
    00090 extern void List_add(formvars *item, formvars **start, formvars **last);
    00091 extern void List_free(formvars **start);
    00092 extern char *List_item(const char *name, formvars *start);
    00093 extern int List_delete(char *name, formvars **start, formvars **last);
    00094
    00095 #ifdef __cplusplus
    00096 }
    00097 #endif
    00098
    00099 #endif // _CGI_H