"log" is a name that belongs to the ANSI C89 standard; it refers to a

function that computes the natural logarithm of a double.  Using it as
the name of a pointer to a routine to do logging can cause namespace
collisions; in fact, it *does* cause them on AIX.  Rename the function
argument to "logfunc".

svn path=/trunk/; revision=4700
This commit is contained in:
Guy Harris 2002-02-05 22:50:17 +00:00
parent e0828c513d
commit 2d3a60e9a9
7 changed files with 56 additions and 54 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ftype-bytes.c,v 1.9 2002/01/21 07:37:39 guy Exp $ * $Id: ftype-bytes.c,v 1.10 2002/02/05 22:50:17 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com> * By Gerald Combs <gerald@ethereal.com>
@ -98,7 +98,7 @@ is_byte_sep(guint8 c)
} }
static gboolean static gboolean
val_from_string(fvalue_t *fv, char *s, LogFunc log) val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
GByteArray *bytes; GByteArray *bytes;
guint8 val; guint8 val;
@ -182,8 +182,8 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
if (fail) { if (fail) {
if (log != NULL) if (logfunc != NULL)
log("\"%s\" is not a valid byte string.", s); logfunc("\"%s\" is not a valid byte string.", s);
g_byte_array_free(bytes, TRUE); g_byte_array_free(bytes, TRUE);
return FALSE; return FALSE;
} }
@ -195,7 +195,7 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
static gboolean static gboolean
ether_from_string(fvalue_t *fv, char *s, LogFunc log) ether_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
guint8 *mac; guint8 *mac;
@ -210,7 +210,8 @@ ether_from_string(fvalue_t *fv, char *s, LogFunc log)
mac = get_ether_addr(s); mac = get_ether_addr(s);
if (!mac) { if (!mac) {
log("\"%s\" is not a valid hostname or Ethernet address.", s); logfunc("\"%s\" is not a valid hostname or Ethernet address.",
s);
return FALSE; return FALSE;
} }
@ -219,12 +220,12 @@ ether_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
static gboolean static gboolean
ipv6_from_string(fvalue_t *fv, char *s, LogFunc log) ipv6_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
guint8 buffer[16]; guint8 buffer[16];
if (!get_host_ipaddr6(s, (struct e_in6_addr*)buffer)) { if (!get_host_ipaddr6(s, (struct e_in6_addr*)buffer)) {
log("\"%s\" is not a valid hostname or IPv6 address.", s); logfunc("\"%s\" is not a valid hostname or IPv6 address.", s);
return FALSE; return FALSE;
} }
@ -233,12 +234,12 @@ ipv6_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
static gboolean static gboolean
u64_from_string(fvalue_t *fv, char *s, LogFunc log) u64_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
guint8 buffer[8]; guint8 buffer[8];
if (atou64(s, buffer) == NULL) { if (atou64(s, buffer) == NULL) {
log("\"%s\" is not a valid integer", s); logfunc("\"%s\" is not a valid integer", s);
return FALSE; return FALSE;
} }
@ -247,12 +248,12 @@ u64_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
static gboolean static gboolean
i64_from_string(fvalue_t *fv, char *s, LogFunc log) i64_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
guint8 buffer[8]; guint8 buffer[8];
if (atoi64(s, buffer) == NULL) { if (atoi64(s, buffer) == NULL) {
log("\"%s\" is not a valid integer", s); logfunc("\"%s\" is not a valid integer", s);
return FALSE; return FALSE;
} }

View File

@ -1,11 +1,9 @@
/* /*
* * $Id: ftype-double.c,v 1.5 2002/02/05 22:50:17 guy Exp $
* $Id: ftype-double.c,v 1.4 2001/07/13 00:55:56 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org> * By Gerald Combs <gerald@ethereal.com>
* Copyright 2001 Gerald Combs * Copyright 2001 Gerald Combs
*
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -50,7 +48,7 @@ value_get_floating(fvalue_t *fv)
} }
static gboolean static gboolean
val_from_string(fvalue_t *fv, char *s, LogFunc log) val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
char *endptr = NULL; char *endptr = NULL;
@ -58,18 +56,19 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
if (endptr == s || *endptr != '\0') { if (endptr == s || *endptr != '\0') {
/* This isn't a valid number. */ /* This isn't a valid number. */
log("\"%s\" is not a valid number.", s); logfunc("\"%s\" is not a valid number.", s);
return FALSE; return FALSE;
} }
if (errno == ERANGE) { if (errno == ERANGE) {
if (fv->value.floating == 0) { if (fv->value.floating == 0) {
log("\"%s\" causes floating-point underflow.", s); logfunc("\"%s\" causes floating-point underflow.", s);
} }
else if (fv->value.floating == HUGE_VAL) { else if (fv->value.floating == HUGE_VAL) {
log("\"%s\" causes floating-point overflow.", s); logfunc("\"%s\" causes floating-point overflow.", s);
} }
else { else {
log("\"%s\" is not a valid floating-point number.", s); logfunc("\"%s\" is not a valid floating-point number.",
s);
} }
return FALSE; return FALSE;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ftype-integer.c,v 1.7 2002/01/21 07:37:39 guy Exp $ * $Id: ftype-integer.c,v 1.8 2002/02/05 22:50:17 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com> * By Gerald Combs <gerald@ethereal.com>
@ -54,7 +54,7 @@ get_integer(fvalue_t *fv)
} }
static gboolean static gboolean
val_from_string(fvalue_t *fv, char *s, LogFunc log) val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
char *endptr; char *endptr;
@ -62,17 +62,18 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
if (endptr == s || *endptr != '\0') { if (endptr == s || *endptr != '\0') {
/* This isn't a valid number. */ /* This isn't a valid number. */
if (log != NULL) if (logfunc != NULL)
log("\"%s\" is not a valid number.", s); logfunc("\"%s\" is not a valid number.", s);
return FALSE; return FALSE;
} }
if (errno == ERANGE) { if (errno == ERANGE) {
if (log != NULL) { if (logfunc != NULL) {
if (fv->value.integer == ULONG_MAX) { if (fv->value.integer == ULONG_MAX) {
log("\"%s\" causes an integer overflow.", s); logfunc("\"%s\" causes an integer overflow.",
s);
} }
else { else {
log("\"%s\" is not an integer.", s); logfunc("\"%s\" is not an integer.", s);
} }
} }
return FALSE; return FALSE;
@ -82,7 +83,7 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
static gboolean static gboolean
ipxnet_from_string(fvalue_t *fv, char *s, LogFunc log) ipxnet_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
guint32 val; guint32 val;
gboolean known; gboolean known;
@ -102,7 +103,7 @@ ipxnet_from_string(fvalue_t *fv, char *s, LogFunc log)
return TRUE; return TRUE;
} }
log("\"%s\" is not a valid IPX network name or address.", s); logfunc("\"%s\" is not a valid IPX network name or address.", s);
return FALSE; return FALSE;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ftype-ipv4.c,v 1.7 2002/01/21 07:37:39 guy Exp $ * $Id: ftype-ipv4.c,v 1.8 2002/02/05 22:50:17 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com> * By Gerald Combs <gerald@ethereal.com>
@ -45,7 +45,7 @@ value_get(fvalue_t *fv)
} }
static gboolean static gboolean
val_from_string(fvalue_t *fv, char *s, LogFunc log) val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
guint32 addr; guint32 addr;
unsigned int nmask_bits; unsigned int nmask_bits;
@ -65,7 +65,8 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
/* I just checked for slash! I shouldn't get NULL here. /* I just checked for slash! I shouldn't get NULL here.
* Double check just in case. */ * Double check just in case. */
if (!addr_str) { if (!addr_str) {
log("Unexpected strtok() error parsing IP address: %s", s_copy); logfunc("Unexpected strtok() error parsing IP address: %s",
s_copy);
g_free(s_copy); g_free(s_copy);
return FALSE; return FALSE;
} }
@ -75,7 +76,8 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
} }
if (!get_host_ipaddr(addr_str, &addr)) { if (!get_host_ipaddr(addr_str, &addr)) {
log("\"%s\" is not a valid hostname or IPv4 address.", addr_str); logfunc("\"%s\" is not a valid hostname or IPv4 address.",
addr_str);
if (has_slash) { if (has_slash) {
g_free(s_copy); g_free(s_copy);
} }
@ -90,12 +92,13 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
/* I checked for slash! I shouldn't get NULL here. /* I checked for slash! I shouldn't get NULL here.
* Double check just in case. */ * Double check just in case. */
if (!net_str) { if (!net_str) {
log("Unexpected strtok() error parsing netmask: %s", s_copy); logfunc("Unexpected strtok() error parsing netmask: %s",
s_copy);
g_free(s_copy); g_free(s_copy);
return FALSE; return FALSE;
} }
nmask_fvalue = fvalue_from_string(FT_UINT32, net_str, log); nmask_fvalue = fvalue_from_string(FT_UINT32, net_str, logfunc);
g_free(s_copy); g_free(s_copy);
if (!nmask_fvalue) { if (!nmask_fvalue) {
return FALSE; return FALSE;
@ -104,7 +107,7 @@ val_from_string(fvalue_t *fv, char *s, LogFunc log)
fvalue_free(nmask_fvalue); fvalue_free(nmask_fvalue);
if (nmask_bits > 32) { if (nmask_bits > 32) {
log("Netmask bits in a CIDR IPv4 address should be <= 32, not %u", logfunc("Netmask bits in a CIDR IPv4 address should be <= 32, not %u",
nmask_bits); nmask_bits);
return FALSE; return FALSE;
} }

View File

@ -1,10 +1,9 @@
/* /*
* $Id: ftype-string.c,v 1.4 2001/07/15 20:31:02 guy Exp $ * $Id: ftype-string.c,v 1.5 2002/02/05 22:50:17 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org> * By Gerald Combs <gerald@ethereal.com>
* Copyright 2001 Gerald Combs * Copyright 2001 Gerald Combs
*
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -61,7 +60,7 @@ value_get(fvalue_t *fv)
} }
static gboolean static gboolean
val_from_string(fvalue_t *fv, char *s, LogFunc log) val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
fv->value.string = g_strdup(s); fv->value.string = g_strdup(s);
return TRUE; return TRUE;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: ftype-time.c,v 1.15 2002/01/30 10:19:44 guy Exp $ * $Id: ftype-time.c,v 1.16 2002/02/05 22:50:17 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com> * By Gerald Combs <gerald@ethereal.com>
@ -167,7 +167,7 @@ get_nsecs(char *startp, int *nsecs)
} }
static gboolean static gboolean
relative_val_from_string(fvalue_t *fv, char *s, LogFunc log) relative_val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
char *curptr, *endptr; char *curptr, *endptr;
@ -218,14 +218,14 @@ relative_val_from_string(fvalue_t *fv, char *s, LogFunc log)
return TRUE; return TRUE;
fail: fail:
if (log != NULL) if (logfunc != NULL)
log("\"%s\" is not a valid time.", s); logfunc("\"%s\" is not a valid time.", s);
return FALSE; return FALSE;
} }
static gboolean static gboolean
absolute_val_from_string(fvalue_t *fv, char *s, LogFunc log) absolute_val_from_string(fvalue_t *fv, char *s, LogFunc logfunc)
{ {
struct tm tm; struct tm tm;
char *curptr; char *curptr;
@ -271,8 +271,8 @@ absolute_val_from_string(fvalue_t *fv, char *s, LogFunc log)
return TRUE; return TRUE;
fail: fail:
if (log != NULL) if (logfunc != NULL)
log("\"%s\" is not a valid absolute time. Example: \"Nov 12, 1999 08:55:44.123\"", logfunc("\"%s\" is not a valid absolute time. Example: \"Nov 12, 1999 08:55:44.123\"",
s); s);
return FALSE; return FALSE;
} }

View File

@ -1,10 +1,9 @@
/* /*
* $Id: ftypes.c,v 1.5 2001/10/26 17:29:12 gram Exp $ * $Id: ftypes.c,v 1.6 2002/02/05 22:50:17 guy Exp $
* *
* Ethereal - Network traffic analyzer * Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org> * By Gerald Combs <gerald@ethereal.com>
* Copyright 2001 Gerald Combs * Copyright 2001 Gerald Combs
*
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -238,18 +237,18 @@ fvalue_free(fvalue_t *fv)
fvalue_t* fvalue_t*
fvalue_from_string(ftenum_t ftype, char *s, LogFunc log) fvalue_from_string(ftenum_t ftype, char *s, LogFunc logfunc)
{ {
fvalue_t *fv; fvalue_t *fv;
fv = fvalue_new(ftype); fv = fvalue_new(ftype);
if (fv->ftype->val_from_string) { if (fv->ftype->val_from_string) {
if (fv->ftype->val_from_string(fv, s, log)) { if (fv->ftype->val_from_string(fv, s, logfunc)) {
return fv; return fv;
} }
} }
else { else {
log("\"%s\" cannot be converted to %s.", logfunc("\"%s\" cannot be converted to %s.",
s, ftype_pretty_name(ftype)); s, ftype_pretty_name(ftype));
} }
fvalue_free(fv); fvalue_free(fv);