ARPA2 Common Libraries
2.6.2
|
Functions | |
bool | access_parse (char *userstr, access_rights *accumulator) |
Parse a string of Access Rights flags. More... | |
void | access_format (const char *opt_fmtstr, access_rights rights, char *outstr) |
Format Access Rights flags to a string. More... | |
static void | access_init (void) |
Initialise the ARPA2 Access system. More... | |
static void | access_fini (void) |
Finalise the ARPA2 Access system. More... | |
const char * | access_host2domain (const char *fqdn_hostname) |
Lookup the realm for a fully qualified host name. More... | |
Access defines some general functions.
|
inlinestatic |
Finalise the ARPA2 Access system.
This may do cleanup operations.
void access_format | ( | const char * | opt_fmtstr, |
access_rights | rights, | ||
char * | outstr | ||
) |
Format Access Rights flags to a string.
This prints to outstr the characters of opt_fmtstr if provided, or otherwise up to 26 characters for a trailing NUL character. The buffer to hold outstr must be large enough.
This function does not fail.
[in] | opt_fmtstr | holds uppercase letters and any other content that should appear in the outstr. Uppercase characters are skipped when the corresponding flag in rights is clear. Other characters are always added. When this parameter is NULL, all the flags are tried in alphabetic order, but no '' or other character is prefixed. |
[in] | rights | holds the access rights to filter which uppercase characters from the opt_fmtstr are added to the outstr. |
[out] | outstr | is a buffer for the formatted output, and it must be large enough to hold the resulting string and a trailing NUL. This means that it should be at least one character longer than the string length of opt_fmtstr or, if that is absent, a buffer size of 27. |
const char* access_host2domain | ( | const char * | fqdn_hostname | ) |
Lookup the realm for a fully qualified host name.
The realm is often a trailer of the hostname, though local conventions may differ; a domain may be used as a hostname, and shared servers may not even show overlap with the domain. The mechanisms for determining this may involve DNS records (with DNSSEC security) or a configuration database, or merely a textual mapping.
This function is used by protocols that communicate host names instead of domain names. A typical example is HTTP. On such systems, aliases must not interfere with the specified host names; the best chance for that is to not lookup the client-sent host name, but the configured canonical host name (web servers tend to have a canonical ServerName and additionally allow ServerAlias names that are also recognised as Host: header).
This function returns NULL if no realm could be found for the supplied host name.
|
inlinestatic |
Initialise the ARPA2 Access system.
This has a mirror image for cleaup in access_fini().
bool access_parse | ( | char * | userstr, |
access_rights * | accumulator | ||
) |
Parse a string of Access Rights flags.
Flags are uppercase letters, and assigned or set and cleared in the accumulator, depending on characters in the string. The parser can handle user input safely, returning an error and making no changes in case of syntax problems.
[in] | flagstr | is the string of flags. It consists of uppercase flag characters, prefixed with instructions to set flags after '+', to clear flags after '-' or to start from zero after '='. The character '' is not required but will be silently ignored. Instructions are processed in their order of appearance and the default mode is '+', so you "RW-CD" is a legal string. |
[in,out] | accumulator | collects the flags, and must be initialised before starting, to be safe in situations where the flagstr contains no '=' instruction. |