projects
/
u
/
mdw
/
catacomb
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2d3bea9
)
In `key list', show timezone for local times, and support `-u' option
author
mdw
<mdw>
Fri, 15 Oct 1999 21:05:28 +0000
(21:05 +0000)
committer
mdw
<mdw>
Fri, 15 Oct 1999 21:05:28 +0000
(21:05 +0000)
for UTC output.
keyutil.c
patch
|
blob
|
blame
|
history
diff --git
a/keyutil.c
b/keyutil.c
index
adf8c50
..
9219ef5
100644
(file)
--- a/
keyutil.c
+++ b/
keyutil.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: keyutil.c,v 1.
1 1999/09/03 08:41:12
mdw Exp $
+ * $Id: keyutil.c,v 1.
2 1999/10/15 21:05:28
mdw Exp $
*
* Simple key manager program
*
*
* Simple key manager program
*
@@
-30,6
+30,10
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: keyutil.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: keyutil.c,v $
+ * Revision 1.2 1999/10/15 21:05:28 mdw
+ * In `key list', show timezone for local times, and support `-u' option
+ * for UTC output.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
@@
-338,7
+342,8
@@
static int cmd_list(int argc, char *argv[])
enum {
f_bogus = 1,
f_newline = 2,
enum {
f_bogus = 1,
f_newline = 2,
- f_attr = 4
+ f_attr = 4,
+ f_utc = 8
};
/* --- Parse subcommand options --- */
};
/* --- Parse subcommand options --- */
@@
-347,13
+352,17
@@
static int cmd_list(int argc, char *argv[])
static struct option opt[] = {
{ "quiet", 0, 0, 'q' },
{ "verbose", 0, 0, 'v' },
static struct option opt[] = {
{ "quiet", 0, 0, 'q' },
{ "verbose", 0, 0, 'v' },
+ { "utc", 0, 0, 'u' },
{ 0, 0, 0, 0 }
};
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "qv", opt, 0, 0, 0);
+ int i = mdwopt(argc, argv, "
+u
qv", opt, 0, 0, 0);
if (i < 0)
break;
switch (i) {
if (i < 0)
break;
switch (i) {
+ case 'u':
+ fl |= f_utc;
+ break;
case 'q':
if (v)
v--;
case 'q':
if (v)
v--;
@@
-368,7
+377,7
@@
static int cmd_list(int argc, char *argv[])
}
if (fl & f_bogus || optind != argc)
}
if (fl & f_bogus || optind != argc)
- die(EXIT_FAILURE, "Usage: list [-qv]");
+ die(EXIT_FAILURE, "Usage: list [-
u
qv]");
/* --- Open the key file --- */
/* --- Open the key file --- */
@@
-377,7
+386,12
@@
static int cmd_list(int argc, char *argv[])
/* --- Write the header --- */
/* --- Write the header --- */
- tfmt = v ? "%Y-%m-%d %H:%M:%S" : "%Y-%m-%d";
+ if (!v)
+ tfmt = "%Y-%m-%d";
+ else if (fl & f_utc)
+ tfmt = "%Y-%m-%d %H:%M:%S UTC";
+ else
+ tfmt = "%Y-%m-%d %H:%M:%S %Z";
/* --- Now iterate through the keys --- */
/* --- Now iterate through the keys --- */
@@
-399,7
+413,7
@@
static int cmd_list(int argc, char *argv[])
if (k->exp == KEXP_FOREVER)
strcpy(ebuf, "forever");
else {
if (k->exp == KEXP_FOREVER)
strcpy(ebuf, "forever");
else {
- tm = localtime(&k->exp);
+ tm =
(fl & f_utc) ? gmtime(&k->exp) :
localtime(&k->exp);
strftime(ebuf, sizeof(ebuf), tfmt, tm);
}
strftime(ebuf, sizeof(ebuf), tfmt, tm);
}
@@
-567,7
+581,7
@@
static struct cmd {
{ "delete", cmd_delete, "delete KEYID..." },
{ "setattr", cmd_setattr, "setattr KEYID ATTR..." },
{ "comment", cmd_comment, "comment KEYID [COMMENT]" },
{ "delete", cmd_delete, "delete KEYID..." },
{ "setattr", cmd_setattr, "setattr KEYID ATTR..." },
{ "comment", cmd_comment, "comment KEYID [COMMENT]" },
- { "list", cmd_list, "list [-qv]" },
+ { "list", cmd_list, "list [-
u
qv]" },
{ "tidy", cmd_tidy, "tidy" },
{ "extract", cmd_extract, "extract FILE KEYID..." },
{ "merge", cmd_merge, "merge FILE" },
{ "tidy", cmd_tidy, "tidy" },
{ "extract", cmd_extract, "extract FILE KEYID..." },
{ "merge", cmd_merge, "merge FILE" },