common_logging.c   common_logging.c 
skipping to change at line 428 skipping to change at line 428
short state; short state;
int level; int level;
int from_line, to_line; int from_line, to_line;
int counter = 0; int counter = 0;
int keep_looking = 1; int keep_looking = 1;
tmp = getenv (constname); tmp = getenv (constname);
if (tmp == NULL) if (tmp == NULL)
return 0; return 0;
def = GNUNET_strdup (tmp); def = GNUNET_strdup (tmp);
level = -1;
from_line = 0; from_line = 0;
to_line = INT_MAX; to_line = INT_MAX;
for (p = def, state = 0, start = def; keep_looking; p++) for (p = def, state = 0, start = def; keep_looking; p++)
{ {
switch (p[0]) switch (p[0])
{ {
case ';': /* found a field separator */ case ';': /* found a field separator */
p[0] = '\0'; p[0] = '\0';
switch (state) switch (state)
{ {
skipping to change at line 456 skipping to change at line 455
/* after a file name there must be a function name */ /* after a file name there must be a function name */
function = start; function = start;
break; break;
case 3: /* within a from-to line range */ case 3: /* within a from-to line range */
if (strlen (start) > 0) if (strlen (start) > 0)
{ {
errno = 0; errno = 0;
from_line = strtol (start, &t, 10); from_line = strtol (start, &t, 10);
if (errno != 0 || from_line < 0) if (errno != 0 || from_line < 0)
{ {
free (def); GNUNET_free (def);
return counter; return counter;
} }
if (t < p && t[0] == '-') if (t < p && t[0] == '-')
{ {
errno = 0; errno = 0;
start = t + 1; start = t + 1;
to_line = strtol (start, &t, 10); to_line = strtol (start, &t, 10);
if (errno != 0 || to_line < 0 || t != p) if (errno != 0 || to_line < 0 || t != p)
{ {
free (def); GNUNET_free (def);
return counter; return counter;
} }
} }
else /* one number means "match this line only" */ else /* one number means "match this line only" */
to_line = from_line; to_line = from_line;
} }
else /* default to 0-max */ else /* default to 0-max */
{ {
from_line = 0; from_line = 0;
to_line = INT_MAX; to_line = INT_MAX;
skipping to change at line 498 skipping to change at line 497
{ {
case 4: /* within a log level */ case 4: /* within a log level */
p[0] = '\0'; p[0] = '\0';
state = 0; state = 0;
level = get_type ((const char *) start); level = get_type ((const char *) start);
if (level == GNUNET_ERROR_TYPE_INVALID || if (level == GNUNET_ERROR_TYPE_INVALID ||
level == GNUNET_ERROR_TYPE_UNSPECIFIED || level == GNUNET_ERROR_TYPE_UNSPECIFIED ||
0 != add_definition (comp, file, function, from_line, to_line, 0 != add_definition (comp, file, function, from_line, to_line,
level, force)) level, force))
{ {
free (def); GNUNET_free (def);
return counter; return counter;
} }
counter += 1; counter += 1;
start = p + 1; start = p + 1;
break; break;
default: default:
break; break;
} }
default: default:
break; break;
} }
} }
free (def); GNUNET_free (def);
return counter; return counter;
} }
/** /**
* Utility function - parses GNUNET_LOG and GNUNET_FORCE_LOG. * Utility function - parses GNUNET_LOG and GNUNET_FORCE_LOG.
*/ */
static void static void
parse_all_definitions () parse_all_definitions ()
{ {
if (gnunet_log_parsed == GNUNET_NO) if (gnunet_log_parsed == GNUNET_NO)
skipping to change at line 603 skipping to change at line 602
altlog_fd = -1; altlog_fd = -1;
} }
} }
else else
{ {
altlog_fd = -1; altlog_fd = -1;
} }
} }
if (altlog_fd == -1) if (altlog_fd == -1)
{ {
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "fopen", fn); GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", fn);
if (dirwarn) if (dirwarn)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Failed to create or access directory for log file `%s' \n"), _("Failed to create or access directory for log file `%s' \n"),
fn); fn);
GNUNET_free (fn); GNUNET_free (fn);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
GNUNET_free (fn); GNUNET_free (fn);
GNUNET_stderr = altlog; GNUNET_stderr = altlog;
return GNUNET_OK; return GNUNET_OK;
skipping to change at line 678 skipping to change at line 677
* @param msg the actual message * @param msg the actual message
*/ */
static void static void
output_message (enum GNUNET_ErrorType kind, const char *comp, output_message (enum GNUNET_ErrorType kind, const char *comp,
const char *datestr, const char *msg) const char *datestr, const char *msg)
{ {
struct CustomLogger *pos; struct CustomLogger *pos;
if (GNUNET_stderr != NULL) if (GNUNET_stderr != NULL)
{ {
fprintf (GNUNET_stderr, "%s %s %s %s", datestr, comp, FPRINTF (GNUNET_stderr, "%s %s %s %s", datestr, comp,
GNUNET_error_type_to_string (kind), msg); GNUNET_error_type_to_string (kind), msg);
fflush (GNUNET_stderr); fflush (GNUNET_stderr);
} }
pos = loggers; pos = loggers;
while (pos != NULL) while (pos != NULL)
{ {
pos->logger (pos->logger_cls, kind, comp, datestr, msg); pos->logger (pos->logger_cls, kind, comp, datestr, msg);
pos = pos->next; pos = pos->next;
} }
} }
skipping to change at line 941 skipping to change at line 940
GNUNET_i2s (const struct GNUNET_PeerIdentity *pid) GNUNET_i2s (const struct GNUNET_PeerIdentity *pid)
{ {
static struct GNUNET_CRYPTO_HashAsciiEncoded ret; static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
GNUNET_CRYPTO_hash_to_enc (&pid->hashPubKey, &ret); GNUNET_CRYPTO_hash_to_enc (&pid->hashPubKey, &ret);
ret.encoding[4] = '\0'; ret.encoding[4] = '\0';
return (const char *) ret.encoding; return (const char *) ret.encoding;
} }
/** /**
* Convert a peer identity to a string (for printing debug messages).
* This is one of the very few calls in the entire API that is
* NOT reentrant!
*
* @param pid the peer identity
* @return string form of the pid; will be overwritten by next
* call to GNUNET_i2s.
*/
const char *
GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid)
{
static struct GNUNET_CRYPTO_HashAsciiEncoded ret;
GNUNET_CRYPTO_hash_to_enc (&pid->hashPubKey, &ret);
return (const char *) ret.encoding;
}
/**
* Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string * Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string
* (for printing debug messages). This is one of the very few calls * (for printing debug messages). This is one of the very few calls
* in the entire API that is NOT reentrant! * in the entire API that is NOT reentrant!
* *
* @param addr the address * @param addr the address
* @param addrlen the length of the address * @param addrlen the length of the address
* @return nicely formatted string for the address * @return nicely formatted string for the address
* will be overwritten by next call to GNUNET_a2s. * will be overwritten by next call to GNUNET_a2s.
*/ */
const char * const char *
 End of changes. 8 change blocks. 
7 lines changed or deleted 24 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/