-/* $NetBSD: getpar.c,v 1.5 1997/10/12 21:24:50 christos Exp $ */
+/* $NetBSD: getpar.c,v 1.12 2004/01/27 20:30:31 jsm Exp $ */
/*
* Copyright (c) 1980, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)getpar.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: getpar.c,v 1.5 1997/10/12 21:24:50 christos Exp $");
+__RCSID("$NetBSD: getpar.c,v 1.12 2004/01/27 20:30:31 jsm Exp $");
#endif
#endif /* not lint */
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "getpar.h"
#include "trek.h"
-static int testterm __P((void));
+static int testterm(void);
/**
** get integer parameter
int
getintpar(s)
-char *s;
+ const char *s;
{
int i;
int n;
**/
double getfltpar(s)
-char *s;
+ const char *s;
{
int i;
double d;
** get yes/no parameter
**/
-struct cvntab Yntab[] =
+const struct cvntab Yntab[] =
{
- { "y", "es", (cmdfun)1, 0 },
+ { "y", "es", (cmdfun)1, 1 },
{ "n", "o", (cmdfun)0, 0 },
{ NULL, NULL, NULL, 0 }
};
int
getynpar(s)
-char *s;
+ const char *s;
{
- struct cvntab *r;
+ const struct cvntab *r;
r = getcodpar(s, Yntab);
- return (int) r->value;
+ return r->value2;
}
** get coded parameter
**/
-struct cvntab *getcodpar(s, tab)
-char *s;
-struct cvntab tab[];
+const struct cvntab *getcodpar(s, tab)
+ const char *s;
+ const struct cvntab tab[];
{
char input[100];
- struct cvntab *r;
+ const struct cvntab *r;
int flag;
- char *p, *q;
+ const char *p, *q;
int c;
int f;
if (f)
cgetc(0); /* throw out the newline */
scanf("%*[ \t;]");
- if ((c = scanf("%[^ \t;\n]", input)) < 0)
+ if ((c = scanf("%99[^ \t;\n]", input)) < 0)
exit(1);
if (c == 0)
continue;
void
getstrpar(s, r, l, t)
-char *s;
-char *r;
-int l;
-char *t;
+ const char *s;
+ char *r;
+ int l;
+ const char *t;
{
int i;
char format[20];
/*
-** TEST FOR SPECIFIED DELIMETER
+** TEST FOR SPECIFIED DELIMITER
**
** The standard input is scanned for the parameter. If found,
** it is thrown away and non-zero is returned. If not found,