date and time created 89/02/03 22:03:45 by kfall
[unix-history] / usr / src / old / athena / kdestroy / kdestroy.c
CommitLineData
b5c8ab0a
KF
1/*
2 * $Source: /mit/kerberos/src/kuser/RCS/kdestroy.c,v $
3 * $Author: steiner $
4 *
5 * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
6 *
7 * For copying and distribution information, please see the file
8 * <mit-copyright.h>.
9 *
10 * This program causes Kerberos tickets to be destroyed.
11 * Options are:
12 *
13 * -q[uiet] - no bell even if tickets not destroyed
14 * -f[orce] - no message printed at all
15 */
16
17#include <mit-copyright.h>
18
19#ifndef lint
20static char rcsid_kdestroy_c[] =
21"$Header: kdestroy.c,v 4.5 88/03/18 15:16:02 steiner Exp $";
22#endif lint
23
24#include <stdio.h>
25#include <krb.h>
26#ifdef BSD42
27#include <strings.h>
28#endif BSD42
29
30
31static char *pname;
32
33static usage()
34{
35 fprintf(stderr, "Usage: %s [-f] [-q]\n", pname);
36 exit(1);
37}
38
39main(argc, argv)
40 char *argv[];
41{
42 int fflag=0, qflag=0, k_errno;
43 register char *cp;
44
45 cp = rindex (argv[0], '/');
46 if (cp == NULL)
47 pname = argv[0];
48 else
49 pname = cp+1;
50
51 if (argc > 2)
52 usage();
53 else if (argc == 2) {
54 if (!strcmp(argv[1], "-f"))
55 ++fflag;
56 else if (!strcmp(argv[1], "-q"))
57 ++qflag;
58 else usage();
59 }
60
61 k_errno = dest_tkt();
62
63 if (fflag) {
64 if (k_errno != 0 && k_errno != RET_TKFIL)
65 exit(1);
66 else
67 exit(0);
68 } else {
69 if (k_errno == 0)
70 printf("Tickets destroyed.\n");
71 else if (k_errno == RET_TKFIL)
72 fprintf(stderr, "No tickets to destroy.\n");
73 else {
74 fprintf(stderr, "Tickets NOT destroyed.\n");
75 if (!qflag)
76 fprintf(stderr, "\007");
77 exit(1);
78 }
79 }
80 exit(0);
81}