args.h 1.37 KB
Newer Older
Enrico Tröger's avatar
Enrico Tröger committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/*
*
*   Copyright (c) 1999-2001, Darren Hiebert
*
*   This source code is released for free distribution under the terms of the
*   GNU General Public License.
*
*   Defines external interface to command line argument reading.
*/
#ifndef _ARGS_H
#define _ARGS_H

/*
*   INCLUDE FILES
*/
#include "general.h"	/* must always come first */

/*
*   DATA DECLARATIONS
*/

typedef struct sArgs {
    enum { ARG_NONE, ARG_STRING, ARG_ARGV, ARG_FILE } type;
    union {
	struct sStringArgs {
	    const char* string;
	    const char* next;
	    const char* item;
	} stringArgs;
	struct sArgvArgs {
	    char* const* argv;
	    char* const* item;
	} argvArgs;
	struct sFileArgs {
	    FILE* fp;
	} fileArgs;
    } u;
    char* item;
    boolean lineMode;
} Arguments;

/*
*   FUNCTION PROTOTYPES
*/
extern Arguments* argNewFromString (const char* const string);
extern Arguments* argNewFromArgv (char* const* const argv);
extern Arguments* argNewFromFile (FILE* const fp);
extern Arguments* argNewFromLineFile (FILE* const fp);
extern char *argItem (const Arguments* const current);
extern boolean argOff (const Arguments* const current);
extern void argSetWordMode (Arguments* const current);
extern void argSetLineMode (Arguments* const current);
extern void argForth (Arguments* const current);
extern void argDelete (Arguments* const current);

#endif	/* _ARGS_H */

/* vi:set tabstop=8 shiftwidth=4: */