summaryrefslogtreecommitdiff
path: root/clients/xzwrite
diff options
context:
space:
mode:
authorGravatar Barry Jaspan <bjaspan@mit.edu>1991-11-15 13:25:51 +0000
committerGravatar Barry Jaspan <bjaspan@mit.edu>1991-11-15 13:25:51 +0000
commitbd7ecb954270b8a1282f44b7926424f2d839d0a4 (patch)
treee947d26274fdd7f7b1ee70bbfc203bd2c25a91d7 /clients/xzwrite
parentbc397d2887ebc73244b79b2923e6182ba33c6070 (diff)
use passwd information when no signature is defined
Diffstat (limited to 'clients/xzwrite')
-rw-r--r--clients/xzwrite/xzwrite.c60
1 files changed, 47 insertions, 13 deletions
diff --git a/clients/xzwrite/xzwrite.c b/clients/xzwrite/xzwrite.c
index 51bf21d..6e04ad3 100644
--- a/clients/xzwrite/xzwrite.c
+++ b/clients/xzwrite/xzwrite.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <pwd.h>
#include "xzwrite.h"
@@ -8,25 +9,15 @@ main(argc, argv)
int argc;
char **argv;
{
+ char sigbfr[BUFSIZ];
+
zeph_init();
build_interface(&argc, argv);
if (argc > 1) usage();
- /* Do magic with signature */
- if (! *defs.signature) {
- char *sig;
-
- sig = (char *) zeph_get_signature();
- if (sig) {
- defs.signature = (char *) Malloc(strlen(sig) + 1,
- "getting signature",
- NULL);
- strcpy(defs.signature, sig);
- }
- }
-
+ set_signature();
dest_init();
yank_init();
edit_win_init();
@@ -42,6 +33,49 @@ main(argc, argv)
go();
}
+set_signature()
+{
+ char *sig, sigbfr[BUFSIZ];
+
+ /* Do magic with signature */
+ if (*defs.signature)
+ return;
+
+ sig = (char *) zeph_get_signature();
+ if (!sig) {
+ /* try to find name in the password file */
+ register struct passwd *pwd;
+ register char *cp = sigbfr;
+ register char *cp2, *pp;
+
+ pwd = getpwuid(getuid());
+ if (pwd) {
+ cp2 = pwd->pw_gecos;
+ for (; *cp2 && *cp2 != ',' ; cp2++) {
+ if (*cp2 == '&') {
+ pp = pwd->pw_name;
+ *cp++ = islower(*pp) ? toupper(*pp) : *pp;
+ pp++;
+ while (*pp)
+ *cp++ = *pp++;
+ } else
+ *cp++ = *cp2;
+ }
+ *cp = '\0';
+ sig = sigbfr;
+ }
+ }
+
+ if (sig) {
+ defs.signature = (char *) Malloc(strlen(sig) + 1,
+ "getting signature",
+ NULL);
+ strcpy(defs.signature, sig);
+ }
+}
+
+
+
usage()
{
fprintf(stderr, "Usage: xzwrite [ -toolkitoption ... ] [-s signature] [+d | -d] [+n | -n]\n\t[+v | -v] [+yd | -yd] [+av | -av] [+ci | -ci] [-my yanks]\n\t[+l | -l] [+a | -a] [+x | -x] [+z | -z] [+pong | -pong] [+reply | -reply]\n");