aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/odbc/misc.h
blob: 161920f9b2b017d3a8caa89d263c5c765ec8fedc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* File:			misc.h
 *
 * Description:		See "misc.c"
 *
 * Comments:		See "notice.txt" for copyright and license information.
 *
 */

#ifndef __MISC_H__
#define __MISC_H__

#include "psqlodbc.h"

#include <stdio.h>

/*	Uncomment MY_LOG define to compile in the mylog() statements.
	Then, debug logging will occur if 'Debug' is set to 1 in the ODBCINST.INI
	portion of the registry.  You may have to manually add this key.
	This logfile is intended for development use, not for an end user!
*/
#define MY_LOG


/*	Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog).
	This logfile contains serious log statements that are intended for an
	end user to be able to read and understand.  It is controlled by the
	'CommLog' flag in the ODBCINST.INI portion of the registry (see above),
	which is manipulated on the setup/connection dialog boxes.
*/
#define Q_LOG


#ifdef MY_LOG
#define MYLOGFILE			"mylog_"
#ifndef WIN32
#define MYLOGDIR			"/tmp"
#else
#define MYLOGDIR			"c:"
#endif /* WIN32 */
extern void mylog(char *fmt,...);

#else
#ifndef WIN32
#define mylog(args...)			/* GNU convention for variable arguments */
#else
extern void MyLog(char *fmt,...);
#define mylog	if (0) MyLog		/* mylog */
#endif /* WIN32 */
#endif /* MY_LOG */
#define	inolog	mylog	/* for really temporary debug */

#ifdef Q_LOG
#define QLOGFILE			"psqlodbc_"
#ifndef WIN32
#define QLOGDIR				"/tmp"
#else
#define QLOGDIR				"c:"
#endif
extern void qlog(char *fmt,...);

#else
#ifndef WIN32
#define qlog(args...)			/* GNU convention for variable arguments */
#else
#define qlog					/* qlog */
#endif
#endif
#define	inoqlog	qlog

#ifndef WIN32
#define DIRSEPARATOR		"/"
#else
#define DIRSEPARATOR		"\\"
#endif

#ifdef WIN32
#define PG_BINARY			O_BINARY
#define PG_BINARY_R			"rb"
#define PG_BINARY_W			"wb"
#define PG_BINARY_A			"ab"
#else
#define PG_BINARY			0
#define PG_BINARY_R			"r"
#define PG_BINARY_W			"w"
#define PG_BINARY_A			"a"
#endif


void		remove_newlines(char *string);
char	   *strncpy_null(char *dst, const char *src, int len);
char	   *trim(char *string);
char	   *make_string(const char *s, int len, char *buf);
char	   *my_strcat(char *buf, const char *fmt, const char *s, int len);
char	   *schema_strcat(char *buf, const char *fmt, const char *s, int len,
			const char *, int);
/* #define	GET_SCHEMA_NAME(nspname) 	(stricmp(nspname, "public") ? nspname : "") */
#define	GET_SCHEMA_NAME(nspname) 	(nspname)

/* defines for return value of my_strcpy */
#define STRCPY_SUCCESS		1
#define STRCPY_FAIL			0
#define STRCPY_TRUNCATED	(-1)
#define STRCPY_NULL			(-2)

int			my_strcpy(char *dst, int dst_len, const char *src, int src_len);

#endif