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).

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_READFILE_TRIMNEWLINES, poptAddItem(), poptParseArgvString(), poptReadFile(), and stpcpy().

Referenced by poptReadConfigFile().

poptContext poptFini ( poptContext  con  ) 

Destroy context (alternative implementation).

Parameters:
con context
Returns:
NULL always

Definition at line 559 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:
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 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:
argc no. of arguments
argv argument array
options address of popt option table
configPaths colon separated file path(s) to read.
Returns:
initialized popt context (NULL on error).

Definition at line 565 of file poptconfig.c.

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

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 392 of file poptconfig.c.

References _isspaceptr, 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 445 of file poptconfig.c.

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

Referenced by poptInit().

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

< errno set, use strerror(errno)

Definition at line 499 of file poptconfig.c.

References poptContext_s::appName, 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_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.7.1