2010-07-19 18:17:08 +00:00
|
|
|
#ifndef _STRUTILS_H
|
|
|
|
#define _STRUTILS_H
|
2006-03-20 16:43:15 +00:00
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-01-03 10:31:02 +00:00
|
|
|
#if defined(macintosh)
|
2013-06-08 22:24:17 +00:00
|
|
|
extern void snprintf(char *out_string, int size, const char * format, ... );
|
2010-07-19 18:17:08 +00:00
|
|
|
#endif
|
2012-05-18 23:36:41 +00:00
|
|
|
extern int d_stricmp( const char *s1, const char *s2 );
|
|
|
|
extern int d_strnicmp( const char *s1, const char *s2, int n );
|
|
|
|
extern void d_strlwr( char *s1 );
|
|
|
|
extern void d_strupr( char *s1 );
|
|
|
|
extern void d_strrev( char *s1 );
|
2013-06-08 22:24:17 +00:00
|
|
|
extern char *d_strdup(const char *str);
|
2008-01-19 01:13:47 +00:00
|
|
|
|
2013-06-09 18:10:09 +00:00
|
|
|
struct splitpath_t
|
|
|
|
{
|
|
|
|
const char *drive_start, *drive_end, *path_start, *path_end, *base_start, *base_end, *ext_start;
|
|
|
|
};
|
|
|
|
|
2008-02-11 12:12:57 +00:00
|
|
|
// remove extension from filename, doesn't work with paths.
|
|
|
|
void removeext(const char *filename, char *out);
|
|
|
|
|
2010-09-26 13:15:20 +00:00
|
|
|
//give a filename a new extension, doesn't work with paths with no extension already there
|
2013-06-08 22:24:17 +00:00
|
|
|
extern void change_filename_extension( char *dest, const char *src, const char *new_ext );
|
2008-01-19 01:13:47 +00:00
|
|
|
|
2012-07-24 09:29:43 +00:00
|
|
|
// split an MS-DOS path into drive, directory path, filename without the extension (base) and extension.
|
|
|
|
// if it's just a filename with no directory specified, this function will get 'base' and 'ext'
|
2013-06-09 18:10:09 +00:00
|
|
|
void d_splitpath(const char *name, struct splitpath_t *path);
|
2010-07-19 18:17:08 +00:00
|
|
|
|
2010-09-26 13:15:20 +00:00
|
|
|
// create a growing 2D array with a single growing buffer for the text
|
|
|
|
// this system is likely to cause less memory fragmentation than having one malloc'd buffer per string
|
|
|
|
int string_array_new(char ***list, char **list_buf, int *num_str, int *max_str, int *max_buf);
|
|
|
|
|
|
|
|
// add a string to a growing 2D array
|
|
|
|
int string_array_add(char ***list, char **list_buf, int *num_str, int *max_str, int *max_buf, const char *str);
|
|
|
|
|
|
|
|
// sort function passed to qsort - also useful for 2d string arrays with individual string pointers
|
|
|
|
int string_array_sort_func(char **e0, char **e1);
|
|
|
|
|
|
|
|
// reallocate pointers to save memory, sort list alphabetically and remove duplicates according to 'comp'
|
|
|
|
void string_array_tidy(char ***list, char **list_buf, int *num_str, int *max_str, int *max_buf, int offset, int (*comp)( const char *, const char * ));
|
|
|
|
|
2012-11-11 22:12:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-19 18:17:08 +00:00
|
|
|
#endif /* _STRUTILS_H */
|