IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 8, 2005, 4:06:17 PM (21 years ago)
Author:
jhoblitt
Message:

change nebSetErr() to handle filename, lineno, & function params
rename nebSetErr() -> p_nebSetErr()
add nebSetErr macro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/nebclient/src/nebclient.c

    r4525 r4527  
    44 * Copyright (C) 2005  Joshua Hoblitt
    55 *
    6  * $Id: nebclient.c,v 1.24 2005-07-09 00:31:49 jhoblitt Exp $
     6 * $Id: nebclient.c,v 1.25 2005-07-09 02:06:17 jhoblitt Exp $
    77 */
    88
     
    2525#define ERRBUF_SIZE 2048
    2626
    27 static void nebSetErr(nebServer *server, const char *format, ...);
     27#define nebSetErr(server,...) \
     28    p_nebSetErr(__FILE__, __LINE__, __func__, server,__VA_ARGS__)
     29
     30static void p_nebSetErr(const char * filename, unsigned long lineno, const char *function, nebServer *server, const char *format, ...);
    2831static void nebSetServerErr(nebServer *server);
    2932static off_t nebCopyFile(nebServer *server, const char *source, const char *dest);
     
    407410}
    408411
    409 static void nebSetErr(nebServer *server, const char *format, ...)
     412
     413static void p_nebSetErr(const char * filename, unsigned long lineno, const char *function, nebServer *server, const char *format, ...)
    410414{
    411415    va_list         args;
    412416    size_t          err_size;
     417    char            err_location[ERRBUF_SIZE];
     418    size_t          err_location_size;
     419
     420    err_location_size = snprintf(err_location, ERRBUF_SIZE, "%s:%lu %s() - ",
     421            filename, lineno, function);
     422
     423    if (err_location_size < 0) {
     424        fprintf(stderr, "failed to set error info");
     425
     426        abort();
     427    }
     428
     429    // copy error location info to start of error string
     430    strncpy(server->err_buf, err_location, ERRBUF_SIZE);
    413431
    414432    while (1) {
    415433        va_start(args, format);
    416         err_size = vsnprintf(server->err_buf, server->err_buf_size, format, args);
     434        // append error string after error location info
     435        err_size = vsnprintf(
     436                server->err_buf + err_location_size,
     437                server->err_buf_size - err_location_size,
     438                format, args);
    417439        va_end(args);
    418440
Note: See TracChangeset for help on using the changeset viewer.