xref: /csrg-svn/old/athena/kdestroy/kdestroy.c (revision 36661)
136652Skfall /*
236652Skfall  * $Source: /mit/kerberos/src/kuser/RCS/kdestroy.c,v $
336652Skfall  * $Author: steiner $
436652Skfall  *
536652Skfall  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
636652Skfall  *
736652Skfall  * For copying and distribution information, please see the file
836652Skfall  * <mit-copyright.h>.
936652Skfall  *
1036652Skfall  * This program causes Kerberos tickets to be destroyed.
1136652Skfall  * Options are:
1236652Skfall  *
1336652Skfall  *   -q[uiet]	- no bell even if tickets not destroyed
1436652Skfall  *   -f[orce]	- no message printed at all
1536652Skfall  */
1636652Skfall 
17*36661Skfall #include <kerberos/mit-copyright.h>
1836652Skfall 
1936652Skfall #ifndef	lint
2036652Skfall static char rcsid_kdestroy_c[] =
2136652Skfall "$Header: kdestroy.c,v 4.5 88/03/18 15:16:02 steiner Exp $";
2236652Skfall #endif	lint
2336652Skfall 
2436652Skfall #include <stdio.h>
25*36661Skfall #include <kerberos/krb.h>
2636652Skfall #include <strings.h>
2736652Skfall 
2836652Skfall static char *pname;
2936652Skfall 
3036652Skfall 
main(argc,argv)3136652Skfall main(argc, argv)
3236652Skfall     char   *argv[];
3336652Skfall {
3436652Skfall     int     fflag=0, qflag=0, k_errno;
3536652Skfall     register char *cp;
3636652Skfall 
3736652Skfall     cp = rindex (argv[0], '/');
3836652Skfall     if (cp == NULL)
3936652Skfall 	pname = argv[0];
4036652Skfall     else
4136652Skfall 	pname = cp+1;
4236652Skfall 
4336652Skfall     if (argc > 2)
4436652Skfall 	usage();
4536652Skfall     else if (argc == 2) {
4636652Skfall 	if (!strcmp(argv[1], "-f"))
4736652Skfall 	    ++fflag;
4836652Skfall 	else if (!strcmp(argv[1], "-q"))
4936652Skfall 	    ++qflag;
5036652Skfall 	else usage();
5136652Skfall     }
5236652Skfall 
5336652Skfall     k_errno = dest_tkt();
5436652Skfall 
5536652Skfall     if (fflag) {
56*36661Skfall 	if (k_errno != KSUCCESS && k_errno != RET_TKFIL)
5736652Skfall 	    exit(1);
5836652Skfall 	else
5936652Skfall 	    exit(0);
6036652Skfall     } else {
61*36661Skfall 	if (k_errno == KSUCCESS)
6236652Skfall 	    printf("Tickets destroyed.\n");
6336652Skfall 	else if (k_errno == RET_TKFIL)
6436652Skfall 	    fprintf(stderr, "No tickets to destroy.\n");
6536652Skfall 	else {
6636652Skfall 	    fprintf(stderr, "Tickets NOT destroyed.\n");
6736652Skfall 	    if (!qflag)
6836652Skfall 		fprintf(stderr, "\007");
6936652Skfall 	    exit(1);
7036652Skfall 	}
7136652Skfall     }
7236652Skfall     exit(0);
7336652Skfall }
74*36661Skfall 
usage()75*36661Skfall static usage()
76*36661Skfall {
77*36661Skfall     fprintf(stderr, "Usage: %s [-f] [-q]\n", pname);
78*36661Skfall     exit(1);
79*36661Skfall }
80