xref: /openbsd/lib/libkeynote/keynote-main.c (revision db3296cf)
1 /* $OpenBSD: keynote-main.c,v 1.9 2003/07/05 17:01:49 deraadt 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 with or 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	mainusage(void);
48 
49 void
50 mainusage(void)
51 {
52     fprintf(stderr, "Usage:\n");
53     fprintf(stderr, "\tsign ...\n");
54     fprintf(stderr, "\tsigver ...\n");
55     fprintf(stderr, "\tverify ...\n");
56     fprintf(stderr, "\tkeygen ...\n");
57     fprintf(stderr, "Issue one of the commands by itself to get more help, "
58 		    "e.g., keynote sign\n");
59 }
60 
61 int
62 main(int argc, char *argv[])
63 {
64     if (argc < 2)
65     {
66 	mainusage();
67 	exit(1);
68     }
69 
70     if (!strcmp(argv[1], "sign"))
71       keynote_sign(argc - 1, argv + 1);
72     else
73       if (!strcmp(argv[1], "verify"))
74 	keynote_verify(argc - 1, argv + 1);
75       else
76 	if (!strcmp(argv[1], "sigver"))
77 	  keynote_sigver(argc - 1, argv + 1);
78 	else
79 	  if (!strcmp(argv[1], "keygen"))
80 	    keynote_keygen(argc - 1, argv + 1);
81 
82     mainusage();
83     exit(1);
84 }
85