From 918971d6886a7e45800cea0abf8da306a46c865c Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 1 Dec 2020 00:33:08 +0100 Subject: [PATCH] vere: replace -O with more generic -Z Lets you specify the output format, either 'jam', or an aura that the scry result (assumed to be an atom in that case) gets rendered to, as a .txt file. --- pkg/urbit/daemon/main.c | 14 ++++++++----- pkg/urbit/include/c/motes.h | 2 +- pkg/urbit/include/vere/vere.h | 2 +- pkg/urbit/vere/pier.c | 39 +++++++++++++++++------------------ 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index 28d0eee42..8186a8c47 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -75,7 +75,6 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.dem = c3n; u3_Host.ops_u.dry = c3n; u3_Host.ops_u.exp = c3n; - u3_Host.ops_u.kex = c3n; u3_Host.ops_u.gab = c3n; u3_Host.ops_u.git = c3n; @@ -94,11 +93,12 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.tex = c3n; u3_Host.ops_u.tra = c3n; u3_Host.ops_u.veb = c3n; + u3_Host.ops_u.puf_c = "jam"; u3_Host.ops_u.hap_w = 50000; u3_Host.ops_u.kno_w = DefaultKernel; while ( -1 != (ch_i=getopt(argc, argv, - "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:LljacdgoqstvxOPDRS")) ) + "X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:Z:LljacdgoqstvxPDRS")) ) { switch ( ch_i ) { case 'X': { @@ -109,6 +109,10 @@ _main_getopt(c3_i argc, c3_c** argv) u3_Host.ops_u.puk_c = strdup(optarg); break; } + case 'Z': { + u3_Host.ops_u.puf_c = strdup(optarg); + break; + } case 'J': { u3_Host.ops_u.lit_c = strdup(optarg); break; @@ -201,7 +205,6 @@ _main_getopt(c3_i argc, c3_c** argv) case 'd': { u3_Host.ops_u.dem = c3y; break; } case 'g': { u3_Host.ops_u.gab = c3y; break; } case 'o': { u3_Host.ops_u.exp = c3y; break; } - case 'O': { u3_Host.ops_u.kex = c3y; break; } case 'P': { u3_Host.ops_u.pro = c3y; break; } case 'D': { u3_Host.ops_u.dry = c3y; break; } case 'q': { u3_Host.ops_u.qui = c3y; break; } @@ -423,9 +426,10 @@ u3_ve_usage(c3_i argc, c3_c** argv) "-u url URL from which to download pill\n", "-v Verbose\n", "-w name Boot as ~name\n", - "-X path Scry, jam to file, then exit\n" + "-X path Scry, write to file, then exit\n" "-x Exit immediately\n", - "-Y file Optional name of jamfile (for -X and -o)\n" + "-Y file Optional name of file (for -X and -o)\n" + "-Z format Optional file format ('jam', or aura, for -X)\n" "\n", "Development Usage:\n", " To create a development ship, use a fakezod:\n", diff --git a/pkg/urbit/include/c/motes.h b/pkg/urbit/include/c/motes.h index e535681f9..da22a6b56 100644 --- a/pkg/urbit/include/c/motes.h +++ b/pkg/urbit/include/c/motes.h @@ -594,6 +594,7 @@ # define c3__ix c3_s2('i','x') # define c3__j c3_s1('j') # define c3__jack c3_s4('j','a','c','k') +# define c3__jam c3_s3('j','a','m') # define c3__jamx c3_s4('j','a','m','x') # define c3__jamz c3_s4('j','a','m','z') # define c3__jato c3_s4('j','a','t','o') @@ -1209,7 +1210,6 @@ # define c3__vern c3_s4('v','e','r','n') # define c3__very c3_s4('v','e','r','y') # define c3__view c3_s4('v','i','e','w') -# define c3__vile c3_s4('v','i','l','e') # define c3__vint c3_s4('v','i','n','t') # define c3__void c3_s4('v','o','i','d') # define c3__vorp c3_s4('v','o','r','p') diff --git a/pkg/urbit/include/vere/vere.h b/pkg/urbit/include/vere/vere.h index d484dfca0..89b303269 100644 --- a/pkg/urbit/include/vere/vere.h +++ b/pkg/urbit/include/vere/vere.h @@ -267,7 +267,6 @@ c3_c* jin_c; // -I, inject raw event c3_c* imp_c; // -i, import pier state c3_o exp; // -o, export pier state - c3_o kex; // -O, export keyfile c3_w hap_w; // -C, cap memo cache c3_c* lit_c; // -J, ivory (fastboot) kernel c3_o tra; // -j, json trace @@ -290,6 +289,7 @@ c3_o tex; // -x, exit after loading c3_c* pek_c; // -X, scry path (/vc/desk/path) c3_c* puk_c; // -Y, scry result filename + c3_c* puf_c; // -Z, scry result format } u3_opts; /* u3_host: entire host. diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index b57fcc1ba..41b4aa4fb 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -491,6 +491,23 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) else { u3l_log("pier: scry succeeded\n"); + // serialize as desired + // + u3_atom out; + c3_c* ext_c; + { + u3l_log("xxx\n"); + u3_atom puf = u3i_string(u3_Host.ops_u.puf_c); + if ( c3y == u3r_sing(c3__jam, puf) ) { + out = u3qe_jam(res); + ext_c = "jam"; + } + else { + out = u3dc("scot", puf, u3k(res)); + ext_c = "txt"; + } + } + c3_c* pac_c = u3_Host.ops_u.puk_c; if (!pac_c) { pac_c = u3_Host.ops_u.pek_c; @@ -510,20 +527,9 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun) } c3_c fil_c[2048]; - snprintf(fil_c, 2048, "%s/.urb/put/%s.%s", pir_u->pax_c, pac_c+1, - (c3y == u3_Host.ops_u.kex) ? "key" : "jam"); + snprintf(fil_c, 2048, "%s/.urb/put/%s.%s", pir_u->pax_c, pac_c+1, ext_c); - // if this was a keyfile scry, serialize it as @uw, - // otherwise, write it to a jamfile - // - //TODO support broader control over output format - // - if ( c3y == u3_Host.ops_u.kex ) { - u3_atom out = u3dc("scot", c3__uw, u3k(res)); - u3_walk_save(fil_c, 0, out, pir_u->pax_c, pad); - } else { - u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad); - } + u3_walk_save(fil_c, 0, out, pir_u->pax_c, pad); u3l_log("pier: scry in %s\n", fil_c); } @@ -634,13 +640,6 @@ _pier_work_init(u3_pier* pir_u) u3z(pex); } - else if ( _(u3_Host.ops_u.kex) ) { - if (!u3_Host.ops_u.puk_c) { - u3_Host.ops_u.puk_c = strdup("/archive/keyfile"); - } - u3_pier_peek_last(pir_u, u3_nul, c3__j, c3__vile, u3_nul, - pir_u, _pier_on_scry_done); - } else { // initialize i/o drivers //