Angband
Functions | Variables
main.c File Reference

Core game initialisation for UNIX (and other) machines. More...

#include "angband.h"
#include "init.h"
#include "savefile.h"
#include "ui-command.h"
#include "ui-display.h"
#include "ui-game.h"
#include "ui-init.h"
#include "ui-input.h"
#include "ui-prefs.h"
#include "ui-signals.h"
#include "locale.h"
#include "langinfo.h"
#include "main.h"

Functions

static void quit_hook (const char *s)
 A hook for "quit()". More...
 
static void init_stuff (void)
 Initialize and verify the file paths, and the score file. More...
 
static void change_path (const char *info)
 Handle a "-d<dir>=<path>" option. More...
 
static void user_name (char *buf, size_t len, int id)
 Find a default user name from the system. More...
 
static void list_saves (void)
 List all savefiles this player can access. More...
 
static void debug_opt (const char *arg)
 
int main (int argc, char *argv[])
 Simple "main" function for multiple platforms. More...
 

Variables

static const struct module modules []
 locale junk More...
 
struct {
   const char *   name
 
   char **   path
 
   bool   setgid_ok
 
change_path_values []
 
static bool new_game
 

Detailed Description

Core game initialisation for UNIX (and other) machines.

Copyright (c) 1997 Ben Harrison, and others

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": 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.

Function Documentation

static void change_path ( const char *  info)
static

Handle a "-d<dir>=<path>" option.

Sets any of angband's special directories to <path>.

The "<path>" can be any legal path for the given system, and should not end in any special path separator (i.e. "/tmp" or "~/.ang-info").

References change_path_values, dir_create(), i, my_stricmp(), N_ELEMENTS, NULL, path, path_build(), quit_fmt(), setgid_ok, string_free(), and string_make().

Referenced by main().

static void debug_opt ( const char *  arg)
static

References mem_flags, MEM_POISON_ALLOC, MEM_POISON_FREE, and streq.

Referenced by main().

static void init_stuff ( void  )
static

Initialize and verify the file paths, and the score file.

Use the ANGBAND_PATH environment var if possible, else use DEFAULT_PATH, and in either case, branch off appropriately.

First, we'll look for the ANGBAND_PATH environment variable, and then look for the files in there. If that doesn't work, we'll try the DEFAULT_PATH constants. So be sure that one of these two things works...

We must ensure that the path ends with "PATH_SEP" if needed, since the "init_file_paths()" function will simply append the relevant "sub-directory names" to the given path.

Make sure that the path doesn't overflow the buffer. We have to leave enough space for the path separator, directory, and filenames.

References DEFAULT_CONFIG_PATH, DEFAULT_DATA_PATH, DEFAULT_LIB_PATH, init_file_paths(), my_strcat(), my_strcpy(), PATH_SEP, and suffix().

Referenced by main().

static void list_saves ( void  )
static

List all savefiles this player can access.

References ANGBAND_DIR_SAVE, desc, my_dclose(), my_dopen(), my_dread(), path, path_build(), player_uid, quit_fmt(), savefile_get_description(), and strnfmt().

Referenced by main().

int main ( int  argc,
char *  argv[] 
)
static void quit_hook ( const char *  s)
static

A hook for "quit()".

Close down, then fall back into "quit()".

References angband_term, ANGBAND_TERM_MAX, term_nuke(), and void().

Referenced by main().

static void user_name ( char *  buf,
size_t  len,
int  id 
)
static

Find a default user name from the system.

References my_strcap(), and my_strcpy().

Referenced by main().

Variable Documentation

const { ... } change_path_values[]
Initial value:
= {
{ "scores", &ANGBAND_DIR_SCORES, true },
{ "gamedata", &ANGBAND_DIR_GAMEDATA, false },
{ "screens", &ANGBAND_DIR_SCREENS, false },
{ "help", &ANGBAND_DIR_HELP, true },
{ "info", &ANGBAND_DIR_INFO, true },
{ "pref", &ANGBAND_DIR_CUSTOMIZE, true },
{ "fonts", &ANGBAND_DIR_FONTS, true },
{ "tiles", &ANGBAND_DIR_TILES, true },
{ "sounds", &ANGBAND_DIR_SOUNDS, true },
{ "icons", &ANGBAND_DIR_ICONS, true },
{ "user", &ANGBAND_DIR_USER, true },
{ "save", &ANGBAND_DIR_SAVE, false },
}
char * ANGBAND_DIR_ICONS
Definition: init.c:87
char * ANGBAND_DIR_INFO
Definition: init.c:91
char * ANGBAND_DIR_SCORES
Definition: init.c:90
char * ANGBAND_DIR_USER
Definition: init.c:88
char * ANGBAND_DIR_HELP
Definition: init.c:82
char * ANGBAND_DIR_FONTS
Definition: init.c:84
char * ANGBAND_DIR_GAMEDATA
Various directories.
Definition: init.c:80
char * ANGBAND_DIR_CUSTOMIZE
Definition: init.c:81
char * ANGBAND_DIR_SAVE
Definition: init.c:89
char * ANGBAND_DIR_TILES
Definition: init.c:85
char * ANGBAND_DIR_SOUNDS
Definition: init.c:86
char * ANGBAND_DIR_SCREENS
Definition: init.c:83

Referenced by change_path(), and main().

const struct module modules[]
static
Initial value:
=
{
}

locale junk

Some machines have a "main()" function in their "main-xxx.c" file, all the others use this file for their "main()" function. List of the available modules in the order they are tried.

const char* name
bool new_game
static

Referenced by main().

char** path
bool setgid_ok

Referenced by change_path(), and main().