Macros | Typedefs
h-basic.h File Reference

The lowest level header. More...

#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
#include <limits.h>
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <pwd.h>
#include <sys/stat.h>
#include <unistd.h>

Go to the source code of this file.


#define HAVE_FCNTL_H
 Include autoconf autodetections, otherwise try to autodetect ourselves. More...
#define HAVE_STAT
#define UNIX
 Extract the "WINDOWS" flag from the compiler. More...
#define PATH_SEP   "/"
 Define SETGID if we are running as a central install on a multiuser system that has setgid support. More...
#define PATH_SEPC   '/'
#define _GNU_SOURCE

Include the library header files

#define DSTRINGIFY(x)   #x
 Debugging macros. More...
#define DSTRING(x)   DSTRINGIFY(x)
#define DHERE   __FILE__ ":" DSTRING(__LINE__) ": "
#define MIN(a, b)   (((a) > (b)) ? (b) : (a))

Basic math macros

#define MAX(a, b)   (((a) < (b)) ? (b) : (a))
#define ABS(a)   (((a) < 0) ? (-(a)) : (a))
#define SGN(a)   (((a) < 0) ? (-1) : ((a) != 0))
#define CMP(a, b)   ((a) < (b) ? -1 : ((b) < (a) ? 1 : 0))
#define N_ELEMENTS(a)   (sizeof(a) / sizeof((a)[0]))

Useful fairly generic macros

#define A2I(X)   ((X) - 'a')

Some hackish character manipulation

#define I2A(X)   ((X) + 'a')
#define D2I(X)   ((X) - '0')
#define I2D(X)   ((X) + '0')


typedef int errr
 ANSI C headers. More...
typedef uint8_t byte
typedef uint16_t u16b
typedef int16_t s16b
typedef uint32_t u32b
typedef int32_t s32b
typedef uint64_t u64b
typedef int64_t s64b

Detailed Description

The lowest level header.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke

This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation

#define _GNU_SOURCE

Include the library header files

#define A2I (   X)    ((X) - 'a')

Some hackish character manipulation

Note that all "index" values must be "lowercase letters", while all "digits" must be "digits".

Referenced by build_prob(), dehex(), and show_file().

#define ABS (   a)    (((a) < 0) ? (-(a)) : (a))
#define CMP (   a,
)    ((a) < (b) ? -1 : ((b) < (a) ? 1 : 0))
#define D2I (   X)    ((X) - '0')
#define DHERE   __FILE__ ":" DSTRING(__LINE__) ": "
#define DSTRING (   x)    DSTRINGIFY(x)
#define DSTRINGIFY (   x)    #x

Debugging macros.

#define HAVE_FCNTL_H

Include autoconf autodetections, otherwise try to autodetect ourselves.

Native MSVC compiler doesn't understand inline or snprintf Using C99, assume we have stdint and stdbool Everyone except RISC OS has fcntl.h and sys/stat.h

#define HAVE_STAT
#define I2A (   X)    ((X) + 'a')
#define I2D (   X)    ((X) + '0')
#define MAX (   a,
)    (((a) < (b)) ? (b) : (a))
#define MIN (   a,
)    (((a) > (b)) ? (b) : (a))
#define N_ELEMENTS (   a)    (sizeof(a) / sizeof((a)[0]))

Useful fairly generic macros

Given an array, determine how many elements are in it.

Referenced by add_high_resist(), build_freq_table(), change_path(), cleanup_arrays(), cmd_idx(), cmd_init(), cmd_lookup_key(), cmd_verb(), count_known_monsters(), death_screen(), display_feeling(), display_options_item(), display_player_xtra_info(), do_cmd_colors(), do_cmd_keymaps(), do_cmd_knowledge_ego_items(), do_cmd_knowledge_features(), do_cmd_knowledge_monsters(), do_cmd_knowledge_runes(), do_cmd_knowledge_traps(), do_cmd_options(), do_cmd_options_item(), do_cmd_save_screen_html(), do_cmd_spoilers(), do_cmd_visuals(), effect_lookup(), ego_has_ignore_type(), ego_item_name(), enter_score(), expression_add_operations_string(), finish_parse_projection(), flag_index_by_name(), grab_effect_data(), handle_options_item(), ignore_tval(), ignore_type_of(), init_arrays(), keycode_find_code(), keycode_find_desc(), keymap_free(), main(), option_dump(), parse_mon_spell_effect(), parse_mon_spell_name(), parse_player_timed_name(), parse_prefs_keymap_action(), parse_prefs_keymap_input(), parse_prefs_window(), parse_profile_name(), parse_profile_room(), parse_random(), parse_room_height(), parse_room_width(), parse_vault_columns(), parse_vault_rows(), predict_score(), print_sound_help(), prt_tmd(), prt_welcome(), py_attack_real(), ranged_helper(), redraw_stuff(), rescale_freqs(), show_scores(), subwindow_flag_changed(), tag_options_item(), test_length(), textui_knowledge_init(), timed_name_to_idx(), try_save(), tval_find_idx(), tval_find_name(), ui_enter_world(), ui_leave_world(), update_sidebar(), update_statusline(), and valid_options_item().

#define PATH_SEP   "/"

Define SETGID if we are running as a central install on a multiuser system that has setgid support.

Every system seems to use its own symbol as a path separator.

Default to the standard Unix slash, but attempt to change this for various other systems. Note that any system that uses the "period" as a separator (i.e. RISCOS) will have to pretend that it uses the slash, and do its own mapping of period <-> slash.

It is most definitely wrong to have such things here. Platform-specific code should handle shifting Angband filenames to platform ones. XXX

Referenced by init_file_paths(), init_stuff(), path_build(), path_process(), set_file_paths(), stats_db_open(), and stats_make_output_dir().

#define PATH_SEPC   '/'

Referenced by dir_create(), and path_filename_index().

#define SGN (   a)    (((a) < 0) ? (-1) : ((a) != 0))

Referenced by object_value_real().

#define UNIX

Extract the "WINDOWS" flag from the compiler.

Define UNIX if our OS is UNIXy

Typedef Documentation

typedef uint8_t byte
typedef int errr

ANSI C headers.

POSIX headers

Define the basic game types

errr is an error code

A "byte" is an unsigned byte of memory. s16b/u16b are exactly 2 bytes (where possible) s32b/u32b are exactly 4 bytes (where possible)

typedef int16_t s16b
typedef int32_t s32b
typedef int64_t s64b
typedef uint16_t u16b
typedef uint32_t u32b
typedef uint64_t u64b