1 /* HOSTOPTS.H (c) Copyright "Fish" (David B. Trout), 2005-2009 */ 2 /* Host-specific features and options for Hercules */ 3 4 5 /* 6 All HOST-operating-specific (Win32, Apple. Linux, etc) FEATures 7 and OPTIONs that cannot be otherwise determined via configure.ac 8 tests should be #defined here, and ONLY here! 9 10 ----------------------------------------------------------------- 11 REMINDER: please do NOT use host-specific tests anywhere else in 12 Hercules source code if you can help it! (e.g. #ifdef WIN32, etc) 13 14 Instead, add a test to configure.ac which tests for the availability 15 of the specific feature in question and then #defines a OPTION_XXX 16 which can then be used in Hercules source code. 17 ----------------------------------------------------------------- 18 19 The ONLY allowed exception is in the Hercules.h and htypes.h 20 header files where different header files need to be #included 21 (e.g. sockets) and/or typedef/#defines need to be made depending 22 on the host build system type. 23 24 ONLY IF such a configure.ac test is impractical or otherwise not 25 possible should you then hard-code the OPTION_XXX setting here in 26 this member (and ONLY in this member!) depending on the host o/s. 27 28 Thus, all of the below hard-coded options are candidates for some 29 future configure.ac test. 30 31 Feel free to design one. 32 33 Please. :) 34 */ 35 36 #ifndef _HOSTOPTS_H 37 #define _HOSTOPTS_H 38 39 #if defined(_MSVC_) 40 #include "hercwind.h" // (need HAVE_DECL_SIOCSIFHWADDR, etc) 41 #endif 42 43 /*-------------------------------------------------------------------*/ 44 /* ZZ FIXME 45 'OPTION_SCSI_ERASE_TAPE' 46 'OPTION_SCSI_ERASE_GAP' 47 48 NOTE: The following SHOULD in reality be some sort of test 49 within configure.ac, but until we can devise some sort of 50 simple configure test, we must hard-code them for now. 51 52 According to the only docs I could find: 53 54 MTERASE Erase the media from current position. 55 If the field mt_count is nonzero, a full 56 erase is done (from current position to 57 end of media). If mt_count is zero, only 58 an erase gap is written. It is hard to 59 say which drives support only one but not 60 the other option 61 62 HOWEVER, since it's hard to say which drivers support short 63 erase-gaps and which support erase-tape (and HOW they support 64 them if they do! For example, Cygwin is currently coded to 65 perform whichever type of erase the drive happens to support; 66 e.g. if you try to do an erase-gap but the drive doesn't support 67 short erases, it will end up doing a LONG erase [of the entire 68 tape]!! (and vice-versa: doing a long erase-tape on a drive 69 that doesn't support it will cause [Cygwin] to do an erase- 70 gap instead)). 71 72 THUS, the SAFEST thing to do is to simply treat all "erases", 73 whether short or long, as 'nop's for now (in order to prevent 74 the accidental erasure of an entire tape!) Once we happen to 75 know for DAMN SURE that a particular host o/s ALWAYS does what 76 we want it to should we then change the below #defines. (and 77 like I said, they really SHOULD be in some type of configure 78 test/setting and not here). 79 */ 80 /*-------------------------------------------------------------------*\ 81 82 File name comparisons 83 ('strcmp' vs. 'strcasecmp') 84 85 On Windows, file names are not case sensitive. While the case 86 of the file name may be preserved by the file system (and thus 87 show file names in both upper/lower case in directory listings 88 for example), the file system itself is NOT case-sensitive. File 89 names "Foo", "foo", "fOo", "FoO", etc, all refer to the same file. 90 91 On other platforms however (e.g. *nix), the file system IS case 92 sensitive. File names "Foo", "foo", "fOo", "FoO", etc, all refer 93 to different files on such systems. Thus we define a 'strfilecmp' 94 macro to be used for filename comparisons and define it to be 95 strcasecmp on Win32 platforms and strcmp for other platforms. 96 97 \*-------------------------------------------------------------------*/ 98 99 100 /*-------------------------------------------------------------------*/ 101 /* Constants used in "#if OPTION_NAME == OPTION_VALUE" statements */ 102 /*-------------------------------------------------------------------*/ 103 104 // HOW_TO_IMPLEMENT_SH_COMMAND 105 106 #define USE_FORK_API_FOR_SH_COMMAND 4 107 #define USE_W32_POOR_MANS_FORK 5 108 #define USE_ANSI_SYSTEM_API_FOR_SH_COMMAND 9 109 110 111 // SET_CONSOLE_CURSOR_SHAPE_METHOD 112 113 #define CURSOR_SHAPE_NOT_SUPPORTED 0 114 #define CURSOR_SHAPE_VIA_SPECIAL_LINUX_ESCAPE 1 115 #define CURSOR_SHAPE_WINDOWS_NATIVE 2 116 117 118 /*-------------------------------------------------------------------*/ 119 /* The following is now handled automatically for ALL host platforms */ 120 /*-------------------------------------------------------------------*/ 121 122 #undef OPTION_TUNTAP_SETNETMASK /* (default initial setting) */ 123 #undef OPTION_TUNTAP_SETMACADDR /* (default initial setting) */ 124 #undef OPTION_TUNTAP_DELADD_ROUTES /* (default initial setting) */ 125 #undef OPTION_TUNTAP_CLRIPADDR /* (default initial setting) */ 126 #undef OPTION_TUNTAP_LCS_SAME_ADDR /* (default initial setting) */ 127 128 #if defined(HAVE_DECL_SIOCSIFNETMASK) && \ 129 HAVE_DECL_SIOCSIFNETMASK 130 131 #define OPTION_TUNTAP_SETNETMASK /* TUNTAP_SetNetMask works */ 132 133 #endif 134 #if defined(HAVE_DECL_SIOCSIFHWADDR) && \ 135 HAVE_DECL_SIOCSIFHWADDR 136 137 #define OPTION_TUNTAP_SETMACADDR /* TUNTAP_SetMACAddr works */ 138 139 #endif 140 #if defined(HAVE_DECL_SIOCADDRT) && defined(HAVE_DECL_SIOCDELRT) && \ 141 HAVE_DECL_SIOCADDRT && HAVE_DECL_SIOCDELRT 142 143 #define OPTION_TUNTAP_DELADD_ROUTES /* Del/Add Routes works */ 144 145 #endif 146 #if defined(HAVE_DECL_SIOCDIFADDR) && \ 147 HAVE_DECL_SIOCDIFADDR 148 149 #define OPTION_TUNTAP_CLRIPADDR /* TUNTAP_ClrIPAddr works */ 150 151 #endif 152 153 154 /*-------------------------------------------------------------------*/ 155 /* Hard-coded Win32-specific features and options... */ 156 /*-------------------------------------------------------------------*/ 157 #if defined(WIN32) /* "Windows" options */ 158 159 #if defined(HDL_BUILD_SHARED) && defined(_MSVC_) 160 #define DLL_IMPORT __declspec ( dllimport ) 161 #define DLL_EXPORT __declspec ( dllexport ) 162 #else 163 #define DLL_IMPORT extern 164 #define DLL_EXPORT 165 #endif 166 167 #define HTTP_SERVER_CONNECT_KLUDGE 168 169 #define OPTION_W32_CTCI /* Fish's TunTap for CTCA's */ 170 #undef TUNTAP_IFF_RUNNING_NEEDED /* TunTap32 doesn't allow it */ 171 172 #define OPTION_SCSI_TAPE /* SCSI tape support */ 173 #ifdef _MSVC_ 174 #define OPTION_SCSI_ERASE_TAPE /* SUPPORTED! */ 175 #define OPTION_SCSI_ERASE_GAP /* SUPPORTED! */ 176 #else // (mingw or cygwin?) 177 #undef OPTION_SCSI_ERASE_TAPE /* (NOT supported!) */ 178 #undef OPTION_SCSI_ERASE_GAP /* (NOT supported!) */ 179 #endif 180 #undef OPTION_FBA_BLKDEVICE /* (no FBA BLKDEVICE support)*/ 181 182 #define MAX_DEVICE_THREADS 0 /* (0 == unlimited) */ 183 #undef MIXEDCASE_FILENAMES_ARE_UNIQUE /* ("Foo" same as "fOo"!!) */ 184 185 #define DEFAULT_HERCPRIO 0 186 #define DEFAULT_TOD_PRIO -20 187 #define DEFAULT_CPU_PRIO 15 188 #define DEFAULT_DEV_PRIO 8 189 190 #ifdef _MSVC_ 191 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_W32_POOR_MANS_FORK 192 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_WINDOWS_NATIVE 193 #define OPTION_EXTCURS /* Extended cursor handling */ 194 #else 195 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_FORK_API_FOR_SH_COMMAND 196 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_VIA_SPECIAL_LINUX_ESCAPE 197 #undef OPTION_EXTCURS /* Normal cursor handling */ 198 #endif 199 200 #define IsEventSet(h) (WaitForSingleObject(h,0) == WAIT_OBJECT_0) 201 202 /* Because Fish's TUNTAP emulation isn't seen as a network interface */ 203 /* by the host operating system, there is only one MAC address. */ 204 /* (The Windows "tap" is a capture and re-inject mechanism) */ 205 /* For other tuntap implementation, the host and guest have */ 206 /* separate abstracted NIC implementation - and therefore require */ 207 /* a separate MAC address to address that (lest briding won't work) */ 208 209 /* If at one point, a TUNTAP implementation comes up and is then */ 210 /* seen as a proper network interface by Windows, then this option */ 211 /* will have to go away - or anyway "undefined" for windows */ 212 #define OPTION_TUNTAP_LCS_SAME_ADDR 1 213 214 215 /*-------------------------------------------------------------------*/ 216 /* Hard-coded Solaris-specific features and options... */ 217 /*-------------------------------------------------------------------*/ 218 #elif defined(__sun__) && defined(__svr4__) 219 220 #define __SOLARIS__ 1 221 222 /* jbs 10/15/2003 need to define INADDR_NONE if using Solaris 10 223 and not Solaris Nevada aka OpenSolaris */ 224 #if !defined(INADDR_NONE) 225 #define INADDR_NONE 0xffffffffU 226 #endif 227 228 #undef OPTION_SCSI_TAPE /* No SCSI tape support */ 229 #undef OPTION_SCSI_ERASE_TAPE /* (NOT supported) */ 230 #undef OPTION_SCSI_ERASE_GAP /* (NOT supported) */ 231 #define DLL_IMPORT extern 232 #define DLL_EXPORT 233 /* #undef OPTION_PTTRACE maybe not, after all */ 234 235 #define MAX_DEVICE_THREADS 0 /* (0 == unlimited) */ 236 #define MIXEDCASE_FILENAMES_ARE_UNIQUE /* ("Foo" and "fOo" unique) */ 237 238 #define DEFAULT_HERCPRIO 0 239 #define DEFAULT_TOD_PRIO -20 240 #define DEFAULT_CPU_PRIO 15 241 #define DEFAULT_DEV_PRIO 8 242 243 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_ANSI_SYSTEM_API_FOR_SH_COMMAND 244 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_NOT_SUPPORTED 245 #undef OPTION_EXTCURS /* Normal cursor handling */ 246 247 248 /*-------------------------------------------------------------------*/ 249 /* Hard-coded Apple-specific features and options... */ 250 /*-------------------------------------------------------------------*/ 251 #elif defined(__APPLE__) /* "Apple" options */ 252 253 #define DLL_IMPORT extern 254 #define DLL_EXPORT 255 256 #define TUNTAP_IFF_RUNNING_NEEDED /* Needed by tuntap driver?? */ 257 258 #undef OPTION_SCSI_TAPE /* No SCSI tape support */ 259 #undef OPTION_SCSI_ERASE_TAPE /* (NOT supported) */ 260 #undef OPTION_SCSI_ERASE_GAP /* (NOT supported) */ 261 #undef OPTION_FBA_BLKDEVICE /* (no FBA BLKDEVICE support)*/ 262 263 #define MAX_DEVICE_THREADS 0 /* (0 == unlimited) */ 264 #define MIXEDCASE_FILENAMES_ARE_UNIQUE /* ("Foo" and "fOo" unique) */ 265 266 #define DEFAULT_HERCPRIO 0 267 #define DEFAULT_TOD_PRIO -20 268 #define DEFAULT_CPU_PRIO 15 269 #define DEFAULT_DEV_PRIO 8 270 271 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_ANSI_SYSTEM_API_FOR_SH_COMMAND 272 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_NOT_SUPPORTED 273 #undef OPTION_EXTCURS /* Normal cursor handling */ 274 275 276 /*-------------------------------------------------------------------*/ 277 /* Hard-coded FreeBSD-specific features and options... */ 278 /*-------------------------------------------------------------------*/ 279 #elif defined(__FreeBSD__) /* "FreeBSD" options */ 280 281 #define DLL_IMPORT extern 282 #define DLL_EXPORT 283 284 #define TUNTAP_IFF_RUNNING_NEEDED /* Needed by tuntap driver?? */ 285 286 #undef OPTION_SCSI_ERASE_TAPE /* (NOT supported) */ 287 #undef OPTION_SCSI_ERASE_GAP /* (NOT supported) */ 288 289 #define MAX_DEVICE_THREADS 0 /* (0 == unlimited) */ 290 #define MIXEDCASE_FILENAMES_ARE_UNIQUE /* ("Foo" and "fOo" unique) */ 291 292 #define DEFAULT_HERCPRIO 0 293 #define DEFAULT_TOD_PRIO -20 294 #define DEFAULT_CPU_PRIO 15 295 #define DEFAULT_DEV_PRIO 8 296 297 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_ANSI_SYSTEM_API_FOR_SH_COMMAND 298 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_NOT_SUPPORTED 299 #undef OPTION_EXTCURS /* Normal cursor handling */ 300 301 302 /*-------------------------------------------------------------------*/ 303 /* GNU Linux options... */ 304 /*-------------------------------------------------------------------*/ 305 #elif defined(__gnu_linux__) /* GNU Linux options */ 306 307 #define DLL_IMPORT extern 308 #define DLL_EXPORT 309 310 #define TUNTAP_IFF_RUNNING_NEEDED /* Needed by tuntap driver?? */ 311 312 #define OPTION_SCSI_TAPE /* SCSI tape support */ 313 #undef OPTION_SCSI_ERASE_TAPE /* (NOT supported) */ 314 #undef OPTION_SCSI_ERASE_GAP /* (NOT supported) */ 315 #define OPTION_FBA_BLKDEVICE /* FBA block device support */ 316 317 #define MAX_DEVICE_THREADS 0 /* (0 == unlimited) */ 318 #define MIXEDCASE_FILENAMES_ARE_UNIQUE /* ("Foo" and "fOo" unique) */ 319 320 #define DEFAULT_HERCPRIO 0 321 #define DEFAULT_TOD_PRIO -20 322 #define DEFAULT_CPU_PRIO 15 323 #define DEFAULT_DEV_PRIO 8 324 325 #if defined( HAVE_FORK ) 326 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_FORK_API_FOR_SH_COMMAND 327 #else 328 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_ANSI_SYSTEM_API_FOR_SH_COMMAND 329 #endif 330 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_VIA_SPECIAL_LINUX_ESCAPE 331 #undef OPTION_EXTCURS /* Normal cursor handling */ 332 333 334 /*-------------------------------------------------------------------*/ 335 /* Hard-coded OTHER (DEFAULT) host-specific features and options... */ 336 /*-------------------------------------------------------------------*/ 337 #else /* "Other platform" options */ 338 339 #warning hostopts.h: unknown target platform: defaulting to generic platform settings. 340 341 #define DLL_IMPORT extern /* (a safe default) */ 342 #define DLL_EXPORT 343 344 #undef TUNTAP_IFF_RUNNING_NEEDED /* (tuntap support unknown) */ 345 #undef OPTION_SCSI_TAPE /* (NO SCSI tape support) */ 346 #undef OPTION_SCSI_ERASE_TAPE /* (NOT supported) */ 347 #undef OPTION_SCSI_ERASE_GAP /* (NOT supported) */ 348 #undef OPTION_FBA_BLKDEVICE /* (no FBA BLKDEVICE support)*/ 349 350 #define MAX_DEVICE_THREADS 0 /* (0 == unlimited) */ 351 #define MIXEDCASE_FILENAMES_ARE_UNIQUE /* ("Foo" and "fOo" unique) */ 352 353 #define DEFAULT_HERCPRIO 0 354 #define DEFAULT_TOD_PRIO -20 355 #define DEFAULT_CPU_PRIO 15 356 #define DEFAULT_DEV_PRIO 8 357 358 #if defined( HAVE_FORK ) 359 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_FORK_API_FOR_SH_COMMAND 360 #else 361 #define HOW_TO_IMPLEMENT_SH_COMMAND USE_ANSI_SYSTEM_API_FOR_SH_COMMAND 362 #endif 363 #define SET_CONSOLE_CURSOR_SHAPE_METHOD CURSOR_SHAPE_NOT_SUPPORTED 364 #undef OPTION_EXTCURS /* Normal cursor handling */ 365 366 367 #endif // (host-specific tests) 368 369 #endif // _HOSTOPTS_H 370