1 /* $Id: ezstream.h 16536 2009-08-30 21:46:15Z moritz $ */ 2 /* 3 * Copyright (c) 2007, 2009 Moritz Grimm <mdgrimm@gmx.net> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef __COMPAT_H__ 19 #define __COMPAT_H__ 20 21 #ifdef HAVE_CONFIG_H 22 # include "config.h" 23 #endif 24 25 #ifdef HAVE_SYS_TYPES_H 26 # include <sys/types.h> 27 #endif /* HAVE_SYS_TYPES_H */ 28 #ifdef HAVE_SYS_TIME_H 29 # include <sys/time.h> 30 #else /* HAVE_SYS_TIME_H */ 31 # include <time.h> 32 #endif /* HAVE_SYS_TIME_H */ 33 #ifdef HAVE_SYS_STAT_H 34 # include <sys/stat.h> 35 #endif /* HAVE_SYS_STAT_H */ 36 37 #include <ctype.h> 38 #include <errno.h> 39 #include <fcntl.h> 40 #include <limits.h> 41 #ifdef HAVE_PATHS_H 42 # include <paths.h> 43 #endif /* HAVE_PATHS_H */ 44 #include <stdarg.h> 45 #include <stdio.h> 46 #include <stdlib.h> 47 #include <string.h> 48 #ifdef HAVE_UNISTD_H 49 # include <unistd.h> 50 #endif 51 52 #ifndef STDIN_FILENO 53 # define STDIN_FILENO 0 54 #endif /* !STDIN_FILENO */ 55 56 #ifndef _PATH_DEVNULL 57 # ifdef WIN32 58 # define _PATH_DEVNULL "nul" 59 # else /* WIN32 */ 60 # define _PATH_DEVNULL "/dev/null" 61 # endif /* WIN32 */ 62 #endif /* !_PATH_DEVNULL */ 63 64 #ifndef PATH_MAX 65 # define PATH_MAX 256 66 #endif /* !PATH_MAX */ 67 68 #if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE) 69 # define pclose _pclose 70 #endif /* !HAVE_PCLOSE && HAVE__PCLOSE */ 71 #if !defined(HAVE_POPEN) && defined(HAVE__POPEN) 72 # define popen _popen 73 #endif /* !HAVE_POPEN && HAVE__POPEN */ 74 #if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF) 75 # define snprintf _snprintf 76 #endif /* !HAVE_SNPRINTF && HAVE__SNPRINTF */ 77 #if !defined(HAVE_STAT) && defined(HAVE__STAT) 78 # define stat _stat 79 #endif /* !HAVE_STAT && HAVE__STAT */ 80 #if !defined(HAVE_STRNCASECMP) && defined(HAVE_STRNICMP) 81 # define strncasecmp strnicmp 82 #endif /* !HAVE_STRNCASECMP && HAVE_STRNICMP */ 83 #if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64) 84 # define strtoll _strtoi64 85 #endif /* !HAVE_STRTOLL && HAVE__STRTOI64 */ 86 87 #ifndef S_IRGRP 88 # define S_IRGRP 0 89 # define S_IWGRP 0 90 # define S_IXGRP 0 91 #endif /* !S_IRGRP */ 92 #ifndef S_IROTH 93 # define S_IROTH 0 94 # define S_IWOTH 0 95 # define S_IXOTH 0 96 #endif /* !S_IROTH */ 97 98 #ifdef WIN32 99 # include <windows.h> 100 # define sleep(a) Sleep((a) * 1000) 101 #endif /* WIN32 */ 102 103 /* 104 * For compat.c and getopt.c: 105 */ 106 107 extern int opterr; 108 extern int optind; 109 extern int optopt; 110 extern int optreset; 111 extern char *optarg; 112 113 extern int 114 local_getopt(int, char * const *, const char *); 115 116 extern const char *path_separators; 117 118 extern char * 119 local_basename(const char *); 120 121 #endif /* __COMPAT_H__ */ 122