smbnetfs  0.6.3
About: SMBNetFS is a Linux/FreeBSD filesystem that allow you to use samba/microsoft network in the same manner as the network neighborhood in Microsoft Windows.
  Fossies Dox: smbnetfs-0.6.3.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

common.h
Go to the documentation of this file.
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__ */
void common_init(void)
Definition: common.c:21
#define ATTRIB(x)
Definition: common.h:15
void common_debug_print(const char *fmt,...)
Definition: common.c:63
int common_set_log_file(const char *logfile)
Definition: common.c:33
void common_print_backtrace(void)
Definition: common.c:77
static int common_get_smbnetfs_debug_level(void)
Definition: common.h:28
int common_debug_level
Definition: common.c:15
int common_set_smbnetfs_debug_level(int level)
Definition: common.c:26