config.c File Reference

#include "sysincludes.h"
#include "mtools.h"
#include "codepage.h"
#include "mtoolsPaths.h"

Include dependency graph for config.c:

Go to the source code of this file.

Data Structures

struct  switches_l
struct  flags_t

Defines

#define MAX_LINE_LEN   256
#define OFFS(x)   ((caddr_t)&((struct device *)0)->x)

Typedefs

typedef switches_l switches_t

Functions

static void syntax (const char *msg, int thisLine)
static void get_env_conf (void)
static int mtools_getline (void)
static void skip_junk (int expect)
static char * get_next_token (void)
static int match_token (const char *template)
static void expect_char (char c)
static char * get_string (void)
static unsigned int get_unumber (void)
static unsigned int get_number (void)
static void purge (char drive, int fn)
static void grow (void)
static void init_drive (void)
static void prepend (void)
static void append (void)
static void finish_drive_clause (void)
static int set_var (struct switches_l *switches, int nr, caddr_t base_address)
static int set_openflags (struct device *dev)
static int set_misc_flags (struct device *dev)
static int set_def_format (struct device *dev)
static void get_codepage (void)
static void get_toupper (void)
static void parse_old_device_line (char drive)
static int parse_one (int privilege)
static int parse (const char *name, int privilege)
void read_config (void)
void mtoolstest (int argc, char **argv, int type)

Variables

static char buffer [MAX_LINE_LEN+1]
static char * pos
static char * token
static int token_length
static FILEfp
static int linenumber
static int lastTokenLinenumber
static const char * filename
static int file_nr = 0
static int flag_mask
static int cur_devs
static int cur_dev
static int trusted = 0
static int nr_dev
static int token_nr
static char letters [][2]
devicedevices
unsigned int mtools_skip_check = 0
unsigned int mtools_fat_compatibility = 0
unsigned int mtools_ignore_short_case = 0
unsigned int mtools_rate_0 = 0
unsigned int mtools_rate_any = 0
unsigned int mtools_no_vfat = 0
unsigned int mtools_numeric_tail = 1
unsigned int mtools_dotted_dir = 0
unsigned int mtools_twenty_four_hour_clock = 1
char * mtools_date_string = "mm-dd-yyyy"
char * country_string = 0
static switches_t switches []
static flags_t openflags []
static flags_t misc_flags []
struct {
   char *   f_name
   FILE *   f_fp
   int   f_type
   char *   word
   int   type
   int   val
   char *   name
   CMD   code
   void(*   fn )()
   ARGT   argt
   char *   name
   char *   nm
   char   type
   char   flags
   char *   value
   const char *   name
   signed char   fat_bits
   int   tracks
   unsigned short   heads
   unsigned short   sectors
   device_t *   dev
   int   nr_partitions
   int   free_regions
   int   used_regions
   int   sectors
   int   nr_regions
   int   biosdrive
   region_t   regions [NR_REGIONS]
   int   this_month
   int   feb
   int   sept
   int   days_in_month
   int   dow_first
   int   o_file
   int   o_field
   WINDOW *   win
   char   erase
   char   kill
   char   werase
   unsigned   baudr
   int   speedcode
   u16_t   vendor
   u16_t   device
default_formats []
static switches_t dswitches []


Define Documentation

#define MAX_LINE_LEN   256
 

Definition at line 12 of file config.c.

Referenced by mtools_getline().

#define OFFS x   )     ((caddr_t)&((struct device *)0)->x)
 

Definition at line 146 of file config.c.


Typedef Documentation

typedef struct switches_l switches_t
 


Function Documentation

static void append void   )  [static]
 

Definition at line 353 of file config.c.

References cur_dev, cur_devs, grow(), and init_drive().

static void expect_char char  c  )  [static]
 

Definition at line 247 of file config.c.

References pos, skip_junk(), sprintf(), and syntax.

Referenced by parse_one(), and set_var().

static void finish_drive_clause void   )  [static]
 

Definition at line 362 of file config.c.

References cur_dev, devices, drive, file_nr, filename, FILTER_FLAG, flag_mask, fprintf(), heads, IS_SCSI, MFORMAT_ONLY_FLAG, misc_flags, PRIV_FLAG, sectors, stderr, syntax, tracks, and trusted.

Referenced by parse(), parse_old_device_line(), and parse_one().

static void get_codepage void   )  [static]
 

Definition at line 480 of file config.c.

References Codepage, get_number(), i, n, New, and Codepage_l::tounix.

Referenced by parse_one().

static void get_env_conf void   )  [static]
 

Definition at line 178 of file config.c.

References address(), getenv(), i, s, strtol(), strtoul(), switches, T_INT, and type.

Referenced by read_config().

static char* get_next_token void   )  [static]
 

Definition at line 227 of file config.c.

References pos, skip_junk(), strcspn(), and token_length.

Referenced by parse_one().

static unsigned int get_number void   )  [static]
 

Definition at line 290 of file config.c.

References int(), n, pos, skip_junk(), strtol(), syntax, and token_nr.

static char* get_string void   )  [static]
 

Definition at line 259 of file config.c.

References pos, skip_junk(), strchr, and syntax.

static void get_toupper void   )  [static]
 

Definition at line 495 of file config.c.

References get_number(), i, mstoupper, and safe_malloc().

Referenced by parse_one().

static unsigned int get_unumber void   )  [static]
 

Definition at line 275 of file config.c.

References int(), n, pos, skip_junk(), strtoul(), syntax, and token_nr.

Referenced by set_var().

static void grow void   )  [static]
 

Definition at line 320 of file config.c.

References cur_devs, devices, exit(), Grow, nr_dev, and printOom().

Referenced by append(), and prepend().

static void init_drive void   )  [static]
 

Definition at line 332 of file config.c.

References cur_dev, devices, and memset().

Referenced by append(), init_params(), and prepend().

static int match_token const char *  template  )  [static]
 

Definition at line 241 of file config.c.

References strlen(), strncasecmp(), and token_length.

Referenced by parse_one(), set_def_format(), set_misc_flags(), set_openflags(), and set_var().

static int mtools_getline void   )  [static]
 

Definition at line 196 of file config.c.

References fgets(), fp, linenumber, MAX_LINE_LEN, pos, strlen(), syntax, and token_nr.

Referenced by skip_junk().

void mtoolstest int  argc,
char **  argv,
int  type
 

Definition at line 698 of file config.c.

References device::cfg_filename, dev, devices, drive, device::drive, device::fat_bits, device::file_nr, get_drive(), device::heads, device::hidden, i, IS_MFORMAT_ONLY, IS_PRIVILEGED, IS_SCSI, j, device::misc_flags, device::mode, device::name, NULL, O_EXCL, device::offset, device::partition, path, device::precmd, printf, device::sectors, SHOULD_USE_VOLD, SHOULD_USE_XDF, skip_drive(), strcmp, and device::tracks.

static int parse const char *  name,
int  privilege
[static]
 

Definition at line 631 of file config.c.

References cur_dev, fclose(), file_nr, filename, finish_drive_clause(), fopen(), fp, lastTokenLinenumber, linenumber, parse_one(), pos, and strdup().

static void parse_old_device_line char  drive  )  [static]
 

Definition at line 505 of file config.c.

References append(), cur_dev, devices, exit(), fat_bits, file_nr, finish_drive_clause(), heads, letters, MAXPATHLEN, offset, pos, printOom(), purge(), sectors, sscanf(), strdup(), syntax, toupper, and tracks.

Referenced by parse_one().

static int parse_one int  privilege  )  [static]
 

Definition at line 560 of file config.c.

References append(), Codepage, cur_dev, devices, dswitches, expect_char(), file_nr, finish_drive_clause(), flag_mask, Free, free, get_codepage(), get_next_token(), get_toupper(), letters, match_token(), memset(), mstoupper, parse_old_device_line(), prepend(), purge(), set_def_format(), set_misc_flags(), set_openflags(), set_var(), switches, syntax, token_length, token_nr, toupper, and trusted.

Referenced by parse().

static void prepend void   )  [static]
 

Definition at line 339 of file config.c.

References cur_dev, cur_devs, devices, grow(), i, and init_drive().

Referenced by parse_one().

static void purge char  drive,
int  fn
[static]
 

Definition at line 306 of file config.c.

References cur_devs, devices, file_nr, i, j, and toupper.

Referenced by parse_old_device_line(), and parse_one().

void read_config void   ) 
 

Definition at line 650 of file config.c.

References CFG_FILE1, CONF_FILE, const_devices, cur_devs, devices, exit(), file_nr, get_env_conf(), get_homedir(), getenv(), homedir, init_codepage(), LOCAL_CONF_FILE, MAXPATHLEN, memcpy(), memset(), mtools_fat_compatibility, mtools_skip_check, NewArray, nr_const_devices, nr_dev, OLD_CONF_FILE, OLD_LOCAL_CONF_FILE, parse(), printOom(), strcat(), strncpy(), and SYS_CONF_FILE.

Referenced by main().

static int set_def_format struct device dev  )  [static]
 

Definition at line 458 of file config.c.

References default_formats, dev, device::fat_bits, device::heads, i, match_token(), device::sectors, device::ssize, and device::tracks.

Referenced by parse_one().

static int set_misc_flags struct device dev  )  [static]
 

Definition at line 432 of file config.c.

References dev, flag, flag_mask, get_number(), i, match_token(), device::misc_flags, misc_flags, pos, skip_junk(), and syntax.

Referenced by parse_one().

static int set_openflags struct device dev  )  [static]
 

Definition at line 419 of file config.c.

References dev, i, match_token(), device::mode, and openflags.

Referenced by parse_one().

static int set_var struct switches_l switches,
int  nr,
caddr_t  base_address
[static]
 

Definition at line 397 of file config.c.

References address(), expect_char(), get_number(), get_string, get_unumber(), i, match_token(), strdup(), switches, T_INT, T_STRING, and type.

Referenced by parse_one().

static void skip_junk int  expect  )  [static]
 

Definition at line 209 of file config.c.

References lastTokenLinenumber, linenumber, mtools_getline(), pos, strchr, syntax, and token_nr.

Referenced by expect_char(), get_next_token(), get_number(), get_string(), get_unumber(), and set_misc_flags().

static void syntax const char *  msg,
int  thisLine
[static]
 

Definition at line 164 of file config.c.

References cur_dev, devices, drive, exit(), filename, fprintf(), lastTokenLinenumber, linenumber, NULL, and stderr.


Variable Documentation

char buffer[MAX_LINE_LEN+1] [static]
 

Definition at line 15 of file config.c.

char* country_string = 0
 

Definition at line 56 of file config.c.

int cur_dev [static]
 

Definition at line 32 of file config.c.

Referenced by append(), finish_drive_clause(), init_drive(), parse(), parse_old_device_line(), parse_one(), prepend(), and syntax().

int cur_devs [static]
 

Definition at line 31 of file config.c.

Referenced by append(), grow(), prepend(), purge(), and read_config().

struct { ... } default_formats[] [static]
 

Referenced by set_def_format().

struct device* devices
 

Definition at line 43 of file config.c.

switches_t dswitches[] [static]
 

Initial value:

 {
    { "FILE", OFFS(name), T_STRING },
    { "OFFSET", OFFS(offset), T_UINT },
    { "PARTITION", OFFS(partition), T_UINT },
    { "FAT", OFFS(fat_bits), T_INT },
    { "FAT_BITS", OFFS(fat_bits), T_UINT },
    { "MODE", OFFS(mode), T_UINT },
    { "TRACKS",  OFFS(tracks), T_UINT },
    { "CYLINDERS",  OFFS(tracks), T_UINT },
    { "HEADS", OFFS(heads), T_UINT },
    { "SECTORS", OFFS(sectors), T_UINT },
    { "HIDDEN", OFFS(hidden), T_UINT },
    { "PRECMD", OFFS(precmd), T_STRING },
    { "BLOCKSIZE", OFFS(blocksize), T_UINT }
}

Definition at line 148 of file config.c.

Referenced by parse_one().

signed char fat_bits
 

Definition at line 120 of file config.c.

Referenced by parse_old_device_line().

int file_nr = 0 [static]
 

Definition at line 25 of file config.c.

Referenced by finish_drive_clause(), parse(), parse_old_device_line(), parse_one(), purge(), and read_config().

const char* filename [static]
 

Definition at line 23 of file config.c.

int flag_mask [static]
 

Definition at line 28 of file config.c.

Referenced by finish_drive_clause(), parse_one(), and set_misc_flags().

FILE* fp [static]
 

Definition at line 19 of file config.c.

Referenced by _get_entry(), advance(), alloc_inode(), announce(), bzopen_or_bzdopen(), cache2file(), cachedhcp(), calendar(), ckfopen(), clone_opcl(), cmdcomp(), common_open(), cpio_options(), crc(), ctty_io(), ctty_opcl(), dev_up(), do_chdir(), do_chmod(), do_chown(), do_chroot(), do_close(), do_dup(), do_exec(), do_fchdir(), do_fcntl(), do_mkdir(), do_mknod(), do_pipe(), do_svrctl(), do_umask(), do_unpause(), do_utime(), doconfig(), dodecl(), doevent(), dohelp(), DOMretr(), DOMstor(), doread(), dowrite(), efopen(), epopen(), f2_only(), f_transfer(), fclose(), fdc_transfer(), fgetln(), file2cache(), file_copyline(), file_read(), fix_mcwd(), fopen_output_safely(), fprintf(), fproc_dmp(), fr(), free_proc(), fs_init(), fxp_getstat(), fxp_init(), fxp_pci_conf(), fxp_readv(), fxp_stop(), fxp_watchdog_f(), fxp_writev(), get1rec(), get_fd(), get_filp(), getfp(), getids(), getline(), Getline(), getrec(), getuser(), getword(), hostalias(), init_f(), inval_filp(), listto(), ls_list(), ltraverse(), macro(), main(), match(), mcd_callback(), mcsub(), mpPrintFilename(), mtools_getline(), nlist(), opentxt(), outfunc(), output(), parse(), parse_path(), parsefield(), passadd(), passfile(), pgets(), pipe_check(), print(), Print(), print_name(), read1line(), read_id(), read_write(), readfile(), recalibrate(), res_init(), seek(), select_callback(), select_cancel_all(), select_reevaluate(), servxcheck(), showpage(), suspend(), tab_print(), tar_options(), tgetent(), tty_opcl(), and writetext().

unsigned short heads
 

Definition at line 122 of file config.c.

Referenced by boundary(), determine(), finish_drive_clause(), geometry(), m_modify(), m_toggle(), parse_old_device_line(), print(), recompute0(), sec2dos(), setsize(), show_chs(), and w_init().

int lastTokenLinenumber [static]
 

Definition at line 22 of file config.c.

Referenced by parse(), skip_junk(), and syntax().

char letters[][2] [static]
 

Initial value:

 { 
        "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
        "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
}

Definition at line 36 of file config.c.

Referenced by parse_old_device_line(), and parse_one().

int linenumber [static]
 

Definition at line 20 of file config.c.

Referenced by mtools_getline(), parse(), skip_junk(), and syntax().

flags_t misc_flags[] [static]
 

Initial value:

 {



    { "scsi",                   SCSI_FLAG },
    { "nolock",                 NOLOCK_FLAG },
    { "mformat_only",   MFORMAT_ONLY_FLAG },
    { "filter",                 FILTER_FLAG },
    { "privileged",             PRIV_FLAG },
    { "vold",                   VOLD_FLAG },
    { "remote",                 FLOPPYD_FLAG }
}

Definition at line 105 of file config.c.

Referenced by finish_drive_clause(), and set_misc_flags().

char* mtools_date_string = "mm-dd-yyyy"
 

Definition at line 55 of file config.c.

Referenced by print_date().

unsigned int mtools_dotted_dir = 0
 

Definition at line 53 of file config.c.

Referenced by list_file().

unsigned int mtools_fat_compatibility = 0
 

Definition at line 47 of file config.c.

Referenced by read_config().

unsigned int mtools_ignore_short_case = 0
 

Definition at line 48 of file config.c.

Referenced by list_file(), and unix_name().

unsigned int mtools_no_vfat = 0
 

Definition at line 51 of file config.c.

Referenced by dos_name().

unsigned int mtools_numeric_tail = 1
 

Definition at line 52 of file config.c.

unsigned int mtools_rate_0 = 0
 

Definition at line 49 of file config.c.

Referenced by mformat().

unsigned int mtools_rate_any = 0
 

Definition at line 50 of file config.c.

Referenced by mformat().

unsigned int mtools_skip_check = 0
 

Definition at line 46 of file config.c.

Referenced by check_fat(), check_media_type(), fs_init(), old_fat_read(), read_config(), and SimpleFileOpen().

unsigned int mtools_twenty_four_hour_clock = 1
 

Definition at line 54 of file config.c.

Referenced by print_time().

const char* name
 

Definition at line 119 of file config.c.

int nr_dev [static]
 

Definition at line 34 of file config.c.

Referenced by grow(), and read_config().

flags_t openflags[] [static]
 

Initial value:

 {









    { "none", 0 }  
}

Definition at line 91 of file config.c.

Referenced by set_openflags().

char* pos [static]
 

Definition at line 16 of file config.c.

unsigned short sectors
 

Definition at line 123 of file config.c.

Referenced by abs2dos(), boundary(), cylinderalign(), file_geom(), finish_drive_clause(), geometry(), m_modify(), m_toggle(), old_dos_size_to_geom(), parse_old_device_line(), print(), recompute0(), regionize(), sec2dos(), setsize(), show_chs(), and w_init().

switches_t switches[] [static]
 

Initial value:

 {
    { "MTOOLS_LOWER_CASE", (caddr_t) & mtools_ignore_short_case, T_UINT },
    { "MTOOLS_FAT_COMPATIBILITY", (caddr_t) & mtools_fat_compatibility, T_UINT },
    { "MTOOLS_SKIP_CHECK", (caddr_t) & mtools_skip_check, T_UINT },
    { "MTOOLS_NO_VFAT", (caddr_t) & mtools_no_vfat, T_UINT },
    { "MTOOLS_RATE_0", (caddr_t) &mtools_rate_0, T_UINT },
    { "MTOOLS_RATE_ANY", (caddr_t) &mtools_rate_any, T_UINT },
    { "MTOOLS_NAME_NUMERIC_TAIL", (caddr_t) &mtools_numeric_tail, T_UINT },
    { "MTOOLS_DOTTED_DIR", (caddr_t) &mtools_dotted_dir, T_UINT },
    { "MTOOLS_TWENTY_FOUR_HOUR_CLOCK", 
      (caddr_t) &mtools_twenty_four_hour_clock, T_UINT },
    { "MTOOLS_DATE_STRING",
      (caddr_t) &mtools_date_string, T_STRING },
    { "COUNTRY", (caddr_t) &country_string, T_STRING }
}

Definition at line 70 of file config.c.

Referenced by get_env_conf(), parse_one(), and set_var().

char* token [static]
 

Definition at line 17 of file config.c.

Referenced by read_conf().

int token_length [static]
 

Definition at line 18 of file config.c.

Referenced by get_next_token(), match_token(), and parse_one().

int token_nr [static]
 

Definition at line 35 of file config.c.

Referenced by get_number(), get_unumber(), mtools_getline(), parse_one(), and skip_junk().

int tracks
 

Definition at line 121 of file config.c.

Referenced by finish_drive_clause(), old_dos_size_to_geom(), and parse_old_device_line().

int trusted = 0 [static]
 

Definition at line 33 of file config.c.

Referenced by finish_drive_clause(), and parse_one().


Generated on Fri Apr 14 23:03:32 2006 for minix by  doxygen 1.4.6