diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-05 19:54:31 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-05 19:54:31 +0000 |
commit | dffa6f386418b19956f23f13f3f2a32cd803bca4 (patch) | |
tree | 3c8bd3a30947452d06a5bd253619a512d025fae0 /src/include/gnunet_strings_lib.h | |
parent | 8d55b650ddeecf9e76e4dd6e03951340cc6f39d7 (diff) | |
download | gnunet-dffa6f386418b19956f23f13f3f2a32cd803bca4.tar.gz gnunet-dffa6f386418b19956f23f13f3f2a32cd803bca4.zip |
-LRN: file checking routines
Diffstat (limited to 'src/include/gnunet_strings_lib.h')
-rw-r--r-- | src/include/gnunet_strings_lib.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h index 4fb007707..385b6c042 100644 --- a/src/include/gnunet_strings_lib.h +++ b/src/include/gnunet_strings_lib.h | |||
@@ -256,6 +256,64 @@ GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen, | |||
256 | } | 256 | } |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | enum GNUNET_STRINGS_FilenameCheck | ||
260 | { | ||
261 | GNUNET_STRINGS_CHECK_EXISTS = 0x00000001, | ||
262 | GNUNET_STRINGS_CHECK_IS_DIRECTORY = 0x00000002, | ||
263 | GNUNET_STRINGS_CHECK_IS_LINK = 0x00000004, | ||
264 | GNUNET_STRINGS_CHECK_IS_ABSOLUTE = 0x00000008 | ||
265 | }; | ||
266 | |||
267 | /** | ||
268 | * Parse a path that might be an URI. | ||
269 | * | ||
270 | * @param path path to parse. Must be NULL-terminated. | ||
271 | * @param scheme_part a pointer to 'char *' where a pointer to a string that | ||
272 | * represents the URI scheme will be stored. Can be NULL. The string is | ||
273 | * allocated by the function, and should be freed by GNUNET_free() when | ||
274 | * it is no longer needed. | ||
275 | * @param path_part a pointer to 'const char *' where a pointer to the path | ||
276 | * part of the URI will be stored. Can be NULL. Points to the same block | ||
277 | * of memory as 'path', and thus must not be freed. Might point to '\0', | ||
278 | * if path part is zero-length. | ||
279 | * @return GNUNET_YES if it's an URI, GNUNET_NO otherwise. If 'path' is not | ||
280 | * an URI, '* scheme_part' and '*path_part' will remain unchanged | ||
281 | * (if they weren't NULL). | ||
282 | */ | ||
283 | int | ||
284 | GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part, | ||
285 | const char **path_part); | ||
286 | |||
287 | /** | ||
288 | * Check whether @filename is absolute or not, and if it's an URI | ||
289 | * | ||
290 | * @param filename filename to check | ||
291 | * @param can_be_uri GNUNET_YES to check for being URI, GNUNET_NO - to | ||
292 | * assume it's not URI | ||
293 | * @param r_is_uri a pointer to an int that is set to GNUNET_YES if @filename | ||
294 | * is URI and to GNUNET_NO otherwise. Can be NULL. If @can_be_uri is | ||
295 | * not GNUNET_YES, *r_is_uri is set to GNUNET_NO. | ||
296 | * @param r_uri a pointer to a char * that is set to a pointer to URI scheme. | ||
297 | * The string is allocated by the function, and should be freed with | ||
298 | * GNUNET_free (). Can be NULL. | ||
299 | * @return GNUNET_YES if @filaneme is absolute, GNUNET_NO otherwise. | ||
300 | */ | ||
301 | int | ||
302 | GNUNET_STRINGS_path_is_absolute (const char *filename, int can_be_uri, | ||
303 | int *r_is_uri, char **r_uri_scheme); | ||
304 | |||
305 | /** | ||
306 | * Perform @checks on @filename | ||
307 | * | ||
308 | * @param filename file to check | ||
309 | * @param checks checks to perform | ||
310 | * @return GNUNET_YES if all @checks pass, GNUNET_NO if at least one of them | ||
311 | * fails, GNUNET_SYSERR when a check can't be performed | ||
312 | */ | ||
313 | int | ||
314 | GNUNET_STRINGS_check_filename (const char *filename, | ||
315 | enum GNUNET_STRINGS_FilenameCheck checks); | ||
316 | |||
259 | 317 | ||
260 | /* ifndef GNUNET_UTIL_STRING_H */ | 318 | /* ifndef GNUNET_UTIL_STRING_H */ |
261 | #endif | 319 | #endif |