1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright (C) 1992,1993 Trusted Information Systems, Inc. 4 * 5 * Permission to include this software in the Kerberos V5 distribution 6 * was graciously provided by Trusted Information Systems. 7 * 8 * Trusted Information Systems makes no representation about the 9 * suitability of this software for any purpose. It is provided 10 * "as is" without express or implied warranty. 11 * 12 * Copyright (C) 1994 Massachusetts Institute of Technology 13 * 14 * Export of this software from the United States of America may 15 * require a specific license from the United States Government. 16 * It is the responsibility of any person or organization contemplating 17 * export to obtain such a license before exporting. 18 * 19 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 20 * distribute this software and its documentation for any purpose and 21 * without fee is hereby granted, provided that the above copyright 22 * notice appear in all copies and that both that copyright notice and 23 * this permission notice appear in supporting documentation, and that 24 * the name of M.I.T. not be used in advertising or publicity pertaining 25 * to distribution of the software without specific, written prior 26 * permission. Furthermore if you modify this software you must label 27 * your software as modified software and not distribute it in such a 28 * fashion that it might be confused with the original M.I.T. software. 29 * M.I.T. makes no representations about the suitability of 30 * this software for any purpose. It is provided "as is" without express 31 * or implied warranty. 32 */ 33 34 /* Split out from "#ifdef STANDALONE" code previously in trval.c, so 35 that trval.o could be linked into other tests too without the 36 -DSTANDALONE code. */ 37 #include "trval.c" 38 39 static void usage() 40 { 41 fprintf(stderr, "Usage: trval [--types] [--krb5] [--krb5decode] [--hex] [-notypebytes] [file]\n"); 42 exit(1); 43 } 44 45 /* 46 * Returns true if the option was selected. Allow "-option" and 47 * "--option" syntax, since we used to accept only "-option" 48 */ 49 static 50 int check_option(word, option) 51 char *word; 52 char *option; 53 { 54 if (word[0] != '-') 55 return 0; 56 if (word[1] == '-') 57 word++; 58 if (strcmp(word+1, option)) 59 return 0; 60 return 1; 61 } 62 63 int main(argc, argv) 64 int argc; 65 char **argv; 66 { 67 int optflg = 1; 68 FILE *fp; 69 int r = 0; 70 71 while (--argc > 0) { 72 argv++; 73 if (optflg && *(argv)[0] == '-') { 74 if (check_option(*argv, "help")) 75 usage(); 76 else if (check_option(*argv, "types")) 77 print_types = 1; 78 else if (check_option(*argv, "notypes")) 79 print_types = 0; 80 else if (check_option(*argv, "krb5")) 81 print_krb5_types = 1; 82 else if (check_option(*argv, "hex")) 83 do_hex = 1; 84 else if (check_option(*argv, "notypebytes")) 85 print_id_and_len = 0; 86 else if (check_option(*argv, "krb5decode")) { 87 print_id_and_len = 0; 88 print_krb5_types = 1; 89 print_types = 1; 90 } else { 91 fprintf(stderr,"trval: unknown option: %s\n", *argv); 92 usage(); 93 } 94 } else { 95 optflg = 0; 96 if ((fp = fopen(*argv,"r")) == NULL) { 97 fprintf(stderr,"trval: unable to open %s\n", *argv); 98 continue; 99 } 100 r = trval(fp, stdout); 101 fclose(fp); 102 } 103 } 104 if (optflg) r = trval(stdin, stdout); 105 106 exit(r); 107 } 108