xref: /openbsd-src/lib/libkeynote/keynote-main.c (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /* $OpenBSD: keynote-main.c,v 1.7 2001/03/08 21:50:11 angelos Exp $ */
2 /*
3  * The author of this code is Angelos D. Keromytis (angelos@dsl.cis.upenn.edu)
4  *
5  * This code was written by Angelos D. Keromytis in Philadelphia, PA, USA,
6  * in April-May 1998
7  *
8  * Copyright (C) 1998, 1999 by Angelos D. Keromytis.
9  *
10  * Permission to use, copy, and modify this software without fee
11  * is hereby granted, provided that this entire notice is included in
12  * all copies of any software which is or includes a copy or
13  * modification of this software.
14  *
15  * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
16  * IMPLIED WARRANTY. IN PARTICULAR, THE AUTHORS MAKES NO
17  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
18  * MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
19  * PURPOSE.
20  */
21 
22 #if HAVE_CONFIG_H
23 #include "config.h"
24 #endif /* HAVE_CONFIG_H */
25 
26 #include <sys/types.h>
27 #include <sys/stat.h>
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <ctype.h>
31 
32 #if STDC_HEADERS
33 #include <string.h>
34 #endif /* STDC_HEADERS */
35 
36 #if HAVE_FCNTL_H
37 #include <fcntl.h>
38 #endif /* HAVE_FCNTL_H */
39 #ifdef WIN32
40 #include <io.h>
41 #else
42 #include <unistd.h>
43 #endif /* WIN32 */
44 
45 #include "header.h"
46 
47 void
48 mainusage()
49 {
50     fprintf(stderr, "Usage:\n");
51     fprintf(stderr, "\tsign ...\n");
52     fprintf(stderr, "\tsigver ...\n");
53     fprintf(stderr, "\tverify ...\n");
54     fprintf(stderr, "\tkeygen ...\n");
55     fprintf(stderr, "Issue one of the commands by itself to get more help, "
56 		    "e.g., keynote sign\n");
57 }
58 
59 int
60 main(int argc, char *argv[])
61 {
62     if (argc < 2)
63     {
64 	mainusage();
65 	exit(1);
66     }
67 
68     if (!strcmp(argv[1], "sign"))
69       keynote_sign(argc - 1, argv + 1);
70     else
71       if (!strcmp(argv[1], "verify"))
72 	keynote_verify(argc - 1, argv + 1);
73       else
74 	if (!strcmp(argv[1], "sigver"))
75 	  keynote_sigver(argc - 1, argv + 1);
76 	else
77 	  if (!strcmp(argv[1], "keygen"))
78 	    keynote_keygen(argc - 1, argv + 1);
79 
80     mainusage();
81     exit(1);
82 }
83