the form
.IB command : arg \c
.BR : ...
+(The delimiter character can be changed using the
+.B \-d
+command-line option.)
A list of directives can be stored in a file, one per line, and included
using the
.B include
.B "\-u, \-\-usage"
Write a usage message to standard output, and exit successfully.
.TP
+.BI "\-d, \-\-delimiter=" char
+Use
+.I char
+as the delimiter to separate argument names in directives, rather than
+.RB ` : '.
+.TP
.BI "\-k, \-\-keyring=" file
Read keys from
.IR file .
.SS "Directives"
A directive is ignored if it is empty, or if its first character is a
.RB ` # '.
+Directives consist of a name followed by zero or more arguments,
+separated by a delimiter character. The default delimiter is
+.RB ` : ',
+but this can be overridden using the
+.B \-d
+option (see above); this manual uses
+.RB ` : '
+consistently as the delimiter character.
The following directives are recognized.
.TP
.BI peer: name : local-port : remote-addr : remote-port
static unsigned npeer = 0;
static key_file keys;
static grand *rng;
+static const char *delim = ":";
#define PASS(f, buf, sz) ((f) ? (f)->func((f), (buf), (sz)) : (void)0)
#define RND(i) (rng->ops->range(rng, (i)))
unsigned c = 0;
const struct cmdtab *ct;
- p = strtok(p, ":");
+ p = strtok(p, delim);
if (!p || *p == '#') return;
do {
v[c++] = p;
- p = strtok(0, ":");
+ p = strtok(0, delim);
} while (p && c < AVMAX - 1);
v[c] = 0;
for (ct = cmdtab; ct->name; ct++) {
{ pquis(fp, "$, TrIPE version " VERSION "\n"); }
static void usage(FILE *fp)
- { pquis(fp, "Usage: $ [-k KEYRING] DIRECTIVE...\n"); }
+ { pquis(fp, "Usage: $ [-d CHAR] [-k KEYRING] DIRECTIVE...\n"); }
static void help(FILE *fp)
{
-v, --version Show the version number.\n\
-u, --usage Show terse usage summary.\n\
\n\
+-d, --delimiter=CHAR Use CHAR rather than `:' as delimiter.\n\
-k, --keyring=FILE Fetch keys from FILE.\n\
\n\
Directives:\n\
{ "help", 0, 0, 'h' },
{ "version", 0, 0, 'v' },
{ "usage", 0, 0, 'u' },
+ { "delimiter", OPTF_ARGREQ, 0, 'd' },
{ "keyring", OPTF_ARGREQ, 0, 'k' },
{ 0, 0, 0, 0 }
};
- if ((i = mdwopt(argc, argv, "hvuk:", opt, 0, 0, 0)) < 0) break;
+ if ((i = mdwopt(argc, argv, "hvud:k:", opt, 0, 0, 0)) < 0) break;
switch (i) {
case 'h': help(stdout); exit(0);
case 'v': version(stdout); exit(0);
case 'u': usage(stdout); exit(0);
+ case 'd':
+ if (!optarg[0] || optarg[1])
+ die(1, "delimiter must be a single character");
+ delim = optarg;
+ break;
case 'k': kfname = optarg; break;
default: f |= f_bogus; break;
}