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

FreeBSD Manual Pages

  
 
  

home | help
KVALID_STRING(3)	     Library Functions Manual		KVALID_STRING(3)

NAME
     kvalid_bit,    kvalid_date,    kvalid_double,   kvalid_email,   kvalid_int,
     kvalid_string, kvalid_stringne, kvalid_udouble, kvalid_uint  --  predefined
     validation functions for kcgi

LIBRARY
     libkcgi

SYNOPSIS
     #include <sys/types.h>
     #include <stdarg.h>
     #include <stdint.h>
     #include <kcgi.h>

     int
     kvalid_bit(struct kpair *kp);

     int
     kvalid_date(struct kpair *kp);

     int
     kvalid_double(struct kpair *kp);

     int
     kvalid_email(struct kpair *kp);

     int
     kvalid_int(struct kpair *kp);

     int
     kvalid_string(struct kpair *kp);

     int
     kvalid_stringne(struct kpair *kp);

     int
     kvalid_udouble(struct kpair *kp);

     int
     kvalid_uint(struct kpair *kp);

DESCRIPTION
     The  predefined  kcgi(3)  validation functions check kp->val and kp->valsz.
     On successful validation, the appropriate kp->parsed field is  set  to  the
     validated	value  and its type stored in kp->type.  These functions are de-
     signed for  use  in  the  valid  field  of  struct  kvalid,  documented  in
     khttp_parse(3).

     The validation functions perform the following validations:

     kvalid_bit()
	     A	bit number in the range from 1 to 64 (first bit, second bit, and
	     so on) or 0 to indicate no bit.  Sets KPAIR_INTEGER.

     kvalid_date()
	     Converts an ISO 8601 YYYY-MM-DD date to the number of seconds since
	     or before the UNIX Epoch, 1970-01-01.  Dates before  1582	are  not
	     accepted.	 Beyond  syntax, dates are checked for correctness (days
	     in month, leap years, etc.).  Sets KPAIR_INTEGER.

     kvalid_double()
	     A signed double-precision floating-point number in  strtod(3)  for-
	     mat.  Sets KPAIR_DOUBLE.

     kvalid_email()
	     A	loosely-validated e-mail address consisting of at most 254 char-
	     acters, with a user part (at least one character) and a domain part
	     (at least one character).	This will allow many invalid e-mail  ad-
	     dresses,  but  will  not  prevent any otherwise valid ones by over-
	     strict testing.  The validated string is  trimmed	for  white-space
	     and lowercased.  Sets KPAIR_STRING.

     kvalid_int()
	     A 64-bit signed integer.  Sets KPAIR_INTEGER.

     kvalid_string()
	     A	NUL-terminated	string that is allowed to be empty.  The valida-
	     tion fails if  kp->valsz  does  not  match  strlen(kp->val).   Sets
	     KPAIR_STRING.

     kvalid_stringne()
	     The  same	as  kvalid_string()  except that validation fails if the
	     string is empty.

     kvalid_udouble()
	     The same as kvalid_double() except that  validation  fails  if  the
	     number is zero or negative.

     kvalid_uint()
	     The same as kvalid_int() except that validation fails if the number
	     is  negative.  The range does not extend to UINT64_MAX, but is lim-
	     ited to INT64_MAX.

RETURN VALUES
     All validation functions return 1 if validation succeeds or 0 if it fails.

SEE ALSO
     kcgi(3), khttp_fcgi_init(3), khttp_parse(3), kutil_invalidate(3)

AUTHORS
     These functions were written by Kristaps Dzonsons <kristaps@bsd.lv>.

BUGS
     The functions kvalid_double() and kvalid_udouble() might attempt to  access
     locale information, which might fail in a sandbox.

FreeBSD ports 15.quarterly	   $Mdocdate$			KVALID_STRING(3)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=kvalid_string&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>

home | help