Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int _mysql_schema_stmt_bind_params(MYSQL_STMT *stmt, MYSQL_BIND *params, int n,
- const char *typestr, va_list args)
- {
- int i;
- memset(params, 0, sizeof(MYSQL_BIND) * n);
- for (i = 0; i < n && *typestr; ++i)
- {
- switch (*typestr++)
- {
- case 'C':
- params[i].is_unsigned = 1;
- case 'c':
- params[i].buffer_type = MYSQL_TYPE_TINY;
- params[i].buffer = va_arg(args, uint8_t*);
- params[i].buffer_length = sizeof(uint8_t);
- break;
- case 'S':
- params[i].is_unsigned = 1;
- case 's':
- params[i].buffer_type = MYSQL_TYPE_SHORT;
- params[i].buffer = va_arg(args, uint8_t*);
- params[i].buffer_length = sizeof(uint8_t);
- break;
- case 'L':
- params[i].is_unsigned = 1;
- case 'l':
- params[i].buffer_type = MYSQL_TYPE_LONG;
- params[i].buffer = va_arg(args, uint32_t*);
- params[i].buffer_length = sizeof(uint32_t);
- break;
- case 'Q':
- params[i].is_unsigned = 1;
- case 'q':
- params[i].buffer_type = MYSQL_TYPE_LONGLONG;
- params[i].buffer = va_arg(args, uint64_t*);
- params[i].buffer_length = sizeof(uint64_t);
- break;
- case 'f':
- params[i].buffer_type = MYSQL_TYPE_FLOAT;
- params[i].buffer = va_arg(args, float*);
- params[i].buffer_length = sizeof(float);
- break;
- case 'd':
- params[i].buffer_type = MYSQL_TYPE_DOUBLE;
- params[i].buffer = va_arg(args, double*);
- params[i].buffer_length = sizeof(double);
- break;
- case 'A':
- params[i].buffer_type = MYSQL_TYPE_STRING;
- params[i].buffer_length = va_arg(args, size_t);
- params[i].buffer = va_arg(args, char*);
- break;
- case 'a':
- params[i].buffer_type = MYSQL_TYPE_STRING;
- params[i].buffer = va_arg(args, char*);
- params[i].buffer_length = strlen(params[i].buffer);
- break;
- case 'x':
- params[i].buffer_type = MYSQL_TYPE_NULL;
- break;
- default:
- return 0;
- }
- }
- if (!mysql_stmt_bind_param(stmt, params))
- return 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement