Line data Source code
1 : /* helptext.c - English help texts
2 : * Copyright (C) 1998, 1999, 2000, 2001, 2002,
3 : * 2004, 2007 Free Software Foundation, Inc.
4 : *
5 : * This file is part of GnuPG.
6 : *
7 : * GnuPG is free software; you can redistribute it and/or modify
8 : * it under the terms of the GNU General Public License as published by
9 : * the Free Software Foundation; either version 3 of the License, or
10 : * (at your option) any later version.
11 : *
12 : * GnuPG is distributed in the hope that it will be useful,
13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 : * GNU General Public License for more details.
16 : *
17 : * You should have received a copy of the GNU General Public License
18 : * along with this program; if not, see <https://www.gnu.org/licenses/>.
19 : */
20 :
21 : #include <config.h>
22 : #include <stdio.h>
23 : #include <stdlib.h>
24 : #include <string.h>
25 :
26 : #include "gpg.h"
27 : #include "util.h"
28 : #include "ttyio.h"
29 : #include "main.h"
30 : #include "i18n.h"
31 :
32 :
33 :
34 :
35 : /* Helper to get the help through the configurable GnuPG help
36 : system. */
37 : static char *
38 0 : get_help_from_file (const char *keyword)
39 : {
40 : char *key, *result;
41 :
42 0 : key = xtrymalloc (4 + strlen (keyword) + 1);
43 0 : if (key)
44 : {
45 0 : strcpy (stpcpy (key, "gpg."), keyword);
46 0 : result = gnupg_get_help_string (key, 0);
47 0 : xfree (key);
48 0 : if (result && !is_native_utf8 ())
49 : {
50 0 : char *tmp = utf8_to_native (result, strlen (result), -1);
51 0 : if (tmp)
52 : {
53 0 : xfree (result);
54 0 : result = tmp;
55 : }
56 : }
57 : }
58 : else
59 0 : result = NULL;
60 0 : return result;
61 : }
62 :
63 :
64 : void
65 0 : display_online_help( const char *keyword )
66 : {
67 : char *result;
68 0 : int need_final_lf = 1;
69 :
70 0 : tty_kill_prompt();
71 0 : if ( !keyword )
72 0 : tty_printf (_("No help available") );
73 0 : else if ( (result = get_help_from_file (keyword)) )
74 : {
75 0 : tty_printf ("%s", result);
76 0 : if (*result && result[strlen (result)-1] == '\n')
77 0 : need_final_lf = 0;
78 0 : xfree (result);
79 : }
80 : else
81 : {
82 0 : tty_printf (_("No help available for '%s'"), keyword );
83 : }
84 0 : if (need_final_lf)
85 0 : tty_printf("\n");
86 0 : }
|