FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tdsconvert.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tdsconvert_h_
21 #define _tdsconvert_h_
22 
23 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
24 #pragma GCC visibility push(hidden)
25 #endif
26 
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #if 0
31 }
32 #endif
33 #endif
34 
35 /* $Id: tdsconvert.h,v 1.26 2010-01-25 23:05:58 freddy77 Exp $ */
36 
37 typedef union conv_result
38 {
39  TDS_TINYINT ti;
40  TDS_SMALLINT si;
41  TDS_INT i;
42  TDS_INT8 bi;
43  TDS_FLOAT f;
44  TDS_REAL r;
45  TDS_CHAR *c;
46  TDS_MONEY m;
47  TDS_MONEY4 m4;
48  TDS_DATETIME dt;
49  TDS_DATETIME4 dt4;
50  TDS_NUMERIC n;
51  TDS_CHAR *ib;
52  TDS_UNIQUE u;
53  /* sizef types */
54  struct cc_t {
55  TDS_CHAR *c;
56  TDS_UINT len;
57  } cc;
58  struct cb_t {
59  TDS_CHAR *ib;
60  TDS_UINT len;
61  } cb;
62 }
64 
65 /*
66  * Failure return codes for tds_convert()
67  */
68 #define TDS_CONVERT_FAIL -1 /* unspecified failure */
69 #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */
70 #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */
71 #define TDS_CONVERT_NOMEM -4 /* insufficient memory */
72 #define TDS_CONVERT_OVERFLOW -5 /* result too large */
73 
74 /* sized types */
75 #define TDS_CONVERT_CHAR 256
76 #define TDS_CONVERT_BINARY 257
77 
78 struct tds_time
79 {
80  int tm_year;
81  int tm_mon;
82  int tm_mday;
83  int tm_hour;
84  int tm_min;
85  int tm_sec;
86  int tm_ms;
87 };
88 
89 unsigned char tds_willconvert(int srctype, int desttype);
90 
91 TDS_INT tds_get_null_type(int srctype);
92 TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
93 TDS_INT tds_convert(const TDSCONTEXT * context, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr);
94 
95 size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr);
96 
97 #ifdef __cplusplus
98 #if 0
99 {
100 #endif
101 }
102 #endif
103 
104 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
105 #pragma GCC visibility pop
106 #endif
107 
108 #endif /* _tdsconvert_h_ */