Lines 1-4
Link Here
|
1 |
--- mysqltcl.c.orig Mon Jul 6 11:35:17 1998 |
1 |
--- mysqltcl.c Mon Jul 6 11:35:17 1998 |
2 |
+++ mysqltcl.c Wed Sep 1 01:27:44 1999 |
2 |
+++ mysqltcl.c Wed Jul 12 17:46:20 2000 |
3 |
@@ -743,5 +743,5 @@ |
3 |
@@ -34,7 +34,7 @@ |
|
|
4 |
#include <string.h> |
5 |
#include <ctype.h> |
6 |
#include <unistd.h> |
7 |
- |
8 |
+#include <stdlib.h> |
9 |
|
10 |
#define MYSQL_HANDLES 15 /* Default number of handles available. */ |
11 |
#define MYSQL_BUFF_SIZE 1024 /* Conversion buffer size for various needs. */ |
12 |
@@ -60,7 +60,7 @@ |
13 |
#define MYSQL_HPREFIX_LEN 5 |
14 |
|
15 |
/* Array for status info, and its elements. */ |
16 |
-static char *MysqlStatusArr = "mysqlstatus"; |
17 |
+#define MysqlStatusArr "mysqlstatus" |
18 |
#define MYSQL_STATUS_CODE "code" |
19 |
#define MYSQL_STATUS_CMD "command" |
20 |
#define MYSQL_STATUS_MSG "message" |
21 |
@@ -686,7 +686,6 @@ |
22 |
Mysqltcl_Init (interp) |
23 |
Tcl_Interp *interp; |
24 |
{ |
25 |
- int i; |
26 |
char nbuf[MYSQL_SMALL_SIZE]; |
27 |
|
28 |
/* |
29 |
@@ -742,7 +739,7 @@ |
30 |
* If this message appears you must change the source code and recompile. |
4 |
*/ |
31 |
*/ |
Line 9
Link Here
|
9 |
{ |
36 |
{ |
|
|
37 |
fprintf (stderr, "*** mysqltcl (mysqltcl.c): handle prefix inconsistency!\n") ; |
38 |
@@ -921,13 +917,13 @@ |
39 |
|
40 |
if ((MysqlHandle[hand].result = mysql_store_result (MysqlHandle[hand].mysql)) == NULL) |
41 |
{ |
42 |
- (void)strcpy (interp->result, "-1") ; |
43 |
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(-1)); |
44 |
} |
45 |
else |
46 |
{ |
47 |
MysqlHandle[hand].res_count = mysql_num_rows (MysqlHandle[hand].result) ; |
48 |
MysqlHandle[hand].col_count = mysql_num_fields (MysqlHandle[hand].result) ; |
49 |
- (void)sprintf (interp->result, "%d", MysqlHandle[hand].res_count) ; |
50 |
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(MysqlHandle[hand].res_count)); |
51 |
} |
52 |
|
53 |
return TCL_OK; |
54 |
@@ -1073,7 +1069,7 @@ |
55 |
MysqlHandle[hand].res_count = total - row; |
56 |
} |
57 |
|
58 |
- (void)sprintf (interp->result, "%d", MysqlHandle[hand].res_count) ; |
59 |
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(MysqlHandle[hand].res_count)); |
60 |
return TCL_OK; |
61 |
} |
62 |
|
63 |
@@ -1244,7 +1240,7 @@ |
64 |
{ |
65 |
case MYSQL_INFNAME_OPT: |
66 |
case MYSQL_INFNAMEQ_OPT: |
67 |
- strcpy (interp->result, MysqlHandle[hand].database) ; |
68 |
+ Tcl_SetResult(interp, MysqlHandle[hand].database, TCL_STATIC); |
69 |
break ; |
70 |
case MYSQL_INFTABLES_OPT: |
71 |
if ((list = mysql_list_tables (MysqlHandle[hand].mysql,(char*)NULL)) == NULL) |
72 |
@@ -1259,7 +1255,7 @@ |
73 |
break ; |
74 |
case MYSQL_INFHOST_OPT: |
75 |
case MYSQL_INFHOSTQ_OPT: |
76 |
- strcpy (interp->result, MysqlHandle[hand].host) ; |
77 |
+ Tcl_SetResult(interp, MysqlHandle[hand].host, TCL_STATIC); |
78 |
break ; |
79 |
case MYSQL_INFLIST_OPT: |
80 |
if ((list = mysql_list_dbs (MysqlHandle[hand].mysql,(char*)NULL)) == NULL) |
81 |
@@ -1299,8 +1295,6 @@ |
82 |
int count ; |
83 |
int hand ; |
84 |
int idx ; |
85 |
- MYSQL_RES* list ; |
86 |
- MYSQL_ROW row ; |
87 |
|
88 |
|
89 |
/* We can't fully check the handle at this stage. */ |
90 |
@@ -1342,19 +1336,20 @@ |
91 |
{ |
92 |
case MYSQL_RESROWS_OPT: |
93 |
case MYSQL_RESROWSQ_OPT: |
94 |
- sprintf (interp->result, "%d", MysqlHandle[hand].res_count) ; |
95 |
+ count = MysqlHandle[hand].res_count; |
96 |
break ; |
97 |
case MYSQL_RESCOLS_OPT: |
98 |
case MYSQL_RESCOLSQ_OPT: |
99 |
- sprintf (interp->result, "%d", MysqlHandle[hand].col_count) ; |
100 |
+ count = MysqlHandle[hand].col_count; |
101 |
break ; |
102 |
case MYSQL_RESCUR_OPT: |
103 |
case MYSQL_RESCURQ_OPT: |
104 |
- sprintf (interp->result, "%d", mysql_num_rows (MysqlHandle[hand].result) |
105 |
- - MysqlHandle[hand].res_count) ; |
106 |
+ count = mysql_num_rows (MysqlHandle[hand].result) |
107 |
+ - MysqlHandle[hand].res_count; |
108 |
default: |
109 |
- ; |
110 |
+ return TCL_OK; /* none of the above -- return without touching result */ |
111 |
} |
112 |
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(count)); |
113 |
return TCL_OK ; |
114 |
} |
115 |
|
116 |
@@ -1500,8 +1495,12 @@ |
117 |
int hi; |
118 |
char* hp ; |
119 |
int numeric ; |
120 |
- char* res ; |
121 |
- |
122 |
+ register short res; |
123 |
+ |
124 |
+ static const char *states[] = { |
125 |
+ "NOT_A_HANDLE", "UNCONNECTED", "CONNECTED", "IN_USE", "RESULT_PENDING" |
126 |
+ }; |
127 |
+ |
128 |
if (mysql_prologue(interp, argc, argv, 2, NULL, "?-numeric? handle") < 0) |
129 |
return TCL_ERROR; |
130 |
|
131 |
@@ -1511,17 +1510,18 @@ |
132 |
hp = (numeric)?argv[2]:argv[1] ; |
133 |
|
134 |
if (HSYNTAX(hp,hi) < 0) |
135 |
- res = (numeric)?"0":"NOT_A_HANDLE" ; |
136 |
+ res = 0; |
137 |
else if (MysqlHandle[hi].connection == 0) |
138 |
- res = (numeric)?"1":"UNCONNECTED" ; |
139 |
+ res = 1; |
140 |
else if (MysqlHandle[hi].database[0] == '\0') |
141 |
- res = (numeric)?"2":"CONNECTED" ; |
142 |
+ res = 2; |
143 |
else if (MysqlHandle[hi].result == NULL) |
144 |
- res = (numeric)?"3":"IN_USE" ; |
145 |
+ res = 3; |
146 |
else |
147 |
- res = (numeric)?"4":"RESULT_PENDING" ; |
148 |
+ res = 4; |
149 |
|
150 |
- (void)strcpy (interp->result, res) ; |
151 |
+ if (numeric) Tcl_SetObjResult(interp, Tcl_NewIntObj(res)); |
152 |
+ else Tcl_SetResult(interp, (char *)states[res], TCL_STATIC); |
153 |
return TCL_OK ; |
154 |
} |
155 |
|
156 |
@@ -1543,7 +1543,6 @@ |
157 |
char **argv; |
158 |
{ |
159 |
int hand; |
160 |
- char* res ; |
161 |
MYSQL* mysql; |
162 |
|
163 |
if ((hand = mysql_prologue(interp, argc, argv, 2, get_handle_conn, |
164 |
@@ -1552,7 +1551,7 @@ |
165 |
|
166 |
mysql = MysqlHandle[hand].mysql; |
167 |
|
168 |
- (void)sprintf (interp->result, "%d", mysql_insert_id(mysql)) ; |
169 |
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(mysql_insert_id(mysql))); |
170 |
|
171 |
return TCL_OK; |
172 |
} |