Back to index

avfs  1.0.1
uri.h
Go to the documentation of this file.
00001 /* 
00002    HTTP URI handling
00003    Copyright (C) 1999-2001, Joe Orton <joe@light.plus.com>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009    
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00018    MA 02111-1307, USA
00019 
00020 */
00021 
00022 #ifndef URI_H
00023 #define URI_H
00024 
00025 #include "neon_defs.h"
00026 
00027 BEGIN_NEON_DECLS
00028 
00029 /* Un-escapes a URI. Returns malloc-allocated URI on success,
00030  * or NULL on failure (malloc failure or invalid %<HEX><HEX> sequence). */
00031 char *uri_unescape(const char *uri);
00032 
00033 /* Escapes the abspath segment of a URI.
00034  * Returns malloc-allocated string on success, or NULL on malloc failure.
00035  */
00036 char *uri_abspath_escape(const char *abs_path);
00037 
00038 /* Returns abspath segment in (absolute) uri */
00039 const char *uri_abspath(const char *uri);
00040 
00041 /* Returns parent of path */
00042 char *uri_parent(const char *path);
00043 
00044 /* Returns strcmp-like value giving comparison between a and b,
00045  * ignoring trailing-slashes. */
00046 int uri_compare(const char *a, const char *b);
00047 
00048 /* Returns an absolute URI from a possibly-relative 'uri', using
00049  * given scheme + hostport segment.
00050  * Returns malloc-allocated string on success, or NULL on malloc failure. */
00051 char *uri_absolute(const char *uri, const char *scheme, const char *hostport);
00052 
00053 /* Returns non-zero if child is a child of parent */
00054 int uri_childof(const char *parent, const char *child);
00055 
00056 /* Returns non-zero if uri has a trailing slash character */
00057 int uri_has_trailing_slash(const char *uri);
00058 
00059 struct uri {
00060     char *scheme;
00061     char *host;
00062     int port;
00063     char *path;
00064 };
00065 
00066 int uri_parse(const char *uri, struct uri *parsed, const struct uri *defaults);
00067 
00068 void uri_free(struct uri *parsed);
00069 
00070 END_NEON_DECLS
00071 
00072 #endif /* URI_H */
00073