GNU libmicrohttpd  0.9.72
mhd_str.h File Reference
#include "mhd_options.h"
#include <stdint.h>
#include <stdlib.h>
Include dependency graph for mhd_str.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MHD_STATICSTR_LEN_(macro)   (sizeof(macro) / sizeof(char) - 1)
 
#define MHD_str_has_s_token_caseless_(str, tkn)    MHD_str_has_token_caseless_ ((str),(tkn),MHD_STATICSTR_LEN_ (tkn))
 

Functions

int MHD_str_equal_caseless_ (const char *str1, const char *str2)
 
int MHD_str_equal_caseless_n_ (const char *const str1, const char *const str2, size_t maxlen)
 
bool MHD_str_has_token_caseless_ (const char *str, const char *const token, size_t token_len)
 
size_t MHD_str_to_uint64_ (const char *str, uint64_t *out_val)
 
size_t MHD_str_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val)
 
size_t MHD_strx_to_uint32_ (const char *str, uint32_t *out_val)
 
size_t MHD_strx_to_uint32_n_ (const char *str, size_t maxlen, uint32_t *out_val)
 
size_t MHD_strx_to_uint64_ (const char *str, uint64_t *out_val)
 
size_t MHD_strx_to_uint64_n_ (const char *str, size_t maxlen, uint64_t *out_val)
 

Macro Definition Documentation

◆ MHD_STATICSTR_LEN_

#define MHD_STATICSTR_LEN_ (   macro)    (sizeof(macro) / sizeof(char) - 1)

Determine length of static string / macro strings at compile time.

Definition at line 45 of file mhd_str.h.

◆ MHD_str_has_s_token_caseless_

#define MHD_str_has_s_token_caseless_ (   str,
  tkn 
)     MHD_str_has_token_caseless_ ((str),(tkn),MHD_STATICSTR_LEN_ (tkn))

Check whether str has case-insensitive static tkn. Token could be surrounded by spaces and tabs and delimited by comma. Match succeed if substring between start, end of string or comma contains only case-insensitive token and optional spaces and tabs.

Warning
tkn must be static string
Parameters
strthe string to check
tknthe static string of token to find
Returns
non-zero if two strings are equal, zero otherwise.

Definition at line 115 of file mhd_str.h.

Function Documentation

◆ MHD_str_equal_caseless_()

int MHD_str_equal_caseless_ ( const char *  str1,
const char *  str2 
)

Check two string for equality, ignoring case of US-ASCII letters.

Parameters
str1first string to compare
str2second string to compare
Returns
non-zero if two strings are equal, zero otherwise.

Definition at line 346 of file mhd_str.c.

◆ MHD_str_equal_caseless_n_()

int MHD_str_equal_caseless_n_ ( const char *const  str1,
const char *const  str2,
size_t  maxlen 
)

Check two string for equality, ignoring case of US-ASCII letters and checking not more than maxlen characters. Compares up to first terminating null character, but not more than first maxlen characters.

Parameters
str1first string to compare
str2second string to compare
maxlenmaximum number of characters to compare
Returns
non-zero if two strings are equal, zero otherwise.

Definition at line 378 of file mhd_str.c.

◆ MHD_str_has_token_caseless_()

bool MHD_str_has_token_caseless_ ( const char *  str,
const char *const  token,
size_t  token_len 
)

Check whether str has case-insensitive token. Token could be surrounded by spaces and tabs and delimited by comma. Match succeed if substring between start, end of string or comma contains only case-insensitive token and optional spaces and tabs.

Warning
token must not contain null-charters except optional terminating null-character.
Parameters
strthe string to check
tokenthe token to find
token_lenlength of token, not including optional terminating null-character.
Returns
non-zero if two strings are equal, zero otherwise.

Check whether str has case-insensitive token. Token could be surrounded by spaces and tabs and delimited by comma. Match succeed if substring between start, end (of string) or comma contains only case-insensitive token and optional spaces and tabs.

Warning
token must not contain null-charters except optional terminating null-character.
Parameters
strthe string to check
tokenthe token to find
token_lenlength of token, not including optional terminating null-character.
Returns
non-zero if two strings are equal, zero otherwise.

Definition at line 412 of file mhd_str.c.

◆ MHD_str_to_uint64_()

size_t MHD_str_to_uint64_ ( const char *  str,
uint64_t *  out_val 
)

Convert decimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character.

Parameters
strstring to convert
out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Convert decimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character.

Parameters
strstring to convert
[out]out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Definition at line 473 of file mhd_str.c.

◆ MHD_str_to_uint64_n_()

size_t MHD_str_to_uint64_n_ ( const char *  str,
size_t  maxlen,
uint64_t *  out_val 
)

Convert not more then maxlen decimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character or after maxlen digits.

Parameters
strstring to convert
maxlenmaximum number of characters to process
out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Convert not more then maxlen decimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character or after maxlen digits.

Parameters
strstring to convert
maxlenmaximum number of characters to process
[out]out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Definition at line 515 of file mhd_str.c.

◆ MHD_strx_to_uint32_()

size_t MHD_strx_to_uint32_ ( const char *  str,
uint32_t *  out_val 
)

Convert hexadecimal US-ASCII digits in string to number in uint32_t. Conversion stopped at first non-digit character.

Parameters
strstring to convert
out_valpointer to uint32_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint32_t or out_val is NULL

Convert hexadecimal US-ASCII digits in string to number in uint32_t. Conversion stopped at first non-digit character.

Parameters
strstring to convert
[out]out_valpointer to uint32_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint32_t or out_val is NULL

Definition at line 558 of file mhd_str.c.

◆ MHD_strx_to_uint32_n_()

size_t MHD_strx_to_uint32_n_ ( const char *  str,
size_t  maxlen,
uint32_t *  out_val 
)

Convert not more then maxlen hexadecimal US-ASCII digits in string to number in uint32_t. Conversion stopped at first non-digit character or after maxlen digits.

Parameters
strstring to convert
maxlenmaximum number of characters to process
out_valpointer to uint32_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint32_t or out_val is NULL

Convert not more then maxlen hexadecimal US-ASCII digits in string to number in uint32_t. Conversion stopped at first non-digit character or after maxlen digits.

Parameters
strstring to convert
maxlenmaximum number of characters to process
[out]out_valpointer to uint32_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint32_t or out_val is NULL

Definition at line 605 of file mhd_str.c.

◆ MHD_strx_to_uint64_()

size_t MHD_strx_to_uint64_ ( const char *  str,
uint64_t *  out_val 
)

Convert hexadecimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character.

Parameters
strstring to convert
out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Convert hexadecimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character.

Parameters
strstring to convert
[out]out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Definition at line 646 of file mhd_str.c.

◆ MHD_strx_to_uint64_n_()

size_t MHD_strx_to_uint64_n_ ( const char *  str,
size_t  maxlen,
uint64_t *  out_val 
)

Convert not more then maxlen hexadecimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character or after maxlen digits.

Parameters
strstring to convert
maxlenmaximum number of characters to process
out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Convert not more then maxlen hexadecimal US-ASCII digits in string to number in uint64_t. Conversion stopped at first non-digit character or after maxlen digits.

Parameters
strstring to convert
maxlenmaximum number of characters to process
[out]out_valpointer to uint64_t to store result of conversion
Returns
non-zero number of characters processed on succeed, zero if no digit is found, resulting value is larger then possible to store in uint64_t or out_val is NULL

Definition at line 692 of file mhd_str.c.