2004-10-13 20:30:29 +02:00
|
|
|
/* ksutil.h
|
2005-01-14 00:37:26 +01:00
|
|
|
* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
2004-10-13 20:30:29 +02:00
|
|
|
*
|
|
|
|
* This file is part of GNUPG.
|
|
|
|
*
|
|
|
|
* GNUPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GNUPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-05-31 10:39:18 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
2004-10-13 20:30:29 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _KSUTIL_H_
|
|
|
|
#define _KSUTIL_H_
|
|
|
|
|
2005-05-04 15:34:25 +02:00
|
|
|
#ifdef HAVE_LIBCURL
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#else
|
2005-04-16 20:50:46 +02:00
|
|
|
#ifdef FAKE_CURL
|
|
|
|
#include "curl-shim.h"
|
2005-05-04 15:34:25 +02:00
|
|
|
#endif
|
2005-04-16 20:50:46 +02:00
|
|
|
#endif
|
|
|
|
|
2005-05-02 02:46:39 +02:00
|
|
|
/* MAX_LINE must be at least 1 larger than the largest item we expect
|
|
|
|
to receive, including the name tag ("COMMAND", "PORT", etc) and
|
|
|
|
space between. In practice, that means it should be
|
|
|
|
strlen("OPAQUE")+1+sizeof_opaque+1 */
|
|
|
|
#define MAX_LINE (6+1+1024+1)
|
2005-01-14 00:37:26 +01:00
|
|
|
|
2005-12-23 21:51:48 +01:00
|
|
|
#define MAX_COMMAND 7
|
2005-01-14 00:37:26 +01:00
|
|
|
#define MAX_OPTION 256
|
|
|
|
#define MAX_SCHEME 20
|
|
|
|
#define MAX_OPAQUE 1024
|
|
|
|
#define MAX_AUTH 128
|
|
|
|
#define MAX_HOST 80
|
|
|
|
#define MAX_PORT 10
|
2005-01-18 12:16:10 +01:00
|
|
|
#define URLMAX_PATH 1024
|
2005-01-14 00:37:26 +01:00
|
|
|
#define MAX_PROXY 128
|
2005-01-18 12:16:10 +01:00
|
|
|
#define MAX_URL (MAX_SCHEME+1+3+MAX_AUTH+1+1+MAX_HOST+1+1 \
|
|
|
|
+MAX_PORT+1+1+URLMAX_PATH+1+50)
|
2005-01-14 00:37:26 +01:00
|
|
|
|
|
|
|
#define STRINGIFY(x) #x
|
|
|
|
#define MKSTRING(x) STRINGIFY(x)
|
|
|
|
|
|
|
|
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
|
|
|
|
#define END "-----END PGP PUBLIC KEY BLOCK-----"
|
|
|
|
|
2005-04-16 20:50:46 +02:00
|
|
|
#ifdef __riscos__
|
|
|
|
#define HTTP_PROXY_ENV "GnuPG$HttpProxy"
|
|
|
|
#else
|
|
|
|
#define HTTP_PROXY_ENV "http_proxy"
|
|
|
|
#endif
|
|
|
|
|
2005-01-14 00:37:26 +01:00
|
|
|
struct keylist
|
|
|
|
{
|
|
|
|
char str[MAX_LINE];
|
|
|
|
struct keylist *next;
|
|
|
|
};
|
|
|
|
|
2005-02-01 18:08:18 +01:00
|
|
|
/* 2 minutes seems reasonable */
|
|
|
|
#define DEFAULT_KEYSERVER_TIMEOUT 120
|
2004-10-13 20:30:29 +02:00
|
|
|
|
|
|
|
unsigned int set_timeout(unsigned int seconds);
|
|
|
|
int register_timeout(void);
|
|
|
|
|
2005-12-23 21:51:48 +01:00
|
|
|
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_GETNAME,KS_SEND,KS_SEARCH};
|
2005-03-17 00:46:07 +01:00
|
|
|
|
2005-08-26 06:24:46 +02:00
|
|
|
enum ks_search_type {KS_SEARCH_SUBSTR,KS_SEARCH_EXACT,
|
|
|
|
KS_SEARCH_MAIL,KS_SEARCH_MAILSUB};
|
|
|
|
|
2005-03-16 16:17:03 +01:00
|
|
|
struct ks_options
|
|
|
|
{
|
2005-03-17 00:46:07 +01:00
|
|
|
enum ks_action action;
|
2005-03-16 16:17:03 +01:00
|
|
|
char *host;
|
|
|
|
char *port;
|
|
|
|
char *scheme;
|
|
|
|
char *auth;
|
|
|
|
char *path;
|
2005-03-17 17:42:41 +01:00
|
|
|
char *opaque;
|
2005-03-16 16:17:03 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned int include_disabled:1;
|
|
|
|
unsigned int include_revoked:1;
|
|
|
|
unsigned int include_subkeys:1;
|
|
|
|
unsigned int check_cert:1;
|
|
|
|
} flags;
|
|
|
|
unsigned int verbose;
|
|
|
|
unsigned int debug;
|
|
|
|
unsigned int timeout;
|
|
|
|
char *ca_cert_file;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ks_options *init_ks_options(void);
|
|
|
|
void free_ks_options(struct ks_options *opt);
|
|
|
|
int parse_ks_options(char *line,struct ks_options *opt);
|
2005-03-17 00:46:07 +01:00
|
|
|
const char *ks_action_to_string(enum ks_action action);
|
2005-03-23 00:41:08 +01:00
|
|
|
void print_nocr(FILE *stream,const char *str);
|
2005-08-26 06:24:46 +02:00
|
|
|
enum ks_search_type classify_ks_search(const char **search);
|
2005-05-04 15:34:25 +02:00
|
|
|
|
|
|
|
#if defined (HAVE_LIBCURL) || defined (FAKE_CURL)
|
2005-04-16 20:50:46 +02:00
|
|
|
int curl_err_to_gpg_err(CURLcode error);
|
2005-04-17 03:52:04 +02:00
|
|
|
|
|
|
|
struct curl_writer_ctx
|
|
|
|
{
|
2005-12-19 20:39:32 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned int initialized:1;
|
|
|
|
unsigned int begun:1;
|
|
|
|
unsigned int done:1;
|
|
|
|
unsigned int armor:1;
|
|
|
|
} flags;
|
|
|
|
|
|
|
|
int armor_remaining;
|
|
|
|
unsigned char armor_ctx[3];
|
|
|
|
int markeridx,linelen;
|
2005-04-17 03:52:04 +02:00
|
|
|
const char *marker;
|
|
|
|
FILE *stream;
|
|
|
|
};
|
|
|
|
|
|
|
|
size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx);
|
2005-12-19 20:39:32 +01:00
|
|
|
void curl_writer_finalize(struct curl_writer_ctx *ctx);
|
|
|
|
|
2005-05-04 15:34:25 +02:00
|
|
|
#endif
|
2005-03-16 16:17:03 +01:00
|
|
|
|
2004-10-13 20:30:29 +02:00
|
|
|
#endif /* !_KSUTIL_H_ */
|