~ubuntu-branches/ubuntu/gutsy/psqlodbc/gutsy

« back to all changes in this revision

Viewing changes to misc.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-05-13 10:47:36 UTC
  • Revision ID: james.westby@ubuntu.com-20040513104736-a530gmn0p3knep89
Tags: upstream-07.03.0200
ImportĀ upstreamĀ versionĀ 07.03.0200

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* File:                        misc.h
 
2
 *
 
3
 * Description:         See "misc.c"
 
4
 *
 
5
 * Comments:            See "notice.txt" for copyright and license information.
 
6
 *
 
7
 */
 
8
 
 
9
#ifndef __MISC_H__
 
10
#define __MISC_H__
 
11
 
 
12
#include "psqlodbc.h"
 
13
 
 
14
#include <stdio.h>
 
15
 
 
16
/*      Uncomment MY_LOG define to compile in the mylog() statements.
 
17
        Then, debug logging will occur if 'Debug' is set to 1 in the ODBCINST.INI
 
18
        portion of the registry.  You may have to manually add this key.
 
19
        This logfile is intended for development use, not for an end user!
 
20
*/
 
21
#define MY_LOG
 
22
 
 
23
 
 
24
/*      Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog).
 
25
        This logfile contains serious log statements that are intended for an
 
26
        end user to be able to read and understand.  It is controlled by the
 
27
        'CommLog' flag in the ODBCINST.INI portion of the registry (see above),
 
28
        which is manipulated on the setup/connection dialog boxes.
 
29
*/
 
30
#define Q_LOG
 
31
 
 
32
#if defined(WIN_MULTITHREAD_SUPPORT)
 
33
#define INIT_QLOG_CS    InitializeCriticalSection(&qlog_cs)
 
34
#define ENTER_QLOG_CS   EnterCriticalSection(&qlog_cs)
 
35
#define LEAVE_QLOG_CS   LeaveCriticalSection(&qlog_cs)
 
36
#define DELETE_QLOG_CS  DeleteCriticalSection(&qlog_cs)
 
37
#define INIT_MYLOG_CS   InitializeCriticalSection(&mylog_cs)
 
38
#define ENTER_MYLOG_CS  EnterCriticalSection(&mylog_cs)
 
39
#define LEAVE_MYLOG_CS  LeaveCriticalSection(&mylog_cs)
 
40
#define DELETE_MYLOG_CS DeleteCriticalSection(&mylog_cs)
 
41
#elif defined(POSIX_MULTITHREAD_SUPPORT)
 
42
#define INIT_QLOG_CS    pthread_mutex_init(&qlog_cs,0)
 
43
#define ENTER_QLOG_CS   pthread_mutex_lock(&qlog_cs)
 
44
#define LEAVE_QLOG_CS   pthread_mutex_unlock(&qlog_cs)
 
45
#define DELETE_QLOG_CS  pthread_mutex_destroy(&qlog_cs)
 
46
#define INIT_MYLOG_CS   pthread_mutex_init(&mylog_cs,0)
 
47
#define ENTER_MYLOG_CS  pthread_mutex_lock(&mylog_cs)
 
48
#define LEAVE_MYLOG_CS  pthread_mutex_unlock(&mylog_cs)
 
49
#define DELETE_MYLOG_CS pthread_mutex_destroy(&mylog_cs)
 
50
#else
 
51
#define INIT_QLOG_CS
 
52
#define ENTER_QLOG_CS
 
53
#define LEAVE_QLOG_CS
 
54
#define DELETE_QLOG_CS
 
55
#define INIT_MYLOG_CS
 
56
#define ENTER_MYLOG_CS
 
57
#define LEAVE_MYLOG_CS
 
58
#define DELETE_MYLOG_CS
 
59
#endif /* WIN_MULTITHREAD_SUPPORT */
 
60
 
 
61
#ifdef MY_LOG
 
62
#define MYLOGFILE                       "mylog_"
 
63
#ifndef WIN32
 
64
#define MYLOGDIR                        "/tmp"
 
65
#else
 
66
#define MYLOGDIR                        "c:"
 
67
#endif /* WIN32 */
 
68
extern void mylog(char *fmt,...);
 
69
 
 
70
#else /* MY_LOG */
 
71
#ifndef WIN32
 
72
#define mylog(args...)                  /* GNU convention for variable arguments */
 
73
#else
 
74
extern void MyLog(char *fmt,...);
 
75
#define mylog   if (0) MyLog            /* mylog */
 
76
#endif /* WIN32 */
 
77
#endif /* MY_LOG */
 
78
#define inolog  mylog   /* for really temporary debug */
 
79
 
 
80
#ifdef Q_LOG
 
81
#define QLOGFILE                        "psqlodbc_"
 
82
#ifndef WIN32
 
83
#define QLOGDIR                         "/tmp"
 
84
#else
 
85
#define QLOGDIR                         "c:"
 
86
#endif
 
87
extern void qlog(char *fmt,...);
 
88
 
 
89
#else
 
90
#ifndef WIN32
 
91
#define qlog(args...)                   /* GNU convention for variable arguments */
 
92
#else
 
93
#define qlog                                    /* qlog */
 
94
#endif
 
95
#endif
 
96
#define inoqlog qlog
 
97
int     get_qlog(void);
 
98
int     get_mylog(void);
 
99
 
 
100
#ifndef WIN32
 
101
#define DIRSEPARATOR            "/"
 
102
#else
 
103
#define DIRSEPARATOR            "\\"
 
104
#endif
 
105
 
 
106
#ifdef WIN32
 
107
#define PG_BINARY                       O_BINARY
 
108
#define PG_BINARY_R                     "rb"
 
109
#define PG_BINARY_W                     "wb"
 
110
#define PG_BINARY_A                     "ab"
 
111
#else
 
112
#define PG_BINARY                       0
 
113
#define PG_BINARY_R                     "r"
 
114
#define PG_BINARY_W                     "w"
 
115
#define PG_BINARY_A                     "a"
 
116
#endif
 
117
 
 
118
 
 
119
void            remove_newlines(char *string);
 
120
char       *strncpy_null(char *dst, const char *src, int len);
 
121
char       *trim(char *string);
 
122
char       *make_string(const char *s, int len, char *buf);
 
123
char       *make_lstring_ifneeded(ConnectionClass *, const char *s, int len, BOOL);
 
124
char       *my_strcat(char *buf, const char *fmt, const char *s, int len);
 
125
char       *schema_strcat(char *buf, const char *fmt, const char *s, int len,
 
126
                const char *, int, ConnectionClass *conn);
 
127
char       *my_strcat1(char *buf, const char *fmt, const char *s1, const char *s, int len);
 
128
char       *schema_strcat1(char *buf, const char *fmt, const char *s1,
 
129
                                const char *s, int len,
 
130
                                const char *, int, ConnectionClass *conn);
 
131
/* #define      GET_SCHEMA_NAME(nspname)        (stricmp(nspname, "public") ? nspname : "") */
 
132
#define GET_SCHEMA_NAME(nspname)        (nspname)
 
133
 
 
134
/* defines for return value of my_strcpy */
 
135
#define STRCPY_SUCCESS          1
 
136
#define STRCPY_FAIL                     0
 
137
#define STRCPY_TRUNCATED        (-1)
 
138
#define STRCPY_NULL                     (-2)
 
139
 
 
140
int                     my_strcpy(char *dst, int dst_len, const char *src, int src_len);
 
141
 
 
142
/* Define a type for defining a constant string expression */
 
143
#define CSTR static const char * const
 
144
 
 
145
#endif