00001 /*! \file dstring.h 00002 Header file for dstring.c 00003 */ 00004 00005 #ifdef __cplusplus 00006 extern "C" { 00007 #endif 00008 00009 #ifndef DSTRING_HEADER 00010 00011 #include <sys/types.h> 00012 00013 /*! \brief Data structure that defines a dynamic string. 00014 */ 00015 00016 struct s_dstring { 00017 /*! \brief Pointer to the start of the data. */ 00018 char *data; 00019 00020 /*! \brief Total number of bytes allocated for the data. */ 00021 size_t size; 00022 00023 /*! \brief Number of characters in the string. */ 00024 size_t nb_car; 00025 }; 00026 00027 /*! \brief Data type for dynamic string. 00028 */ 00029 00030 typedef struct s_dstring dstring; 00031 00032 int dstring_init (dstring *s, size_t init_size); 00033 void dstring_free (dstring *s); 00034 int dstring_add (dstring *s, char *buff, size_t nb_elem); 00035 char* dstring_get_data (dstring *s, size_t *size); 00036 00037 #define DSTRING_HEADER 00038 #endif 00039 00040 #ifdef __cplusplus 00041 } 00042 #endif 00043