1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-13 00:09:51 +02:00

* ksutil.h, gpgkeys_curl.c, gpgkeys_hkp.c, gpgkeys_ldap.c,

gpgkeys_finger.c, gpgkeys_http.c: Part 2 of the cleanup.  Move all the
various defines to ksutil.h.
This commit is contained in:
David Shaw 2005-01-13 23:37:26 +00:00
parent 0a42f97e43
commit 996c82ffd6
7 changed files with 51 additions and 99 deletions

View File

@ -1,5 +1,9 @@
2005-01-13 David Shaw <dshaw@jabberwocky.com> 2005-01-13 David Shaw <dshaw@jabberwocky.com>
* ksutil.h, gpgkeys_curl.c, gpgkeys_hkp.c, gpgkeys_ldap.c,
gpgkeys_finger.c, gpgkeys_http.c: Part 2 of the cleanup. Move all
the various defines to ksutil.h.
* gpgkeys_finger.c, gpgkeys_hkp.c, gpgkeys_http.c, gpgkeys_ldap.c: * gpgkeys_finger.c, gpgkeys_hkp.c, gpgkeys_http.c, gpgkeys_ldap.c:
Part 1 of a minor cleanup to use #defines instead of hard-coded Part 1 of a minor cleanup to use #defines instead of hard-coded
sizes. sizes.

View File

@ -1,5 +1,5 @@
/* gpgkeys_curl.c - fetch a key via libcurl /* gpgkeys_curl.c - fetch a key via libcurl
* Copyright (C) 2004 Free Software Foundation, Inc. * Copyright (C) 2004, 2005 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -34,20 +34,6 @@
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
#define GET 0
#define MAX_LINE 80
#define MAX_SCHEME 20
#define MAX_AUTH 128
#define MAX_HOST 80
#define MAX_PORT 10
#define MAX_PATH 1024
#define MAX_PROXY 128
#define MAX_URL (MAX_SCHEME+1+3+MAX_AUTH+1+1+MAX_HOST+1+1+MAX_PORT+1+1+MAX_PATH+1+50)
#define STRINGIFY(x) #x
#define MKSTRING(x) STRINGIFY(x)
static int verbose=0; static int verbose=0;
static char scheme[MAX_SCHEME+1],auth[MAX_AUTH+1],host[MAX_HOST+1]={'\0'},port[MAX_PORT+1]={'\0'},path[MAX_PATH+1]={'\0'},proxy[MAX_PROXY+1]={'\0'}; static char scheme[MAX_SCHEME+1],auth[MAX_AUTH+1],host[MAX_HOST+1]={'\0'},port[MAX_PORT+1]={'\0'},path[MAX_PATH+1]={'\0'},proxy[MAX_PROXY+1]={'\0'};
static FILE *input=NULL,*output=NULL,*console=NULL; static FILE *input=NULL,*output=NULL,*console=NULL;
@ -187,8 +173,8 @@ main(int argc,char *argv[])
while(fgets(line,MAX_LINE,input)!=NULL) while(fgets(line,MAX_LINE,input)!=NULL)
{ {
int version; int version;
char commandstr[7]; char command[MAX_COMMAND+1];
char optionstr[256]; char option[MAX_OPTION+1];
char hash; char hash;
if(line[0]=='\n') if(line[0]=='\n')
@ -197,11 +183,11 @@ main(int argc,char *argv[])
if(sscanf(line,"%c",&hash)==1 && hash=='#') if(sscanf(line,"%c",&hash)==1 && hash=='#')
continue; continue;
if(sscanf(line,"COMMAND %6s\n",commandstr)==1) if(sscanf(line,"COMMAND %" MKSTRING(MAX_COMMAND) "s\n",command)==1)
{ {
commandstr[6]='\0'; command[MAX_COMMAND]='\0';
if(strcasecmp(commandstr,"get")==0) if(strcasecmp(command,"get")==0)
action=GET; action=GET;
continue; continue;
@ -248,17 +234,17 @@ main(int argc,char *argv[])
continue; continue;
} }
if(sscanf(line,"OPTION %255s\n",optionstr)==1) if(sscanf(line,"OPTION %" MKSTRING(MAX_OPTION) "s\n",option)==1)
{ {
int no=0; int no=0;
char *start=&optionstr[0]; char *start=&option[0];
optionstr[255]='\0'; option[MAX_OPTION]='\0';
if(strncasecmp(optionstr,"no-",3)==0) if(strncasecmp(option,"no-",3)==0)
{ {
no=1; no=1;
start=&optionstr[3]; start=&option[3];
} }
if(strcasecmp(start,"verbose")==0) if(strcasecmp(start,"verbose")==0)

View File

@ -1,5 +1,5 @@
/* gpgkeys_finger.c - fetch a key via finger /* gpgkeys_finger.c - fetch a key via finger
* Copyright (C) 2004 Free Software Foundation, Inc. * Copyright (C) 2004, 2005 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -55,22 +55,10 @@
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
#define GET 0
#define MAX_LINE 80
#define MAX_COMMAND 7
#define MAX_OPAQUE 1024
#define MAX_OPTION 256
#define STRINGIFY(x) #x
#define MKSTRING(x) STRINGIFY(x)
static int verbose=0; static int verbose=0;
static char path[MAX_OPAQUE+1]; static char path[MAX_OPAQUE+1];
static FILE *input, *output, *console; static FILE *input, *output, *console;
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
#define END "-----END PGP PUBLIC KEY BLOCK-----"
#ifdef _WIN32 #ifdef _WIN32
static void static void
deinit_sockets (void) deinit_sockets (void)

View File

@ -1,5 +1,5 @@
/* gpgkeys_hkp.c - talk to an HKP keyserver /* gpgkeys_hkp.c - talk to an HKP keyserver
* Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. * Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -37,33 +37,11 @@
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
#define GET 0
#define SEND 1
#define SEARCH 2
#define MAX_LINE 80
#define MAX_HOST 80
#define MAX_PORT 10
#define MAX_PROXY 80
#define MAX_COMMAND 7
#define MAX_OPTION 110
#define STRINGIFY(x) #x
#define MKSTRING(x) STRINGIFY(x)
static int verbose=0,include_revoked=0,include_disabled=0; static int verbose=0,include_revoked=0,include_disabled=0;
static unsigned int http_flags=0; static unsigned int http_flags=0;
static char host[MAX_HOST+1]={'\0'},proxy[MAX_PROXY+1]={'\0'},port[MAX_PORT+1]={'\0'}; static char host[MAX_HOST+1]={'\0'},proxy[MAX_PROXY+1]={'\0'},port[MAX_PORT+1]={'\0'};
static FILE *input=NULL,*output=NULL,*console=NULL; static FILE *input=NULL,*output=NULL,*console=NULL;
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
#define END "-----END PGP PUBLIC KEY BLOCK-----"
struct keylist
{
char str[MAX_LINE];
struct keylist *next;
};
#ifdef __riscos__ #ifdef __riscos__
#define HTTP_PROXY_ENV "GnuPG$HttpProxy" #define HTTP_PROXY_ENV "GnuPG$HttpProxy"
#else #else

View File

@ -1,5 +1,5 @@
/* gpgkeys_http.c - fetch a key via HTTP /* gpgkeys_http.c - fetch a key via HTTP
* Copyright (C) 2004 Free Software Foundation, Inc. * Copyright (C) 2004, 2005 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -36,27 +36,11 @@
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
#define GET 0
#define MAX_LINE 80
#define MAX_AUTH 128
#define MAX_HOST 80
#define MAX_PROXY 80
#define MAX_PORT 10
#define MAX_PATH 1024
#define MAX_COMMAND 7
#define MAX_OPTION 256
#define STRINGIFY(x) #x
#define MKSTRING(x) STRINGIFY(x)
static int verbose=0; static int verbose=0;
static unsigned int http_flags=0; static unsigned int http_flags=0;
static char auth[MAX_AUTH+1]={'\0'},host[MAX_HOST+1]={'\0'},proxy[MAX_PROXY+1]={'\0'},port[MAX_PORT+1]={'\0'},path[MAX_PATH+1]={'\0'}; static char auth[MAX_AUTH+1]={'\0'},host[MAX_HOST+1]={'\0'},proxy[MAX_PROXY+1]={'\0'},port[MAX_PORT+1]={'\0'},path[MAX_PATH+1]={'\0'};
static FILE *input=NULL,*output=NULL,*console=NULL; static FILE *input=NULL,*output=NULL,*console=NULL;
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
#define END "-----END PGP PUBLIC KEY BLOCK-----"
#ifdef __riscos__ #ifdef __riscos__
#define HTTP_PROXY_ENV "GnuPG$HttpProxy" #define HTTP_PROXY_ENV "GnuPG$HttpProxy"
#else #else

View File

@ -1,5 +1,5 @@
/* gpgkeys_ldap.c - talk to a LDAP keyserver /* gpgkeys_ldap.c - talk to a LDAP keyserver
* Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. * Copyright (C) 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -47,19 +47,6 @@
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
#define GET 0
#define SEND 1
#define SEARCH 2
#define MAX_LINE 255
#define MAX_HOST 80
#define MAX_SCHEME 20
#define MAX_PORT 10
#define MAX_OPTION 255
#define MAX_COMMAND 7
#define STRINGIFY(x) #x
#define MKSTRING(x) STRINGIFY(x)
static int verbose=0,include_disabled=0,include_revoked=0,include_subkeys=0; static int verbose=0,include_disabled=0,include_revoked=0,include_subkeys=0;
static int real_ldap=0; static int real_ldap=0;
static char *basekeyspacedn=NULL; static char *basekeyspacedn=NULL;
@ -73,12 +60,6 @@ static LDAP *ldap=NULL;
time_t timegm(struct tm *tm); time_t timegm(struct tm *tm);
#endif #endif
struct keylist
{
char str[MAX_LINE];
struct keylist *next;
};
static int static int
ldap_err_to_gpg_err(int err) ldap_err_to_gpg_err(int err)
{ {

View File

@ -1,5 +1,5 @@
/* ksutil.h /* ksutil.h
* Copyright (C) 2004 Free Software Foundation, Inc. * Copyright (C) 2004, 2005 Free Software Foundation, Inc.
* *
* This file is part of GNUPG. * This file is part of GNUPG.
* *
@ -21,6 +21,37 @@
#ifndef _KSUTIL_H_ #ifndef _KSUTIL_H_
#define _KSUTIL_H_ #define _KSUTIL_H_
#define GET 0
#define SEND 1
#define SEARCH 2
/* MAX_LINE must be 1 larger than the largest item we expect to
receive. */
#define MAX_LINE 1080
#define MAX_COMMAND 6
#define MAX_OPTION 256
#define MAX_SCHEME 20
#define MAX_OPAQUE 1024
#define MAX_AUTH 128
#define MAX_HOST 80
#define MAX_PORT 10
#define MAX_PATH 1024
#define MAX_PROXY 128
#define MAX_URL (MAX_SCHEME+1+3+MAX_AUTH+1+1+MAX_HOST+1+1+MAX_PORT+1+1+MAX_PATH+1+50)
#define STRINGIFY(x) #x
#define MKSTRING(x) STRINGIFY(x)
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
#define END "-----END PGP PUBLIC KEY BLOCK-----"
struct keylist
{
char str[MAX_LINE];
struct keylist *next;
};
/* 30 seconds seems reasonable */ /* 30 seconds seems reasonable */
#define DEFAULT_KEYSERVER_TIMEOUT 30 #define DEFAULT_KEYSERVER_TIMEOUT 30