2808 lines · 100.4 KB · C
RawDownload
/* ------------------------------------------------------------------------- *//*   Header file for Inform:  Z-machine ("Infocom" format) compiler          *//*                                                                           *//*                              Inform 6.33                                  *//*                                                                           *//*   This header file and the others making up the Inform source code are    *//*   copyright (c) Graham Nelson 1993 - 2014                                 *//*                                                                           *//*   Manuals for this language are available from the IF-Archive at          *//*   http://www.ifarchive.org/                                               *//*                                                                           *//*   For notes on how this program may legally be used, see the Designer's   *//*   Manual introduction.  (Any recreational use is fine, and so is some     *//*   commercial use.)                                                        *//*                                                                           *//*   For detailed documentation on how this program internally works, and    *//*   how to port it to a new environment, see the Technical Manual.          *//*                                                                           *//*   *** To compile this program in one of the existing ports, you must      *//*       at least change the machine definition (on the next page).          *//*       In most cases no other work will be needed. ***                     *//*                                                                           *//*   Contents:                                                               *//*                                                                           *//*       Machine/host OS definitions (in alphabetical order)                 *//*       Default definitions                                                 *//*       Standard ANSI inclusions, macro definitions, structures             *//*       Definitions of internal code numbers                                *//*       Extern declarations for linkage (in alphabetical order of file)     *//*                                                                           *//* ------------------------------------------------------------------------- */ #define RELEASE_DATE "10th May 2014"#define RELEASE_NUMBER 1633#define GLULX_RELEASE_NUMBER 38#define MODULE_VERSION_NUMBER 1#define VNUMBER RELEASE_NUMBER /* N indicates an intermediate release for Inform 7 *//*#define RELEASE_SUFFIX "N"*/ /* ------------------------------------------------------------------------- *//*   Our host machine or OS for today is...                                  *//*                                                                           *//*   [ Inform should compile (possibly with warnings) and work safely        *//*     if you just:                                                          *//*                                                                           *//*     #define AMIGA       -  for the Commodore Amiga under SAS/C            *//*     #define ARCHIMEDES  -  for Acorn RISC OS machines under Norcroft C    *//*     #define ATARIST     -  for the Atari ST                               *//*     #define BEOS        -  for the BeBox                                  *//*     #define LINUX       -  for Linux under gcc (essentially as Unix)      *//*     #define MACINTOSH   -  for the Apple Mac under Think C or Codewarrior *//*     #define MAC_MPW     -  for MPW under Codewarrior (and maybe Think C)  *//*     #define OS2         -  for OS/2 32-bit mode under IBM's C Set++       *//*     #define OSX         -  for the Apple Mac with OS X (another Unix)     *//*     #define PC          -  for 386+ IBM PCs, eg. Microsoft Visual C/C++   *//*     #define PC_QUICKC   -  for small IBM PCs under QuickC                 *//*     #define PC_WIN32    -  for Borland C++ or Microsoft Visual C++        *//*     #define UNIX        -  for Unix under gcc (or big IBM PC under djgpp) *//*     #define UNIX64      -  for 64-bit Unix under gcc                      *//*     #define VMS         -  for VAX or ALPHA under DEC C, but not VAX C    *//*                                                                           *//*     In most cases executables are already available at                    *//*     http://www.ifarchive.org/, and these are sometimes enhanced with      *//*     e.g. windowed interfaces whose source is not archived with the        *//*     main Inform source.]                                                  *//*                                                                           *//*   (If no machine is defined, then cautious #defines will be made.  In     *//*   most cases, porting to a new machine is a matter of carefully filling   *//*   out a block of definitions like those below.)                           *//* ------------------------------------------------------------------------- */ /* #define UNIX */ /* ------------------------------------------------------------------------- *//*   The first task is to include the ANSI header files, and typedef         *//*   suitable 32-bit integer types.                                          *//* ------------------------------------------------------------------------- */ #include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <ctype.h>#include <string.h>#include <time.h>#include <limits.h>#include <math.h> #ifndef VAX#if   SCHAR_MAX >= 0x7FFFFFFFL && SCHAR_MIN <= -0x7FFFFFFFL      typedef signed char       int32;      typedef unsigned char     uint32;#elif SHRT_MAX >= 0x7FFFFFFFL  && SHRT_MIN <= -0x7FFFFFFFL      typedef signed short int  int32;      typedef unsigned short int uint32;#elif INT_MAX >= 0x7FFFFFFFL   && INT_MIN <= -0x7FFFFFFFL      typedef signed int        int32;      typedef unsigned int      uint32;#elif LONG_MAX >= 0x7FFFFFFFL  && LONG_MIN <= -0x7FFFFFFFL      typedef signed long int   int32;      typedef unsigned long int uint32;#else#error No type large enough to support 32-bit integers.#endif#else      /*  VAX C does not provide these limit constants, contrary to ANSI  */      typedef int int32;      typedef unsigned int uint32;#endif /* ------------------------------------------------------------------------- *//*   The next part of this file contains blocks of definitions, one for      *//*   each port, of machine or OS-dependent constants needed by Inform.       *//*                                                                           *//*   1. MACHINE_STRING should be set to the name of the machine or OS.       *//*                                                                           *//*   2. Some miscellaneous #define options (set if the constant is           *//*   defined, otherwise not set):                                            *//*                                                                           *//*   USE_TEMPORARY_FILES - use scratch files for workspace, not memory,      *//*                         by default                                        *//*   PROMPT_INPUT        - prompt input (don't use Unix-style command line)  *//*   TIME_UNAVAILABLE    - don't use ANSI time routines to work out today's  *//*                         date                                              *//*   CHAR_IS_UNSIGNED    - if on your compiler the type "char" is unsigned   *//*                         by default, you should define this                *//*   HAS_REALPATH        - the POSIX realpath() function is available to     *//*                         find the absolute path to a file                  *//*                                                                           *//*   3. An estimate of the typical amount of memory likely to be free        *//*   should be given in DEFAULT_MEMORY_SIZE.                                 *//*   For most modern machines, HUGE_SIZE is the appropriate setting, but     *//*   some older micros may benefit from SMALL_SIZE.                          *//* ------------------------------------------------------------------------- */ #define LARGE_SIZE   1#define SMALL_SIZE   2#define HUGE_SIZE    3 /* ------------------------------------------------------------------------- *//*   4. Filenaming definitions:                                              *//*                                                                           *//*   It's assumed that the host OS has the concept of subdirectories and     *//*   has "pathnames", that is, filenames giving a chain of subdirectories    *//*   divided by the FN_SEP (filename separator) character: e.g. for Unix     *//*   FN_SEP is defined below as '/' and a typical name is                    *//*                         "users/graham/jigsaw.z5".                         *//*   White space is not allowed in filenames, and nor is the special         *//*   character FN_ALT, which unless defined here will be a comma and will    *//*   be used to separate alternative locations in a path variable.           *//*                                                                           *//*   If NO_FILE_EXTENSIONS is undefined then the OS allows "file extensions" *//*   of 1 to 3 alphanumeric characters like ".txt" (for text files), ".z5"   *//*   (for game files), etc., to indicate the file's type (and, crucially,    *//*   regards the same filename but with different extensions -- e.g.,        *//*   "frog.amp" and "frog.lil" -- as being different names).                 *//*   (The file extensions defined below are widely accepted, so please use   *//*   them unless there's a good reason why not.)                             *//*                                                                           *//*   You should then define STANDARD_DIRECTORIES (you can define it anyway)  *//*   in which case Inform will expect by default that files are sorted out   *//*   by being put into suitable directories (e.g., a "games" directory for   *//*   story files).                                                           *//*                                                                           *//*   If it's convenient for your port you can alter the detailed definitions *//*   which these broad settings make.  Be careful if NO_FILE_EXTENSIONS      *//*   is set without STANDARD_DIRECTORIES, as then Inform may                 *//*   overwrite its source with object code.                                  *//*                                                                           *//*   5. Filenames (or code related to filenames) for the three temporary     *//*   files.  These only exist during compilation (and only if -F1 is set).   *//*   Temporary_Name is the body of a filename to use                         *//*   (if you don't set this, it becomes "Inftemp") and Temporary_Directory   *//*   is the directory path for the files to go in (which can be altered on   *//*   the command line).  On some multi-tasking OSs these filenames ought to  *//*   include a number uniquely identifying the process: to indicate this,    *//*   define INCLUDE_TASK_ID and provide some code...                         *//*                                                                           *//*       #define INCLUDE_TASK_ID                                             *//*       #ifdef INFORM_FILE                                                  *//*       static int32 unique_task_id(void)                                   *//*       {   ...some code returning your task ID...                          *//*       }                                                                   *//*       #endif                                                              *//*                                                                           *//*   6. Any other definitions specific to the OS or machine.                 *//*   (In particular DEFAULT_ERROR_FORMAT is 0 on most machines and 1 on PCs; *//*   it controls the style of error messages, which is important for some    *//*   error-throwback debugging tools.)                                       *//* ------------------------------------------------------------------------- */ /* ========================================================================= *//*   The blocks now follow in alphabetical order.                            *//* ------------------------------------------------------------------------- *//*   AMIGA block                                                             *//* ------------------------------------------------------------------------- */#ifdef AMIGA/* 1 */#define MACHINE_STRING   "Amiga"/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '/'/* 5 */#define __USE_SYSBASE#include <proto/exec.h>#define INCLUDE_TASK_ID#define Temporary_Directory "T:"#ifdef MAIN_INFORM_FILEstatic int32 unique_task_id(void){   return (int32)FindTask(NULL);}#endif#endif/* ------------------------------------------------------------------------- *//*   ARCHIMEDES block: Acorn/RISC OS settings                                *//* ------------------------------------------------------------------------- */#ifdef ARCHIMEDES/* 1 */#define MACHINE_STRING   "RISC OS"/* 2 */#define CHAR_IS_UNSIGNED/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '.'#define STANDARD_DIRECTORIES#define NO_FILE_EXTENSIONS#define Source_Directory "inform"#define ICL_Directory "ICL"/* 5 */#define ENABLE_TEMPORARY_PATH#define Temporary_Directory "ram:"/* 6 */#define ARC_THROWBACK#endif/* ------------------------------------------------------------------------- *//*   Atari ST block                                                          *//* ------------------------------------------------------------------------- */#ifdef ATARIST/* 1 */#define MACHINE_STRING   "Atari ST"/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '/'/* 5 */#ifndef TOSFS#define Temporary_Directory "/tmp"#define INCLUDE_TASK_ID#ifdef MAIN_INFORM_FILEstatic int32 unique_task_id(void){   return (int32)getpid();}#endif#endif#endif/* ------------------------------------------------------------------------- *//*   BEOS block                                                              *//* ------------------------------------------------------------------------- */#ifdef BEOS/* 1 */#define MACHINE_STRING   "BeOS"/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '/'#define FILE_EXTENSIONS/* 5 */#define Temporary_Directory "/tmp"#endif/* ------------------------------------------------------------------------- *//*   LINUX block                                                             *//* ------------------------------------------------------------------------- */#ifdef LINUX/* 1 */#define MACHINE_STRING   "Linux"/* 2 */#define HAS_REALPATH/* 3 */#define DEFAULT_MEMORY_SIZE HUGE_SIZE/* 4 */#define FN_SEP '/'/* 5 */#define Temporary_Directory "/tmp"/* 6 */#define PATHLEN 8192#endif/* ------------------------------------------------------------------------- *//*   Macintosh block                                                         *//* ------------------------------------------------------------------------- */#ifdef MAC_MPW#define MACINTOSH#endif #ifdef MACINTOSH/* 1 */#ifdef MAC_MPW#define MACHINE_STRING   "Macintosh Programmer's Workshop"#else#define MACHINE_STRING   "Macintosh"#endif/* 2 */#ifdef MAC_FACE#define EXTERNAL_SHELL#endif#ifndef MAC_FACE#ifndef MAC_MPW#define PROMPT_INPUT#endif#endif/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP           ':'#ifdef MAC_MPW#define Include_Extension ".h"#endif/* 6 */#ifdef MAC_FACE#include "TB Inform.h"#endif#ifdef MAC_MPW#include <CursorCtl.h>#define DEFAULT_ERROR_FORMAT 2#endif#endif/* ------------------------------------------------------------------------- *//*   OS/2 block                                                              *//* ------------------------------------------------------------------------- */#ifdef OS2/* 1 */#define MACHINE_STRING   "OS/2"/* 2 */#define CHAR_IS_UNSIGNED/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '/'#endif/* ------------------------------------------------------------------------- *//*   OSX block                                                              *//* ------------------------------------------------------------------------- */#ifdef OSX/* 1 */#define MACHINE_STRING   "Mac OS X"/* 2 */#define HAS_REALPATH/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '/'/* 5 */#define Temporary_Directory "/tmp"#define INCLUDE_TASK_ID#define _POSIX_C_SOURCE 199506L#define _XOPEN_SOURCE 500#ifdef MAIN_INFORM_FILE#include <sys/types.h>#include <unistd.h>static int32 unique_task_id(void){   return (int32)getpid();}#endif/* 6 */#define PATHLEN 8192#endif/* ------------------------------------------------------------------------- *//*   PC and PC_QUICKC block                                                  *//* ------------------------------------------------------------------------- */#ifdef PC_QUICKC#define PC#endif #ifdef PC/* 1 */#define MACHINE_STRING   "PC"/* 2 */#define USE_TEMPORARY_FILES/* 3 */#ifdef PC_QUICKC#define DEFAULT_MEMORY_SIZE SMALL_SIZE#else#define DEFAULT_MEMORY_SIZE LARGE_SIZE#endif/* 4 */#define FN_SEP '\\'/* 6 */#define DEFAULT_ERROR_FORMAT 1#endif/* ------------------------------------------------------------------------- *//*   PC_WIN32 block                                                          *//* ------------------------------------------------------------------------- */#ifdef PC_WIN32/* 1 */#define MACHINE_STRING   "Win32"/* 2 */#define HAS_REALPATH/* 3 */#define DEFAULT_MEMORY_SIZE HUGE_SIZE/* 4 */#define FN_SEP '\\'/* 6 */#define DEFAULT_ERROR_FORMAT 1#define PATHLEN 512#ifdef _MSC_VER /* Microsoft Visual C++ */#define snprintf _snprintf#define isnan _isnan#define isinf(x) (!_isnan(x) && !_finite(x))#endif#endif/* ------------------------------------------------------------------------- *//*   UNIX block                                                              *//* ------------------------------------------------------------------------- */#ifdef UNIX/* 1 */#define MACHINE_STRING   "Unix"/* 2 */#define USE_TEMPORARY_FILES#define HAS_REALPATH/* 3 */#define DEFAULT_MEMORY_SIZE HUGE_SIZE/* 4 */#define FN_SEP '/'/* 5 */#define PATHLEN 512#define Temporary_Directory "/tmp"#define INCLUDE_TASK_ID#ifdef MAIN_INFORM_FILEstatic int32 unique_task_id(void){   return (int32)getpid();}#endif#endif/* ------------------------------------------------------------------------- *//*   UNIX64 block                                                            *//* ------------------------------------------------------------------------- */#ifdef UNIX64/* 1 */#ifndef MACHINE_STRING#define MACHINE_STRING   "Unix"#endif/* 2 */#define USE_TEMPORARY_FILES#define HAS_REALPATH/* 3 */#define DEFAULT_MEMORY_SIZE HUGE_SIZE/* 4 */#define FN_SEP '/'/* 5 */#define Temporary_Directory "/tmp"#define PATHLEN 512#define INCLUDE_TASK_ID#ifdef MAIN_INFORM_FILEstatic int32 unique_task_id(void){   return (int32)getpid();}#endif#endif/* ------------------------------------------------------------------------- *//*   VMS (Dec VAX and Alpha) block                                           *//* ------------------------------------------------------------------------- */#ifdef __VMS#define VMS#endif #ifdef VMS/* 1 */#ifdef __ALPHA#define MACHINE_STRING   "Alpha/VMS"#else#define MACHINE_STRING   "VAX/VMS"#endif/* 2 */#define CHAR_IS_UNSIGNED/* 3 */#define DEFAULT_MEMORY_SIZE LARGE_SIZE/* 4 */#define FN_SEP '/'#define Code_Extension   ".zip"#define V4Code_Extension ".zip"#define V5Code_Extension ".zip"#define V6Code_Extension ".zip"#define V7Code_Extension ".zip"#define V8Code_Extension ".zip"#endif/* ========================================================================= *//* Default settings:                                                         *//* ------------------------------------------------------------------------- */ #ifndef NO_FILE_EXTENSIONS#define FILE_EXTENSIONS#endif #ifndef Transcript_File#ifdef FILE_EXTENSIONS#define Transcript_File "gametext.txt"#else#define Transcript_File "gametext"

Lines 1–500 of 2808.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t