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 #ifdef __cplusplus
24 extern "C"
25 {
26 #if 0
27 }
28 #endif
29 #endif
30 
31 /* $Id: tdsconvert.h,v 1.23 2006/04/15 08:18:44 freddy77 Exp $ */
32 
33 typedef union conv_result
34 {
35  TDS_TINYINT ti;
36  TDS_SMALLINT si;
37  TDS_INT i;
38  TDS_INT8 bi;
39  TDS_FLOAT f;
40  TDS_REAL r;
41  TDS_CHAR *c;
42  TDS_MONEY m;
43  TDS_MONEY4 m4;
44  TDS_DATETIME dt;
45  TDS_DATETIME4 dt4;
46  TDS_NUMERIC n;
47  TDS_CHAR *ib;
48  TDS_UNIQUE u;
49  /* sizef types */
50  struct cc_t {
51  TDS_CHAR *c;
52  TDS_UINT len;
53  } cc;
54  struct cb_t {
55  TDS_CHAR *ib;
56  TDS_UINT len;
57  } cb;
58 }
60 
61 /*
62  * Failure return codes for tds_convert()
63  */
64 #define TDS_CONVERT_FAIL -1 /* unspecified failure */
65 #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */
66 #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */
67 #define TDS_CONVERT_NOMEM -4 /* insufficient memory */
68 #define TDS_CONVERT_OVERFLOW -5 /* result too large */
69 
70 /* sized types */
71 #define TDS_CONVERT_CHAR 256
72 #define TDS_CONVERT_BINARY 257
73 
74 struct tds_time
75 {
76  int tm_year;
77  int tm_mon;
78  int tm_mday;
79  int tm_hour;
80  int tm_min;
81  int tm_sec;
82  int tm_ms;
83 };
84 
85 unsigned char tds_willconvert(int srctype, int desttype);
86 
87 TDS_INT tds_get_null_type(int srctype);
88 TDS_INT tds_convert(const TDSCONTEXT * context, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr);
89 
90 size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr);
91 
92 #ifdef __cplusplus
93 #if 0
94 {
95 #endif
96 }
97 #endif
98 
99 #endif /* _tdsconvert_h_ */
Definition: tds.h:122
Definition: tds.h:139
Definition: tdsconvert.h:50
int tm_year
year (0=1900)
Definition: tdsconvert.h:76
int tm_min
minutes (0-59)
Definition: tdsconvert.h:80
int tm_hour
hours (0-23)
Definition: tdsconvert.h:79
int tm_mday
month day (1-31)
Definition: tdsconvert.h:78
Definition: tds.h:133
Definition: tdsconvert.h:54
Definition: tdsconvert.h:74
Definition: tds.h:1245
int tm_sec
seconds (0-59)
Definition: tdsconvert.h:81
int tm_ms
milliseconds (0-999)
Definition: tdsconvert.h:82
Definition: tds.h:109
int tm_mon
month (0-11)
Definition: tdsconvert.h:77
TDS_INT tds_convert(const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1668
information on data, used by tds_datecrack
Definition: tds.h:165
size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr)
format a date string according to an "extended" strftime(3) formatting definition.
Definition: convert.c:2749
Definition: tds.h:128
Definition: tdsconvert.h:33
unsigned char tds_willconvert(int srctype, int desttype)
Test if a conversion is possible.
Definition: convert.c:2830
Definition: tds.h:156
TDS_INT tds_get_null_type(int srctype)
Get same type but nullable.
Definition: convert.c:2706