cstr.h 1.44 KB
Newer Older
#ifndef CSTR_H
#define CSTR_H
#ifdef __cplusplus
extern "C" {
#endif

int    cstrlen(const char * str);
/* copy src to dst and return pointer to the next byte after the end */ 
char * cstrcpy(char * dst, const char * src);

/* copy up to maxsize characters from src to dst and return pointer to the next byte after the end */ 
char * cstrncpy(char * dst, int maxsize, const char * src);

/* copy up to maxsize characters from parameters to dst and return pointer to the next byte after the end */ 
char * cvstrncpy(char * dst, int maxsize, const char * ptr, ...);


/* allocate copy of the str */ 
char * cstralloc(int size);
char * cstrdup(const char * str);
char * cstrndup(const char * str, int max_size);


/* allocate new str and collect all paramaters */ 
char * cvstrdup(const char * ptr, ...);

char * cstrnload(char * dst, int max_size, const char * path);
char * cstraload(char ** p, const char * path);

const char * cstrlastpathelement(const char * str);

int cstr_write(const char * const p, char ** const ptr, const char * const end, int * const error);
int cstr_read (char * const p, const char ** const ptr, const char * const end, int * const error);

int cstrn_write(const char * const p, int length, char ** const ptr, const char * const end, int * const error);
int cstrn_read (char * const p, int length, const char ** const ptr, const char * const end, int * const error);

#ifdef __cplusplus
}
#endif
#endif