61
65
/* The list of commands and options. */
62
static ARGPARSE_OPTS opts[] =
64
{ 301, NULL, 0, N_("@\nOptions:\n ") },
66
static ARGPARSE_OPTS opts[] = {
67
ARGPARSE_group (301, N_("@\nOptions:\n ")),
66
{ oVerbose, "verbose", 0, N_("verbose") },
67
{ oQuiet, "quiet", 0, N_("quiet") },
68
{ oHex, "hex", 0, N_("print data out hex encoded") },
69
{ oDecode,"decode", 0, N_("decode received data lines") },
70
{ oRawSocket, "raw-socket", 2, N_("|NAME|connect to Assuan socket NAME")},
71
{ oExec, "exec", 0, N_("run the Assuan server given on the command line")},
72
{ oNoExtConnect, "no-ext-connect",
73
0, N_("do not use extended connect mode")},
74
{ oRun, "run", 2, N_("|FILE|run commands from FILE on startup")},
75
{ oSubst, "subst", 0, N_("run /subst on startup")},
77
{ oNoVerbose, "no-verbose", 0, "@"},
78
{ oHomedir, "homedir", 2, "@" },
69
ARGPARSE_s_n (oVerbose, "verbose", N_("verbose")),
70
ARGPARSE_s_n (oQuiet, "quiet", N_("quiet")),
71
ARGPARSE_s_n (oHex, "hex", N_("print data out hex encoded")),
72
ARGPARSE_s_n (oDecode,"decode", N_("decode received data lines")),
73
ARGPARSE_s_s (oRawSocket, "raw-socket",
74
N_("|NAME|connect to Assuan socket NAME")),
75
ARGPARSE_s_n (oExec, "exec",
76
N_("run the Assuan server given on the command line")),
77
ARGPARSE_s_n (oNoExtConnect, "no-ext-connect",
78
N_("do not use extended connect mode")),
79
ARGPARSE_s_s (oRun, "run",
80
N_("|FILE|run commands from FILE on startup")),
81
ARGPARSE_s_n (oSubst, "subst", N_("run /subst on startup")),
83
ARGPARSE_s_n (oNoVerbose, "no-verbose", "@"),
84
ARGPARSE_s_s (oHomedir, "homedir", "@" ),
83
90
/* We keep all global options in the structure OPT. */
1432
1454
add_definq (p, 0, 1);
1456
else if (!strcmp (cmd, "datafile"))
1460
if (current_datasink)
1462
if (current_datasink != stdout)
1463
fclose (current_datasink);
1464
current_datasink = NULL;
1466
tmpline = opt.enable_varsubst? substitute_line (p) : NULL;
1467
fname = tmpline? tmpline : p;
1468
if (fname && !strcmp (fname, "-"))
1469
current_datasink = stdout;
1470
else if (fname && *fname)
1472
current_datasink = fopen (fname, "wb");
1473
if (!current_datasink)
1474
log_error ("can't open `%s': %s\n",
1475
fname, strerror (errno));
1434
1479
else if (!strcmp (cmd, "showdef"))
1436
1481
show_definq ();
1937
2002
&& line[0] == 'S'
1938
2003
&& (line[1] == '\0' || line[1] == ' '))
1940
fwrite (line, linelen, 1, stdout);
2005
if (!current_datasink || current_datasink != stdout)
2007
fwrite (line, linelen, 1, stdout);
1943
2011
else if (linelen >= 2
1944
2012
&& line[0] == 'O' && line[1] == 'K'
1945
2013
&& (line[2] == '\0' || line[2] == ' '))
1947
fwrite (line, linelen, 1, stdout);
2015
if (!current_datasink || current_datasink != stdout)
2017
fwrite (line, linelen, 1, stdout);
1949
2020
set_int_var ("?", 0);
2008
2088
/* Check whether we can connect at the standard socket. */
2009
2089
sockname = make_filename (opt.homedir, "S.gpg-agent", NULL);
2010
2090
rc = assuan_socket_connect (&ctx, sockname, 0);
2092
#ifdef HAVE_W32_SYSTEM
2093
/* If we failed to connect under Windows, we fire up the agent. */
2094
if (gpg_err_code (rc) == GPG_ERR_ASS_CONNECT_FAILED)
2096
const char *agent_program;
2097
const char *argv[3];
2101
log_info (_("no running gpg-agent - starting one\n"));
2102
agent_program = gnupg_module_name (GNUPG_MODULE_NAME_AGENT);
2104
argv[0] = "--daemon";
2105
argv[1] = "--use-standard-socket";
2108
rc = gnupg_spawn_process_detached (agent_program, argv, NULL);
2110
log_debug ("failed to start agent `%s': %s\n",
2111
agent_program, gpg_strerror (rc));
2114
/* Give the agent some time to prepare itself. */
2116
/* Now try again to connect the agent. */
2117
rc = assuan_socket_connect (&ctx, sockname, 0);
2122
#endif /*HAVE_W32_SYSTEM*/
2011
2123
xfree (sockname);