vere: add -O for exporting keyfile

For integration with other flagday-related logic.
This commit is contained in:
fang 2020-11-30 22:50:12 +01:00
parent d7c740b32a
commit 8f22a9a501
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
4 changed files with 26 additions and 3 deletions

View File

@ -75,6 +75,7 @@ _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;
@ -97,7 +98,7 @@ _main_getopt(c3_i argc, c3_c** argv)
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:LljacdgoqstvxPDRS")) )
"X:Y:G:J:B:K:A:H:I:C:w:u:e:F:k:n:p:r:i:LljacdgoqstvxOPDRS")) )
{
switch ( ch_i ) {
case 'X': {
@ -200,6 +201,7 @@ _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; }

View File

@ -592,6 +592,7 @@
# define c3__is c3_s2('i','s')
# define c3__item c3_s4('i','t','e','m')
# define c3__ix c3_s2('i','x')
# define c3__j c3_s1('j')
# define c3__jack c3_s4('j','a','c','k')
# define c3__jamx c3_s4('j','a','m','x')
# define c3__jamz c3_s4('j','a','m','z')
@ -1208,6 +1209,7 @@
# 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')

View File

@ -267,6 +267,7 @@
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

View File

@ -510,9 +510,20 @@ _pier_on_scry_done(void* ptr_v, u3_noun nun)
}
c3_c fil_c[2048];
snprintf(fil_c, 2048, "%s/.urb/put/%s.jam", pir_u->pax_c, pac_c+1);
snprintf(fil_c, 2048, "%s/.urb/put/%s.%s", pir_u->pax_c, pac_c+1,
(c3y == u3_Host.ops_u.kex) ? "key" : "jam");
u3_walk_save(fil_c, 0, u3qe_jam(res), pir_u->pax_c, pad);
// 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);
}
u3l_log("pier: scry in %s\n", fil_c);
}
@ -623,6 +634,13 @@ _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
//