GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
sf_cgi(3) FreeBSD Library Functions Manual sf_cgi(3)

params, param, param2, set_cookie, cookie, cookies, html_quote, getlanguageprefs
functions to support CGI programming

url_decode, url_encode

recoding functions

#include <strfunc.h>

char *
param(char *fieldname);

svect *
param2(char *fieldname, int flags);


int
set_cookie(char *name, char *value, char *optDomain, char *optPath, time_t optMaxAge, char *optComment, int optSecure);

char *
cookie(char *name);

svect *
cookies(void);

char *
html_quote(char *);

svect *
getlanguageprefs(void);

URL-encoding and decoding
char *
url_decode(char *str);

char *
url_encode(char *str);

These routines give the user a method of dealing with CGI forms and other related data.

char * param(char *paramName) function used to obtain the form parameters by specifying their names.

svect * param2(char *paramName, int flags) may be required if multiple values are expected. It stores the current result in the internal buffer and other invocations will destroy its contents. Flags used to specify the type of returned values. If flags = 0, param2() will return the decoded values of the parameter specified by paramName. If flags = 1, param2() will return the unmodified (non-decoded) values. If flags = 2, param2() will return the appropriate content types (to use with multipart forms and binary values).

svect * params(void) used to get all the parameter names (keys). Not always applicable, sure.

char * cookie(char *cookieName) and svect * cookies(void) functions are used to obtain the cookie by its name or all cookie names, respectively.

int set_cookie(char *name, char *value, char *optDomain, char *optPath, time_t optMaxAge, char *optComment, int optSecure) is used to set a cookie. Arguments prefixed by 'opt' are optional.

char * html_quote(char *) used to escape some symbols, such as quotation mark, ampersand, left and right angle quotes, and others. This function can be used to safe include any text to the html document.

svect * getlanguageprefs() returns a pointer to an internal svect structure containing the array of user-preferred languages (from HTTP_ACCEPT_LANGUAGE ). If this information is not available, it returns NULL.

char * url_decode(char *) and url_encode(char *) are used to deal with url-encoded strings.

void cgiparse() {
	char *login, pwd, oldpwd;

	login = param("login");
	pwd = param("password");
	oldpwd = param("oldpassword");

	if(!login || !pwd || !oldpwd) {
		printf("One or more parameters are missing.\n");
		return;
	};

	/* ... some job ... */

	/* This will produce the following output:
	 * "John Smith &lt;john@smith.com&gt;\n"
	 */
	printf("%s\n", html_quote("John Smith <john@smith.com>") );

};

strfunc(3), svect(3), replace(3), limittextwidth(3).

Lev Walkin <vlm@lionet.info>
October 1, 2000 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.