options.c File Reference

#include "race.h"
#include "options.h"
#include "macros.h"
#include "pace.h"
#include "fs.h"
#include "utils.h"
#include "logging.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL.h>

Go to the source code of this file.

Defines

#define DEFAULT_DATADIR   CONFIG_DATADIR
#define DEFAULT_SAVEDIR   (".")
#define ENVIRON_DATADIR   ("BARIS_DATA")
#define ENVIRON_SAVEDIR   ("BARIS_SAVE")

Functions

static void fixpath_options (void)
static char * get_homedir (void)
 LOG_DEFAULT_CATEGORY (config)
static int parse_var_value (FILE *f, int index)
static int read_config_file (void)
 read the config file
int setup_options (int argc, char *argv[])
 read the commandline options
static void shift_argv (char **argv, int len, int shift)
static int skip_past_newline (FILE *f)
static void usage (int fail)
 prints the minimal usage information to stderr
static int write_default_config (void)

Variables

struct {
   char *   comment
 a note to the user
   void *   dest
 pointer to the variable to hold the content
   char *   name
 name of option
   int   need_alloc
 max size of the data in byte ???
   char *   type
 type of the data we get
config_strings []
struct {
   char *   def_val
   char **   dest
   char *   name
env_vars []
game_options options


Define Documentation

#define DEFAULT_DATADIR   CONFIG_DATADIR

Definition at line 40 of file options.c.

#define DEFAULT_SAVEDIR   (".")

Definition at line 41 of file options.c.

#define ENVIRON_DATADIR   ("BARIS_DATA")

Definition at line 33 of file options.c.

#define ENVIRON_SAVEDIR   ("BARIS_SAVE")

Definition at line 34 of file options.c.

Referenced by setup_options().


Function Documentation

static void fixpath_options ( void   )  [static]

Definition at line 311 of file options.c.

References game_options::dir_gamedata, game_options::dir_savegame, and fix_pathsep().

Referenced by setup_options().

static char* get_homedir ( void   )  [static]

Definition at line 284 of file options.c.

References xstrcat2(), and xstrdup().

Referenced by setup_options().

LOG_DEFAULT_CATEGORY ( config   ) 

static int parse_var_value ( FILE *  f,
int  index 
) [static]

Definition at line 138 of file options.c.

References ARRAY_LENGTH, config_strings, need_alloc, type, and xrealloc().

Referenced by read_config_file().

static int read_config_file ( void   )  [static]

read the config file

Returns:
-1 if the config file is unavailable

Note:
config variables may be 32 characters of alphas plus dash and underscore

Definition at line 172 of file options.c.

References ARRAY_LENGTH, c, config_strings, name, NOTICE1, NOTICE2, open_savedat(), parse_var_value(), skip_past_newline(), and WARNING1.

Referenced by setup_options().

int setup_options ( int  argc,
char *  argv[] 
)

read the commandline options

Returns:
length of modified argv
Todo:
possibly maintain a list of dirs to search??

Todo:
should use PATH_MAX or something similar here

Definition at line 324 of file options.c.

References ARRAY_LENGTH, def_val, dest, env_vars, ENVIRON_SAVEDIR, ERROR2, fixpath_options(), get_homedir(), name, PACKAGE_TARNAME, read_config_file(), shift_argv(), usage(), game_options::want_audio, game_options::want_cheats, game_options::want_debug, game_options::want_fullscreen, game_options::want_intro, WARNING2, write_default_config(), xmalloc(), and xstrdup().

Referenced by main().

static void shift_argv ( char **  argv,
int  len,
int  shift 
) [static]

Definition at line 116 of file options.c.

Referenced by setup_options().

static int skip_past_newline ( FILE *  f  )  [static]

Definition at line 131 of file options.c.

Referenced by read_config_file().

static void usage ( int  fail  )  [static]

prints the minimal usage information to stderr

Parameters:
fail sets the exit code

Definition at line 105 of file options.c.

static int write_default_config ( void   )  [static]

Definition at line 248 of file options.c.

References ARRAY_LENGTH, comment, config_strings, create_save_dir(), game_options::dir_savegame, name, NOTICE3, open_savedat(), PACKAGE_STRING, WARNING2, and WARNING4.

Referenced by setup_options().


Variable Documentation

char* comment

a note to the user

Definition at line 84 of file options.c.

Referenced by write_default_config().

struct { ... } config_strings[] [static]

Referenced by parse_var_value(), read_config_file(), and write_default_config().

char* def_val

Definition at line 73 of file options.c.

Referenced by setup_options().

void* dest

pointer to the variable to hold the content

Definition at line 81 of file options.c.

char** dest

Definition at line 72 of file options.c.

Referenced by DispIt(), HDispIt(), RLED(), and setup_options().

struct { ... } env_vars[] [static]

Referenced by setup_options().

char* name

name of option

Definition at line 80 of file options.c.

char* name

Definition at line 71 of file options.c.

Referenced by Best(), BuildVAB(), CalcSaf(), ChkDelVab(), DispVA(), DrawBudget(), Drec(), FillVab(), frm_read_tbl(), music_load(), play_audio(), PlaySequence(), read_config_file(), setup_options(), ShowVA(), SwapRec(), VAB(), VVals(), write_default_config(), and WriteRecord().

int need_alloc

max size of the data in byte ???

Definition at line 83 of file options.c.

Referenced by parse_var_value().

game_options options

Definition at line 65 of file options.c.

Referenced by av_setup(), create_save_dir(), first_saved_game(), main(), MisCheck(), remove_savedat(), and try_find_file().

char* type

type of the data we get

Definition at line 82 of file options.c.

Referenced by Drec(), main(), parse_var_value(), RecChange(), write_image(), and WriteRecord().


Generated on Fri Sep 28 00:35:47 2007 for raceintospace by  doxygen 1.5.3