nonposix.h revision 75584
175584Sru/* Copyright (C) 2000 Free Software Foundation, Inc. 275584Sru Written by Eli Zaretskii (eliz@is.elta.co.il) 375584Sru 475584SruThis file is part of groff. 575584Sru 675584Srugroff is free software; you can redistribute it and/or modify it under 775584Sruthe terms of the GNU General Public License as published by the Free 875584SruSoftware Foundation; either version 2, or (at your option) any later 975584Sruversion. 1075584Sru 1175584Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY 1275584SruWARRANTY; without even the implied warranty of MERCHANTABILITY or 1375584SruFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1475584Srufor more details. 1575584Sru 1675584SruYou should have received a copy of the GNU General Public License along 1775584Sruwith groff; see the file COPYING. If not, write to the Free Software 1875584SruFoundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 1975584Sru 2075584Sru/* This header file compartmentalize all idiosyncrasies of non-Posix 2175584Sru systems, such as MS-DOS, MS-Windows, etc. */ 2275584Sru 2375584Sru#if defined _MSC_VER 2475584Sru# ifndef _WIN32 2575584Sru# define _WIN32 2675584Sru# endif 2775584Sru# define setmode(f,m) _setmode(f,m) 2875584Sru#endif 2975584Sru 3075584Sru#if defined(__MSDOS__) || (defined(_WIN32) && !defined(__CYGWIN32__)) 3175584Sru 3275584Sru/* Binary I/O nuisances. Note: "setmode" is right for DJGPP and 3375584Sru Borland; Windows compilers might need _setmode or some such. */ 3475584Sru# include <fcntl.h> 3575584Sru# include <io.h> 3675584Sru# ifdef HAVE_UNISTD_H 3775584Sru# include <unistd.h> 3875584Sru# endif 3975584Sru# define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0) 4075584Sru# define FOPEN_RB "rb" 4175584Sru# define FOPEN_WB "wb" 4275584Sru# define FOPEN_RWB "wb+" 4375584Sru# ifdef _MSC_VER 4475584Sru# define POPEN_RT "rt" 4575584Sru# define POPEN_WT "wt" 4675584Sru# define popen(c,m) _popen(c,m) 4775584Sru# define pclose(p) _pclose(p) 4875584Sru# define getpid() (1) 4975584Sru# endif 5075584Sru# ifndef O_BINARY 5175584Sru# ifdef _O_BINARY 5275584Sru# define O_BINARY (_O_BINARY) 5375584Sru# endif 5475584Sru# endif 5575584Sru 5675584Sru/* The system shell. Groff assumes a Unixy shell, but non-Posix 5775584Sru systems don't have standard places where it lives, and might not 5875584Sru have it installed to begin with. We want to give them some leeway. */ 5975584Sru# define BSHELL (system_shell_name()) 6075584Sru# define BSHELL_DASH_C (system_shell_dash_c()) 6175584Sru# define IS_BSHELL(s) (is_system_shell(s)) 6275584Sru 6375584Sru/* The separator for directories in PATH and other environment 6475584Sru variables. */ 6575584Sru# define PATH_SEP ";" 6675584Sru 6775584Sru/* Characters that separate directories in a path name. */ 6875584Sru# define DIR_SEPS "/\\:" 6975584Sru 7075584Sru/* How to tell if the argument is an absolute file name. */ 7175584Sru# define IS_ABSOLUTE(f) \ 7275584Sru ((f)[0] == '/' || (f)[0] == '\\' || (f)[0] && (f)[1] == ':') 7375584Sru 7475584Sru/* The executable extension. */ 7575584Sru# define EXE_EXT ".exe" 7675584Sru 7775584Sru/* The system null device. */ 7875584Sru# define NULL_DEV "NUL" 7975584Sru 8075584Sru/* Prototypes. */ 8175584Sru# ifdef __cplusplus 8275584Sru extern "C" { 8375584Sru# endif 8475584Sru const char * system_shell_name(void); 8575584Sru const char * system_shell_dash_c(void); 8675584Sru int is_system_shell(const char *); 8775584Sru# ifdef __cplusplus 8875584Sru } 8975584Sru# endif 9075584Sru 9175584Sru#endif 9275584Sru 9375584Sru/* Defaults, for Posix systems. */ 9475584Sru 9575584Sru#ifndef FOPEN_RB 9675584Sru# define FOPEN_RB "r" 9775584Sru#endif 9875584Sru#ifndef FOPEN_WB 9975584Sru# define FOPEN_WB "w" 10075584Sru#endif 10175584Sru#ifndef FOPEN_RWB 10275584Sru# define FOPEN_RWB "w+" 10375584Sru#endif 10475584Sru#ifndef POPEN_RT 10575584Sru# define POPEN_RT "r" 10675584Sru#endif 10775584Sru#ifndef POPEN_WT 10875584Sru# define POPEN_WT "w" 10975584Sru#endif 11075584Sru#ifndef O_BINARY 11175584Sru# define O_BINARY 0 11275584Sru#endif 11375584Sru#ifndef BSHELL 11475584Sru# define BSHELL "/bin/sh" 11575584Sru#endif 11675584Sru#ifndef BSHELL_DASH_C 11775584Sru# define BSHELL_DASH_C "-c" 11875584Sru#endif 11975584Sru#ifndef IS_BSHELL 12075584Sru# define IS_BSHELL(s) ((s) && strcmp(s,BSHELL) == 0) 12175584Sru#endif 12275584Sru#ifndef PATH_SEP 12375584Sru# define PATH_SEP ":" 12475584Sru#endif 12575584Sru#ifndef DIR_SEPS 12675584Sru# define DIR_SEPS "/" 12775584Sru#endif 12875584Sru#ifndef IS_ABSOLUTE 12975584Sru# define IS_ABSOLUTE(f) ((f)[0] == '/') 13075584Sru#endif 13175584Sru#ifndef EXE_EXT 13275584Sru# define EXE_EXT "" 13375584Sru#endif 13475584Sru#ifndef NULL_DEV 13575584Sru# define NULL_DEV "/dev/null" 13675584Sru#endif 137