2002-12-25 Havoc Pennington <hp@pobox.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 };
46
47 dbus_bool_t _dbus_string_init           (DBusString *str,
48                                          int         max_length);
49 void        _dbus_string_init_const     (DBusString *str,
50                                          const char *value);
51 void        _dbus_string_free           (DBusString *str);
52 void        _dbus_string_lock           (DBusString *str);
53
54 void        _dbus_string_get_data           (DBusString        *str,
55                                              char             **data_return);
56 void        _dbus_string_get_const_data     (const DBusString  *str,
57                                              const char       **data_return);
58 void        _dbus_string_get_data_len       (DBusString        *str,
59                                              char             **data_return,
60                                              int                start,
61                                              int                len);
62 void        _dbus_string_get_const_data_len (const DBusString  *str,
63                                              const char       **data_return,
64                                              int                start,
65                                              int                len);
66 dbus_bool_t _dbus_string_steal_data         (DBusString        *str,
67                                              char             **data_return);
68 dbus_bool_t _dbus_string_steal_data_len     (DBusString        *str,
69                                              char             **data_return,
70                                              int                start,
71                                              int                len);
72
73 int  _dbus_string_get_length         (const DBusString  *str);
74
75 dbus_bool_t _dbus_string_lengthen   (DBusString *str,
76                                      int         additional_length);
77 void        _dbus_string_shorten    (DBusString *str,
78                                      int         length_to_remove);
79 dbus_bool_t _dbus_string_set_length (DBusString *str,
80                                      int         length);
81
82 dbus_bool_t _dbus_string_append         (DBusString    *str,
83                                          const char    *buffer);
84 dbus_bool_t _dbus_string_append_len     (DBusString    *str,
85                                          const char    *buffer,
86                                          int            len);
87 dbus_bool_t _dbus_string_append_int     (DBusString    *str,
88                                          long           value);
89 dbus_bool_t _dbus_string_append_double  (DBusString    *str,
90                                          double         value);
91 dbus_bool_t _dbus_string_append_byte    (DBusString    *str,
92                                          unsigned char  byte);
93 dbus_bool_t _dbus_string_append_unichar (DBusString    *str,
94                                          dbus_unichar_t ch);
95
96
97 void        _dbus_string_delete     (DBusString       *str,
98                                      int               start,
99                                      int               len);
100 dbus_bool_t _dbus_string_move       (DBusString       *source,
101                                      int               start,
102                                      DBusString       *dest,
103                                      int               insert_at);
104 dbus_bool_t _dbus_string_copy       (const DBusString *source,
105                                      int               start,
106                                      DBusString       *dest,
107                                      int               insert_at);
108 dbus_bool_t _dbus_string_move_len   (DBusString       *source,
109                                      int               start,
110                                      int               len,
111                                      DBusString       *dest,
112                                      int               insert_at);
113 dbus_bool_t _dbus_string_copy_len   (const DBusString *source,
114                                      int               start,
115                                      int               len,
116                                      DBusString       *dest,
117                                      int               insert_at);
118
119
120 void       _dbus_string_get_unichar (const DBusString *str,
121                                      int               start,
122                                      dbus_unichar_t   *ch_return,
123                                      int              *end_return);
124
125 dbus_bool_t _dbus_string_parse_int    (const DBusString *str,
126                                        int               start,
127                                        long             *value_return,
128                                        int              *end_return);
129 dbus_bool_t _dbus_string_parse_double (const DBusString *str,
130                                        int               start,
131                                        double           *value,
132                                        int              *end_return);
133
134 dbus_bool_t _dbus_string_find         (const DBusString *str,
135                                        int               start,
136                                        const char       *substr,
137                                        int              *found);
138
139 dbus_bool_t _dbus_string_find_blank   (const DBusString *str,
140                                        int               start,
141                                        int              *found);
142
143 void        _dbus_string_skip_blank   (const DBusString *str,
144                                        int               start,
145                                        int              *end);
146
147 dbus_bool_t _dbus_string_equal        (const DBusString *a,
148                                        const DBusString *b);
149
150 dbus_bool_t _dbus_string_equal_c_str  (const DBusString *a,
151                                        const char       *c_str);
152
153 dbus_bool_t _dbus_string_base64_encode (const DBusString *source,
154                                         int               start,
155                                         DBusString       *dest,
156                                         int               insert_at);
157 dbus_bool_t _dbus_string_base64_decode (const DBusString *source,
158                                         int               start,
159                                         DBusString       *dest,
160                                         int               insert_at);
161
162 DBUS_END_DECLS;
163
164 #endif /* DBUS_STRING_H */