1 /*- 2 * Copyright (c) 2010 Alistair Crooks <agc@NetBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 #include <sys/types.h> 26 27 #include <inttypes.h> 28 #include <netpgp.h> 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <string.h> 32 #include <unistd.h> 33 34 #include "hkpc.h" 35 36 int 37 main(int argc, char **argv) 38 { 39 char *res; 40 char server[BUFSIZ]; 41 int family; 42 int port; 43 int i; 44 45 port = 11371; 46 family = 4; 47 (void) snprintf(server, sizeof(server), "localhost"); 48 while ((i = getopt(argc, argv, "f:h:p:")) != -1) { 49 switch(i) { 50 case 'f': 51 family = atoi(optarg); 52 break; 53 case 'h': 54 (void) snprintf(server, sizeof(server), optarg); 55 break; 56 case 'p': 57 port = atoi(optarg); 58 break; 59 default: 60 break; 61 } 62 } 63 for (i = optind + 1 ; i < argc ; i++) { 64 if (hkpc_get(&res, server, port, family, argv[optind], argv[i])) { 65 hkpc_print_key(stdout, argv[optind], res); 66 } 67 } 68 exit(EXIT_SUCCESS); 69 } 70