File: strutil.h

package info (click to toggle)
d1x-rebirth 0.58.1-1.2
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, sid
  • size: 5,876 kB
  • sloc: ansic: 95,642; asm: 1,228; ada: 364; objc: 243; python: 121; cpp: 118; makefile: 23
file content (37 lines) | stat: -rw-r--r-- 1,830 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef _STRUTILS_H
#define _STRUTILS_H

#if defined(macintosh)
extern void snprintf(char *out_string, int size, char * format, ... );
#endif
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 );
extern char *d_strdup(char *str);

// remove extension from filename, doesn't work with paths.
void removeext(const char *filename, char *out);

//give a filename a new extension, doesn't work with paths with no extension already there
extern void change_filename_extension( char *dest, const char *src, char *new_ext );

// 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'
extern void d_splitpath(char *name, char *drive, char *path, char *base, char *ext);

// 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 * ));

#endif /* _STRUTILS_H */