""
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.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
|
||||
* failure, or 0 if no value was found. */
|
||||
int config_get_float(const char *directive, float *value) {
|
||||
stringmap S;
|
||||
item *I;
|
||||
char *s, *t;
|
||||
|
||||
if (!value) return -1;
|
||||
|
||||
I = stringmap_find(config, directive);
|
||||
if (!I) return 0;
|
||||
if (!(S = stringmap_find(config, directive)))
|
||||
return 0;
|
||||
|
||||
s = (char*)I->v;
|
||||
s = (char*)S->d.v;
|
||||
if (!*s) return -1;
|
||||
errno = 0;
|
||||
*value = strtod(s, &t);
|
||||
|
||||
@@ -240,7 +240,7 @@ static void usage(FILE *fp) {
|
||||
"\n"
|
||||
" -h display this message\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"
|
||||
" hosts on the same network segment)\n"
|
||||
" -b don't display a bar graph of traffic\n"
|
||||
|
||||
@@ -16,7 +16,7 @@ static const char rcsid[] = "$Id$";
|
||||
|
||||
#include "stringmap.h"
|
||||
#include "vector.h"
|
||||
/*include "util.h"*/
|
||||
#include "util.h"
|
||||
|
||||
/* stringmap_new:
|
||||
* Allocate memory for a new stringmap. */
|
||||
|
||||
19
util.h
Normal file
19
util.h
Normal 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_ */
|
||||
Reference in New Issue
Block a user