/
ma_c_stuff.h
111 lines (92 loc) · 2.89 KB
/
ma_c_stuff.h
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
108
109
110
111
/************************************************************************************
Copyright (C) 2019,2023 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*************************************************************************************/
#ifndef _ma_c_stuff_h_
#define _ma_c_stuff_h_
#include "ma_odbc_version.h"
#ifdef _WIN32
# include "ma_platform_win32.h"
#else
# include "ma_platform_posix.h"
#endif
#include <stdlib.h>
#include <ma_legacy_helpers.h>
#include <sql.h>
#include <sqlext.h>
#include <odbcinst.h>
#include <errmsg.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stddef.h>
#include <assert.h>
#include <time.h>
#include <sqlext.h>
#include <mysql.h>
#define MADB_FREE(a) do { \
free((void*)(a));\
(a)= NULL; \
} while(0)
#define MADB_ALLOC(a) malloc((a))
#define MADB_CALLOC(a) calloc((a) > 0 ? (a) : 1, sizeof(char))
#define MADB_REALLOC(a,b) realloc((a),(b))
/* If required to free old memory pointed by current ptr, and set new value */
#define MADB_RESET(ptr, newptr) do {\
const char *local_new_ptr= (newptr);\
if (local_new_ptr != ptr) {\
free((char*)(ptr));\
if (local_new_ptr != NULL)\
(ptr)= _strdup(local_new_ptr);\
else\
(ptr)= NULL;\
}\
} while(0)
#define MADB_IS_EMPTY(STR) ((STR)==NULL || *(STR)=='\0')
typedef struct st_client_charset
{
unsigned int CodePage;
MARIADB_CHARSET_INFO* cs_info;
} Client_Charset;
struct MADB_ERROR
{
char SqlState[SQL_SQLSTATE_SIZE + 1];
char SqlStateV2[SQLSTATE_LENGTH + 1];
char SqlErrorMsg[SQL_MAX_MESSAGE_LENGTH + 1];
SQLRETURN ReturnValue;
};
struct MADB_Error
{
size_t PrefixLen;
struct MADB_ERROR* ErrRecord;
SQLINTEGER NativeError;
/* Order number of last requested error record */
unsigned int ErrorNum;
char SqlErrorMsg[SQL_MAX_MESSAGE_LENGTH + 1];
char SqlState[SQLSTATE_LENGTH + 1];
SQLRETURN ReturnValue;
};
/**
* Things that are staying C at least for transition period. Mainly the stuff that has to be used
* both from C and C++ code.
*/
#ifdef __cplusplus
extern "C" {
#endif
const char* ltrim(const char *Str);
char* trim(char* Str);
#ifdef __cplusplus
} /* End of "extern C" */
#endif
#endif /* _ma_c_stuff_h_ */