Changeset 41
- Timestamp:
- 04/10/07 20:46:44 (1 year ago)
- Files:
-
- trunk/src/Makefile.inc (modified) (1 diff)
- trunk/src/Makefile.std (modified) (1 diff)
- trunk/src/cmd4.c (modified) (1 diff)
- trunk/src/config.h (modified) (3 diffs)
- trunk/src/files.c (modified) (3 diffs)
- trunk/src/h-basic.h (modified) (2 diffs)
- trunk/src/h-config.h (modified) (6 diffs)
- trunk/src/h-define.h (deleted)
- trunk/src/h-system.h (deleted)
- trunk/src/h-type.h (deleted)
- trunk/src/init2.c (modified) (2 diffs)
- trunk/src/main-gcu.c (modified) (2 diffs)
- trunk/src/main-win.c (modified) (2 diffs)
- trunk/src/main-x11.c (modified) (1 diff)
- trunk/src/main-xpj.c (modified) (1 diff)
- trunk/src/save.c (modified) (1 diff)
- trunk/src/z-file.c (modified) (1 diff)
- trunk/src/z-file.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/Makefile.inc
r16 r41 6 6 # 7 7 8 HDRS = h-basic.h h- define.h h-type.h h-system.h h-config.h8 HDRS = h-basic.h h-config.h 9 9 INCS = angband.h config.h defines.h types.h externs.h \ 10 10 z-term.h z-rand.h z-util.h z-virt.h z-form.h $(HDRS) trunk/src/Makefile.std
r38 r41 111 111 endif 112 112 113 # Add Solaris bits -- untested114 ifeq ($(uname),SunOS)115 LIBS += -lsocket116 CFLAGS += -DSOLARIS117 endif118 119 113 120 114 # Object definitions trunk/src/cmd4.c
r40 r41 2076 2076 op_ptr->opt[oid] = !op_ptr->opt[oid]; 2077 2077 break; 2078 case 0xff:2079 op_ptr->opt[oid] = !op_ptr->opt[oid];2080 break;2081 2078 case '?': 2082 2079 show_file(format("option.txt#%s", option_text[oid]), NULL, 0, 0); trunk/src/config.h
r39 r41 31 31 * the "termcap" library, or with hard-coded vt100 terminals). 32 32 * 33 * The old "USE_NCU" option has been replaced with "USE_GCU".34 *35 33 * Several other such options are available for non-unix machines, 36 34 * such as "MACINTOSH", "WINDOWS", "USE_IBM", "USE_EMX". 37 * 38 * You may also need to specify the "system", using defines such as 39 * "SOLARIS" (for Solaris), etc, see "h-config.h" for more info. 40 */ 41 42 43 /* 44 * OPTION: Include "ncurses.h" instead of "curses.h" in "main-gcu.c" 45 */ 46 /* #define USE_NCURSES */ 35 */ 47 36 48 37 … … 64 53 #ifdef _POSIX_SAVED_IDS 65 54 # define SAFE_SETUID_POSIX 66 #endif67 68 69 /*70 * Prevent problems on (non-Solaris) Suns using "SAFE_SETUID".71 * The SAFE_SETUID code is weird, use it at your own risk...72 */73 #if defined(SUNOS) && !defined(SOLARIS)74 # undef SAFE_SETUID_POSIX75 55 #endif 76 56 … … 327 307 #ifdef SET_UID 328 308 # define SAVEFILE_USE_UID 329 #endif /* SET_UID */330 331 332 /*333 * Allow the user to execute his own scripts in debug mode.334 *335 * The user-script code has not been checked for security issues yet,336 * so the user shouldn't be allowed to execute his own scripts from337 * a setgid executable.338 */339 #ifndef SET_UID340 # define ALLOW_USER_SCRIPTS341 309 #endif /* SET_UID */ 342 310 trunk/src/files.c
r38 r41 2028 2028 char c; 2029 2029 2030 int fd;2031 2032 2030 FILE *fff = NULL; 2033 2031 … … 2048 2046 FILE_TYPE(FILE_TYPE_TEXT); 2049 2047 2050 /* Check for existing file */ 2051 fd = fd_open(buf, O_RDONLY); 2052 2053 /* Existing file */ 2054 if (fd >= 0) 2048 /* Check if the file currently exists */ 2049 if (my_fexists(buf)) 2055 2050 { 2056 2051 char out_val[160]; 2057 2058 /* Close the file */2059 fd_close(fd);2060 2052 2061 2053 /* Build query */ … … 2063 2055 2064 2056 /* Ask */ 2065 if (get_check(out_val)) fd = -1; 2066 } 2067 2068 /* Open the non-existing file */ 2069 if (fd < 0) fff = my_fopen(buf, "w"); 2070 2057 if (get_check(out_val)) 2058 return -1; 2059 } 2060 2061 2062 /* Open the file for writing */ 2063 fff = my_fopen(buf, "w"); 2071 2064 2072 2065 /* Invalid file */ trunk/src/h-basic.h
r1 r41 1 /* File: h-basic.h */ 1 /* 2 * File: h-basic.h 3 * 4 * The most basic "include" file. 5 */ 2 6 3 7 #ifndef INCLUDED_H_BASIC_H 4 8 #define INCLUDED_H_BASIC_H 5 6 /*7 * The most basic "include" file.8 *9 * This file simply includes other low level header files.10 */11 9 12 10 #ifdef HAVE_CONFIG_H … … 14 12 #endif /* HAVE_CONFIG_H */ 15 13 16 /* System Configuration */ 14 15 /* 16 * h-config sets various system-specific defines, relied on later in this file 17 * and throughout the game. 18 */ 17 19 #include "h-config.h" 18 20 19 /* System includes/externs */20 #include "h-system.h"21 21 22 /* Basic types */23 #include "h-type.h"24 22 25 /* Basic constants and macros */ 26 #include "h-define.h" 23 /*** Include the library header files ***/ 24 25 /** ANSI C headers **/ 26 27 #include <ctype.h> 28 #include <errno.h> 29 #include <assert.h> 30 31 #include <stdarg.h> 32 #include <stdio.h> 33 #include <stdlib.h> 34 #include <string.h> 35 #include <time.h> 36 37 /** POSIX headers **/ 38 39 #if defined(SET_UID) || defined(MACH_O_CARBON) 40 # include <pwd.h> 41 # include <sys/stat.h> 42 # include <unistd.h> 43 #endif 44 45 #ifdef SET_UID 46 # include <sys/types.h> 47 #endif 48 49 #if defined(__DJGPP__) || defined(__MWERKS__) 50 #include <unistd.h> 51 #endif 52 53 /** Other headers **/ 54 55 #if defined(MACINTOSH) && defined(__MWERKS__) 56 # include <unix.h> 57 #endif 58 59 #if defined(WINDOWS) || defined(MSDOS) || defined(USE_EMX) 60 # include <io.h> 61 #endif 62 63 64 65 /*** Define the basic game types ***/ 66 67 /* 68 * cptr is a shortcut type for "const char *". XXX 69 * errr is an error code 70 * 71 * A "byte" is an unsigned byte of memory. 72 * s16b/u16b are exactly 2 bytes (where possible) 73 * s32b/u32b are exactly 4 bytes (where possible) 74 * 75 * We define a "bool" as a char. We should really be able to use the C89 types 76 * where available. XXX 77 */ 78 79 /* C++ defines its own bool type, so we hack around it */ 80 #undef bool 81 #define bool bool_hack 82 83 84 typedef const char *cptr; 85 typedef int errr; 86 typedef unsigned char byte; 87 typedef char bool; 88 89 90 /* C99/stdint.h provide guaranteed-size ints */ 91 #if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || defined HAVE_STDINT_H 92 93 /* Use guaranteed-size types */ 94 #include <stdint.h> 95 96 typedef uint16_t u16b; 97 typedef int16_t s16b; 98 99 typedef uint32_t u32b; 100 typedef int32_t s32b; 101 102 #else /* __STDC__ */ 103 104 /* Try hacks instead (not guaranteed to work) */ 105 typedef signed short s16b; 106 typedef unsigned short u16b; 107 108 /* Try to detect 64-bit longs -- this will probably not work without stdint.h on GCC */ 109 #ifdef __WORDSIZE 110 #if __WORDSIZE == 64 111 #define L64 112 #endif 113 #endif 114 115 #ifdef L64 116 typedef signed int s32b; 117 typedef unsigned int u32b; 118 #else 119 typedef signed long s32b; 120 typedef unsigned long u32b; 121 #endif /* L64 */ 122 123 #endif /* __STDC__ */ 124 125 126 127 /*** Simple constants ***/ 128 129 /* Define NULL */ 130 #ifndef NULL 131 # define NULL ((void*)0) 132 #endif 133 134 135 /* Define "TRUE" and "FALSE" */ 136 #undef TRUE 137 #undef FALSE 138 139 #define TRUE 1 140 #define FALSE 0 141 142 143 144 /*** Basic math macros ***/ 145 146 #undef MIN 147 #undef MAX 148 #undef ABS 149 #undef SGN 150 151 #define MIN(a,b) (((a) > (b)) ? (b) : (a)) 152 #define MAX(a,b) (((a) < (b)) ? (b) : (a)) 153 #define ABS(a) (((a) < 0) ? (-(a)) : (a)) 154 #define SGN(a) (((a) < 0) ? (-1) : ((a) != 0)) 155 156 157 158 /*** Some hackish character manipulation ***/ 159 160 /* 161 * Note that all "index" values must be "lowercase letters", while 162 * all "digits" must be "digits". Control characters can be made 163 * from any legal characters. XXX XXX XXX 164 */ 165 #define A2I(X) ((X) - 'a') 166 #define I2A(X) ((X) + 'a') 167 #define D2I(X) ((X) - '0') 168 #define I2D(X) ((X) + '0') 169 #define KTRL(X) ((X) & 0x1F) 170 #define UN_KTRL(X) ((X) + 64) 171 #define ESCAPE '\033' 172 173 174 /* 175 * System-independent definitions for the arrow keys. 176 */ 177 #define ARROW_DOWN '\x8A' 178 #define ARROW_LEFT '\x8B' 179 #define ARROW_RIGHT '\x8C' 180 #define ARROW_UP '\x8D' 181 182 /* Analogous to isdigit() etc in ctypes */ 183 #define isarrow(c) ((c >= ARROW_DOWN) && (c <= ARROW_UP)) 184 27 185 28 186 #endif trunk/src/h-config.h
r8 r41 31 31 32 32 /* 33 * OPTION: Compile on a SYS III version of UNIX34 */35 #ifndef SYS_III36 /* #define SYS_III */37 #endif38 39 /*40 * OPTION: Compile on a SYS V version of UNIX41 */42 #ifndef SYS_V43 /* #define SYS_V */44 #endif45 46 /*47 33 * OPTION: Compile on a HPUX version of UNIX 48 34 */ … … 51 37 #endif 52 38 53 /*54 * OPTION: Compile on an SGI running IRIX55 */56 #ifndef SGI57 /* #define SGI */58 #endif59 60 /*61 * OPTION: Compile on a SunOS machine62 */63 #ifndef SUNOS64 /* #define SUNOS */65 #endif66 67 /*68 * OPTION: Compile on a Solaris machine69 */70 #ifndef SOLARIS71 /* #define SOLARIS */72 #endif73 74 /*75 * OPTION: Compile on an ultrix/4.2BSD/Dynix/etc. version of UNIX,76 * Do not define this if you are on any kind of SunOS.77 */78 #ifndef ULTRIX79 /* #define ULTRIX */80 #endif81 82 83 84 /*85 * Extract the "SUNOS" flag from the compiler86 */87 #if defined(sun)88 # ifndef SUNOS89 # define SUNOS90 # endif91 #endif92 93 /*94 * Extract the "ULTRIX" flag from the compiler95 */96 #if defined(ultrix) || defined(Pyramid)97 # ifndef ULTRIX98 # define ULTRIX99 # endif100 #endif101 102 /*103 * Extract the "ATARI" flag from the compiler [cjh]104 */105 #if defined(__atarist) || defined(__atarist__)106 # ifndef ATARI107 # define ATARI108 # endif109 #endif110 39 111 40 /* … … 115 44 # ifndef RISCOS 116 45 # define RISCOS 117 # endif118 #endif119 120 /*121 * Extract the "SGI" flag from the compiler122 */123 #ifdef sgi124 # ifndef SGI125 # define SGI126 46 # endif 127 47 #endif … … 156 76 #endif 157 77 158 /*159 * OPTION: Define "L64" if a "long" is 64-bits. See "h-types.h".160 * The only such platform that angband is ported to is currently161 * DEC Alpha AXP running OSF/1 (OpenVMS uses 32-bit longs).162 *163 * Try to use __WORDSIZE to test for 64-bit platforms.164 * I don't know how portable this is.165 * -CJN-166 */167 #ifdef __WORDSIZE168 # if __WORDSIZE == 64169 # define L64170 # endif171 #endif172 173 #if defined(__alpha) && defined(__osf__) && !defined(L64)174 # define L64175 #endif176 177 78 178 79 … … 190 91 #if !defined(MACH_O_CARBON) && !defined(WINDOWS) && \ 191 92 !defined(MSDOS) && !defined(USE_EMX) && \ 192 !defined(AMIGA) && !defined(RISCOS) 93 !defined(AMIGA) && !defined(RISCOS) && !defined(GAMEBOY) 193 94 # define SET_UID 194 95 #endif … … 245 146 */ 246 147 #if defined(SET_UID) && !defined(HAVE_CONFIG_H) 247 # if !defined(HPUX) && !defined( ULTRIX) && !defined(ISC)148 # if !defined(HPUX) && !defined(ISC) 248 149 # define HAVE_USLEEP 249 150 # endif trunk/src/init2.c
r36 r41 62 62 * by the user) will NOT end in the "PATH_SEP" string, see the special 63 63 * "path_build()" function in "util.c" for more information. 64 *65 * Mega-Hack -- support fat raw files under NEXTSTEP, using special66 * "suffixed" directories for the "ANGBAND_DIR_DATA" directory, but67 * requiring the directories to be created by hand by the user.68 64 * 69 65 * Hack -- first we free all the strings, since this is known … … 204 200 strcpy(tail, "script"); 205 201 ANGBAND_DIR_SCRIPT = string_make(path); 206 207 208 #ifdef NeXT209 210 /* Allow "fat binary" usage with NeXT */211 if (TRUE)212 {213 cptr next = NULL;214 215 # if defined(m68k)216 next = "m68k";217 # endif218 219 # if defined(i386)220 next = "i386";221 # endif222 223 # if defined(sparc)224 next = "sparc";225 # endif226 227 # if defined(hppa)228 next = "hppa";229 # endif230 231 /* Use special directory */232 if (next)233 {234 /* Forget the old path name */235 string_free(ANGBAND_DIR_DATA);236 237 /* Build a new path name */238 sprintf(tail, "data-%s", next);239 ANGBAND_DIR_DATA = string_make(path);240 }241 }242 243 #endif /* NeXT */244 245 202 } 246 203 trunk/src/main-gcu.c
r1 r41 11 11 12 12 /* 13 * This file helps Angband run on Unix/Curses machines. 14 * 15 * 16 * To use this file, you must define "USE_GCU" in the Makefile. 17 * 18 * 19 * Note that this file is not "intended" to support non-Unix machines, 20 * nor is it intended to support VMS or other bizarre setups. 21 * 22 * Also, this package assumes that the underlying "curses" handles both 23 * the "nonl()" and "cbreak()" commands correctly, see the "OPTION" below. 24 * 25 * This code should work with most versions of "curses" or "ncurses", 26 * and the "main-ncu.c" file (and USE_NCU define) are no longer used. 13 * This file provides support for Angband using the Curses library. To use 14 * it, define USE_GCU in your makefile, and if you are using the ncurses 15 * library, also add USE_NCURSES. 16 * 17 * 18 * Note that this file is not *intended* to support non-Unix machines, nor is 19 * it intended to support VMS or other bizarre setups. It should, however, 20 * work with most versions of "curses" or "ncurses". 21 * 22 * This package assumes that the underlying "curses" handles both the "nonl()" 23 * and "cbreak()" commands correctly, see the "OPTION" below. 24 * 27 25 * 28 26 * See also "USE_CAP" and "main-cap.c" for code that bypasses "curses" … … 30 28 * "termcap" information and sends direct vt100 escape sequences. 31 29 * 32 * This file provides up to 4 term windows. 30 * This file provides up to 4 term windows, or alternatively, bigscreen 31 * support. 33 32 * 34 33 * This file will attempt to redefine the screen colors to conform to trunk/src/main-win.c
r1 r41 73 73 74 74 #include "angband.h" 75 75 #define uint unsigned int 76 76 77 77 #ifdef WINDOWS … … 2611 2611 { 2612 2612 term_data *td = &data[0]; 2613 charch;2613 event_type ch; 2614 2614 2615 2615 /* Only in graphics mode since the fonts can't be scaled */ trunk/src/main-x11.c
r1 r41 96 96 97 97 #include "angband.h" 98 99 #define uint unsigned int 98 100 99 101 trunk/src/main-xpj.c
r1 r41 34 34 35 35 #include "angband.h" 36 #define uint unsigned int 36 37 37 38 trunk/src/save.c
r39 r41 969 969 /* 970 970 * Medium level player saver 971 *972 * XXX XXX XXX Angband 2.8.0 will use "fd" instead of "fff" if possible973 971 */ 974 972 static bool save_player_aux(cptr name) trunk/src/z-file.c
r16 r41 222 222 223 223 224 /* 225 * Check to see if a file exists, by opening it read-only. 226 * 227 * Return TRUE if it does, FALSE if it does not. 228 */ 229 bool my_fexists(const char *fname) 230 { 231 int fd; 232 233 /* Try to open it */ 234 fd = fd_open(fname, O_RDONLY); 235 236 /* It worked */ 237 if (fd >= 0) 238 fd_close(fd); 239 240 return (fd == 0) ? FALSE : TRUE; 241 } 242 243 224 244 225 245 /* The file routines for RISC OS are in main-ros.c. */ trunk/src/z-file.h
r15 r41 11 11 #endif /* O_BINARY */ 12 12 13 13 14 /* 14 * Hack -- assist "main-ros.c" XXX15 * Use POSIX file control where we can, otherwise help out RISC OS 15 16 */ 16 #ifdef RISCOS 17 #ifndef RISCOS 18 # include <fcntl.h> 19 #else 17 20 # define O_RDONLY 0 18 21 # define O_WRONLY 1 … … 56 59 extern errr my_fgets(FILE *fff, char *buf, size_t n); 57 60 extern errr my_fputs(FILE *fff, cptr buf, size_t n); 61 extern bool my_fexists(const char *fname); 58 62 extern errr fd_kill(cptr file); 59 63 extern errr fd_move(cptr file, cptr what);
