[94dc7a]: src / compat.h  Maximize  Restore  History

Download this file

145 lines (119 with data), 3.9 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
 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
#ifndef COMPAT_H
/*
* File: compat.h
* Centralised platform dependency handling for man's C compilation units.
*
* Copyright (C) 2005, Keith D. Marshall <keithmarshall@users.sourceforge.net>
*
* This file is part of the man package.
*
* man is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2, or (at your option) any later version.
*
* man is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with man; see the file COPYING. If not, write to the Free Software
* Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#define COMPAT_H
/* Always include config.h, if we have it. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
/* Always prefer strchr() over index(), and strrchr() over rindex(),
* if we have them.
*/
#ifdef HAVE_STRCHR
# define index strchr
#endif
#ifdef HAVE_STRRCHR
# define rindex strrchr
#endif
#ifdef __MINGW32__
/*
* This could probably be better handled by autoconf,
* but, as a quick and dirty hack for now...
*
* On MinGW based platforms, glob.c will not currently compile,
* unless we define...
*/
# define _POSIX_SOURCE
# define __GNU_LIBRARY__
#endif
#ifdef _WIN32
/*
* Handle various nuisances/peculiarities of Microsoft's
* 32-bit Windows platform.
*
* Win32 Path Name Handling
* ------------------------
*
* Silently correct the misdemeanours of Win32, and its
* "dyed in the wool" users who refuse to believe that it is ok
* to use "/" instead of "\" in path names; however, we must
* still use ";" as the path separator.
*/
#define PATH_SEPARATOR_CHAR ';'
#define POSIX_STYLE_PATH(p) win32path_transform(p)
extern char *win32path_transform(const char *);
/*
* Because we are forcing the use of "/" as a directory separator,
* we don't need to check for leading "\" as an absolute path indicator,
* but we *do* still need to allow for a drive designator.
*/
#define IS_ABSOLUTE_PATH(p) win32path_is_absolute((p))
extern int win32path_is_absolute(const char *);
/*
* Win32 User Identification
* -------------------------
*
* Win32 user model is not consistent with POSIX,
* so, when we care, just pretend we are running as root...
*/
#define getuid() 0
#define geteuid() 0
#define getgid() 0
#define getegid() 0
/*
* Running a Command Pipeline on Win32
* -----------------------------------
*
* On POSIXy systems, we do this by simply passing an appropriately
* formatted command line to the system() function. On Win32, this
* implies the use of cmd.exe to run the pipeline, which is a POSIX
* format command line, and will, therefore, fail; instead we use a
* replacement function, win32run_command_sequence(), which spawns
* a UNIXy shell, to execute the command sequence.
*/
#define RUN_COMMAND_SEQUENCE(cmds) win32run_command_sequence (cmds)
extern int win32run_command_sequence (const char *);
#else /* !_WIN32 */
/*
* POSIX Style Path Name Handling
* ------------------------------
*
* On an already POSIXy system,
* we don't need any Win32 normalisation of the DIR separator,
* and we keep to the standard ":" as the path separator.
*/
#define PATH_SEPARATOR_CHAR ':'
#define POSIX_STYLE_PATH(p) p
/*
* POSIX mandates that absolute path names begin with a "/".
*/
#define IS_ABSOLUTE_PATH(p) (*(p) == '/')
/*
* Running a POSIX Command Pipeline
* --------------------------------
*
* This is achieved by using a simple system() function call.
*/
#define RUN_COMMAND_SEQUENCE(cmds) system (cmds)
#endif /* !_WIN32 */
#endif /* COMPAT_H */

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks