dstring.h

00001 /* 
00002  * Copyright (C) 2005 iptelorg GmbH
00003  *
00004  * This file is part of ser, a free SIP server.
00005  *
00006  * ser is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version
00010  *
00011  * For a license to use the ser software under conditions
00012  * other than those described here, or to purchase support for this
00013  * software, please contact iptel.org by e-mail at the following addresses:
00014  *    info@iptel.org
00015  *
00016  * ser is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 
00026 #ifndef __DSTRING_H
00027 #define __DSTRING_H
00028 
00029 #include <cds/sstr.h>
00030 
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif
00034 
00058 typedef struct _dstr_buff_t {
00059         int len; 
00060         int used; 
00061         struct _dstr_buff_t *next; 
00062         char data[1]; 
00063 } dstr_buff_t;
00064 
00071 typedef struct _dstring_t {
00073         dstr_buff_t *first;
00075         dstr_buff_t *last;
00077         int len;
00079         int buff_size;
00080 
00083         int error;
00084 } dstring_t;
00085 
00089 int dstr_append_zt(dstring_t *dstr, const char *s);
00090 
00094 int dstr_append(dstring_t *dstr, const char *s, int len);
00095 
00099 int dstr_append_str(dstring_t *dstr, const str_t *s);
00100 
00101 /* int dstr_get_data_length(dstring_t *dstr); */
00102 
00107 int dstr_get_data(dstring_t *dstr, char *dst);
00108 
00113 int dstr_get_str(dstring_t *dstr, str_t *dst);
00114 
00119 int dstr_get_str_pkg(dstring_t *dstr, str_t *dst);
00125 int dstr_init(dstring_t *dstr, int buff_size);
00126 
00128 int dstr_destroy(dstring_t *dstr);
00129 
00130 /* returns nozero if error !!! */
00131 /* int dstr_error(dstring_t *dstr);
00132 void dstr_clear_error(dstring_t *dstr); */
00133 
00135 #define dstr_get_data_length(dstr) (dstr)->len
00136 
00140 #define dstr_error(dstr) (dstr)->error
00141 
00143 #define dstr_clear_error(dstr) (dstr)->error = 0
00144 
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151         
00152 #endif