mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-21 21:39:58 +01:00
* main.h, misc.c (parse_options): New general option line parser. Fix the
bug in the old version that did not handle report syntax errors after a valid entry. * import.c (parse_import_options), export.c (parse_export_options): Call it here instead of duplicating the code.
This commit is contained in:
parent
9390fe676b
commit
ff43d07819
@ -1,3 +1,13 @@
|
|||||||
|
2003-05-31 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* main.h, misc.c (parse_options): New general option line
|
||||||
|
parser. Fix the bug in the old version that did not handle report
|
||||||
|
syntax errors after a valid entry.
|
||||||
|
|
||||||
|
* import.c (parse_import_options), export.c
|
||||||
|
(parse_export_options): Call it here instead of duplicating the
|
||||||
|
code.
|
||||||
|
|
||||||
2003-05-30 David Shaw <dshaw@jabberwocky.com>
|
2003-05-30 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* keylist.c (list_one): Don't show the keyring filename when in
|
* keylist.c (list_one): Don't show the keyring filename when in
|
||||||
|
38
g10/export.c
38
g10/export.c
@ -42,13 +42,7 @@ static int do_export_stream( IOBUF out, STRLIST users, int secret,
|
|||||||
int
|
int
|
||||||
parse_export_options(char *str,unsigned int *options)
|
parse_export_options(char *str,unsigned int *options)
|
||||||
{
|
{
|
||||||
char *tok;
|
struct parse_options export_opts[]=
|
||||||
int hit=0;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
unsigned int bit;
|
|
||||||
} export_opts[]=
|
|
||||||
{
|
{
|
||||||
{"include-non-rfc",EXPORT_INCLUDE_NON_RFC},
|
{"include-non-rfc",EXPORT_INCLUDE_NON_RFC},
|
||||||
{"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS},
|
{"include-local-sigs",EXPORT_INCLUDE_LOCAL_SIGS},
|
||||||
@ -58,34 +52,7 @@ parse_export_options(char *str,unsigned int *options)
|
|||||||
/* add tags for include revoked and disabled? */
|
/* add tags for include revoked and disabled? */
|
||||||
};
|
};
|
||||||
|
|
||||||
while((tok=strsep(&str," ,")))
|
return parse_options(str,options,export_opts);
|
||||||
{
|
|
||||||
int i,rev=0;
|
|
||||||
|
|
||||||
if(ascii_strncasecmp("no-",tok,3)==0)
|
|
||||||
{
|
|
||||||
rev=1;
|
|
||||||
tok+=3;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0;export_opts[i].name;i++)
|
|
||||||
{
|
|
||||||
if(ascii_strcasecmp(export_opts[i].name,tok)==0)
|
|
||||||
{
|
|
||||||
if(rev)
|
|
||||||
*options&=~export_opts[i].bit;
|
|
||||||
else
|
|
||||||
*options|=export_opts[i].bit;
|
|
||||||
hit=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!hit && !export_opts[i].name)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
@ -427,4 +394,3 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
|
|||||||
log_info(_("WARNING: nothing exported\n"));
|
log_info(_("WARNING: nothing exported\n"));
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
g10/import.c
37
g10/import.c
@ -85,13 +85,7 @@ static int merge_keysigs( KBNODE dst, KBNODE src, int *n_sigs,
|
|||||||
int
|
int
|
||||||
parse_import_options(char *str,unsigned int *options)
|
parse_import_options(char *str,unsigned int *options)
|
||||||
{
|
{
|
||||||
char *tok;
|
struct parse_options import_opts[]=
|
||||||
int hit=0;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
char *name;
|
|
||||||
unsigned int bit;
|
|
||||||
} import_opts[]=
|
|
||||||
{
|
{
|
||||||
{"allow-local-sigs",IMPORT_ALLOW_LOCAL_SIGS},
|
{"allow-local-sigs",IMPORT_ALLOW_LOCAL_SIGS},
|
||||||
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG},
|
{"repair-hkp-subkey-bug",IMPORT_REPAIR_PKS_SUBKEY_BUG},
|
||||||
@ -101,34 +95,7 @@ parse_import_options(char *str,unsigned int *options)
|
|||||||
{NULL,0}
|
{NULL,0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while((tok=strsep(&str," ,")))
|
return parse_options(str,options,import_opts);
|
||||||
{
|
|
||||||
int i,rev=0;
|
|
||||||
|
|
||||||
if(ascii_strncasecmp("no-",tok,3)==0)
|
|
||||||
{
|
|
||||||
rev=1;
|
|
||||||
tok+=3;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0;import_opts[i].name;i++)
|
|
||||||
{
|
|
||||||
if(ascii_strcasecmp(import_opts[i].name,tok)==0)
|
|
||||||
{
|
|
||||||
if(rev)
|
|
||||||
*options&=~import_opts[i].bit;
|
|
||||||
else
|
|
||||||
*options|=import_opts[i].bit;
|
|
||||||
hit=1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!hit && !import_opts[i].name)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
10
g10/main.h
10
g10/main.h
@ -95,8 +95,16 @@ int string_to_compress_algo(const char *string);
|
|||||||
int check_compress_algo(int algo);
|
int check_compress_algo(int algo);
|
||||||
int default_cipher_algo(void);
|
int default_cipher_algo(void);
|
||||||
int default_compress_algo(void);
|
int default_compress_algo(void);
|
||||||
void compliance_failure(void);
|
|
||||||
const char *compliance_option_string(void);
|
const char *compliance_option_string(void);
|
||||||
|
void compliance_failure(void);
|
||||||
|
|
||||||
|
struct parse_options
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
unsigned int bit;
|
||||||
|
};
|
||||||
|
|
||||||
|
int parse_options(char *str,unsigned int *options,struct parse_options *opts);
|
||||||
|
|
||||||
/*-- helptext.c --*/
|
/*-- helptext.c --*/
|
||||||
void display_online_help( const char *keyword );
|
void display_online_help( const char *keyword );
|
||||||
|
37
g10/misc.c
37
g10/misc.c
@ -639,3 +639,40 @@ compliance_failure(void)
|
|||||||
log_info(_("this message may not be usable by %s\n"),compliance_string());
|
log_info(_("this message may not be usable by %s\n"),compliance_string());
|
||||||
opt.compliance=CO_GNUPG;
|
opt.compliance=CO_GNUPG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
parse_options(char *str,unsigned int *options,struct parse_options *opts)
|
||||||
|
{
|
||||||
|
char *tok;
|
||||||
|
|
||||||
|
while((tok=strsep(&str," ,")))
|
||||||
|
{
|
||||||
|
int i,rev=0;
|
||||||
|
|
||||||
|
if(tok[0]=='\0')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(ascii_strncasecmp("no-",tok,3)==0)
|
||||||
|
{
|
||||||
|
rev=1;
|
||||||
|
tok+=3;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i=0;opts[i].name;i++)
|
||||||
|
{
|
||||||
|
if(ascii_strcasecmp(opts[i].name,tok)==0)
|
||||||
|
{
|
||||||
|
if(rev)
|
||||||
|
*options&=~opts[i].bit;
|
||||||
|
else
|
||||||
|
*options|=opts[i].bit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!opts[i].name)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user