"Fossies" - the Fresh Open Source Software Archive

Member "smbnetfs-0.6.3/src/common.h" (2 Jan 2018, 1438 Bytes) of package /linux/misc/smbnetfs-0.6.3.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "common.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 0.6.0_vs_0.6.1.

    1 #ifndef __COMMON_H__
    2 #define __COMMON_H__
    3 
    4 #include "config.h"
    5 #include <sys/types.h>
    6 #include <unistd.h>
    7 #include <time.h>
    8 #include <sys/time.h>
    9 #include <glib.h>
   10 
   11 /* gcc specific extension. does nothing on other compilers */
   12 #if defined(__GNUC__)
   13   #define ATTRIB(x) __attribute__ (x)
   14 #else
   15   #define ATTRIB(x) /* no attributes */
   16 #endif
   17 
   18 extern int common_debug_level;
   19 
   20 void common_init(void);
   21 
   22 int  common_set_smbnetfs_debug_level(int level);
   23 int  common_set_log_file(const char *logfile);
   24 
   25 void common_debug_print(const char *fmt, ...) ATTRIB((format(printf, 1, 2)));
   26 void common_print_backtrace(void);
   27 
   28 static inline int common_get_smbnetfs_debug_level(void){
   29     return g_atomic_int_get(&common_debug_level);
   30 }
   31 
   32 #define DEBUG_PRINT(level, fmt, args...) \
   33     if ((level >= 0) && (level <= common_get_smbnetfs_debug_level())){ \
   34         struct timeval __now; \
   35         gettimeofday(&__now, NULL); \
   36         char __tstamp[20]; \
   37         struct tm __tm; \
   38         localtime_r(&__now.tv_sec, &__tm); \
   39         strftime(__tstamp, 20, "%Y-%m-%d %T", &__tm); \
   40         common_debug_print("%.19s.%03d " fmt, __tstamp, (int)(__now.tv_usec / 1000), ## args); \
   41     }
   42 
   43 #ifdef PRINTF_DEBUG
   44   #include <stdio.h>
   45   #define   DPRINTF(level, fmt, args...)    dprintf(fileno(stderr), "%d->%s: " fmt, getpid(), __FUNCTION__, ## args)
   46 #else
   47   #define   DPRINTF(level, fmt, args...)    DEBUG_PRINT(level, "%d->%s: " fmt, getpid(), __FUNCTION__, ## args)
   48 #endif
   49 
   50 #endif /* __COMMON_H__ */