1
/* status.c - Status message and command-fd interface
1
/* status.c - Status message and command-fd interface
2
2
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
3
3
* 2004, 2005, 2006 Free Software Foundation, Inc.
132
132
write_status_text( no, NULL );
136
/* Write a status line with code NO followed by the string TEXT and
137
directly followed by the remaining strings up to a NULL. */
136
write_status_text ( int no, const char *text)
139
write_status_strings (int no, const char *text, ...)
138
if( !statusfp || !status_currently_allowed (no) )
139
return; /* Not enabled or allowed. */
141
fputs ( "[GNUPG:] ", statusfp );
142
fputs ( get_status_string (no), statusfp );
144
putc ( ' ', statusfp );
145
for (; *text; text++) {
147
fputs ( "\\n", statusfp );
148
else if (*text == '\r')
149
fputs ( "\\r", statusfp );
151
putc ( *(const byte *)text, statusfp );
144
if (!statusfp || !status_currently_allowed (no) )
145
return; /* Not enabled or allowed. */
147
fputs ("[GNUPG:] ", statusfp);
148
fputs (get_status_string (no), statusfp);
151
putc ( ' ', statusfp);
152
va_start (arg_ptr, text);
159
fputs ("\\n", statusfp);
161
fputs ("\\r", statusfp);
163
fputc (*(const byte *)s, statusfp);
166
while ((s = va_arg (arg_ptr, const char*)));
154
putc ('\n',statusfp);
155
if ( fflush (statusfp) && opt.exit_on_status_write_error )
169
putc ('\n', statusfp);
170
if (fflush (statusfp) && opt.exit_on_status_write_error)
176
write_status_text (int no, const char *text)
178
write_status_strings (no, text, NULL);
163
185
if (!statusfp || !status_currently_allowed (STATUS_ERROR))
164
186
return; /* Not enabled or allowed. */
166
fprintf (statusfp, "[GNUPG:] %s %s %u\n",
188
fprintf (statusfp, "[GNUPG:] %s %s %u\n",
167
189
get_status_string (STATUS_ERROR), where, gpg_err_code (errcode));
168
190
if (fflush (statusfp) && opt.exit_on_status_write_error)
214
236
for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) {
215
if ( *s == '%' || *(const byte*)s <= lower_limit
216
|| *(const byte*)s == 127 )
237
if ( *s == '%' || *(const byte*)s <= lower_limit
238
|| *(const byte*)s == 127 )
218
240
if ( wrap && ++count > wrap ) {
270
292
if (i < 4 || i > 7)
271
293
if ( gcry_md_is_enabled (md, i) && buflen < DIM(buf) )
273
snprintf (buf+buflen, DIM(buf) - buflen - 1,
295
snprintf (buf+buflen, DIM(buf) - buflen - 1,
274
296
"%sH%d", buflen? " ":"",i);
275
297
buflen += strlen (buf+buflen);
320
342
if (statusfp != stdout)
323
345
write_status_text (getbool? STATUS_GET_BOOL :
324
346
hidden? STATUS_GET_HIDDEN : STATUS_GET_LINE, keyword);
326
for (string = NULL, i = len = 200; ; i++ )
348
for (string = NULL, i = len = 200; ; i++ )
330
352
char *save = string;
338
360
/* Fixme: why not use our read_line function here? */
339
361
if ( myread( opt.command_fd, string+i, 1) != 1 || string[i] == '\n' )
341
else if ( string[i] == CONTROL_D )
363
else if ( string[i] == CONTROL_D )
343
365
/* Found ETX - Cancel the line and return a sole ETX. */
344
366
string[0] = CONTROL_D;