MAN page from Mandrake Other XITE-3.3-3.i386.rpm
READ_SWITCH
Section: C Library Functions (3)
Updated: 16 Mar 1998
Index
NAME
read_switch, read_bswitch, read_iswitch, read_dswitch -read switches from command line
SYNTAX
#include <
xite/readarg.h>
char *read_switch( int* argc, char** argv,
char* name, int args, char* defreturn );
int read_bswitch( int* argc, char** argv,
char* name );
int read_iswitch( int* argc, char** argv,
char* name, int defval );
double read_dswitch( int* argc, char** argv,
char* name, double defval );
DESCRIPTION
read_switchreads a switch/option from the command line. Theroutine searches for the switch
name.If
nameis foundand args is zero, a pointer to the switch is returned.If
nameis found and
argsis nonzero, a stringcontaining the switch argument(s) is returned.Otherwise, if
namedoes not occur in thecommand line,
defreturnis returned.
read_bswitchreturns TRUE if nameis a switchin the command line, FALSE otherwise.
read_iswitchsearches for switch nameand returnsits argument (converted to integer), otherwise itreturns defval.
read_dswitchsearches for switch nameand returnsits argument (converted to double), otherwise itreturns defval.
The switch and its argument are removed fromargv,and argcis decremented.
EXAMPLES
#include <
math.h>
#include <
xite/readarg.h>
char *res, *fn;
double d;
int i, j, l;
d = atof(read_switch(&argc, argv, "-scale", 1, "0.5"));
sscanf(read_switch(&argc, argv, "-offset", 2, "128 128"),
"%d%d", &i, &j);
l = read_switch(&argc, argv, "-log", 0, NULL) != NULL;
res = read_switch(&argc, argv, "-yes", 0, "-no");
fn = argv[1];
or:
d = read_dswitch(&argc, argv, "-scale", 0.5);
sscanf(read_switch(&argc, argv, "-offset", 2, "128 128"),
"%d%d", &i, &j);
l = read_bswitch(&argc, argv, "-log");
res = read_switch(&argc, argv, "-yes", 0, "-no");
fn = argv[1];
commandline: prog -offset 3 3 -scale 2 -log filename
d : 2.0
i : 3
j : 3
l : TRUE
res : "-no"
fn : "filename"
AUTHOR
Otto Milvang
ID
$Id: readswitch.c,v 1.27 1996/06/04 14:56:33 svein Exp $
Index
- NAME
- SYNTAX
- DESCRIPTION
- EXAMPLES
- AUTHOR
- ID
This document was created byman2html,using the manual pages.