1CGI manipulation(3)        Library Functions Manual        CGI manipulation(3)
2
3
4

NAME

6       CGI manipulation -
7
8   Functions
9       formvars * cgi_process_form ()
10           Process HTML form or URL data.
11       void cgi_fatal (const char *msg)
12           Kills the application with a message.
13       int cgi_include (const char *filename)
14           Include static files.
15       void cgi_init_headers ()
16           Initialize HTML headers.
17       char * cgi_param_multiple (const char *name)
18           Return all values with the same name sent by a form.
19       void cgi_redirect (char *url)
20           Recirects to the specified url.
21       int cgi_init ()
22           Main cgi function.
23       void cgi_end ()
24           Performs cgi clean ups.
25       char * cgi_unescape_special_chars (char *str)
26           Transforms' URL special chars.
27       char * cgi_escape_special_chars (char *str)
28           Transforms' special characters into hexadecimal form ( %E1 ).
29       char * cgi_param (const char *var_name)
30           Gets the of HTML or URL variable indicated by 'name'.
31       void cgi_send_header (const char *header)
32           Sends a specific header.
33

Function Documentation

35   void cgi_end ()
36       Performs cgi clean ups.Provides some methods to clean memory or any
37       other job that need to be done before the end of the application.
38
39       See also:
40           cgi_init
41
42   char* cgi_escape_special_chars (char * str)
43       Transforms' special characters into hexadecimal form ( %E1
44       ).Parameters:
45           str String to parse
46
47       Returns:
48           The new string
49
50       See also:
51           cgi_unescape_special_chars
52
53   void cgi_fatal (const char * msg)
54       Kills the application with a message.Writes msg and terminate
55
56       Parameters:
57           msg Message to send to the browser before killing
58
59   int cgi_include (const char * filename)
60       Include static files.Function used to include static data ( normaly
61       html files ). File contents will never be processed. Note that I don't
62       scan for any special character. The reason I did it is, if the you are
63       using this library, you have a shell where you can compile the cgi
64       program. And can do much more ;-)
65
66       Parameters:
67           filename Filename with full path to include
68
69       Returns:
70           If an error occurs and libcgi_debug is true, then a warning message
71           is showed.
72
73       See also:
74           libcgi_debug
75
76        cgi_include('top_bar.htm');
77
78
79   int cgi_init ()
80       Main cgi function.Configures all (most?) we need to get cgi library
81       working correctly. It MUST be called before any other cgi function.
82
83       See also:
84           cgi_end, cgi_process_form, cgi_init_headers
85
86   void cgi_init_headers ()
87       Initialize HTML headers.You need to call this function before that any
88       content is send to the brosert, otherwise you'll get an error (Error
89       500).
90
91       See also:
92           cgi_init
93
94   char* cgi_param (const char * var_name)
95       Gets the of HTML or URL variable indicated by 'name'.Parameters:
96           name Form Variable name
97
98       See also:
99           cgi_param_multiple, cgi_process_form, cgi_init
100
101        // ...
102        char *contents;
103
104        cgi_init();
105        cgi_process_form();
106        cgi_init_headers();
107
108        contents = cgi_param('foo');
109
110        puts(contents);
111
112        // ...
113
114
115   char* cgi_param_multiple (const char * name)
116       Return all values with the same name sent by a form.Parameters:
117           name Form variable name
118
119       Returns:
120           Form variable contents
121
122       See also:
123           cgi_param
124
125       Example: For example, if in your HTML you have something like
126
127
128
129        'What do you like??'
130
131         Computers : <input type='checkbox' name='like' value='computers'><br>
132         Internet : <input type='checkbox' name='like' value='net'><br>
133         games : <input type='checkbox' name='like' 'value='games''><br>
134
135
136        then, to retrieve all values, you can make a code like
137
138
139        // ...
140        char *data;
141        \ ...
142        while ((data = cgi_param_multiple('like')) != NULL)
143               puts(data);
144        \ ...
145
146
147   formvars* cgi_process_form ()
148       Process HTML form or URL data.Used to retrieve GET or POST data. It
149       handles automaticaly the correct REQUEST_METHOD, so you don't need to
150       afraid about it.
151
152       Returns:
153           Returns the contents of URL or FORM into a formvars variable, or
154           NULL if FALSE. Most of time, you don't need any variable to store
155           the form data, because is used an internal variable to manipulate
156           the contents.
157
158       See also:
159           cgi_init, cgi_init_headers
160
161   void cgi_redirect (char * url)
162       Recirects to the specified url.Remember that you cannot send any header
163       before this function, or it will not work. Note:
164        LibCGI does not implement RFC 2396 to make the lib simple and quick.
165       You should be sure to pass a correct URI to this function.
166
167       Parameters:
168           url url to redirect the browser
169
170        cgi_redirect('http://wwww.linux.org');
171
172
173   void cgi_send_header (const char * header)
174       Sends a specific header.Sends a specific HTTP header. You won't need to
175       add '\n\n' chars.
176
177       Parameters:
178           header HTTP header to send, without new line characteres
179
180       Returns:
181           True
182
183       See also:
184           cgi_init_headers
185
186   char* cgi_unescape_special_chars (char * str)
187       Transforms' URL special chars.Search for special chars ( like %E1 ) in
188       str, converting them to the ascii character correspondent.
189
190       Parameters:
191           str String containing data to parse
192
193       Returns:
194           The new string
195
196       See also:
197           cgi_escape_special_chars
198
199LibCGI                            13 Mar 2003              CGI manipulation(3)
Impressum