mi->stmt_ins = mi->stmt_val;
- for (i = 0; i < upi->input.num; i++) {
- res = upi->input[i].u.source;
+ for (i = 0; i < upi->input.num_keys; i++) {
+ res = upi->input.keys[i].u.source;
if (!res)
ulogd_log(ULOGD_NOTICE, "no result for %s ?!?\n",
- upi->input[i].name);
+ upi->input.keys[i].name);
- if (!res || !IS_VALID(res)) {
+ if (!res || !IS_VALID(*res)) {
/* no result, we have to fake something */
sprintf(mi->stmt_ins, "NULL,");
mi->stmt_ins = mi->stmt + strlen(mi->stmt);
addr.s_addr = ntohl(res->u.value.ui32);
*(mi->stmt_ins++) = '\'';
tmpstr = inet_ntoa(addr);
-#ifdef LD_MYSQL
+#ifdef OLD_MYSQL
mysql_escape_string(mi->stmt_ins, tmpstr,
strlen(tmpstr));
#else
case ULOGD_RET_RAW:
ulogd_log(ULOGD_NOTICE,
"%s: type RAW not supported by MySQL\n",
- upi->input[i].name);
+ upi->input.keys[i].name);
break;
default:
ulogd_log(ULOGD_NOTICE,
"unknown type %d for %s\n",
- res->type, upi->input[i].name);
+ res->type, upi->input.keys[i].name);
break;
}
mi->stmt_ins = mi->stmt + strlen(mi->stmt);
for (i = 0; i < upi->input.num_keys; i++) {
/* we need space for the key and a comma, as well as
* enough space for the values */
- size += strlen(upi->input[i].name) + 1 + MYSQL_VALSIZE;
+ size += strlen(upi->input.keys[i].name) + 1 + MYSQL_VALSIZE;
}
ulogd_log(ULOGD_DEBUG, "allocating %u bytes for statement\n", size);
mi->stmt_val = mi->stmt + strlen(mi->stmt);
for (i = 0; i < upi->input.num_keys; i++) {
- strncpy(buf, upi->input[i].name, ULOGD_MAX_KEYLEN);
+ strncpy(buf, upi->input.keys[i].name, ULOGD_MAX_KEYLEN);
while ((underscore = strchr(buf, '.')))
*underscore = '_';
sprintf(mi->stmt_val, "%s,", buf);
* never free()s the memory we allocate here. FIXME. */
/* Cleanup before reconnect */
- if (upi->input) {
- free(upi->input);
- upi->input = NULL;
+ if (upi->input.keys) {
+ free(upi->input.keys);
+ upi->input.keys = NULL;
}
- upi->input = malloc(sizeof(struct ulogd_key) *
+ upi->input.keys = malloc(sizeof(struct ulogd_key) *
mysql_field_count(mi->dbh));
- if (!upi->input)
+ if (!upi->input.keys)
return -ENOMEM;
i = 0;
DEBUGP("field '%s' found: ", buf);
/* add it u list of input keys */
- strncpy(upi->input[i].name, buf, ULOGD_MAX_KEYLEN);
+ strncpy(upi->input.keys[i].name, buf, ULOGD_MAX_KEYLEN);
i++;
}
mysql_close(mi->dbh);
/* try to free our dynamically allocated input key array */
- if (upi->input) {
- free(upi->input);
- upi->input = 0;
+ if (upi->input.keys) {
+ free(upi->input.keys);
+ upi->input.keys = NULL;
}
return 0;
}