|
|
@ -596,6 +596,55 @@ int vm_intfn_sql_query_1s(void) |
|
|
|
stack_poke(vm_current, 0, result); /* return value */ |
|
|
|
stack_poke(vm_current, 0, result); /* return value */ |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int vm_intfn_sql_getvar(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int len; |
|
|
|
|
|
|
|
char buf[VM_STRING_MAX]; |
|
|
|
|
|
|
|
char query[VM_STRING_MAX]; |
|
|
|
|
|
|
|
int result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
len = stack_get(vm_current, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len >= VM_STRING_MAX) { |
|
|
|
|
|
|
|
printf("Excessive string length - can't perform query\n"); |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(buf, len+1, stack_getstr(vm_current, len, 1)); |
|
|
|
|
|
|
|
snprintf(query, VM_STRING_MAX, "SELECT value FROM vars WHERE name=\"%s\"", buf); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql_query(query, strlen(query), &result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX what to do with an error here? */ |
|
|
|
|
|
|
|
stack_poke(vm_current, 0, result); /* return value */ |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int vm_intfn_sql_setvar(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int len, val; |
|
|
|
|
|
|
|
char buf[VM_STRING_MAX]; |
|
|
|
|
|
|
|
char query[VM_STRING_MAX]; |
|
|
|
|
|
|
|
int result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val = stack_get(vm_current, 1); |
|
|
|
|
|
|
|
len = stack_get(vm_current, 2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (len >= VM_STRING_MAX) { |
|
|
|
|
|
|
|
printf("Excessive string length - can't perform query\n"); |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(buf, len+1, stack_getstr(vm_current, len, 2)); |
|
|
|
|
|
|
|
snprintf(query, VM_STRING_MAX, "INSERT OR REPLACE INTO vars VALUES(\"%s\", %d)", buf, val); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sql_query(query, strlen(query), &result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* XXX what to do with an error here? */ |
|
|
|
|
|
|
|
stack_poke(vm_current, 0, result); /* return value */ |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
int vm_intfn_beatdetect_read(void) |
|
|
|
int vm_intfn_beatdetect_read(void) |
|
|
|