1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| size_t msg_len = 0;
char *msg = null;
//do
//{
//**** Determine the size of buffer and allocate it ****
//msg_len = 0;
//msg_len += 1;
//msg_len += strlen(query);
msg_len = strlen(query) + 1;
if (count > 0 && paramtypes)
{
msg_len += sizeof(int16) + count * sizeof(int32);
}
else
{
msg_len += sizeof(int16);
}
// @FIXME: N'a-t-on pas déjà réservé une place pour le caractère terminal
msg_len++;
msg = (char *) malloc(msg_len);
if (msg != null) {
// Fill the buffer
msg_len = 0;
memcpy(msg + msg_len, "", 1); // An empty string selects the non-prepared statement named.
msg_len += 1;
memcpy(msg + msg_len, query, strlen(query));// Query string to analyse.
if (count > 0 && paramtypes)
{
sql_put_int(sizeof(int16), count, msg + msg_len); // Number format codes following parameters.
msg_len += sizeof(int16);
for (i=0; i<count; i++)
{
sql_put_int(sizeof(int32), paramtypes[i], msg + msg_len);// Object ID of the data type of the parameter.
msg_len += sizeof(int32);
}
}
else
{
sql_put_int(sizeof(int16), 0, msg + msg_len); // Many types of data specified parameter.
msg_len += sizeof(int16);
}
msg[msg_len] = '\0';
msg_len++;
}
// }
// while (msg); |
Partager