This commit is contained in:
chris
2003-11-04 11:57:45 +00:00
parent fa64b3dd74
commit db4cda4090
5 changed files with 27 additions and 6 deletions

View File

@@ -6,6 +6,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include "stringmap.h" #include "stringmap.h"
@@ -162,15 +163,16 @@ int config_get_int(const char *directive, int *value) {
* Get an integer value from a config string. Returns 1 on success, -1 on * Get an integer value from a config string. Returns 1 on success, -1 on
* failure, or 0 if no value was found. */ * failure, or 0 if no value was found. */
int config_get_float(const char *directive, float *value) { int config_get_float(const char *directive, float *value) {
stringmap S;
item *I; item *I;
char *s, *t; char *s, *t;
if (!value) return -1; if (!value) return -1;
I = stringmap_find(config, directive); if (!(S = stringmap_find(config, directive)))
if (!I) return 0; return 0;
s = (char*)I->v; s = (char*)S->d.v;
if (!*s) return -1; if (!*s) return -1;
errno = 0; errno = 0;
*value = strtod(s, &t); *value = strtod(s, &t);

View File

@@ -240,7 +240,7 @@ static void usage(FILE *fp) {
"\n" "\n"
" -h display this message\n" " -h display this message\n"
" -n don't do hostname lookups\n" " -n don't do hostname lookups\n"
" -N don't convery port numbers to services\n" " -N don't convert port numbers to services\n"
" -p run in promiscuous mode (show traffic between other\n" " -p run in promiscuous mode (show traffic between other\n"
" hosts on the same network segment)\n" " hosts on the same network segment)\n"
" -b don't display a bar graph of traffic\n" " -b don't display a bar graph of traffic\n"

View File

@@ -16,7 +16,7 @@ static const char rcsid[] = "$Id$";
#include "stringmap.h" #include "stringmap.h"
#include "vector.h" #include "vector.h"
/*include "util.h"*/ #include "util.h"
/* stringmap_new: /* stringmap_new:
* Allocate memory for a new stringmap. */ * Allocate memory for a new stringmap. */

19
util.h Normal file
View File

@@ -0,0 +1,19 @@
/*
* util.h:
* Utility functions
*
* $Id$
*
*/
#ifndef __UTIL_H_ /* include guard */
#define __UTIL_H_
/* util.c */
void *xmalloc(size_t n);
void *xcalloc(size_t n, size_t m);
void *xrealloc(void *w, size_t n);
char *xstrdup(const char *s);
void xfree(void *v);
#endif /* __UTIL_H_ */

View File

@@ -16,7 +16,7 @@ static const char rcsid[] = "$Id$";
#include <string.h> #include <string.h>
#include "vector.h" #include "vector.h"
/*include "util.h"*/ #include "util.h"
vector vector_new(void) { vector vector_new(void) {
vector v; vector v;