conn: produce command line arguments

Involves saving a copy of the arguments in _main_getopt.
This commit is contained in:
Jōshin 2022-02-05 18:53:21 -06:00
parent c6a147257a
commit c2bc47a399
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
4 changed files with 25 additions and 0 deletions

View File

@ -87,6 +87,13 @@ _main_getopt(c3_i argc, c3_c** argv)
u3_Host.ops_u.hap_w = 50000;
u3_Host.ops_u.kno_w = DefaultKernel;
u3_Host.ops_u.arg_v = c3_malloc((argc + 1) * sizeof(c3_c*));
for ( ch_i = 0; ch_i < argc; ch_i++ ) {
u3_Host.ops_u.arg_v[ch_i] = strdup(argv[ch_i]);
}
u3_Host.ops_u.arg_v[argc] = 0;
u3l_log("%s %d\n", u3_Host.ops_u.arg_v[0], argc);
while ( -1 != (ch_i=getopt(argc, argv,
"X:Y:G:J:B:b:K:A:H:I:C:w:u:e:F:k:n:p:r:i:Z:LljacdgqstvxPDRS")) )
{

View File

@ -20,6 +20,7 @@
# define c3__any c3_s3('a','n','y')
# define c3__ap c3_s2('a','p')
# define c3__apen c3_s4('a','p','e','n')
# define c3__args c3_s4('a','r','g','s')
# define c3__aro c3_s3('a','r','o')
# define c3__arvo c3_s4('a','r','v','o')
# define c3__ash c3_s3('a','s','h')

View File

@ -270,6 +270,7 @@
/* u3_opts: command line configuration.
*/
typedef struct _u3_opts {
c3_c** arg_v; // NULL-terminated raw arguments
c3_c* arv_c; // -A, initial sync from
c3_o abo; // -a, abort aggressively
c3_c* pil_c; // -B, bootstrap from

View File

@ -453,6 +453,22 @@ _conn_run_peel(u3_conn* con_u, u3_chan* can_u, u3_noun rid, u3_noun dat)
res = u3nt(u3_nul, u3_nul, con_u->kan_o);
break;
}
// raw command-line options.
//
case c3__args: {
c3_c** arg_c;
res = u3_nul;
for ( arg_c = u3_Host.ops_u.arg_v; 0 != *arg_c; arg_c++ ) {
u3l_log("%p\n", *arg_c);
u3l_log("%s\n", *arg_c);
res = u3nc(u3i_string(*arg_c), res);
}
u3l_log("here\n");
res = u3v_do("flop", res);
u3l_log("here\n");
break;
}
// vere version.
//
case c3__v: {