FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
convert.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 #include <freetds/pushvis.h>
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32 
33 typedef union conv_result
34 {
35  /* fixed */
36  TDS_TINYINT ti;
37  TDS_SMALLINT si;
38  TDS_USMALLINT usi;
39  TDS_INT i;
40  TDS_UINT ui;
41  TDS_INT8 bi;
42  TDS_UINT8 ubi;
43  TDS_FLOAT f;
44  TDS_REAL r;
45  TDS_MONEY m;
46  TDS_MONEY4 m4;
47  TDS_DATETIME dt;
48  TDS_DATETIME4 dt4;
49  TDS_DATETIMEALL dta;
50  TDS_NUMERIC n;
51  TDS_UNIQUE u;
52 
53  /* variable */
54  TDS_CHAR *c;
55  TDS_CHAR *ib;
56 
57  /* sized buffer types */
58  struct cc_t {
59  TDS_CHAR *c;
60  TDS_UINT len;
61  } cc;
62  struct cb_t {
63  TDS_CHAR *ib;
64  TDS_UINT len;
65  } cb;
66 }
68 
69 /*
70  * Failure return codes for tds_convert()
71  */
72 #define TDS_CONVERT_FAIL -1 /* unspecified failure */
73 #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */
74 #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */
75 #define TDS_CONVERT_NOMEM -4 /* insufficient memory */
76 #define TDS_CONVERT_OVERFLOW -5 /* result too large */
77 
78 /* sized types */
79 #define TDS_CONVERT_CHAR 256
80 #define TDS_CONVERT_BINARY 257
81 
82 unsigned char tds_willconvert(int srctype, int desttype);
83 
84 TDS_INT tds_get_null_type(int srctype);
85 TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
86 TDS_INT tds_convert(const TDSCONTEXT * context, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr);
87 
88 size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec);
89 
90 #ifdef __cplusplus
91 #if 0
92 {
93 #endif
94 }
95 #endif
96 
97 #include <freetds/popvis.h>
98 
99 #endif /* _tdsconvert_h_ */
Definition: proto.h:55
Definition: convert.h:62
Definition: proto.h:25
Definition: proto.h:38
Definition: convert.h:33
Definition: proto.h:44
Definition: tds.h:1031
TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1796
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information...
Definition: tds.h:141
Definition: proto.h:49
size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *timeptr, int prec)
format a date string according to an "extended" strftime(3) formatting definition.
Definition: convert.c:2903
Definition: proto.h:61
unsigned char tds_willconvert(int srctype, int desttype)
Test if a conversion is possible.
Definition: convert.c:2987
Used by tds_datecrack.
Definition: tds.h:154
TDS_INT tds_get_null_type(int srctype)
Get same type but nullable.
Definition: convert.c:2855
Definition: convert.h:58