-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutil.h
More file actions
84 lines (64 loc) · 1.82 KB
/
util.h
File metadata and controls
84 lines (64 loc) · 1.82 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* $Id: util.h,v 1.7 2001/12/15 20:23:20 gray Exp $ */
/*
* $Log: util.h,v $
* Revision 1.7 2001/12/15 20:23:20 gray
* Work around a name conflict on Linux.
*
* Revision 1.6 1995/07/04 23:43:33 gray
* When on Macintosh, use ':' as the directory delimiter.
*
* Revision 1.5 1995/05/22 02:52:28 gray
* Add recognition of Windows NT - treat the same as MS-DOS.
*
* Revision 1.4 1995/05/08 03:19:46 gray
* Define `MSDOS' if `__MSDOS__' is defined.
*/
#ifndef UTIL_H
#define UTIL_H
#include <stdlib.h>
#ifndef MSDOS
#if defined(__MSDOS__) || defined(_MSDOS) || defined(_WIN32)
#define MSDOS 1
#endif
#endif
typedef enum {
MemoryPatterns, MemoryStream, MemoryInputBuf, MemoryOutputBuf,
MemoryVar, MemoryPath, MemoryRegexp, MemoryDispatch
} Memory_Kinds;
#ifdef __linux__
/* On Linux, change the name of this to avoid some sort of compiler or
linker confusion when optimized. */
#define allocate gema_mem_alloc
#endif
/* allocate memory space; does not return unless succesful */
void* allocate( size_t size, Memory_Kinds what );
char* str_dup( const char* x ); /* return new copy of string */
char* str_dup_len( const char* x, int len );
/* directory delimiter character */
#if defined(MSDOS)
#define DirDelim '\\'
#elif defined(MACOS)
#define DirDelim ':'
#else /* assume Unix */
#define DirDelim '/'
#endif
const char*
pathname_name_and_type(const char* path);
const char*
pathname_type(const char* path);
char*
pathname_merge_directory( const char* path, const char* dir );
int
is_absolute_pathname(const char* path);
const char*
relative_pathname(const char* relative_to, const char* file_path);
const char*
canonicalize_path(const char* path);
#ifdef MSDOS
#define HAS_STRICMP
#endif
#ifndef HAS_STRICMP
/* unless already provided in the compiler's library */
int stricmp (const char* s1, const char* s2);
#endif
#endif