poptconfig.c File Reference

#include "system.h"
#include "poptint.h"
#include <sys/stat.h>

Include dependency graph for poptconfig.c:

Go to the source code of this file.

Functions

static int poptGlob (poptContext con, const char *pattern, int *acp, const char ***avp)
 Return path(s) from a glob pattern.
int poptSaneFile (const char *fn)
 Perform sanity checks on a file path.
int poptReadFile (const char *fn, char **bp, size_t *nbp, int flags)
 Read a file into a buffer.
static int configAppMatch (poptContext con, const char *s)
 Check for application match.
static int poptConfigLine (poptContext con, char *line)
int poptReadConfigFile (poptContext con, const char *fn)
 Read configuration file.
int poptReadConfigFiles (poptContext con, const char *paths)
 Read configuration file(s).
int poptReadDefaultConfig (poptContext con, int useEnv)
 Read default configuration from /etc/popt and $HOME/.popt.


Function Documentation

static int configAppMatch ( poptContext  con,
const char *  s 
) [static]

Check for application match.

Parameters:
con context
s config application name return 0 if config application matches

Definition at line 239 of file poptconfig.c.

References poptContext_s::appName.

Referenced by poptConfigLine().

static int poptConfigLine ( poptContext  con,
char *  line 
) [static]

< config file failed sanity test

< don't show in help/usage

< don't show in help/usage

< don't show in help/usage

< arg will be saved as string

Definition at line 263 of file poptconfig.c.

References _isspaceptr, poptContext_s::appName, configAppMatch(), POPT_ARG_STRING, POPT_ARGFLAG_DOC_HIDDEN, POPT_ERROR_BADCONFIG, POPT_READFILE_TRIMNEWLINES, poptAddItem(), poptParseArgvString(), poptReadFile(), and stpcpy().

Referenced by poptReadConfigFile().

static int poptGlob ( poptContext  con,
const char *  pattern,
int *  acp,
const char ***  avp 
) [static]

Return path(s) from a glob pattern.

Parameters:
con context
pattern glob pattern
Return values:
*acp no. of paths
*avp array of paths
Returns:
0 on success

Definition at line 96 of file poptconfig.c.

References POPT_ERROR_ERRNO, and xstrdup.

Referenced by poptReadConfigFiles(), and poptReadDefaultConfig().

int poptReadConfigFile ( poptContext  con,
const char *  fn 
)

Read configuration file.

Parameters:
con context
fn file name to read
Returns:
0 on success, POPT_ERROR_ERRNO on failure

< config file failed sanity test

Definition at line 391 of file poptconfig.c.

References _isspaceptr, POPT_ERROR_BADCONFIG, POPT_READFILE_TRIMNEWLINES, poptConfigLine(), and poptReadFile().

Referenced by poptReadConfigFiles(), and poptReadDefaultConfig().

int poptReadConfigFiles ( poptContext  con,
const char *  paths 
)

Read configuration file(s).

Colon separated files to read, looping over poptReadConfigFile(). Note that an '@' character preceeding a path in the list will also perform additional sanity checks on the file before reading.

Parameters:
con context
paths colon separated file name(s) to read
Returns:
0 on success, POPT_ERROR_BADCONFIG on failure

< config file failed sanity test

Definition at line 444 of file poptconfig.c.

References POPT_ERROR_BADCONFIG, poptGlob(), poptReadConfigFile(), poptSaneFile(), and xstrdup.

int poptReadDefaultConfig ( poptContext  con,
int  useEnv 
)

Read default configuration from /etc/popt and $HOME/.popt.

Parameters:
con context
useEnv (unused)
Returns:
0 on success, POPT_ERROR_ERRNO on failure

Definition at line 498 of file poptconfig.c.

References poptContext_s::appName, POPT_ERROR_ERRNO, poptGlob(), poptReadConfigFile(), and stpcpy().

int poptReadFile ( const char *  fn,
char **  bp,
size_t *  nbp,
int  flags 
)

Read a file into a buffer.

Parameters:
fn file name
Return values:
*bp buffer (malloc'd) (or NULL)
*nbp no. of bytes in buffer (including final NUL) (or NULL)
Parameters:
flags 1 to trim escaped newlines return 0 on success

< errno set, use strerror(errno)

< memory allocation failed

Definition at line 159 of file poptconfig.c.

References POPT_ERROR_ERRNO, POPT_ERROR_MALLOC, and POPT_READFILE_TRIMNEWLINES.

Referenced by poptConfigLine(), and poptReadConfigFile().

int poptSaneFile ( const char *  fn  ) 

Perform sanity checks on a file path.

Parameters:
fn file name
Returns:
0 on OK, 1 on NOTOK.

Definition at line 141 of file poptconfig.c.

Referenced by poptReadConfigFiles().


Generated for popt by  doxygen 1.5.8