Main Page | Data Structures | File List | Data Fields | Globals

popts2.h File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cuf-global.h"
#include "array.h"
#include "llist.h"

Go to the source code of this file.

Data Structures

struct  _DescMember
struct  _DescCatagory
struct  _COption

Typedefs

typedef enum _OType OType
typedef enum _OClass OClass
typedef _DescMember DescMember
typedef _DescCatagory DescCatagory
typedef _COption COption

Enumerations

enum  _OType {
  OBool,
  OChar,
  OInt,
  OLong,
  OFloat,
  ODouble,
  OString,
  OFuncVoid,
  OFuncBool,
  OFuncChar,
  OFuncInt,
  OFuncLong,
  OFuncFloat,
  OFuncDouble,
  OFuncString,
  OString2d,
  OFuncString2d,
  OProgramname
}
enum  _OClass {
  OCLetter,
  OCWord,
  OCSpecial
}

Functions

unsigned int popts2_add (char *s, OClass oc, OType ot, void *var)
void popts2_desc_cat_add (char *cname, char *text)
int popts2_desc_add (char *cname, char *desc)
void popts2_desc_connect (unsigned int did, unsigned int oid)
void popts2_desc_print (void)
void popts2_help_add (void)
void popts2_parse (int argc, char **argv)
void popts2_done (void)


Detailed Description

Command line options parser, v0.3

Typedef Documentation

typedef struct _COption COption
 

Description:
Command Option, (Internal Only).

typedef struct _DescCatagory DescCatagory
 

Description:
Description Catagory, (Internal Only).

typedef struct _DescMember DescMember
 

Description:
Description Member, (Internal Only).

typedef enum _OClass OClass
 

Description:
Option Class.

typedef enum _OType OType
 

Description:
The data type.


Enumeration Type Documentation

enum _OClass
 

Description:
Option Class.
Enumeration values:
OCLetter  Single Character switch.
OCWord  String switch.
OCSpecial  Special (not switched and program name).

enum _OType
 

Description:
The data type.
Enumeration values:
OBool  int, The bool inverts the current setting. Multiable calls to the bool on the command line will invert with each time the switch is parsed.
OChar  char
OInt  int
OLong  long
OFloat  float
ODouble  double
OString  char *, If the pointer is NULL, then memory will be allocated. If the pointer is not null it will be freed and new memory will be allocated.
OFuncVoid  FuncVoid, Just the function is called with no arguments.
OFuncBool  FuncBool, The function is called with TRUE as the argument.
OFuncChar  FuncChar
OFuncInt  FuncInt
OFuncLong  FuncLong
OFuncFloat  FuncFloat
OFuncDouble  FuncDouble
OFuncString  FuncString
OString2d  char **
OFuncString2d  void func (char **)
OProgramname  char *


Function Documentation

unsigned int popts2_add char *  s,
OClass  oc,
OType  ot,
void *  var
 

Parameters:
s The switch character or string.
oc Option class. If its a single character, string or special type.
ot Option type. The variable type to expect and to convert to.
var The variable to minipulate when the option is parsed.
Return values:
unsigned int A non-zero identifyer for the newly added option. This is used to attach a description to this option.
0 On failure. Failures include: NULL argument 's' and it is not of the class OCSpecial or the switch is allready being used.
Description:
Adds a switch option to search for when parseing the command line options.

int popts2_desc_add char *  cname,
char *  desc
 

Parameters:
cname The description catagory to add this description to. If NULL it will be added to 'Options'.
desc The description text.
Return values:
int A non-zero positive integer of the added description ID.
0 If the 'desc' option was NULL.
Description:
Adds a description.

void popts2_desc_cat_add char *  cname,
char *  text
 

Parameters:
cname Catagory name.
text Some optional, extra text to print for this catagory.
Description:
Adds a new description catagory.

void popts2_desc_connect unsigned int  did,
unsigned int  oid
 

Parameters:
did The description ID to attach to.
oid The command option ID to attach.
Description:
Connects a command option to a description.

void popts2_desc_print void   ) 
 

Description:
Prints out the command options and descriptions. Organized by the categories the options are attached to. Unattached options are printed after all the options that had descriptions. If a description is attached to the OString2d or OFuncString2d special type, it is printed as the very last thing.

void popts2_done void   ) 
 

Description:
Frees and cleans up all the variables. After calling this function it is safe to begin addin new options for a seprate parse, with out conflict from the previous options.

void popts2_help_add void   ) 
 

Description:
Automaticly adds the '-h' and '--help' options to call popts2_desc_print(). If 'h' or 'help' is allready used then it is not added for that option.

void popts2_parse int  argc,
char **  argv
 

Parameters:
argc The 'argc' argument passed to main().
argv The 'argv' argument passed to main().
Description:
The main parseing function for the command options. This is called after all the options and descriptions are added and attached.


Generated on Fri Jun 4 18:35:20 2004 for cuf by doxygen 1.3.6