3 * Description: See "misc.c"
5 * Comments: See "notice.txt" for copyright and license information.
12 /* Define a type for defining a constant string expression.
13 * Note: needed by psqlodbc.h
15 #define CSTR static const char * const
27 /* Uncomment MY_LOG define to compile in the mylog() statements.
28 Then, debug logging will occur if 'Debug' is set to 1 in the ODBCINST.INI
29 portion of the registry. You may have to manually add this key.
30 This logfile is intended for development use, not for an end user!
35 /* Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog).
36 This logfile contains serious log statements that are intended for an
37 end user to be able to read and understand. It is controlled by the
38 'CommLog' flag in the ODBCINST.INI portion of the registry (see above),
39 which is manipulated on the setup/connection dialog boxes.
43 #if defined(WIN_MULTITHREAD_SUPPORT)
44 #define INIT_QLOG_CS InitializeCriticalSection(&qlog_cs)
45 #define ENTER_QLOG_CS EnterCriticalSection(&qlog_cs)
46 #define LEAVE_QLOG_CS LeaveCriticalSection(&qlog_cs)
47 #define DELETE_QLOG_CS DeleteCriticalSection(&qlog_cs)
48 #define INIT_MYLOG_CS InitializeCriticalSection(&mylog_cs)
49 #define ENTER_MYLOG_CS EnterCriticalSection(&mylog_cs)
50 #define LEAVE_MYLOG_CS LeaveCriticalSection(&mylog_cs)
51 #define DELETE_MYLOG_CS DeleteCriticalSection(&mylog_cs)
52 #elif defined(POSIX_MULTITHREAD_SUPPORT)
53 #define INIT_QLOG_CS pthread_mutex_init(&qlog_cs,0)
54 #define ENTER_QLOG_CS pthread_mutex_lock(&qlog_cs)
55 #define LEAVE_QLOG_CS pthread_mutex_unlock(&qlog_cs)
56 #define DELETE_QLOG_CS pthread_mutex_destroy(&qlog_cs)
57 #define INIT_MYLOG_CS pthread_mutex_init(&mylog_cs,0)
58 #define ENTER_MYLOG_CS pthread_mutex_lock(&mylog_cs)
59 #define LEAVE_MYLOG_CS pthread_mutex_unlock(&mylog_cs)
60 #define DELETE_MYLOG_CS pthread_mutex_destroy(&mylog_cs)
65 #define DELETE_QLOG_CS
67 #define ENTER_MYLOG_CS
68 #define LEAVE_MYLOG_CS
69 #define DELETE_MYLOG_CS
70 #endif /* WIN_MULTITHREAD_SUPPORT */
73 #define MYLOGDIR "/tmp"
75 #define MYLOGDIR "c:\\temp"
79 # define mylog(fmt, args...) _mylog(__func__, __LINE__, fmt, ## args)
80 # define forcelog(fmt, args...) _forcelog(__func__, __LINE__, fmt, ## args)
81 extern int _mylog(const char *file
, int line
, const char *fmt
, ...);
82 extern int _forcelog(const char *file
, int line
, const char *fmt
, ...);
84 # define mylog(fmt, args...)
87 #define inolog if (get_mylog() > 1) mylog /* for really temporary debug */
90 # define qlog(fmt, args...) _qlog(__func__, __LINE__, fmt, ## args)
91 extern int _qlog(const char *file
, int line
, const char *fmt
, ...);
93 # define qlog(fmt, args...)
101 #define DIRSEPARATOR "/"
103 #define DIRSEPARATOR "\\"
107 #define PG_BINARY O_BINARY
108 #define PG_BINARY_R "rb"
109 #define PG_BINARY_W "wb"
110 #define PG_BINARY_A "ab"
113 #define PG_BINARY_R "r"
114 #define PG_BINARY_W "w"
115 #define PG_BINARY_A "a"
119 void InitializeLogging();
120 void FinalizeLogging();
122 void remove_newlines(char *string
);
123 char *strncpy_null(char *dst
, const char *src
, ssize_t len
);
124 char *trim(char *string
);
125 char *make_string(const unsigned char *s
, ssize_t len
, char *buf
, size_t bufsize
);
126 char *make_lstring_ifneeded(ConnectionClass
*, const void *s
, ssize_t len
, BOOL
);
127 char *my_strcat(char *buf
, const char *fmt
, const char *s
, ssize_t len
);
128 char *schema_strcat(char *buf
, const char *fmt
, const char *s
, ssize_t len
,
129 const char *, int, ConnectionClass
*conn
);
130 char *my_strcat1(char *buf
, const char *fmt
, const char *s1
,
131 const char *s
, ssize_t len
);
132 char *schema_strcat1(char *buf
, const char *fmt
, const char *s1
,
133 const char *s
, ssize_t len
,
134 const char *, int, ConnectionClass
*conn
);
135 int snprintf_add(char *buf
, size_t size
, const char *format
, ...);
136 size_t snprintf_len(char *buf
, size_t size
, const char *format
, ...);
137 /* #define GET_SCHEMA_NAME(nspname) (stricmp(nspname, "public") ? nspname : "") */
138 #define GET_SCHEMA_NAME(nspname) (nspname)
140 /* defines for return value of my_strcpy */
141 #define STRCPY_SUCCESS 1
142 #define STRCPY_FAIL 0
143 #define STRCPY_TRUNCATED (-1)
144 #define STRCPY_NULL (-2)
146 ssize_t
my_strcpy(char *dst
, ssize_t dst_len
, const char *src
, ssize_t src_len
);
151 #endif /* __MISC_H__ */