1 /****************************************************************************
4 * Name: mysql-helper.cl
5 * Purpose: Helper functions for mysql.cl to handle 64-bit parts of API
6 * Programmer: Kevin M. Rosenberg
7 * Date Started: Mar 2002
9 * $Id: clsql-mysql.c,v 1.2 2002/03/27 05:37:35 kevin Exp $
11 * This file, part of CLSQL, is Copyright (c) 2002 by Kevin M. Rosenberg
13 * CLSQL users are granted the rights to distribute and use this software
14 * as governed by the terms of the Lisp Lesser GNU Public License
15 * (http://opensource.franz.com/preamble.html), also known as the LLGPL.
16 ***************************************************************************/
21 BOOL WINAPI DllEntryPoint(HINSTANCE hinstdll, DWORD fdwReason,
27 #define DLLEXPORT __declspec(dllexport)
36 /* Need to assemble a 64-bit integer to send to MySQL */
39 clsql_mysql_data_seek (MYSQL_RES* res, unsigned int offset_high32,
40 unsigned int offset_low32)
44 offset = offset_high32;
45 offset = offset << 32;
46 offset += offset_low32;
48 mysql_data_seek (res, offset);
51 /* The following functions are used to return 64-bit integers to Lisp.
52 They return the 32-bit low part and store in upper 32-bits in a
53 located sent via a pointer */
55 const unsigned int bitmask_32bits = 0xFFFFFFFF;
57 #define lower_32bits(int64) ((unsigned int) int64 & bitmask_32bits)
58 #define upper_32bits(int64) ((unsigned int) (int64 >> 32))
62 clsql_mysql_affected_rows (MYSQL* res, unsigned int* pHigh32)
64 my_ulonglong nAffected = mysql_affected_rows (res);
65 *pHigh32 = upper_32bits(nAffected);
66 return lower_32bits(nAffected);
71 clsql_mysql_insert_id (MYSQL* mysql, unsigned int* pHigh32)
73 my_ulonglong insert_id = mysql_insert_id (mysql);
74 *pHigh32 = upper_32bits(insert_id);
75 return lower_32bits(insert_id);
79 /* Reads a 64-bit integer string, returns result as two 32-bit integers */
83 atol64 (const unsigned char* str, int* pHigh32)
90 if (i < 0 || i > 9) /* Non-numeric character -- quit */
92 result = i + (10 * result);
96 *pHigh32 = upper_32bits(result);
97 return lower_32bits(result);