Changeset 13 in openpam


Ignore:
Timestamp:
Feb 1, 2002, 9:35:31 PM (16 years ago)
Author:
Dag-Erling Smørgrav
Message:

Rename openpam_log() to _openpam_log(), add an argument for the
function name, and wrap it in a macro called openpam_log().

Sponsored by: DARPA, NAI Labs

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/security/openpam.h

    r9 r13  
    5151 * Log to syslog
    5252 */
    53 void openpam_log(int _level,
     53void _openpam_log(int _level,
     54        const char *_func,
    5455        const char *_fmt,
    5556        ...);
     57
     58#ifdef __GNUC__
     59#define openpam_log(lvl, fmt...) \
     60        _openpam_log((lvl), __func__, ##fmt)
     61#else
     62#define openpam_log(lvl, fmt, ...) \
     63        _openpam_log((lvl), __func__, fmt, __VA_ARGS__)
     64#endif
    5665
    5766/*
  • trunk/lib/openpam_log.c

    r10 r13  
    3737#include <stdarg.h>
    3838#include <stdio.h>
     39#include <stdlib.h>
    3940#include <syslog.h>
    4041
     
    4849
    4950void
    50 openpam_log(int level, const char *fmt, ...)
     51_openpam_log(int level, const char *func, const char *fmt, ...)
    5152{
    5253        va_list ap;
     54        char *format;
    5355        int priority;
    5456
     
    6870        }
    6971        va_start(ap, fmt);
    70         vsyslog(priority, fmt, ap);
     72        if ((format = malloc(strlen(func) + strlen(fmt) + 8)) != NULL) {
     73                sprintf(format, "in %s(): %s", func, fmt);
     74                vsyslog(priority, format, ap);
     75                free(format);
     76        } else {
     77                vsyslog(priority, fmt, ap);
     78        }
    7179        va_end(ap);
    7280}
Note: See TracChangeset for help on using the changeset viewer.