popt  1.16
Functions
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.
poptContext poptFini (poptContext con)
 Destroy context (alternative implementation).
poptContext poptInit (int argc, const char **argv, const struct poptOption *options, const char *configPaths)
 Initialize popt context (alternative implementation).

Detailed Description

Definition in file poptconfig.c.


Function Documentation

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

Check for application match.

Parameters:
concontext
sconfig 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(), realloc(), and stpcpy().

Referenced by poptReadConfigFile().

Destroy context (alternative implementation).

Parameters:
concontext
Returns:
NULL always

Definition at line 561 of file poptconfig.c.

References poptFreeContext().

Referenced by poptInit().

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

Return path(s) from a glob pattern.

Parameters:
concontext
patternglob pattern
Return values:
*acpno. of paths
*avparray of paths
Returns:
0 on success

Definition at line 96 of file poptconfig.c.

References calloc(), POPT_ERROR_ERRNO, and xstrdup.

Referenced by poptReadConfigFiles(), and poptReadDefaultConfig().

poptContext poptInit ( int  argc,
const char **  argv,
const struct poptOption options,
const char *  configPaths 
)

Initialize popt context (alternative implementation).

This routine does poptGetContext() and then poptReadConfigFiles().

Parameters:
argcno. of arguments
argvargument array
optionsaddress of popt option table
configPathscolon separated file path(s) to read.
Returns:
initialized popt context (NULL on error).

Definition at line 567 of file poptconfig.c.

References poptFini(), poptGetContext(), and poptReadConfigFiles().

int poptReadConfigFile ( poptContext  con,
const char *  fn 
)

Read configuration file.

Parameters:
concontext
fnfile name to read
Returns:
0 on success, POPT_ERROR_ERRNO on failure

< no context

< config file failed sanity test

Definition at line 392 of file poptconfig.c.

References _isspaceptr, malloc(), POPT_ERROR_BADCONFIG, POPT_ERROR_NOCONTEXT, 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:
concontext
pathscolon separated file name(s) to read
Returns:
0 on success, POPT_ERROR_BADCONFIG on failure

< config file failed sanity test

Definition at line 447 of file poptconfig.c.

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

Referenced by poptInit().

int poptReadDefaultConfig ( poptContext  con,
int  useEnv 
)

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

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

< errno set, use strerror(errno)

Definition at line 501 of file poptconfig.c.

References poptContext_s::appName, malloc(), 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:
fnfile name
Return values:
*bpbuffer (malloc'd) (or NULL)
*nbpno. of bytes in buffer (including final NUL) (or NULL)
Parameters:
flags1 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 calloc(), 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:
fnfile 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.7.6.1