r1670: updated mysql to handle :longlong field translation
[clsql.git] / interfaces / mysql / clsql-mysql.c
index 7557589f3a6c3e8ba084a4db968cf350ffe288f1..4fd36dbaa989de099a0a38258c6bb5aef8ee3786 100644 (file)
@@ -6,7 +6,7 @@
  *   Programmer:    Kevin M. Rosenberg
  *   Date Started:  Mar 2002
  *
- * $Id: clsql-mysql.c,v 1.1 2002/03/23 14:04:52 kevin Exp $
+ * $Id: clsql-mysql.c,v 1.2 2002/03/27 05:37:35 kevin Exp $
  *
  * This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
  *
@@ -57,15 +57,6 @@ const unsigned int bitmask_32bits = 0xFFFFFFFF;
 #define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
 #define upper_32bits(int64) ((unsigned int) (int64 >> 32))
 
-DLLEXPORT
-unsigned int
-clsql_mysql_num_rows (MYSQL_RES* res, unsigned int* pHigh32)
-{
-  my_ulonglong nRows = mysql_num_rows (res);
-  *pHigh32 = upper_32bits(nRows);
-  return lower_32bits(nRows);
-}
-
 DLLEXPORT
 unsigned int
 clsql_mysql_affected_rows (MYSQL* res, unsigned int* pHigh32)
@@ -85,6 +76,27 @@ clsql_mysql_insert_id (MYSQL* mysql, unsigned int* pHigh32)
 }
 
 
+/* Reads a 64-bit integer string, returns result as two 32-bit integers */
+
+DLLEXPORT
+unsigned int
+atol64 (const unsigned char* str, int* pHigh32)
+{
+  long long result = 0;
+  int minus = 0;
+
+  while (*str) {
+    int i = *str - '0';
+    if (i < 0 || i > 9) /* Non-numeric character -- quit */
+      break;
+    result = i + (10 * result);
+    str++;
+  }
+
+  *pHigh32 = upper_32bits(result);
+  return lower_32bits(result);
+}
 
   
   
+