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 Make a temporary filename.
00073  *
00074  * @param template  Template to replace. The last six characters of template
00075  *                  must be XXXXXX and these are replaced with a string that
00076  *                  makes the filename more or less unique. Since it will be
00077  *                  modified, template must not be a string constant, but
00078  *                  should be declared as a character array.
00079  *
00080  * @return 0 on succes, < 0 on error with errno set.
00081  */
00082 int c_tmpname(char *template);
00083 
00084 /**
00085  * @brief parse a uri and split it into components.
00086  *
00087  * parse_uri parses an uri in the format
00088  *
00089  * [<scheme>:][//[<user>[:<password>]@]<host>[:<port>]]/[<path>]
00090  *
00091  * into its compoments. If you only want a special component,
00092  * pass NULL for all other components. All components will be allocated if they have
00093  * been found.
00094  *
00095  * @param uri       The uri to parse.
00096  * @param scheme    String for the scheme component
00097  * @param user      String for the username component
00098  * @param passwd    String for the password component
00099  * @param host      String for the password component
00100  * @param port      Integer for the port
00101  * @param path      String for the path component with a leading slash.
00102  *
00103  * @return  0 on success, < 0 on error.
00104  */
00105 int c_parse_uri(const char *uri, char **scheme, char **user, char **passwd,
00106     char **host, unsigned int *port, char **path);
00107 
00108 /**
00109  * }@
00110  */
00111 #endif /* _C_PATH_H */

Generated on Mon May 4 17:43:35 2009 for doc by  doxygen 1.5.6