2003-04-02 Havoc Pennington <hp@redhat.com>
[platform/upstream/dbus.git] / dbus / dbus-string.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-string.h String utility class (internal to D-BUS implementation)
3  * 
4  * Copyright (C) 2002  Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 1.2
7  * 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #ifndef DBUS_STRING_H
25 #define DBUS_STRING_H
26
27 #include <config.h>
28
29 #include <dbus/dbus-memory.h>
30 #include <dbus/dbus-types.h>
31
32 DBUS_BEGIN_DECLS;
33
34 typedef struct DBusString DBusString;
35
36 struct DBusString
37 {
38   void *dummy1; /**< placeholder */
39   int   dummy2; /**< placeholder */
40   int   dummy3; /**< placeholder */
41   int   dummy4; /**< placeholder */
42   unsigned int dummy5 : 1; /**< placeholder */
43   unsigned int dummy6 : 1; /**< placeholder */
44   unsigned int dummy7 : 1; /**< placeholder */
45   unsigned int dummy8 : 3; /**< placeholder */
46 };
47
48 dbus_bool_t   _dbus_string_init                  (DBusString        *str);
49 void          _dbus_string_init_const            (DBusString        *str,
50                                                   const char        *value);
51 void          _dbus_string_init_const_len        (DBusString        *str,
52                                                   const char        *value,
53                                                   int                len);
54 void          _dbus_string_free                  (DBusString        *str);
55 void          _dbus_string_lock                  (DBusString        *str);
56 char*         _dbus_string_get_data              (DBusString        *str);
57 const char*   _dbus_string_get_const_data        (const DBusString  *str);
58 char*         _dbus_string_get_data_len          (DBusString        *str,
59                                                   int                start,
60                                                   int                len);
61 const char*   _dbus_string_get_const_data_len    (const DBusString  *str,
62                                                   int                start,
63                                                   int                len);
64 void          _dbus_string_set_byte              (DBusString        *str,
65                                                   int                i,
66                                                   unsigned char      byte);
67 unsigned char _dbus_string_get_byte              (const DBusString  *str,
68                                                   int                start);
69 dbus_bool_t   _dbus_string_insert_byte           (DBusString        *str,
70                                                   int                i,
71                                                   unsigned char      byte);
72 dbus_bool_t   _dbus_string_steal_data            (DBusString        *str,
73                                                   char             **data_return);
74 dbus_bool_t   _dbus_string_steal_data_len        (DBusString        *str,
75                                                   char             **data_return,
76                                                   int                start,
77                                                   int                len);
78 dbus_bool_t   _dbus_string_copy_data             (const DBusString  *str,
79                                                   char             **data_return);
80 dbus_bool_t   _dbus_string_copy_data_len         (const DBusString  *str,
81                                                   char             **data_return,
82                                                   int                start,
83                                                   int                len);
84 int           _dbus_string_get_length            (const DBusString  *str);
85 dbus_bool_t   _dbus_string_lengthen              (DBusString        *str,
86                                                   int                additional_length);
87 void          _dbus_string_shorten               (DBusString        *str,
88                                                   int                length_to_remove);
89 dbus_bool_t   _dbus_string_set_length            (DBusString        *str,
90                                                   int                length);
91 dbus_bool_t   _dbus_string_align_length          (DBusString        *str,
92                                                   int                alignment);
93 dbus_bool_t   _dbus_string_append                (DBusString        *str,
94                                                   const char        *buffer);
95 dbus_bool_t   _dbus_string_append_len            (DBusString        *str,
96                                                   const char        *buffer,
97                                                   int                len);
98 dbus_bool_t   _dbus_string_append_int            (DBusString        *str,
99                                                   long               value);
100 dbus_bool_t   _dbus_string_append_uint           (DBusString        *str,
101                                                   unsigned long      value);
102 dbus_bool_t   _dbus_string_append_double         (DBusString        *str,
103                                                   double             value);
104 dbus_bool_t   _dbus_string_append_byte           (DBusString        *str,
105                                                   unsigned char      byte);
106 dbus_bool_t   _dbus_string_append_unichar        (DBusString        *str,
107                                                   dbus_unichar_t     ch);
108 void          _dbus_string_delete                (DBusString        *str,
109                                                   int                start,
110                                                   int                len);
111 dbus_bool_t   _dbus_string_move                  (DBusString        *source,
112                                                   int                start,
113                                                   DBusString        *dest,
114                                                   int                insert_at);
115 dbus_bool_t   _dbus_string_copy                  (const DBusString  *source,
116                                                   int                start,
117                                                   DBusString        *dest,
118                                                   int                insert_at);
119 dbus_bool_t   _dbus_string_move_len              (DBusString        *source,
120                                                   int                start,
121                                                   int                len,
122                                                   DBusString        *dest,
123                                                   int                insert_at);
124 dbus_bool_t   _dbus_string_copy_len              (const DBusString  *source,
125                                                   int                start,
126                                                   int                len,
127                                                   DBusString        *dest,
128                                                   int                insert_at);
129 dbus_bool_t   _dbus_string_replace_len           (const DBusString  *source,
130                                                   int                start,
131                                                   int                len,
132                                                   DBusString        *dest,
133                                                   int                replace_at,
134                                                   int                replace_len);
135 void          _dbus_string_get_unichar           (const DBusString  *str,
136                                                   int                start,
137                                                   dbus_unichar_t    *ch_return,
138                                                   int               *end_return);
139 dbus_bool_t   _dbus_string_parse_int             (const DBusString  *str,
140                                                   int                start,
141                                                   long              *value_return,
142                                                   int               *end_return);
143 dbus_bool_t   _dbus_string_parse_uint            (const DBusString  *str,
144                                                   int                start,
145                                                   unsigned long     *value_return,
146                                                   int               *end_return);
147 dbus_bool_t   _dbus_string_parse_double          (const DBusString  *str,
148                                                   int                start,
149                                                   double            *value,
150                                                   int               *end_return);
151 dbus_bool_t   _dbus_string_find                  (const DBusString  *str,
152                                                   int                start,
153                                                   const char        *substr,
154                                                   int               *found);
155 dbus_bool_t   _dbus_string_find_to               (const DBusString  *str,
156                                                   int                start,
157                                                   int                end,
158                                                   const char        *substr,
159                                                   int               *found);
160 dbus_bool_t   _dbus_string_find_byte_backward    (const DBusString  *str,
161                                                   int                start,
162                                                   unsigned char      byte,
163                                                   int               *found);
164 dbus_bool_t   _dbus_string_find_blank            (const DBusString  *str,
165                                                   int                start,
166                                                   int               *found);
167 void          _dbus_string_skip_blank            (const DBusString  *str,
168                                                   int                start,
169                                                   int               *end);
170 void          _dbus_string_skip_white            (const DBusString  *str,
171                                                   int                start,
172                                                   int               *end);
173 dbus_bool_t   _dbus_string_equal                 (const DBusString  *a,
174                                                   const DBusString  *b);
175 dbus_bool_t   _dbus_string_equal_c_str           (const DBusString  *a,
176                                                   const char        *c_str);
177 dbus_bool_t   _dbus_string_equal_len             (const DBusString  *a,
178                                                   const DBusString  *b,
179                                                   int                len);
180 dbus_bool_t   _dbus_string_starts_with_c_str     (const DBusString  *a,
181                                                   const char        *c_str);
182 dbus_bool_t   _dbus_string_ends_with_c_str       (const DBusString  *a,
183                                                   const char        *c_str);
184 dbus_bool_t   _dbus_string_pop_line              (DBusString        *source,
185                                                   DBusString        *dest);
186 void          _dbus_string_delete_first_word     (DBusString        *str);
187 void          _dbus_string_delete_leading_blanks (DBusString        *str);
188 dbus_bool_t   _dbus_string_base64_encode         (const DBusString  *source,
189                                                   int                start,
190                                                   DBusString        *dest,
191                                                   int                insert_at);
192 dbus_bool_t   _dbus_string_base64_decode         (const DBusString  *source,
193                                                   int                start,
194                                                   DBusString        *dest,
195                                                   int                insert_at);
196 dbus_bool_t   _dbus_string_hex_encode            (const DBusString  *source,
197                                                   int                start,
198                                                   DBusString        *dest,
199                                                   int                insert_at);
200 dbus_bool_t   _dbus_string_hex_decode            (const DBusString  *source,
201                                                   int                start,
202                                                   DBusString        *dest,
203                                                   int                insert_at);
204 dbus_bool_t   _dbus_string_validate_ascii        (const DBusString  *str,
205                                                   int                start,
206                                                   int                len);
207 dbus_bool_t   _dbus_string_validate_utf8         (const DBusString  *str,
208                                                   int                start,
209                                                   int                len);
210 dbus_bool_t   _dbus_string_validate_nul          (const DBusString  *str,
211                                                   int                start,
212                                                   int                len);
213 void          _dbus_string_zero                  (DBusString        *str);
214
215
216 DBUS_END_DECLS;
217
218 #endif /* DBUS_STRING_H */