| 1 |
/* |
| 2 |
* $Id: args.h 443 2006-05-30 04:37:13Z darren $ |
| 3 |
* |
| 4 |
* Copyright (c) 1999-2002, Darren Hiebert |
| 5 |
* |
| 6 |
* This source code is released for free distribution under the terms of the |
| 7 |
* GNU General Public License. |
| 8 |
* |
| 9 |
* Defines external interface to command line argument reading. |
| 10 |
*/ |
| 11 |
#ifndef _ARGS_H |
| 12 |
#define _ARGS_H |
| 13 |
|
| 14 |
/* |
| 15 |
* INCLUDE FILES |
| 16 |
*/ |
| 17 |
#include "general.h" /* must always come first */ |
| 18 |
|
| 19 |
#include <stdio.h> |
| 20 |
|
| 21 |
/* |
| 22 |
* DATA DECLARATIONS |
| 23 |
*/ |
| 24 |
|
| 25 |
typedef enum { ARG_NONE, ARG_STRING, ARG_ARGV, ARG_FILE } argType; |
| 26 |
|
| 27 |
typedef struct sArgs { |
| 28 |
argType type; |
| 29 |
union { |
| 30 |
struct sStringArgs { |
| 31 |
const char* string; |
| 32 |
const char* next; |
| 33 |
const char* item; |
| 34 |
} stringArgs; |
| 35 |
struct sArgvArgs { |
| 36 |
char* const* argv; |
| 37 |
char* const* item; |
| 38 |
} argvArgs; |
| 39 |
struct sFileArgs { |
| 40 |
FILE* fp; |
| 41 |
} fileArgs; |
| 42 |
} u; |
| 43 |
char* item; |
| 44 |
boolean lineMode; |
| 45 |
} Arguments; |
| 46 |
|
| 47 |
/* |
| 48 |
* FUNCTION PROTOTYPES |
| 49 |
*/ |
| 50 |
extern Arguments* argNewFromString (const char* const string); |
| 51 |
extern Arguments* argNewFromArgv (char* const* const argv); |
| 52 |
extern Arguments* argNewFromFile (FILE* const fp); |
| 53 |
extern Arguments* argNewFromLineFile (FILE* const fp); |
| 54 |
extern char *argItem (const Arguments* const current); |
| 55 |
extern boolean argOff (const Arguments* const current); |
| 56 |
extern void argSetWordMode (Arguments* const current); |
| 57 |
extern void argSetLineMode (Arguments* const current); |
| 58 |
extern void argForth (Arguments* const current); |
| 59 |
extern void argDelete (Arguments* const current); |
| 60 |
|
| 61 |
#endif /* _ARGS_H */ |
| 62 |
|
| 63 |
/* vi:set tabstop=4 shiftwidth=4: */ |