hash function naming

This commit is contained in:
udo
2022-01-19 22:38:48 +00:00
parent 08496afa11
commit c17c72d59f
18 changed files with 71 additions and 52 deletions
Binary file not shown.
+6 -6
View File
@@ -1,9 +1,9 @@
Noise Functions Noise/Hash Functions
draw_float draw_float
draw_int draw_int
generate_float gen_noise01
generate_int gen_noise32
noise01 gen_noise64
noise32 gen_float
noise64 gen_int
+11 -9
View File
@@ -25,9 +25,9 @@ RENDER()
String page = first(context->get["p"], "index"); String page = first(context->get["p"], "index");
<><html> <><html>
<header> <head>
<link rel="stylesheet" href='style.css'></link> <link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
</header> </head>
<body> <body>
<h1> <h1>
<a href="index.uce">UCE Docs</a>: <a href="index.uce">UCE Docs</a>:
@@ -72,9 +72,10 @@ RENDER()
{ {
auto doc = split(file_get_contents("pages/"+page+".txt"), "\n"); auto doc = split(file_get_contents("pages/"+page+".txt"), "\n");
String layout_class = "text"; String layout_class = "text";
?><div><? u32 line_idx = 0;
for(auto s : doc) for(auto s : doc)
{ {
line_idx++;
if(s == "") if(s == "")
{ {
@@ -82,7 +83,11 @@ RENDER()
else if(s.substr(0, 1) == ":") else if(s.substr(0, 1) == ":")
{ {
layout_class = s.substr(1); layout_class = s.substr(1);
?></div><? if(line_idx > 1)
{
?></div><?
}
?><div class="<?= layout_class ?>"><?
if(layout_class == "params") if(layout_class == "params")
{ {
?><h3>Parameters</h3><? ?><h3>Parameters</h3><?
@@ -101,13 +106,12 @@ RENDER()
} }
else if(layout_class == "see") else if(layout_class == "see")
{ {
?><h3>Related</h3><? /*?><h3>Related</h3><?*/
} }
else else
{ {
?><h3><?= layout_class ?></h3><? ?><h3><?= layout_class ?></h3><?
} }
?><div class="<?= layout_class ?>"><?
} }
else else
{ {
@@ -122,7 +126,6 @@ RENDER()
} }
else if(layout_class == "see") else if(layout_class == "see")
{ {
?><div style="margin-left: 2em"><?
if(s[0] == '>') if(s[0] == '>')
{ {
render_see_section(s.substr(1)); render_see_section(s.substr(1));
@@ -131,7 +134,6 @@ RENDER()
{ {
?><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span style="opacity:0.5">()</span></a></div><? ?><div><a href="index.uce?p=<?= trim(s) ?>"><?= trim(s) ?><span style="opacity:0.5">()</span></a></div><?
} }
?></div><?
} }
else else
{ {
+19 -12
View File
@@ -6,9 +6,15 @@
line-height: inherit; line-height: inherit;
} }
h1 {
font-family: monospace;
font-size: 200%;
padding-top: 8px;
padding-bottom: 8px;
}
body { body {
max-width: 1024px; max-width: 1024px;
margin: 0;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
padding-left: 16px; padding-left: 16px;
@@ -16,22 +22,19 @@ body {
font-family: Tahoma, Helvetica, Arial; font-family: Tahoma, Helvetica, Arial;
font-size: 1.2em; font-size: 1.2em;
box-sizing: border-box; box-sizing: border-box;
background: #24f; background: #139;
color: white; color: white;
line-height: 150%; line-height: 150%;
} }
a { body > * {
color: yellow; background: rgba(255,255,255,0.1);
padding: 32px;
margin: 16px;
} }
h1 { a {
font-size: 200%; color: yellow;
padding-top: 16px;
padding-bottom: 16px;
border-bottom: 8px solid rgba(0,0,0,0.5);
margin: 0;
margin-bottom: 8px;
} }
form > div, label { form > div, label {
@@ -79,7 +82,11 @@ pre {
} }
h3 { h3 {
margin: 0;
font-family: monospace;
font-size: 1.4em;
margin-bottom: 0.8em;
opacity: 0.7;
} }
.sig { .sig {
+11 -11
View File
@@ -257,7 +257,7 @@ unsigned char c;
/* ================ end of sha1.c ================ */ /* ================ end of sha1.c ================ */
String String
sha1(String s, bool as_binary) gen_sha1(String s, bool as_binary)
{ {
unsigned char v[20]; unsigned char v[20];
SHA1_CTX ctx; SHA1_CTX ctx;
@@ -279,7 +279,7 @@ sha1(String s, bool as_binary)
#define BIT_NOISE3 0x1B56C4E9 #define BIT_NOISE3 0x1B56C4E9
// based on Squirrel3 https://www.youtube.com/watch?v=LWFzPP8ZbdU&t=2666s // based on Squirrel3 https://www.youtube.com/watch?v=LWFzPP8ZbdU&t=2666s
u32 noise32(u32 index, u32 seed) u32 gen_noise32(u32 index, u32 seed)
{ {
u32 r = index; u32 r = index;
r *= BIT_NOISE1; r *= BIT_NOISE1;
@@ -296,7 +296,7 @@ u32 noise32(u32 index, u32 seed)
#define BIT_NOISE62 0xb8E31DA41B56C4E9 #define BIT_NOISE62 0xb8E31DA41B56C4E9
#define BIT_NOISE63 0x18cd227aaa1168c1 #define BIT_NOISE63 0x18cd227aaa1168c1
u64 noise64(u64 index, u64 seed) u64 gen_noise64(u64 index, u64 seed)
{ {
u64 r = index; u64 r = index;
r *= BIT_NOISE61; r *= BIT_NOISE61;
@@ -311,31 +311,31 @@ u64 noise64(u64 index, u64 seed)
#define MAX_64 0xffffffffffffffff #define MAX_64 0xffffffffffffffff
f64 noise01(u64 index, u64 seed) f64 gen_noise01(u64 index, u64 seed)
{ {
return((float)noise64(index, seed)/(float)MAX_64); return((float)gen_noise64(index, seed)/(float)MAX_64);
} }
u64 generate_int(u64 from, u64 to, u64 index, u64 seed) u64 gen_int(u64 from, u64 to, u64 index, u64 seed)
{ {
u64 b = 1 + to - from; u64 b = 1 + to - from;
return(from + (noise64(index, seed) % b)); return(from + (gen_noise64(index, seed) % b));
} }
#include <tgmath.h> #include <tgmath.h>
f64 generate_float(f64 from, f64 to, u64 index, u64 seed, f64 decimal_precision) f64 gen_float(f64 from, f64 to, u64 index, u64 seed, f64 decimal_precision)
{ {
f64 b = to - from; f64 b = to - from;
return(from + fmod( decimal_precision*(f64)noise64(index, seed), b)); return(from + fmod( decimal_precision*(f64)gen_noise64(index, seed), b));
} }
u64 draw_int(u64 from, u64 to) u64 draw_int(u64 from, u64 to)
{ {
return(generate_int(from, to, context->random_index++, context->random_seed)); return(gen_int(from, to, context->random_index++, context->random_seed));
} }
f64 draw_float(f64 from, f64 to, f64 decimal_precision) f64 draw_float(f64 from, f64 to, f64 decimal_precision)
{ {
return(generate_float(from, to, context->random_index++, context->random_seed, decimal_precision)); return(gen_float(from, to, context->random_index++, context->random_seed, decimal_precision));
} }
+6 -6
View File
@@ -6,14 +6,14 @@ By Steve Reid <steve@edmweb.com>
*/ */
String sha1(String s, bool as_binary = false); String gen_sha1(String s, bool as_binary = false);
u32 noise32(u32 index, u32 seed = 0); u32 gen_noise32(u32 index, u32 seed = 0);
u64 noise64(u64 index, u64 seed = 0); u64 gen_noise64(u64 index, u64 seed = 0);
f64 noise01(u64 index, u64 seed = 0); f64 gen_noise01(u64 index, u64 seed = 0);
u64 generate_int(u64 from, u64 to, u64 index, u64 seed = 0); u64 gen_int(u64 from, u64 to, u64 index, u64 seed = 0);
f64 generate_float(f64 from, f64 to, u64 index, u64 seed = 0, f64 decimal_precision = 0.000000000001); f64 gen_float(f64 from, f64 to, u64 index, u64 seed = 0, f64 decimal_precision = 0.000000000001);
u64 draw_int(u64 from, u64 to); u64 draw_int(u64 from, u64 to);
f64 draw_float(f64 from, f64 to, f64 decimal_precision = 0.000000000001); f64 draw_float(f64 from, f64 to, f64 decimal_precision = 0.000000000001);
+1 -1
View File
@@ -147,7 +147,7 @@ String to_string(s64 v) { return(std::to_string(v)); }
struct ServerSettings { struct ServerSettings {
String BIN_DIRECTORY = "work"; String BIN_DIRECTORY = "/tmp/uce/work";
String COMPILE_SCRIPT = "scripts/compile"; String COMPILE_SCRIPT = "scripts/compile";
String LIT_ESC = "3d5b5_1"; String LIT_ESC = "3d5b5_1";
String CONTENT_TYPE = "text/html; charset=utf-8"; String CONTENT_TYPE = "text/html; charset=utf-8";
+2 -3
View File
@@ -47,7 +47,7 @@ int handle_complete(FastCGIRequest& request) {
request.header["Content-Type"] = context->server->config.CONTENT_TYPE; request.header["Content-Type"] = context->server->config.CONTENT_TYPE;
request.get = parse_query(request.params["QUERY_STRING"]); request.get = parse_query(request.params["QUERY_STRING"]);
request.random_index = 0; request.random_index = 0;
request.random_seed = noise64(*reinterpret_cast<u64*>(&request.stats.time_start)); request.random_seed = gen_noise64(*reinterpret_cast<u64*>(&request.stats.time_start));
request.ob_start(); request.ob_start();
if(request.params["HTTP_COOKIE"].length() > 0) if(request.params["HTTP_COOKIE"].length() > 0)
@@ -118,8 +118,6 @@ int main(int argc, char** argv)
printf("Compiler base path: %s\n", server_state.config.COMPILER_SYS_PATH.c_str()); printf("Compiler base path: %s\n", server_state.config.COMPILER_SYS_PATH.c_str());
server_state.config.BIN_DIRECTORY =
server_state.config.COMPILER_SYS_PATH + "/" + server_state.config.BIN_DIRECTORY;
server_state.config.COMPILE_SCRIPT = server_state.config.COMPILE_SCRIPT =
server_state.config.COMPILER_SYS_PATH + "/" + server_state.config.COMPILE_SCRIPT; server_state.config.COMPILER_SYS_PATH + "/" + server_state.config.COMPILE_SCRIPT;
if(server_state.config.LISTEN_PORT) if(server_state.config.LISTEN_PORT)
@@ -131,6 +129,7 @@ int main(int argc, char** argv)
dirname(server_state.config.COMPILER_SYS_PATH); dirname(server_state.config.COMPILER_SYS_PATH);
basename(server_state.config.COMPILER_SYS_PATH); basename(server_state.config.COMPILER_SYS_PATH);
mkdir(server_state.config.BIN_DIRECTORY);
mkdir(server_state.config.TMP_UPLOAD_PATH); mkdir(server_state.config.TMP_UPLOAD_PATH);
mkdir(server_state.config.SESSION_PATH); mkdir(server_state.config.SESSION_PATH);
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
rm -r work/* ; ./build_linux.sh && bin/uce_fastcgi.debug.linux.bin rm -r /tmp/uce/work/* ; ./build_linux.sh && bin/uce_fastcgi.debug.linux.bin
+4
View File
@@ -0,0 +1,4 @@
void hello()
{
}
+1 -1
View File
@@ -6,7 +6,7 @@ RENDER()
p.set(context->params); p.set(context->params);
<> <>
<link rel="stylesheet" href='style.css'></link> <link rel="stylesheet" href='style.css?v=<?= time() ?>'></link>
<h1> <h1>
<a href="index.uce">UCE Test</a>: <a href="index.uce">UCE Test</a>:
Index Index
+9 -2
View File
@@ -14,6 +14,7 @@ h1 {
font-size: 200%; font-size: 200%;
padding-top: 8px; padding-top: 8px;
padding-bottom: 8px; padding-bottom: 8px;
font-family: monospace;
} }
body { body {
@@ -25,11 +26,17 @@ body {
font-family: Tahoma, Helvetica, Arial; font-family: Tahoma, Helvetica, Arial;
font-size: 1.2em; font-size: 1.2em;
box-sizing: border-box; box-sizing: border-box;
background: #24f; background: #139;
color: white; color: white;
line-height: 150%; line-height: 150%;
} }
body > * {
background: rgba(255,255,255,0.1);
padding: 32px;
margin: 16px;
}
form > div, label { form > div, label {
display: block; display: block;
padding-top: 8px; padding-top: 8px;
@@ -69,7 +76,7 @@ pre {
overflow: auto; overflow: auto;
padding: 8px; padding: 8px;
border: 2px solid rgba(0,0,0,0.2); border: 2px solid rgba(0,0,0,0.2);
background: rgba(100,100,100,0.15); background: rgba(255,255,255,0.1);
font-family: monospace; font-family: monospace;
white-space: pre-wrap; white-space: pre-wrap;
} }