.TH ustr_const 3 "05-Mar-2008" "Ustr 1.0.4" "Ustr String Library" .SH "NAME" ustr_const \- ustr string library constants .SH "SYNOPSIS" .in \w' 'u #include "ustr.h" .sp .sp .br .ti \w' 'u \fBUSTR_CONF_INCLUDE_CODEONLY_HEADERS\fR .br .ti \w' 'u \fBUSTR_CONF_USE_EOS_MARK\fR .br .ti \w' 'u \fBUSTR_CONF_USE_ASSERT\fR .br .ti \w' 'u \fBUSTR_CONF_COMPILE_USE_ATTRIBUTES\fR .br .ti \w' 'u \fBUSTR_CONF_COMPILE_TYPEDEF\fR .br .ti \w' 'u \fBUSTR_CONF_COMPILE_USE_INLINE\fR .sp .br .ti \w' 'u \fBUSTR_BEG_CONST1\fR .br .ti \w' 'u \fBUSTR_BEG_CONST2\fR .br .ti \w' 'u \fBUSTR_BEG_CONST4\fR .br .ti \w' 'u \fBUSTR_BEG_FIXED1\fR .br .ti \w' 'u \fBUSTR_BEG_FIXED2\fR .br .ti \w' 'u \fBUSTR_BEG_FIXED4\fR .br .ti \w' 'u \fBUSTR_BEG_FIXED8\fR .br .ti \w' 'u \fBUSTR_END_ALOCDx\fR .br .ti \w' 'u \fBUSTR_END_CONSTx\fR .br .ti \w' 'u \fBUSTR_END_FIXEDx\fR .sp .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_DEF\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_SEP\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_OVERFLOW\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_SPACE\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_NO_BEG_ZERO\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_NO_BEG_PM\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_NO_NEGATIVE\fR .br .ti \w' 'u \fBUSTR_FLAG_PARSE_NUM_EXACT\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_NONE\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_ONLY_S\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_ONLY_SPM\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_ONLY_SPMX\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_OOB\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_OVERFLOW\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_NEGATIVE\fR .br .ti \w' 'u \fBUSTR_TYPE_PARSE_NUM_ERR_BEG_ZERO\fR .sp .br .ti \w' 'u \fBUSTR_FLAG_SPLIT_DEF\fR .br .ti \w' 'u \fBUSTR_FLAG_SPLIT_RET_SEP\fR .br .ti \w' 'u \fBUSTR_FLAG_SPLIT_RET_NON\fR .br .ti \w' 'u \fBUSTR_FLAG_SPLIT_KEEP_CONFIG\fR .sp .br .ti \w' 'u \fBUSTR_NULL\fR .br .ti \w' 'u \fBUSTR_POOL_NULL\fR .br .ti \w' 'u \fBUSTR_TRUE\fR .br .ti \w' 'u \fBUSTR_FALSE\fR .sp .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_REF_BYTES\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_REF_BYTES\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_HAS_SIZE\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_HAS_SIZE\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_EXACT_BYTES\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_EXACT_BYTES\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_MEM\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_MEM\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_MC_M_SCRUB\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_MC_M_SCRUB\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_MC_F_SCRUB\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_MC_F_SCRUB\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_MC_R_SCRUB\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_MC_R_SCRUB\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_GET_FMT\fR .br .ti \w' 'u \fBUSTR_CNTL_OPT_SET_FMT\fR .sp .br .ti \w' 'u \fBUSTR_POOL_LL_CNTL_GET_FREE_CMP\fR .br .ti \w' 'u \fBUSTR_POOL_LL_CNTL_SET_FREE_CMP\fR .br .ti \w' 'u \fBUSTR_POOL_LL_CNTL_GET_REALLOC\fR .br .ti \w' 'u \fBUSTR_POOL_LL_CNTL_SET_REALLOC\fR .ti .SH "DESCRIPTION" .SH Compile switch constants .br \fBConstant: \fR USTR_CONF_INCLUDE_CODEONLY_HEADERS .br \fBExplanation:\fR .br This switch controls whether all the code will be included as inline functions. Having this be non\-zero means that you don't have to link against the library. .br \fBConstant: \fR USTR_CONF_USE_EOS_MARK .br \fBExplanation:\fR .br This switch turns on End of String markers, so any bounds overflow will be noticed by ustr_assert_valid(). .sp \fBNote:\fR .br Changing this will not do anything useful unless USTR_CONF_INCLUDE_CODEONLY_HEADERS is non\-zero. .br \fBConstant: \fR USTR_CONF_USE_ASSERT .br \fBExplanation:\fR .br This switch turns USTR_ASSERT() calls on, so the code within them will be evaluated. Note that there are many calls to ustr_assert_valid() within USTR_ASSERT() macros and that call is relatively expensive. .sp \fBNote:\fR .br Changing this will not do anything useful unless USTR_CONF_INCLUDE_CODEONLY_HEADERS is non\-zero. .br \fBConstant: \fR USTR_CONF_COMPILE_USE_ATTRIBUTES .br \fBExplanation:\fR .br This switch controls whether gcc type __attribute__() statements are used in the public headers headers for the library. If the value is 1 then if they are supported by the compiler that built the library they will be used, if the value is 0 they won't be used at all. .br \fBConstant: \fR USTR_CONF_COMPILE_TYPEDEF .br \fBExplanation:\fR .br This switch controls whether typedef will be used for the structs in the public headers for the library. If the value is 1 then they will be used, if the value is 0 they won't be used at all (and your code will have to use struct tags instead \-\- note all libraries using ustr should compile without this option set). .br \fBConstant: \fR USTR_CONF_COMPILE_USE_INLINE .br \fBExplanation:\fR .br This switch controls whether inline functions will be used in a few cases where the function bodies are very small. .sp \fBNote:\fR .br In some cases this is used so that GCC can eliminate calls to strlen(), for the *_cstr() functions. .SH Constants to created fixed/read\-only Ustr's .br \fBConstant: \fR USTR_BEG_CONST1 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a constant/read\-only Ustr that has a length in the range 0\-255. .br \fBConstant: \fR USTR_BEG_CONST2 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a constant/read\-only Ustr that has a length in the range 0\-65535. .br \fBConstant: \fR USTR_BEG_CONST4 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a constant/read\-only Ustr that has a length in the range 0\-4294967295. .br \fBConstant: \fR USTR_BEG_FIXED1 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a fixed Ustr that has a length in the range 0\-255. .br \fBConstant: \fR USTR_BEG_FIXED2 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a fixed Ustr that has a length in the range 0\-65535. .br \fBConstant: \fR USTR_BEG_FIXED4 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a fixed Ustr that has a length in the range 0\-4294967295. .br \fBConstant: \fR USTR_BEG_FIXED8 .br \fBExplanation:\fR .br This macro is a constant C\-style string of the first byte of a fixed Ustr that has a length in the range 0\-18446744073709551615. .sp \fBNote:\fR .br This macro is only available if the Ustr code was compiled in a 64bit environment. .br \fBConstant: \fR USTR_END_ALOCDx .br \fBExplanation:\fR .br This macro is a constant C\-style string of the last bytes of an allocated Ustr. .sp \fBNote:\fR .br Unless USTR_CONF_USE_EOS_MARK is non\-zero, this is just the NIL byte. .br \fBConstant: \fR USTR_END_CONSTx .br \fBExplanation:\fR .br This macro is a constant C\-style string of the last bytes of a constant/read\-only Ustr. .sp \fBNote:\fR .br Unless USTR_CONF_USE_EOS_MARK is non\-zero, this is just the NIL byte. .br \fBConstant: \fR USTR_END_FIXEDx .br \fBExplanation:\fR .br This macro is a constant C\-style string of the last bytes of a fixed Ustr. .sp \fBNote:\fR .br Unless USTR_CONF_USE_EOS_MARK is non\-zero, this is just the NIL byte. .SH Constants to use with parsing numbers: ustr_parse_uintmaxx, etc. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_DEF .br \fBExplanation:\fR .br Default flags, this is merely 0 but can be used as live documentation. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_SEP .br \fBExplanation:\fR .br This flag allows the parsing (and ignoring) of the separator character, at arbitrary pointers in the number, so "1234" and "1_234" would both parse the same (assuming "_" is the separator). .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_OVERFLOW .br \fBExplanation:\fR .br This flag turns on the overflow checking, in other words without it USTR_TYPE_PARSE_NUM_ERR_OVERFLOW will never be returned as an error code. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_SPACE .br \fBExplanation:\fR .br This flag allows one or more ' ' (Space) characters before the number or number prefix (Plus Sign, Hyphen). .sp \fBNote:\fR .br Other forms of whitespace don't count, this just affects ' '. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_NO_BEG_ZERO .br \fBExplanation:\fR .br This flag disallows one or more '0' (Digit Zero) characters before the number. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_NO_BEG_PM .br \fBExplanation:\fR .br This flag disallows a plus or a minus character before the number. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_NO_NEGATIVE .br \fBExplanation:\fR .br This flag disallows negative values. .br \fBConstant: \fR USTR_FLAG_PARSE_NUM_EXACT .br \fBExplanation:\fR .br This flag makes the parsing functions return an error if the entire string doesn't contain the number being parsed. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_NONE .br \fBExplanation:\fR .br This error code has the value 0, and means that no error occurred parsing the number. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_ONLY_S .br \fBExplanation:\fR .br This error code means that the Ustr string consisted only of spaces. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_ONLY_SPM .br \fBExplanation:\fR .br This error code means that the Ustr string consisted only spaces, and a plus or minus sign. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_ONLY_SPMX .br \fBExplanation:\fR .br This error code means that the Ustr string consisted of only spaces, a plus or minus sign and a "0x" base 16 prefix. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_OOB .br \fBExplanation:\fR .br This error code means that the Ustr string had characters in it that where out of bounds from the working base. .sp \fBNote:\fR .br Without the USTR_FLAG_PARSE_NUM_EXACT, this error is ignored as soon as any number is parsed. .br This out of bounds includes the Ustr string "++" as well as "4A", when parsing in a base less than 11. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_OVERFLOW .br \fBExplanation:\fR .br This error code means that the number parsed from the Ustr string would overflow the type it is being parsed into, this is only returned when the USTR_FLAG_PARSE_NUM_OVERFLOW flag was passed to the parse function. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_NEGATIVE .br \fBExplanation:\fR .br This error code means that the number parsed from the Vstr string starts with a '\-' (Hyphen) character when it is supposed to be an unsigned number. .br \fBConstant: \fR USTR_TYPE_PARSE_NUM_ERR_BEG_ZERO .br \fBExplanation:\fR .br This error code means that the number parsed from the Vstr string starts with a '0' (Digit Zero) character, when the USTR_FLAG_PARSE_NUM_NO_BEG_ZERO flag was passed to the parse function. .SH Constants to pass to ustr_split* .br \fBConstant: \fR USTR_FLAG_SPLIT_DEF .br \fBExplanation:\fR .br Default flags, this is merely 0 but can be used as live documentation. .br \fBConstant: \fR USTR_FLAG_SPLIT_RET_SEP .br \fBExplanation:\fR .br Return the separator along with the tokens. For example splitting "a,b," using separator "," will return the tokens "a," and "b," whereas without this flag only "a" and "b" would be returned. .br .br \fBConstant: \fR USTR_FLAG_SPLIT_RET_NON .br \fBExplanation:\fR .br Return empty tokens. For example: splitting "a,,b" with separator "," will return the tokens {"a" "" "b"}. .br \fBConstant: \fR USTR_FLAG_SPLIT_KEEP_CONFIG .br \fBExplanation:\fR .br Force the returned Ustr's to have same configuration parameters as the Ustr string that is being split. .SH Misc constants to use in code .br \fBConstant: \fR USTR_NULL .br \fBExplanation:\fR .br This macro is merely 0 cast to (struct Ustr *), and can be used anywhere NULL would be but "returns" the correct type. .br \fBConstant: \fR USTR_POOL_NULL .br \fBExplanation:\fR .br This macro is merely 0 cast to (struct Ustr_pool *), and can be used anywhere NULL would be but "returns" the correct type. .br \fBConstant: \fR USTR_TRUE .br \fBExplanation:\fR .br This macro is 1, but shows the intent that a boolean value is expected and not a number. .br \fBConstant: \fR USTR_FALSE .br \fBExplanation:\fR .br This macro is 0, but shows the intent that a boolean value is expected and not a number. .SH Constants passed to ustr_cntl_opt() .br \fBConstant: \fR USTR_CNTL_OPT_GET_REF_BYTES .br Parameter\fB[1]\fR: Number of bytes for default reference count in Ustr .br Type\fB[1]\fR: size_t * .br \fBExplanation:\fR .br This option will get the default number of bytes used for a reference count when creating Ustr's. .br \fBConstant: \fR USTR_CNTL_OPT_SET_REF_BYTES .br Parameter\fB[1]\fR: Number of bytes for default reference count in Ustr .br Type\fB[1]\fR: size_t .br \fBExplanation:\fR .br This option will set the default number of bytes used for a reference count when creating Ustr's. .sp \fBNote:\fR .br For a single instance, the ustr_dupx_*() functions can be used. .br \fBConstant: \fR USTR_CNTL_OPT_GET_HAS_SIZE .br Parameter\fB[1]\fR: Default flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int * .br \fBExplanation:\fR .br This option will get the default flag for whether to store an explicit size in created Ustr's. .br \fBConstant: \fR USTR_CNTL_OPT_SET_HAS_SIZE .br Parameter\fB[1]\fR: Default flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This option will set the default flag for whether to store an explicit size in created Ustr's. .sp \fBNote:\fR .br For a single instance, the ustr_dupx_*() functions can be used. .br \fBConstant: \fR USTR_CNTL_OPT_GET_EXACT_BYTES .br Parameter\fB[1]\fR: Default flag for whether to exactly allocate memory .br Type\fB[1]\fR: int * .br \fBExplanation:\fR .br This option will get the default flag for whether to exactly allocate memory when a Ustr needs to be resized. .br \fBConstant: \fR USTR_CNTL_OPT_SET_EXACT_BYTES .br Parameter\fB[1]\fR: Default flag for whether to exactly allocate memory .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This option will set the default flag for whether to exactly allocate memory when a Ustr needs to be resized. .sp \fBNote:\fR .br For a single instance, the ustr_dupx_*() functions can be used. .br \fBConstant: \fR USTR_CNTL_OPT_GET_MEM .br Parameter\fB[1]\fR: Pointer to colleciton of function pointers for system allocation .br Type\fB[1]\fR: struct Ustr_cntl_mem * .br \fBExplanation:\fR .br This option will get the "system" allocation functions (malloc, realloc, free) for allocated Ustr's. .sp \fBNote:\fR .br As you would expect the default values are: malloc, realloc, free. .br \fBConstant: \fR USTR_CNTL_OPT_SET_MEM .br Parameter\fB[1]\fR: Pointer to colleciton of function pointers for system allocation .br Type\fB[1]\fR: const struct Ustr_cntl_mem * .br \fBExplanation:\fR .br This option will set the "system" allocation functions (malloc, realloc, free) for allocated Ustr's. .sp \fBNote:\fR .br If this option is set after a Ustr has been created, then when freeing or reallocating the existing Ustr the given functions will be used. So they must either be compatible with the default or you must ensure that nothing is allocated before they are set. .br \fBConstant: \fR USTR_CNTL_OPT_GET_MC_M_SCRUB .br Parameter\fB[1]\fR: Flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int * .br \fBExplanation:\fR .br This option will get the flag for whether to "scrub" data allocated via. malloc check. .sp \fBNote:\fR .br Malloc check has to be enabled for this to mean anything, Ie. USTR_CNTL_MALLOC_LVL() must be positive. .br \fBConstant: \fR USTR_CNTL_OPT_SET_MC_M_SCRUB .br Parameter\fB[1]\fR: Flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This option will set the flag for whether to "scrub" data allocated via. malloc check. .sp \fBNote:\fR .br Malloc check has to be enabled for this to mean anything, Ie. USTR_CNTL_MALLOC_LVL() must be positive. .br \fBConstant: \fR USTR_CNTL_OPT_GET_MC_F_SCRUB .br Parameter\fB[1]\fR: Flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int * .br \fBExplanation:\fR .br This option will get the flag for whether to "scrub" data freed via. malloc check. .sp \fBNote:\fR .br Malloc check has to be enabled for this to mean anything, Ie. USTR_CNTL_MALLOC_LVL() must be positive. .br \fBConstant: \fR USTR_CNTL_OPT_SET_MC_F_SCRUB .br Parameter\fB[1]\fR: Flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This option will set the flag for whether to "scrub" data freed via. malloc check. .sp \fBNote:\fR .br Malloc check has to be enabled for this to mean anything, Ie. USTR_CNTL_MALLOC_LVL() must be positive. .br \fBConstant: \fR USTR_CNTL_OPT_GET_MC_R_SCRUB .br Parameter\fB[1]\fR: Flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int * .br \fBExplanation:\fR .br This option will get the flag for whether to "scrub" data reallocated via. malloc check. This is done by turning all reallocations into a malloc() and free(), and so is even more costly than normal scrubbing. .sp \fBNote:\fR .br Malloc check has to be enabled for this to mean anything, Ie. USTR_CNTL_MALLOC_LVL() must be positive. .br \fBConstant: \fR USTR_CNTL_OPT_SET_MC_R_SCRUB .br Parameter\fB[1]\fR: Flag for whether to include an explicit size in a Ustr .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This option will set the flag for whether to "scrub" data reallocated via. malloc check. This is done by turning all reallocations into a malloc() and free(), and so is even more costly than normal scrubbing. .sp \fBNote:\fR .br Malloc check has to be enabled for this to mean anything, Ie. USTR_CNTL_MALLOC_LVL() must be positive. .br \fBConstant: \fR USTR_CNTL_OPT_GET_FMT .br Parameter\fB[1]\fR: Pointer to colleciton of function pointers for system formatting .br Type\fB[1]\fR: struct Ustr_cntl_fmt * .br \fBExplanation:\fR .br This option will get the system formatting functions (vsnprintf) for Ustr's. .br There are two functions, the first is always called and the second is likely called (always with the exact same arguments) if the length passed to the first call was not big enough. .sp \fBNote:\fR .br As you would expect the default values are: vsnprintf and vsnprintf .br \fBConstant: \fR USTR_CNTL_OPT_SET_FMT .br Parameter\fB[1]\fR: Pointer to colleciton of function pointers for system formatting .br Type\fB[1]\fR: const struct Ustr_cntl_fmt * .br \fBExplanation:\fR .br This option will set the system formatting functions (vsnprintf) for Ustr's. .SH Constants passed to ustr_pool_ll_cntl() .br \fBConstant: \fR USTR_POOL_LL_CNTL_GET_FREE_CMP .br Parameter\fB[1]\fR: Number of pointers to compare to in the pool .br Type\fB[1]\fR: unsigned int * .br \fBExplanation:\fR .br This option will get the number of comparisons done on a pool free operation. .br \fBConstant: \fR USTR_POOL_LL_CNTL_SET_FREE_CMP .br Parameter\fB[1]\fR: Number of pointers to compare to in the pool .br Type\fB[1]\fR: unsigned int .br \fBExplanation:\fR .br This option will set the number of comparisons done on a pool free operation. .sp \fBNote:\fR .br The default is a small non\-zero value, as it's significantly common to have very short lived ustr's ... however this doesn't mean that you can't forget to take references even with pool allocated ustrs. .br \fBConstant: \fR USTR_POOL_LL_CNTL_GET_REALLOC .br Parameter\fB[1]\fR: Flag for if we should call realloc() .br Type\fB[1]\fR: int * .br \fBExplanation:\fR .br This option will get the flag for if we call realloc() to make data bigger, or revert to just allocating anew each time. .br \fBConstant: \fR USTR_POOL_LL_CNTL_SET_REALLOC .br Parameter\fB[1]\fR: Flag for if we should call realloc() .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This option will set the flag for if we call realloc() to make data bigger, or revert to just allocating anew each time. .sp \fBNote:\fR .br As with USTR_POOL_LL_CNTL_SET_FREE_CMP this option means you can't assume that pool allocated data is never freed until ustr_pool_free() is called, and again it is due to there being significant speed improvements for not making that assumption. Instead of disabling this option, just take areference (which will also make sure the ustr isn't modified behind your back). .SH "SEE ALSO" .BR ustr (3)