Changeset 41

Show
Ignore:
Timestamp:
04/10/07 20:46:44 (1 year ago)
Author:
takkaria
Message:
  • fix warnings in main-win, cmd4
  • clear a lot of cruft out (reduce down to two h-* files, amongst other things)
  • compiled on Solaris, and found that the definitions in Makefile.std were unnecessary
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/Makefile.inc

    r16 r41  
    66# 
    77 
    8 HDRS = h-basic.h h-define.h h-type.h h-system.h h-config.h 
     8HDRS = h-basic.h h-config.h 
    99INCS = angband.h config.h defines.h types.h externs.h \ 
    1010       z-term.h z-rand.h z-util.h z-virt.h z-form.h $(HDRS) 
  • trunk/src/Makefile.std

    r38 r41  
    111111endif 
    112112 
    113 # Add Solaris bits -- untested 
    114 ifeq ($(uname),SunOS) 
    115   LIBS += -lsocket 
    116   CFLAGS += -DSOLARIS 
    117 endif 
    118  
    119113 
    120114# Object definitions 
  • trunk/src/cmd4.c

    r40 r41  
    20762076                op_ptr->opt[oid] = !op_ptr->opt[oid]; 
    20772077                break; 
    2078         case 0xff: 
    2079                 op_ptr->opt[oid] = !op_ptr->opt[oid]; 
    2080                 break; 
    20812078        case '?': 
    20822079                show_file(format("option.txt#%s", option_text[oid]), NULL, 0, 0); 
  • trunk/src/config.h

    r39 r41  
    3131 * the "termcap" library, or with hard-coded vt100 terminals). 
    3232 * 
    33  * The old "USE_NCU" option has been replaced with "USE_GCU". 
    34  * 
    3533 * Several other such options are available for non-unix machines, 
    3634 * 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 */ 
    4736 
    4837 
     
    6453#ifdef _POSIX_SAVED_IDS 
    6554# define SAFE_SETUID_POSIX 
    66 #endif 
    67  
    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_POSIX 
    7555#endif 
    7656 
     
    327307#ifdef SET_UID 
    328308# 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 from 
    337  * a setgid executable. 
    338  */ 
    339 #ifndef SET_UID 
    340 # define ALLOW_USER_SCRIPTS 
    341309#endif /* SET_UID */ 
    342310 
  • trunk/src/files.c

    r38 r41  
    20282028        char c; 
    20292029 
    2030         int fd; 
    2031  
    20322030        FILE *fff = NULL; 
    20332031 
     
    20482046        FILE_TYPE(FILE_TYPE_TEXT); 
    20492047 
    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)) 
    20552050        { 
    20562051                char out_val[160]; 
    2057  
    2058                 /* Close the file */ 
    2059                 fd_close(fd); 
    20602052 
    20612053                /* Build query */ 
     
    20632055 
    20642056                /* 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"); 
    20712064 
    20722065        /* 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 */ 
    26 
    37#ifndef INCLUDED_H_BASIC_H 
    48#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  */ 
    119 
    1210#ifdef HAVE_CONFIG_H 
     
    1412#endif /* HAVE_CONFIG_H */ 
    1513 
    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 */ 
    1719#include "h-config.h" 
    1820 
    19 /* System includes/externs */ 
    20 #include "h-system.h" 
    2121 
    22 /* Basic types */ 
    23 #include "h-type.h" 
    2422 
    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 
     84typedef const char *cptr; 
     85typedef int errr; 
     86typedef unsigned char byte; 
     87typedef 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 
    27185 
    28186#endif 
  • trunk/src/h-config.h

    r8 r41  
    3131 
    3232/* 
    33  * OPTION: Compile on a SYS III version of UNIX 
    34  */ 
    35 #ifndef SYS_III 
    36 /* #define SYS_III */ 
    37 #endif 
    38  
    39 /* 
    40  * OPTION: Compile on a SYS V version of UNIX 
    41  */ 
    42 #ifndef SYS_V 
    43 /* #define SYS_V */ 
    44 #endif 
    45  
    46 /* 
    4733 * OPTION: Compile on a HPUX version of UNIX 
    4834 */ 
     
    5137#endif 
    5238 
    53 /* 
    54  * OPTION: Compile on an SGI running IRIX 
    55  */ 
    56 #ifndef SGI 
    57 /* #define SGI */ 
    58 #endif 
    59  
    60 /* 
    61  * OPTION: Compile on a SunOS machine 
    62  */ 
    63 #ifndef SUNOS 
    64 /* #define SUNOS */ 
    65 #endif 
    66  
    67 /* 
    68  * OPTION: Compile on a Solaris machine 
    69  */ 
    70 #ifndef SOLARIS 
    71 /* #define SOLARIS */ 
    72 #endif 
    73  
    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 ULTRIX 
    79 /* #define ULTRIX */ 
    80 #endif 
    81  
    82  
    83  
    84 /* 
    85  * Extract the "SUNOS" flag from the compiler 
    86  */ 
    87 #if defined(sun) 
    88 # ifndef SUNOS 
    89 #   define SUNOS 
    90 # endif 
    91 #endif 
    92  
    93 /* 
    94  * Extract the "ULTRIX" flag from the compiler 
    95  */ 
    96 #if defined(ultrix) || defined(Pyramid) 
    97 # ifndef ULTRIX 
    98 #  define ULTRIX 
    99 # endif 
    100 #endif 
    101  
    102 /* 
    103  * Extract the "ATARI" flag from the compiler [cjh] 
    104  */ 
    105 #if defined(__atarist) || defined(__atarist__) 
    106 # ifndef ATARI 
    107 #  define ATARI 
    108 # endif 
    109 #endif 
    11039 
    11140/* 
     
    11544# ifndef RISCOS 
    11645#  define RISCOS 
    117 # endif 
    118 #endif 
    119  
    120 /* 
    121  * Extract the "SGI" flag from the compiler 
    122  */ 
    123 #ifdef sgi 
    124 # ifndef SGI 
    125 #  define SGI 
    12646# endif 
    12747#endif 
     
    15676#endif 
    15777 
    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 currently 
    161  * 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 __WORDSIZE 
    168 # if __WORDSIZE == 64 
    169 #  define L64 
    170 # endif 
    171 #endif 
    172  
    173 #if defined(__alpha) && defined(__osf__) && !defined(L64) 
    174 # define L64 
    175 #endif 
    176  
    17778 
    17879 
     
    19091#if !defined(MACH_O_CARBON) && !defined(WINDOWS) && \ 
    19192    !defined(MSDOS) && !defined(USE_EMX) && \ 
    192     !defined(AMIGA) && !defined(RISCOS) 
     93    !defined(AMIGA) && !defined(RISCOS) && !defined(GAMEBOY) 
    19394# define SET_UID 
    19495#endif 
     
    245146 */ 
    246147#if defined(SET_UID) && !defined(HAVE_CONFIG_H) 
    247 # if !defined(HPUX) && !defined(ULTRIX) && !defined(ISC) 
     148# if !defined(HPUX) && !defined(ISC) 
    248149#  define HAVE_USLEEP 
    249150# endif 
  • trunk/src/init2.c

    r36 r41  
    6262 * by the user) will NOT end in the "PATH_SEP" string, see the special 
    6363 * "path_build()" function in "util.c" for more information. 
    64  * 
    65  * Mega-Hack -- support fat raw files under NEXTSTEP, using special 
    66  * "suffixed" directories for the "ANGBAND_DIR_DATA" directory, but 
    67  * requiring the directories to be created by hand by the user. 
    6864 * 
    6965 * Hack -- first we free all the strings, since this is known 
     
    204200        strcpy(tail, "script"); 
    205201        ANGBAND_DIR_SCRIPT = string_make(path); 
    206  
    207  
    208 #ifdef NeXT 
    209  
    210         /* Allow "fat binary" usage with NeXT */ 
    211         if (TRUE) 
    212         { 
    213                 cptr next = NULL; 
    214  
    215 # if defined(m68k) 
    216                 next = "m68k"; 
    217 # endif 
    218  
    219 # if defined(i386) 
    220                 next = "i386"; 
    221 # endif 
    222  
    223 # if defined(sparc) 
    224                 next = "sparc"; 
    225 # endif 
    226  
    227 # if defined(hppa) 
    228                 next = "hppa"; 
    229 # endif 
    230  
    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  
    245202} 
    246203 
  • trunk/src/main-gcu.c

    r1 r41  
    1111 
    1212/* 
    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 * 
    2725 * 
    2826 * See also "USE_CAP" and "main-cap.c" for code that bypasses "curses" 
     
    3028 * "termcap" information and sends direct vt100 escape sequences. 
    3129 * 
    32  * This file provides up to 4 term windows. 
     30 * This file provides up to 4 term windows, or alternatively, bigscreen 
     31 * support. 
    3332 * 
    3433 * This file will attempt to redefine the screen colors to conform to 
  • trunk/src/main-win.c

    r1 r41  
    7373 
    7474#include "angband.h" 
    75  
     75#define uint unsigned int 
    7676 
    7777#ifdef WINDOWS 
     
    26112611{ 
    26122612        term_data *td = &data[0]; 
    2613         char ch; 
     2613        event_type ch; 
    26142614 
    26152615        /* Only in graphics mode since the fonts can't be scaled */ 
  • trunk/src/main-x11.c

    r1 r41  
    9696 
    9797#include "angband.h" 
     98 
     99#define uint unsigned int 
    98100 
    99101 
  • trunk/src/main-xpj.c

    r1 r41  
    3434 
    3535#include "angband.h" 
     36#define uint unsigned int 
    3637 
    3738 
  • trunk/src/save.c

    r39 r41  
    969969/* 
    970970 * Medium level player saver 
    971  * 
    972  * XXX XXX XXX Angband 2.8.0 will use "fd" instead of "fff" if possible 
    973971 */ 
    974972static bool save_player_aux(cptr name) 
  • trunk/src/z-file.c

    r16 r41  
    222222 
    223223 
     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 */ 
     229bool 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 
    224244 
    225245/* The file routines for RISC OS are in main-ros.c. */ 
  • trunk/src/z-file.h

    r15 r41  
    1111#endif /* O_BINARY */ 
    1212 
     13 
    1314/* 
    14  * Hack -- assist "main-ros.c" XXX 
     15 * Use POSIX file control where we can, otherwise help out RISC OS 
    1516 */ 
    16 #ifdef RISCOS 
     17#ifndef RISCOS 
     18# include <fcntl.h> 
     19#else 
    1720# define O_RDONLY   0 
    1821# define O_WRONLY   1 
     
    5659extern errr my_fgets(FILE *fff, char *buf, size_t n); 
    5760extern errr my_fputs(FILE *fff, cptr buf, size_t n); 
     61extern bool my_fexists(const char *fname); 
    5862extern errr fd_kill(cptr file); 
    5963extern errr fd_move(cptr file, cptr what);