Index: commandline.doc ================================================================== --- commandline.doc +++ commandline.doc @@ -37,10 +37,13 @@ Start in the editor instead of game. -n (not implemented yet) Create a new puzzle set. +-r + Open in read-only mode. + -t Enable tracing. -v More verbose error logging. Index: main.c ================================================================== --- main.c +++ main.c @@ -143,11 +143,11 @@ if(us) *us=sqlite3_value_dup(sqlite3_column_value(readusercachest,6)); if(sqlite3_column_type(readusercachest,5)==SQLITE_BLOB) { const unsigned char*con=sqlite3_column_blob(readusercachest,5); *sz=sqlite3_column_bytes(readusercachest,5); buf=malloc(*sz); - if(*sz && !buf) fatal("Allocation failed"); + if(*sz && !buf) fatal("Allocation failed\n"); memcpy(buf,con,*sz); } else { FILE*fp=sol?solutionfp:levelfp; rewind(fp); fseek(fp,sqlite3_column_int64(readusercachest,4)-4,SEEK_SET); @@ -386,13 +386,15 @@ fwrite(sqlite3_column_text(st,1),1,sqlite3_column_bytes(st,1)+1,fp); j=sqlite3_column_bytes(st,2); fputc(j>>16,fp); fputc(j>>24,fp); fputc(j,fp); fputc(j>>8,fp); ofs[i++]=ftell(fp); fwrite(sqlite3_column_blob(st,2),1,j,fp); + if(ferror(fp)) fatal("I/O error: %m\n"); } if(e!=SQLITE_DONE) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb)); if(ftruncate(fd,ftell(fp))) fatal("I/O error: %m\n"); + rewind(fp); sqlite3_finalize(st); if(e=sqlite3_prepare_v2(userdb,"UPDATE `USERCACHEDATA` SET `OFFSET` = ?2 WHERE `ID` = ?1;",-1,&st,0)) fatal("SQL error (%d): %s\n",e,sqlite3_errmsg(userdb)); i=0; while(it1 || fst.st_ctime>t1) leveluc=reset_usercache(levelfp,nam2,&fst,".LVL"); if(stat(nam3,&fst)) fatal("Unable to stat '%s': %m\n",nam3); - if(!fst.st_size) fatal("File '%s' has zero size\n",nam2); if(fst.st_mtime>t2 || fst.st_ctime>t2) solutionuc=reset_usercache(solutionfp,nam3,&fst,".SOL"); free(nam2); free(nam3); if(z=sqlite3_prepare_v3(userdb,"SELECT * FROM `USERCACHEDATA` WHERE `FILE` = ?1 AND `LEVEL` = ?2;",-1,SQLITE_PREPARE_PERSISTENT,&readusercachest,0)) { fatal("SQL error (%d): %s\n",z,sqlite3_errmsg(userdb));