w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

cfg.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include "main.h"
#include "convert.h"
#include "funct1.h"
#include "cfg.h"
#include "util.h"
Include dependency graph for cfg.c:

Go to the source code of this file.

Classes

struct  ConfigInfoT
 

Macros

#define CONFIG_SIZE   (sizeof(configinfo) / sizeof(ConfigInfoT))
 
#define BUFFER_INCREMENT   1024
 
#define CR   (char) 0x0d
 
#define LF   (char) 0x0a
 

Typedefs

typedef struct ConfigInfoT ConfigInfoT
 

Functions

char * ReadUptoMatch (FILE *infile, const char *scanchars)
 
static int cfg_compare (ConfigEntryT **el1, ConfigEntryT **el2)
 
static FILEtry_path (const char *path, const char *file)
 
voidopen_cfg (const char *name, int quit_on_error)
 
static size_t read_cfg (FILE *cfgfile, ConfigEntryT ***pointer_array, bool do_remove_backslash)
 
void ReadCfg (void)
 
static ConfigEntryT ** search_rtf (const char *theTexCommand, int WhichCfg)
 
int SearchRtfIndex (const char *theTexCommand, int WhichCfg)
 
char * SearchRtfCmd (const char *theTexCommand, int WhichCfg)
 
ConfigEntryT ** CfgStartIterate (int WhichCfg)
 
ConfigEntryT ** CfgNext (int WhichCfg, ConfigEntryT **last)
 
void ReadLanguage (char *lang)
 
void ConvertBabelName (char *name)
 

Variables

static ConfigInfoT configinfo []
 
static char * buffer = NULL
 
static size_t bufsize = 0
 

Macro Definition Documentation

◆ BUFFER_INCREMENT

#define BUFFER_INCREMENT   1024

Definition at line 63 of file cfg.c.

◆ CONFIG_SIZE

#define CONFIG_SIZE   (sizeof(configinfo) / sizeof(ConfigInfoT))

Definition at line 62 of file cfg.c.

◆ CR

#define CR   (char) 0x0d

Definition at line 439 of file cfg.c.

◆ LF

#define LF   (char) 0x0a

Definition at line 440 of file cfg.c.

Typedef Documentation

◆ ConfigInfoT

typedef struct ConfigInfoT ConfigInfoT

Function Documentation

◆ cfg_compare()

static int cfg_compare ( ConfigEntryT **  el1,
ConfigEntryT **  el2 
)
static

purpose: compare-function for bsearch params: el1, el2: Config Entries to be compared

Definition at line 67 of file cfg.c.

References strcmp().

Referenced by read_cfg(), and search_rtf().

◆ CfgNext()

ConfigEntryT** CfgNext ( int  WhichCfg,
ConfigEntryT **  last 
)

purpose: Get the next entry from specified configuration data

Definition at line 370 of file cfg.c.

References ConfigInfoT::config_info, configinfo, last, and NULL.

Referenced by CurrentCyrillicFontFamily(), RtfFontNumber(), WriteFontHeader(), and WriteStyleHeader().

◆ CfgStartIterate()

ConfigEntryT** CfgStartIterate ( int  WhichCfg)

purpose: Start iterating of configuration data

Definition at line 361 of file cfg.c.

References NULL.

Referenced by CurrentCyrillicFontFamily(), RtfFontNumber(), WriteFontHeader(), and WriteStyleHeader().

◆ ConvertBabelName()

void ConvertBabelName ( char *  name)

purpose : returns a pointer to the Printout name of a Heading, since this is read from a language file it provides translation capability. params : name, name of heading.

Definition at line 429 of file cfg.c.

References ConvertString(), LANGUAGE_A, name, NULL, s, and SearchRtfCmd().

Referenced by CmdAbstract(), CmdCaption(), CmdPs(), CmdSection(), and CmdThebibliography().

◆ open_cfg()

void* open_cfg ( const char *  name,
int  quit_on_error 
)

purpose: open config by trying multiple paths

Definition at line 117 of file cfg.c.

References CFGDIR, diagnostics(), ERROR, f, FILE, fopen, fp, free, g_config_path, getenv(), kpse_program_text_format, name, NULL, p, p1, strchr, strdup, try_path(), and WARNING__.

Referenced by my_fopen(), ReadCfg(), and ReadLanguage().

◆ read_cfg()

static size_t read_cfg ( FILE cfgfile,
ConfigEntryT ***  pointer_array,
bool  do_remove_backslash 
)
static

purpose: Read config file and provide sorted lookup table

Definition at line 193 of file cfg.c.

References BUFFER_INCREMENT, bufsize, cfg_compare(), diagnostics(), ERROR, getc, isspace, line, malloc, NULL, qsort, ReadUptoMatch(), realloc, strchr, strdup, and strrchr.

Referenced by ReadCfg(), and ReadLanguage().

◆ ReadCfg()

void ReadCfg ( void  )

purpose: opens config-files & reads them globals: Direct-, Font- IgnoreArray[Size/Root]

Definition at line 278 of file cfg.c.

References ConfigInfoT::config_info_size, CONFIG_SIZE, configinfo, diagnostics(), fclose, FILE, ConfigInfoT::filename, fname, fp, i, open_cfg(), read_cfg(), TRUE, and void.

Referenced by main().

◆ ReadLanguage()

void ReadLanguage ( char *  lang)

opens and reads the language configuration file named in lang

Opens language file & builds a search tree for the translation of "Hardcoded" latex headings like "Part", "References", ... The file format is: LATEXTOKEN,Translation.

Definition at line 399 of file cfg.c.

References ConfigInfoT::config_info_size, configinfo, diagnostics(), ERROR, fclose, FILE, fp, free, lang, LANGUAGE_A, malloc, NULL, open_cfg(), read_cfg(), strcpy(), strlen(), TRUE, and void.

Referenced by setPackageBabel().

◆ ReadUptoMatch()

char * ReadUptoMatch ( FILE infile,
const char *  scanchars 
)

Definition at line 447 of file cfg.c.

References buffer, BUFFER_INCREMENT, bufsize, c, CR, diagnostics(), EOF, ERROR, feof, getc, infile, LF, malloc, NULL, realloc, strchr, and ungetc.

Referenced by read_cfg().

◆ search_rtf()

static ConfigEntryT** search_rtf ( const char *  theTexCommand,
int  WhichCfg 
)
static

purpose: search theTexCommand in specified config data and return pointer to the data

Definition at line 303 of file cfg.c.

References assert(), bsearch(), cfg_compare(), CONFIG_SIZE, configinfo, NULL, ConfigEntryT::RtfCommand, and ConfigEntryT::TexCommand.

Referenced by SearchRtfCmd(), and SearchRtfIndex().

◆ SearchRtfCmd()

char* SearchRtfCmd ( const char *  theTexCommand,
int  WhichCfg 
)

purpose: search theTexCommand in a specified config data and return pointer to the data

Definition at line 344 of file cfg.c.

References fc-lang::help, NULL, and search_rtf().

Referenced by ConvertBabelName(), InsertStyle(), TryDirectConvert(), TryStyleConvert(), and TryVariableIgnore().

◆ SearchRtfIndex()

int SearchRtfIndex ( const char *  theTexCommand,
int  WhichCfg 
)

purpose: search theTexCommand in a specified config data and return index

Definition at line 329 of file cfg.c.

References ConfigInfoT::config_info, configinfo, fc-lang::help, NULL, and search_rtf().

Referenced by TexFontNumber().

◆ try_path()

static FILE* try_path ( const char *  path,
const char *  file 
)
static

purpose: append path to .cfg file name and open return NULL upon failure, return filepointer otherwise

Definition at line 77 of file cfg.c.

References diagnostics(), ERROR, FILE, fopen, fp, free, lastchar, malloc, NULL, PATHSEP, strcpy(), and strlen().

Referenced by open_cfg().

Variable Documentation

◆ buffer

char* buffer = NULL
static

Definition at line 436 of file cfg.c.

Referenced by ReadUptoMatch().

◆ bufsize

size_t bufsize = 0
static

Definition at line 437 of file cfg.c.

Referenced by read_cfg(), and ReadUptoMatch().

◆ configinfo

ConfigInfoT configinfo[]
static
Initial value:
=
{
{"direct.cfg", NULL, 0, 0 },
{"fonts.cfg", NULL, 0, 0 },
{"ignore.cfg", NULL, 0, 0 },
{"style.cfg", NULL, 0, 0 },
{"english.cfg", NULL, 0, 0 },
}
#define NULL
Definition: ftobjs.h:61

Definition at line 53 of file cfg.c.

Referenced by CfgNext(), ReadCfg(), ReadLanguage(), search_rtf(), and SearchRtfIndex().