aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-09 19:01:49 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-09 19:01:49 +0000
commit060add957685ac818b3a3f9a9f266b57073a3a06 (patch)
treeda459769ea06449860ba3cb376b0b64aa6aebc55 /src/include
parent82bc3225b7b1167f04b92ec5ef7799b0d3c884ef (diff)
downloadgnunet-060add957685ac818b3a3f9a9f266b57073a3a06.tar.gz
gnunet-060add957685ac818b3a3f9a9f266b57073a3a06.zip
-fixes
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_strings_lib.h127
1 files changed, 83 insertions, 44 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index b4ae27c32..4073b0cfa 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) 3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -108,7 +108,9 @@ GNUNET_STRINGS_byte_size_fancy (unsigned long long size);
108 */ 108 */
109char * 109char *
110GNUNET_STRINGS_conv (const char *input, size_t len, 110GNUNET_STRINGS_conv (const char *input, size_t len,
111 const char *input_charset, const char *output_charset); 111 const char *input_charset,
112 const char *output_charset);
113
112 114
113/** 115/**
114 * Convert the len characters long character sequence 116 * Convert the len characters long character sequence
@@ -121,7 +123,10 @@ GNUNET_STRINGS_conv (const char *input, size_t len,
121 * @return the converted string (0-terminated) 123 * @return the converted string (0-terminated)
122 */ 124 */
123char * 125char *
124GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset); 126GNUNET_STRINGS_to_utf8 (const char *input,
127 size_t len,
128 const char *charset);
129
125 130
126/** 131/**
127 * Convert the len bytes-long UTF-8 string 132 * Convert the len bytes-long UTF-8 string
@@ -132,7 +137,10 @@ GNUNET_STRINGS_to_utf8 (const char *input, size_t len, const char *charset);
132 * string is returned. 137 * string is returned.
133 */ 138 */
134char * 139char *
135GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset); 140GNUNET_STRINGS_from_utf8 (const char *input,
141 size_t len,
142 const char *charset);
143
136 144
137/** 145/**
138 * Convert the utf-8 input string to lowercase 146 * Convert the utf-8 input string to lowercase
@@ -142,7 +150,8 @@ GNUNET_STRINGS_from_utf8 (const char *input, size_t len, const char *charset);
142 * @param output output buffer 150 * @param output output buffer
143 */ 151 */
144void 152void
145GNUNET_STRINGS_utf8_tolower(const char* input, char** output); 153GNUNET_STRINGS_utf8_tolower (const char* input,
154 char** output);
146 155
147 156
148/** 157/**
@@ -153,7 +162,8 @@ GNUNET_STRINGS_utf8_tolower(const char* input, char** output);
153 * @param output output buffer 162 * @param output output buffer
154 */ 163 */
155void 164void
156GNUNET_STRINGS_utf8_toupper(const char* input, char** output); 165GNUNET_STRINGS_utf8_toupper (const char* input,
166 char** output);
157 167
158 168
159/** 169/**
@@ -169,16 +179,14 @@ GNUNET_STRINGS_filename_expand (const char *fil);
169 179
170 180
171/** 181/**
172 * Fill a buffer of the given size with 182 * Fill a buffer of the given size with count 0-terminated strings
173 * count 0-terminated strings (given as varargs). 183 * (given as varargs). If "buffer" is NULL, only compute the amount
174 * If "buffer" is NULL, only compute the amount of 184 * of space required (sum of "strlen(arg)+1").
175 * space required (sum of "strlen(arg)+1").
176 * 185 *
177 * Unlike using "snprintf" with "%s", this function 186 * Unlike using "snprintf" with "%s", this function will add
178 * will add 0-terminators after each string. The 187 * 0-terminators after each string. The
179 * "GNUNET_string_buffer_tokenize" function can be 188 * "GNUNET_string_buffer_tokenize" function can be used to parse the
180 * used to parse the buffer back into individual 189 * buffer back into individual strings.
181 * strings.
182 * 190 *
183 * @param buffer the buffer to fill with strings, can 191 * @param buffer the buffer to fill with strings, can
184 * be NULL in which case only the necessary 192 * be NULL in which case only the necessary
@@ -190,15 +198,16 @@ GNUNET_STRINGS_filename_expand (const char *fil);
190 * (or number of bytes that would have been written) 198 * (or number of bytes that would have been written)
191 */ 199 */
192size_t 200size_t
193GNUNET_STRINGS_buffer_fill (char *buffer, size_t size, unsigned int count, ...); 201GNUNET_STRINGS_buffer_fill (char *buffer,
202 size_t size,
203 unsigned int count,
204 ...);
194 205
195 206
196/** 207/**
197 * Given a buffer of a given size, find "count" 208 * Given a buffer of a given size, find "count" 0-terminated strings
198 * 0-terminated strings in the buffer and assign 209 * in the buffer and assign the count (varargs) of type "const char**"
199 * the count (varargs) of type "const char**" to the 210 * to the locations of the respective strings in the buffer.
200 * locations of the respective strings in the
201 * buffer.
202 * 211 *
203 * @param buffer the buffer to parse 212 * @param buffer the buffer to parse
204 * @param size size of the buffer 213 * @param size size of the buffer
@@ -232,6 +241,7 @@ GNUNET_STRINGS_absolute_time_to_string (struct GNUNET_TIME_Absolute t);
232char * 241char *
233GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta); 242GNUNET_STRINGS_relative_time_to_string (struct GNUNET_TIME_Relative delta);
234 243
244
235/** 245/**
236 * "man basename" 246 * "man basename"
237 * Returns a pointer to a part of filename (allocates nothing)! 247 * Returns a pointer to a part of filename (allocates nothing)!
@@ -263,8 +273,10 @@ GNUNET_STRINGS_get_short_name (const char *filename);
263 * @return pointer to the next byte in 'out' or NULL on error. 273 * @return pointer to the next byte in 'out' or NULL on error.
264 */ 274 */
265char * 275char *
266GNUNET_STRINGS_data_to_string (const unsigned char *data, size_t size, 276GNUNET_STRINGS_data_to_string (const unsigned char *data,
267 char *out, size_t out_size); 277 size_t size,
278 char *out,
279 size_t out_size);
268 280
269 281
270/** 282/**
@@ -278,24 +290,11 @@ GNUNET_STRINGS_data_to_string (const unsigned char *data, size_t size,
278 * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding 290 * @return GNUNET_OK on success, GNUNET_SYSERR if result has the wrong encoding
279 */ 291 */
280int 292int
281GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen, 293GNUNET_STRINGS_string_to_data (const char *enc,
282 unsigned char *out, size_t out_size); 294 size_t enclen,
283 295 unsigned char *out,
296 size_t out_size);
284 297
285#if 0 /* keep Emacsens' auto-indent happy */
286{
287#endif
288#ifdef __cplusplus
289}
290#endif
291
292enum GNUNET_STRINGS_FilenameCheck
293{
294 GNUNET_STRINGS_CHECK_EXISTS = 0x00000001,
295 GNUNET_STRINGS_CHECK_IS_DIRECTORY = 0x00000002,
296 GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004,
297 GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008
298};
299 298
300/** 299/**
301 * Parse a path that might be an URI. 300 * Parse a path that might be an URI.
@@ -314,8 +313,9 @@ enum GNUNET_STRINGS_FilenameCheck
314 * (if they weren't NULL). 313 * (if they weren't NULL).
315 */ 314 */
316int 315int
317GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part, 316GNUNET_STRINGS_parse_uri (const char *path,
318 const char **path_part); 317 char **scheme_part,
318 const char **path_part);
319 319
320 320
321/** 321/**
@@ -340,7 +340,35 @@ GNUNET_STRINGS_path_is_absolute (const char *filename,
340 340
341 341
342/** 342/**
343 * Perform checks on 'filename; 343 * Flags for what we should check a file for.
344 */
345enum GNUNET_STRINGS_FilenameCheck
346{
347 /**
348 * Check that it exists.
349 */
350 GNUNET_STRINGS_CHECK_EXISTS = 0x00000001,
351
352 /**
353 * Check that it is a directory.
354 */
355 GNUNET_STRINGS_CHECK_IS_DIRECTORY = 0x00000002,
356
357 /**
358 * Check that it is a link.
359 */
360 GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004,
361
362 /**
363 * Check that the path is an absolute path.
364 */
365 GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008
366};
367
368
369/**
370 * Perform checks on 'filename'. FIXME: some duplication with
371 * "GNUNET_DISK_"-APIs. We should unify those.
344 * 372 *
345 * @param filename file to check 373 * @param filename file to check
346 * @param checks checks to perform 374 * @param checks checks to perform
@@ -417,9 +445,20 @@ GNUNET_STRINGS_to_address_ip (const char *addr,
417 * @return GNUNET_OK on success, GNUNET_SYSERR on failure 445 * @return GNUNET_OK on success, GNUNET_SYSERR on failure
418 */ 446 */
419int 447int
420GNUNET_STRINGS_get_utf8_args (int argc, char *const *argv, int *u8argc, 448GNUNET_STRINGS_get_utf8_args (int argc,
449 char *const *argv,
450 int *u8argc,
421 char *const **u8argv); 451 char *const **u8argv);
422 452
453
454#if 0 /* keep Emacsens' auto-indent happy */
455{
456#endif
457#ifdef __cplusplus
458}
459#endif
460
461
423/* ifndef GNUNET_UTIL_STRING_H */ 462/* ifndef GNUNET_UTIL_STRING_H */
424#endif 463#endif
425/* end of gnunet_util_string.h */ 464/* end of gnunet_util_string.h */