summaryrefslogtreecommitdiff
path: root/lib/os_internal.h
blob: 24d810ffdf64b9e191f2ffc2efc72e0276cba162 (plain)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#ifndef _XINE_OS_INTERNAL_H
#define _XINE_OS_INTERNAL_H

#include <stddef.h>
#include "os_types.h"

#if defined (__SVR4) && defined (__sun)
#  include <sys/int_types.h>

/* maybe needed for FreeBSD 4-STABLE */
/* 
#elif defined (__FreeBSD__)
#  include <stdint.h>
*/

#endif


/* replacement of strndup */
#ifndef HAVE_STRNDUP
#define strndup(S, N) _xine_private_strndup((S), (N))
char *_xine_private_strndup(const char *s, size_t n);
#endif

/* replacement of basename */
#ifndef HAVE_BASENAME
#define basename(PATH) _xine_private_basename((PATH))
char *_xine_private_basename(char *path);
#endif

/* replacement of hstrerror */
#ifndef HAVE_HSTRERROR
#define hstrerror(ERR) _xine_private_hstrerror((ERR))
const char *_xine_private_hstrerror(int err);
#endif

/* replacement of setenv */
#ifndef HAVE_SETENV
#define setenv(NAME, VALUE, OVERWRITE) _xine_private_setenv((NAME), (VALUE))
int _xine_private_setenv(const char *name, const char *value);
#endif

/* replacement of strtok_r */
#ifndef HAVE_STRTOK_R
#define strtok_r(S, DELIM, PTRPTR) _xine_private_strtok_r((S), (DELIM), (PTRPTR))
char *_xine_private_strtok_r(char *s, const char *delim, char **ptrptr);
#endif

/* replacement of gettimeofday */
#ifndef HAVE_GETTIMEOFDAY
#  ifdef WIN32
#    include <winsock.h>
struct timezone;
#  else
#    include <sys/time.h>
#  endif
#  define gettimeofday(TV, TZ) _xine_private_gettimeofday((TV))
int _xine_private_gettimeofday(struct timeval *tv);
#endif

/* replacement of strpbrk */
#ifndef HAVE_STRPBRK
#define strpbrk(S, ACCEPT) _xine_private_strpbrk((S), (ACCEPT))
char *_xine_private_strpbrk(const char *s, const char *accept);
#endif

/* replacement of strsep */
#ifndef HAVE_STRSEP
#define strsep(STRINGP, DELIM) _xine_private_strsep((STRINGP), (DELIM))
char *_xine_private_strsep(char **stringp, const char *delim);
#endif

/* macross needed for MSVC */
#ifdef _MSC_VER
#  define snprintf _snprintf
#  define vsnprintf _vsnprintf
#  define strcasecmp _stricmp
#  define strncasecmp _strnicmp
#  define M_PI 3.14159265358979323846
#endif

#ifdef WIN32
#include <io.h>
#  define mkdir(A, B) _mkdir((A))

#  ifndef S_ISDIR
#    define S_ISDIR(m) ((m) & _S_IFDIR)
#  endif

#  ifndef S_ISREG
#    define S_ISREG(m) ((m) & _S_IFREG)
#  endif

#  ifndef S_ISBLK
#    define S_ISBLK(m) 0
#  endif

#  ifndef S_ISCHR
#    define S_ISCHR(m) 0
#  endif

#  ifndef S_ISLNK
#    define S_ISLNK(mode)  0
#  endif

#  ifndef S_ISSOCK
#    define S_ISSOCK(mode) 0
#  endif

#  ifndef S_ISFIFO
#    define S_ISFIFO(mode) 0
#  endif

#  ifndef S_IXUSR
#    define S_IXUSR S_IEXEC
#  endif

#  ifndef S_IXGRP
#    define S_IXGRP S_IEXEC
#  endif

#  ifndef S_IXOTH
#    define S_IXOTH S_IEXEC
#  endif

#  if !S_IXUGO
#    define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
#  endif

#endif

#ifndef HAVE_READLINK
#  define readlink(PATH, BUF, BUFSIZE) 0
#endif

/* replacing lstat by stat */
#ifndef HAVE_LSTAT
#  define lstat(FILENAME, BUF) stat((FILENAME), (BUF))
#endif

/* replacements of dirent for MSVC platform */
#ifndef HAVE_OPENDIR
typedef struct DIR DIR;

struct dirent {
  unsigned short d_reclen;
  char *d_name;
};

DIR           *_xine_private_opendir(const char *);
int           _xine_private_closedir(DIR *);
struct dirent *_xine_private_readdir(DIR *);
void          _xine_private_rewinddir(DIR *);

#define opendir(DIRENT_NAME) _xine_private_opendir((DIRENT_NAME))
#define closedir(DIRENT_DIR) _xine_private_closedir((DIRENT_DIR))
#define readdir(DIRENT_DIR) _xine_private_readdir((DIRENT_DIR))
#define rewinddir(DIRENT_DIR) _xine_private_rewinddir((DIRENT_DIR))

#endif

#endif