300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
static void fn_pfsize(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,*(Uint8*)sqlite3_user_data(cxt));
}
static void fn_picture_size(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,picture_size);
}
static void fn_read_lump_at(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_int64 of=sqlite3_value_int64(argv[0]);
FILE*fp=sqlite3_value_pointer(argv[1],"http://zzo38computer.org/fossil/heromesh.ui#FILE_ptr");
long sz;
Uint8*buf;
if(!fp) return;
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
static void fn_pfsize(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,*(Uint8*)sqlite3_user_data(cxt));
}
static void fn_picture_size(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_result_int(cxt,picture_size);
}
static void fn_pipe(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
const char*name=sqlite3_value_text(*argv);
FILE*fp;
int i;
char buf[512];
sqlite3_str*str;
if(!name) return;
fp=popen(name,"r");
if(!fp) {
sqlite3_result_error(cxt,"Cannot open pipe",-1);
return;
}
str=sqlite3_str_new(userdb);
for(;;) {
i=fread(buf,1,512,fp);
if(i<=0) break;
sqlite3_str_append(str,buf,i);
}
pclose(fp);
i=sqlite3_str_errcode(str);
if(i==SQLITE_NOMEM) {
sqlite3_result_error_nomem(cxt);
} else if(i==SQLITE_TOOBIG) {
sqlite3_result_error_toobig(cxt);
} else if(i) {
sqlite3_result_error(cxt,"Unknown error",-1);
}
if(i) {
sqlite3_free(sqlite3_str_finish(str));
return;
}
if(i=sqlite3_str_length(str)) {
sqlite3_result_blob(cxt,sqlite3_str_finish(str),i,sqlite3_free);
} else {
sqlite3_free(sqlite3_str_finish(str));
sqlite3_result_zeroblob(cxt,0);
}
}
static void fn_read_lump_at(sqlite3_context*cxt,int argc,sqlite3_value**argv) {
sqlite3_int64 of=sqlite3_value_int64(argv[0]);
FILE*fp=sqlite3_value_pointer(argv[1],"http://zzo38computer.org/fossil/heromesh.ui#FILE_ptr");
long sz;
Uint8*buf;
if(!fp) return;
|
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
|
sqlite3_create_function(userdb,"MOVENUMBER",0,SQLITE_UTF8,0,fn_movenumber,0,0);
sqlite3_create_function(userdb,"MVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_mvalue,0,0);
sqlite3_create_function(userdb,"NVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_zero_extend,0,0);
sqlite3_create_function(userdb,"OVALUE",1,SQLITE_UTF8,0,fn_ovalue,0,0);
sqlite3_create_function(userdb,"PFHEIGHT",0,SQLITE_UTF8,&pfheight,fn_pfsize,0,0);
sqlite3_create_function(userdb,"PFWIDTH",0,SQLITE_UTF8,&pfwidth,fn_pfsize,0,0);
sqlite3_create_function(userdb,"PICTURE_SIZE",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_picture_size,0,0);
sqlite3_create_function(userdb,"READ_LUMP_AT",2,SQLITE_UTF8,0,fn_read_lump_at,0,0);
sqlite3_create_function(userdb,"RESOURCE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_resource,0,0);
sqlite3_create_function(userdb,"SIGN_EXTEND",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_sign_extend,0,0);
sqlite3_create_function(userdb,"SOLUTION_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr1,fn_cacheid,0,0);
sqlite3_create_function(userdb,"TRACE_OFF",0,SQLITE_UTF8,"",fn_trace_on,0,0);
sqlite3_create_function(userdb,"TRACE_ON",0,SQLITE_UTF8,"\x01",fn_trace_on,0,0);
sqlite3_create_function(userdb,"XY",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_xy,0,0);
|
>
|
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
|
sqlite3_create_function(userdb,"MOVENUMBER",0,SQLITE_UTF8,0,fn_movenumber,0,0);
sqlite3_create_function(userdb,"MVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_mvalue,0,0);
sqlite3_create_function(userdb,"NVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_zero_extend,0,0);
sqlite3_create_function(userdb,"OVALUE",1,SQLITE_UTF8,0,fn_ovalue,0,0);
sqlite3_create_function(userdb,"PFHEIGHT",0,SQLITE_UTF8,&pfheight,fn_pfsize,0,0);
sqlite3_create_function(userdb,"PFWIDTH",0,SQLITE_UTF8,&pfwidth,fn_pfsize,0,0);
sqlite3_create_function(userdb,"PICTURE_SIZE",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_picture_size,0,0);
sqlite3_create_function(userdb,"PIPE",1,SQLITE_UTF8,0,fn_pipe,0,0);
sqlite3_create_function(userdb,"READ_LUMP_AT",2,SQLITE_UTF8,0,fn_read_lump_at,0,0);
sqlite3_create_function(userdb,"RESOURCE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_resource,0,0);
sqlite3_create_function(userdb,"SIGN_EXTEND",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_sign_extend,0,0);
sqlite3_create_function(userdb,"SOLUTION_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr1,fn_cacheid,0,0);
sqlite3_create_function(userdb,"TRACE_OFF",0,SQLITE_UTF8,"",fn_trace_on,0,0);
sqlite3_create_function(userdb,"TRACE_ON",0,SQLITE_UTF8,"\x01",fn_trace_on,0,0);
sqlite3_create_function(userdb,"XY",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_xy,0,0);
|