Improved yat2m.

Tweaked gpg.texti to be used for gpg1 and gpg2.
This commit is contained in:
Werner Koch 2006-09-22 14:38:38 +00:00
parent b0a06d18a4
commit c9f8a69f0f
6 changed files with 316 additions and 59 deletions

View File

@ -1,3 +1,15 @@
2006-09-22 Werner Koch <wk@g10code.com>
* gpg.texi: Make some parts depend on the "gpgone" set
command. This allows us to use the same source for gpg1 and gpg2.
* yat2m.c (parse_file): Better parsing of @ifset and ifclear.
(main): Allow definition of "-D gpgone".
(parse_file): Allow macro definitions.
(proc_texi_cmd): Expand macros.
(proc_texi_buffer): Process commands terminated by the closing
brace of the enclosing command.
2006-09-20 Werner Koch <wk@g10code.com> 2006-09-20 Werner Koch <wk@g10code.com>
* texi.css: New. Note that the current vesion of makeinfo has a * texi.css: New. Note that the current vesion of makeinfo has a

View File

@ -18,6 +18,7 @@ the X.509/CMS (for S/MIME) counterpart of
@command{gpg2}. @command{gpg-agent} is a passphrase and private key @command{gpg2}. @command{gpg-agent} is a passphrase and private key
daemon which may also emulate the @command{ssh-agent}. daemon which may also emulate the @command{ssh-agent}.
@mansect see also @mansect see also
@command{gpg}(1),
@command{gpg2}(1), @command{gpg2}(1),
@command{gpgv}(1), @command{gpgv}(1),
@command{gpgsm}(1), @command{gpgsm}(1),

View File

@ -9,7 +9,36 @@
@cindex command options @cindex command options
@cindex options, GPG command @cindex options, GPG command
@c Begin GnuPG 1.x specific stuff
@ifset gpgone
@macro gpgname
gpg
@end macro
@manpage gpg.1
@ifset manverb
.B gpg
\- OpenPGP encryption and signing tool
@end ifset
@mansect synopsis
@ifset manverb
.B gpg
.RB [ \-\-homedir
.IR dir ]
.RB [ \-\-options
.IR file ]
.RI [ options ]
.I command
.RI [ args ]
@end ifset
@end ifset
@c End GnuPG 1.x specific stuff
@c Begin GnuPG 2 specific stuff
@ifclear gpgone
@macro gpgname
gpg2
@end macro
@manpage gpg2.1 @manpage gpg2.1
@ifset manverb @ifset manverb
.B gpg2 .B gpg2
@ -27,14 +56,22 @@
.I command .I command
.RI [ args ] .RI [ args ]
@end ifset @end ifset
@end ifclear
@c Begin GnuPG 2 specific stuff
@mansect description @mansect description
@command{gpg2} is the OpenPGP part of the GNU Privacy Guard (GnuPG). It @command{@gpgname} is the OpenPGP part of the GNU Privacy Guard (GnuPG). It
is a tool to provide digital encryption and signing services using the is a tool to provide digital encryption and signing services using the
OpenPGP standard. @command{gpg2} features complete key management and OpenPGP standard. @command{@gpgname} features complete key management and
all bells and whistles you can expect from a decent OpenPGP all bells and whistles you can expect from a decent OpenPGP
implementation. implementation.
@ifset gpgone
This is the standa alone version of @command{gpg}. For desktop use you
shoul consider using @command{gpg2}.
@end ifset
@ifclear gpgone
In contrast to the standalone version @command{gpg}, which is more In contrast to the standalone version @command{gpg}, which is more
suited for server and embedded platforms, this version is installed suited for server and embedded platforms, this version is installed
under the name @command{gpg2} and more targeted to the desktop as it under the name @command{gpg2} and more targeted to the desktop as it
@ -43,12 +80,15 @@ will be kept maintained and it is possible to install both versions on
the same system. If you need to use different configuration files, you the same system. If you need to use different configuration files, you
should make use of something like @file{gpg.conf-2} instead of just should make use of something like @file{gpg.conf-2} instead of just
@file{gpg.conf}. @file{gpg.conf}.
@end ifclear
@manpause @manpause
Documentation for the old standard @command{gpg} is available as man page @ifclear gpgone
man page and at @inforef{Top,GnuPG 1,gpg}. Documentation for the old standard @command{gpg} is available as a man
page and at @inforef{Top,GnuPG 1,gpg}.
@end ifclear
@xref{Option Index}, for an index to @command{GPG}'s commands and options. @xref{Option Index}, for an index to @command{@gpgname}'s commands and options.
@mancont @mancont
@menu @menu
@ -76,7 +116,7 @@ Developer information:
Commands are not distinguished from options execpt for the fact that Commands are not distinguished from options execpt for the fact that
only one command is allowed. only one command is allowed.
@code{gpg2} may be run with no commands, in which case it will @command{@gpgname} may be run with no commands, in which case it will
perform a reasonable action depending on the type of file it is given perform a reasonable action depending on the type of file it is given
as input (an encrypted message is decrypted, a signature is verified, as input (an encrypted message is decrypted, a signature is verified,
a file containing keys is listed). a file containing keys is listed).
@ -778,7 +818,7 @@ from --edit.
@node GPG Options @node GPG Options
@section Option Summary @section Option Summary
@command{GPG} comes features a bunch of options to control the exact @command{@gpgname} comes features a bunch of options to control the exact
behaviour and to change the default configuration. behaviour and to change the default configuration.
@menu @menu
@ -1380,10 +1420,15 @@ disables this option.
@item --use-agent @item --use-agent
@itemx --no-use-agent @itemx --no-use-agent
Try to use the GnuPG-Agent. Please note that this agent is still under @ifclear gpgone
development. With this option, GnuPG first tries to connect to the This is dummy option. @command{@gpgname} always requires the agent.
@end ifclear
@ifset gpgone
Try to use the GnuPG-Agent.
With this option, GnuPG first tries to connect to the
agent before it asks for a passphrase. --no-use-agent disables this agent before it asks for a passphrase. --no-use-agent disables this
option. option.
@end ifset
@item --gpg-agent-info @item --gpg-agent-info
Override the value of the environment variable Override the value of the environment variable
@ -1462,7 +1507,7 @@ Refuse to run if GnuPG cannot get secure memory. Defaults to no
When verifying a signature made from a subkey, ensure that the cross When verifying a signature made from a subkey, ensure that the cross
certification "back signature" on the subkey is present and valid. certification "back signature" on the subkey is present and valid.
This protects against a subtle attack against subkeys that can sign. This protects against a subtle attack against subkeys that can sign.
Defaults to --require-cross-certification for @command{gpg2}. Defaults to --require-cross-certification for @command{@gpgname}.
@item --expert @item --expert
@itemx --no-expert @itemx --no-expert
@ -2361,14 +2406,14 @@ are deprecated. Use `--list-options [no-]show-policy-url' and/or
@section Configuration files @section Configuration files
There are a few configuration files to control certain aspects of There are a few configuration files to control certain aspects of
@command{gpg2}'s operation. Unless noted, they are expected in the @command{@gpgname}'s operation. Unless noted, they are expected in the
current home directory (@pxref{option --homedir}). current home directory (@pxref{option --homedir}).
@table @file @table @file
@item gpg.conf @item gpg.conf
@cindex gpgsm.conf @cindex gpgsm.conf
This is the standard configuration file read by @command{gpg2} on This is the standard configuration file read by @command{@gpgname} on
startup. It may contain any valid long option; the leading two dashes startup. It may contain any valid long option; the leading two dashes
may not be entered and the option may not be abbreviated. This default may not be entered and the option may not be abbreviated. This default
name may be changed on the command line (@pxref{option name may be changed on the command line (@pxref{option
@ -2382,9 +2427,9 @@ into the directory @file{/etc/skel/.gnupg/} so that newly created users
start up with a working configuration. For existing users the a small start up with a working configuration. For existing users the a small
helper script is provided to create these files (@pxref{addgnupghome}). helper script is provided to create these files (@pxref{addgnupghome}).
For internal purposes @command{gpg2} creates and maintaines a few other For internal purposes @command{@gpgname} creates and maintaines a few other
files; They all live in in the current home directory (@pxref{option files; They all live in in the current home directory (@pxref{option
--homedir}). Only the @command{gpg2} may modify these files. --homedir}). Only the @command{@gpgname} may modify these files.
@table @file @table @file

View File

@ -105,11 +105,27 @@ static const char *opt_select;
static const char *opt_include; static const char *opt_include;
static int opt_store; static int opt_store;
/* The only define we understand is -D gpgone. Thus we need a simple
boolean tro track it. */
static int gpgone_defined;
/* Flag to keep track whether any error occurred. */ /* Flag to keep track whether any error occurred. */
static int any_error; static int any_error;
/* Object to keep macro definitions. */
struct macro_s
{
struct macro_s *next;
char *value; /* Malloced value. */
char name[1];
};
typedef struct macro_s *macro_t;
/* List of all defined macros. */
static macro_t macrolist;
/* Object to store one line of content. */ /* Object to store one line of content. */
struct line_buffer_s struct line_buffer_s
{ {
@ -468,8 +484,6 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
{ "bullet", 0, "* " }, { "bullet", 0, "* " },
{ "end", 4 }, { "end", 4 },
{ "quotation",1, ".RS\n\\fB" }, { "quotation",1, ".RS\n\\fB" },
{ "ifset", 1 },
{ "ifclear", 1 },
{ NULL } { NULL }
}; };
size_t n; size_t n;
@ -551,8 +565,20 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
} }
else else
{ {
inf ("texinfo command `%s' not supported (%.*s)", command, macro_t m;
((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest);
for (m = macrolist; m ; m = m->next)
if (!strcmp (m->name, command))
break;
if (m)
{
proc_texi_buffer (fp, m->value, strlen (m->value),
table_level, eol_action);
ignore_args = 1; /* Parameterized macros are not yet supported. */
}
else
inf ("texinfo command `%s' not supported (%.*s)", command,
((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest);
} }
if (*rest == '{') if (*rest == '{')
@ -654,6 +680,16 @@ proc_texi_buffer (FILE *fp, const char *line, size_t len,
else else
putc (*s, fp); putc (*s, fp);
} }
if (in_cmd > 1)
{
cmdbuf[cmdidx] = 0;
n = proc_texi_cmd (fp, cmdbuf, s, len, table_level, eol_action);
assert (n <= len);
s += n; len -= n;
s--; len++;
in_cmd = 0;
}
} }
@ -808,9 +844,22 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
{ {
char *line; char *line;
int lnr = 0; int lnr = 0;
/* Fixme: The follwing state variables don't carry over to include
files. */
int in_verbatim = 0; int in_verbatim = 0;
int skip_to_end = 0; /* Used to skip over menu entries. */ int skip_to_end = 0; /* Used to skip over menu entries. */
int skip_sect_line = 0; /* Skip after @mansect. */ int skip_sect_line = 0; /* Skip after @mansect. */
int ifset_nesting = 0; /* How often a ifset has been seen. */
int ifclear_nesting = 0; /* How often a ifclear has been seen. */
int in_gpgone = 0; /* Keep track of "@ifset gpgone" parts. */
int not_in_gpgone = 0; /* Keep track of "@ifclear gpgone" parts. */
int not_in_man = 0; /* Keep track of "@ifclear isman" parts. */
/* Helper to define a macro. */
char *macroname = NULL;
char *macrovalue = NULL;
size_t macrovaluesize = 0;
size_t macrovalueused = 0;
line = xmalloc (LINESIZE); line = xmalloc (LINESIZE);
while (fgets (line, LINESIZE, fp)) while (fgets (line, LINESIZE, fp))
@ -828,6 +877,63 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
} }
line[--n] = 0; line[--n] = 0;
if (*line == '@')
{
for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++)
n++;
while (*p == ' ' || *p == '\t')
p++;
}
else
p = line;
/* Take action on macro. */
if (macroname)
{
if (n == 4 && !memcmp (line, "@end", 4)
&& (line[4]==' '||line[4]=='\t'||!line[4])
&& !strncmp (p, "macro", 5)
&& (p[5]==' '||p[5]=='\t'||!p[5]))
{
macro_t m;
if (macrovalueused)
macrovalue[--macrovalueused] = 0; /* Kill the last LF. */
macrovalue[macrovalueused] = 0; /* Terminate macro. */
macrovalue = xrealloc (macrovalue, macrovalueused+1);
for (m= macrolist; m; m = m->next)
if (!strcmp (m->name, macroname))
break;
if (m)
free (m->value);
else
{
m = xcalloc (1, sizeof *m + strlen (macroname));
strcpy (m->name, macroname);
m->next = macrolist;
macrolist = m;
}
m->value = macrovalue;
macrovalue = NULL;
free (macroname);
macroname = NULL;
}
else
{
if (macrovalueused + strlen (line) + 2 >= macrovaluesize)
{
macrovaluesize += strlen (line) + 256;
macrovalue = xrealloc (macrovalue, macrovaluesize);
}
strcpy (macrovalue+macrovalueused, line);
macrovalueused += strlen (line);
macrovalue[macrovalueused++] = '\n';
}
continue;
}
if (n >= 5 && !memcmp (line, "@node", 5) if (n >= 5 && !memcmp (line, "@node", 5)
&& (line[5]==' '||line[5]=='\t'||!line[5])) && (line[5]==' '||line[5]=='\t'||!line[5]))
{ {
@ -849,36 +955,115 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
few macros used to control this as well as one @ifset few macros used to control this as well as one @ifset
command. Parts we know about are saved away into containers command. Parts we know about are saved away into containers
separate for each section. */ separate for each section. */
/* First process ifset/ifclear commands. */
if (*line == '@') if (*line == '@')
{ {
for (p=line+1, n=1; *p && *p != ' ' && *p != '\t'; p++) if (n == 6 && !memcmp (line, "@ifset", 6)
n++; && (line[6]==' '||line[6]=='\t'))
while (*p == ' ' || *p == '\t') {
p++; ifset_nesting++;
if (!strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7]))
{
if (in_verbatim)
err ("%s:%d: nested \"@ifset manverb\"", fname, lnr);
else
in_verbatim = ifset_nesting;
}
else if (!strncmp (p, "gpgone", 6)
&& (p[6]==' '||p[6]=='\t'||!p[6]))
{
if (in_gpgone)
err ("%s:%d: nested \"@ifset gpgone\"", fname, lnr);
else
in_gpgone = ifset_nesting;
}
continue;
}
else if (n == 4 && !memcmp (line, "@end", 4)
&& (line[4]==' '||line[4]=='\t')
&& !strncmp (p, "ifset", 5)
&& (p[5]==' '||p[5]=='\t'||!p[5]))
{
if (in_verbatim && ifset_nesting == in_verbatim)
in_verbatim = 0;
if (in_gpgone && ifset_nesting == in_gpgone)
in_gpgone = 0;
if (ifset_nesting)
ifset_nesting--;
else
err ("%s:%d: unbalanced \"@end ifset\"", fname, lnr);
continue;
}
else if (n == 8 && !memcmp (line, "@ifclear", 8)
&& (line[8]==' '||line[8]=='\t'))
{
ifclear_nesting++;
if (!strncmp (p, "gpgone", 6)
&& (p[6]==' '||p[6]=='\t'||!p[6]))
{
if (not_in_gpgone)
err ("%s:%d: nested \"@ifclear gpgone\"", fname, lnr);
else
not_in_gpgone = ifclear_nesting;
}
else if (!strncmp (p, "isman", 5)
&& (p[5]==' '||p[5]=='\t'||!p[5]))
{
if (not_in_man)
err ("%s:%d: nested \"@ifclear isman\"", fname, lnr);
else
not_in_man = ifclear_nesting;
}
continue;
}
else if (n == 4 && !memcmp (line, "@end", 4)
&& (line[4]==' '||line[4]=='\t')
&& !strncmp (p, "ifclear", 7)
&& (p[7]==' '||p[7]=='\t'||!p[7]))
{
if (not_in_gpgone && ifclear_nesting == not_in_gpgone)
not_in_gpgone = 0;
if (not_in_man && ifclear_nesting == not_in_man)
not_in_man = 0;
if (ifclear_nesting)
ifclear_nesting--;
else
err ("%s:%d: unbalanced \"@end ifclear\"", fname, lnr);
continue;
}
}
/* Take action on ifset/ifclear. */
if ( (in_gpgone && !gpgone_defined)
|| (not_in_gpgone && gpgone_defined)
|| not_in_man)
continue;
/* Process commands. */
if (*line == '@')
{
if (skip_to_end if (skip_to_end
&& n == 4 && !memcmp (line, "@end", 4) && n == 4 && !memcmp (line, "@end", 4)
&& (line[4]==' '||line[4]=='\t'||!line[4])) && (line[4]==' '||line[4]=='\t'||!line[4]))
{ {
skip_to_end = 0; skip_to_end = 0;
} }
else if (n == 6 && !memcmp (line, "@ifset", 6)
&& !strncmp (p, "manverb", 7) && (p[7]==' '||p[7]=='\t'||!p[7]))
{
if (in_verbatim)
err ("%s:%d: nested \"@ifset manverb\"", fname, lnr);
else
in_verbatim = 1;
}
else if (in_verbatim && n == 4 && !memcmp (line, "@end", 4)
&& !strncmp (p, "ifset", 5)
&& (p[5]==' '||p[5]=='\t'||!p[5]))
{
in_verbatim = 0;
}
else if (in_verbatim) else if (in_verbatim)
{ {
got_line = 1; got_line = 1;
}
else if (n == 6 && !memcmp (line, "@macro", 6))
{
macroname = xstrdup (p);
macrovalue = xmalloc ((macrovaluesize = 1024));
macrovalueused = 0;
} }
else if (n == 8 && !memcmp (line, "@manpage", 8)) else if (n == 8 && !memcmp (line, "@manpage", 8))
{ {
@ -923,11 +1108,6 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
{ {
skip_to_end = 1; skip_to_end = 1;
} }
else if (n == 8 && !memcmp (line, "@ifclear", 8)
&& !strncmp (p, "isman", 5) && (p[5]==' '||p[5]=='\t'||!p[5]))
{
skip_to_end = 1;
}
else if (n == 8 && !memcmp (line, "@include", 8) else if (n == 8 && !memcmp (line, "@include", 8)
&& (line[8]==' '||line[8]=='\t'||!line[8])) && (line[8]==' '||line[8]=='\t'||!line[8]))
{ {
@ -956,6 +1136,11 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
} }
free (incname); free (incname);
} }
else if (n == 4 && !memcmp (line, "@bye", 4)
&& (line[4]==' '||line[4]=='\t'||!line[4]))
{
break;
}
else if (!skip_to_end) else if (!skip_to_end)
got_line = 1; got_line = 1;
} }
@ -970,6 +1155,8 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
} }
if (ferror (fp)) if (ferror (fp))
err ("%s:%d: read error: %s", fname, lnr, strerror (errno)); err ("%s:%d: read error: %s", fname, lnr, strerror (errno));
free (macroname);
free (macrovalue);
free (line); free (line);
} }
@ -979,6 +1166,14 @@ top_parse_file (const char *fname, FILE *fp)
{ {
char *section_name = NULL; /* Name of the current section or NULL char *section_name = NULL; /* Name of the current section or NULL
if not in a section. */ if not in a section. */
while (macrolist)
{
macro_t m = macrolist->next;
free (m->value);
free (m);
macrolist = m;
}
parse_file (fname, fp, &section_name, 0); parse_file (fname, fp, &section_name, 0);
free (section_name); free (section_name);
finish_page (); finish_page ();
@ -1017,7 +1212,8 @@ main (int argc, char **argv)
" --verbose enable extra informational output\n" " --verbose enable extra informational output\n"
" --debug enable additional debug output\n" " --debug enable additional debug output\n"
" --help display this help and exit\n" " --help display this help and exit\n"
" -I DIR also search in include DIR\n\n" " -I DIR also search in include DIR\n"
" -D gpgone the only useable define\n\n"
"With no FILE, or when FILE is -, read standard input.\n\n" "With no FILE, or when FILE is -, read standard input.\n\n"
"Report bugs to <bugs@g10code.com>."); "Report bugs to <bugs@g10code.com>.");
exit (0); exit (0);
@ -1091,6 +1287,16 @@ main (int argc, char **argv)
argc--; argv++; argc--; argv++;
} }
} }
else if (!strcmp (*argv, "-D"))
{
argc--; argv++;
if (argc)
{
if (!strcmp (*argv, "gpgone"))
gpgone_defined = 1;
argc--; argv++;
}
}
} }
if (argc > 1) if (argc > 1)

View File

@ -7,6 +7,8 @@
to OpenSSL. This is considered a bug fix and forgives all to OpenSSL. This is considered a bug fix and forgives all
possible violations, pertaining to this issue, possibly occured in possible violations, pertaining to this issue, possibly occured in
the past. the past.
* no-libgcrypt.c: Changed license to a simple all permissive one.
* Makefile.am (gpg2keys_ldap_LDADD): For license reasons do not * Makefile.am (gpg2keys_ldap_LDADD): For license reasons do not
link against common_libs. link against common_libs.

View File

@ -1,22 +1,13 @@
/* no-libgcrypt.c - Replacement functions for libgcrypt. /* no-libgcrypt.c - Replacement functions for libgcrypt.
* Copyright (C) 2003 Free Software Foundation, Inc. * Copyright (C) 2003 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is free software; as a special exception the author gives
* * unlimited permission to copy and/or distribute it, with or without
* GnuPG is free software; you can redistribute it and/or modify * modifications, as long as this notice is preserved.
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * This file is distributed in the hope that it will be useful, but
* (at your option) any later version. * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
* * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/ */
#include <config.h> #include <config.h>