Skip to content
This repository was archived by the owner on Jul 14, 2019. It is now read-only.

Commit f7615d2

Browse files
Richard HavenLior Amram
authored andcommitted
mysql_helper_hstmt
1 parent 5abd5c7 commit f7615d2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

include/mysql_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ int mysql_helper_real_connect(struct mysql_helper *mysql_helper, struct mysql_lo
108108
int mysql_helper_connect(struct mysql_helper *mysql_helper, struct mysql_login_info *login_info);
109109
int mysql_helper_stmt(struct mysql_helper *mysql_helper, const char *query, size_t query_len, const char *params, const char *fields, ...);
110110
int mysql_helper_vstmt(struct mysql_helper *mysql_helper, const char *query, size_t query_len, const char *params, const char *fields, void ** input);
111+
int mysql_helper_hstmt(struct mysql_helper *helper, const char *query, size_t query_len, const char *input_param_types, void **input_params, const char *output_field_types, ...);
111112
int mysql_helper_stmt_col_map(struct mysql_helper *mysql_helper,
112113
const char *query, size_t query_len,
113114
void *params, struct mysql_helper_column_map *params_map, size_t nparams, /* primary params */

src/mysql_helper.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,26 @@ int mysql_helper_vstmt(struct mysql_helper *mysql_helper,
524524
return 0;
525525
}
526526

527+
int mysql_helper_hstmt(struct mysql_helper *helper, const char *query, size_t query_len, const char *input_param_types, void **input_params, const char *output_field_types, ...)
528+
{
529+
int pointer_buffer_count = strlen(input_param_types) + strlen(output_field_types);
530+
void *pointer_buffer[pointer_buffer_count];
531+
int param_count = strlen(input_param_types);
532+
533+
memcpy(pointer_buffer, input_params, param_count * sizeof(void *));
534+
535+
void **append_pointer = pointer_buffer + param_count;
536+
537+
va_list ap;
538+
va_start(ap, output_field_types);
539+
int field_count = strlen(output_field_types);
540+
for(; field_count > 0; field_count--, ++append_pointer)
541+
*append_pointer = va_arg(ap, void *);
542+
va_end(ap);
543+
544+
return mysql_helper_vstmt(helper, query, query_len, input_param_types, output_field_types, pointer_buffer);
545+
}
546+
527547
static int _mysql_helper_init_bind_map(void *data, size_t n, struct mysql_helper_column_map *map, MYSQL_BIND *pbind, unsigned long *plengths, my_bool *pnulls, struct vmbuf *tb) {
528548
if (n == 0) return 0;
529549
memset(pbind, 0, sizeof(MYSQL_BIND) * n);

0 commit comments

Comments
 (0)