00001
00002
00003
00004
00005 #ifndef _U_LIBU_STRING_H_
00006 #define _U_LIBU_STRING_H_
00007
00008 #include <u/libu_conf.h>
00009
00010 #include <stdlib.h>
00011 #include <unistd.h>
00012 #include <stdio.h>
00013 #include <stdarg.h>
00014 #include <sys/types.h>
00015
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019
00020 enum { BLOCK_SIZE = 64 };
00021
00022 struct u_string_s;
00023 typedef struct u_string_s u_string_t;
00024
00025 #define STRING_NULL { NULL, 0, 0, 0 };
00026
00027 #define u_string_sprintf( s, ... ) \
00028 u_string_do_printf(s, 1, __VA_ARGS__ )
00029 #define u_string_aprintf( s, ... ) \
00030 u_string_do_printf(s, 0, __VA_ARGS__ )
00031 #define u_string_cat( s, buf) \
00032 u_string_append(s, buf, strlen(buf))
00033 #define u_string_ncat( s, buf, len) \
00034 u_string_append(s, buf, len)
00035
00036 int u_string_create(const char *buf, size_t len, u_string_t **ps);
00037 int u_string_append(u_string_t *s, const char *buf, size_t len);
00038 int u_string_set(u_string_t *s, const char *buf, size_t len);
00039 int u_string_clear(u_string_t *s);
00040 int u_string_free(u_string_t *s);
00041 const char *u_string_c(u_string_t *s);
00042 size_t u_string_len(u_string_t *s);
00043 int u_string_copy(u_string_t *dst, u_string_t *src);
00044 int u_string_set_length(u_string_t *s, size_t len);
00045 int u_string_trim(u_string_t *s);
00046 int u_string_reserve(u_string_t *s, size_t size);
00047 int u_string_do_printf(u_string_t *s, int clear, const char *fmt, ...);
00048
00049 #ifdef __cplusplus
00050 }
00051 #endif
00052
00053 #endif