Overview
Comment: | Implement cryptographic hash algorithms. (These are not currently used by Free Hero Mesh but is expected to be used in future.) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
12934338676a381159f7149f6a415d92 |
User & Date: | user on 2022-01-13 06:48:00.255 |
Other Links: | manifest | tags |
Context
2022-01-15
| ||
05:59 | Implement the user sounds (uncompressed) and MML sounds; does not work in the game yet, and built-in sounds are not yet implemented. check-in: 5c902e7a3f user: user tags: trunk | |
2022-01-13
| ||
06:48 | Implement cryptographic hash algorithms. (These are not currently used by Free Hero Mesh but is expected to be used in future.) check-in: 1293433867 user: user tags: trunk | |
2022-01-12
| ||
02:28 | Use 23-bit code page numbers. check-in: 0ced76ece7 user: user tags: trunk | |
Changes
Modified ARCHITECTURE
from [2e9d020285]
to [cf4caa50f5].
︙ | ︙ | |||
41 42 43 44 45 46 47 48 49 50 51 52 53 54 | heromesh.h: Contains structures, macros, and function and variables for Free Hero Mesh, which can be used by multiple files. game.c: The game play. The game behaviour is implemented in exec.c; this one just handles the input and display, and solution replay, and any move which is made calls exec.c to execute the mode. It contains one function (locate_me) which is called by exec.c. instruc,instruc.h,instruc.js: The "instruc" file contains a list of the keywords and internal operator names used in the class definitions. Some of these are only used internally, although most are available directly as keywords. Many are also opcodes in the compiled P-code, although some are only used as keywords, which are handled during class loading. The instruc.js program generates instruc.h from instruc. | > > > > > > | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | heromesh.h: Contains structures, macros, and function and variables for Free Hero Mesh, which can be used by multiple files. game.c: The game play. The game behaviour is implemented in exec.c; this one just handles the input and display, and solution replay, and any move which is made calls exec.c to execute the mode. It contains one function (locate_me) which is called by exec.c. hash.c,hash.h: A set of functions for computing cryptographic hashes. These functions can be used outside of Free Hero Mesh, too. If you want to add new algorithms, use the multicodec table to assign the numbers. (Currently they are not used for anything, but some planned features may use it in future.) instruc,instruc.h,instruc.js: The "instruc" file contains a list of the keywords and internal operator names used in the class definitions. Some of these are only used internally, although most are available directly as keywords. Many are also opcodes in the compiled P-code, although some are only used as keywords, which are handled during class loading. The instruc.js program generates instruc.h from instruc. |
︙ | ︙ |
Modified compile
from [9ee9dc5e0b]
to [552320bf15].
1 2 3 4 5 6 7 8 9 | #!/bin/bash -- set -e if test "$1" = "p"; then echo 'Using portable mode.' test -d bin || mkdir bin export EXE=bin/heromesh test -e bin/current.heromeshrc || cp default.heromeshrc bin/current.heromeshrc fi test -f CFLAGS || echo xxx > CFLAGS | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #!/bin/bash -- set -e if test "$1" = "p"; then echo 'Using portable mode.' test -d bin || mkdir bin export EXE=bin/heromesh test -e bin/current.heromeshrc || cp default.heromeshrc bin/current.heromeshrc fi test -f CFLAGS || echo xxx > CFLAGS test "xx$CFLAGS" = "x`cat CFLAGS`" || rm bindings.o class.o picture.o function.o exec.o game.o edit.o picedit.o hash.o || true echo "x$CFLAGS" > CFLAGS test "x$EXE" = "x" && export EXE=~/bin/heromesh echo 'Flags: ' "$CFLAGS" echo 'Target filename: ' "$EXE" test instruc -nt instruc.h && node instruc.js > instruc.h test instruc.js -nt instruc.h && node instruc.js > instruc.h test names.js -nt names.h && node names.js > names.h test quarks -nt quarks.h && node quarks.js > quarks.h test quarks.js -nt quarks.h && node quarks.js > quarks.h test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o function.o exec.o game.o edit.o picedit.o || true test instruc.h -nt "$EXE" && rm class.o exec.o || true test pcfont.h -nt "$EXE" && rm picture.o || true test quarks.h -nt "$EXE" && rm bindings.o edit.o exec.o game.o picture.o picedit.o || true test hash.h -nt "$EXE" && rm hash.o function.o || true echo '* smallxrm' test smallxrm.c -nt smallxrm.o && bash smallxrm.c echo '* bindings' test bindings.c -nt bindings.o && bash bindings.c echo '* class' test class.c -nt class.o && bash class.c echo '* function' test function.c -nt function.o && bash function.c echo '* picture' test picture.c -nt picture.o && bash picture.c echo '* exec' test exec.c -nt exec.o && bash exec.c echo '* game' test game.c -nt game.o && bash game.c echo '* edit' test edit.c -nt edit.o && bash edit.c echo '* picedit' test picedit.c -nt picedit.o && bash picedit.c echo '* hash' test hash.c -nt hash.o && bash hash.c echo '* main' bash main.c echo 'DONE' |
Modified function.c
from [77517819b9]
to [830d643cb4].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <stdlib.h> #include <string.h> #include "sqlite3.h" #include "smallxrm.h" #include "heromesh.h" #include "cursorshapes.h" #include "instruc.h" typedef struct { struct sqlite3_vtab_cursor; sqlite3_int64 rowid; char unique,eof; Uint16 arg[4]; } Cursor; | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <stdlib.h> #include <string.h> #include "sqlite3.h" #include "smallxrm.h" #include "heromesh.h" #include "cursorshapes.h" #include "instruc.h" #include "hash.h" typedef struct { struct sqlite3_vtab_cursor; sqlite3_int64 rowid; char unique,eof; Uint16 arg[4]; } Cursor; |
︙ | ︙ | |||
152 153 154 155 156 157 158 159 160 161 162 163 164 165 | return; } else { a=sqlite3_value_int(*argv)&0xFFFF; if(!a || (a&~0x3FFF) || !classes[a] || (classes[a]->cflags&CF_NOCLASS2)) return; } found: sqlite3_result_int64(cxt,a|((sqlite3_int64)TY_CLASS<<32)); } static void fn_heromesh_escape(sqlite3_context*cxt,int argc,sqlite3_value**argv) { const unsigned char*u=sqlite3_value_blob(*argv); int un=sqlite3_value_bytes(*argv); char*e; int en=0; int i=0; | > > > > > > > > > | 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | return; } else { a=sqlite3_value_int(*argv)&0xFFFF; if(!a || (a&~0x3FFF) || !classes[a] || (classes[a]->cflags&CF_NOCLASS2)) return; } found: sqlite3_result_int64(cxt,a|((sqlite3_int64)TY_CLASS<<32)); } static void fn_hash(sqlite3_context*cxt,int argc,sqlite3_value**argv) { const unsigned char*u=sqlite3_value_blob(*argv); int n=sqlite3_value_bytes(*argv); long long h=sqlite3_value_int64(argv[1]); int m=hash_length(h); if(sqlite3_value_type(*argv)==SQLITE_NULL || !m) return; sqlite3_result_blob(cxt,hash_buffer(h,u,n),m,free); } static void fn_heromesh_escape(sqlite3_context*cxt,int argc,sqlite3_value**argv) { const unsigned char*u=sqlite3_value_blob(*argv); int un=sqlite3_value_bytes(*argv); char*e; int en=0; int i=0; |
︙ | ︙ | |||
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 | void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1) { sqlite3_create_function(userdb,"BASENAME",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_basename,0,0); sqlite3_create_function(userdb,"BCAT",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_bcat,0,0); sqlite3_create_function(userdb,"BYTE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_byte,0,0); sqlite3_create_function(userdb,"CL",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cl,0,0); sqlite3_create_function(userdb,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0); sqlite3_create_function(userdb,"CVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cvalue,0,0); sqlite3_create_function(userdb,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0); sqlite3_create_function(userdb,"HEROMESH_TYPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_type,0,0); sqlite3_create_function(userdb,"HEROMESH_UNESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_unescape,0,0); sqlite3_create_function(userdb,"INRECT",2,SQLITE_UTF8,0,fn_inrect,0,0); sqlite3_create_function(userdb,"LEVEL",0,SQLITE_UTF8,&level_ord,fn_level,0,0); sqlite3_create_function(userdb,"LEVEL_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr0,fn_cacheid,0,0); sqlite3_create_function(userdb,"LEVEL_ID",0,SQLITE_UTF8,&level_id,fn_level,0,0); | > | 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 | void init_sql_functions(sqlite3_int64*ptr0,sqlite3_int64*ptr1) { sqlite3_create_function(userdb,"BASENAME",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_basename,0,0); sqlite3_create_function(userdb,"BCAT",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_bcat,0,0); sqlite3_create_function(userdb,"BYTE",-1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_byte,0,0); sqlite3_create_function(userdb,"CL",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cl,0,0); sqlite3_create_function(userdb,"CLASS_DATA",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_class_data,0,0); sqlite3_create_function(userdb,"CVALUE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_cvalue,0,0); sqlite3_create_function(userdb,"HASH",2,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_hash,0,0); sqlite3_create_function(userdb,"HEROMESH_ESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_escape,0,0); sqlite3_create_function(userdb,"HEROMESH_TYPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_type,0,0); sqlite3_create_function(userdb,"HEROMESH_UNESCAPE",1,SQLITE_UTF8|SQLITE_DETERMINISTIC,0,fn_heromesh_unescape,0,0); sqlite3_create_function(userdb,"INRECT",2,SQLITE_UTF8,0,fn_inrect,0,0); sqlite3_create_function(userdb,"LEVEL",0,SQLITE_UTF8,&level_ord,fn_level,0,0); sqlite3_create_function(userdb,"LEVEL_CACHEID",0,SQLITE_UTF8|SQLITE_DETERMINISTIC,ptr0,fn_cacheid,0,0); sqlite3_create_function(userdb,"LEVEL_ID",0,SQLITE_UTF8,&level_id,fn_level,0,0); |
︙ | ︙ |
Added hash.c version [56ec27ebd5].
Added hash.h version [ed7b8f308a].
Modified main.c
from [d1bd9cc799]
to [f5412e16d8].
1 | #if 0 | | | 1 2 3 4 5 6 7 8 9 | #if 0 gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} -Wno-multichar main.c class.o picture.o bindings.o function.o exec.o game.o edit.o picedit.o smallxrm.o hash.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread -lm exit #endif /* This program is part of Free Hero Mesh and is public domain. */ |
︙ | ︙ |
Modified sql.doc
from [4e8a641099]
to [56d19caca8].
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 130 = CollisionLayers 132 = Compatible CVALUE(number) Makes a game value of type 'class', given the class number. You can also specify the class name instead of the number. HEROMESH_ESCAPE(blob) Converts blob representation of a game string into escaped format. HEROMESH_TYPE(value) The type of a game value, given as a 64-bit integer. The types are 'class', 'number', 'string', 'object', and 'sound'. | > > > > | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 130 = CollisionLayers 132 = Compatible CVALUE(number) Makes a game value of type 'class', given the class number. You can also specify the class name instead of the number. HASH(data,algorithm) Make the hash of the data as a binary blob. See hash.h for a list of the valid numbers to use as the hash algorithm numbers. HEROMESH_ESCAPE(blob) Converts blob representation of a game string into escaped format. HEROMESH_TYPE(value) The type of a game value, given as a 64-bit integer. The types are 'class', 'number', 'string', 'object', and 'sound'. |
︙ | ︙ |