1 #ifndef _COMPAT_H
2 #define _COMPAT_H
3 
4 #include <sys/time.h>
5 
6 #define DOS_CLK_TCK 0x10000
7 
8 extern time_t dos_clock(void);
9 
10 void getext_malloc (const char *src, char **ext);
11 extern int splitpath4_malloc(const char *src, char **drive, char **path, char **file, char **ext); /* returns non-zero on errors */
12 extern int splitpath_malloc(const char *src, char **drive, char **path, char **filename); /* returns non-zero on errors */
13 extern int makepath_malloc(char **dst, const char *drive, const char *path, const char *file, const char *ext); /* returns non-zero on errors */
14 
15 #ifndef HAVE_STRUPR
16 extern char *strupr(char *src);
17 #else
18 #include <string.h>
19 #endif
20 
21 #ifndef HAVE_VSNPRINTF
22 #include <stdarg.h> /* for va_list */
23 extern int vsnprintf(char *buff, size_t bufsiz, const char *fmt, va_list ap);
24 #endif
25 
26 #ifndef HAVE_SNPRINTF
27 extern int snprintf(char *buff, size_t bufsiz, const char *fmt, ...);
28 #endif /* HAVE_SNPRINTF */
29 
30 #ifndef HAVE_STRERROR
31 extern char *strerror(int errnum);
32 #endif /* HAVE_STRERROR */
33 
34 /* There is no prototype of usleep() on Solaris. Why? */
35 #if !defined(HAVE_USLEEP) || defined(SOLARIS)
36 extern int usleep(unsigned int usec);
37 #endif
38 
39 #ifdef __W32__
40 #define sleep(time) Sleep(time)
41 #else
42 #ifndef HAVE_SLEEP
43 #define sleep(s) usleep((s) * 1000000)
44 #endif /* HAVE_SLEEP */
45 #endif
46 
47 #ifndef HAVE_STRDUP
48 extern char *strdup(const char *s);
49 #endif /* HAVE_STRDUP */
50 
51 char *getcwd_malloc (void);
52 
53 #ifndef HAVE_STRSTR
54 #define strstr(s,c)	index(s,c)
55 #endif /* HAVE_STRSTR */
56 
57 #ifndef HAVE_STRNCASECMP
58 extern int strncasecmp(char *s1, char *s2, unsigned int len);
59 #endif /* HAVE_STRNCASECMP */
60 
61 #ifndef HAVE_MKSTEMP
62 extern int mkstemp(char *template);
63 #endif /* HAVE_MKSTEMP */
64 
65 #ifndef HAVE_SYS_STAT_H
66 #ifdef __W32__
67 #include <sys/stat.h>          /* they have. */
68 #elif defined(__MACOS__)
69 #define S_IFDIR 1
70 #define S_ISDIR(m)   ((m) & S_IFDIR)
71 struct stat {
72 	short st_mode;
73 	short st_dev;
74 	long st_ino;
75 	unsigned long st_size;
76 	unsigned long st_mtime, st_ctime, st_btime;
77 };
78 int stat(const char *filename, struct stat *st);
79 #endif /* __W32__ */
80 #else
81 #include <sys/stat.h>
82 #endif /* HAVE_SYS_STAT_H*/
83 
84 #endif
85 
86 #ifndef S_ISDIR
87 #define S_ISDIR(mode) (((mode)&0xF000) == 0x4000)
88 #endif /* S_ISDIR */
89 
90 #ifndef HAVE_STRLCPY
91 #include <stddef.h>
92 extern size_t strlcpy(char *dst, const char *src, size_t size);
93 #endif
94 
95 #ifndef HAVE_STRLCAT
96 #include <stddef.h>
97 extern size_t strlcat(char *dst, const char *src, size_t size);
98 #endif
99 
100 extern void strreplace (char *dst, char old, char replacement);
101