peapod  0.1.0
EAPOL Proxy Daemon
Functions | Variables
args.c File Reference

Parse command-line arguments, set up the global program arguments data structure. More...

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <getopt.h>
#include <libgen.h>
#include <string.h>
#include <unistd.h>
#include "args.h"
#include "defaults.h"
#include "log.h"
Include dependency graph for args.c:

Functions

static void print_args (void)
 Log the global program arguments data structure. More...
 
char * args_canonpath (const char *path, uint8_t create)
 Validate and canonicalize a path. More...
 
int args_get (int argc, char *argv[])
 Parse command-line arguments and set up the global program arguments data structure. More...
 

Variables

static char * opts = ":hdp:c:tl::svCo"
 An optstring for getopt(3) More...
 
static struct option long_opts []
 An array of struct option structures for getopt_long(3) More...
 
struct args_t args
 Program arguments data structure. More...
 

Detailed Description

Parse command-line arguments, set up the global program arguments data structure.

Function Documentation

static void print_args ( void  )
static

Log the global program arguments data structure.

char* args_canonpath ( const char *  path,
uint8_t  create 
)

Validate and canonicalize a path.

Parameters
pathPath to validate
createFlag: Test creating nonexistent path, mode 0644?
Returns
A newly allocated C string containing the canonicalized path if successful, or NULL if unsuccessful
Note
If successful, caller is responsible for free(3)ing the result
See also
defaults.h
int args_get ( int  argc,
char *  argv[] 
)

Parse command-line arguments and set up the global program arguments data structure.

Parameters
argcThe number of command-line arguments
argvA vector of command-line arguments
Returns
0 if successful, or -1 if unsuccessful

Variable Documentation

char* opts = ":hdp:c:tl::svCo"
static

An optstring for getopt(3)

struct option long_opts[]
static
Initial value:
= {
{ "help", no_argument, NULL, 'h' },
{ "daemon", no_argument, NULL, 'd' },
{ "pid", required_argument, NULL, 'p' },
{ "config", required_argument, NULL, 'c' },
{ "test", no_argument, NULL, 't' },
{ "log", optional_argument, NULL, 'l' },
{ "syslog", no_argument, NULL, 's' },
{ "quiet-script", no_argument, NULL, 'q' },
{ "color", no_argument, NULL, 'C' },
{ "oneshot", no_argument, NULL, 'o' },
{ NULL, 0, NULL, 0 }
}

An array of struct option structures for getopt_long(3)

struct args_t args

Program arguments data structure.

Note
Global