parser.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <stdarg.h>
#include "gis.h"
#include "glocale.h"

Include dependency graph for parser.c:

Go to the source code of this file.

Data Structures

struct  Item

Defines

#define BAD_SYNTAX   1
#define OUT_OF_RANGE   2
#define MISSING_VALUE   3

Functions

int G_disable_interactive (void)
 turns off interactive capability
Flag * G_define_flag (void)
 return Flag structure
Option * G_define_option (void)
 returns Option structure
Option * G_define_standard_option (int opt)
GModule * G_define_module (void)
int G_parser (int argc, char **argv)
 parse command line
int G_usage (void)
 command line help/usage message
void print_escaped_for_xml (FILE *fp, char *str)
char * G_recreate_command (void)


Define Documentation

#define BAD_SYNTAX   1

Definition at line 107 of file parser.c.

#define MISSING_VALUE   3

Definition at line 109 of file parser.c.

#define OUT_OF_RANGE   2

Definition at line 108 of file parser.c.


Function Documentation

struct Flag* G_define_flag ( void   ) 

return Flag structure

Allocates memory for the Flag structure and returns a pointer to this memory (of type struct Flag *).

Returns:
Flag *

Definition at line 195 of file parser.c.

References G_malloc(), G_zero(), Item::next_item, and NULL.

struct GModule* G_define_module ( void   ) 

Definition at line 393 of file parser.c.

References G_zero().

struct Option* G_define_option ( void   ) 

returns Option structure

Allocates memory for the Option structure and returns a pointer to this memory (of type struct Option *).

Returns:
Option *

Definition at line 246 of file parser.c.

References G_malloc(), G_zero(), Item::next_item, and NULL.

Referenced by G_define_standard_option().

struct Option* G_define_standard_option ( int  opt  ) 

Definition at line 301 of file parser.c.

References G_define_option().

int G_disable_interactive ( void   ) 

turns off interactive capability

When a user calls a command with no arguments on the command line, the parser will enter its own standardized interactive session in which all flags and options are presented to the user for input. A call to G_disable_interactive() disables the parser's interactive prompting.

Returns:
int

Definition at line 176 of file parser.c.

int G_parser ( int  argc,
char **  argv 
)

parse command line

The command line parameters argv and the number of parameters argc from the main() routine are passed directly to G_parser(). G_parser() accepts the command line input entered by the user, and parses this input according to the input options and/or flags that were defined by the programmer. G_parser() returns 0 if successful. If not successful, a usage statement is displayed that describes the expected and/or required options and flags and a non-zero value is returned.

Parameters:
argc 
argv 
Returns:
0 on success, -1 on error

Definition at line 429 of file parser.c.

References fprintf(), G_calloc(), G_free_tokens(), G_malloc(), G_realloc(), G_store(), G_tokenize(), G_usage(), G_warning(), getenv(), and NULL.

char* G_recreate_command ( void   ) 

Definition at line 2114 of file parser.c.

References G_calloc(), G_debug(), G_program_name(), G_realloc(), if(), and NULL.

int G_usage ( void   ) 

command line help/usage message

Calls to G_usage() allow the programmer to print the usage message at any time. This will explain the allowed and required command line input to the user. This description is given according to the programmer's definitions for options and flags. This function becomes useful when the user enters options and/or flags on the command line that are syntactically valid to the parser, but functionally invalid for the command (e.g. an invalid file name.) For example, the parser logic doesn't directly support grouping options. If two options be specified together or not at all, the parser must be told that these options are not required and the programmer must check that if one is specified the other must be as well. If this additional check fails, then G_parser() will succeed, but the programmer can then call G_usage() to print the standard usage message and print additional information about how the two options work together.

Returns:
int

Definition at line 680 of file parser.c.

References fprintf(), G_program_name(), if(), and NULL.

Referenced by G_parser().

void print_escaped_for_xml ( FILE *  fp,
char *  str 
)

Definition at line 828 of file parser.c.


Generated on Sat Jul 22 22:06:32 2006 for GRASS by  doxygen 1.4.7