1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-05-24 16:43:28 +02:00

* ksutil.h, ksutil.c (ks_action_to_string): New. (free_ks_options): Only

free if options exist.
This commit is contained in:
David Shaw 2005-03-16 23:46:07 +00:00
parent 8ba895c763
commit 4f347281a9
3 changed files with 31 additions and 13 deletions

View File

@ -1,5 +1,8 @@
2005-03-16 David Shaw <dshaw@jabberwocky.com> 2005-03-16 David Shaw <dshaw@jabberwocky.com>
* ksutil.h, ksutil.c (ks_action_to_string): New.
(free_ks_options): Only free if options exist.
* ksutil.h, ksutil.c (init_ks_options, free_ks_options, * ksutil.h, ksutil.c (init_ks_options, free_ks_options,
parse_ks_options): Pull a lot of duplicated code into a single parse_ks_options): Pull a lot of duplicated code into a single
options parser for all keyserver helpers. options parser for all keyserver helpers.

View File

@ -85,13 +85,16 @@ init_ks_options(void)
void void
free_ks_options(struct ks_options *opt) free_ks_options(struct ks_options *opt)
{ {
free(opt->host); if(opt)
free(opt->port); {
free(opt->scheme); free(opt->host);
free(opt->auth); free(opt->port);
free(opt->path); free(opt->scheme);
free(opt->ca_cert_file); free(opt->auth);
free(opt); free(opt->path);
free(opt->ca_cert_file);
free(opt);
}
} }
/* Returns 0 if we "ate" the line. Returns >0, a KEYSERVER_ error /* Returns 0 if we "ate" the line. Returns >0, a KEYSERVER_ error
@ -109,11 +112,6 @@ parse_ks_options(char *line,struct ks_options *opt)
char path[URLMAX_PATH+1]; char path[URLMAX_PATH+1];
char option[MAX_OPTION+1]; char option[MAX_OPTION+1];
#if 0
if(sscanf(line,"%c",&hash)==1 && hash=='#')
continue;
#endif
if(line[0]=='#') if(line[0]=='#')
return 0; return 0;
@ -267,3 +265,17 @@ parse_ks_options(char *line,struct ks_options *opt)
return -1; return -1;
} }
const char *
ks_action_to_string(enum ks_action action)
{
switch(action)
{
case KS_UNKNOWN: return "UNKNOWN";
case KS_GET: return "GET";
case KS_SEND: return "SEND";
case KS_SEARCH: return "SEARCH";
}
return "?";
}

View File

@ -59,9 +59,11 @@ struct keylist
unsigned int set_timeout(unsigned int seconds); unsigned int set_timeout(unsigned int seconds);
int register_timeout(void); int register_timeout(void);
enum ks_action {KS_UNKNOWN=0,KS_GET,KS_SEND,KS_SEARCH};
struct ks_options struct ks_options
{ {
enum {KS_UNKNOWN,KS_GET,KS_SEND,KS_SEARCH} action; enum ks_action action;
char *host; char *host;
char *port; char *port;
char *scheme; char *scheme;
@ -83,5 +85,6 @@ struct ks_options
struct ks_options *init_ks_options(void); struct ks_options *init_ks_options(void);
void free_ks_options(struct ks_options *opt); void free_ks_options(struct ks_options *opt);
int parse_ks_options(char *line,struct ks_options *opt); int parse_ks_options(char *line,struct ks_options *opt);
const char *ks_action_to_string(enum ks_action action);
#endif /* !_KSUTIL_H_ */ #endif /* !_KSUTIL_H_ */