libjulius/src/m_jconf.c File Reference

Read a configuration file. More...

#include <julius/julius.h>

Go to the source code of this file.

Defines

#define ISTOKEN(A)   (A == ' ' || A == '\t' || A == '\n')
 Determine token characters.

Functions

static char * fgets_jconf (char *buf, int size, FILE *fp)
 line reading function for jconf file.
void get_dirname (char *path)
 Get directory name from a path name of a file.
static char * expand_env (char *str)
 Envronment valuable expansion for a string.
boolean config_file_parse (char *conffile, Jconf *jconf)
 Read and parse a jconf file, and set the specified option values.


Detailed Description

Read a configuration file.

These functions are for reading jconf configuration file and set the parameters into jconf structure. String bracing by double quotation, and escaping character with backslash are supproted. Characters after '#' at each line will be ignored.

Note that all relative paths in jconf file are treated as relative to the jconf file, not the run-time current directory.

You can expand environment variables in a format of $HOME, ${HOME} or /home/ri in jconf file.

Author:
Akinobu Lee
Date:
Thu May 12 14:16:18 2005
Revision
1.1.1.1

Definition in file m_jconf.c.


Function Documentation

static char* fgets_jconf ( char *  buf,
int  size,
FILE *  fp 
) [static]

line reading function for jconf file.

This function has capability of character escaping and newline codes on Win/Mac. Blank line will be skipped and newline characters will be stripped.

Parameters:
buf [out] buffer to store the read text per line
size [in] size of buf in bytes
fp [in] file pointer
Returns:
buf on success, or NULL when encountered EOF and no further input.

Definition at line 87 of file m_jconf.c.

Referenced by config_file_parse().

void get_dirname ( char *  path  ) 

Get directory name from a path name of a file.

The trailing slash will be left, and the given buffer will be modified.

Parameters:
path [i/o] file path name, will be modified to directory name

Definition at line 153 of file m_jconf.c.

Referenced by config_file_parse(), and multigram_add_prefix_filelist().

static char* expand_env ( char *  str  )  [static]

Envronment valuable expansion for a string.

This function expands environment valuable in a string. When an expantion occurs, the given buffer will be released inside this function and newly allocated buffer that holds the resulting string will be returned.

Environment valuables should be in a form of $HOME, ${HOME} or /home/ri. '$' can be escaped by back slash, and strings enbraced by single quote will be treated as is (no expansion).

Parameters:
str [in] target string
Returns:
the str itself when no expansion performed, or newly allocated buffer if expansion occurs.

Definition at line 206 of file m_jconf.c.

Referenced by config_file_parse().

boolean config_file_parse ( char *  conffile,
Jconf jconf 
)

Read and parse a jconf file, and set the specified option values.

Parameters:
conffile [in] jconf file path name
jconf [out] global configuration data to be written.

Definition at line 376 of file m_jconf.c.

Referenced by j_config_load_file(), j_config_load_file_new(), and opt_parse().

Here is the caller graph for this function:


Generated on Tue Dec 18 16:01:17 2007 for Julius by  doxygen 1.5.4