.TH ustr 3 "05-Mar-2008" "Ustr 1.0.4" "Ustr String Library" .SH "NAME" ustr \- ustr string library functions .SH "SYNOPSIS" .in \w' 'u #include "ustr.h" .sp .sp .br .in \w' struct Ustr *\fBUSTR\fR('u .ti \w' 'u struct Ustr *\fBUSTR\fR(void *); .br .in \w' struct Ustrp *\fBUSTRP\fR('u .ti \w' 'u struct Ustrp *\fBUSTRP\fR(void *); .br .in \w' struct Ustr *\fBUSTR1\fR('u .ti \w' 'u struct Ustr *\fBUSTR1\fR(symbol, const char[]); .br .in \w' struct Ustr *\fBUSTR2\fR('u .ti \w' 'u struct Ustr *\fBUSTR2\fR(symbol, symbol, const char[]); .br .in \w' struct Ustr *\fBUSTR4\fR('u .ti \w' 'u struct Ustr *\fBUSTR4\fR(symbol, symbol, symbol, symbol, const char[]); .br .in \w' struct Ustr *\fBUSTR1_CHK\fR('u .ti \w' 'u struct Ustr *\fBUSTR1_CHK\fR(symbol, const char[]); .br .in \w' struct Ustr *\fBUSTR2_CHK\fR('u .ti \w' 'u struct Ustr *\fBUSTR2_CHK\fR(symbol, symbol, const char[]); .br .in \w' struct Ustr *\fBUSTR4_CHK\fR('u .ti \w' 'u struct Ustr *\fBUSTR4_CHK\fR(symbol, symbol, symbol, symbol, const char[]); .br .in \w' struct Ustr *\fBUSTRP1\fR('u .ti \w' 'u struct Ustr *\fBUSTRP1\fR(symbol, const char[]); .br .in \w' struct Ustr *\fBUSTRP2\fR('u .ti \w' 'u struct Ustr *\fBUSTRP2\fR(symbol, symbol, const char[]); .br .in \w' struct Ustrp *\fBUSTRP4\fR('u .ti \w' 'u struct Ustrp *\fBUSTRP4\fR(symbol, symbol, symbol, symbol, const char[]); .br .in \w' struct Ustr *\fBUSTRP1_CHK\fR('u .ti \w' 'u struct Ustr *\fBUSTRP1_CHK\fR(symbol, const char[]); .br .in \w' struct Ustr *\fBUSTRP2_CHK\fR('u .ti \w' 'u struct Ustr *\fBUSTRP2_CHK\fR(symbol, symbol, const char[]); .br .in \w' struct Ustrp *\fBUSTRP4_CHK\fR('u .ti \w' 'u struct Ustrp *\fBUSTRP4_CHK\fR(symbol, symbol, symbol, symbol, const char[]); .sp .br .in \w' size_t \fBUSTR_SIZE_FIXED\fR('u .ti \w' 'u size_t \fBUSTR_SIZE_FIXED\fR(size_t); .br .in \w' struct Ustr *\fBustr_init_fixed\fR('u .ti \w' 'u struct Ustr *\fBustr_init_fixed\fR(void *, size_t, int, size_t); .br .in \w' struct Ustr *\fBUSTR_SC_INIT_AUTO\fR('u .ti \w' 'u struct Ustr *\fBUSTR_SC_INIT_AUTO\fR(char[], int, size_t); .br .in \w' struct Ustr *\fBUSTR_SC_INIT_AUTO_OSTR\fR('u .ti \w' 'u struct Ustr *\fBUSTR_SC_INIT_AUTO_OSTR\fR(char[], int, size_t); .sp .br .in \w' int \fBustr_assert_valid\fR('u .ti \w' 'u int \fBustr_assert_valid\fR(Ustr *); .br .in \w' int \fBustr_assert_valid_subustr\fR('u .ti \w' 'u int \fBustr_assert_valid_subustr\fR(Ustr *, size_t, size_t); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_BEG\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_BEG\fR(int); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_LVL\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_LVL\fR(void); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_MEM\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_MEM\fR(void *); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_MEM_SZ\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_MEM_SZ\fR(void *, size_t); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_MEM_MINSZ\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_MEM_MINSZ\fR(void *, size_t); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_MEM_USTR\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_MEM_USTR\fR(Ustr *); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_MEM_USTRP\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_MEM_USTRP\fR(Ustrp *); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_END\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_END\fR(void); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_ADD\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_ADD\fR(int); .br .in \w' int \fBUSTR_CNTL_MALLOC_CHECK_DEL\fR('u .ti \w' 'u int \fBUSTR_CNTL_MALLOC_CHECK_DEL\fR(int); .sp .br .in \w' size_t \fBustr_init_size\fR('u .ti \w' 'u size_t \fBustr_init_size\fR(size_t, size_t, int, size_t); .br .in \w' struct Ustr *\fBustr_init_alloc\fR('u .ti \w' 'u struct Ustr *\fBustr_init_alloc\fR(void *, size_t, size_t, size_t, int, int, size_t); .br .in \w' struct Ustr *\fBustr_dupx_empty\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_empty\fR(size_t, size_t, int, int); .br .in \w' struct Ustr *\fBustr_dup_empty\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_empty\fR(void); .br .in \w' struct Ustr *\fBustr_dupx_undef\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_undef\fR(size_t, size_t, int, int, size_t); .br .in \w' struct Ustr *\fBustr_dup_undef\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_undef\fR(size_t); .br .in \w' struct Ustr *\fBustr_dup\fR('u .ti \w' 'u struct Ustr *\fBustr_dup\fR(const struct Ustr *); .br .in \w' struct Ustr *\fBustr_dupx\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx\fR(size_t, size_t, int, int, const struct Ustr *); .br .in \w' struct Ustr *\fBustr_sc_dup\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_dup\fR(struct Ustr **); .br .in \w' struct Ustr *\fBustr_sc_dupx\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_dupx\fR(size_t, size_t, int, int, struct Ustr **); .br .in \w' struct Ustr *\fBustr_dup_buf\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_buf\fR(const void *, size_t); .br .in \w' struct Ustr *\fBustr_dupx_buf\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_buf\fR(size_t, size_t, int, int, const void *, size_t); .br .in \w' struct Ustr *\fBustr_dup_cstr\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_cstr\fR(const char *); .br .in \w' struct Ustr *\fBustr_dupx_cstr\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_cstr\fR(size_t, size_t, int, int, const char *); .br .in \w' struct Ustr *\fBUSTR_DUP_OSTR\fR('u .ti \w' 'u struct Ustr *\fBUSTR_DUP_OSTR\fR(const char []); .br .in \w' struct Ustr *\fBUSTR_DUP_OBJ\fR('u .ti \w' 'u struct Ustr *\fBUSTR_DUP_OBJ\fR(...); .br .in \w' struct Ustr *\fBustr_dup_subustr\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_subustr\fR(const struct Ustr *, size_t, size_t); .br .in \w' struct Ustr *\fBustr_dupx_subustr\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_subustr\fR(size_t, size_t, int, int, const struct Ustr *, size_t, size_t); .br .in \w' struct Ustr *\fBustr_dup_rep_chr\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_rep_chr\fR(char, size_t); .br .in \w' struct Ustr *\fBustr_dupx_rep_chr\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_rep_chr\fR(size_t, size_t, int, int, char, size_t); .br .in \w' struct Ustr *\fBustr_sc_vjoin\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_vjoin\fR(const struct Ustr *, const struct Ustr *, const struct Ustr *, va_list); .br .in \w' struct Ustr *\fBustr_sc_join\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_join\fR(const struct Ustr *, const struct Ustr *, const struct Ustr *, ...); .br .in \w' struct Ustr *\fBustr_sc_vjoinx\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_vjoinx\fR(size_t, size_t, int, int, const struct Ustr *, const struct Ustr *, const struct Ustr *, va_list); .br .in \w' struct Ustr *\fBustr_sc_joinx\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_joinx\fR(size_t, size_t, int, int, const struct Ustr *, const struct Ustr *, const struct Ustr *, ...); .br .in \w' struct Ustr *\fBustr_sc_vconcat\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_vconcat\fR(const struct Ustr *, va_list); .br .in \w' struct Ustr *\fBustr_sc_concat\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_concat\fR(const struct Ustr *, ...); .br .in \w' struct Ustr *\fBustr_sc_vconcatx\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_vconcatx\fR(size_t, size_t, int, int, const struct Ustr *, va_list); .br .in \w' struct Ustr *\fBustr_sc_concatx\fR('u .ti \w' 'u struct Ustr *\fBustr_sc_concatx\fR(size_t, size_t, int, int, const struct Ustr *, ...); .sp .br .in \w' void \fBustr_free\fR('u .ti \w' 'u void \fBustr_free\fR(struct Ustr *); .br .in \w' void \fBustrp_free\fR('u .ti \w' 'u void \fBustrp_free\fR(struct Ustr_pool *, struct Ustrp *); .br .in \w' void \fBustr_sc_free\fR('u .ti \w' 'u void \fBustr_sc_free\fR(struct Ustr **); .br .in \w' void \fBustr_sc_free2\fR('u .ti \w' 'u void \fBustr_sc_free2\fR(struct Ustr **, struct Ustr *); .br .in \w' void \fBustr_sc_free_shared\fR('u .ti \w' 'u void \fBustr_sc_free_shared\fR(struct Ustr **); .br .in \w' int \fBustr_del\fR('u .ti \w' 'u int \fBustr_del\fR(struct Ustr **, size_t); .br .in \w' int \fBustr_del_subustr\fR('u .ti \w' 'u int \fBustr_del_subustr\fR(struct Ustr **, size_t, size_t); .br .in \w' void \fBustr_sc_del\fR('u .ti \w' 'u void \fBustr_sc_del\fR(struct Ustr **); .sp .br .in \w' int \fBustr_add_undef\fR('u .ti \w' 'u int \fBustr_add_undef\fR(struct Ustr **, size_t); .br .in \w' int \fBustr_add_buf\fR('u .ti \w' 'u int \fBustr_add_buf\fR(struct Ustr **, const void *, size_t); .br .in \w' int \fBustr_add_cstr\fR('u .ti \w' 'u int \fBustr_add_cstr\fR(struct Ustr **, const char *); .br .in \w' int \fBUSTR_ADD_OSTR\fR('u .ti \w' 'u int \fBUSTR_ADD_OSTR\fR(struct Ustr **, const char []); .br .in \w' int \fBUSTR_ADD_OBJ\fR('u .ti \w' 'u int \fBUSTR_ADD_OBJ\fR(struct Ustr **, ...); .br .in \w' int \fBustr_add\fR('u .ti \w' 'u int \fBustr_add\fR(struct Ustr **, const struct Ustr *); .br .in \w' int \fBustr_add_subustr\fR('u .ti \w' 'u int \fBustr_add_subustr\fR(struct Ustr **, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_add_rep_chr\fR('u .ti \w' 'u int \fBustr_add_rep_chr\fR(struct Ustr **, char, size_t); .sp .br .in \w' int \fBustr_set_undef\fR('u .ti \w' 'u int \fBustr_set_undef\fR(struct Ustr **, size_t); .br .in \w' int \fBustr_set_empty\fR('u .ti \w' 'u int \fBustr_set_empty\fR(struct Ustr **); .br .in \w' int \fBustr_set_buf\fR('u .ti \w' 'u int \fBustr_set_buf\fR(struct Ustr **, const void *, size_t); .br .in \w' int \fBustr_set_cstr\fR('u .ti \w' 'u int \fBustr_set_cstr\fR(struct Ustr **, const char *); .br .in \w' int \fBUSTR_SET_OSTR\fR('u .ti \w' 'u int \fBUSTR_SET_OSTR\fR(struct Ustr **, const char []); .br .in \w' int \fBUSTR_SET_OBJ\fR('u .ti \w' 'u int \fBUSTR_SET_OBJ\fR(struct Ustr **, ...); .br .in \w' int \fBustr_set\fR('u .ti \w' 'u int \fBustr_set\fR(struct Ustr **, const struct Ustr *); .br .in \w' int \fBustr_set_subustr\fR('u .ti \w' 'u int \fBustr_set_subustr\fR(struct Ustr **, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_set_rep_chr\fR('u .ti \w' 'u int \fBustr_set_rep_chr\fR(struct Ustr **, char, size_t); .sp .br .in \w' int \fBustr_ins_undef\fR('u .ti \w' 'u int \fBustr_ins_undef\fR(struct Ustr **, size_t, size_t); .br .in \w' int \fBustr_ins_buf\fR('u .ti \w' 'u int \fBustr_ins_buf\fR(struct Ustr **, size_t, const void *, size_t); .br .in \w' int \fBustr_ins_cstr\fR('u .ti \w' 'u int \fBustr_ins_cstr\fR(struct Ustr **, size_t, const char *); .br .in \w' int \fBUSTR_INS_OSTR\fR('u .ti \w' 'u int \fBUSTR_INS_OSTR\fR(struct Ustr **, size_t, const char []); .br .in \w' int \fBUSTR_INS_OBJ\fR('u .ti \w' 'u int \fBUSTR_INS_OBJ\fR(struct Ustr **, size_t, ...); .br .in \w' int \fBustr_ins\fR('u .ti \w' 'u int \fBustr_ins\fR(struct Ustr **, size_t, const struct Ustr *); .br .in \w' int \fBustr_ins_subustr\fR('u .ti \w' 'u int \fBustr_ins_subustr\fR(struct Ustr **, size_t, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_ins_rep_chr\fR('u .ti \w' 'u int \fBustr_ins_rep_chr\fR(struct Ustr **, size_t, char, size_t); .sp .br .in \w' int \fBustr_add_vfmt_lim\fR('u .ti \w' 'u int \fBustr_add_vfmt_lim\fR(struct Ustr **, size_t, const char *, va_list); .br .in \w' int \fBustr_add_vfmt\fR('u .ti \w' 'u int \fBustr_add_vfmt\fR(struct Ustr **, const char *, va_list); .br .in \w' int \fBustr_add_fmt_lim\fR('u .ti \w' 'u int \fBustr_add_fmt_lim\fR(struct Ustr **, size_t, const char *, ...); .br .in \w' int \fBustr_add_fmt\fR('u .ti \w' 'u int \fBustr_add_fmt\fR(struct Ustr **, const char *, ...); .br .in \w' struct Ustr *\fBustr_dup_vfmt_lim\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_vfmt_lim\fR(size_t, const char *, va_list); .br .in \w' struct Ustr *\fBustr_dup_vfmt\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_vfmt\fR(size_t, const char *, va_list); .br .in \w' struct Ustr *\fBustr_dup_fmt_lim\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_fmt_lim\fR(size_t, const char *, ...); .br .in \w' struct Ustr *\fBustr_dup_fmt\fR('u .ti \w' 'u struct Ustr *\fBustr_dup_fmt\fR(const char *, ...); .br .in \w' struct Ustr *\fBustr_dupx_fmt_lim\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_fmt_lim\fR(size_t, size_t, int, int, size_t, const char *, ...); .br .in \w' struct Ustr *\fBustr_dupx_fmt\fR('u .ti \w' 'u struct Ustr *\fBustr_dupx_fmt\fR(size_t, size_t, int, int, const char *, ...); .br .in \w' int \fBustr_set_vfmt_lim\fR('u .ti \w' 'u int \fBustr_set_vfmt_lim\fR(struct Ustr **, size_t, const char *, va_list); .br .in \w' int \fBustr_set_vfmt\fR('u .ti \w' 'u int \fBustr_set_vfmt\fR(struct Ustr **, const char *, va_list); .br .in \w' int \fBustr_set_fmt_lim\fR('u .ti \w' 'u int \fBustr_set_fmt_lim\fR(struct Ustr **, size_t, const char *, ...); .br .in \w' int \fBustr_set_fmt\fR('u .ti \w' 'u int \fBustr_set_fmt\fR(struct Ustr **, const char *, ...); .br .in \w' int \fBustr_ins_vfmt_lim\fR('u .ti \w' 'u int \fBustr_ins_vfmt_lim\fR(struct Ustr **, size_t, size_t, const char *, va_list); .br .in \w' int \fBustr_ins_vfmt\fR('u .ti \w' 'u int \fBustr_ins_vfmt\fR(struct Ustr **, size_t, const char *, va_list); .br .in \w' int \fBustr_ins_fmt_lim\fR('u .ti \w' 'u int \fBustr_ins_fmt_lim\fR(struct Ustr **, size_t, size_t, const char *, ...); .br .in \w' int \fBustr_ins_fmt\fR('u .ti \w' 'u int \fBustr_ins_fmt\fR(struct Ustr **, size_t, const char *, ...); .br .in \w' int \fBustr_sub_vfmt_lim\fR('u .ti \w' 'u int \fBustr_sub_vfmt_lim\fR(struct Ustr **, size_t, size_t, const char *, va_list); .br .in \w' int \fBustr_sub_vfmt\fR('u .ti \w' 'u int \fBustr_sub_vfmt\fR(struct Ustr **, size_t, const char *, va_list); .br .in \w' int \fBustr_sub_fmt_lim\fR('u .ti \w' 'u int \fBustr_sub_fmt_lim\fR(struct Ustr **, size_t, size_t, const char *, ...); .br .in \w' int \fBustr_sub_fmt\fR('u .ti \w' 'u int \fBustr_sub_fmt\fR(struct Ustr **, size_t, const char *, ...); .br .in \w' int \fBustr_sc_sub_vfmt_lim\fR('u .ti \w' 'u int \fBustr_sc_sub_vfmt_lim\fR(struct Ustr **, size_t, size_t, size_t, const char *, va_list); .br .in \w' int \fBustr_sc_sub_vfmt\fR('u .ti \w' 'u int \fBustr_sc_sub_vfmt\fR(struct Ustr **, size_t, size_t, const char *, va_list); .br .in \w' int \fBustr_sc_sub_fmt_lim\fR('u .ti \w' 'u int \fBustr_sc_sub_fmt_lim\fR(struct Ustr **, size_t, size_t, size_t, const char *, ...); .br .in \w' int \fBustr_sc_sub_fmt\fR('u .ti \w' 'u int \fBustr_sc_sub_fmt\fR(struct Ustr **, size_t, size_t, const char *, ...); .sp .br .in \w' size_t \fBustr_len\fR('u .ti \w' 'u size_t \fBustr_len\fR(const struct Ustr *); .br .in \w' const char *\fBustr_cstr\fR('u .ti \w' 'u const char *\fBustr_cstr\fR(const struct Ustr *); .br .in \w' char *\fBustr_wstr\fR('u .ti \w' 'u char *\fBustr_wstr\fR(struct Ustr *); .br .in \w' int \fBustr_alloc\fR('u .ti \w' 'u int \fBustr_alloc\fR(const struct Ustr *); .br .in \w' int \fBustr_exact\fR('u .ti \w' 'u int \fBustr_exact\fR(const struct Ustr *); .br .in \w' int \fBustr_sized\fR('u .ti \w' 'u int \fBustr_sized\fR(const struct Ustr *); .br .in \w' int \fBustr_ro\fR('u .ti \w' 'u int \fBustr_ro\fR(const struct Ustr *); .br .in \w' int \fBustr_fixed\fR('u .ti \w' 'u int \fBustr_fixed\fR(const struct Ustr *); .br .in \w' int \fBustr_enomem\fR('u .ti \w' 'u int \fBustr_enomem\fR(const struct Ustr *); .br .in \w' int \fBustr_shared\fR('u .ti \w' 'u int \fBustr_shared\fR(const struct Ustr *); .br .in \w' int \fBustr_limited\fR('u .ti \w' 'u int \fBustr_limited\fR(const struct Ustr *); .br .in \w' int \fBustr_owner\fR('u .ti \w' 'u int \fBustr_owner\fR(const struct Ustr *); .br .in \w' size_t \fBustr_size\fR('u .ti \w' 'u size_t \fBustr_size\fR(const struct Ustr *); .br .in \w' size_t \fBustr_size_alloc\fR('u .ti \w' 'u size_t \fBustr_size_alloc\fR(const struct Ustr *); .br .in \w' size_t \fBustr_size_overhead\fR('u .ti \w' 'u size_t \fBustr_size_overhead\fR(const struct Ustr *); .br .in \w' void \fBustr_conf\fR('u .ti \w' 'u void \fBustr_conf\fR(const struct Ustr *, size_t *, size_t *, int *, size_t *, size_t *); .sp .br .in \w' int \fBustr_setf_enomem_err\fR('u .ti \w' 'u int \fBustr_setf_enomem_err\fR(struct Ustr *); .br .in \w' int \fBustr_setf_enomem_clr\fR('u .ti \w' 'u int \fBustr_setf_enomem_clr\fR(struct Ustr *); .br .in \w' int \fBustr_setf_share\fR('u .ti \w' 'u int \fBustr_setf_share\fR(struct Ustr *); .br .in \w' int \fBustr_setf_owner\fR('u .ti \w' 'u int \fBustr_setf_owner\fR(struct Ustr *); .sp .br .in \w' int \fBustr_cmp_buf\fR('u .ti \w' 'u int \fBustr_cmp_buf\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp\fR('u .ti \w' 'u int \fBustr_cmp\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_subustr\fR('u .ti \w' 'u int \fBustr_cmp_subustr\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_cstr\fR('u .ti \w' 'u int \fBustr_cmp_cstr\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_fast_buf\fR('u .ti \w' 'u int \fBustr_cmp_fast_buf\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_fast\fR('u .ti \w' 'u int \fBustr_cmp_fast\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_fast_subustr\fR('u .ti \w' 'u int \fBustr_cmp_fast_subustr\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_fast_cstr\fR('u .ti \w' 'u int \fBustr_cmp_fast_cstr\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_case_buf\fR('u .ti \w' 'u int \fBustr_cmp_case_buf\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_case\fR('u .ti \w' 'u int \fBustr_cmp_case\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_case_subustr\fR('u .ti \w' 'u int \fBustr_cmp_case_subustr\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_case_cstr\fR('u .ti \w' 'u int \fBustr_cmp_case_cstr\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_eq\fR('u .ti \w' 'u int \fBustr_cmp_eq\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_buf_eq\fR('u .ti \w' 'u int \fBustr_cmp_buf_eq\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_subustr_eq\fR('u .ti \w' 'u int \fBustr_cmp_subustr_eq\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_cstr_eq\fR('u .ti \w' 'u int \fBustr_cmp_cstr_eq\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_case_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_eq\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_case_buf_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_buf_eq\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_case_subustr_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_subustr_eq\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_case_cstr_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_cstr_eq\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_prefix_eq\fR('u .ti \w' 'u int \fBustr_cmp_prefix_eq\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_prefix_buf_eq\fR('u .ti \w' 'u int \fBustr_cmp_prefix_buf_eq\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_prefix_cstr_eq\fR('u .ti \w' 'u int \fBustr_cmp_prefix_cstr_eq\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_prefix_subustr_eq\fR('u .ti \w' 'u int \fBustr_cmp_prefix_subustr_eq\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_case_prefix_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_prefix_eq\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_case_prefix_buf_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_prefix_buf_eq\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_case_prefix_cstr_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_prefix_cstr_eq\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_case_prefix_subustr_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_prefix_subustr_eq\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_suffix_eq\fR('u .ti \w' 'u int \fBustr_cmp_suffix_eq\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_suffix_buf_eq\fR('u .ti \w' 'u int \fBustr_cmp_suffix_buf_eq\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_suffix_cstr_eq\fR('u .ti \w' 'u int \fBustr_cmp_suffix_cstr_eq\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_suffix_subustr_eq\fR('u .ti \w' 'u int \fBustr_cmp_suffix_subustr_eq\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_cmp_case_suffix_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_suffix_eq\fR(const struct Ustr *, const struct Ustr *); .br .in \w' int \fBustr_cmp_case_suffix_buf_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_suffix_buf_eq\fR(const struct Ustr *, const void *, size_t); .br .in \w' int \fBustr_cmp_case_suffix_cstr_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_suffix_cstr_eq\fR(const struct Ustr *, const char *); .br .in \w' int \fBustr_cmp_case_suffix_subustr_eq\fR('u .ti \w' 'u int \fBustr_cmp_case_suffix_subustr_eq\fR(const struct Ustr *, const struct Ustr *, size_t, size_t); .sp .br .in \w' size_t \fBustr_srch_chr_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_chr_fwd\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_srch_chr_rev\fR('u .ti \w' 'u size_t \fBustr_srch_chr_rev\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_srch_buf_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_buf_fwd\fR(const struct Ustr *, size_t, const void *, size_t); .br .in \w' size_t \fBustr_srch_buf_rev\fR('u .ti \w' 'u size_t \fBustr_srch_buf_rev\fR(const struct Ustr *, size_t, const void *, size_t); .br .in \w' size_t \fBustr_srch_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_fwd\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_srch_rev\fR('u .ti \w' 'u size_t \fBustr_srch_rev\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_srch_cstr_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_cstr_fwd\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_srch_cstr_rev\fR('u .ti \w' 'u size_t \fBustr_srch_cstr_rev\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_srch_subustr_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_subustr_fwd\fR(const struct Ustr *, size_t, const struct Ustr *, size_t, size_t); .br .in \w' size_t \fBustr_srch_subustr_rev\fR('u .ti \w' 'u size_t \fBustr_srch_subustr_rev\fR(const struct Ustr *, size_t, const struct Ustr *, size_t, size_t); .br .in \w' size_t \fBustr_srch_case_chr_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_case_chr_fwd\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_srch_case_chr_rev\fR('u .ti \w' 'u size_t \fBustr_srch_case_chr_rev\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_srch_case_buf_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_case_buf_fwd\fR(const struct Ustr *, size_t, const void *, size_t); .br .in \w' size_t \fBustr_srch_case_buf_rev\fR('u .ti \w' 'u size_t \fBustr_srch_case_buf_rev\fR(const struct Ustr *, size_t, const void *, size_t); .br .in \w' size_t \fBustr_srch_case_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_case_fwd\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_srch_case_rev\fR('u .ti \w' 'u size_t \fBustr_srch_case_rev\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_srch_case_cstr_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_case_cstr_fwd\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_srch_case_cstr_rev\fR('u .ti \w' 'u size_t \fBustr_srch_case_cstr_rev\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_srch_case_subustr_fwd\fR('u .ti \w' 'u size_t \fBustr_srch_case_subustr_fwd\fR(const struct Ustr *, size_t, const struct Ustr *, size_t, size_t); .br .in \w' size_t \fBustr_srch_case_subustr_rev\fR('u .ti \w' 'u size_t \fBustr_srch_case_subustr_rev\fR(const struct Ustr *, size_t, const struct Ustr *, size_t, size_t); .sp .br .in \w' size_t \fBustr_spn_chr_fwd\fR('u .ti \w' 'u size_t \fBustr_spn_chr_fwd\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_spn_chr_rev\fR('u .ti \w' 'u size_t \fBustr_spn_chr_rev\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_spn_chrs_fwd\fR('u .ti \w' 'u size_t \fBustr_spn_chrs_fwd\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_spn_chrs_rev\fR('u .ti \w' 'u size_t \fBustr_spn_chrs_rev\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_spn_fwd\fR('u .ti \w' 'u size_t \fBustr_spn_fwd\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_spn_rev\fR('u .ti \w' 'u size_t \fBustr_spn_rev\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_spn_cstr_fwd\fR('u .ti \w' 'u size_t \fBustr_spn_cstr_fwd\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_spn_cstr_rev\fR('u .ti \w' 'u size_t \fBustr_spn_cstr_rev\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_cspn_chr_fwd\fR('u .ti \w' 'u size_t \fBustr_cspn_chr_fwd\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_cspn_chr_rev\fR('u .ti \w' 'u size_t \fBustr_cspn_chr_rev\fR(const struct Ustr *, size_t, char); .br .in \w' size_t \fBustr_cspn_chrs_fwd\fR('u .ti \w' 'u size_t \fBustr_cspn_chrs_fwd\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_cspn_chrs_rev\fR('u .ti \w' 'u size_t \fBustr_cspn_chrs_rev\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_cspn_fwd\fR('u .ti \w' 'u size_t \fBustr_cspn_fwd\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_cspn_rev\fR('u .ti \w' 'u size_t \fBustr_cspn_rev\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_cspn_cstr_fwd\fR('u .ti \w' 'u size_t \fBustr_cspn_cstr_fwd\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_cspn_cstr_rev\fR('u .ti \w' 'u size_t \fBustr_cspn_cstr_rev\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_utf8_spn_chrs_fwd\fR('u .ti \w' 'u size_t \fBustr_utf8_spn_chrs_fwd\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_utf8_spn_chrs_rev\fR('u .ti \w' 'u size_t \fBustr_utf8_spn_chrs_rev\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_utf8_spn_fwd\fR('u .ti \w' 'u size_t \fBustr_utf8_spn_fwd\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_utf8_spn_rev\fR('u .ti \w' 'u size_t \fBustr_utf8_spn_rev\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_utf8_spn_cstr_fwd\fR('u .ti \w' 'u size_t \fBustr_utf8_spn_cstr_fwd\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_utf8_spn_cstr_rev\fR('u .ti \w' 'u size_t \fBustr_utf8_spn_cstr_rev\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_utf8_cspn_chrs_fwd\fR('u .ti \w' 'u size_t \fBustr_utf8_cspn_chrs_fwd\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_utf8_cspn_chrs_rev\fR('u .ti \w' 'u size_t \fBustr_utf8_cspn_chrs_rev\fR(const struct Ustr *, size_t, const char *, size_t); .br .in \w' size_t \fBustr_utf8_cspn_fwd\fR('u .ti \w' 'u size_t \fBustr_utf8_cspn_fwd\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_utf8_cspn_rev\fR('u .ti \w' 'u size_t \fBustr_utf8_cspn_rev\fR(const struct Ustr *, size_t, const struct Ustr *); .br .in \w' size_t \fBustr_utf8_cspn_cstr_fwd\fR('u .ti \w' 'u size_t \fBustr_utf8_cspn_cstr_fwd\fR(const struct Ustr *, size_t, const char *); .br .in \w' size_t \fBustr_utf8_cspn_cstr_rev\fR('u .ti \w' 'u size_t \fBustr_utf8_cspn_cstr_rev\fR(const struct Ustr *, size_t, const char *); .sp .br .in \w' int \fBustr_io_get\fR('u .ti \w' 'u int \fBustr_io_get\fR(struct Ustr **, FILE *, size_t, size_t *); .br .in \w' int \fBustr_io_getfile\fR('u .ti \w' 'u int \fBustr_io_getfile\fR(struct Ustr **, FILE *); .br .in \w' int \fBustr_io_getfilename\fR('u .ti \w' 'u int \fBustr_io_getfilename\fR(struct Ustr **, const char *); .br .in \w' int \fBustr_io_getdelim\fR('u .ti \w' 'u int \fBustr_io_getdelim\fR(struct Ustr **, FILE *, char); .br .in \w' int \fBustr_io_getline\fR('u .ti \w' 'u int \fBustr_io_getline\fR(struct Ustr **, FILE *); .br .in \w' int \fBustr_io_put\fR('u .ti \w' 'u int \fBustr_io_put\fR(struct Ustr **, FILE *, size_t); .br .in \w' int \fBustr_io_putline\fR('u .ti \w' 'u int \fBustr_io_putline\fR(struct Ustr **, FILE *, size_t); .br .in \w' int \fBustr_io_putfile\fR('u .ti \w' 'u int \fBustr_io_putfile\fR(struct Ustr **, FILE *); .br .in \w' int \fBustr_io_putfileline\fR('u .ti \w' 'u int \fBustr_io_putfileline\fR(struct Ustr **, FILE *); .br .in \w' int \fBustr_io_putfilename\fR('u .ti \w' 'u int \fBustr_io_putfilename\fR(struct Ustr **, const char *, const char *); .sp .br .in \w' int \fBustr_sub_undef\fR('u .ti \w' 'u int \fBustr_sub_undef\fR(struct Ustr **, size_t, size_t); .br .in \w' int \fBustr_sub_buf\fR('u .ti \w' 'u int \fBustr_sub_buf\fR(struct Ustr **, size_t, const void *, size_t); .br .in \w' int \fBustr_sub_cstr\fR('u .ti \w' 'u int \fBustr_sub_cstr\fR(struct Ustr **, size_t, const char *); .br .in \w' int \fBUSTR_SUB_OSTR\fR('u .ti \w' 'u int \fBUSTR_SUB_OSTR\fR(struct Ustr **, size_t, const char []); .br .in \w' int \fBUSTR_SUB_OBJ\fR('u .ti \w' 'u int \fBUSTR_SUB_OBJ\fR(struct Ustr **, size_t, ...); .br .in \w' int \fBustr_sub\fR('u .ti \w' 'u int \fBustr_sub\fR(struct Ustr **, size_t, const struct Ustr *); .br .in \w' int \fBustr_sub_subustr\fR('u .ti \w' 'u int \fBustr_sub_subustr\fR(struct Ustr **, size_t, const struct Ustr *, size_t, size_t); .br .in \w' int \fBustr_sc_sub_undef\fR('u .ti \w' 'u int \fBustr_sc_sub_undef\fR(struct Ustr **, size_t, size_t, size_t); .br .in \w' int \fBustr_sc_sub_buf\fR('u .ti \w' 'u int \fBustr_sc_sub_buf\fR(struct Ustr **, size_t , size_t , const void *, size_t ); .br .in \w' int \fBustr_sc_sub_cstr\fR('u .ti \w' 'u int \fBustr_sc_sub_cstr\fR(struct Ustr **, size_t, size_t, const char *); .br .in \w' int \fBustr_sc_sub\fR('u .ti \w' 'u int \fBustr_sc_sub\fR(struct Ustr **, size_t, size_t, const struct Ustr *); .br .in \w' int \fBustr_sc_sub_subustr\fR('u .ti \w' 'u int \fBustr_sc_sub_subustr\fR(struct Ustr **, size_t, size_t, const struct Ustr *, size_t, size_t); .br .in \w' int \fBUSTR_SC_SUB_OSTR\fR('u .ti \w' 'u int \fBUSTR_SC_SUB_OSTR\fR(struct Ustr **, size_t, size_t, const char []); .br .in \w' int \fBUSTR_SC_SUB_OBJ\fR('u .ti \w' 'u int \fBUSTR_SC_SUB_OBJ\fR(struct Ustr **, size_t, size_t, ...); .br .in \w' size_t \fBustr_replace_buf\fR('u .ti \w' 'u size_t \fBustr_replace_buf\fR(struct Ustr **, const void *, size_t, const void *, size_t, size_t); .br .in \w' size_t \fBustr_replace_cstr\fR('u .ti \w' 'u size_t \fBustr_replace_cstr\fR(struct Ustr **, const char *, const char *, size_t); .br .in \w' int \fBustr_replace\fR('u .ti \w' 'u int \fBustr_replace\fR(struct Ustr **, const struct Ustr *, const struct Ustr *, size_t); .br .in \w' size_t \fBustr_replace_rep_chr\fR('u .ti \w' 'u size_t \fBustr_replace_rep_chr\fR(struct Ustr **ps1, char, size_t, char, size_t nlen, size_t lim); .sp .br .in \w' struct Ustr *\fBustr_split_buf\fR('u .ti \w' 'u struct Ustr *\fBustr_split_buf\fR(const struct Ustr *, size_t *, const void *, size_t, struct Ustr *, unsigned int); .br .in \w' struct Ustr *\fBustr_split\fR('u .ti \w' 'u struct Ustr *\fBustr_split\fR(const struct Ustr *, size_t *, const struct Ustr *, struct Ustr *, unsigned int); .br .in \w' struct Ustr *\fBustr_split_cstr\fR('u .ti \w' 'u struct Ustr *\fBustr_split_cstr\fR(const struct Ustr *, size_t *, const char *, struct Ustr *, unsigned int); .br .in \w' struct Ustr *\fBustr_split_spn_chrs\fR('u .ti \w' 'u struct Ustr *\fBustr_split_spn_chrs\fR(const struct Ustr *, size_t *, const char *, size_t, struct Ustr *, unsigned int); .br .in \w' struct Ustr *\fBustr_split_spn_cstr\fR('u .ti \w' 'u struct Ustr *\fBustr_split_spn_cstr\fR(const struct Ustr *, size_t *, const char *, struct Ustr *, unsigned int); .br .in \w' struct Ustr *\fBustr_split_spn\fR('u .ti \w' 'u struct Ustr *\fBustr_split_spn\fR(const struct Ustr *, size_t *, const struct Ustr *, struct Ustr *, unsigned int); .sp .br .in \w' int \fBustr_utf8_valid\fR('u .ti \w' 'u int \fBustr_utf8_valid\fR(const struct Ustr *); .br .in \w' size_t \fBustr_utf8_len\fR('u .ti \w' 'u size_t \fBustr_utf8_len\fR(const struct Ustr *); .br .in \w' ssize_t \fBustr_utf8_width\fR('u .ti \w' 'u ssize_t \fBustr_utf8_width\fR(const struct Ustr *); .br .in \w' size_t \fBustr_utf8_chars2bytes\fR('u .ti \w' 'u size_t \fBustr_utf8_chars2bytes\fR(const struct Ustr *, size_t, size_t, size_t *); .br .in \w' size_t \fBustr_utf8_bytes2chars\fR('u .ti \w' 'u size_t \fBustr_utf8_bytes2chars\fR(const struct Ustr *, size_t, size_t, size_t *); .br .in \w' int \fBustr_sc_utf8_reverse\fR('u .ti \w' 'u int \fBustr_sc_utf8_reverse\fR(struct Ustr **); .sp .br .in \w' uintmax_t \fBustr_parse_uintmaxx\fR('u .ti \w' 'u uintmax_t \fBustr_parse_uintmaxx\fR(const struct Ustr *, size_t, unsigned int, uintmax_t, uintmax_t, const char *, size_t *, unsigned int *); .br .in \w' uintmax_t \fBustr_parse_uintmax\fR('u .ti \w' 'u uintmax_t \fBustr_parse_uintmax\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' intmax_t \fBustr_parse_intmax\fR('u .ti \w' 'u intmax_t \fBustr_parse_intmax\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' unsigned long \fBustr_parse_ulongx\fR('u .ti \w' 'u unsigned long \fBustr_parse_ulongx\fR(const struct Ustr *, size_t, unsigned int, unsigned long, unsigned long, const char *, size_t *, unsigned int *); .br .in \w' unsigned long \fBustr_parse_ulong\fR('u .ti \w' 'u unsigned long \fBustr_parse_ulong\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' long \fBustr_parse_long\fR('u .ti \w' 'u long \fBustr_parse_long\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' unsigned int \fBustr_parse_uint\fR('u .ti \w' 'u unsigned int \fBustr_parse_uint\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' int \fBustr_parse_int\fR('u .ti \w' 'u int \fBustr_parse_int\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' unsigned short \fBustr_parse_ushort\fR('u .ti \w' 'u unsigned short \fBustr_parse_ushort\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .br .in \w' short \fBustr_parse_short\fR('u .ti \w' 'u short \fBustr_parse_short\fR(const struct Ustr *, size_t, unsigned int, size_t *, unsigned int *); .sp .br .in \w' int \fBustr_sc_ensure_owner\fR('u .ti \w' 'u int \fBustr_sc_ensure_owner\fR(struct Ustr **); .br .in \w' char *\fBustr_sc_wstr\fR('u .ti \w' 'u char *\fBustr_sc_wstr\fR(struct Ustr **); .br .in \w' char *\fBustr_sc_export_subustr\fR('u .ti \w' 'u char *\fBustr_sc_export_subustr\fR(const struct Ustr *, size_t, size_t, void *(*)(size_t)); .br .in \w' char *\fBustr_sc_export\fR('u .ti \w' 'u char *\fBustr_sc_export\fR(const struct Ustr *, void *(*)(size_t)); .br .in \w' char *\fBustrp_sc_export_subustrp\fR('u .ti \w' 'u char *\fBustrp_sc_export_subustrp\fR(struct Ustr_pool *, const struct Ustr *, size_t, size_t, void *(*)(size_t)); .br .in \w' char *\fBustrp_sc_export\fR('u .ti \w' 'u char *\fBustrp_sc_export\fR(struct Ustr_pool *, const struct Ustr *, void *(*)(size_t)); .br .in \w' int \fBustr_sc_reverse\fR('u .ti \w' 'u int \fBustr_sc_reverse\fR(struct Ustr **); .br .in \w' int \fBustr_sc_tolower\fR('u .ti \w' 'u int \fBustr_sc_tolower\fR(struct Ustr **); .br .in \w' int \fBustr_sc_toupper\fR('u .ti \w' 'u int \fBustr_sc_toupper\fR(struct Ustr **); .br .in \w' int \fBustr_sc_ltrim_chrs\fR('u .ti \w' 'u int \fBustr_sc_ltrim_chrs\fR(struct Ustr **, const char *, size_t); .br .in \w' int \fBustr_sc_ltrim\fR('u .ti \w' 'u int \fBustr_sc_ltrim\fR(struct Ustr **, const struct Ustr *); .br .in \w' int \fBustr_sc_ltrim_cstr\fR('u .ti \w' 'u int \fBustr_sc_ltrim_cstr\fR(struct Ustr **, const char *); .br .in \w' int \fBustr_sc_rtrim_chrs\fR('u .ti \w' 'u int \fBustr_sc_rtrim_chrs\fR(struct Ustr **, const char *, size_t); .br .in \w' int \fBustr_sc_rtrim\fR('u .ti \w' 'u int \fBustr_sc_rtrim\fR(struct Ustr **, const struct Ustr *); .br .in \w' int \fBustr_sc_rtrim_cstr\fR('u .ti \w' 'u int \fBustr_sc_rtrim_cstr\fR(struct Ustr **, const char *); .br .in \w' int \fBustr_sc_trim_chrs\fR('u .ti \w' 'u int \fBustr_sc_trim_chrs\fR(struct Ustr **, const char *, size_t); .br .in \w' int \fBustr_sc_trim\fR('u .ti \w' 'u int \fBustr_sc_trim\fR(struct Ustr **, const struct Ustr *); .br .in \w' int \fBustr_sc_trim_cstr\fR('u .ti \w' 'u int \fBustr_sc_trim_cstr\fR(struct Ustr **, const char *); .sp .br .in \w' int \fBustr_add_b_uint16\fR('u .ti \w' 'u int \fBustr_add_b_uint16\fR(struct Ustr **, uint_least16_t); .br .in \w' int \fBustr_add_b_uint32\fR('u .ti \w' 'u int \fBustr_add_b_uint32\fR(struct Ustr **, uint_least32_t); .br .in \w' int \fBustr_add_b_uint64\fR('u .ti \w' 'u int \fBustr_add_b_uint64\fR(struct Ustr **, uint_least64_t); .sp .br .in \w' uint_least16_t \fBustr_parse_b_uint16\fR('u .ti \w' 'u uint_least16_t \fBustr_parse_b_uint16\fR(const struct Ustr *, size_t); .br .in \w' uint_least32_t \fBustr_parse_b_uint32\fR('u .ti \w' 'u uint_least32_t \fBustr_parse_b_uint32\fR(const struct Ustr *, size_t); .br .in \w' uint_least64_t \fBustr_parse_b_uint64\fR('u .ti \w' 'u uint_least64_t \fBustr_parse_b_uint64\fR(const struct Ustr *, size_t); .sp .br .in \w' int \fBustr_realloc\fR('u .ti \w' 'u int \fBustr_realloc\fR(struct Ustr **, size_t); .br .in \w' int \fBustr_cntl_opt\fR('u .ti \w' 'u int \fBustr_cntl_opt\fR(int, ...); .sp .br .in \w' struct Ustr_pool *\fBustr_pool_ll_make\fR('u .ti \w' 'u struct Ustr_pool *\fBustr_pool_ll_make\fR(void); .br .in \w' struct Ustr_pool *\fBustr_pool_make_subpool\fR('u .ti \w' 'u struct Ustr_pool *\fBustr_pool_make_subpool\fR(struct Ustr_pool *); .br .in \w' void \fBustr_pool_free\fR('u .ti \w' 'u void \fBustr_pool_free\fR(struct Ustr_pool *); .br .in \w' void \fBustr_pool_clear\fR('u .ti \w' 'u void \fBustr_pool_clear\fR(struct Ustr_pool *); .ti .SH "DESCRIPTION" A very simple overview is that you can use ustr_dup_cstr() to convert a C\-style to a Ustr, and ustr_cstr() to convert it back. You can also use USTR1() to create constant/read\-only strings, and USTR_SC_INIT_AUTO() to create strings that use stack space up to a certain amount. Use is somewhat unique in that, by default, it has an average overhead of only 55% overhead over strdup(), for strings in the range of 0 to 20 bytes. Or, to put it another way it only uses 8 bytes to store a 2 byte string where strdup() uses 3. .SH Creating read\-only Ustr functions .ti -2 .br \fBFunction: \fR USTR() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to Ustr data .br Type\fB[1]\fR: void * .br \fBExplanation:\fR .br This macro function is normally used with the empty string "". .sp \fBNote:\fR .br There is basically just a simple cast behind the macro. .ti -2 .br \fBFunction: \fR USTRP() .br Returns: Ustrp string .br Type: struct Ustrp * .br Parameter\fB[1]\fR: Pointer to Ustrp data .br Type\fB[1]\fR: void * .br \fBExplanation:\fR .br This macro function is normally used with the empty string "". .sp \fBNote:\fR .br There is basically just a simple cast behind the macro. .ti -2 .br \fBFunction: \fR USTR1() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Data for Ustr string .br Type\fB[2]\fR: const char[] .br \fBExplanation:\fR .br This macro function simplifies the creation of read\-only Ustr string's. And is normally used like... USTR1(\\x4, "abcd") ...it is worth pointing out that running with debugging turned on (USTR_CONF_USE_ASSERT) will complain if the length isn't encoded correctly, as in... USTR1(\\x3, "abcd") ...here ustr_assert_valid() will fail, which is called before most functions do anything in debugging mode. Note also that extra debugging (USTR_CONF_USE_EOS_MARK) will still catch cases like... USTR1(\\x3, "abc\\0d") ...at least using debugging is esp. important if you are putting UTF\-8 characters into the strings. .sp \fBNote:\fR .br Having ustr_ro() return true means that the Ustr cannot be written to without be reallocated into allocation space ... not that ustr_add() etc. will fail. .br There is now USTR1_CHK() which performs a compile time check so you can never have an invalid ustr. .ti -2 .br \fBFunction: \fR USTR2() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded 2nd byte of number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 1st byte of number of the length of Ustr string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Data for Ustr string .br Type\fB[3]\fR: const char[] .br \fBExplanation:\fR .br This function works in the same way as USTR1() but takes two length bytes, so the read\-only string can be up to 65,535 (2**16 \- 1) bytes in length. .ti -2 .br \fBFunction: \fR USTR4() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded 4th byte of number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 3rd byte of number of the length of Ustr string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Encoded 2nd byte of number of the length of Ustr string .br Type\fB[3]\fR: symbol .br Parameter\fB[4]\fR: Encoded 1st byte of number of the length of Ustr string .br Type\fB[4]\fR: symbol .br Parameter\fB[5]\fR: Data for Ustr string .br Type\fB[5]\fR: const char[] .br \fBExplanation:\fR .br This function works in the same way as USTR1() but takes four length bytes, so the read\-only string can be up to 2**32 \- 1 bytes in length. .ti -2 .br \fBFunction: \fR USTR1_CHK() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Data for Ustr string .br Type\fB[2]\fR: const char[] .br \fBExplanation:\fR .br This function works in the same way as USTR1() but it does a check against the length of (Parameter[2]) using sizeof() \- 1. .sp \fBNote:\fR .br If the check fails the returned Ustr * will be "", so you can check ustr_len() to see if you screwed something up. .ti -2 .br \fBFunction: \fR USTR2_CHK() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded 2nd byte of number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 1st byte of number of the length of Ustr string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Data for Ustr string .br Type\fB[3]\fR: const char[] .br \fBExplanation:\fR .br This function works in the same way as USTR2() but it does a check against the length of (Parameter[2]) using sizeof() \- 1. .sp \fBNote:\fR .br If the check fails the returned Ustr * will be "". .ti -2 .br \fBFunction: \fR USTR4_CHK() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded 4th byte of number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 3rd byte of number of the length of Ustr string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Encoded 2nd byte of number of the length of Ustr string .br Type\fB[3]\fR: symbol .br Parameter\fB[4]\fR: Encoded 1st byte of number of the length of Ustr string .br Type\fB[4]\fR: symbol .br Parameter\fB[5]\fR: Data for Ustr string .br Type\fB[5]\fR: const char[] .br \fBExplanation:\fR .br This function works in the same way as USTR4() but it does a check against the length of (Parameter[2]) using sizeof() \- 1. .sp \fBNote:\fR .br If the check fails the returned Ustr * will be "". .ti -2 .br \fBFunction: \fR USTRP1() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Data for Ustr string .br Type\fB[2]\fR: const char[] .br \fBExplanation:\fR .br This function works like USTR1(), but returns a Ustrp instead. .ti -2 .br \fBFunction: \fR USTRP2() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded 2nd byte of number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 1st byte of number of the length of Ustr string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Data for Ustr string .br Type\fB[3]\fR: const char[] .br \fBExplanation:\fR .br This function works like USTR4(), but returns a Ustrp instead. .ti -2 .br \fBFunction: \fR USTRP4() .br Returns: Ustrp string .br Type: struct Ustrp * .br Parameter\fB[1]\fR: Encoded 4th byte of number of the length of Ustrp string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 3rd byte of number of the length of Ustrp string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Encoded 2nd byte of number of the length of Ustrp string .br Type\fB[3]\fR: symbol .br Parameter\fB[4]\fR: Encoded 1st byte of number of the length of Ustrp string .br Type\fB[4]\fR: symbol .br Parameter\fB[5]\fR: Data for Ustr string .br Type\fB[5]\fR: const char[] .br \fBExplanation:\fR .br This function works like USTR2(), but returns a Ustrp instead. .ti -2 .br \fBFunction: \fR USTRP1_CHK() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Data for Ustr string .br Type\fB[2]\fR: const char[] .br \fBExplanation:\fR .br This function works like USTR1_CHK(), but returns a Ustrp instead. .ti -2 .br \fBFunction: \fR USTRP2_CHK() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Encoded 2nd byte of number of the length of Ustr string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 1st byte of number of the length of Ustr string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Data for Ustr string .br Type\fB[3]\fR: const char[] .br \fBExplanation:\fR .br This function works like USTR4_CHK(), but returns a Ustrp instead. .ti -2 .br \fBFunction: \fR USTRP4_CHK() .br Returns: Ustrp string .br Type: struct Ustrp * .br Parameter\fB[1]\fR: Encoded 4th byte of number of the length of Ustrp string .br Type\fB[1]\fR: symbol .br Parameter\fB[2]\fR: Encoded 3rd byte of number of the length of Ustrp string .br Type\fB[2]\fR: symbol .br Parameter\fB[3]\fR: Encoded 2nd byte of number of the length of Ustrp string .br Type\fB[3]\fR: symbol .br Parameter\fB[4]\fR: Encoded 1st byte of number of the length of Ustrp string .br Type\fB[4]\fR: symbol .br Parameter\fB[5]\fR: Data for Ustr string .br Type\fB[5]\fR: const char[] .br \fBExplanation:\fR .br This function works like USTR2_CHK(), but returns a Ustrp instead. .SH Creating fixed Ustr functions .ti -2 .br \fBFunction: \fR USTR_SIZE_FIXED() .br Returns: Size of area of memory .br Type: size_t .br Parameter\fB[1]\fR: Size of area of memory .br Type\fB[1]\fR: size_t .br \fBExplanation:\fR .br This macro function is replaced by a static conversion from the max length desired (Parameter[1]) to the storage size needed. In other words it works out what ustr_size_overhead() will be, and adds that value. .sp \fBNote:\fR .br This is useful is you want a small fixed size allocation, as you can declare it like so: .br char buf[USTR_SIZE_FIXED(4)]; ...to give you exactly 4 bytes as a maximum, this is esp. useful if you want a limited (ustr_limited() == USTR_TRUE) Ustr string. .ti -2 .br \fBFunction: \fR ustr_init_fixed() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to area of memory to use as a Ustr string .br Type\fB[1]\fR: void * .br Parameter\fB[2]\fR: Size of area of memory .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Whether the fixed size Ustr should be limited .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: The initial length of the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This creates a new Ustr string, which is "fixed". This means the Ustr storage is managed outside of the ustr_* API, it is often used for stack allocated strings. .br As you add data to the Ustr past the size allowed via. the fixed storge the Ustr will automatically be converted into an allocated Ustr. So if this is possible you should always call ustr_free(), as this does nothing if given a fixed size Ustr. .sp \fBNote:\fR .br For simplicity you probably want to use USTR_SC_INIT_AUTO() or USTR_SC_INIT_AUTO() when possible. .ti -2 .br \fBFunction: \fR USTR_SC_INIT_AUTO() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Area of memory to use as a Ustr string .br Type\fB[1]\fR: char[] .br Parameter\fB[2]\fR: Whether the fixed size Ustr should be limited .br Type\fB[2]\fR: int .br Parameter\fB[3]\fR: The initial length of the Ustr .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This calls ustr_init_fixed() with sizeof() the area of memory (Parameter[1]) as the second argument. .sp \fBNote:\fR .br This does mean that the first argument must be the correct size, as far as sizeof() is concerned, as in... char buf_sz[1024]; Ustr *s1 = USTR_SC_INIT_AUTO(buf_sz, USTR_FALSE, 0); ...so passing pointers to memory from malloc() will probably just return NULL. .ti -2 .br \fBFunction: \fR USTR_SC_INIT_AUTO_OSTR() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Area of memory to use as a Ustr string .br Type\fB[1]\fR: char[] .br Parameter\fB[2]\fR: Whether the fixed size Ustr should be limited .br Type\fB[2]\fR: int .br Parameter\fB[3]\fR: The initial string in the buffer, as a constant string .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This calls ustr_init_fixed() with sizeof() the area of memory (Parameter[1]) as the second argument, given as an "object string". .sp \fBNote:\fR .br This does mean that the first argument must be the correct size, as far as sizeof() is concerned, as in... char buf_sz[1024] = USTR_BEG_FIXED2 "abcd"; Ustr *s1 = USTR_SC_INIT_AUTO_OSTR(buf_sz, USTR_FALSE, "abcd"); ...so passing pointers to memory from malloc() will probably just return NULL. .SH Debugging functions .ti -2 .br \fBFunction: \fR ustr_assert_valid() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a Ustr string .br Type\fB[1]\fR: Ustr * .br \fBExplanation:\fR .br This function asserts a few internal consistency checks, and can help point out when a Ustr is invalid. .sp \fBNote:\fR .br This calls ustr_assert_ret() so that when USTR_DEBUG if off the checks are still performed and the result is returned. .ti -2 .br \fBFunction: \fR ustr_assert_valid_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a Ustr string .br Type\fB[1]\fR: Ustr * .br Parameter\fB[2]\fR: Position in the Ustr .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length to delete from the Ustr .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function calls ustr_assert_valid() and also checks that the position and length are within the Ustr. If they aren't valid it returns 0, if they are valid it returns ustr_len(). .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_BEG() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Condition for begin malloc checking or not .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This function begins malloc checking, meaning all ustr allocations will go through the malloc check routines, but it fails if the condition check (Parameter[1]) fails. .sp \fBNote:\fR .br Turning malloc checking on after one or more allocations has happened will lead to false failures unless you really known what you are doing. .br You can automatically turn malloc checking on by giving the USTR_CNTL_MC environment variable the value of "1", "yes" or "on". .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_LVL() .br Returns: Level of current malloc check .br Type: int .br Parameter\fB[1]\fR: Nothing .br Type\fB[1]\fR: void .br \fBExplanation:\fR .br This function returns the current "level" of the malloc check, with 0 indicating that malloc check isn't enabled. .br The level goes up by one whenever USTR_CNTL_MALLOC_CHECK_BEG() or USTR_CNTL_MALLOC_CHECK_ADD() returns success, and goes down by one whenever USTR_CNTL_MALLOC_CHECK_DEL() or USTR_CNTL_MALLOC_CHECK_END() returns success. .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_MEM() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer returned from malloc check .br Type\fB[1]\fR: void * .br \fBExplanation:\fR .br This function asserts that the pointer (Parameter[1]) was allocated from malloc checking. .sp \fBNote:\fR .br Unless you are doing something special, or using a builtin Ustr_pool it is very likely you want to just call USTR_CNTL_MALLOC_CHECK_MEM_USTR(). .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_MEM_SZ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer returned from malloc check .br Type\fB[1]\fR: void * .br Parameter\fB[2]\fR: Length of allocated memory .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function asserts that the pointer (Parameter[1]) was allocated from malloc checking, and has the specified size (Parameter[2]). .sp \fBNote:\fR .br Unless you are doing something special, or using a builtin Ustr_pool it is very likely you want to just call USTR_CNTL_MALLOC_CHECK_MEM_USTR(). .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_MEM_MINSZ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer returned from malloc check .br Type\fB[1]\fR: void * .br Parameter\fB[2]\fR: Length of allocated memory .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function asserts that the pointer (Parameter[1]) was allocated from malloc checking, and has at least the specified size (Parameter[2]). .sp \fBNote:\fR .br Unless you are doing something special, or using a builtin Ustr_pool it is very likely you want to just call USTR_CNTL_MALLOC_CHECK_MEM_USTR(). .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_MEM_USTR() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a Ustr string .br Type\fB[1]\fR: Ustr * .br \fBExplanation:\fR .br This function asserts that the pointer (Parameter[1]) is a Ustr allocated from malloc checking, if the Ustr is allocated (if not it returns TRUE). .sp \fBNote:\fR .br Because of the layering between the Ustr code and the pool code, if you allocate an implicitly sized Ustrp from a pool and then delete some data from it (which fails) the Ustr layer will think it has an implicit less than the actual size so this function will fail. This is what USTR_CNTL_MALLOC_CHECK_MEM_USTRP() is for. .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_MEM_USTRP() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a Ustrp string .br Type\fB[1]\fR: Ustrp * .br \fBExplanation:\fR .br This function asserts that the pointer (Parameter[1]) is a Ustr allocated from a builtin pool using malloc checking, if the Ustr is allocated (if not it returns TRUE). .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_END() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Nothing .br Type\fB[1]\fR: void .br \fBExplanation:\fR .br This macro will cleanup any memory used by malloc check, and assert that no memory is left allocated. .sp \fBNote:\fR .br If any memory is left allocated, each one found is output to stderr with the file/line/function of the level it was allocated from. .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_ADD() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Condition to begin malloc checking or not .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This function works like USTR_CNTL_MALLOC_CHECK_END() but it fails if the condition check (Parameter[1]) fails, or if USTR_CNTL_MALLOC_CHECK_LVL() is zero. .ti -2 .br \fBFunction: \fR USTR_CNTL_MALLOC_CHECK_DEL() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Condition to end malloc checking or not .br Type\fB[1]\fR: int .br \fBExplanation:\fR .br This function works like USTR_CNTL_MALLOC_CHECK_END() but it fails if the condition check (Parameter[1]) fails, or if USTR_CNTL_MALLOC_CHECK_LVL() is one. .sp \fBNote:\fR .br The condition (Parameter[1]) to this macro should almost certainly be the return value from USTR_CNTL_MALLOC_CHECK_ADD(). .SH Creating allocated Ustr functions .ti -2 .br \fBFunction: \fR ustr_init_size() .br Returns: Size that needs to be allocated .br Type: size_t .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: Length of data in the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function finds out the exact size of memory needed to store the specified Ustr of the given configuration. .ti -2 .br \fBFunction: \fR ustr_init_alloc() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to area of memory to use as a Ustr string .br Type\fB[1]\fR: void * .br Parameter\fB[2]\fR: Size of area of memory .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Whether Ustr should store the size .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Number of bytes to use for references .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Whether the Ustr should use exact allocations .br Type\fB[5]\fR: int .br Parameter\fB[6]\fR: Whether the Ustr should have the "enomem" flag set .br Type\fB[6]\fR: int .br Parameter\fB[7]\fR: The initial length of the Ustr .br Type\fB[7]\fR: size_t .br \fBExplanation:\fR .br This creates a new Ustr string, you should have allocated the data via. USTR_CONF_MALLOC() or bad things will happen if the Ustr string is ever free'd or reallocated. .ti -2 .br \fBFunction: \fR ustr_dupx_empty() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocation flag .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br \fBExplanation:\fR .br This function creates an empty Ustr, owned by you, that is allocated from system memory, or it returns NULL. .br The size is the desired allocation size for the entire Ustr, including overhead for metadata. This value will be rounded up, if it's too small, so passing 1 as the size means you want a stored size but to allocate the smallest amount of memory possible. .br The exact memory allocation flag says if the Ustr should round allocations up to the nearest half power of two or should be no more than needed. .br The ENOMEM memory error flag sets the iniital state of the user visible flag for memory allocation errors. Eg. ustr_enomem(), ustr_setf_enomem_clr() and ustr_setf_enomem_err() .sp \fBNote:\fR .br The reference byte count can only be one of the following values: 0, 1, 2 or 4, or 8 (on environments with a 64bit size_t). .br It can be useful to ensure that the Ustr is in system memory, so that you can add things to it and check for errors with ustr_enomem(). .br If you chose to store the allocated size in the Ustr then the number of bytes allocated for the reference count will be a minimum of 2. .ti -2 .br \fBFunction: \fR ustr_dup_empty() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Nothing .br Type\fB[1]\fR: void .br \fBExplanation:\fR .br This function is the same as calling ustr_dupx_empty() with the current set of default options. .ti -2 .br \fBFunction: \fR ustr_dupx_undef() .br Returns: Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Length of new undefined data .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function works like you called ustr_dupx_empty() and then ustr_add_undef(). .ti -2 .br \fBFunction: \fR ustr_dup_undef() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Length of new undefined data .br Type\fB[1]\fR: size_t .br \fBExplanation:\fR .br This function is the same as calling ustr_dupx_undef() with the current set of default options. .ti -2 .br \fBFunction: \fR ustr_dup() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function tries to increase the reference count on the passed Ustr string, and if that succeeds returns that as an argument. If that fails it tries creates a new Ustr string that looks identical to the old Ustr string, apart from the reference count. .sp \fBNote:\fR .br Because the new Ustr string is configured identically to the old Ustr string this means the result can be very different to what you get if you call ustr_dup_buf() with ustr_cstr() and ustr_len() from the original string where the configuration would be whatever the default is. .br Esp. worth of note is that if you ustr_dup() a Ustr string with an explicit size of 900 but a length of 1, and the reference count is full the returned Ustr string will have a size of 900 bytes and so will have allocated a little over that. ustr_dup_buf(), even with a sized configuration would only allocate about 12 bytes and have a size a little less than that. .ti -2 .br \fBFunction: \fR ustr_dupx() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Pointer to a constant Ustr string .br Type\fB[5]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function tries to add a reference if the value of the size, reference bytes, exact memory allocations and ENOMEM are the same as those in the passed Ustr string (Parameter[5]). If the comparison fails or the addition of a reference fails it works like ustr_dupx_buf() using ustr_cstr() and ustr_len(). .ti -2 .br \fBFunction: \fR ustr_sc_dup() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function works like calling ustr_dup(), but if the reference count is maxed out then and so a new Ustr string has been allocated then that is stored in the passed argument (Parameter[1]) and the "old" Ustr string is returned. .sp \fBNote:\fR .br The reason to use this is that if you have a "main" Ustr string pointer that a lot of things are getting references too then when the reference count maxes out you'll degrade into worst case behaviour which acts as though there are no reference counts. This function stops that problem. .br As an example, if you have a 1 byte reference count and have 255 * 2 references then using ustr_dup() will create 256 Ustr strings using this function will create 4 Ustr strings. .ti -2 .br \fBFunction: \fR ustr_sc_dupx() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: A pointer to a pointer to a Ustr string .br Type\fB[5]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function works like calling ustr_dupx(), but if the reference count is maxed out then and so a new Ustr string is allocated then that is stored in the passed argument (Parameter[1]) and the "old" Ustr string is returned. .br If the configurations of the new Ustr string and the old Ustr string are not the same, this function works identically to ustr_dupx(). .sp \fBNote:\fR .br The reason to use this is that if you have a "main" Ustr string pointer that a lot of things are getting references too then when the reference count maxes out you'll degrade into worst case behaviour which acts as though there are no reference counts. This function stops that problem. .br As an example, if you have a 1 byte reference count and have 255 * 2 references then using ustr_dupx() will create 256 Ustr strings using this function will create 4 Ustr strings. .ti -2 .br \fBFunction: \fR ustr_dup_buf() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to data .br Type\fB[1]\fR: const void * .br Parameter\fB[2]\fR: Length of data .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_dup_undef() and then copied the data into the new undefined space. .ti -2 .br \fBFunction: \fR ustr_dupx_buf() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Pointer to data .br Type\fB[5]\fR: const void * .br Parameter\fB[6]\fR: Length of data .br Type\fB[6]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_dupx_undef() and then copied the data into the new undefined space. .ti -2 .br \fBFunction: \fR ustr_dup_cstr() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to constant C\-style string .br Type\fB[1]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_dup_buf() and passed strlen() as the length. .ti -2 .br \fBFunction: \fR ustr_dupx_cstr() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Pointer to constant C\-style string .br Type\fB[5]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_dupx_buf() and passed strlen() as the length. .ti -2 .br \fBFunction: \fR USTR_DUP_OSTR() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: A constant C\-style string .br Type\fB[1]\fR: const char [] .br \fBExplanation:\fR .br This function works as if you had called ustr_dup_buf() and passed sizeof() \- 1 as the length. .ti -2 .br \fBFunction: \fR USTR_DUP_OBJ() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: A symbol .br Type\fB[1]\fR: ... .br \fBExplanation:\fR .br This function works as if you had called ustr_dup_buf() and passed sizeof() as the length. .sp \fBNote:\fR .br In most cases you'll want to use USTR_DUP_OSTR(). .ti -2 .br \fBFunction: \fR ustr_dup_subustr() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Position in the Ustr .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length to add from the Ustr .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function mostly works as if you had called ustr_dup_buf() with the ustr_cstr() + position \- 1 and length values of the Ustr string to be added. .sp \fBNote:\fR .br If the position is 1 and the length is the length of the Ustr string then it just calls ustr_dup(). .ti -2 .br \fBFunction: \fR ustr_dupx_subustr() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: A pointer to a constant Ustr string .br Type\fB[5]\fR: const struct Ustr * .br Parameter\fB[6]\fR: Position in the Ustr .br Type\fB[6]\fR: size_t .br Parameter\fB[7]\fR: Length to add from the Ustr .br Type\fB[7]\fR: size_t .br \fBExplanation:\fR .br This function mostly works as if you had called ustr_dupx_buf() with the ustr_cstr() + position \- 1 and length values of the Ustr string to be added. .sp \fBNote:\fR .br If the position is 1 and the length is the length of the Ustr string then it just calls ustr_dupx(). .ti -2 .br \fBFunction: \fR ustr_dup_rep_chr() .br Returns: A pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Byte value of data .br Type\fB[1]\fR: char .br Parameter\fB[2]\fR: Length of bytes as data .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_dup_undef() and then copied the byte value to each position. .ti -2 .br \fBFunction: \fR ustr_dupx_rep_chr() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Byte value of data .br Type\fB[5]\fR: char .br Parameter\fB[6]\fR: Length of bytes as data .br Type\fB[6]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_dupx_undef() and then copied the byte value to each position. .ti -2 .br \fBFunction: \fR ustr_sc_vjoin() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Separator to go between Ustr strings .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to the first constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: A pointer to the second constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Variable argument list variable, from va_start() .br Type\fB[4]\fR: va_list .br \fBExplanation:\fR .br This function works as if you called ustr_dup() on the first Ustr string (Parameter[2]), and then ustr_add() on the separator (Parameter[1]) followed by ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. .sp \fBNote:\fR .br This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. .ti -2 .br \fBFunction: \fR ustr_sc_join() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Separator to go between Ustr strings .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to the first constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: A pointer to the second constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Zero or more pointers to constant Ustr strings and then USTR_NULL .br Type\fB[4]\fR: ... .br \fBExplanation:\fR .br This function calls va_start() to get a variable argument list and then calls ustr_sc_vjoin(). .sp \fBNote:\fR .br This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. .ti -2 .br \fBFunction: \fR ustr_sc_vjoinx() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Separator to go between Ustr strings .br Type\fB[5]\fR: const struct Ustr * .br Parameter\fB[6]\fR: A pointer to the first constant Ustr string .br Type\fB[6]\fR: const struct Ustr * .br Parameter\fB[7]\fR: A pointer to the second constant Ustr string .br Type\fB[7]\fR: const struct Ustr * .br Parameter\fB[8]\fR: Variable argument list variable, from va_start() .br Type\fB[8]\fR: va_list .br \fBExplanation:\fR .br This function works as if you called ustr_dupx() on the first Ustr string (Parameter[2]), and then ustr_add() on the separator (Parameter[1]) followed by ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. .sp \fBNote:\fR .br This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. .ti -2 .br \fBFunction: \fR ustr_sc_joinx() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Separator to go between Ustr strings .br Type\fB[5]\fR: const struct Ustr * .br Parameter\fB[6]\fR: A pointer to the first constant Ustr string .br Type\fB[6]\fR: const struct Ustr * .br Parameter\fB[7]\fR: A pointer to the second constant Ustr string .br Type\fB[7]\fR: const struct Ustr * .br Parameter\fB[8]\fR: Zero or more pointers to constant Ustr strings and then USTR_NULL .br Type\fB[8]\fR: ... .br \fBExplanation:\fR .br This function calls va_start() to get a variable argument list and then calls ustr_sc_vjoinx(). .ti -2 .br \fBFunction: \fR ustr_sc_vconcat() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: A pointer to the first constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Variable argument list variable, from va_start() .br Type\fB[2]\fR: va_list .br \fBExplanation:\fR .br This function works as if you called ustr_dup() on the first Ustr string (Parameter[1]), and then ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. .sp \fBNote:\fR .br This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. .ti -2 .br \fBFunction: \fR ustr_sc_concat() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: A pointer to the first constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Zero or more pointers to constant Ustr strings and then USTR_NULL .br Type\fB[2]\fR: ... .br \fBExplanation:\fR .br This function calls va_start() to get a variable argument list and then calls ustr_sc_vconcat(). .ti -2 .br \fBFunction: \fR ustr_sc_vconcatx() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: A pointer to the first constant Ustr string .br Type\fB[5]\fR: const struct Ustr * .br Parameter\fB[6]\fR: Variable argument list variable, from va_start() .br Type\fB[6]\fR: va_list .br \fBExplanation:\fR .br This function works as if you called ustr_dupx() on the first Ustr string (Parameter[1]), and then ustr_add() on the second Ustr string (Parameter[3]). This process then repeats for all the Ustr strings in the variable argument list (Parameter[4]) until a USTR_NULL is reached. .sp \fBNote:\fR .br This function doesn't guarantee to just take a reference to one of the passed Ustr strings, even if that is what would happen if you called the above manually. .ti -2 .br \fBFunction: \fR ustr_sc_concatx() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: A pointer to the first constant Ustr string .br Type\fB[5]\fR: const struct Ustr * .br Parameter\fB[6]\fR: Zero or more pointers to constant Ustr strings and then USTR_NULL .br Type\fB[6]\fR: ... .br \fBExplanation:\fR .br This function calls va_start() to get a variable argument list and then calls ustr_sc_vconcatx(). .SH Deleting a Ustr, or data within a Ustr .ti -2 .br \fBFunction: \fR ustr_free() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: Pointer to a Ustr .br Type\fB[1]\fR: struct Ustr * .br \fBExplanation:\fR .br This function decrements the reference count on a Ustr, if there is one, and free's it if it is allocated and the reference count becomes zero. .sp \fBNote:\fR .br This function does nothing if passed USTR_NULL. .ti -2 .br \fBFunction: \fR ustrp_free() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: Pointer to a Ustr pool object .br Type\fB[1]\fR: struct Ustr_pool * .br Parameter\fB[2]\fR: Pointer to a Ustrp (pool allocated Ustr) .br Type\fB[2]\fR: struct Ustrp * .br \fBExplanation:\fR .br This function works like ustr_free() but calls the pool_free member function of the Ustr_pool (Parameter[1]) instead of the ustr system free. .ti -2 .br \fBFunction: \fR ustr_sc_free() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function calls ustr_free() and then sets the pointer (Parameter[1]) to USTR_NULL, which is a noop when passed to ustr_free(). This can be used to help prevent "double free" errors. .sp \fBNote:\fR .br While the point to the pointer must be non\-NULL, this function also accepts a NULL ustr and does nothing. So you can pass the same pointer to this function multiple times and only the first one will do anything. .ti -2 .br \fBFunction: \fR ustr_sc_free2() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Pointer to a Ustr string .br Type\fB[2]\fR: struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_sc_free() but instead of setting the pointer (Parameter[1]) to USTR_NULL it sets it to the Ustr string (Parameter[2]). .sp \fBNote:\fR .br While the point to the pointer must be non\-NULL, this function also accepts a NULL ustr to be free'd and does nothing. So you can pass the same pointer to ustr_sc_free() and then this function safely. .br The passed value (Parameter[2]) shouldn't be USTR_NULL, and in debugging mode the function will assert() that it isn't. .ti -2 .br \fBFunction: \fR ustr_sc_free_shared() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function is a simple way to "free" a Ustr string that has been shared (ustr_shared() returns USTR_TRUE), normally ustr_free() is ignored on a shared Ustr string. It just calls ustr_setf_owner() and then ustr_sc_free(). .ti -2 .br \fBFunction: \fR ustr_del() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Length to delete from the Ustr .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function deletes data from the end of Ustr, possibly re\-sizing the Ustr at the same time. .sp \fBNote:\fR .br The Ustr is never re\-sized when the size is stored explicitly, so the pointer never changes. .ti -2 .br \fBFunction: \fR ustr_del_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position in the Ustr .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length to delete from the Ustr .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_del() but can delete an arbitrary section of the Ustr. .ti -2 .br \fBFunction: \fR ustr_sc_del() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function is like calling ustr_del() with ustr_len() as the length, however if that fails it does a ustr_free() and then sets the pointer to USTR(""). .sp \fBNote:\fR .br While the benefit is that you don't have to check for memory failure errors, if there is a memory failure and you have a non\-default configuration the configuration will revert back to the default. .SH Adding data to a Ustr .ti -2 .br \fBFunction: \fR ustr_add_undef() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Length of new undefined data .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br The Ustr string is expanded (possibly reallocated) so that it can contain length (Parameter[2]) extra data, if the length is not zero the Ustr will be writable. Or it'll return USTR_FALSE (zero) on failure. .ti -2 .br \fBFunction: \fR ustr_add_buf() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Pointer to data .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_add_undef() and then copied the data into the new undefined space. .ti -2 .br \fBFunction: \fR ustr_add_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Pointer to constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_add_buf() and passed strlen() as the length. .ti -2 .br \fBFunction: \fR USTR_ADD_OSTR() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A constant C\-style string .br Type\fB[2]\fR: const char [] .br \fBExplanation:\fR .br This function works as if you had called ustr_add_buf() and passed sizeof() \- 1 as the length. .ti -2 .br \fBFunction: \fR USTR_ADD_OBJ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A symbol .br Type\fB[2]\fR: ... .br \fBExplanation:\fR .br This function works as if you had called ustr_add_buf() and passed sizeof() as the length. .sp \fBNote:\fR .br In most cases you'll want to use USTR_ADD_OSTR(). .ti -2 .br \fBFunction: \fR ustr_add() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function mostly works as if you had called ustr_add_buf() with the ustr_cstr() and ustr_len() values of the Ustr string to be added. .sp \fBNote:\fR .br If the Ustr string is zero length and isn't writable this function may just add a reference, this is fine for Ustr strings that are "constant" because if the Ustr is read\-only then the memory will not be written to. .ti -2 .br \fBFunction: \fR ustr_add_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to add from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function mostly works as if you had called ustr_add_buf() with the ustr_cstr() + position \- 1 and length values of the Ustr string to be added. The exception being if you add a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr, but this function just works. .sp \fBNote:\fR .br If the position is 1 and the length is the length of the Ustr string then it just calls ustr_add(). .ti -2 .br \fBFunction: \fR ustr_add_rep_chr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Byte value of data .br Type\fB[2]\fR: char .br Parameter\fB[3]\fR: Length of bytes as data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_add_undef() and then copied the byte value to each position. .SH Setting a Ustr to some data .ti -2 .br \fBFunction: \fR ustr_set_undef() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: size_t .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and the ustr_add_undef(). .ti -2 .br \fBFunction: \fR ustr_set_empty() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string, however the string will be allocated if this completes. .ti -2 .br \fBFunction: \fR ustr_set_buf() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Buffer containing data .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of Buffer .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and the ustr_add_buf(). .ti -2 .br \fBFunction: \fR ustr_set_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and then ustr_add_cstr(). .ti -2 .br \fBFunction: \fR USTR_SET_OSTR() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A constant C\-style string .br Type\fB[2]\fR: const char [] .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and then USTR_ADD_OSTR(). .ti -2 .br \fBFunction: \fR USTR_SET_OBJ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A symbol .br Type\fB[2]\fR: ... .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and then USTR_ADD_OBJ(). .sp \fBNote:\fR .br In most cases you'll want to use USTR_SET_OSTR(). .ti -2 .br \fBFunction: \fR ustr_set() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and the ustr_add(). .ti -2 .br \fBFunction: \fR ustr_set_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to set from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and the ustr_add_subustr(). The exception being if you set a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr data, but this function just works. .ti -2 .br \fBFunction: \fR ustr_set_rep_chr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Byte value of data .br Type\fB[2]\fR: char .br Parameter\fB[3]\fR: Length of bytes as data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_del() for the entire string and the ustr_add_rep_chr(). .SH Inserting data into a Ustr .ti -2 .br \fBFunction: \fR ustr_ins_undef() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of new undefined data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br The Ustr string is expanded (possibly reallocated) so that it can contain length (Parameter[2]) extra data, from after the required position. If the length is not zero the Ustr will be writable. Or it'll return USTR_FALSE (zero) on failure. The data in the Ustr is moved as needed to put the new data at position (Parameter[2]) + 1. .ti -2 .br \fBFunction: \fR ustr_ins_buf() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Pointer to data .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of data .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_ins_undef() and then copied the data into the new undefined space. .ti -2 .br \fBFunction: \fR ustr_ins_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Pointer to constant C\-style string .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_ins_buf() and passed strlen() as the length. .ti -2 .br \fBFunction: \fR USTR_INS_OSTR() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A constant C\-style string .br Type\fB[3]\fR: const char [] .br \fBExplanation:\fR .br This function works as if you had called ustr_ins_buf() and passed sizeof() \- 1 as the length. .ti -2 .br \fBFunction: \fR USTR_INS_OBJ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A symbol .br Type\fB[3]\fR: ... .br \fBExplanation:\fR .br This function works as if you had called ustr_ins_buf() and passed sizeof() as the length. .sp \fBNote:\fR .br In most cases you'll want to use USTR_INS_OSTR(). .ti -2 .br \fBFunction: \fR ustr_ins() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_ins_buf() with the ustr_cstr() and ustr_len() values of the Ustr string to be added. .ti -2 .br \fBFunction: \fR ustr_ins_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to ins from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function mostly as if you had called ustr_ins_buf() with the ustr_cstr() + position \- 1 and length values of the Ustr string to be insed. The exception being if you insert a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr data, but this function just works. .ti -2 .br \fBFunction: \fR ustr_ins_rep_chr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[2]\fR: Byte value of data .br Type\fB[2]\fR: char .br Parameter\fB[3]\fR: Length of bytes as data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_ins_undef() and then copied the byte value to each position. .SH Adding, duplicating and setting formatted data to a Ustr .ti -2 .br \fBFunction: \fR ustr_add_vfmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Limit of data to add .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Variable argument list variable, from va_start() .br Type\fB[4]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() with the limit (Parameter[2]) as the limit to vsnprintf() and then calling ustr_add_buf(). .ti -2 .br \fBFunction: \fR ustr_add_vfmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Variable argument list variable, from va_start() .br Type\fB[3]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() and then calling ustr_add_buf(). .ti -2 .br \fBFunction: \fR ustr_add_fmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Limit of data to add .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Options depending on value of Parameter[3] .br Type\fB[4]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() with the limit (Parameter[2]) as the limit to snprintf() and then calling ustr_add_buf(). .ti -2 .br \fBFunction: \fR ustr_add_fmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Options depending on value of Parameter[2] .br Type\fB[3]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() and then calling ustr_add_buf(). .ti -2 .br \fBFunction: \fR ustr_dup_vfmt_lim() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Limit of data to dup .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Pointer to a constant Ustr string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Variable argument list variable, from va_start() .br Type\fB[3]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() with the limit (Parameter[2]) as the limit to vsnprintf() and then calling ustr_dup_buf(). .ti -2 .br \fBFunction: \fR ustr_dup_vfmt() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Limit of data to dup .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Pointer to a constant Ustr string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Variable argument list variable, from va_start() .br Type\fB[3]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() and then calling ustr_dup_buf(). .ti -2 .br \fBFunction: \fR ustr_dup_fmt_lim() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Limit of data to dup .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Pointer to a constant Ustr string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Options depending on value of Parameter[2] .br Type\fB[3]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() with the limit (Parameter[2]) as the limit to snprintf() and then calling ustr_dup_buf(). .ti -2 .br \fBFunction: \fR ustr_dup_fmt() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a constant Ustr string .br Type\fB[1]\fR: const char * .br Parameter\fB[2]\fR: Options depending on value of Parameter[1] .br Type\fB[2]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() and then calling ustr_dup_buf(). .ti -2 .br \fBFunction: \fR ustr_dupx_fmt_lim() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Limit of data to dup .br Type\fB[5]\fR: size_t .br Parameter\fB[6]\fR: Pointer to a constant Ustr string .br Type\fB[6]\fR: const char * .br Parameter\fB[7]\fR: Options depending on value of Parameter[6] .br Type\fB[7]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() with the limit (Parameter[2]) as the limit to snprintf() and then calling ustr_dupx_buf(). .ti -2 .br \fBFunction: \fR ustr_dupx_fmt() .br Returns: Pointer to a Ustr string .br Type: struct Ustr * .br Parameter\fB[1]\fR: Size of allocated storage .br Type\fB[1]\fR: size_t .br Parameter\fB[2]\fR: Number of bytes to use for reference count .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Exact memory allocations .br Type\fB[3]\fR: int .br Parameter\fB[4]\fR: ENOMEM, memory error flag .br Type\fB[4]\fR: int .br Parameter\fB[5]\fR: Pointer to a constant Ustr string .br Type\fB[5]\fR: const char * .br Parameter\fB[6]\fR: Options depending on value of Parameter[5] .br Type\fB[6]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() and then calling ustr_dup_bufx(). .ti -2 .br \fBFunction: \fR ustr_set_vfmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Limit of data to set .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Variable argument list variable, from va_start() .br Type\fB[4]\fR: va_list .br \fBExplanation:\fR .br This function works like calling ustr_del() for all the data and then ustr_add_vfmt_lim(). .ti -2 .br \fBFunction: \fR ustr_set_vfmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Variable argument list variable, from va_start() .br Type\fB[3]\fR: va_list .br \fBExplanation:\fR .br This function works like calling ustr_del() for all the data and then ustr_add_vfmt(). .ti -2 .br \fBFunction: \fR ustr_set_fmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Limit of data to set .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Options depending on value of Parameter[3] .br Type\fB[4]\fR: ... .br \fBExplanation:\fR .br This function works like calling ustr_del() for all the data and then ustr_add_fmt_lim(). .ti -2 .br \fBFunction: \fR ustr_set_fmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Options depending on value of Parameter[2] .br Type\fB[3]\fR: ... .br \fBExplanation:\fR .br This function works like calling ustr_del() for all the data and then ustr_add_fmt(). .ti -2 .br \fBFunction: \fR ustr_ins_vfmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Limit of data to insert .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string .br Type\fB[4]\fR: const char * .br Parameter\fB[5]\fR: Variable argument list variable, from va_start() .br Type\fB[5]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() with the limit (Parameter[3]) as the limit to vsnprintf() and then calling ustr_ins_buf(). .ti -2 .br \fBFunction: \fR ustr_ins_vfmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Variable argument list variable, from va_start() .br Type\fB[4]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() and then calling ustr_ins_buf(). .ti -2 .br \fBFunction: \fR ustr_ins_fmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Limit of data to insert .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string .br Type\fB[4]\fR: const char * .br Parameter\fB[5]\fR: Options depending on value of Parameter[4] .br Type\fB[5]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() with the limit (Parameter[3]) as the limit to snprintf() and then calling ustr_ins_buf(). .ti -2 .br \fBFunction: \fR ustr_ins_fmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position after which the data should be added .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Options depending on value of Parameter[3] .br Type\fB[4]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() and then calling ustr_ins_buf(). .ti -2 .br \fBFunction: \fR ustr_sub_vfmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Limit of data to substitute .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string .br Type\fB[4]\fR: const char * .br Parameter\fB[5]\fR: Variable argument list variable, from va_start() .br Type\fB[5]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() with the limit (Parameter[3]) as the limit to vsnprintf() and then calling ustr_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sub_vfmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Variable argument list variable, from va_start() .br Type\fB[4]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() and then calling ustr_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sub_fmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Limit of data to substitute .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string .br Type\fB[4]\fR: const char * .br Parameter\fB[5]\fR: Options depending on value of Parameter[4] .br Type\fB[5]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() with the limit (Parameter[3]) as the limit to snprintf() and then calling ustr_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sub_fmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Options depending on value of Parameter[3] .br Type\fB[4]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() and then calling ustr_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sc_sub_vfmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Limit of data to substitute .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: A pointer to a constant C\-style string .br Type\fB[5]\fR: const char * .br Parameter\fB[6]\fR: Variable argument list variable, from va_start() .br Type\fB[6]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() with the limit (Parameter[4]) as the limit to vsnprintf() and then calling ustr_sc_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sc_sub_vfmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string .br Type\fB[4]\fR: const char * .br Parameter\fB[5]\fR: Variable argument list variable, from va_start() .br Type\fB[5]\fR: va_list .br \fBExplanation:\fR .br This function works like calling the system vsnprintf() and then calling ustr_sc_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sc_sub_fmt_lim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Limit of data to substitute .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: A pointer to a constant C\-style string .br Type\fB[5]\fR: const char * .br Parameter\fB[6]\fR: Options depending on value of Parameter[5] .br Type\fB[6]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() with the limit (Parameter[3]) as the limit to snprintf() and then calling ustr_sc_sub_buf(). .ti -2 .br \fBFunction: \fR ustr_sc_sub_fmt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string .br Type\fB[4]\fR: const char * .br Parameter\fB[5]\fR: Options depending on value of Parameter[5] .br Type\fB[5]\fR: ... .br \fBExplanation:\fR .br This function works like calling the system snprintf() and then calling ustr_sc_sub_buf(). .SH Accessing the "variables" of a Ustr .ti -2 .br \fBFunction: \fR ustr_len() .br Returns: The length of the Ustr .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function returns the length of the data within the Ustr, much like strlen() but without getting the value wrong in the case of extra NIL bytes. .ti -2 .br \fBFunction: \fR ustr_cstr() .br Returns: Read\-only pointer to the start of data in the Ustr .br Type: const char * .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function returns a read\-only pointer to the start of the data of the Ustr string. Due to there always being a terminating NIL byte in a Ustr, this is also a valid C\-style string. .ti -2 .br \fBFunction: \fR ustr_wstr() .br Returns: Writable pointer to the start of data in the Ustr, or NULL .br Type: char * .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: struct Ustr * .br \fBExplanation:\fR .br This function returns a writable pointer to the start of the data of the Ustr string. Due to there always being a terminating NIL byte in a Ustr, this is also a valid C\-style string. .br If the ustr is read\-only (ustr_ro() == USTR_TRUE) then this function will return NULL. .sp \fBNote:\fR .br Unless the string is owned (ustr_owner() == USTR_TRUE) it can be a very bad idea to use this to change data, as then all references will be updated. See ustr_sc_wstr(). .ti -2 .br \fBFunction: \fR ustr_alloc() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr is currently in allocated storage. .ti -2 .br \fBFunction: \fR ustr_exact() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr is doing exact allocations, so as the Ustr grows it will only have storage allocated exactly as required and not in half powers of two. .sp \fBNote:\fR .br This will always be USTR_FALSE for read\-only Ustr strings (ustr_ro() == USTR_TRUE), even though the default may be to used exact sized allocations when adding data to them etc. .ti -2 .br \fBFunction: \fR ustr_sized() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr stores an explicit allocation size, if not the size is implied as the next highest half power of two. .ti -2 .br \fBFunction: \fR ustr_ro() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr is current in read\-only storage. .br Read\-only storage is not writable but can be referenced via. ustr_dup() an infinite number of times. .ti -2 .br \fBFunction: \fR ustr_fixed() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr is current in fixed size storage. .br Fixed size storage is writable but cannot be referenced. .sp \fBNote:\fR .br Fixed size storage always explicitly stores the size of the storage. .ti -2 .br \fBFunction: \fR ustr_enomem() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function just returns the value of the user settable flag in the Ustr. It can be set via. ustr_setf_enomem_err() and cleared by ustr_setf_enomem_clr(). .br This function is automatically set to on whever a memory allocation failure happens for a Ustr. .sp \fBNote:\fR .br If a Ustr is referenced multiple times, ustr_setf_enomem_err() will fail. .br This always fails for Ustr's in read\-only storage. .ti -2 .br \fBFunction: \fR ustr_shared() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr is in the "shared" mode. It can be set via. ustr_setf_shared() and cleared by ustr_setf_owner() on allocated Ustr's. .br Shared mode means that a Ustr can be referenced and unreferenced an infinite number of times. .sp \fBNote:\fR .br This always succeeds for Ustr's in read\-only storage. .br This always fails for Ustr's in fixed size storage. .ti -2 .br \fBFunction: \fR ustr_limited() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if the Ustr is currently in fixed size storage and cannot move to allocated storage. .sp \fBNote:\fR .br This always fails for Ustr's in allocated storage. .br This always fails for Ustr's in read\-only storage. .ti -2 .br \fBFunction: \fR ustr_owner() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function says if there is only a single reference to the Ustr string. .sp \fBNote:\fR .br This always fails for Ustr's in read\-only storage. .br This always succeeds for Ustr's in fixed size storage. .ti -2 .br \fBFunction: \fR ustr_size() .br Returns: size_t .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function calculates the maximum amount of data that could be stored (Ie. the max ustr_len()) without having to re\-size the Ustr string. .ti -2 .br \fBFunction: \fR ustr_size_alloc() .br Returns: size_t .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function returns the size of the storage for the Ustr. .ti -2 .br \fBFunction: \fR ustr_size_overhead() .br Returns: size_t .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function returns the difference between the size of the storage and the maximum amount of data that could be stored without having to re\-size the Ustr string. .ti -2 .br \fBFunction: \fR ustr_conf() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Return size allocated number .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: Return number of bytes used in the reference count .br Type\fB[3]\fR: size_t * .br Parameter\fB[4]\fR: Return exact allocations flag .br Type\fB[4]\fR: int * .br Parameter\fB[5]\fR: Return number of bytes used in the length .br Type\fB[5]\fR: size_t * .br Parameter\fB[5]\fR: Return number of references to this Ustr .br Type\fB[5]\fR: size_t * .br \fBExplanation:\fR .br This function gives the configuration of the current Ustr needed to duplicate it via. the ustr_dupx_*() functions. It also gives the number of bytes used for the length and the number of references, which are mainly informational. .sp \fBNote:\fR .br This function differs from calling the ustr_exact() etc. functions in that it returns the global options if this Ustr isn't allocated, thus telling you what the configuration would be if the Ustr was turned into an allocated Ustr by adding data etc. .br Zero references for an allocated Ustr with a non\-zero number of bytes for a reference count means it's in "shared" mode). .SH Setting the "flags" of a Ustr .ti -2 .br \fBFunction: \fR ustr_setf_enomem_err() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr * .br \fBExplanation:\fR .br This function sets the enomem flag, which can be observed via. the ustr_enomem() function. .br The implication of setting this flag is that a memory error has occurred in a previous function call on this Ustr. .sp \fBNote:\fR .br This function fails if ustr_owner() fails for the Ustr. .ti -2 .br \fBFunction: \fR ustr_setf_enomem_clr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr * .br \fBExplanation:\fR .br This function clears the enomem flag, which can be observed via. the ustr_enomem() function. .br The implication of this flag being set is that a memory error has occurred in a previous function call on this Ustr, so on clearing the flag you should know you have brought the Ustr back to a known state. .sp \fBNote:\fR .br This function fails if ustr_owner() fails for the Ustr. .ti -2 .br \fBFunction: \fR ustr_setf_share() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr * .br \fBExplanation:\fR .br This function sets the shared mode, which can be observed via. the ustr_shared() function. .br This is used on a Ustr so that it can have more references than it is able to hold in it's reference count. After this call the Ustr can be referenced and unreferenced an infinite number of times. .sp \fBNote:\fR .br After this call the Ustr will never be deleted until ustr_setf_owner() is called. .br This function fails if ustr_alloc() fails for the Ustr. .ti -2 .br \fBFunction: \fR ustr_setf_owner() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr * .br \fBExplanation:\fR .br This function removes the shared mode, which can be observed via. the ustr_shared() function. .br This is used so that a Ustr in shared mode can be free'd. .sp \fBNote:\fR .br This function fails if ustr_alloc() fails for the Ustr. .SH Comparing data in a Ustr .ti -2 .br \fBFunction: \fR ustr_cmp_buf() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like memcmp() on the Ustr and the passed data. .ti -2 .br \fBFunction: \fR ustr_cmp() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cmp_buf() but with the data from ustr_cstr() and the length from ustr_len(). .ti -2 .br \fBFunction: \fR ustr_cmp_subustr() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp() but with a limit on the data and length. .ti -2 .br \fBFunction: \fR ustr_cmp_cstr() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cmp_buf() but with a length from strlen(). .ti -2 .br \fBFunction: \fR ustr_cmp_fast_buf() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp_buf() but the order of comparison is optimized for speed, but is much less friendly to humans. .ti -2 .br \fBFunction: \fR ustr_cmp_fast() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cmp_fast_buf() but with the data from ustr_cstr() and the length from ustr_len(). .ti -2 .br \fBFunction: \fR ustr_cmp_fast_subustr() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp_fast() but with a limit on the data and length. .ti -2 .br \fBFunction: \fR ustr_cmp_fast_cstr() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cmp_fast_buf() but with a length from strlen(). .ti -2 .br \fBFunction: \fR ustr_cmp_case_buf() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp_buf() but the order of comparison ignores ASCII case. .ti -2 .br \fBFunction: \fR ustr_cmp_case() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cmp_case_buf() but with the data from ustr_cstr() and the length from ustr_len(). .ti -2 .br \fBFunction: \fR ustr_cmp_case_subustr() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp_case() but with a limit on the data and length. .ti -2 .br \fBFunction: \fR ustr_cmp_case_cstr() .br Returns: Less then zero, zero or greater than zero depending on comparison .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cmp_case_buf() but with a length from strlen(). .ti -2 .br \fBFunction: \fR ustr_cmp_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_buf_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_buf() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_subustr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_subustr() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_cstr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_cstr() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_case_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_case_buf_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_buf() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_case_subustr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_subustr() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_case_cstr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_cstr() against 0. .ti -2 .br \fBFunction: \fR ustr_cmp_prefix_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp() against 0, but the comparison is limited to the length of the right hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_prefix_buf_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_buf() against 0, but the comparison is limited to the length of the right hand side (Parameter[3]). .ti -2 .br \fBFunction: \fR ustr_cmp_prefix_cstr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_cstr() against 0, but the comparison is limited to the length of the right hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_prefix_subustr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_subustr() against 0, but the comparison is limited to the given length (Parameter[4]). .ti -2 .br \fBFunction: \fR ustr_cmp_case_prefix_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case() against 0, but the comparison is limited to the length of the right hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_case_prefix_buf_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_buf() against 0, but the comparison is limited to the length of the right hand side (Parameter[3]). .ti -2 .br \fBFunction: \fR ustr_cmp_case_prefix_cstr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_cstr() against 0, but the comparison is limited to the length of the right hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_case_prefix_subustr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_subustr() against 0, but the comparison is limited to the given length (Parameter[4]). .ti -2 .br \fBFunction: \fR ustr_cmp_suffix_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cmp_prefix_eq() but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_suffix_buf_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp_prefix_buf_eq() but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_suffix_cstr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cmp_prefix_cstr_eq() but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_suffix_subustr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_subustr() against 0, but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_case_suffix_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cmp_case_prefix_eq() but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_case_suffix_buf_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to constant bytes, to compare .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of comparison bytes .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cmp_case_prefix_buf_eq() but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_case_suffix_cstr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant C\-style string .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cmp_case_prefix_cstr_eq() but compares the end of the left hand side. .ti -2 .br \fBFunction: \fR ustr_cmp_case_suffix_subustr_eq() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to compare from the Ustr .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like comparing ustr_cmp_case_subustr() against 0, but compares the end of the left hand side. .SH Searching for data in a Ustr .ti -2 .br \fBFunction: \fR ustr_srch_chr_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data to search for .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function searches for the data (Parameter[3]) in the Ustr, skipping an offset (Parameter[2]) number of bytes. .ti -2 .br \fBFunction: \fR ustr_srch_chr_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data to search for .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function works like ustr_srch_chr_fwd() but it searches from the end of the string to the beginning. .sp \fBNote:\fR .br The searching starts from the end of the string, and so the offset is the offset from the end. However the position of a byte is always relative to the beginning, so to do a loop you need to take the position from the length. .ti -2 .br \fBFunction: \fR ustr_srch_buf_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to data to search for .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of the data to search for .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function searches for the data (Parameter[3]) of length (Parameter[4]) in the Ustr, skipping an offset (Parameter[2]) number of bytes. .ti -2 .br \fBFunction: \fR ustr_srch_buf_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to data to search for .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of the data to search for .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_buf_fwd() but it searches from the end of the string to the beginning. .sp \fBNote:\fR .br The searching starts from the end of the string, and so the offset is the offset from the end. However the position of a byte is always relative to the beginning, so to do a loop you need to take the position from the length. .ti -2 .br \fBFunction: \fR ustr_srch_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, to search for .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_srch_buf_fwd() but it gets the data pointer by calling ustr_cstr() and the length by calling ustr_len() on the passed Ustr (Parameter[3]). .ti -2 .br \fBFunction: \fR ustr_srch_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, to search for .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_srch_fwd() but it searches from the end of the string to the beginning. .sp \fBNote:\fR .br The searching starts from the end of the string, and so the offset is the offset from the end. However the position of a byte is always relative to the beginning, so to do a loop you need to take the position from the length. .ti -2 .br \fBFunction: \fR ustr_srch_cstr_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to C\-style string data, to search for .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_srch_buf_fwd() but it gets the length by calling strlen() on the passed data (Parameter[3]). .ti -2 .br \fBFunction: \fR ustr_srch_cstr_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to C\-style string data, to search for .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_srch_cstr_fwd() but it searches from the end of the string to the beginning. .sp \fBNote:\fR .br The searching starts from the end of the string, and so the offset is the offset from the end. However the position of a byte is always relative to the beginning, so to do a loop you need to take the position from the length. .ti -2 .br \fBFunction: \fR ustr_srch_subustr_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Position in the Ustr .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Length of data to search, from the Ustr .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_fwd() but it moves the data to start at the correct position and limits the length to the value specified. .ti -2 .br \fBFunction: \fR ustr_srch_subustr_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Position in the Ustr .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Length of data to search, from the Ustr .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_rev() but it moves the data to start at the correct position and limits the length to the value specified. .sp \fBNote:\fR .br The searching starts from the end of the string, and so the offset is the offset from the end. However the position of a byte is always relative to the beginning, so to do a loop you need to take the position from the length. .ti -2 .br \fBFunction: \fR ustr_srch_case_chr_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data to search for .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function works like ustr_srch_chr_fwd(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_chr_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data to search for .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function works like ustr_srch_chr_fwd(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_buf_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to data to search for .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of the data to search for .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_buf_fwd(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_buf_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to data to search for .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of the data to search for .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_buf_rev(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, to search for .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_srch_fwd(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, to search for .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_srch_rev(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_cstr_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to C\-style string data, to search for .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_srch_cstr_fwd(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_cstr_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to C\-style string data, to search for .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_srch_cstr_rev(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_subustr_fwd() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Position in the Ustr .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Length of data to search, from the Ustr .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_subustr_fwd(), but treats ASCII uppercase and lowercase as equivalent. .ti -2 .br \fBFunction: \fR ustr_srch_case_subustr_rev() .br Returns: Position in the Ustr, or zero if not found .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start searching at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Position in the Ustr .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Length of data to search, from the Ustr .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_srch_subustr_rev(), but treats ASCII uppercase and lowercase as equivalent. .SH Span lengths of data in a Ustr .ti -2 .br \fBFunction: \fR ustr_spn_chr_fwd() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function returns the length of the start of the Ustr (Parameter[1]) that only contains bytes that are equal to the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_spn_chr_rev() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function returns the length of the end of the Ustr (Parameter[1]) that only contains bytes that are equal to the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_spn_chrs_fwd() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Array of byte data, for spanning .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of byte data, for spanning .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function returns the length of the start of the Ustr (Parameter[1]) that only contains bytes that are equal to any byte in the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_spn_chrs_rev() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Array of byte data .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of byte data .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function returns the length of the end of the Ustr (Parameter[1]) that only contains bytes that are equal to any byte in the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_spn_fwd() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, containing spanning bytes .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_spn_buf_fwd() but passing ustr_cstr() and ustr_len() .ti -2 .br \fBFunction: \fR ustr_spn_rev() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, containing spanning bytes .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_spn_buf_rev() but passing ustr_cstr() and ustr_len() .ti -2 .br \fBFunction: \fR ustr_spn_cstr_fwd() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string, containing spanning bytes .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_spn_buf_fwd() but passing strlen() for the length. .ti -2 .br \fBFunction: \fR ustr_spn_cstr_rev() .br Returns: Number of bytes in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string, containing spanning bytes .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_spn_buf_rev() but passing strlen() for the length. .ti -2 .br \fBFunction: \fR ustr_cspn_chr_fwd() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function returns the length of the start of the Ustr (Parameter[1]) that only contains bytes that are not equal to the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_cspn_chr_rev() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Byte data .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function returns the length of the end of the Ustr (Parameter[1]) that only contains bytes that are not equal to the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_cspn_chrs_fwd() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Array of byte data .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of byte data .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function returns the length of the start of the Ustr (Parameter[1]) that only contains bytes that are not equal to any byte in the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_cspn_chrs_rev() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Array of byte data .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of byte data .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function returns the length of the end of the Ustr (Parameter[1]) that only contains bytes that are not equal to any byte in the data (Parameter[3]), skipping offset (Parameter[2]) bytes. .ti -2 .br \fBFunction: \fR ustr_cspn_fwd() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, containing spanning bytes .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cspn_buf_fwd() but passing ustr_cstr() and ustr_len() .ti -2 .br \fBFunction: \fR ustr_cspn_rev() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string, containing spanning bytes .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cspn_buf_rev() but passing ustr_cstr() and ustr_len() .ti -2 .br \fBFunction: \fR ustr_cspn_cstr_fwd() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string, containing spanning bytes .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cspn_buf_fwd() but passing strlen() for the length. .ti -2 .br \fBFunction: \fR ustr_cspn_cstr_rev() .br Returns: Number of bytes not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string, containing spanning bytes .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cspn_buf_rev() but passing strlen() for the length. .ti -2 .br \fBFunction: \fR ustr_utf8_spn_chrs_fwd() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style UTF\-8 string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of the C\-style UTF\-8 string .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_spn_chrs_fwd() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_chrs_fwd() but given "xy" as a multi\-byte UTF\-8 character it understands that the span over "xyxz" is 1 UTF\-8 character and not 3 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_spn_chrs_rev() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style UTF\-8 string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_spn_chrs_rev() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_chrs_rev() but given "xy" as a multi\-byte UTF\-8 character it understands that the span over "xyxz" is 1 UTF\-8 character and not 3 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_spn_fwd() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_spn_fwd() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_fwd() but given "xy" as a multi\-byte UTF\-8 character it understands that the span over "xyxz" is 1 UTF\-8 character and not 3 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_spn_rev() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_spn_rev() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_rev() but given "xy" as a multi\-byte UTF\-8 character it understands that the span over "xyxz" is 1 UTF\-8 character and not 3 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_spn_cstr_fwd() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style UTF\-8 string .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_spn_cstr_fwd() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_cstr_fwd() but given "xy" as a multi\-byte UTF\-8 character it understands that the span over "xyxz" is 1 UTF\-8 character and not 3 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_spn_cstr_rev() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style UTF\-8 string .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_spn_cstr_rev() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_cstr_rev() but given "xy" as a multi\-byte UTF\-8 character it understands that the span over "xyxz" is 1 UTF\-8 character and not 3 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_cspn_chrs_fwd() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style UTF\-8 string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of the C\-style UTF\-8 string .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cspn_chrs_fwd() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_cspn_chrs_fwd() but given "xy" as a multi\-byte UTF\-8 character it understands that the compliment span over "xzxy" is 1 UTF\-8 character and not 0 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_cspn_chrs_rev() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style UTF\-8 string .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of the C\-style UTF\-8 string .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_cspn_chrs_rev() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_cspn_chrs_rev() but given "xy" as a multi\-byte UTF\-8 character it understands that the compliment span over "xzxy" is 1 UTF\-8 character and not 0 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_cspn_fwd() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr UTF\-8 string, containing spanning data .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cspn_fwd() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_cspn_fwd() but given "xy" as a multi\-byte UTF\-8 character it understands that the compliment span over "xzxy" is 1 UTF\-8 character and not 0 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_cspn_rev() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to constant Ustr UTF\-8 string data, containing spanning data .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works like ustr_cspn_rev() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_cspn_rev() but given "xy" as a multi\-byte UTF\-8 character it understands that the compliment span over "xzxy" is 1 UTF\-8 character and not 0 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_cspn_cstr_fwd() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to constant C\-style UTF\-8 string data, containing spanning data .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cspn_cstr_fwd() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_cspn_cstr_fwd() but given "xy" as a multi\-byte UTF\-8 character it understands that the compliment span over "xzxy" is 1 UTF\-8 character and not 0 bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_cspn_cstr_rev() .br Returns: Number of UTF\-8 characters not in the span .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr UTF\-8 string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string, in UTF\-8 characters, to start compliment spanning from .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to C\-style UTF\-8 string data, containing spanning data .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_cspn_cstr_rev() but the return value, offset, and length all use UTF\-8 characters and not bytes. .sp \fBNote:\fR .br This is much slower than ustr_spn_cstr_rev() but given "xy" as a multi\-byte UTF\-8 character it understands that the compliment span over "xzxy" is 1 UTF\-8 character and not 0 bytes. .SH Doing IO from or to a Ustr .ti -2 .br \fBFunction: \fR ustr_io_get() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br Parameter\fB[3]\fR: Number of bytes to read .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Returned number of bytes read .br Type\fB[4]\fR: size_t * .br \fBExplanation:\fR .br This function tries to read a minimum number of bytes from the file object, into the Ustr string. The exact number read is returned, unless (Parameter[4]) is NULL. .ti -2 .br \fBFunction: \fR ustr_io_getfile() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br \fBExplanation:\fR .br This function calls ustr_io_get() rpeatedly until EOF is encountered. .sp \fBNote:\fR .br The errno value when this function ends could either be from fopen(), fread(), or if both of the those succeeded from fclose(). .ti -2 .br \fBFunction: \fR ustr_io_getfilename() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A C\-style string of a filename .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function opens a specified file, and then calls ustr_io_getfile(). Finally closing the FILE * object. .ti -2 .br \fBFunction: \fR ustr_io_getdelim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br Parameter\fB[3]\fR: A delimiter byte to stop reading at .br Type\fB[3]\fR: char .br \fBExplanation:\fR .br This function reads bytes from the file until it hits the delimiter byte. .sp \fBNote:\fR .br The delimiter is included, use ustr_del() to remove 1 byte from the end if you don't want it. .br This function assumes a delimiter will happen every 80 bytes or so. .ti -2 .br \fBFunction: \fR ustr_io_getline() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br \fBExplanation:\fR .br This function works like calling ustr_io_getdelim() with '\\n' as the delimiter. .ti -2 .br \fBFunction: \fR ustr_io_put() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br Parameter\fB[3]\fR: Number of bytes to write .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function is the opposite of ustr_io_get(), taking bytes from the beginning of the Ustr and writing them to the file. .sp \fBNote:\fR .br Deleting bytes from the beginning of a Ustr string is the most inefficient thing to do, so it is recommended to use ustr_io_putfile(). .ti -2 .br \fBFunction: \fR ustr_io_putline() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br Parameter\fB[3]\fR: Number of bytes to write .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function works like calling ustr_io_put(), and then writing a '\\n' to the file. .sp \fBNote:\fR .br This doesn't write a line from the Ustr to the file, if you want that call ustr_io_put() directly, using the return from ustr_srch_chr_fwd() (with a '\\n') as the number of bytes argument. .ti -2 .br \fBFunction: \fR ustr_io_putfile() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br \fBExplanation:\fR .br This function works like calling ustr_io_put() with ustr_len() as the number of bytes. .ti -2 .br \fBFunction: \fR ustr_io_putfileline() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a C file object .br Type\fB[2]\fR: FILE * .br \fBExplanation:\fR .br This function works like calling ustr_io_putline() with ustr_len() as the number of bytes. .ti -2 .br \fBFunction: \fR ustr_io_putfilename() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A C\-style string of a filename .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: A C\-style string of a filemode (the second argument to fopen) .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function opens a specified file, and then calls ustr_io_putfile(). Finally closing the FILE * object. .sp \fBNote:\fR .br The errno value when this function ends could either be from fopen(), fwrite(), or if both of the those succeeded from fclose(). .SH String substitution/replacement .ti -2 .br \fBFunction: \fR ustr_sub_undef() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of undefined data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br The Ustr string is expanded as required (possibly reallocated) so that it can contain length (Parameter[2]) data, from the required position. If the length is not zero the Ustr will be writable. Or it'll return USTR_FALSE (zero) on failure. .sp \fBNote:\fR .br You can think of the operation as two separate tasks, one which makes the current data in the Ustr undefined and the second which adds undefined data to the ustr to accommodate the desired length. .ti -2 .br \fBFunction: \fR ustr_sub_buf() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Buffer containing substitution string .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of buffer .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had called ustr_sub_undef() and then copied the data into the new undefined space. .ti -2 .br \fBFunction: \fR ustr_sub_cstr() .br Returns: success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant C\-style string, which is the substitution .br Type\fB[3]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_sub_buf() but the length is worked out automatically by strlen(). .ti -2 .br \fBFunction: \fR USTR_SUB_OSTR() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A constant C\-style string .br Type\fB[3]\fR: const char [] .br \fBExplanation:\fR .br This function works as if you had called ustr_sub_buf() and passed sizeof() \- 1 as the length. .ti -2 .br \fBFunction: \fR USTR_SUB_OBJ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A symbol .br Type\fB[3]\fR: ... .br \fBExplanation:\fR .br This function works as if you had called ustr_sub_buf() and passed sizeof() as the length. .sp \fBNote:\fR .br In most cases you'll want to use USTR_SUB_OSTR(). .ti -2 .br \fBFunction: \fR ustr_sub() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_sub_buf() with the ustr_cstr() and ustr_len() values of the Ustr string to be added. The exception being if you substitute a ustr into itself, while only having a single reference count, the simple method could access a free'd ustr data, but this function just works. .ti -2 .br \fBFunction: \fR ustr_sub_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: A pointer to a constant Ustr string .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Position in the Ustr .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Length to substitute from the Ustr .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function mostly as if you had called ustr_sub_buf() with the ustr_cstr() + position \- 1 and length values of the Ustr string to be insed. The exception being if you insert a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr data, but this function just works. .ti -2 .br \fBFunction: \fR ustr_sc_sub_undef() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length of undefined data .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works as if you had done ustr_del_subustr() followed by ustr_ins_undef(), however it is significantly more efficient. .ti -2 .br \fBFunction: \fR ustr_sc_sub_buf() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Buffer containing substitute data .br Type\fB[4]\fR: const void * .br Parameter\fB[5]\fR: Length of Buffer .br Type\fB[5]\fR: size_t .br \fBExplanation:\fR .br This function will substitute a specific number of characters in a Ustr with the data from a buffer, this function does the job of one or more of ustr_add_buf(), ustr_sub_buf() and ustr_del(). .ti -2 .br \fBFunction: \fR ustr_sc_sub_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start replacement .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant C\-style string, containing spanning bytes .br Type\fB[4]\fR: const char * .br \fBExplanation:\fR .br This function works like ustr_sc_sub_buf() but the length is worked out automatically by strlen(). .ti -2 .br \fBFunction: \fR ustr_sc_sub() .br Returns: success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Pointer to a Ustr containing the substitute string .br Type\fB[4]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_sub_buf() with the ustr_cstr() and ustr_len() values of the Ustr string to be added. The exception being if you substitute a ustr into itself, while only having a single reference count, the simple method could access a free'd ustr data, but this function just works. .ti -2 .br \fBFunction: \fR ustr_sc_sub_subustr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A pointer to a constant Ustr string .br Type\fB[4]\fR: const struct Ustr * .br Parameter\fB[5]\fR: Position in the Ustr .br Type\fB[5]\fR: size_t .br Parameter\fB[6]\fR: Length to substitute from the Ustr .br Type\fB[6]\fR: size_t .br \fBExplanation:\fR .br This function mostly as if you had called ustr_sc_sub_buf() with the ustr_cstr() + position \- 1 and length values of the Ustr string to be insed. The exception being if you insert a ustr to itself, while only having a single reference count, the simple method would access a free'd ustr data, but this function just works. .ti -2 .br \fBFunction: \fR USTR_SC_SUB_OSTR() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A constant C\-style string .br Type\fB[4]\fR: const char [] .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_sub_buf() and passed sizeof() \- 1 as the length. .ti -2 .br \fBFunction: \fR USTR_SC_SUB_OBJ() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Position where to start substitution .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of substitution .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: A symbol .br Type\fB[4]\fR: ... .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_sub_buf() and passed sizeof() as the length. .sp \fBNote:\fR .br In most cases you'll want to use USTR_SUB_OSTR(). .ti -2 .br \fBFunction: \fR ustr_replace_buf() .br Returns: Number of tokens replaced .br Type: size_t .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr (haystack) .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Buffer containing search data .br Type\fB[2]\fR: const void * .br Parameter\fB[3]\fR: Length of search buffer .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Buffer containing replacement data .br Type\fB[4]\fR: const void * .br Parameter\fB[5]\fR: Length of replacement buffer .br Type\fB[5]\fR: size_t .br Parameter\fB[6]\fR: Maximum number of matches to replace (0 for unlimited) .br Type\fB[6]\fR: size_t .br \fBExplanation:\fR .br This function scans the "haystack" (Parameter[1]) for "needle" (Parameter[2]) and replaces max_replacements (Parameter[6]) matches with the "replacement" (Parameter[4]). .sp \fBNote:\fR .br If max_replacements (Parameter[6]) is 0, this function will replace ALL occurrences. .ti -2 .br \fBFunction: \fR ustr_replace_cstr() .br Returns: Number of tokens replaced .br Type: size_t .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr (haystack) .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string, containing search bytes .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: A pointer to a constant C\-style string, containing replacement bytes .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Maximum number of matches to replace (0 for unlimited) .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_replace_buf() but gets the lengths for the buffer automatically from strlen(). .ti -2 .br \fBFunction: \fR ustr_replace() .br Returns: Number of tokens replaced .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr (haystack) .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Ustr to search for (needle) .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Ustr to replace needle with .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Maximum number of matches to replace (0 for unlimited) .br Type\fB[4]\fR: size_t .br \fBExplanation:\fR .br This function works like ustr_replace_buf() but gets the lengths from the ustr automatically. .ti -2 .br \fBFunction: \fR ustr_replace_rep_chr() .br Returns: number of replacements made .br Type: size_t .br Parameter\fB[1]\fR: pointer to a pointer to a Ustr to be modified .br Type\fB[1]\fR: struct Ustr **ps1 .br Parameter\fB[2]\fR: character to replace .br Type\fB[2]\fR: char .br Parameter\fB[3]\fR: number of characters to replace .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: character to replace with .br Type\fB[4]\fR: char .br Parameter\fB[5]\fR: number of characters to replace with .br Type\fB[5]\fR: size_t nlen .br Parameter\fB[6]\fR: maximum number of replacements to make (use 0 for unlimited) .br Type\fB[6]\fR: size_t lim .br \fBExplanation:\fR .br This function replaces a repeating sequence of characters with another repeating sequence of characters. For example... Ustr *data = ustr_dup_cstr("xxxBxxCxDxxx"); ustr_replace_rep_chr(&data,'x',2,'y',1, 0) ...would change data to be "yxByCxDyx". .sp \fBNote:\fR .br Changing the same letter the same number of times is considered a No\-op since it is a vast performance improvement this way. So passing in (&data,'y',2,'y',2 ,0) will have a return value of 0 and the string will be unchanged. .SH Splitting a Ustr .ti -2 .br \fBFunction: \fR ustr_split_buf() .br Returns: pointer to a Ustr representing the next token .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a constant Ustr to be split .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Pointer to an offset .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: Buffer to use as split search pattern .br Type\fB[3]\fR: const void * .br Parameter\fB[4]\fR: Length of buffer .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Pointer to a Ustr to be used as the return value .br Type\fB[5]\fR: struct Ustr * .br Parameter\fB[6]\fR: Flags with the prefix USTR_FLAG_SPLIT_ .br Type\fB[6]\fR: unsigned int .br \fBExplanation:\fR .br This function works in a manner similar to strtok(). Each time the function is called, the string inside of the buffer (Parameter[3]) is used as a search pattern at which to split. If the pattern is not found, the entire string will be returned. A USTR_NULL return value indicates there are no more tokens remaining. .br Parameter[5] is a a pointer to a Ustr where the return value will be placed. Passing a USTR_NULL to this parameter will cause the string to be allocated and \fBMUST\fR be freed \fBmanually\fR. If, however, you pass in a non\-null Ustr to this parameter, each call to ustr_split_buf() will free what is in this pointer and place the new token there (when USTR_NULL is returned, nothing needs to be free'd). For example, given... Ustr *data = ...; Ustr *tok = USTR_NULL; const char *sep = ","; size_t off = 0; unsigned int flags = USTR_FLAGS_SPLIT_DEF; ...there are two options... while ((tok = ustr_split_buf(data, &off, sep, strlen(sep), tok, flags))) { /* Do something with tok \-\- but next iteration of the loop will free * and overwrite tok, so you must ustr_dup() if you want to keep it */ } /* tok is now NULL again after the loop */ ...or... while ((tok = ustr_split_buf(data, &off, sep, strlen(sep), USTR_NULL, flags))) { /* Do something with tok, and it will NOT be freed in the next iteration of * the loop */ ustr_free(tok); /* have to free to avoid mem leaks */ } ...the former of which being the safer option. .sp \fBNote:\fR .br There are several flags that will alter the behaviour of this function, all of which have a common with the default being USTR_FLAG_SPLIT_DEF. .br If you are calling this function directly, it is very likely that you'd want to use ustr_split_cstr() instead. .ti -2 .br \fBFunction: \fR ustr_split() .br Returns: Pointer to a Ustr representing the next token .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a constant Ustr to be split .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Pointer to an offset variable .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: Pointer to a constant Ustr to use as the split search pattern .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Pointer to a Ustr where the return value will be placed .br Type\fB[4]\fR: struct Ustr * .br Parameter\fB[5]\fR: Flags .br Type\fB[5]\fR: unsigned int .br \fBExplanation:\fR .br Works like ustr_split_buf() but takes a Ustr as the split search pattern .br instead. .ti -2 .br \fBFunction: \fR ustr_split_cstr() .br Returns: Pointer to a Ustr representing the next token .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a constant Ustr to be split .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Pointer to an offset variable .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: C string to use as split search pattern .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Pointer to a Ustr where the return value will be placed .br Type\fB[4]\fR: struct Ustr * .br Parameter\fB[5]\fR: Flags .br Type\fB[5]\fR: unsigned int .br \fBExplanation:\fR .br Works like ustr_split_buf() but takes a C string as the split search pattern, and so gets the length via. strlen(). .ti -2 .br \fBFunction: \fR ustr_split_spn_chrs() .br Returns: Pointer to a Ustr representing the next token .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a Ustr to be split .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Pointer to an offset variable .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: String representing a set of bytes to use as split chars .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Length of the string of set of bytes .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Pointer to a Ustr where the return value will be placed .br Type\fB[5]\fR: struct Ustr * .br Parameter\fB[6]\fR: flags .br Type\fB[6]\fR: unsigned int .br \fBExplanation:\fR .br Works like ustr_split_buf() but uses the individual ASCII bytes in the separator string (Parameter[3]) as search patterns. It will split if \fBANY\fR of these individual characters are matched (much like strtok()). For example: if splitting "this, is,a test" with the separator string ", " the tokens returned would be {"this" "is" "a" "test"}; .sp \fBNote:\fR .br If you are calling this function directly, it is very likely that you'd want to use ustr_split_spn_cstr() instead. .ti -2 .br \fBFunction: \fR ustr_split_spn_cstr() .br Returns: Pointer to a Ustr representing the next token .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a Ustr to be split .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Pointer to an offset variable .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: String representing a set of bytes to use as split chars .br Type\fB[3]\fR: const char * .br Parameter\fB[4]\fR: Pointer to a Ustr where the return value will be placed .br Type\fB[4]\fR: struct Ustr * .br Parameter\fB[5]\fR: flags .br Type\fB[5]\fR: unsigned int .br \fBExplanation:\fR .br Works like ustr_split_spn_chrs() but gets the length automatically via. strlen(). .ti -2 .br \fBFunction: \fR ustr_split_spn() .br Returns: Pointer to a Ustr representing the next token .br Type: struct Ustr * .br Parameter\fB[1]\fR: Pointer to a constant Ustr to be split .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Pointer to an offset variable .br Type\fB[2]\fR: size_t * .br Parameter\fB[3]\fR: Pointer to a constant Ustr to use as the split search pattern .br Type\fB[3]\fR: const struct Ustr * .br Parameter\fB[4]\fR: Pointer to a Ustr where the return value will be placed .br Type\fB[4]\fR: struct Ustr * .br Parameter\fB[5]\fR: Flags .br Type\fB[5]\fR: unsigned int .br \fBExplanation:\fR .br Works like ustr_split_spn_chrs() but takes a Ustr as the split chars instead. .SH Dealing with UTF\-8 in a Ustr .ti -2 .br \fBFunction: \fR ustr_utf8_valid() .br Returns: A boolean flag of either USTR_TRUE or USTR_FALSE .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function tries it's best to find out if the string is a valid utf\-8 string. .ti -2 .br \fBFunction: \fR ustr_utf8_len() .br Returns: The number of the utf\-8 characters in the Ustr .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function counts the number of utf\-8 characters inn the Ustr. .sp \fBNote:\fR .br This function gives undefined answers on strings that aren't utf\-8 valid. .ti -2 .br \fBFunction: \fR ustr_utf8_width() .br Returns: ssize_t .br Type: ssize_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function returns the visible width of the string, assuming it is a valid utf\-8 string. This is like converting to wide characters and using wcwidth(). .ti -2 .br \fBFunction: \fR ustr_utf8_chars2bytes() .br Returns: Length of span in bytes .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Position of a span in utf\-8 characters .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of a span in utf\-8 characters .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Returns the position of the span in bytes .br Type\fB[4]\fR: size_t * .br \fBExplanation:\fR .br This function converts a span, in utf\-8 characters, to the same span in bytes. .ti -2 .br \fBFunction: \fR ustr_utf8_bytes2chars() .br Returns: Returns the position of a span in utf\-8 characters .br Type: size_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Position of a span in bytes .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length of a span in bytes .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Returns length of a span in utf\-8 characters .br Type\fB[4]\fR: size_t * .br \fBExplanation:\fR .br This function converts a span, in bytes, to the same span in utf\-8 characters. .sp \fBNote:\fR .br Because a byte span can start or end within a utf\-8 character, converting the return values back into bytes via. ustr_utf8_chars2bytes() may make the span be slightly bigger (position slightly earlier, and the length slightly longer). .ti -2 .br \fBFunction: \fR ustr_sc_utf8_reverse() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function reverses the utf\-8 characters in the Ustr string, assuming it is a valid utf\-8 string, so the last one becomes the first and the second to last becomes the second etc. .SH Parsing ASCII integer numbers from a Ustr .ti -2 .br \fBFunction: \fR ustr_parse_uintmaxx() .br Returns: Parsed number, or zero on error .br Type: uintmax_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Absolute minimum value .br Type\fB[4]\fR: uintmax_t .br Parameter\fB[5]\fR: Absolute maximum value .br Type\fB[5]\fR: uintmax_t .br Parameter\fB[6]\fR: Thousands separator .br Type\fB[6]\fR: const char * .br Parameter\fB[7]\fR: Return length of parsed number .br Type\fB[7]\fR: size_t * .br Parameter\fB[8]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[8]\fR: unsigned int * .br \fBExplanation:\fR .br This function parses an ASCII representation of a number from a Ustr (Parameter[1]) starting at the offset (Parameter[2]). .sp \fBNote:\fR .br If stdint.h isn't available this function won't be available. .ti -2 .br \fBFunction: \fR ustr_parse_uintmax() .br Returns: Parsed number, or zero on error .br Type: uintmax_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_uintmaxx() with the minimum and maximum values taken as 0 and UINTMAX_MAX, and the thousands separator as "_". .sp \fBNote:\fR .br If stdint.h isn't available this function won't be available. .ti -2 .br \fBFunction: \fR ustr_parse_intmax() .br Returns: Parsed number, or zero on error .br Type: intmax_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_uintmaxx() with the minimum and maximum values taken as \-INTMAX_MIN and INTMAX_MAX, and the thousands separator as "_". .sp \fBNote:\fR .br If stdint.h isn't available this function won't be available. .ti -2 .br \fBFunction: \fR ustr_parse_ulongx() .br Returns: Parsed number, or zero on error .br Type: unsigned long .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Absolute minimum value .br Type\fB[4]\fR: unsigned long .br Parameter\fB[5]\fR: Absolute maximum value .br Type\fB[5]\fR: unsigned long .br Parameter\fB[6]\fR: Thousands separator .br Type\fB[6]\fR: const char * .br Parameter\fB[7]\fR: Return length of parsed number .br Type\fB[7]\fR: size_t * .br Parameter\fB[8]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[8]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_uintmaxx() but returns an unsigned long, it is always available even when stdint.h isn't. .ti -2 .br \fBFunction: \fR ustr_parse_ulong() .br Returns: Parsed number, or zero on error .br Type: unsigned long .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_ulongx() with the minimum and maximum values taken as 0 and ULONG_MAX, and the thousands separator as "_". .ti -2 .br \fBFunction: \fR ustr_parse_long() .br Returns: Parsed number, or zero on error .br Type: long .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_ulongx() with the minimum and maximum values taken as \-LONG_MIN and LONG_MAX, and the thousands separator as "_". .ti -2 .br \fBFunction: \fR ustr_parse_uint() .br Returns: Parsed number, or zero on error .br Type: unsigned int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_ulongx() with the minimum and maximum values taken as 0 and UINT_MAX, and the thousands separator as "_". .ti -2 .br \fBFunction: \fR ustr_parse_int() .br Returns: Parsed number, or zero on error .br Type: int .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_ulongx() with the minimum and maximum values taken as \-INT_MIN and INT_MAX, and the thousands separator as "_". .ti -2 .br \fBFunction: \fR ustr_parse_ushort() .br Returns: Parsed number, or zero on error .br Type: unsigned short .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_ulongx() with the minimum and maximum values taken as 0 and USHRT_MAX, and the thousands separator as "_". .ti -2 .br \fBFunction: \fR ustr_parse_short() .br Returns: Parsed number, or zero on error .br Type: short .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Base (2\-36) and flags, starting with USTR_FLAG_PARSE_NUM_ .br Type\fB[3]\fR: unsigned int .br Parameter\fB[4]\fR: Return length of parsed number .br Type\fB[4]\fR: size_t * .br Parameter\fB[5]\fR: Return error code, starting with USTR_TYPE_PARSE_NUM_ERR_ .br Type\fB[5]\fR: unsigned int * .br \fBExplanation:\fR .br This function works like ustr_parse_ulongx() with the minimum and maximum values taken as \-SHRT_MIN and SHRT_MAX, and the thousands separator as "_". .SH Misc shortcut helper functions for Ustrs .ti -2 .br \fBFunction: \fR ustr_sc_ensure_owner() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function makes sure that the Ustr string is owned when it returns (Ie. ustr_owner() returns USTR_TRUE), or it fails to allocate. .ti -2 .br \fBFunction: \fR ustr_sc_wstr() .br Returns: Writable pointer to the start of data in the Ustr, or NULL .br Type: char * .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function works like calling ustr_sc_ensure_owner(), to make sure the Ustr string is writable, and if that succeeds it returns ustr_wstr(). On failure it returns NULL. .ti -2 .br \fBFunction: \fR ustr_sc_export_subustr() .br Returns: A pointer to newly allocated block of memory .br Type: char * .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Position in the Ustr .br Type\fB[2]\fR: size_t .br Parameter\fB[3]\fR: Length to export from the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Allocation function (like malloc) .br Type\fB[4]\fR: void *(*)(size_t) .br \fBExplanation:\fR .br This function allocates a block of memory of size Length (Parameter[3]) + 1 using the provided allocation function (Parameter[4]) and copies the data starting from Position (Parameter[2]) within the ustr. .ti -2 .br \fBFunction: \fR ustr_sc_export() .br Returns: A pointer to newly allocated block of memory .br Type: char * .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Allocation function (like malloc) .br Type\fB[2]\fR: void *(*)(size_t) .br \fBExplanation:\fR .br This function works like calling ustr_sc_export_subustr() with a position of 1 and a length of ustr_len(). .ti -2 .br \fBFunction: \fR ustrp_sc_export_subustrp() .br Returns: A pointer to newly allocated block of memory .br Type: char * .br Parameter\fB[1]\fR: Pointer to a Ustr pool object .br Type\fB[1]\fR: struct Ustr_pool * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Position in the Ustr .br Type\fB[3]\fR: size_t .br Parameter\fB[4]\fR: Length to export from the Ustr .br Type\fB[4]\fR: size_t .br Parameter\fB[5]\fR: Allocation function (like malloc), or NULL .br Type\fB[5]\fR: void *(*)(size_t) .br \fBExplanation:\fR .br This function allocates a block of memory of size Length (Parameter[4]) + 1 using either the provided allocation function (Parameter[5]), or from the pool object if the allocation function is NUL, and copies the data starting from Position (Parameter[3]) within the ustr. .ti -2 .br \fBFunction: \fR ustrp_sc_export() .br Returns: A pointer to newly allocated block of memory .br Type: char * .br Parameter\fB[1]\fR: Pointer to a Ustr pool object .br Type\fB[1]\fR: struct Ustr_pool * .br Parameter\fB[2]\fR: A pointer to a constant Ustr string .br Type\fB[2]\fR: const struct Ustr * .br Parameter\fB[3]\fR: Allocation function (like malloc) .br Type\fB[3]\fR: void *(*)(size_t) .br \fBExplanation:\fR .br This function works like calling ustrp_sc_export_subustrp() with a position of 1 and a length of ustrp_len(). .ti -2 .br \fBFunction: \fR ustr_sc_reverse() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function reverses all the bytes in the Ustr string, so the last one becomes the first and the second to last becomes the second etc. .ti -2 .br \fBFunction: \fR ustr_sc_tolower() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function changes any ASCII upper case bytes into ASCII lower case bytes. .ti -2 .br \fBFunction: \fR ustr_sc_toupper() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br \fBExplanation:\fR .br This function changes any ASCII lower case bytes into ASCII upper case bytes. .ti -2 .br \fBFunction: \fR ustr_sc_ltrim_chrs() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Array of bytes, containing trimming data .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Length of byte data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function deletes the bytes at the beginning of the Ustr (Parameter[1]) that are in the span (Parameter[2]) of the specificed length (parameter[2]). .ti -2 .br \fBFunction: \fR ustr_sc_ltrim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string, containing trimming bytes .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_ltrim_chrs() and passed ustr_cstr() and ustr_len() values of the Ustr string (Parameter[2]). .ti -2 .br \fBFunction: \fR ustr_sc_ltrim_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string, containing trimming bytes .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_ltrim_chrs() and passed strlen() as the length. .ti -2 .br \fBFunction: \fR ustr_sc_rtrim_chrs() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Array of bytes, containing trimming data .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Length of byte data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function deletes the bytes at the end of the Ustr (Parameter[1]) that are in the span (Parameter[2]) of the specificed length (parameter[2]). .ti -2 .br \fBFunction: \fR ustr_sc_rtrim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string, containing trimming bytes .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_rtrim_chrs() and passed ustr_cstr() and ustr_len() values of the Ustr string (Parameter[2]). .ti -2 .br \fBFunction: \fR ustr_sc_rtrim_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string, containing trimming bytes .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_rtrim_chrs() and passed strlen() as the length. .ti -2 .br \fBFunction: \fR ustr_sc_trim_chrs() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Array of bytes, containing trimming data .br Type\fB[2]\fR: const char * .br Parameter\fB[3]\fR: Length of byte data .br Type\fB[3]\fR: size_t .br \fBExplanation:\fR .br This function deletes the bytes at the beginning or end of the Ustr (Parameter[1]) that are in the span (Parameter[2]) of the specificed length (parameter[2]). .sp \fBNote:\fR .br Calling this function is much more efficient than calling ustr_sc_rtrim_chrs() and then ustr_sc_ltrim_chrs(), as both ends are trimmed in a single pass. .ti -2 .br \fBFunction: \fR ustr_sc_trim() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant Ustr string, containing trimming bytes .br Type\fB[2]\fR: const struct Ustr * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_trim_chrs() and passed ustr_cstr() and ustr_len() values of the Ustr string (Parameter[2]). .ti -2 .br \fBFunction: \fR ustr_sc_trim_cstr() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: A pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: A pointer to a constant C\-style string, containing trimming bytes .br Type\fB[2]\fR: const char * .br \fBExplanation:\fR .br This function works as if you had called ustr_sc_trim_chrs() and passed strlen() as the length. .SH Adding binary data to a Ustr .ti -2 .br \fBFunction: \fR ustr_add_b_uint16() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Binary value to add to the Ustr .br Type\fB[2]\fR: uint_least16_t .br \fBExplanation:\fR .br This function adds a binary representation of a value (Parameter[2]) to the Ustr (Parameter[1]). .ti -2 .br \fBFunction: \fR ustr_add_b_uint32() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Binary value to add to the Ustr .br Type\fB[2]\fR: uint_least32_t .br \fBExplanation:\fR .br This function adds a binary representation of a value (Parameter[2]) to the Ustr (Parameter[1]). .ti -2 .br \fBFunction: \fR ustr_add_b_uint64() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Binary value to add to the Ustr .br Type\fB[2]\fR: uint_least64_t .br \fBExplanation:\fR .br This function adds a binary representation of a value (Parameter[2]) to the Ustr (Parameter[1]). .SH Parsing binary data from a Ustr .ti -2 .br \fBFunction: \fR ustr_parse_b_uint16() .br Returns: uint_least16_t .br Type: uint_least16_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function parses a binary representation from a Ustr (Parameter[1]) starting at the offset (Parameter[2]). .ti -2 .br \fBFunction: \fR ustr_parse_b_uint32() .br Returns: uint_least32_t .br Type: uint_least32_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function parses a binary representation from a Ustr (Parameter[1]) starting at the offset (Parameter[2]). .ti -2 .br \fBFunction: \fR ustr_parse_b_uint64() .br Returns: uint_least64_t .br Type: uint_least64_t .br Parameter\fB[1]\fR: A pointer to a constant Ustr string .br Type\fB[1]\fR: const struct Ustr * .br Parameter\fB[2]\fR: Offset within string to start parsing at .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function parses a binary representation from a Ustr (Parameter[1]) starting at the offset (Parameter[2]). .SH Misc. functions .ti -2 .br \fBFunction: \fR ustr_realloc() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Pointer to a pointer to a Ustr string .br Type\fB[1]\fR: struct Ustr ** .br Parameter\fB[2]\fR: Size of allocation .br Type\fB[2]\fR: size_t .br \fBExplanation:\fR .br This function is re\-sizes the Ustr to the specified size (Parameter[2]). .br This is mostly used to shrink a sized Ustr that is now significantly smaller than it once was. Although this function can also grow a Ustr. .sp \fBNote:\fR .br To have a size that isn't implied from the length the Ustr must store a size value as well as a length (ustr_sized() must return USTR_TRUE). .ti -2 .br \fBFunction: \fR ustr_cntl_opt() .br Returns: Success or failure .br Type: int .br Parameter\fB[1]\fR: Optional value starting with USTR_CNTL_OPT_ .br Type\fB[1]\fR: int .br Parameter\fB[2]\fR: Arguments to option .br Type\fB[2]\fR: ... .br \fBExplanation:\fR .br This function views and/or changes global Ustr options, like whether ustr's have an implicit or explicit size (USTR_CNTL_OPT_GET_HAS_SIZE). .SH Simple Ustr pool API .ti -2 .br \fBFunction: \fR ustr_pool_ll_make() .br Returns: Pointer to a Ustr pool object .br Type: struct Ustr_pool * .br Parameter\fB[1]\fR: Nothing .br Type\fB[1]\fR: void .br \fBExplanation:\fR .br This allocates a new pool using the "linked list" strategy, each allocation in the pool is added to a linked list ... and any allocations not freed directly are freed by the pool when it is cleared or freed. .ti -2 .br \fBFunction: \fR ustr_pool_make_subpool() .br Returns: Pointer to a Ustr pool object .br Type: struct Ustr_pool * .br Parameter\fB[1]\fR: struct Ustr_pool * .br Type\fB[1]\fR: struct Ustr_pool * .br \fBExplanation:\fR .br This allocates a new pool as a child of the passed in pool (Parameter[1]), The pool can be freed and cleared independently of the parent pool however free and clear operations on the parent pool are automatically applied to all child pools. .ti -2 .br \fBFunction: \fR ustr_pool_free() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: Pointer to a Ustr pool object .br Type\fB[1]\fR: struct Ustr_pool * .br \fBExplanation:\fR .br This deallocates a pool, and all sub\-pools. .sp \fBNote:\fR .br This also operates on all sub\-pools. .ti -2 .br \fBFunction: \fR ustr_pool_clear() .br Returns: Nothing .br Type: void .br Parameter\fB[1]\fR: Pointer to a Ustr pool object .br Type\fB[1]\fR: struct Ustr_pool * .br \fBExplanation:\fR .br This allows all the data in the pool to be reused, it may also free some/all of the data in the pool, from the pool API. .sp \fBNote:\fR .br This also operates on all sub\-pools. .SH "SEE ALSO" .BR ustr_const (3)