doc
Data Structures | Functions | Variables
cynapses libc path functions

Data Structures

struct  C_PATHINFO
 

Functions

char * c_basename (const char *path)
 
char * c_dirname (const char *path)
 
int c_parse_uri (const char *uri, char **scheme, char **user, char **passwd, char **host, unsigned int *port, char **path)
 
C_PATHINFOc_split_path (const char *pathSrc)
 
char * c_tmpname (const char *templ)
 

Variables

char * C_PATHINFO::directory
 
char * C_PATHINFO::extension
 
char * C_PATHINFO::filename
 

Detailed Description

Function Documentation

char* c_basename ( const char *  path)

basename - parse filename component.

basename breaks a null-terminated pathname string into a filename component. c_basename() returns the component following the final '/'. Trailing '/' characters are not counted as part of the pathname.

Parameters
pathThe path to parse.
Returns
The filename of path or NULL if we can't allocate memory. If path is a the string "/", basename returns the string "/". If path is NULL or an empty string, "." is returned.
char* c_dirname ( const char *  path)

Parse directory component.

dirname breaks a null-terminated pathname string into a directory component. In the usual case, c_dirname() returns the string up to, but not including, the final '/'. Trailing '/' characters are not counted as part of the pathname. The caller must free the memory.

Parameters
pathThe path to parse.
Returns
The dirname of path or NULL if we can't allocate memory. If path does not contain a slash, c_dirname() returns the string ".". If path is the string "/", it returns the string "/". If path is NULL or an empty string, "." is returned.
int c_parse_uri ( const char *  uri,
char **  scheme,
char **  user,
char **  passwd,
char **  host,
unsigned int *  port,
char **  path 
)

parse a uri and split it into components.

parse_uri parses an uri in the format

[<scheme>:][//[<user>[:<password>]@]<host>[:<port>]]/[<path>]

into its compoments. If you only want a special component, pass NULL for all other components. All components will be allocated if they have been found.

Parameters
uriThe uri to parse.
schemeString for the scheme component
userString for the username component
passwdString for the password component
hostString for the password component
portInteger for the port
pathString for the path component with a leading slash.
Returns
0 on success, < 0 on error.
C_PATHINFO* c_split_path ( const char *  pathSrc)

Extracting directory, filename and extension from a path.

Parameters
pathSrcThe path to parse.
Returns
Returns a C_PATHINFO structure that should be freed using SAFE_FREE().
char* c_tmpname ( const char *  templ)

Make a temporary filename.

Parameters
templThe template to replace. If the template contains six X like 'XXXXXX', these are replaced by a random string. If not, the templ is interpreted as a path, and a name to a hidden file with six random is returned. The caller has to free the memory.
Returns
a poitner to the random hidden filename or NULL.

Variable Documentation

char* C_PATHINFO::directory

Definition at line 120 of file c_path.h.

char* C_PATHINFO::extension

Definition at line 122 of file c_path.h.

char* C_PATHINFO::filename

Definition at line 121 of file c_path.h.