Changeset 1064 in MondoRescue for branches/stable/mondo/src/lib/mr_msg.c


Ignore:
Timestamp:
Jan 23, 2007, 1:09:32 AM (17 years ago)
Author:
Bruno Cornec
Message:

More controls at the compiler level
still working with the problems around variable arguments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/lib/mr_msg.c

    r1061 r1064  
    1010 */
    1111
     12#ifndef _GNU_SOURCE
     13#define _GNU_SOURCE
     14#endif
    1215#include <stdio.h>
    1316#include <stdarg.h>
     17#include <stdlib.h>
    1418
    1519static int mr_loglevel = 0;
     
    4347 * but through other functions
    4448 */
    45 void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, va_list args) {
     49void _mr_msg(int debug, const char *file, const char *function, int line, const char *fmt, ...) {
    4650
    4751    int i = 0;
    4852    int res = 0;
    4953    FILE *fout = NULL;
     54    va_list args;
    5055
    5156    if (mr_logfile == NULL) {
     
    5863            return;
    5964        }
     65        va_start(args,fmt);
    6066
    6167        // add 2 spaces to distinguish log levels
     
    6773        if (vfprintf(fout, fmt, args) < 0) {
    6874            fprintf(stderr,"Unable to print to %s\n",mr_logfile);
    69             return;
    7075        }
    7176
     
    7479            fprintf(stderr,"Unable to close %s\n",mr_logfile);
    7580        }
     81        va_end(args);
    7682    }
    7783}
    7884
    79 void mr_msg(int level, const char *fmt, va_list args) {
     85void mr_msg(int level, const char *fmt, ...) {
    8086
     87    va_list args;
     88
     89    va_start(args,fmt);
    8190    _mr_msg(level, __FILE__, __FUNCTION__, __LINE__, fmt, args);
     91    va_end(args);
    8292}
Note: See TracChangeset for help on using the changeset viewer.