Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
sf_cgi(3)		 BSD Library Functions Manual		     sf_cgi(3)

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

     url_decode, url_encode -- recoding	functions

SYNOPSIS
     #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);

DESCRIPTION
     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 de-
     coded 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 al-
     ways 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 struc-
     ture 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.

EXAMPLE
     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>") );

     };

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

AUTHORS
     Lev Walkin	<vlm@lionet.info>

BSD				October	1, 2000				   BSD

NAME | SYNOPSIS | DESCRIPTION | EXAMPLE | SEE ALSO | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=param&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help