Skip to content
function.h 2.24 KiB
Newer Older
Seblu's avatar
Seblu committed
/*
Seblu's avatar
Seblu committed
** function.h for 42sh
Seblu's avatar
Seblu committed
**
** Made by Seblu
** Login   <seblu@epita.fr>
**
** Started on  Sun Jul 30 03:59:48 2006 Seblu
Seblu's avatar
Seblu committed
** Last update Tue Nov 14 15:36:14 2006 seblu
Seblu's avatar
Seblu committed
#ifndef FUNCTION_H_
# define FUNCTION_H_
Seblu's avatar
Seblu committed
/*!
** Merge strings
**
** @param n number of string to merge
** @param s1 First string to merge
**
** @return malloced string merged
** @warning the returned string must be freed by the caller
*/
Seblu's avatar
Seblu committed
char            *strmerge(int n, const char *s1, ...);
Seblu's avatar
Seblu committed

/*!
** Merge a vector of string
**
** @param vtable strings to merge
**
** @return a string merged from @arg vtable
*/
Seblu's avatar
Seblu committed
char            *strvmerge(const char * const *vtable);

Seblu's avatar
Seblu committed
/*!
** Return a malloc copy of the given, conserving only the basename
**
** @param path path where basename will be extracted
**
** @return malloced basename
** @warning Not use the standard function for reason of vicious
** definition in manuel.
*/
char		*basename(const char *path);

/*!
** Duplicate a string for @arg n characteres
**
** @param str string to duplicate
** @param n number of caractere to duplicate
**
** @return a new malloced string
*/
char            *strndup(const char *str, size_t n);

Seblu's avatar
Seblu committed
/*!
** Compute if string is composed only by digit
**
** @param str string to test
**
** @return boolean result
*/
int		isdigitstr(const char *str);

Seblu's avatar
Seblu committed
/*!
** Add @arg str at the end of @arg vector. vector is a
** table of char *, where the last element is NULL.
** if @arg str is NULL, nothing is done
**
** @param vector first vector
** @param str string to add at the end of vector
**
** @return the new vector. You should not think that have the
** same address that @arg vector
*/
char		**strvectoradd(char **vector, char *str);

Seblu's avatar
Seblu committed
/*!
** Return the current working directory in a malloced string.
**
** @return the current working directory
*/
char			*getcwd2(void);

/*!
** Add a name and value to the current environment
**
** @param name variable name
** @param value variable value
** @param overwrite boolean which tell if overwrite a existing value
**
** @return boolean success
*/
int		setenv2(char	*name,
			char	*value,
			int	overwrite);

/*!
** Remove from environment a variable.
** @warning Don't use unsetenv !
**
** @param name env variable to remove
**
** @return boolean success
*/
int		unsetenv2(const char *name);

Seblu's avatar
Seblu committed
#endif