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
KVALID_STRING(3) FreeBSD Library Functions Manual KVALID_STRING(3)

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”

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

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 designed 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) format. Sets KPAIR_DOUBLE.
kvalid_email()
A loosely-validated e-mail address consisting of at most 254 characters, with a user part (at least one character) and a domain part (at least one character). This will allow many invalid e-mail addresses, 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 validation 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 limited to INT64_MAX.

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

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

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

The functions kvalid_double() and kvalid_udouble() might attempt to access locale information, which might fail in a sandbox.
June 12, 2022 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.