summaryrefslogtreecommitdiff
path: root/clients/xzwrite/xzwrite.c
blob: 6e04ad39fd41f021d76d552401bd6fce121665f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <stdio.h>
#include <pwd.h>

#include "xzwrite.h"

extern Defaults defs;

main(argc, argv)
   int	argc;
   char	**argv;
{
     char sigbfr[BUFSIZ];
     
     zeph_init();

     build_interface(&argc, argv);

     if (argc > 1) usage();

     set_signature();
     dest_init();
     yank_init();
     edit_win_init();
     menu_match_defs();
     (void) load_default_dest();
     display_dest();

     if (defs.track_logins)
	  logins_subscribe();
     if (defs.auto_reply)
	  zeph_subto_replies();

     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");
     exit(1);
}