c_path.h

Go to the documentation of this file.
00001 /*
00002  * cynapses libc functions
00003  *
00004  * Copyright (c) 2007-2008 by Andreas Schneider <mail@cynapses.org>
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  *
00020  * vim: ft=c.doxygen ts=2 sw=2 et cindent
00021  */
00022 
00023 /**
00024  * @file c_path.h
00025  *
00026  * @brief Interface of the cynapses libc path functions
00027  *
00028  * @defgroup cynPathInternals cynapses libc path functions
00029  * @ingroup cynLibraryAPI
00030  *
00031  * @{
00032  */
00033 
00034 #ifndef _C_PATH_H
00035 #define _C_PATH_H
00036 
00037 #include "c_macro.h"
00038 
00039 /**
00040  * @brief Parse directory component.
00041  *
00042  * dirname breaks a null-terminated pathname string into a directory component.
00043  * In the usual case, c_dirname() returns the string up to, but not including,
00044  * the final '/'. Trailing '/' characters are  not  counted as part of the
00045  * pathname. The caller must free the memory.
00046  *
00047  * @param path  The path to parse.
00048  *
00049  * @return  The dirname of path or NULL if we can't allocate memory. If path
00050  *          does not contain a slash, c_dirname() returns the string ".".  If
00051  *          path is the string "/", it returns the string "/". If path is
00052  *          NULL or an empty string, "." is returned.
00053  */
00054 char *c_dirname(const char *path);
00055 
00056 /**
00057  * @brief basename - parse filename component.
00058  *
00059  * basename breaks a null-terminated pathname string into a filename component.
00060  * c_basename() returns the component following the final '/'.  Trailing '/'
00061  * characters are not counted as part of the pathname.
00062  *
00063  * @param path The path to parse.
00064  *
00065  * @return  The filename of path or NULL if we can't allocate memory. If path
00066  *          is a the string "/", basename returns the string "/". If path is
00067  *          NULL or an empty string, "." is returned.
00068  */
00069 char *c_basename (const char *path);
00070 
00071 /**
00072  * @brief parse a uri and split it into components.
00073  *
00074  * parse_uri parses an uri in the format
00075  *
00076  * [<scheme>:][//[<user>[:<password>]@]<host>[:<port>]]/[<path>]
00077  *
00078  * into its compoments. If you only want a special component,
00079  * pass NULL for all other components. All components will be allocated if they have
00080  * been found.
00081  *
00082  * @param uri       The uri to parse.
00083  * @param scheme    String for the scheme component
00084  * @param user      String for the username component
00085  * @param passwd    String for the password component
00086  * @param host      String for the password component
00087  * @param port      Integer for the port
00088  * @param path      String for the path component with a leading slash.
00089  *
00090  * @return  0 on success, < 0 on error.
00091  */
00092 int c_parse_uri(const char *uri, char **scheme, char **user, char **passwd,
00093     char **host, unsigned int *port, char **path);
00094 
00095 /**
00096  * }@
00097  */
00098 #endif /* _C_PATH_H */

Generated on Wed Dec 3 19:20:09 2008 for csync by  doxygen 1.5.6