diff options
author | Werner Koch <wk@gnupg.org> | 2011-02-04 12:57:53 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2011-02-04 12:57:53 +0100 |
commit | b008274afdbe375b32a7e66dbd073e200f6f0587 (patch) | |
tree | 219e239d39cf06be3f03aa82fb572080ac163a15 /common | |
parent | Let autogen.sh check the git config (diff) | |
download | gnupg2-b008274afdbe375b32a7e66dbd073e200f6f0587.tar.xz gnupg2-b008274afdbe375b32a7e66dbd073e200f6f0587.zip |
Nuked almost all trailing white space.post-nuke-of-trailing-ws
We better do this once and for all instead of cluttering all future
commits with diffs of trailing white spaces. In the majority of cases
blank or single lines are affected and thus this change won't disturb
a git blame too much. For future commits the pre-commit scripts
checks that this won't happen again.
Diffstat (limited to 'common')
85 files changed, 998 insertions, 1050 deletions
diff --git a/common/Makefile.am b/common/Makefile.am index 2539859d5..5d7f22496 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -7,12 +7,12 @@ # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. -# +# # 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, see <http://www.gnu.org/licenses/>. @@ -97,12 +97,12 @@ common_sources = \ # separate source files. if HAVE_W32_SYSTEM if HAVE_W32CE_SYSTEM -common_sources += exechelp-w32ce.c +common_sources += exechelp-w32ce.c else -common_sources += exechelp-w32.c +common_sources += exechelp-w32.c endif else -common_sources += exechelp-posix.c +common_sources += exechelp-posix.c endif # Sources only useful without PTH. @@ -155,7 +155,7 @@ endif # # Module tests # -t_jnlib_src = t-support.c t-support.h +t_jnlib_src = t-support.c t-support.h jnlib_tests = t-stringhelp t-timestuff if HAVE_W32_SYSTEM jnlib_tests += t-w32-reg @@ -194,7 +194,3 @@ t_b64_LDADD = $(t_common_ldadd) t_exechelp_LDADD = $(t_common_ldadd) t_session_env_LDADD = $(t_common_ldadd) t_openpgp_oid_LDADD = $(t_common_ldadd) - - - - diff --git a/common/README.jnlib b/common/README.jnlib index e8df795cb..50a29257e 100644 --- a/common/README.jnlib +++ b/common/README.jnlib @@ -60,7 +60,7 @@ libjnlib_a_SOURCES = \ logging.c logging.h \ dotlock.c dotlock.h \ types.h mischelp.c mischelp.h dynload.h w32help.h \ - xmalloc.c xmalloc.h + xmalloc.c xmalloc.h if HAVE_W32_SYSTEM libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h @@ -79,7 +79,7 @@ if HAVE_W32_SYSTEM module_tests += t-w32-reg endif -t_jnlib_src = t-support.c t-support.h +t_jnlib_src = t-support.c t-support.h t_jnlib_ldadd = libjnlib.a $(LIBINTL) $(LIBICONV) # For W32 we need libgpg-error because it provides gettext. if HAVE_W32_SYSTEM @@ -97,5 +97,3 @@ t_w32_reg_SOURCES = t-w32-reg.c $(t_jnlib_src) t_w32_reg_LDADD = $(t_jnlib_ldadd) endif ==>8=================================================== - - diff --git a/common/argparse.h b/common/argparse.h index 5bd18d28c..b2ed9eed8 100644 --- a/common/argparse.h +++ b/common/argparse.h @@ -24,12 +24,12 @@ #include "types.h" typedef struct -{ +{ int *argc; /* Pointer to ARGC (value subject to change). */ char ***argv; /* Pointer to ARGV (value subject to change). */ unsigned int flags; /* Global flags. May be set prior to calling the parser. The parser may change the value. */ - int err; /* Print error description for last option. + int err; /* Print error description for last option. Either 0, ARGPARSE_PRINT_WARNING or ARGPARSE_PRINT_ERROR. */ @@ -78,7 +78,7 @@ typedef struct #define ARGPARSE_TYPE_STRING 2 /* Takes a string argument. */ #define ARGPARSE_TYPE_LONG 3 /* Takes a long argument. */ #define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */ -#define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */ +#define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */ #define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */ #define ARGPARSE_OPT_COMMAND (1<<8) /* The argument is a command. */ @@ -149,7 +149,7 @@ typedef struct #define ARGPARSE_group(s,d) \ - { (s), NULL, 0, (d) } + { (s), NULL, 0, (d) } #define ARGPARSE_end() { 0, NULL, 0, NULL } diff --git a/common/asshelp.c b/common/asshelp.c index b8be103fc..c5d5a3359 100644 --- a/common/asshelp.c +++ b/common/asshelp.c @@ -32,7 +32,7 @@ #include "util.h" #include "exechelp.h" #include "sysutils.h" -#include "status.h" +#include "status.h" #include "asshelp.h" /* The type we use for lock_agent_spawning. */ @@ -43,7 +43,7 @@ #endif /* The time we wait until the agent or the dirmngr are ready for - operation after we started them before giving up. */ + operation after we started them before giving up. */ #ifdef HAVE_W32CE_SYSTEM # define SECS_TO_WAIT_FOR_AGENT 30 # define SECS_TO_WAIT_FOR_DIRMNGR 30 @@ -110,7 +110,7 @@ send_one_option (assuan_context_t ctx, gpg_err_source_t errsource, if (!value || !*value) err = 0; /* Avoid sending empty strings. */ - else if (asprintf (&optstr, "OPTION %s%s=%s", + else if (asprintf (&optstr, "OPTION %s%s=%s", use_putenv? "putenv=":"", name, value) < 0) err = gpg_error_from_syserror (); else @@ -136,7 +136,7 @@ send_pinentry_environment (assuan_context_t ctx, { gpg_error_t err = 0; #if defined(HAVE_SETLOCALE) - char *old_lc = NULL; + char *old_lc = NULL; #endif char *dft_lc = NULL; const char *dft_ttyname; @@ -144,7 +144,7 @@ send_pinentry_environment (assuan_context_t ctx, const char *name, *assname, *value; int is_default; - iterator = 0; + iterator = 0; while ((name = session_env_list_stdenvnames (&iterator, &assname))) { value = session_env_getenv_or_default (session_env, name, NULL); @@ -164,7 +164,7 @@ send_pinentry_environment (assuan_context_t ctx, } - dft_ttyname = session_env_getenv_or_default (session_env, "GPG_TTY", + dft_ttyname = session_env_getenv_or_default (session_env, "GPG_TTY", &is_default); if (dft_ttyname && !is_default) dft_ttyname = NULL; /* We need the default value. */ @@ -182,7 +182,7 @@ send_pinentry_environment (assuan_context_t ctx, #endif if (opt_lc_ctype || (dft_ttyname && dft_lc)) { - err = send_one_option (ctx, errsource, "lc-ctype", + err = send_one_option (ctx, errsource, "lc-ctype", opt_lc_ctype ? opt_lc_ctype : dft_lc, 0); } #if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) @@ -208,7 +208,7 @@ send_pinentry_environment (assuan_context_t ctx, #endif if (opt_lc_messages || (dft_ttyname && dft_lc)) { - err = send_one_option (ctx, errsource, "lc-messages", + err = send_one_option (ctx, errsource, "lc-messages", opt_lc_messages ? opt_lc_messages : dft_lc, 0); } #if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) @@ -240,7 +240,7 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name, (void)homedir; /* Not required. */ - *lock = CreateMutexW + *lock = CreateMutexW (NULL, FALSE, !strcmp (name, "agent")? L"GnuPG_spawn_agent_sentinel": !strcmp (name, "dirmngr")? L"GnuPG_spawn_dirmngr_sentinel": @@ -256,7 +256,7 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name, waitrc = WaitForSingleObject (*lock, 1000); if (waitrc == WAIT_OBJECT_0) return 0; - + if (waitrc == WAIT_TIMEOUT && timeout) { timeout--; @@ -268,7 +268,7 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name, if (waitrc == WAIT_TIMEOUT) log_info ("error waiting for the spawn_%s mutex: timeout\n", name); else - log_info ("error waiting for the spawn_%s mutex: (code=%d) %s\n", + log_info ("error waiting for the spawn_%s mutex: (code=%d) %s\n", name, waitrc, w32_strerror (-1)); return gpg_error (GPG_ERR_GENERAL); #else /*!HAVE_W32_SYSTEM*/ @@ -377,11 +377,11 @@ start_new_gpg_agent (assuan_context_t *r_ctx, if (verbose) log_info (_("no running gpg-agent - starting `%s'\n"), agent_program); - + if (status_cb) - status_cb (status_cb_arg, STATUS_PROGRESS, + status_cb (status_cb_arg, STATUS_PROGRESS, "starting_agent ? 0 0", NULL); - + if (fflush (NULL)) { gpg_error_t tmperr = gpg_err_make (errsource, @@ -392,9 +392,9 @@ start_new_gpg_agent (assuan_context_t *r_ctx, assuan_release (ctx); return tmperr; } - - argv[0] = "--use-standard-socket-p"; - argv[1] = NULL; + + argv[0] = "--use-standard-socket-p"; + argv[1] = NULL; err = gnupg_spawn_process_fd (agent_program, argv, -1, -1, -1, &pid); if (err) log_debug ("starting `%s' for testing failed: %s\n", @@ -404,7 +404,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx, if (excode == -1) log_debug ("running `%s' for testing failed (wait): %s\n", agent_program, gpg_strerror (err)); - } + } gnupg_release_process (pid); if (!err && !excode) @@ -416,8 +416,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx, lock_spawn_t lock; argv[0] = "--daemon"; - argv[1] = "--use-standard-socket"; - argv[2] = NULL; + argv[1] = "--use-standard-socket"; + argv[2] = NULL; if (!(err = lock_spawning (&lock, homedir, "agent", verbose)) && assuan_socket_connect (ctx, sockname, 0, 0)) @@ -463,22 +463,22 @@ start_new_gpg_agent (assuan_context_t *r_ctx, const char *pgmname; int no_close_list[3]; int i; - + if ( !(pgmname = strrchr (agent_program, '/'))) pgmname = agent_program; else pgmname++; - + argv[0] = pgmname; argv[1] = "--server"; argv[2] = NULL; - + i=0; if (log_get_fd () != -1) no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ()); no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr)); no_close_list[i] = -1; - + /* Connect to the agent and perform initial handshaking. */ err = assuan_pipe_connect (ctx, agent_program, argv, no_close_list, NULL, NULL, 0); @@ -566,7 +566,7 @@ start_new_dirmngr (assuan_context_t *r_ctx, assuan_context_t ctx; const char *sockname; int did_success_msg = 0; - + *r_ctx = NULL; err = assuan_new (&ctx); @@ -595,11 +595,11 @@ start_new_dirmngr (assuan_context_t *r_ctx, if (verbose) log_info (_("no running Dirmngr - starting `%s'\n"), dirmngr_program); - + if (status_cb) - status_cb (status_cb_arg, STATUS_PROGRESS, + status_cb (status_cb_arg, STATUS_PROGRESS, "starting_dirmngr ? 0 0", NULL); - + if (fflush (NULL)) { gpg_error_t tmperr = gpg_err_make (errsource, @@ -609,10 +609,10 @@ start_new_dirmngr (assuan_context_t *r_ctx, assuan_release (ctx); return tmperr; } - + argv[0] = "--daemon"; - argv[1] = NULL; - + argv[1] = NULL; + if (!(err = lock_spawning (&lock, homedir, "dirmngr", verbose)) && assuan_socket_connect (ctx, sockname, 0, 0)) { @@ -623,7 +623,7 @@ start_new_dirmngr (assuan_context_t *r_ctx, else { int i; - + for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++) { if (verbose) @@ -645,7 +645,7 @@ start_new_dirmngr (assuan_context_t *r_ctx, } } } - + unlock_spawning (&lock, "dirmngr"); } #else @@ -655,7 +655,7 @@ start_new_dirmngr (assuan_context_t *r_ctx, (void)status_cb; (void)status_cb_arg; #endif /*USE_DIRMNGR_AUTO_START*/ - + if (err) { log_error ("connecting dirmngr at `%s' failed: %s\n", @@ -670,4 +670,3 @@ start_new_dirmngr (assuan_context_t *r_ctx, *r_ctx = ctx; return 0; } - diff --git a/common/audit.c b/common/audit.c index 38d0c0c3d..ead28ceb1 100644 --- a/common/audit.c +++ b/common/audit.c @@ -57,7 +57,7 @@ struct audit_ctx_s { const char *failure; /* If set a description of the internal failure. */ audit_type_t type; - + log_item_t log; /* The table with the log entries. */ size_t logsize; /* The allocated size for LOG. */ size_t logused; /* The used size of LOG. */ @@ -71,17 +71,17 @@ struct audit_ctx_s -static void writeout_para (audit_ctx_t ctx, +static void writeout_para (audit_ctx_t ctx, const char *format, ...) JNLIB_GCC_A_PRINTF(2,3); static void writeout_li (audit_ctx_t ctx, const char *oktext, const char *format, ...) JNLIB_GCC_A_PRINTF(3,4); -static void writeout_rem (audit_ctx_t ctx, +static void writeout_rem (audit_ctx_t ctx, const char *format, ...) JNLIB_GCC_A_PRINTF(2,3); /* Add NAME to the list of help tags. NAME needs to be a const string an this function merly stores this pointer. */ -static void +static void add_helptag (audit_ctx_t ctx, const char *name) { helptag_t item; @@ -127,7 +127,7 @@ event2str (audit_event_t event) /* Create a new audit context. In case of an error NULL is returned - and errno set appropriately. */ + and errno set appropriately. */ audit_ctx_t audit_new (void) { @@ -228,7 +228,7 @@ create_log_item (audit_ctx_t ctx) item->cert = NULL; return item; - + } /* Add a new event to the audit log. If CTX is NULL, this function @@ -329,7 +329,7 @@ audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value) does nothing. This version also adds the certificate CERT and the result of an operation to the log. */ void -audit_log_cert (audit_ctx_t ctx, audit_event_t event, +audit_log_cert (audit_ctx_t ctx, audit_event_t event, ksba_cert_t cert, gpg_error_t err) { log_item_t item; @@ -348,14 +348,14 @@ audit_log_cert (audit_ctx_t ctx, audit_event_t event, item->have_err = 1; if (cert) { - ksba_cert_ref (cert); + ksba_cert_ref (cert); item->cert = cert; } } /* Write TEXT to the outstream. */ -static void +static void writeout (audit_ctx_t ctx, const char *text) { if (ctx->use_html) @@ -376,7 +376,7 @@ writeout (audit_ctx_t ctx, const char *text) /* Write TEXT to the outstream using a variable argument list. */ -static void +static void writeout_v (audit_ctx_t ctx, const char *format, va_list arg_ptr) { char *buf; @@ -440,7 +440,7 @@ leave_li (audit_ctx_t ctx) } } - + /* Write TEXT as a list element. If OKTEXT is not NULL, append it to the last line. */ static void @@ -451,7 +451,7 @@ writeout_li (audit_ctx_t ctx, const char *oktext, const char *format, ...) if (ctx->use_html && format && oktext) { - if (!strcmp (oktext, "Yes") + if (!strcmp (oktext, "Yes") || !strcmp (oktext, "good") ) color = "green"; else if (!strcmp (oktext, "No") @@ -530,13 +530,13 @@ writeout_li (audit_ctx_t ctx, const char *oktext, const char *format, ...) if (color) es_fprintf (ctx->outstream, "<font color=\"%s\">", color); } - else + else writeout (ctx, ": "); writeout (ctx, oktext); if (color) es_fputs ("</font>", ctx->outstream); } - + if (ctx->use_html) es_fputs ("</td></tr>\n", ctx->outstream); else @@ -579,7 +579,7 @@ writeout_rem (audit_ctx_t ctx, const char *format, ...) look behind that event in the log. If STARTITEM is not NULL start search _after_that item. */ static log_item_t -find_next_log_item (audit_ctx_t ctx, log_item_t startitem, +find_next_log_item (audit_ctx_t ctx, log_item_t startitem, audit_event_t event, audit_event_t stopevent) { int idx; @@ -725,9 +725,9 @@ list_certchain (audit_ctx_t ctx, log_item_t startitem, audit_event_t stopevent) startitem = find_next_log_item (ctx, startitem, AUDIT_CHAIN_BEGIN,stopevent); writeout_li (ctx, startitem? "Yes":"No", _("Certificate chain available")); if (!startitem) - return; + return; - item = find_next_log_item (ctx, startitem, + item = find_next_log_item (ctx, startitem, AUDIT_CHAIN_ROOTCERT, AUDIT_CHAIN_END); if (!item) writeout_rem (ctx, "%s", _("root certificate missing")); @@ -736,7 +736,7 @@ list_certchain (audit_ctx_t ctx, log_item_t startitem, audit_event_t stopevent) list_cert (ctx, item->cert, 0); } item = startitem; - while ( ((item = find_next_log_item (ctx, item, + while ( ((item = find_next_log_item (ctx, item, AUDIT_CHAIN_CERT, AUDIT_CHAIN_END)))) { list_cert (ctx, item->cert, 1); @@ -779,7 +779,7 @@ proc_type_encrypt (audit_ctx_t ctx) } item = find_log_item (ctx, AUDIT_GOT_RECIPIENTS, 0); - snprintf (numbuf, sizeof numbuf, "%d", + snprintf (numbuf, sizeof numbuf, "%d", item && item->have_intvalue? item->intvalue : 0); writeout_li (ctx, numbuf, "%s", _("Number of recipients")); @@ -830,7 +830,7 @@ proc_type_sign (audit_ctx_t ctx) writeout_li (ctx, item? "Yes":"No", "%s", _("Data available")); /* Write remarks with the data hash algorithms. We use a very simple scheme to avoid some duplicates. */ - loopitem = NULL; + loopitem = NULL; lastalgo = 0; while ((loopitem = find_next_log_item (ctx, loopitem, AUDIT_DATA_HASH_ALGO, AUDIT_NEW_SIG))) @@ -1033,7 +1033,7 @@ proc_type_verify (audit_ctx_t ctx) writeout_rem (ctx, _("data hash algorithm: %s"), gcry_md_algo_name (item->intvalue)); else if (item->event == AUDIT_BAD_DATA_HASH_ALGO) - writeout_rem (ctx, _("bad data hash algorithm: %s"), + writeout_rem (ctx, _("bad data hash algorithm: %s"), item->string? item->string:"?"); } } @@ -1066,7 +1066,7 @@ proc_type_verify (audit_ctx_t ctx) gcry_md_algo_name (item->intvalue)); enter_li (ctx); - + /* List the certificate chain. */ list_certchain (ctx, loopitem, AUDIT_NEW_SIG); @@ -1075,12 +1075,12 @@ proc_type_verify (audit_ctx_t ctx) AUDIT_CHAIN_STATUS, AUDIT_NEW_SIG); if (item && item->have_err) { - writeout_li (ctx, item->err? "No":"Yes", + writeout_li (ctx, item->err? "No":"Yes", _("Certificate chain valid")); if (item->err) writeout_rem (ctx, "%s", gpg_strerror (item->err)); } - + /* Show whether the root certificate is fine. */ item = find_next_log_item (ctx, loopitem, AUDIT_ROOT_TRUSTED, AUDIT_CHAIN_STATUS); @@ -1115,9 +1115,9 @@ proc_type_verify (audit_ctx_t ctx) break; default: ok = gpg_strerror (item->err); break; } - + writeout_li (ctx, ok, "%s", _("CRL/OCSP check of certificates")); - if (item->err + if (item->err && gpg_err_code (item->err) != GPG_ERR_CERT_REVOKED && gpg_err_code (item->err) != GPG_ERR_NOT_ENABLED) add_helptag (ctx, "gpgsm.crl-problem"); @@ -1132,13 +1132,13 @@ proc_type_verify (audit_ctx_t ctx) /* Always list the certificates stored in the signature. */ item = NULL; count = 0; - while ( ((item = find_next_log_item (ctx, item, + while ( ((item = find_next_log_item (ctx, item, AUDIT_SAVE_CERT, AUDIT_NEW_SIG)))) count++; snprintf (numbuf, sizeof numbuf, "%d", count); writeout_li (ctx, numbuf, _("Included certificates")); item = NULL; - while ( ((item = find_next_log_item (ctx, item, + while ( ((item = find_next_log_item (ctx, item, AUDIT_SAVE_CERT, AUDIT_NEW_SIG)))) { char *name = get_cert_name (item->cert); @@ -1169,7 +1169,7 @@ audit_print_result (audit_ctx_t ctx, estream_t out, int use_html) const char *s; int show_raw = 0; char *orig_codeset; - + if (!ctx) return; @@ -1201,31 +1201,31 @@ audit_print_result (audit_ctx_t ctx, estream_t out, int use_html) for (idx=0,maxlen=0; idx < DIM (eventstr_msgidx); idx++) { - n = strlen (eventstr_msgstr + eventstr_msgidx[idx]); + n = strlen (eventstr_msgstr + eventstr_msgidx[idx]); if (n > maxlen) maxlen = n; } - + if (use_html) es_fputs ("<pre>\n", out); for (idx=0; idx < ctx->logused; idx++) { - es_fprintf (out, "log: %-*s", + es_fprintf (out, "log: %-*s", maxlen, event2str (ctx->log[idx].event)); if (ctx->log[idx].have_intvalue) - es_fprintf (out, " i=%d", ctx->log[idx].intvalue); + es_fprintf (out, " i=%d", ctx->log[idx].intvalue); if (ctx->log[idx].string) { - es_fputs (" s=`", out); - writeout (ctx, ctx->log[idx].string); - es_fputs ("'", out); + es_fputs (" s=`", out); + writeout (ctx, ctx->log[idx].string); + es_fputs ("'", out); } if (ctx->log[idx].cert) - es_fprintf (out, " has_cert"); + es_fprintf (out, " has_cert"); if (ctx->log[idx].have_err) { es_fputs (" err=`", out); - writeout (ctx, gpg_strerror (ctx->log[idx].err)); + writeout (ctx, gpg_strerror (ctx->log[idx].err)); es_fputs ("'", out); } es_fputs ("\n", out); @@ -1321,4 +1321,3 @@ audit_print_result (audit_ctx_t ctx, estream_t out, int use_html) clear_helptags (ctx); i18n_switchback (orig_codeset); } - diff --git a/common/audit.h b/common/audit.h index 8f413aa30..77d8f0632 100644 --- a/common/audit.h +++ b/common/audit.h @@ -56,7 +56,7 @@ typedef enum /* Indicates whether the gpg-agent is available. For some operations the agent is not required and thus no such event will be logged. */ - + AUDIT_DIRMNGR_READY, /* err */ /* Indicates whether the Dirmngr is available. For some operations the Dirmngr is not required and thus no such event @@ -115,7 +115,7 @@ typedef enum /* The program was used in an inappropriate way; For example by passing a data object while the signature does not expect one or vice versa. */ - + AUDIT_SAVE_CERT, /* cert, ok_err */ /* Save the certificate received in a message. */ @@ -123,7 +123,7 @@ typedef enum /* Start the verification of a new signature for the last data object. The argument is the signature number as used internally by the program. */ - + AUDIT_SIG_NAME, /* string */ /* The name of a signer. This is the name or other identification data as known from the signature and not the name from the @@ -135,7 +135,7 @@ typedef enum audit information for one signature. STRING gives the status: "error" - there was a problem checking this or any signature. - "unsupported" - the signature type is not supported. + "unsupported" - the signature type is not supported. "no-cert" - The certificate of the signer was not found (the S/N+issuer of the signer is already in the log). "bad" - bad signature @@ -145,7 +145,7 @@ typedef enum AUDIT_NEW_RECP, /* int */ /* A new recipient has been seen during decryption. The argument is the recipient number as used internally by the program. */ - + AUDIT_RECP_NAME, /* string */ /* The name of a recipient. This is the name or other identification data as known from the decryption and not the name from the @@ -169,7 +169,7 @@ typedef enum AUDIT_CHAIN_END, /* These 4 events are used to log the certificates making up a certificate chain. ROOTCERT is used for the trustanchor and - CERT for all other certificates. */ + CERT for all other certificates. */ AUDIT_CHAIN_STATUS, /* err */ /* Tells the final status of the chain validation. */ @@ -217,7 +217,7 @@ void audit_log (audit_ctx_t ctx, audit_event_t event); void audit_log_ok (audit_ctx_t ctx, audit_event_t event, gpg_error_t err); void audit_log_i (audit_ctx_t ctx, audit_event_t event, int value); void audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value); -void audit_log_cert (audit_ctx_t ctx, audit_event_t event, +void audit_log_cert (audit_ctx_t ctx, audit_event_t event, ksba_cert_t cert, gpg_error_t err); void audit_print_result (audit_ctx_t ctx, estream_t stream, int use_html); diff --git a/common/b64dec.c b/common/b64dec.c index 137dd7216..edd72c6a9 100644 --- a/common/b64dec.c +++ b/common/b64dec.c @@ -29,7 +29,7 @@ /* The reverse base-64 list used for base-64 decoding. */ -static unsigned char const asctobin[128] = +static unsigned char const asctobin[128] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -49,7 +49,7 @@ static unsigned char const asctobin[128] = 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff }; -enum decoder_states +enum decoder_states { s_init, s_idle, s_lfseen, s_begin, s_b64_0, s_b64_1, s_b64_2, s_b64_3, @@ -62,7 +62,7 @@ enum decoder_states plain base64 decoding is done. If it is the empty string the decoder will skip everything until a "-----BEGIN " line has been seen, decoding ends at a "----END " line. - + Not yet implemented: If TITLE is either "PGP" or begins with "PGP " the PGP armor lines are skipped as well. */ gpg_error_t @@ -96,7 +96,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length, { enum decoder_states ds = state->idx; unsigned char val = state->radbuf[0]; - int pos = state->quad_count; + int pos = state->quad_count; char *d, *s; if (state->lasterr) @@ -110,7 +110,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length, state->title = NULL; return state->lasterr; } - + for (s=d=buffer; length && !state->stop_seen; length--, s++) { switch (ds) @@ -143,7 +143,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length, { int c; - if (*s == '-' && state->title) + if (*s == '-' && state->title) { /* Not a valid Base64 character: assume end header. */ @@ -158,7 +158,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length, } else if (*s == '\n' || *s == ' ' || *s == '\r' || *s == '\t') ; /* Skip white spaces. */ - else if ( (*s & 0x80) + else if ( (*s & 0x80) || (c = asctobin[*(unsigned char *)s]) == 255) { /* Skip invalid encodings. */ @@ -198,8 +198,8 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length, case s_waitend: if ( *s == '\n') state->stop_seen = 1; - break; - default: + break; + default: BUG(); } } @@ -207,7 +207,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length, state->idx = ds; state->radbuf[0] = val; - state->quad_count = pos; + state->quad_count = pos; *r_nbytes = (d -(char*) buffer); return 0; } @@ -226,4 +226,3 @@ b64dec_finish (struct b64state *state) state->title = NULL; return state->invalid_encoding? gpg_error(GPG_ERR_BAD_DATA): 0; } - diff --git a/common/b64enc.c b/common/b64enc.c index 5d616198e..eae796c6e 100644 --- a/common/b64enc.c +++ b/common/b64enc.c @@ -34,25 +34,25 @@ #define B64ENC_USE_PGPCRC 32 /* The base-64 character list */ -static unsigned char bintoasc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; +static unsigned char bintoasc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789+/"; /* Stuff required to create the OpenPGP CRC. This crc_table has been created using this code: #include <stdio.h> #include <stdint.h> - + #define CRCPOLY 0x864CFB - + int main (void) { int i, j; uint32_t t; uint32_t crc_table[256]; - + crc_table[0] = 0; for (i=j=0; j < 128; j++ ) { @@ -70,7 +70,7 @@ static unsigned char bintoasc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" crc_table[i++] = t ^ CRCPOLY; } } - + puts ("static const u32 crc_table[256] = {"); for (i=j=0; i < 256; i++) { @@ -224,11 +224,11 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes) || my_fputs (state->title, state) == EOF || my_fputs ("-----\n", state) == EOF) goto write_error; - if ( (state->flags & B64ENC_USE_PGPCRC) + if ( (state->flags & B64ENC_USE_PGPCRC) && my_fputs ("\n", state) == EOF) goto write_error; } - + state->flags |= B64ENC_DID_HEADER; } @@ -274,7 +274,7 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes) if (ferror (state->fp)) goto write_error; } - if (++quad_count >= (64/4)) + if (++quad_count >= (64/4)) { quad_count = 0; if (!(state->flags & B64ENC_NO_LINEFEEDS) @@ -328,8 +328,8 @@ b64enc_finish (struct b64state *state) tmp[2] = '='; tmp[3] = '='; } - else - { + else + { tmp[1] = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077]; tmp[2] = bintoasc[((radbuf[1] << 2) & 074) & 077]; tmp[3] = '='; @@ -351,7 +351,7 @@ b64enc_finish (struct b64state *state) goto write_error; } - if (++quad_count >= (64/4)) + if (++quad_count >= (64/4)) { quad_count = 0; if (!(state->flags & B64ENC_NO_LINEFEEDS) @@ -365,7 +365,7 @@ b64enc_finish (struct b64state *state) && !(state->flags & B64ENC_NO_LINEFEEDS) && my_fputs ("\n", state) == EOF) goto write_error; - + if ( (state->flags & B64ENC_USE_PGPCRC) ) { /* Write the CRC. */ @@ -420,4 +420,3 @@ b64enc_finish (struct b64state *state) state->lasterr = err; return err; } - diff --git a/common/dns-cert.c b/common/dns-cert.c index 80ba7d06d..888ffb7b1 100644 --- a/common/dns-cert.c +++ b/common/dns-cert.c @@ -82,7 +82,7 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf, adns_finish (state); return -1; } - if (answer->status != adns_s_ok) + if (answer->status != adns_s_ok) { /* log_error ("DNS query returned an error: %s (%s)\n", */ /* adns_strerror (answer->status), */ @@ -112,7 +112,7 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf, *iobuf = iobuf_temp_with_content ((char*)data, datalen); rc = 1; } - else if (ctype == 6 && datalen && datalen < 1023 + else if (ctype == 6 && datalen && datalen < 1023 && datalen >= data[0]+1 && fpr && fpr_len && url) { /* CERT type is IPGP. We made sure tha the data is @@ -126,7 +126,7 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf, } else *fpr = NULL; - + if (datalen > *fpr_len + 1) { *url = xmalloc (datalen - (*fpr_len+1) + 1); @@ -135,11 +135,11 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf, } else *url = NULL; - + rc = 2; } } - + adns_free (answer); adns_finish (state); return rc; diff --git a/common/dotlock.c b/common/dotlock.c index c41f69481..507546562 100644 --- a/common/dotlock.c +++ b/common/dotlock.c @@ -1,5 +1,5 @@ /* dotlock.c - dotfile locking - * Copyright (C) 1998, 2000, 2001, 2003, 2004, + * Copyright (C) 1998, 2000, 2001, 2003, 2004, * 2005, 2006, 2008, 2010 Free Software Foundation, Inc. * * This file is part of JNLIB. @@ -61,7 +61,7 @@ /* The object describing a lock. */ -struct dotlock_handle +struct dotlock_handle { struct dotlock_handle *next; char *lockname; /* Name of the actual lockfile. */ @@ -112,7 +112,7 @@ disable_dotlock(void) Calling this function with NULL does only install the atexit handler and may thus be used to assure that the cleanup is called after all other atexit handlers. - + This function creates a lock file in the same directory as FILE_TO_LOCK using that name and a suffix of ".lock". Note that on POSIX systems a temporary file ".#lk.<hostname>.pid[.threadid] is @@ -174,7 +174,7 @@ create_dotlock (const char *file_to_lock) nodename = "unknown"; else nodename = utsbuf.nodename; - + #ifdef __riscos__ { char *iter = (char *) nodename; @@ -223,15 +223,15 @@ create_dotlock (const char *file_to_lock) "%s/%d", nodename, (int)getpid () ); #endif /* __riscos__ */ - do + do { jnlib_set_errno (0); fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL, S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR ); - } + } while (fd == -1 && errno == EINTR); - if ( fd == -1 ) + if ( fd == -1 ) { all_lockfiles = h->next; log_error (_("failed to create temporary file `%s': %s\n"), @@ -303,11 +303,11 @@ create_dotlock (const char *file_to_lock) reasons why a lock file can't be created and thus the process would not stop as expected but spin til until Windows crashes. Our solution is to keep the lock file open; that does not - harm. */ + harm. */ { #ifdef HAVE_W32CE_SYSTEM wchar_t *wname = utf8_to_wchar (h->lockname); - + h->lockhd = INVALID_HANDLE_VALUE; if (wname) h->lockhd = CreateFile (wname, @@ -318,7 +318,7 @@ create_dotlock (const char *file_to_lock) FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL); #ifdef HAVE_W32CE_SYSTEM - jnlib_free (wname); + jnlib_free (wname); #endif } if (h->lockhd == INVALID_HANDLE_VALUE) @@ -355,7 +355,7 @@ destroy_dotlock (dotlock_t h) h->next = NULL; break; } - + /* Then destroy the lock. */ if (!h->disable) { @@ -364,7 +364,7 @@ destroy_dotlock (dotlock_t h) { OVERLAPPED ovl; - memset (&ovl, 0, sizeof ovl); + memset (&ovl, 0, sizeof ovl); UnlockFileEx (h->lockhd, 0, 1, 0, &ovl); } CloseHandle (h->lockhd); @@ -414,7 +414,7 @@ make_dotlock (dotlock_t h, long timeout) if ( h->disable ) return 0; /* Locks are completely disabled. Return success. */ - if ( h->locked ) + if ( h->locked ) { #ifndef __riscos__ log_debug ("Oops, `%s' is already locked\n", h->lockname); @@ -438,19 +438,19 @@ make_dotlock (dotlock_t h, long timeout) return -1; } # else /* __riscos__ */ - if ( !renamefile(h->tname, h->lockname) ) + if ( !renamefile(h->tname, h->lockname) ) { h->locked = 1; return 0; /* okay */ } - if ( errno != EEXIST ) + if ( errno != EEXIST ) { log_error( "lock not made: rename() failed: %s\n", strerror(errno) ); return -1; } # endif /* __riscos__ */ - if ( (pid = read_lockfile (h, &same_node)) == -1 ) + if ( (pid = read_lockfile (h, &same_node)) == -1 ) { if ( errno != ENOENT ) { @@ -480,11 +480,11 @@ make_dotlock (dotlock_t h, long timeout) # endif /* __riscos__ */ } - if ( timeout == -1 ) + if ( timeout == -1 ) { /* Wait until lock has been released. */ struct timeval tv; - + log_info (_("waiting for lock (held by %d%s) %s...\n"), pid, maybe_dead, maybe_deadlock(h)? _("(deadlock?) "):""); @@ -503,7 +503,7 @@ make_dotlock (dotlock_t h, long timeout) OVERLAPPED ovl; /* Lock one byte at offset 0. The offset is given by OVL. */ - memset (&ovl, 0, sizeof ovl); + memset (&ovl, 0, sizeof ovl); if (LockFileEx (h->lockhd, (LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY), 0, 1, 0, &ovl)) { @@ -518,7 +518,7 @@ make_dotlock (dotlock_t h, long timeout) return -1; } - if ( timeout == -1 ) + if ( timeout == -1 ) { /* Wait until lock has been released. */ log_info (_("waiting for lock %s...\n"), h->lockname); @@ -561,8 +561,8 @@ release_dotlock (dotlock_t h) #ifdef HAVE_DOSISH_SYSTEM { OVERLAPPED ovl; - - memset (&ovl, 0, sizeof ovl); + + memset (&ovl, 0, sizeof ovl); if (!UnlockFileEx (h->lockhd, 0, 1, 0, &ovl)) { log_error ("release_dotlock: error removing lockfile `%s': %s\n", @@ -573,7 +573,7 @@ release_dotlock (dotlock_t h) #else pid = read_lockfile (h, &same_node); - if ( pid == -1 ) + if ( pid == -1 ) { log_error( "release_dotlock: lockfile error\n"); return -1; @@ -594,7 +594,7 @@ release_dotlock (dotlock_t h) /* Fixme: As an extra check we could check whether the link count is now really at 1. */ #else /* __riscos__ */ - if ( renamefile (h->lockname, h->tname) ) + if ( renamefile (h->lockname, h->tname) ) { log_error ("release_dotlock: error renaming lockfile `%s' to `%s'\n", h->lockname, h->tname); @@ -622,7 +622,7 @@ read_lockfile (dotlock_t h, int *same_node ) char *buffer, *p; size_t expected_len; int res, nread; - + *same_node = 0; expected_len = 10 + 1 + h->nodename_len + 1; if ( expected_len >= sizeof buffer_space) @@ -655,7 +655,7 @@ read_lockfile (dotlock_t h, int *same_node ) if (res < 0) { log_info ("error reading lockfile `%s'", h->lockname ); - close (fd); + close (fd); if (buffer != buffer_space) jnlib_free (buffer); jnlib_set_errno (0); /* Do not return an inappropriate ERRNO. */ @@ -679,7 +679,7 @@ read_lockfile (dotlock_t h, int *same_node ) if (buffer[10] != '\n' || (buffer[10] = 0, pid = atoi (buffer)) == -1 #ifndef __riscos__ - || !pid + || !pid #else /* __riscos__ */ || (!pid && riscos_getpid()) #endif /* __riscos__ */ @@ -693,7 +693,7 @@ read_lockfile (dotlock_t h, int *same_node ) } if (nread == expected_len - && !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len) + && !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len) && buffer[11+h->nodename_len] == '\n') *same_node = 1; @@ -711,10 +711,10 @@ void dotlock_remove_lockfiles (void) { dotlock_t h, h2; - + h = all_lockfiles; all_lockfiles = NULL; - + while ( h ) { h2 = h->next; @@ -722,4 +722,3 @@ dotlock_remove_lockfiles (void) h = h2; } } - diff --git a/common/dynload.h b/common/dynload.h index 0c8a3bbaa..84407c2d5 100644 --- a/common/dynload.h +++ b/common/dynload.h @@ -81,6 +81,6 @@ dlclose (void * hd) return 0; } return -1; -} +} # endif /*__MINGW32__*/ #endif /*LIBJNLIB_DYNLOAD_H*/ diff --git a/common/estream-printf.c b/common/estream-printf.c index 3955a01cb..797f9aa30 100644 --- a/common/estream-printf.c +++ b/common/estream-printf.c @@ -93,7 +93,7 @@ #if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T) # ifdef HAVE_STDINT_H # include <stdint.h> -# endif +# endif #endif #ifdef HAVE_LANGINFO_THOUSANDS_SEP #include <langinfo.h> @@ -111,12 +111,12 @@ /* Allow redefinition of asprintf used malloc functions. */ #if defined(_ESTREAM_PRINTF_MALLOC) -#define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a)) +#define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a)) #else #define my_printf_malloc(a) malloc((a)) #endif #if defined(_ESTREAM_PRINTF_FREE) -#define my_printf_free(a) _ESTREAM_PRINTF_FREE((a)) +#define my_printf_free(a) _ESTREAM_PRINTF_FREE((a)) #else #define my_printf_free(a) free((a)) #endif @@ -233,7 +233,7 @@ typedef enum /* A union used to store the actual values. */ -typedef union +typedef union { char a_char; signed char a_schar; @@ -317,7 +317,7 @@ dump_argspecs (argspec_t arg, size_t argcount) int idx; for (idx=0; argcount; argcount--, arg++, idx++) - fprintf (stderr, + fprintf (stderr, "%2d: len=%u flags=%u width=%d prec=%d mod=%d " "con=%d vt=%d pos=%d-%d-%d\n", idx, @@ -341,8 +341,8 @@ compute_type (argspec_t arg) { switch (arg->conspec) { - case CONSPEC_UNKNOWN: - arg->vt = VALTYPE_UNSUPPORTED; + case CONSPEC_UNKNOWN: + arg->vt = VALTYPE_UNSUPPORTED; break; case CONSPEC_DECIMAL: @@ -353,7 +353,7 @@ compute_type (argspec_t arg) case LENMOD_LONG: arg->vt = VALTYPE_LONG; break; case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break; case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break; - case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; + case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break; default: arg->vt = VALTYPE_INT; break; } @@ -370,12 +370,12 @@ compute_type (argspec_t arg) case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break; case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break; case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break; - case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; + case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break; default: arg->vt = VALTYPE_UINT; break; } break; - + case CONSPEC_FLOAT: case CONSPEC_FLOAT_UP: case CONSPEC_EXP: @@ -391,9 +391,9 @@ compute_type (argspec_t arg) default: arg->vt = VALTYPE_DOUBLE; break; } break; - + case CONSPEC_CHAR: - arg->vt = VALTYPE_INT; + arg->vt = VALTYPE_INT; break; case CONSPEC_STRING: @@ -416,12 +416,12 @@ compute_type (argspec_t arg) case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break; case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break; case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break; - case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break; + case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break; case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break; default: arg->vt = VALTYPE_INT_PTR; break; } break; - + } } @@ -446,7 +446,7 @@ parse_format (const char *format, if (!format) goto leave_einval; - + for (; *format; format++) { unsigned int flags; @@ -454,7 +454,7 @@ parse_format (const char *format, lenmod_t lenmod; conspec_t conspec; int arg_pos, width_pos, precision_pos; - + if (*format != '%') continue; s = ++format; @@ -468,7 +468,7 @@ parse_format (const char *format, if (*s >= '1' && *s <= '9') { const char *save_s = s; - + arg_pos = (*s++ - '0'); for (; *s >= '0' && *s <= '9'; s++) arg_pos = 10*arg_pos + (*s - '0'); @@ -482,7 +482,7 @@ parse_format (const char *format, s = save_s; } } - + /* Parse the flags. */ flags = 0; for ( ; *s; s++) @@ -500,7 +500,7 @@ parse_format (const char *format, } } flags_parsed: - + /* Parse the field width. */ width_pos = 0; if (*s == '*') @@ -583,11 +583,11 @@ parse_format (const char *format, if (ignore_value) precision = NO_FIELD_VALUE; } - + /* Parse the length modifiers. */ switch (*s) { - case 'h': + case 'h': if (s[1] == 'h') { lenmod = LENMOD_CHAR; @@ -613,7 +613,7 @@ parse_format (const char *format, case 'L': lenmod = LENMOD_LONGDBL; s++; break; default: lenmod = LENMOD_NONE; break; } - + /* Parse the conversion specifier. */ switch (*s) { @@ -683,7 +683,7 @@ parse_format (const char *format, *argspecs_addr = argspecs; *r_argspecs_count = argcount; return 0; /* Success. */ - + leave_einval: _set_errno (EINVAL); leave: @@ -714,14 +714,14 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs) value->a_char_ptr = va_arg (vaargs, char *); break; case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break; - case VALTYPE_SCHAR_PTR: - value->a_schar_ptr = va_arg (vaargs, signed char *); + case VALTYPE_SCHAR_PTR: + value->a_schar_ptr = va_arg (vaargs, signed char *); break; case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break; case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break; case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break; - case VALTYPE_SHORT_PTR: - value->a_short_ptr = va_arg (vaargs, short *); + case VALTYPE_SHORT_PTR: + value->a_short_ptr = va_arg (vaargs, short *); break; case VALTYPE_INT: value->a_int = va_arg (vaargs, int); @@ -735,20 +735,20 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs) case VALTYPE_LONG: value->a_long = va_arg (vaargs, long); break; - case VALTYPE_ULONG: + case VALTYPE_ULONG: value->a_ulong = va_arg (vaargs, unsigned long); break; - case VALTYPE_LONG_PTR: - value->a_long_ptr = va_arg (vaargs, long *); + case VALTYPE_LONG_PTR: + value->a_long_ptr = va_arg (vaargs, long *); break; #ifdef HAVE_LONG_LONG_INT case VALTYPE_LONGLONG: value->a_longlong = va_arg (vaargs, long long int); break; - case VALTYPE_ULONGLONG: - value->a_ulonglong = va_arg (vaargs, unsigned long long int); + case VALTYPE_ULONGLONG: + value->a_ulonglong = va_arg (vaargs, unsigned long long int); break; - case VALTYPE_LONGLONG_PTR: + case VALTYPE_LONGLONG_PTR: value->a_longlong_ptr = va_arg (vaargs, long long *); break; #endif @@ -763,31 +763,31 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs) case VALTYPE_STRING: value->a_string = va_arg (vaargs, const char *); break; - case VALTYPE_POINTER: + case VALTYPE_POINTER: value->a_void_ptr = va_arg (vaargs, void *); break; #ifdef HAVE_INTMAX_T case VALTYPE_INTMAX: value->a_intmax = va_arg (vaargs, intmax_t); break; - case VALTYPE_INTMAX_PTR: - value->a_intmax_ptr = va_arg (vaargs, intmax_t *); + case VALTYPE_INTMAX_PTR: + value->a_intmax_ptr = va_arg (vaargs, intmax_t *); break; #endif #ifdef HAVE_UINTMAX_T - case VALTYPE_UINTMAX: - value->a_uintmax = va_arg (vaargs, uintmax_t); + case VALTYPE_UINTMAX: + value->a_uintmax = va_arg (vaargs, uintmax_t); break; #endif case VALTYPE_SIZE: value->a_size = va_arg (vaargs, size_t); break; - case VALTYPE_SIZE_PTR: - value->a_size_ptr = va_arg (vaargs, size_t *); + case VALTYPE_SIZE_PTR: + value->a_size_ptr = va_arg (vaargs, size_t *); break; #ifdef HAVE_PTRDIFF_T case VALTYPE_PTRDIFF: - value->a_ptrdiff = va_arg (vaargs, ptrdiff_t); + value->a_ptrdiff = va_arg (vaargs, ptrdiff_t); break; case VALTYPE_PTRDIFF_PTR: value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *); @@ -822,7 +822,7 @@ pad_out (estream_printf_out_t outfnc, void *outfncarg, *nbytes += n; count -= n; } - + return 0; } @@ -859,18 +859,18 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg, { case VALTYPE_SHORT: along = value.a_short; break; case VALTYPE_INT: along = value.a_int; break; - case VALTYPE_LONG: along = value.a_long; break; + case VALTYPE_LONG: along = value.a_long; break; #ifdef HAVE_LONG_LONG_INT - case VALTYPE_LONGLONG: along = value.a_longlong; break; - case VALTYPE_SIZE: along = value.a_size; break; + case VALTYPE_LONGLONG: along = value.a_longlong; break; + case VALTYPE_SIZE: along = value.a_size; break; # ifdef HAVE_INTMAX_T - case VALTYPE_INTMAX: along = value.a_intmax; break; + case VALTYPE_INTMAX: along = value.a_intmax; break; # endif # ifdef HAVE_PTRDIFF_T - case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break; + case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break; # endif #endif /*HAVE_LONG_LONG_INT*/ - default: + default: return -1; } if (along < 0) @@ -887,18 +887,18 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg, { case VALTYPE_USHORT: aulong = value.a_ushort; break; case VALTYPE_UINT: aulong = value.a_uint; break; - case VALTYPE_ULONG: aulong = value.a_ulong; break; + case VALTYPE_ULONG: aulong = value.a_ulong; break; #ifdef HAVE_LONG_LONG_INT - case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break; - case VALTYPE_SIZE: aulong = value.a_size; break; + case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break; + case VALTYPE_SIZE: aulong = value.a_size; break; # ifdef HAVE_UINTMAX_T - case VALTYPE_UINTMAX: aulong = value.a_uintmax; break; + case VALTYPE_UINTMAX: aulong = value.a_uintmax; break; # endif # ifdef HAVE_PTRDIFF_T - case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break; + case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break; # endif #endif /*HAVE_LONG_LONG_INT*/ - default: + default: return -1; } } @@ -929,7 +929,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg, do { - if ((arg->flags & FLAG_GROUPING) + if ((arg->flags & FLAG_GROUPING) && (++grouping == 3) && *grouping_string) { *--p = *grouping_string; @@ -964,7 +964,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg, if ((arg->flags & FLAG_ALT_CONV)) n_extra += 2; } - + n = pend - p; if ((arg->flags & FLAG_ZERO_PAD) @@ -1009,7 +1009,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg, if (rc) return rc; } - + rc = outfnc (outfncarg, p, pend - p); if (rc) return rc; @@ -1062,7 +1062,7 @@ pr_float (estream_printf_out_t outfnc, void *outfncarg, adblfloat = value.a_longdouble; use_dbl=1; break; #endif - default: + default: return -1; } @@ -1173,7 +1173,7 @@ pr_char (estream_printf_out_t outfnc, void *outfncarg, if(rc) return rc; *nbytes += 1; - + return 0; } @@ -1194,7 +1194,7 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg, string = "(null)"; if (arg->precision >= 0) { - for (n=0,s=string; *s && n < arg->precision; s++) + for (n=0,s=string; *s && n < arg->precision; s++) n++; } else @@ -1220,7 +1220,7 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg, if (rc) return rc; } - + return 0; } @@ -1261,7 +1261,7 @@ pr_pointer (estream_printf_out_t outfnc, void *outfncarg, *--p = '0'; *--p = 'x'; *--p = '0'; - + rc = outfnc (outfncarg, p, pend - p); if (rc) return rc; @@ -1280,14 +1280,14 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg, switch (arg->vt) { - case VALTYPE_SCHAR_PTR: - *value.a_schar_ptr = (signed char)(unsigned int)(*nbytes); + case VALTYPE_SCHAR_PTR: + *value.a_schar_ptr = (signed char)(unsigned int)(*nbytes); break; - case VALTYPE_SHORT_PTR: + case VALTYPE_SHORT_PTR: *value.a_short_ptr = (short)(unsigned int)(*nbytes); break; - case VALTYPE_LONG_PTR: - *value.a_long_ptr = (long)(*nbytes); + case VALTYPE_LONG_PTR: + *value.a_long_ptr = (long)(*nbytes); break; #ifdef HAVE_LONG_LONG_INT case VALTYPE_LONGLONG_PTR: @@ -1295,12 +1295,12 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg, break; #endif #ifdef HAVE_INTMAX_T - case VALTYPE_INTMAX_PTR: + case VALTYPE_INTMAX_PTR: *value.a_intmax_ptr = (intmax_t)(*nbytes); break; #endif case VALTYPE_SIZE_PTR: - *value.a_size_ptr = (*nbytes); + *value.a_size_ptr = (*nbytes); break; #ifdef HAVE_PTRDIFF_T case VALTYPE_PTRDIFF_PTR: @@ -1325,8 +1325,8 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg, holds the values and may be directly addressed using the position arguments given by ARGSPECS. MYERRNO is used for the "%m" conversion. NBYTES well be updated to reflect the number of bytes - send to the output function. */ -static int + send to the output function. */ +static int do_format (estream_printf_out_t outfnc, void *outfncarg, const char *format, argspec_t argspecs, size_t argspecs_len, valueitem_t valuetable, int myerrno, size_t *nbytes) @@ -1370,7 +1370,7 @@ do_format (estream_printf_out_t outfnc, void *outfncarg, /* Save the next start. */ s += arg->length; format = s; - + assert (argidx < argspecs_len); argidx++; @@ -1438,9 +1438,9 @@ do_format (estream_printf_out_t outfnc, void *outfncarg, } if (rc) return rc; - arg++; + arg++; } - + /* Print out any trailing stuff. */ n = s - format; rc = n? outfnc (outfncarg, format, n) : 0; @@ -1458,7 +1458,7 @@ do_format (estream_printf_out_t outfnc, void *outfncarg, output of the formatted stuff. FORMAT is the format specification and VAARGS a variable argumemt list matching the arguments of FORMAT. */ -int +int estream_format (estream_printf_out_t outfnc, void *outfncarg, const char *format, va_list vaargs) @@ -1493,7 +1493,7 @@ estream_format (estream_printf_out_t outfnc, /* Check that all ARG_POS fields are set. */ for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++) { - if (argspecs[argidx].arg_pos != -1 + if (argspecs[argidx].arg_pos != -1 && argspecs[argidx].arg_pos > max_pos) max_pos = argspecs[argidx].arg_pos; if (argspecs[argidx].width_pos > max_pos) @@ -1574,13 +1574,13 @@ estream_format (estream_printf_out_t outfnc, valuetable[validx].vt = VALTYPE_INT; } } - + /* Read all the arguments. This will error out for unsupported types and for not given positional arguments. */ rc = read_values (valuetable, max_pos, vaargs); if (rc) - goto leave_einval; - + goto leave_einval; + /* for (validx=0; validx < max_pos; validx++) */ /* fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */ @@ -1589,7 +1589,7 @@ estream_format (estream_printf_out_t outfnc, argspecs, argspecs_len, valuetable, myerrno, &nbytes); goto leave; - + leave_einval: _set_errno (EINVAL); leave_error: @@ -1623,11 +1623,11 @@ estream_printf (const char *format, ...) { int rc; va_list arg_ptr; - + va_start (arg_ptr, format); rc = estream_format (plain_stdio_out, stderr, format, arg_ptr); va_end (arg_ptr); - + return rc; } @@ -1637,16 +1637,16 @@ estream_fprintf (FILE *fp, const char *format, ...) { int rc; va_list arg_ptr; - + va_start (arg_ptr, format); rc = estream_format (plain_stdio_out, fp, format, arg_ptr); va_end (arg_ptr); - + return rc; } /* A replacement for vfprintf. */ -int +int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) { return estream_format (plain_stdio_out, fp, format, arg_ptr); @@ -1693,7 +1693,7 @@ fixed_buffer_out (void *outfncarg, const char *buf, size_t buflen) /* A replacement for vsnprintf. */ -int +int estream_vsnprintf (char *buf, size_t bufsize, const char *format, va_list arg_ptr) { @@ -1718,7 +1718,7 @@ estream_vsnprintf (char *buf, size_t bufsize, } /* A replacement for snprintf. */ -int +int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) { int rc; @@ -1727,7 +1727,7 @@ estream_snprintf (char *buf, size_t bufsize, const char *format, ...) va_start (arg_ptr, format); rc = estream_vsnprintf (buf, bufsize, format, arg_ptr); va_end (arg_ptr); - + return rc; } @@ -1737,7 +1737,7 @@ estream_snprintf (char *buf, size_t bufsize, const char *format, ...) dynamic_buffer_out. */ struct dynamic_buffer_parm_s { - int error_flag; /* Internal helper. */ + int error_flag; /* Internal helper. */ size_t alloced; /* Allocated size of the buffer. */ size_t used; /* Used size of the buffer. */ char *buffer; /* Malloced buffer. */ @@ -1760,7 +1760,7 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen) if (parm->used + buflen >= parm->alloced) { char *p; - + parm->alloced += buflen + 512; p = realloc (parm->buffer, parm->alloced); if (!p) @@ -1783,7 +1783,7 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen) /* A replacement for vasprintf. As with the BSD of vasprintf version -1 will be returned on error and NULL stored at BUFP. On success the number of bytes printed will be returned. */ -int +int estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) { struct dynamic_buffer_parm_s parm; @@ -1798,7 +1798,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) *bufp = NULL; return -1; } - + rc = estream_format (dynamic_buffer_out, &parm, format, arg_ptr); if (!rc) rc = dynamic_buffer_out (&parm, "", 1); /* Print terminating Nul. */ @@ -1823,7 +1823,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) /* A replacement for asprintf. As with the BSD of asprintf version -1 will be returned on error and NULL stored at BUFP. On success the number of bytes printed will be returned. */ -int +int estream_asprintf (char **bufp, const char *format, ...) { int rc; @@ -1832,8 +1832,6 @@ estream_asprintf (char **bufp, const char *format, ...) va_start (arg_ptr, format); rc = estream_vasprintf (bufp, format, arg_ptr); va_end (arg_ptr); - + return rc; } - - diff --git a/common/estream-printf.h b/common/estream-printf.h index 16e42490c..9b6b83810 100644 --- a/common/estream-printf.h +++ b/common/estream-printf.h @@ -60,7 +60,7 @@ /* To use this file with libraries the following macro is useful: #define _ESTREAM_EXT_SYM_PREFIX _foo_ - + This prefixes all external symbols with "_foo_". For the implementation of the code (estream-printf.c) the following @@ -119,9 +119,9 @@ typedef int (*estream_printf_out_t) (void *outfncarg, const char *buf, size_t buflen); int estream_format (estream_printf_out_t outfnc, void *outfncarg, - const char *format, va_list vaargs) + const char *format, va_list vaargs) _ESTREAM_GCC_A_PRINTF(3,0); -int estream_printf (const char *format, ...) +int estream_printf (const char *format, ...) _ESTREAM_GCC_A_PRINTF(1,2); int estream_fprintf (FILE *fp, const char *format, ... ) _ESTREAM_GCC_A_PRINTF(2,3); @@ -129,8 +129,8 @@ int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) _ESTREAM_GCC_A_PRINTF(2,0); int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) _ESTREAM_GCC_A_PRINTF(3,4); -int estream_vsnprintf (char *buf,size_t bufsize, - const char *format, va_list arg_ptr) +int estream_vsnprintf (char *buf,size_t bufsize, + const char *format, va_list arg_ptr) _ESTREAM_GCC_A_PRINTF(3,0); int estream_asprintf (char **bufp, const char *format, ...) _ESTREAM_GCC_A_PRINTF(2,3); diff --git a/common/estream.c b/common/estream.c index 416aa8376..bc820513e 100644 --- a/common/estream.c +++ b/common/estream.c @@ -357,7 +357,7 @@ map_w32_to_errno (DWORD w32_err) case ERROR_NOT_ENOUGH_MEMORY: return ENOMEM; - + case ERROR_NO_DATA: return EPIPE; @@ -406,7 +406,7 @@ static void do_list_remove (estream_t stream, int with_locked_list) { estream_list_t list_obj; - + if (!with_locked_list) ESTREAM_LIST_LOCK; for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr) @@ -509,7 +509,7 @@ do_init (void) #else initialized = 1; #endif - atexit (do_deinit); + atexit (do_deinit); } return 0; } @@ -602,7 +602,7 @@ es_func_mem_read (void *cookie, void *buffer, size_t size) memcpy (buffer, mem_cookie->memory + mem_cookie->offset, size); mem_cookie->offset += size; } - + ret = size; return ret; } @@ -627,7 +627,7 @@ es_func_mem_write (void *cookie, const void *buffer, size_t size) assert (mem_cookie->memory_size >= mem_cookie->offset); nleft = mem_cookie->memory_size - mem_cookie->offset; - + /* If we are not allowed to grow limit the size to the left space. */ if (!mem_cookie->flags.grow && size > nleft) size = nleft; @@ -668,20 +668,20 @@ es_func_mem_write (void *cookie, const void *buffer, size_t size) _set_errno (ENOSPC); return -1; } - + newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize); if (!newbuf) return -1; - + mem_cookie->memory = newbuf; mem_cookie->memory_size = newsize; assert (mem_cookie->memory_size >= mem_cookie->offset); nleft = mem_cookie->memory_size - mem_cookie->offset; - + assert (size <= nleft); } - + memcpy (mem_cookie->memory + mem_cookie->offset, buffer, size); if (mem_cookie->offset + size > mem_cookie->data_len) mem_cookie->data_len = mem_cookie->offset + size; @@ -743,7 +743,7 @@ es_func_mem_seek (void *cookie, off_t *offset, int whence) _set_errno (ENOSPC); return -1; } - + newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize); if (!newbuf) return -1; @@ -825,7 +825,7 @@ func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close) *cookie = fd_cookie; err = 0; } - + return err; } @@ -836,7 +836,7 @@ es_func_fd_read (void *cookie, void *buffer, size_t size) { estream_cookie_fd_t file_cookie = cookie; ssize_t bytes_read; - + if (IS_INVALID_FD (file_cookie->fd)) { ESTREAM_SYS_YIELD (); @@ -844,7 +844,7 @@ es_func_fd_read (void *cookie, void *buffer, size_t size) } else { - do + do bytes_read = ESTREAM_SYS_READ (file_cookie->fd, buffer, size); while (bytes_read == -1 && errno == EINTR); } @@ -969,7 +969,7 @@ es_func_w32_create (void **cookie, HANDLE hd, *cookie = w32_cookie; err = 0; } - + return err; } @@ -979,7 +979,7 @@ es_func_w32_read (void *cookie, void *buffer, size_t size) { estream_cookie_w32_t w32_cookie = cookie; ssize_t bytes_read; - + if (w32_cookie->hd == INVALID_HANDLE_VALUE) { ESTREAM_SYS_YIELD (); @@ -994,7 +994,7 @@ es_func_w32_read (void *cookie, void *buffer, size_t size) bytes_read = pth_read ((int)w32_cookie->hd, buffer, size); #else DWORD nread, ec; - + if (!ReadFile (w32_cookie->hd, buffer, size, &nread, NULL)) { ec = GetLastError (); @@ -1116,7 +1116,7 @@ es_func_w32_destroy (void *cookie) else if (w32_cookie->no_close) err = 0; else - { + { if (!CloseHandle (w32_cookie->hd)) { _set_errno (map_w32_to_errno (GetLastError ())); @@ -1158,7 +1158,7 @@ typedef struct estream_cookie_fp /* Create function for FILE objects. */ static int -func_fp_create (void **cookie, FILE *fp, +func_fp_create (void **cookie, FILE *fp, unsigned int modeflags, int no_close) { estream_cookie_fp_t fp_cookie; @@ -1249,7 +1249,7 @@ es_func_fp_seek (void *cookie, off_t *offset, int whence) if (!file_cookie->fp) { _set_errno (ESPIPE); - return -1; + return -1; } if ( fseek (file_cookie->fp, (long int)*offset, whence) ) @@ -1415,7 +1415,7 @@ parse_mode (const char *modestr, case ',': goto keyvalue; default: /* Ignore unknown flags. */ - break; + break; } } @@ -1536,10 +1536,10 @@ es_flush (estream_t stream) they were asked to write, we have to check for "(stream->data_offset - data_flushed) > 0" instead of "stream->data_offset - data_flushed". */ - + data_flushed = 0; err = 0; - + while ((((ssize_t) (stream->data_offset - data_flushed)) > 0) && (! err)) { ret = (*func_write) (stream->intern->cookie, @@ -1573,7 +1573,7 @@ es_flush (estream_t stream) err = 0; out: - + if (err) stream->intern->indicators.err = 1; @@ -1896,7 +1896,7 @@ es_readn (estream_t ES__RESTRICT stream, if (err) goto out; stream->flags.writing = 0; - } + } /* Read unread data first. */ while ((bytes_to_read - data_read_unread) && stream->unread_data_len) @@ -1993,7 +1993,7 @@ es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence, off = off - stream->data_len + stream->data_offset; off -= stream->unread_data_len; } - + ret = (*func_seek) (stream->intern->cookie, &off, whence); if (ret == -1) { @@ -2011,7 +2011,7 @@ es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence, stream->intern->offset = off; out: - + if (err) stream->intern->indicators.err = 1; @@ -2035,11 +2035,11 @@ es_write_nbf (estream_t ES__RESTRICT stream, { err = EOPNOTSUPP; goto out; - } + } data_written = 0; err = 0; - + while (bytes_to_write - data_written) { ret = (*func_write) (stream->intern->cookie, @@ -2087,12 +2087,12 @@ es_write_fbf (estream_t ES__RESTRICT stream, if (! err) { /* Flushing resulted in empty container. */ - + data_to_write = bytes_to_write - data_written; space_available = stream->buffer_size - stream->data_offset; if (data_to_write > space_available) data_to_write = space_available; - + memcpy (stream->buffer + stream->data_offset, buffer + data_written, data_to_write); stream->data_offset += data_to_write; @@ -2153,7 +2153,7 @@ es_writen (estream_t ES__RESTRICT stream, data_written = 0; err = 0; - + if (!stream->flags.writing) { /* Switching to writing mode -> discard input data and seek to @@ -2188,7 +2188,7 @@ es_writen (estream_t ES__RESTRICT stream, } out: - + if (bytes_written) *bytes_written = data_written; if (data_written) @@ -2212,7 +2212,7 @@ es_peek (estream_t ES__RESTRICT stream, unsigned char **ES__RESTRICT data, if (err) goto out; stream->flags.writing = 0; - } + } if (stream->data_offset == stream->data_len) { @@ -2221,7 +2221,7 @@ es_peek (estream_t ES__RESTRICT stream, unsigned char **ES__RESTRICT data, if (err) goto out; } - + if (data) *data = stream->buffer + stream->data_offset; if (data_len) @@ -2277,7 +2277,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length, err = func_mem_create (&line_stream_cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE, 1, - mem_realloc, mem_free, + mem_realloc, mem_free, O_RDWR, 0); if (err) @@ -2333,7 +2333,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length, goto out; /* Complete line has been written to line_stream. */ - + if ((max_length > 1) && (! line_size)) { stream->intern->indicators.eof = 1; @@ -2429,7 +2429,7 @@ static int es_get_indicator (estream_t stream, int ind_err, int ind_eof) { int ret = 0; - + if (ind_err) ret = stream->intern->indicators.err; else if (ind_eof) @@ -2456,7 +2456,7 @@ es_set_buffering (estream_t ES__RESTRICT stream, es_empty (stream); es_set_indicators (stream, -1, 0); - + /* Free old buffer in case that was allocated by this function. */ if (stream->intern->deallocate_buffer) { @@ -2470,7 +2470,7 @@ es_set_buffering (estream_t ES__RESTRICT stream, else { void *buffer_new; - + if (buffer) buffer_new = buffer; else @@ -2560,11 +2560,11 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode) err = parse_mode (mode, &modeflags, &cmode); if (err) goto out; - + err = func_file_create (&cookie, &fd, path, modeflags, cmode); if (err) goto out; - + syshd.type = ES_SYSHD_FD; syshd.u.fd = fd; @@ -2577,7 +2577,7 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode) fname_set_internal (stream, path, 1); out: - + if (err && create_called) (*estream_functions_fd.func_close) (cookie); @@ -2602,17 +2602,17 @@ es_mopen (unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len, cookie = 0; stream = NULL; create_called = 0; - + err = parse_mode (mode, &modeflags, NULL); if (err) goto out; err = func_mem_create (&cookie, data, data_n, data_len, - BUFFER_BLOCK_SIZE, grow, + BUFFER_BLOCK_SIZE, grow, func_realloc, func_free, modeflags, 0); if (err) goto out; - + memset (&syshd, 0, sizeof syshd); create_called = 1; err = es_create (&stream, cookie, &syshd, @@ -2642,13 +2642,13 @@ es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode) return NULL; modeflags |= O_RDWR; - + if (func_mem_create (&cookie, NULL, 0, 0, BUFFER_BLOCK_SIZE, 1, mem_realloc, mem_free, modeflags, memlimit)) return NULL; - + memset (&syshd, 0, sizeof syshd); if (es_create (&stream, cookie, &syshd, estream_functions_mem, modeflags, 0)) (*estream_functions_mem.func_close) (cookie); @@ -2670,7 +2670,7 @@ es_fopencookie (void *ES__RESTRICT cookie, stream = NULL; modeflags = 0; - + err = parse_mode (mode, &modeflags, NULL); if (err) goto out; @@ -2774,7 +2774,7 @@ do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list) return stream; } - + /* Create an estream from the stdio stream FP. This mechanism is useful in case the stdio streams have special properties and may not be mixed with fd based functions. This is for example the case @@ -2844,7 +2844,7 @@ do_sysopen (es_syshd_t *syshd, const char *mode, int no_close) case ES_SYSHD_SOCK: stream = do_fdopen (syshd->u.fd, mode, no_close, 0); break; - + #ifdef HAVE_W32_SYSTEM case ES_SYSHD_HANDLE: stream = do_w32open (syshd->u.handle, mode, no_close, 0); @@ -2922,7 +2922,7 @@ _es_get_std_stream (int fd) stream = do_fdopen (custom_std_fds[1], "a", 1, 1); else if (custom_std_fds_valid[2]) stream = do_fdopen (custom_std_fds[2], "a", 1, 1); - + if (!stream) { /* Second try is to use the standard C streams. */ @@ -2933,8 +2933,8 @@ _es_get_std_stream (int fd) else stream = do_fpopen (stderr, "a", 1, 1); } - - if (!stream) + + if (!stream) { /* Last try: Create a bit bucket. */ stream = do_fpopen (NULL, fd? "a":"r", 0, 1); @@ -2950,7 +2950,7 @@ _es_get_std_stream (int fd) stream->intern->stdstream_fd = fd; if (fd == 2) es_set_buffering (stream, NULL, _IOLBF, 0); - fname_set_internal (stream, + fname_set_internal (stream, fd == 0? "[stdin]" : fd == 1? "[stdout]" : "[stderr]", 0); } @@ -2975,7 +2975,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, cookie = NULL; create_called = 0; - + ESTREAM_LOCK (stream); es_deinitialize (stream); @@ -2983,7 +2983,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, err = parse_mode (mode, &modeflags, &cmode); if (err) goto leave; - + err = func_file_create (&cookie, &fd, path, modeflags, cmode); if (err) goto leave; @@ -2999,7 +2999,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode, { if (create_called) es_func_fd_destroy (cookie); - + do_close (stream, 0); stream = NULL; } @@ -3057,7 +3057,7 @@ es_onclose (estream_t stream, int mode, ESTREAM_LOCK (stream); err = do_onclose (stream, mode, fnc, fnc_value); ESTREAM_UNLOCK (stream); - + return err; } @@ -3073,7 +3073,7 @@ es_fileno_unlocked (estream_t stream) { case ES_SYSHD_FD: return syshd.u.fd; case ES_SYSHD_SOCK: return syshd.u.sock; - default: + default: _set_errno (EINVAL); return -1; } @@ -3094,7 +3094,7 @@ es_syshd_unlocked (estream_t stream, es_syshd_t *syshd) _set_errno (EINVAL); return -1; } - + *syshd = stream->intern->syshd; return 0; } @@ -3211,7 +3211,7 @@ static int do_fflush (estream_t stream) { int err; - + if (stream->flags.writing) err = es_flush (stream); else @@ -3228,7 +3228,7 @@ int es_fflush (estream_t stream) { int err; - + if (stream) { ESTREAM_LOCK (stream); @@ -3259,7 +3259,7 @@ int es_fseeko (estream_t stream, off_t offset, int whence) { int err; - + ESTREAM_LOCK (stream); err = es_seek (stream, offset, whence, NULL); ESTREAM_UNLOCK (stream); @@ -3272,7 +3272,7 @@ long int es_ftell (estream_t stream) { long int ret; - + ESTREAM_LOCK (stream); ret = es_offset_calculate (stream); ESTREAM_UNLOCK (stream); @@ -3333,7 +3333,7 @@ int es_fgetc (estream_t stream) { int ret; - + ESTREAM_LOCK (stream); ret = es_getc_unlocked (stream); ESTREAM_UNLOCK (stream); @@ -3346,7 +3346,7 @@ int es_fputc (int c, estream_t stream) { int ret; - + ESTREAM_LOCK (stream); ret = es_putc_unlocked (c, stream); ESTREAM_UNLOCK (stream); @@ -3458,10 +3458,10 @@ es_fgets (char *ES__RESTRICT buffer, int length, estream_t ES__RESTRICT stream) { unsigned char *s = (unsigned char*)buffer; int c; - + if (!length) return NULL; - + c = EOF; ESTREAM_LOCK (stream); while (length > 1 && (c = es_getc_unlocked (stream)) != EOF && c != '\n') @@ -3525,7 +3525,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, if (*n) { /* Caller wants us to use his buffer. */ - + if (*n < (line_n + 1)) { /* Provided buffer is too small -> resize. */ @@ -3569,7 +3569,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, considered a byte stream ending in a LF. If MAX_LENGTH is not NULL, it shall point to a value with the - maximum allowed allocation. + maximum allowed allocation. Returns the length of the line. EOF is indicated by a line of length zero. A truncated line is indicated my setting the value at @@ -3593,7 +3593,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n, released using es_free. */ ssize_t -es_read_line (estream_t stream, +es_read_line (estream_t stream, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length) { @@ -3605,7 +3605,7 @@ es_read_line (estream_t stream, char *p; if (!buffer) - { + { /* No buffer given - allocate a new one. */ length = 256; buffer = mem_alloc (length); @@ -3634,9 +3634,9 @@ es_read_line (estream_t stream, while ((c = es_getc_unlocked (stream)) != EOF) { if (nbytes == length) - { + { /* Enlarge the buffer. */ - if (maxlen && length > maxlen) + if (maxlen && length > maxlen) { /* We are beyond our limit: Skip the rest of the line. */ while (c != '\n' && (c=es_getc_unlocked (stream)) != EOF) @@ -3653,7 +3653,7 @@ es_read_line (estream_t stream, if (!*addr_of_buffer) { int save_errno = errno; - mem_free (buffer); + mem_free (buffer); *length_of_buffer = 0; if (max_length) *max_length = 0; @@ -3663,7 +3663,7 @@ es_read_line (estream_t stream, } buffer = *addr_of_buffer; *length_of_buffer = length; - length -= 3; + length -= 3; p = buffer + nbytes; } *p++ = c; @@ -3701,7 +3701,7 @@ es_vfprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, va_list ap) { int ret; - + ESTREAM_LOCK (stream); ret = es_print (stream, format, ap); ESTREAM_UNLOCK (stream); @@ -3715,7 +3715,7 @@ es_fprintf_unlocked (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, ...) { int ret; - + va_list ap; va_start (ap, format); ret = es_print (stream, format, ap); @@ -3730,7 +3730,7 @@ es_fprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format, ...) { int ret; - + va_list ap; va_start (ap, format); ESTREAM_LOCK (stream); @@ -3746,7 +3746,7 @@ int es_printf_unlocked (const char *ES__RESTRICT format, ...) { int ret; - + va_list ap; va_start (ap, format); ret = es_print (es_stdout, format, ap); @@ -3761,7 +3761,7 @@ es_printf (const char *ES__RESTRICT format, ...) { int ret; estream_t stream = es_stdout; - + va_list ap; va_start (ap, format); ESTREAM_LOCK (stream); @@ -3799,7 +3799,7 @@ es_asprintf (const char *ES__RESTRICT format, ...) should use es_free to release the buffer. This function actually belongs into estream-printf but we put it here as a convenience and because es_free is required anyway. */ -char * +char * es_vasprintf (const char *ES__RESTRICT format, va_list ap) { int rc; @@ -3830,7 +3830,7 @@ tmpfd (void) int pid = GetCurrentProcessId (); unsigned int value; int i; - + n = GetTempPath (MAX_PATH+1, buffer); if (!n || n > MAX_PATH || mystrlen (buffer) > MAX_PATH) { @@ -3896,7 +3896,7 @@ tmpfd (void) fp = NULL; fd = -1; - + fp = tmpfile (); if (! fp) goto out; @@ -3928,7 +3928,7 @@ es_tmpfile (void) stream = NULL; modeflags = O_RDWR | O_TRUNC | O_CREAT; cookie = NULL; - + fd = tmpfd (); if (fd == -1) { @@ -3954,7 +3954,7 @@ es_tmpfile (void) close (fd); stream = NULL; } - + return stream; } @@ -3964,7 +3964,7 @@ es_setvbuf (estream_t ES__RESTRICT stream, char *ES__RESTRICT buf, int type, size_t size) { int err; - + if ((type == _IOFBF || type == _IOLBF || type == _IONBF) && (!buf || size || type == _IONBF)) { @@ -4036,7 +4036,7 @@ void * es_opaque_get (estream_t stream) { void *opaque; - + ESTREAM_LOCK (stream); es_opaque_ctrl (stream, NULL, &opaque); ESTREAM_UNLOCK (stream); @@ -4111,10 +4111,10 @@ es_fname_get (estream_t stream) Returns 0 on success or -1 on error. If BYTES_WRITTEN is not NULL the number of bytes actually written are stored at this address. */ -int +int es_write_sanitized (estream_t ES__RESTRICT stream, const void * ES__RESTRICT buffer, size_t length, - const char * delimiters, + const char * delimiters, size_t * ES__RESTRICT bytes_written) { const unsigned char *p = buffer; @@ -4124,9 +4124,9 @@ es_write_sanitized (estream_t ES__RESTRICT stream, ESTREAM_LOCK (stream); for (; length; length--, p++, count++) { - if (*p < 0x20 + if (*p < 0x20 || *p == 0x7f - || (delimiters + || (delimiters && (strchr (delimiters, *p) || *p == '\\'))) { es_putc_unlocked ('\\', stream); @@ -4228,19 +4228,19 @@ es_write_hexstring (estream_t ES__RESTRICT stream, #ifdef GNUPG_MAJOR_VERSION /* Special estream function to print an UTF8 string in the native encoding. The interface is the same as es_write_sanitized, however - only one delimiter may be supported. + only one delimiter may be supported. THIS IS NOT A STANDARD ESTREAM FUNCTION AND ONLY USED BY GNUPG!. */ int es_write_sanitized_utf8_buffer (estream_t stream, - const void *buffer, size_t length, + const void *buffer, size_t length, const char *delimiters, size_t *bytes_written) { const char *p = buffer; size_t i; /* We can handle plain ascii simpler, so check for it first. */ - for (i=0; i < length; i++ ) + for (i=0; i < length; i++ ) { if ( (p[i] & 0x80) ) break; diff --git a/common/estream.h b/common/estream.h index 5c5e216e0..432143fd3 100644 --- a/common/estream.h +++ b/common/estream.h @@ -215,7 +215,7 @@ typedef struct es_cookie_io_functions } es_cookie_io_functions_t; -enum es_syshd_types +enum es_syshd_types { ES_SYSHD_NONE, /* No system handle available. */ ES_SYSHD_FD, /* A file descriptor as returned by open(). */ diff --git a/common/exaudit.awk b/common/exaudit.awk index 270e148b1..0d2f95ef4 100644 --- a/common/exaudit.awk +++ b/common/exaudit.awk @@ -30,7 +30,7 @@ topheader == 1 && /\*\// { topheader = 2; print "" } /AUDIT_NULL_EVENT/ { okay = 1 } !okay { next } /AUDIT_LAST_EVENT/ { exit } -/AUDIT_[A-Za-z_]+/ { +/AUDIT_[A-Za-z_]+/ { sub (/[,\/\*]+/, "", $1); desc = tolower (substr($1,7)); gsub (/_/," ",desc); diff --git a/common/exechelp-posix.c b/common/exechelp-posix.c index 6ffc562ca..5479fe3fc 100644 --- a/common/exechelp-posix.c +++ b/common/exechelp-posix.c @@ -32,7 +32,7 @@ #ifdef HAVE_SIGNAL_H # include <signal.h> #endif -#include <unistd.h> +#include <unistd.h> #include <fcntl.h> #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ @@ -40,7 +40,7 @@ #undef USE_GNU_PTH #endif -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH #include <pth.h> #endif #include <sys/wait.h> @@ -64,7 +64,7 @@ and some are not. However we want to use pth_fork and pth_waitpid here. Using a weak symbol works but is not portable - we should provide a an explicit dummy pth module instead of using the - pragma. */ + pragma. */ #pragma weak pth_fork #pragma weak pth_waitpid @@ -181,7 +181,7 @@ get_all_open_fds (void) array = calloc (narray, sizeof *array); if (!array) return NULL; - + /* Note: The list we return is ordered. */ for (idx=0, fd=0; fd < max_fd; fd++) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) @@ -258,7 +258,7 @@ do_exec (const char *pgmname, const char *argv[], /* Close all other files. */ close_all_fds (3, NULL); - + if (preexec) preexec (); execv (pgmname, arg_list); @@ -328,7 +328,7 @@ create_pipe_and_estream (int filedes[2], estream_t *r_fp, } return 0; } - + /* Fork and exec the PGMNAME, see exechelp.h for details. */ @@ -388,7 +388,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], } -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH *pid = pth_fork? pth_fork () : fork (); #else *pid = fork (); @@ -415,7 +415,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], } if (!*pid) - { + { /* This is the child. */ gcry_control (GCRYCTL_TERM_SECMEM); es_fclose (outfp); @@ -454,7 +454,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], { gpg_error_t err; -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH *pid = pth_fork? pth_fork () : fork (); #else *pid = fork (); @@ -467,7 +467,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], } if (!*pid) - { + { gcry_control (GCRYCTL_TERM_SECMEM); /* Run child. */ do_exec (pgmname, argv, infd, outfd, errfd, NULL); @@ -501,7 +501,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode) && errno == EINTR) ; } - + if (i == (pid_t)(-1)) { ec = gpg_err_code_from_errno (errno); @@ -531,7 +531,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode) log_error (_("error running `%s': terminated\n"), pgmname); ec = GPG_ERR_GENERAL; } - else + else { if (r_exitcode) *r_exitcode = 0; @@ -569,7 +569,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], if (access (pgmname, X_OK)) return gpg_error_from_syserror (); -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH pid = pth_fork? pth_fork () : fork (); #else pid = fork (); @@ -596,12 +596,12 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], if (envp) for (i=0; envp[i]; i++) putenv (xstrdup (envp[i])); - + do_exec (pgmname, argv, -1, -1, -1, NULL); /*NOTREACHED*/ } - + if (waitpid (pid, NULL, 0) == -1) log_error ("waitpid failed in gnupg_spawn_process_detached: %s", strerror (errno)); @@ -618,6 +618,6 @@ gnupg_kill_process (pid_t pid) { if (pid != (pid_t)(-1)) { - kill (pid, SIGTERM); + kill (pid, SIGTERM); } } diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c index e76c7d726..a8fbd1587 100644 --- a/common/exechelp-w32.c +++ b/common/exechelp-w32.c @@ -32,7 +32,7 @@ #ifdef HAVE_SIGNAL_H # include <signal.h> #endif -#include <unistd.h> +#include <unistd.h> #include <fcntl.h> #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ @@ -40,7 +40,7 @@ #undef USE_GNU_PTH #endif -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH #include <pth.h> #endif @@ -127,7 +127,7 @@ get_all_open_fds (void) array = calloc (narray, sizeof *array); if (!array) return NULL; - + /* Note: The list we return is ordered. */ for (idx=0, fd=0; fd < max_fd; fd++) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) @@ -184,7 +184,7 @@ build_w32_commandline_copy (char *buffer, const char *string) /* Build a command line for use with W32's CreateProcess. On success CMDLINE gets the address of a newly allocated string. */ static gpg_error_t -build_w32_commandline (const char *pgmname, const char * const *argv, +build_w32_commandline (const char *pgmname, const char * const *argv, char **cmdline) { int i, n; @@ -212,7 +212,7 @@ build_w32_commandline (const char *pgmname, const char * const *argv, return gpg_error_from_syserror (); p = build_w32_commandline_copy (p, pgmname); - for (i=0; argv[i]; i++) + for (i=0; argv[i]; i++) { *p++ = ' '; p = build_w32_commandline_copy (p, argv[i]); @@ -234,7 +234,7 @@ create_inheritable_pipe (HANDLE filedes[2], int inherit_idx) memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; - + if (!CreatePipe (&r, &w, &sec_attr, 0)) return -1; @@ -296,7 +296,7 @@ do_create_pipe (int filedes[2], int inherit_idx) log_error ("failed to translate osfhandle %p\n", fds[0]); CloseHandle (fds[1]); } - else + else { filedes[1] = _open_osfhandle (handle_to_fd (fds[1]), 1); if (filedes[1] == -1) @@ -343,7 +343,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], { gpg_error_t err; SECURITY_ATTRIBUTES sec_attr; - PROCESS_INFORMATION pi = + PROCESS_INFORMATION pi = { NULL, /* Returns process handle. */ 0, /* Returns primary thread handle. */ @@ -369,7 +369,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], if (r_errfp) *r_errfp = NULL; *pid = (pid_t)(-1); /* Always required. */ - + if (infp) { es_fflush (infp); @@ -389,7 +389,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], default: inhandle = INVALID_HANDLE_VALUE; break; - } + } if (inhandle == INVALID_HANDLE_VALUE) return gpg_err_make (errsource, GPG_ERR_INV_VALUE); /* FIXME: In case we can't get a system handle (e.g. due to @@ -455,11 +455,11 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; - + /* Build the command line. */ err = build_w32_commandline (pgmname, argv, &cmdline); if (err) - return err; + return err; if (inhandle != INVALID_HANDLE_VALUE) nullhd[0] = w32_open_null (0); @@ -483,7 +483,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], cr_flags = (CREATE_DEFAULT_ERROR_MODE | ((flags & 128)? DETACHED_PROCESS : 0) | GetPriorityClass (GetCurrentProcess ()) - | CREATE_SUSPENDED); + | CREATE_SUSPENDED); /* log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */ if (!CreateProcess (pgmname, /* Program to start. */ cmdline, /* Command line arguments. */ @@ -526,7 +526,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], CloseHandle (outpipe[1]); if (errpipe[1] != INVALID_HANDLE_VALUE) CloseHandle (errpipe[1]); - + /* log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */ /* " dwProcessID=%d dwThreadId=%d\n", */ /* pi.hProcess, pi.hThread, */ @@ -541,7 +541,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); - CloseHandle (pi.hThread); + CloseHandle (pi.hThread); if (r_outfp) *r_outfp = outfp; @@ -582,11 +582,11 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; - + /* Build the command line. */ err = build_w32_commandline (pgmname, argv, &cmdline); if (err) - return err; + return err; memset (&si, 0, sizeof si); si.cb = sizeof (si); @@ -633,7 +633,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); - CloseHandle (pi.hThread); + CloseHandle (pi.hThread); *pid = handle_to_pid (pi.hProcess); return 0; @@ -660,7 +660,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode) been implemented. A special W32 pth system call would even be better. */ code = WaitForSingleObject (proc, hang? INFINITE : 0); - switch (code) + switch (code) { case WAIT_TIMEOUT: ec = GPG_ERR_TIMEOUT; @@ -694,14 +694,14 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode) ec = 0; } break; - + default: log_error ("WaitForSingleObject returned unexpected " "code %d for pid %d\n", code, (int)pid ); ec = GPG_ERR_GENERAL; break; } - + return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec); } @@ -713,7 +713,7 @@ gnupg_release_process (pid_t pid) if (pid != (pid_t)INVALID_HANDLE_VALUE) { HANDLE process = (HANDLE)pid; - + CloseHandle (process); } } @@ -732,7 +732,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], { gpg_error_t err; SECURITY_ATTRIBUTES sec_attr; - PROCESS_INFORMATION pi = + PROCESS_INFORMATION pi = { NULL, /* Returns process handle. */ 0, /* Returns primary thread handle. */ @@ -757,11 +757,11 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], memset (&sec_attr, 0, sizeof sec_attr ); sec_attr.nLength = sizeof sec_attr; sec_attr.bInheritHandle = FALSE; - + /* Build the command line. */ err = build_w32_commandline (pgmname, argv, &cmdline); if (err) - return err; + return err; /* Start the process. */ memset (&si, 0, sizeof si); @@ -772,7 +772,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], cr_flags = (CREATE_DEFAULT_ERROR_MODE | GetPriorityClass (GetCurrentProcess ()) | CREATE_NEW_PROCESS_GROUP - | DETACHED_PROCESS); + | DETACHED_PROCESS); /* log_debug ("CreateProcess(detached), path=`%s' cmdline=`%s'\n", */ /* pgmname, cmdline); */ if (!CreateProcess (pgmname, /* Program to start. */ @@ -799,7 +799,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], /* pi.hProcess, pi.hThread, */ /* (int) pi.dwProcessId, (int) pi.dwThreadId); */ - CloseHandle (pi.hThread); + CloseHandle (pi.hThread); return 0; } @@ -814,7 +814,7 @@ gnupg_kill_process (pid_t pid) if (pid != (pid_t) INVALID_HANDLE_VALUE) { HANDLE process = (HANDLE) pid; - + /* Arbitrary error code. */ TerminateProcess (process, 1); } diff --git a/common/exechelp-w32ce.c b/common/exechelp-w32ce.c index 774214259..1bc2d6c3a 100644 --- a/common/exechelp-w32ce.c +++ b/common/exechelp-w32ce.c @@ -32,7 +32,7 @@ #ifdef HAVE_SIGNAL_H # include <signal.h> #endif -#include <unistd.h> +#include <unistd.h> #include <fcntl.h> #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ @@ -40,7 +40,7 @@ #undef USE_GNU_PTH #endif -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH #include <pth.h> #endif @@ -73,8 +73,8 @@ #define handle_to_pid(a) ((int)(a)) -#ifdef USE_GNU_PTH -/* The data passed to the feeder_thread. */ +#ifdef USE_GNU_PTH +/* The data passed to the feeder_thread. */ struct feeder_thread_parms { estream_t stream; @@ -173,7 +173,7 @@ leave: } #endif /*USE_GNU_PTH*/ -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH static void feeder_onclose_notification (estream_t stream, void *opaque) { @@ -191,11 +191,11 @@ feeder_onclose_notification (estream_t stream, void *opaque) static gpg_error_t start_feeder (estream_t stream, HANDLE hd, int direction) { -#ifdef USE_GNU_PTH +#ifdef USE_GNU_PTH gpg_error_t err; struct feeder_thread_parms *parm; pth_attr_t tattr; - + parm = xtrymalloc (sizeof *parm); if (!parm) return gpg_error_from_syserror (); @@ -210,12 +210,12 @@ start_feeder (estream_t stream, HANDLE hd, int direction) xfree (parm); return err; } - + tattr = pth_attr_new (); pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 64*1024); pth_attr_set (tattr, PTH_ATTR_NAME, "exec-feeder"); - + log_debug ("spawning new feeder(%p, %p, %d)\n", stream, hd, direction); if(!pth_spawn (tattr, feeder_thread, parm)) { @@ -291,7 +291,7 @@ get_all_open_fds (void) array = calloc (narray, sizeof *array); if (!array) return NULL; - + /* Note: The list we return is ordered. */ for (idx=0, fd=0; fd < max_fd; fd++) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) @@ -376,7 +376,7 @@ build_w32_commandline (const char * const *argv, else strcpy (p, "-&S2=null "); p += strlen (p); - + *cmdline = NULL; n = strlen (fdbuf); for (i=0; (s = argv[i]); i++) @@ -393,7 +393,7 @@ build_w32_commandline (const char * const *argv, return -1; p = stpcpy (p, fdbuf); - for (i = 0; argv[i]; i++) + for (i = 0; argv[i]; i++) { *p++ = ' '; p = copy_quoted (p, argv[i]); @@ -518,7 +518,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], (void)preexec; (void)flags; - + /* Setup return values. */ if (r_outfp) *r_outfp = NULL; @@ -623,7 +623,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], { /* Fixme release other stuff/kill feeder. */ CloseHandle (errpipe.hd); - return err; + return err; } log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); @@ -645,11 +645,11 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], " dwProcessID=%d dwThreadId=%d\n", pi.hProcess, pi.hThread, (int) pi.dwProcessId, (int) pi.dwThreadId); - + /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); - CloseHandle (pi.hThread); + CloseHandle (pi.hThread); if (r_outfp) *r_outfp = outfp; @@ -686,7 +686,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], /* Build the command line. */ err = build_w32_commandline (argv, 0, 0, 0, &cmdline); if (err) - return err; + return err; log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); if (!create_process (pgmname, cmdline, &pi)) @@ -702,10 +702,10 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[], " dwProcessID=%d dwThreadId=%d\n", pi.hProcess, pi.hThread, (int) pi.dwProcessId, (int) pi.dwThreadId); - + /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); - CloseHandle (pi.hThread); + CloseHandle (pi.hThread); *pid = handle_to_pid (pi.hProcess); return 0; @@ -731,12 +731,12 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *exitcode) been implemented. A special W32 pth system call would even be better. */ code = WaitForSingleObject (proc, hang? INFINITE : 0); - switch (code) + switch (code) { case WAIT_TIMEOUT: ec = GPG_ERR_TIMEOUT; break; - + case WAIT_FAILED: log_error (_("waiting for process %d to terminate failed: %s\n"), (int)pid, w32_strerror (-1)); @@ -765,7 +765,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *exitcode) ec = 0; } break; - + default: log_error ("WaitForSingleObject returned unexpected " "code %d for pid %d\n", code, (int)pid ); @@ -783,7 +783,7 @@ gnupg_release_process (pid_t pid) if (pid != (pid_t)INVALID_HANDLE_VALUE) { HANDLE process = (HANDLE)pid; - + CloseHandle (process); } } @@ -805,11 +805,11 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], PROCESS_INFORMATION pi = {NULL }; (void)envp; - + /* Build the command line. */ err = build_w32_commandline (argv, 0, 0, 0, &cmdline); if (err) - return err; + return err; /* Note: There is no detached flag under CE. */ log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); @@ -826,10 +826,10 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[], " dwProcessID=%d dwThreadId=%d\n", pi.hProcess, pi.hThread, (int) pi.dwProcessId, (int) pi.dwThreadId); - + /* Process has been created suspended; resume it now. */ ResumeThread (pi.hThread); - CloseHandle (pi.hThread); + CloseHandle (pi.hThread); return 0; } @@ -844,7 +844,7 @@ gnupg_kill_process (pid_t pid) if (pid != (pid_t) INVALID_HANDLE_VALUE) { HANDLE process = (HANDLE) pid; - + /* Arbitrary error code. */ TerminateProcess (process, 1); } diff --git a/common/exechelp.h b/common/exechelp.h index e6a0ee5e1..b97516657 100644 --- a/common/exechelp.h +++ b/common/exechelp.h @@ -66,7 +66,7 @@ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]); The arguments for the process are expected in the NULL terminated array ARGV. The program name itself should not be included there. If PREEXEC is not NULL, the given function will be called right - before the exec. + before the exec. Returns 0 on success or an error code. Calling gnupg_wait_process and gnupg_release_process is required if the function succeeded. @@ -77,7 +77,7 @@ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]); This flag is only useful under W32 (but not W32CE) systems, so that no new console is created and pops up a console window when starting the server. Does not work on W32CE. - + Bit 6: On W32 (but not on W32CE) run AllowSetForegroundWindow for the child. Note that due to unknown problems this actually allows SetForegroundWindow for all childs of this process. @@ -101,7 +101,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[], included there. Calling gnupg_wait_process and gnupg_release_process is required. Returns 0 on success or an error code. */ -gpg_error_t gnupg_spawn_process_fd (const char *pgmname, +gpg_error_t gnupg_spawn_process_fd (const char *pgmname, const char *argv[], int infd, int outfd, int errfd, pid_t *pid); @@ -120,11 +120,11 @@ gpg_error_t gnupg_spawn_process_fd (const char *pgmname, is then stored at R_EXITCODE. An exit code of -1 indicates that the process terminated abnormally (e.g. due to a signal). - GPG_ERR_TIMEOUT + GPG_ERR_TIMEOUT The process is still running (returned only if HANG is false). - GPG_ERR_INV_VALUE - An invalid PID has been specified. + GPG_ERR_INV_VALUE + An invalid PID has been specified. Other error codes may be returned as well. Unless otherwise noted, -1 will be stored at R_EXITCODE. R_EXITCODE may be passed as NULL diff --git a/common/exstatus.awk b/common/exstatus.awk index ea48e8156..fb1381947 100644 --- a/common/exstatus.awk +++ b/common/exstatus.awk @@ -26,7 +26,7 @@ topheader == 0 && /^\/\*/ { topheader = 1 } topheader == 1 { print $0 } topheader == 1 && /\*\// { topheader = 2; print "" } -/^[ \t]+STATUS_[A-Za-z_]+/ { +/^[ \t]+STATUS_[A-Za-z_]+/ { sub (/[,\/\*]+/, "", $1); desc = substr($1,8); printf "%d\t%s\t%s\n", code, $1, desc; @@ -37,4 +37,3 @@ topheader == 1 && /\*\// { topheader = 2; print "" } END { print "# end of status codes." } - diff --git a/common/gc-opt-flags.h b/common/gc-opt-flags.h index 261fe8796..b777c06d6 100644 --- a/common/gc-opt-flags.h +++ b/common/gc-opt-flags.h @@ -4,7 +4,7 @@ * This file is free software; as a special exception the author gives * unlimited permission to copy and/or distribute it, with or without * modifications, as long as this notice is preserved. - * + * * This file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY, to the extent permitted by law; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR diff --git a/common/get-passphrase.c b/common/get-passphrase.c index 090079405..1aaeeac6c 100644 --- a/common/get-passphrase.c +++ b/common/get-passphrase.c @@ -79,7 +79,7 @@ start_agent (void) pth. We will need a context for each thread or serialize the access to the agent. */ if (agent_ctx) - return 0; + return 0; err = start_new_gpg_agent (&agent_ctx, agentargs.errsource, @@ -129,7 +129,7 @@ membuf_data_cb (void *opaque, const void *buffer, size_t length) put_membuf (data, buffer, length); return 0; } - + /* Ask for a passphrase via gpg-agent. On success the caller needs to free the string stored at R_PASSPHRASE. On error NULL will be @@ -158,8 +158,8 @@ gnupg_get_passphrase (const char *cache_id, gpg_error_t err; char line[ASSUAN_LINELENGTH]; const char *arg1 = NULL; - char *arg2 = NULL; - char *arg3 = NULL; + char *arg2 = NULL; + char *arg3 = NULL; char *arg4 = NULL; membuf_t data; @@ -170,7 +170,7 @@ gnupg_get_passphrase (const char *cache_id, return err; /* Check that the gpg-agent understands the repeat option. */ - if (assuan_transact (agent_ctx, + if (assuan_transact (agent_ctx, "GETINFO cmd_has_option GET_PASSPHRASE repeat", NULL, NULL, NULL, NULL, NULL, NULL)) return gpg_error (GPG_ERR_NOT_SUPPORTED); @@ -186,10 +186,10 @@ gnupg_get_passphrase (const char *cache_id, if (!(arg4 = percent_plus_escape (desc_msg))) goto no_mem; - snprintf (line, DIM(line)-1, - "GET_PASSPHRASE --data %s--repeat=%d -- %s %s %s %s", + snprintf (line, DIM(line)-1, + "GET_PASSPHRASE --data %s--repeat=%d -- %s %s %s %s", check_quality? "--check ":"", - repeat, + repeat, arg1? arg1:"X", arg2? arg2:"X", arg3? arg3:"X", @@ -203,10 +203,10 @@ gnupg_get_passphrase (const char *cache_id, init_membuf_secure (&data, 64); else init_membuf (&data, 64); - err = assuan_transact (agent_ctx, line, + err = assuan_transact (agent_ctx, line, membuf_data_cb, &data, default_inq_cb, NULL, NULL, NULL); - + /* Older Pinentries return the old assuan error code for canceled which gets translated bt libassuan to GPG_ERR_ASS_CANCELED and not to the code for a user cancel. Fix this here. */ @@ -224,7 +224,7 @@ gnupg_get_passphrase (const char *cache_id, wipememory (p, n); xfree (p); } - else + else { put_membuf (&data, "", 1); *r_passphrase = get_membuf (&data, NULL); diff --git a/common/gettime.c b/common/gettime.c index 1ccbbc654..27dc8456e 100644 --- a/common/gettime.c +++ b/common/gettime.c @@ -31,7 +31,7 @@ #ifdef HAVE_UNSIGNED_TIME_T # define IS_INVALID_TIME_T(a) ((a) == (time_t)(-1)) -#else +#else /* Error or 32 bit time_t and value after 2038-01-19. */ # define IS_INVALID_TIME_T(a) ((a) < 0) #endif @@ -46,8 +46,8 @@ static enum { NORMAL = 0, FROZEN, FUTURE, PAST } timemode; /* Wrapper for the time(3). We use this here so we can fake the time for tests */ -time_t -gnupg_get_time () +time_t +gnupg_get_time () { time_t current = time (NULL); if (timemode == NORMAL) @@ -66,15 +66,15 @@ void gnupg_get_isotime (gnupg_isotime_t timebuf) { time_t atime = gnupg_get_time (); - + if (atime == (time_t)(-1)) *timebuf = 0; - else + else { struct tm *tp; #ifdef HAVE_GMTIME_R struct tm tmbuf; - + tp = gmtime_r (&atime, &tmbuf); #else tp = gmtime (&atime); @@ -128,7 +128,7 @@ gnupg_faked_time_p (void) /* This function is used by gpg because OpenPGP defines the timestamp as an unsigned 32 bit value. */ -u32 +u32 make_timestamp (void) { time_t t = gnupg_get_time (); @@ -233,12 +233,12 @@ epoch2isotime (gnupg_isotime_t timebuf, time_t atime) { if (atime == (time_t)(-1)) *timebuf = 0; - else + else { struct tm *tp; #ifdef HAVE_GMTIME_R struct tm tmbuf; - + tp = gmtime_r (&atime, &tmbuf); #else tp = gmtime (&atime); @@ -296,7 +296,7 @@ strtimestamp (u32 stamp) static char buffer[11+5]; struct tm *tp; time_t atime = stamp; - + if (IS_INVALID_TIME_T (atime)) { strcpy (buffer, "????" "-??" "-??"); @@ -320,7 +320,7 @@ isotimestamp (u32 stamp) static char buffer[25+5]; struct tm *tp; time_t atime = stamp; - + if (IS_INVALID_TIME_T (atime)) { strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??"); @@ -364,7 +364,7 @@ asctimestamp (u32 stamp) /* NOTE: gcc -Wformat-noliteral will complain here. I have found no way to suppress this warning. */ strftime (buffer, DIM(buffer)-1, fmt, tp); -# elif defined(HAVE_W32CE_SYSTEM) +# elif defined(HAVE_W32CE_SYSTEM) /* tzset is not available but %Z nevertheless prints a default nonsense timezone ("WILDABBR"). Thus we don't print the time zone at all. */ @@ -400,7 +400,7 @@ static int days_per_month (int y, int m) { int s; - + switch(m) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: @@ -460,19 +460,19 @@ jd2date (unsigned long jd, int *year, int *month, int *day) m = (delta / 31) + 1; while( (delta = jd - date2jd (y, m, d)) > days_per_month (y,m)) if (++m > 12) - { + { m = 1; y++; } d = delta + 1 ; if (d > days_per_month (y, m)) - { + { d = 1; m++; } if (m > 12) - { + { m = 1; y++; } @@ -499,7 +499,7 @@ check_isotime (const gnupg_isotime_t atime) if (!*atime) return gpg_error (GPG_ERR_NO_VALUE); - + for (s=atime, i=0; i < 8; i++, s++) if (!digitp (s)) return gpg_error (GPG_ERR_INV_TIME); @@ -566,7 +566,7 @@ add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds) sec = atoi_2 (atime+13); if (year <= 1582) /* The julian date functions don't support this. */ - return gpg_error (GPG_ERR_INV_VALUE); + return gpg_error (GPG_ERR_INV_VALUE); sec += nseconds; minute += sec/60; @@ -575,14 +575,14 @@ add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds) minute %= 60; ndays = hour/24; hour %= 24; - + jd = date2jd (year, month, day) + ndays; jd2date (jd, &year, &month, &day); if (year > 9999 || month > 12 || day > 31 || year < 0 || month < 1 || day < 1) - return gpg_error (GPG_ERR_INV_VALUE); - + return gpg_error (GPG_ERR_INV_VALUE); + snprintf (atime, 16, "%04d%02d%02dT%02d%02d%02d", year, month, day, hour, minute, sec); return 0; @@ -611,15 +611,15 @@ add_days_to_isotime (gnupg_isotime_t atime, int ndays) sec = atoi_2 (atime+13); if (year <= 1582) /* The julian date functions don't support this. */ - return gpg_error (GPG_ERR_INV_VALUE); + return gpg_error (GPG_ERR_INV_VALUE); jd = date2jd (year, month, day) + ndays; jd2date (jd, &year, &month, &day); if (year > 9999 || month > 12 || day > 31 || year < 0 || month < 1 || day < 1) - return gpg_error (GPG_ERR_INV_VALUE); - + return gpg_error (GPG_ERR_INV_VALUE); + snprintf (atime, 16, "%04d%02d%02dT%02d%02d%02d", year, month, day, hour, minute, sec); return 0; diff --git a/common/gpgrlhelp.c b/common/gpgrlhelp.c index 28459aac2..b6fca82f3 100644 --- a/common/gpgrlhelp.c +++ b/common/gpgrlhelp.c @@ -85,7 +85,3 @@ gnupg_rl_initialize (void) rl_readline_name = "GnuPG"; #endif } - - - - diff --git a/common/helpfile.c b/common/helpfile.c index 34b6bdc4e..6666a800e 100644 --- a/common/helpfile.c +++ b/common/helpfile.c @@ -52,7 +52,7 @@ findkey_fname (const char *key, const char *fname) while (fgets (line, DIM(line)-1, fp)) { lnr++; - + if (!*line || line[strlen(line)-1] != '\n') { /* Eat until end of line. */ @@ -65,7 +65,7 @@ findkey_fname (const char *key, const char *fname) } else line[strlen(line)-1] = 0; /* Chop the LF. */ - + again: if (!in_item) { @@ -96,7 +96,7 @@ findkey_fname (const char *key, const char *fname) if (*line == '#') continue; if (*line == '.') - { + { if (spacep(line+1)) p = line + 2; else @@ -126,7 +126,7 @@ findkey_fname (const char *key, const char *fname) log_error (_("error reading `%s', line %d: %s\n"), fname, lnr, gpg_strerror (err)); } - + fclose (fp); if (is_membuf_ready (&mb)) { @@ -182,7 +182,7 @@ findkey_locale (const char *key, const char *locname, else result = NULL; } - + if (!result && (!only_current_locale || !*locname) ) { /* Last try: Search in file without any locale info. ("help.txt") */ @@ -204,18 +204,18 @@ findkey_locale (const char *key, const char *locname, /etc/gnupg/help.txt /usr/share/gnupg/help.LL.txt /usr/share/gnupg/help.txt - + Here LL denotes the two digit language code of the current locale. If ONLY_CURRENT_LOCALE is set, the fucntion won;t fallback to the english valiant ("help.txt") unless that locale has been requested. - + The help file needs to be encoded in UTF-8, lines with a '#' in the first column are comment lines and entirely ignored. Help keys are identified by a key consisting of a single word with a single dot as the first character. All key lines listed without any intervening lines (except for comment lines) lead to the same help text. Lines following the key lines make up the actual hep texts. - + */ char * @@ -249,7 +249,7 @@ gnupg_get_help_string (const char *key, int only_current_locale) if (!key || !*key) return NULL; - result = findkey_locale (key, locname, only_current_locale, + result = findkey_locale (key, locname, only_current_locale, gnupg_sysconfdir ()); if (!result) result = findkey_locale (key, locname, only_current_locale, diff --git a/common/homedir.c b/common/homedir.c index 3d31bd376..56cacaff8 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -55,7 +55,7 @@ w32_try_mkdir (const char *dir) CreateDirectory (wdir, NULL); xfree (wdir); } -#else +#else CreateDirectory (dir, NULL); #endif } @@ -115,7 +115,7 @@ standard_homedir (void) if (!dir) { char path[MAX_PATH]; - + /* It might be better to use LOCAL_APPDATA because this is defined as "non roaming" and thus more likely to be kept locally. For private keys this is desired. However, given @@ -123,13 +123,13 @@ standard_homedir (void) using a system roaming services might be better than to let them do it manually. A security conscious user will anyway use the registry entry to have better control. */ - if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) + if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, + NULL, 0, path) >= 0) { char *tmp = xmalloc (strlen (path) + 6 +1); strcpy (stpcpy (tmp, path), "\\gnupg"); dir = tmp; - + /* Try to create the directory if it does not yet exists. */ if (access (dir, F_OK)) w32_try_mkdir (dir); @@ -155,7 +155,7 @@ default_homedir (void) if (!dir || !*dir) { static const char *saved_dir; - + if (!saved_dir) { if (!dir || !*dir) @@ -172,7 +172,7 @@ default_homedir (void) if (tmp) saved_dir = tmp; } - + if (!saved_dir) saved_dir = standard_homedir (); } @@ -228,7 +228,7 @@ w32_rootdir (void) if (!p) { log_debug ("bad filename `%s' returned for this process\n", dir); - *dir = 0; + *dir = 0; } } @@ -247,8 +247,8 @@ w32_commondir (void) { char path[MAX_PATH]; - if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA, - NULL, 0, path) >= 0) + if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA, + NULL, 0, path) >= 0) { char *tmp = xmalloc (strlen (path) + 4 +1); strcpy (stpcpy (tmp, path), "\\GNU"); @@ -263,7 +263,7 @@ w32_commondir (void) dir = xstrdup (w32_rootdir ()); } } - + return dir; } #endif /*HAVE_W32_SYSTEM*/ @@ -389,8 +389,8 @@ gnupg_cachedir (void) for (comp = s1; *comp; comp++) s1_len += 1 + strlen (*comp); - if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, - NULL, 0, path) >= 0) + if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, + NULL, 0, path) >= 0) { char *tmp = xmalloc (strlen (path) + s1_len + 1); char *p; @@ -475,49 +475,49 @@ gnupg_module_name (int which) if (!name) \ name = xstrconcat (gnupg_ ## a (), DIRSEP_S b EXEEXT_S, NULL); \ return name; \ - } while (0) - + } while (0) + switch (which) { case GNUPG_MODULE_NAME_AGENT: #ifdef GNUPG_DEFAULT_AGENT return GNUPG_DEFAULT_AGENT; -#else +#else X(bindir, "gpg-agent"); #endif - + case GNUPG_MODULE_NAME_PINENTRY: #ifdef GNUPG_DEFAULT_PINENTRY return GNUPG_DEFAULT_PINENTRY; -#else +#else X(bindir, "pinentry"); #endif case GNUPG_MODULE_NAME_SCDAEMON: #ifdef GNUPG_DEFAULT_SCDAEMON return GNUPG_DEFAULT_SCDAEMON; -#else +#else X(bindir, "scdaemon"); #endif case GNUPG_MODULE_NAME_DIRMNGR: #ifdef GNUPG_DEFAULT_DIRMNGR return GNUPG_DEFAULT_DIRMNGR; -#else +#else X(bindir, "dirmngr"); #endif case GNUPG_MODULE_NAME_PROTECT_TOOL: #ifdef GNUPG_DEFAULT_PROTECT_TOOL return GNUPG_DEFAULT_PROTECT_TOOL; -#else +#else X(libexecdir, "gpg-protect-tool"); #endif case GNUPG_MODULE_NAME_DIRMNGR_LDAP: #ifdef GNUPG_DEFAULT_DIRMNGR_LDAP return GNUPG_DEFAULT_DIRMNGR_LDAP; -#else +#else X(libexecdir, "dirmngr_ldap"); #endif @@ -536,7 +536,7 @@ gnupg_module_name (int which) case GNUPG_MODULE_NAME_GPGCONF: X(bindir, "gpgconf"); - default: + default: BUG (); } #undef X diff --git a/common/http.c b/common/http.c index b50b6b8ad..f8628e622 100644 --- a/common/http.c +++ b/common/http.c @@ -176,21 +176,21 @@ static es_cookie_io_functions_t cookie_functions = cookie_close }; -struct cookie_s +struct cookie_s { /* File descriptor or -1 if already closed. */ int fd; /* TLS session context or NULL if not used. */ - gnutls_session_t tls_session; + gnutls_session_t tls_session; /* The remaining content length and a flag telling whether to use the content length. */ - longcounter_t content_length; + longcounter_t content_length; unsigned int content_length_valid:1; /* Flag to communicate with the close handler. */ - unsigned int keep_socket:1; + unsigned int keep_socket:1; }; typedef struct cookie_s *cookie_t; @@ -210,7 +210,7 @@ typedef struct header_s *header_t; /* Our handle context. */ -struct http_context_s +struct http_context_s { unsigned int status_code; int sock; @@ -258,14 +258,14 @@ init_sockets (void) if (initialized) return; - if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) ) + if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) ) { - log_error ("error initializing socket library: ec=%d\n", + log_error ("error initializing socket library: ec=%d\n", (int)WSAGetLastError () ); return; } - if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR - || HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR ) + if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR + || HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR ) { log_error ("socket library version is %x.%x - but %d.%d needed\n", LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion), @@ -290,7 +290,7 @@ static char * make_header_line (const char *prefix, const char *suffix, const void *data, size_t len ) { - static unsigned char bintoasc[] = + static unsigned char bintoasc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; @@ -308,7 +308,7 @@ make_header_line (const char *prefix, const char *suffix, *p++ = bintoasc[(((s[1]<<2)&074)|((s[2]>>6)&03))&077]; *p++ = bintoasc[s[2]&077]; } - if ( len == 2 ) + if ( len == 2 ) { *p++ = bintoasc[(s[0] >> 2) & 077]; *p++ = bintoasc[(((s[0] <<4)&060)|((s[1] >> 4)&017))&077]; @@ -336,7 +336,7 @@ http_register_tls_callback ( gpg_error_t (*cb) (http_t, void *, int) ) tls_callback = (gpg_error_t (*) (http_t, gnutls_session_t, int))cb; #else (void)cb; -#endif +#endif } @@ -345,14 +345,14 @@ http_register_tls_callback ( gpg_error_t (*cb) (http_t, void *, int) ) pointer for completing the the request and to wait for the response. */ gpg_error_t -_http_open (http_t *r_hd, http_req_t reqtype, const char *url, +_http_open (http_t *r_hd, http_req_t reqtype, const char *url, const char *auth, unsigned int flags, const char *proxy, void *tls_context, const char *srvtag, strlist_t headers, gpg_err_source_t errsource) { gpg_error_t err; http_t hd; - + *r_hd = NULL; if (!(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST)) @@ -370,7 +370,7 @@ _http_open (http_t *r_hd, http_req_t reqtype, const char *url, err = _http_parse_uri (&hd->uri, url, 0, errsource); if (!err) err = send_request (hd, auth, proxy, srvtag, headers, errsource); - + if (err) { if (!hd->fp_read && !hd->fp_write && hd->sock != -1) @@ -408,7 +408,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource) cookie_t cookie; /* Make sure that we are in the data. */ - http_start_data (hd); + http_start_data (hd); /* Close the write stream but keep the socket open. */ cookie = hd->write_cookie; @@ -455,7 +455,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource) be used as an HTTP proxy and any enabled $http_proxy gets ignored. */ gpg_error_t -_http_open_document (http_t *r_hd, const char *document, +_http_open_document (http_t *r_hd, const char *document, const char *auth, unsigned int flags, const char *proxy, void *tls_context, const char *srvtag, strlist_t headers, gpg_err_source_t errsource) @@ -620,7 +620,7 @@ do_parse_uri (parsed_uri_t uri, int only_local_part, int no_scheme_check) p++; if (*p == '/') /* There seems to be a hostname. */ - { + { p++; if ((p2 = strchr (p, '/'))) *p2++ = 0; @@ -678,7 +678,7 @@ do_parse_uri (parsed_uri_t uri, int only_local_part, int no_scheme_check) return GPG_ERR_BAD_URI; /* Path includes a Nul. */ p = p2 ? p2 : NULL; - if (!p || !*p) + if (!p || !*p) return 0; /* We don't have a query string. Okay. */ /* Now parse the query string. */ @@ -902,7 +902,7 @@ send_request (http_t hd, const char *auth, if ( (proxy && *proxy) || ( (hd->flags & HTTP_FLAG_TRY_PROXY) - && (http_proxy = getenv (HTTP_PROXY_ENV)) + && (http_proxy = getenv (HTTP_PROXY_ENV)) && *http_proxy )) { parsed_uri_t uri; @@ -947,7 +947,7 @@ send_request (http_t hd, const char *auth, if (hd->sock == -1) { xfree (proxy_authstr); - return gpg_err_make (errsource, (save_errno + return gpg_err_make (errsource, (save_errno ? gpg_err_code_from_errno (save_errno) : GPG_ERR_NOT_FOUND)); } @@ -987,7 +987,7 @@ send_request (http_t hd, const char *auth, if (auth || hd->uri->auth) { char *myauth; - + if (auth) { myauth = xtrystrdup (auth); @@ -1015,14 +1015,14 @@ send_request (http_t hd, const char *auth, return gpg_err_make (errsource, gpg_err_code_from_syserror ()); } } - + p = build_rel_path (hd->uri); if (!p) return gpg_err_make (errsource, gpg_err_code_from_syserror ()); if (http_proxy && *http_proxy) { - request = es_asprintf + request = es_asprintf ("%s http://%s:%hu%s%s HTTP/1.0\r\n%s%s", hd->req_type == HTTP_REQ_GET ? "GET" : hd->req_type == HTTP_REQ_HEAD ? "HEAD" : @@ -1034,13 +1034,13 @@ send_request (http_t hd, const char *auth, else { char portstr[35]; - + if (port == 80) *portstr = 0; else snprintf (portstr, sizeof portstr, ":%u", port); - request = es_asprintf + request = es_asprintf ("%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s", hd->req_type == HTTP_REQ_GET ? "GET" : hd->req_type == HTTP_REQ_HEAD ? "HEAD" : @@ -1099,7 +1099,7 @@ send_request (http_t hd, const char *auth, } } } - + leave: es_free (request); xfree (authstr); @@ -1228,7 +1228,7 @@ store_header (http_t hd, char *line) while (*p == ' ' || *p == '\t') p++; value = p; - + for (h=hd->headers; h; h = h->next) if ( !strcmp (h->name, line) ) break; @@ -1494,9 +1494,9 @@ connect_server (const char *server, unsigned short port, if ( inaddr != INADDR_NONE ) { struct sockaddr_in addr; - + memset(&addr,0,sizeof(addr)); - + sock = socket(AF_INET,SOCK_STREAM,0); if ( sock==INVALID_SOCKET ) { @@ -1504,9 +1504,9 @@ connect_server (const char *server, unsigned short port, return -1; } - addr.sin_family = AF_INET; + addr.sin_family = AF_INET; addr.sin_port = htons(port); - memcpy (&addr.sin_addr,&inaddr,sizeof(inaddr)); + memcpy (&addr.sin_addr,&inaddr,sizeof(inaddr)); if (!my_connect (sock,(struct sockaddr *)&addr,sizeof(addr)) ) return sock; @@ -1575,7 +1575,7 @@ connect_server (const char *server, unsigned short port, errno = save_errno; return -1; } - + if (my_connect (sock, ai->ai_addr, ai->ai_addrlen)) last_errno = errno; else @@ -1608,7 +1608,7 @@ connect_server (const char *server, unsigned short port, xfree (serverlist); return -1; } - + addr.sin_family = host->h_addrtype; if (addr.sin_family != AF_INET) { @@ -1675,7 +1675,7 @@ write_server (int sock, const char *data, size_t length) { #if defined(HAVE_W32_SYSTEM) && !defined(HAVE_PTH) nwritten = send (sock, data, nleft, 0); - if ( nwritten == SOCKET_ERROR ) + if ( nwritten == SOCKET_ERROR ) { log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ()); return gpg_error (GPG_ERR_NETWORK); @@ -1739,7 +1739,7 @@ cookie_read (void *cookie, void *buffer, size_t size) if (nread == GNUTLS_E_AGAIN) { struct timeval tv; - + tv.tv_sec = 0; tv.tv_usec = 50000; my_select (0, NULL, NULL, NULL, &tv); @@ -1762,7 +1762,7 @@ cookie_read (void *cookie, void *buffer, size_t size) #elif defined(HAVE_W32_SYSTEM) /* Under Windows we need to use recv for a socket. */ nread = recv (c->fd, buffer, size, 0); -#else +#else nread = read (c->fd, buffer, size); #endif } @@ -1774,7 +1774,7 @@ cookie_read (void *cookie, void *buffer, size_t size) if (nread < c->content_length) c->content_length -= nread; else - c->content_length = 0; + c->content_length = 0; } return nread; @@ -1793,7 +1793,7 @@ cookie_write (void *cookie, const void *buffer, size_t size) int nleft = size; while (nleft > 0) { - nwritten = gnutls_record_send (c->tls_session, buffer, nleft); + nwritten = gnutls_record_send (c->tls_session, buffer, nleft); if (nwritten <= 0) { if (nwritten == GNUTLS_E_INTERRUPTED) @@ -1801,7 +1801,7 @@ cookie_write (void *cookie, const void *buffer, size_t size) if (nwritten == GNUTLS_E_AGAIN) { struct timeval tv; - + tv.tv_sec = 0; tv.tv_usec = 50000; my_select (0, NULL, NULL, NULL, &tv); diff --git a/common/http.h b/common/http.h index 7eecbc004..50c478c84 100644 --- a/common/http.h +++ b/common/http.h @@ -1,7 +1,7 @@ /* http.h - HTTP protocol handler * Copyright (C) 1999, 2000, 2001, 2003, 2006, * 2010 Free Software Foundation, Inc. - * + * * This file is part of GnuPG. * * GnuPG is free software; you can redistribute it and/or modify @@ -18,12 +18,12 @@ * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #ifndef GNUPG_COMMON_HTTP_H -#define GNUPG_COMMON_HTTP_H +#define GNUPG_COMMON_HTTP_H #include <gpg-error.h> #include "../common/estream.h" -struct uri_tuple_s +struct uri_tuple_s { struct uri_tuple_s *next; const char *name; /* A pointer into name. */ @@ -34,7 +34,7 @@ struct uri_tuple_s }; typedef struct uri_tuple_s *uri_tuple_t; -struct parsed_uri_s +struct parsed_uri_s { /* All these pointers point into BUFFER; most stuff is not escaped. */ char *scheme; /* Pointer to the scheme string (always lowercase). */ @@ -50,17 +50,17 @@ struct parsed_uri_s }; typedef struct parsed_uri_s *parsed_uri_t; -typedef enum +typedef enum { HTTP_REQ_GET = 1, HTTP_REQ_HEAD = 2, HTTP_REQ_POST = 3 - } + } http_req_t; /* We put the flag values into an enum, so that gdb can display them. */ enum - { + { HTTP_FLAG_TRY_PROXY = 1, HTTP_FLAG_SHUTDOWN = 2, HTTP_FLAG_LOG_RESP = 8, diff --git a/common/i18n.c b/common/i18n.c index d0d804a32..d8189974d 100644 --- a/common/i18n.c +++ b/common/i18n.c @@ -69,7 +69,7 @@ i18n_switchto_utf8 (void) if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) { xfree (orig_codeset); - orig_codeset = NULL; + orig_codeset = NULL; } } return orig_codeset; diff --git a/common/i18n.h b/common/i18n.h index abb8bd83e..3b02a6bbd 100644 --- a/common/i18n.h +++ b/common/i18n.h @@ -4,7 +4,7 @@ * This file is free software; as a special exception the author gives * unlimited permission to copy and/or distribute it, with or without * modifications, as long as this notice is preserved. - * + * * This file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY, to the extent permitted by law; without even * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR @@ -21,7 +21,7 @@ # define N_(a) (a) #else # ifdef HAVE_LOCALE_H -# include <locale.h> +# include <locale.h> # endif # ifdef ENABLE_NLS # include <libintl.h> diff --git a/common/init.c b/common/init.c index de79a14c4..bcb0cd4ea 100644 --- a/common/init.c +++ b/common/init.c @@ -27,7 +27,7 @@ #ifdef HAVE_W32_SYSTEM #include <windows.h> #endif -#ifdef HAVE_PTH +#ifdef HAVE_PTH #include <pth.h> #endif #ifdef HAVE_W32CE_SYSTEM @@ -79,7 +79,7 @@ void init_common_subsystems (int *argcp, char ***argvp) { /* Try to auto set the character set. */ - set_native_charset (NULL); + set_native_charset (NULL); #ifdef HAVE_W32_SYSTEM /* For W32 we need to initialize the socket layer. This is because @@ -92,12 +92,12 @@ init_common_subsystems (int *argcp, char ***argvp) # else { WSADATA wsadat; - + WSAStartup (0x202, &wsadat); } # endif /*!HAVE_PTH*/ #endif - + #ifdef HAVE_W32CE_SYSTEM /* Register the sleep exit function before the estream init so that the sleep will be called after the estream registered atexit @@ -173,7 +173,7 @@ parse_std_file_handles (int *argcp, char ***argvp) s = *argv; if (*s == '-' && s[1] == '&' && s[2] == 'S' && (s[3] == '0' || s[3] == '1' || s[3] == '2') - && s[4] == '=' + && s[4] == '=' && (strchr ("-01234567890", s[5]) || !strcmp (s+5, "null"))) { if (s[5] == 'n') @@ -200,6 +200,6 @@ parse_std_file_handles (int *argcp, char ***argvp) argv[i] = NULL; } - + } #endif /*HAVE_W32CE_SYSTEM*/ diff --git a/common/iobuf.c b/common/iobuf.c index 9813d3da6..5f20d6e63 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -45,7 +45,7 @@ /*-- Begin configurable part. --*/ -/* The size of the internal buffers. +/* The size of the internal buffers. NOTE: If you change this value you MUST also adjust the regression test "armored_key_8192" in armor.test! */ #define IOBUF_BUFFER_SIZE 8192 @@ -71,7 +71,7 @@ typedef struct { gnupg_fd_t fp; /* Open file pointer or handle. */ - int keep_open; + int keep_open; int no_cache; int eof_seen; int print_only_name; /* Flags indicating that fname is not a real file. */ @@ -156,7 +156,7 @@ fd_cache_strcmp (const char *a, const char *b) #ifdef HAVE_DOSISH_SYSTEM for (; *a && *b; a++, b++) { - if (*a != *b && !((*a == '/' && *b == '\\') + if (*a != *b && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')) ) break; } @@ -327,7 +327,7 @@ direct_open (const char *fname, const char *mode) /* - * Instead of closing an FD we keep it open and cache it for later reuse + * Instead of closing an FD we keep it open and cache it for later reuse * Note that this caching strategy only works if the process does not chdir. */ static void @@ -878,7 +878,7 @@ block_filter (void *opaque, int control, iobuf_t chain, byte * buffer, /* log_debug("partial: ctx=%p c=%02x size=%u\n", a, c, a->size); */ } else - BUG (); + BUG (); } while (!rc && size && a->size) @@ -1483,13 +1483,13 @@ int iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval) { if (cmd == IOBUF_IOCTL_KEEP_OPEN) - { + { /* Keep system filepointer/descriptor open. This was used in the past by http.c; this ioctl is not directly used anymore. */ if (DBG_IOBUF) log_debug ("iobuf-%d.%d: ioctl `%s' keep_open=%d\n", - a ? a->no : -1, a ? a->subno : -1, + a ? a->no : -1, a ? a->subno : -1, a && a->desc ? a->desc : "?", intval); for (; a; a = a->chain) @@ -1524,7 +1524,7 @@ iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval) { if (DBG_IOBUF) log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n", - a ? a->no : -1, a ? a->subno : -1, + a ? a->no : -1, a ? a->subno : -1, a && a->desc? a->desc : "?", intval); for (; a; a = a->chain) @@ -1640,7 +1640,7 @@ iobuf_push_filter2 (iobuf_t a, if (DBG_IOBUF) { - log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno, + log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno, a->desc?a->desc:"?"); print_chain (a); } @@ -2147,24 +2147,24 @@ iobuf_get_filelength (iobuf_t a, int *overflow) if (overflow) *overflow = 0; - - if ( a->directfp ) + + if ( a->directfp ) { FILE *fp = a->directfp; - + if ( !fstat(fileno(fp), &st) ) return st.st_size; log_error("fstat() failed: %s\n", strerror(errno) ); return 0; } - + /* Hmmm: file_filter may have already been removed */ for ( ; a; a = a->chain ) if ( !a->chain && a->filter == file_filter ) { file_filter_ctx_t *b = a->filter_ov; gnupg_fd_t fp = b->fp; - + #if defined(HAVE_W32_SYSTEM) ulong size; static int (* __stdcall get_file_size_ex) (void *handle, @@ -2174,7 +2174,7 @@ iobuf_get_filelength (iobuf_t a, int *overflow) if (!get_file_size_ex_initialized) { void *handle; - + handle = dlopen ("kernel32.dll", RTLD_LAZY); if (handle) { @@ -2184,21 +2184,21 @@ iobuf_get_filelength (iobuf_t a, int *overflow) } get_file_size_ex_initialized = 1; } - + if (get_file_size_ex) { /* This is a newer system with GetFileSizeEx; we use this then because it seem that GetFileSize won't return a proper error in case a file is larger than 4GB. */ LARGE_INTEGER exsize; - + if (get_file_size_ex (fp, &exsize)) { if (!exsize.u.HighPart) return exsize.u.LowPart; if (overflow) *overflow = 1; - return 0; + return 0; } } else @@ -2215,14 +2215,14 @@ iobuf_get_filelength (iobuf_t a, int *overflow) #endif break/*the for loop*/; } - + return 0; } /* Return the file descriptor of the underlying file or -1 if it is not available. */ -int +int iobuf_get_fd (iobuf_t a) { if (a->directfp) @@ -2501,7 +2501,7 @@ translate_file_handle (int fd, int for_write) #elif defined(HAVE_W32_SYSTEM) { int x; - + (void)for_write; if (fd == 0) @@ -2533,13 +2533,13 @@ iobuf_skip_rest (iobuf_t a, unsigned long n, int partial) { for (;;) { - if (a->nofast || a->d.start >= a->d.len) + if (a->nofast || a->d.start >= a->d.len) { if (iobuf_readbyte (a) == -1) { break; } - } + } else { unsigned long count = a->d.len - a->d.start; @@ -2547,11 +2547,11 @@ iobuf_skip_rest (iobuf_t a, unsigned long n, int partial) a->d.start = a->d.len; } } - } + } else { unsigned long remaining = n; - while (remaining > 0) + while (remaining > 0) { if (a->nofast || a->d.start >= a->d.len) { @@ -2560,11 +2560,11 @@ iobuf_skip_rest (iobuf_t a, unsigned long n, int partial) break; } --remaining; - } - else + } + else { unsigned long count = a->d.len - a->d.start; - if (count > remaining) + if (count > remaining) { count = remaining; } diff --git a/common/iobuf.h b/common/iobuf.h index 3ac4fa061..3a189c47d 100644 --- a/common/iobuf.h +++ b/common/iobuf.h @@ -38,7 +38,7 @@ /* Command codes for iobuf_ioctl. */ -typedef enum +typedef enum { IOBUF_IOCTL_KEEP_OPEN = 1, /* Uses intval. */ IOBUF_IOCTL_INVALIDATE_CACHE = 2, /* Uses ptrval. */ diff --git a/common/localename.c b/common/localename.c index 8f7774880..82fe51754 100644 --- a/common/localename.c +++ b/common/localename.c @@ -1,5 +1,5 @@ /* localename.c - Determine the current selected locale. - Copyright (C) 1995-1999, 2000-2003, 2007, + Copyright (C) 1995-1999, 2000-2003, 2007, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or @@ -17,7 +17,7 @@ */ /* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */ /* Win32 code written by Tor Lillqvist <tml@iki.fi>. */ -/* Modified for GpgOL use by Werner Koch <wk@gnupg.org>, 2005. */ +/* Modified for GpgOL use by Werner Koch <wk@gnupg.org>, 2005. */ /* Modified for GnuPG use by Werner Koch <wk@gnupg.org>, 2007 */ #ifdef HAVE_CONFIG_H @@ -68,7 +68,7 @@ do_nl_locale_name (int category, const char *categoryname) # if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL (void)categoryname; retval = setlocale (category, NULL); -# else +# else /* Setting of LC_ALL overwrites all other. */ retval = getenv ("LC_ALL"); if (retval == NULL || retval[0] == '\0') @@ -114,4 +114,3 @@ gnupg_messages_locale_name (void) return s; } - diff --git a/common/logging.c b/common/logging.c index a32514502..94e7fbae1 100644 --- a/common/logging.c +++ b/common/logging.c @@ -1,5 +1,5 @@ /* logging.c - Useful logging functions - * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, + * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, * 2009, 2010 Free Software Foundation, Inc. * * This file is part of JNLIB. @@ -134,7 +134,7 @@ writen (int fd, const void *buffer, size_t nbytes, int is_socket) #ifndef HAVE_W32_SYSTEM (void)is_socket; /* Not required. */ #endif - + while (nleft > 0) { #ifdef HAVE_W32_SYSTEM @@ -151,14 +151,14 @@ writen (int fd, const void *buffer, size_t nbytes, int is_socket) nleft -= nwritten; buf = buf + nwritten; } - + return 0; } /* Returns true if STR represents a valid port number in decimal notation and no garbage is following. */ -static int +static int parse_portno (const char *str, unsigned short *r_port) { unsigned int value; @@ -177,7 +177,7 @@ parse_portno (const char *str, unsigned short *r_port) } -static ssize_t +static ssize_t fun_writer (void *cookie_arg, const void *buffer, size_t size) { struct fun_cookie_s *cookie = cookie_arg; @@ -222,7 +222,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size) else if (!strncmp (name, "socket://", 9) && name[9]) name += 9; #endif - + if (af == AF_LOCAL) { #ifdef HAVE_W32_SYSTEM @@ -255,7 +255,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size) jnlib_set_errno (EINVAL); addrlen = 0; } - else + else { *p = 0; #ifdef WITH_IPV6 @@ -310,7 +310,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size) addrlen = 0; #endif /*!HAVE_INET_PTON*/ } - + jnlib_free (addrstr); } @@ -334,7 +334,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size) cookie->fd = -1; } } - + if (cookie->fd == -1) { if (!running_detached) @@ -357,21 +357,21 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size) cookie->is_socket = 1; } } - + log_socket = cookie->fd; if (cookie->fd != -1) - { + { #ifdef HAVE_W32CE_SYSTEM if (cookie->use_writefile) { DWORD nwritten; - + WriteFile ((HANDLE)cookie->fd, buffer, size, &nwritten, NULL); return (ssize_t)size; /* Okay. */ } #endif if (!writen (cookie->fd, buffer, size, cookie->is_socket)) - return (ssize_t)size; /* Okay. */ + return (ssize_t)size; /* Okay. */ } if (!running_detached && cookie->fd != -1 @@ -390,7 +390,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size) cookie->fd = -1; log_socket = -1; } - + return (ssize_t)size; } @@ -411,7 +411,7 @@ fun_closer (void *cookie_arg) /* Common function to either set the logging to a file or a file descriptor. */ static void -set_file_fd (const char *name, int fd) +set_file_fd (const char *name, int fd) { estream_t fp; int want_socket; @@ -489,7 +489,7 @@ set_file_fd (const char *name, int fd) es_cookie_io_functions_t io = { NULL }; io.func_write = fun_writer; io.func_close = fun_closer; - + fp = es_fopencookie (cookie, "w", io); } @@ -498,7 +498,7 @@ set_file_fd (const char *name, int fd) fp = es_stderr; es_setvbuf (fp, NULL, _IOLBF, 0); - + logstream = fp; /* We always need to print the prefix and the pid for socket mode, @@ -518,7 +518,7 @@ set_file_fd (const char *name, int fd) tries the next time again to connect the socket. */ void -log_set_file (const char *name) +log_set_file (const char *name) { set_file_fd (name? name: "-", -1); } @@ -545,7 +545,7 @@ log_set_prefix (const char *text, unsigned int flags) strncpy (prefix_buffer, text, sizeof (prefix_buffer)-1); prefix_buffer[sizeof (prefix_buffer)-1] = 0; } - + with_prefix = (flags & JNLIB_LOG_WITH_PREFIX); with_time = (flags & JNLIB_LOG_WITH_TIME); with_pid = (flags & JNLIB_LOG_WITH_PID); @@ -635,7 +635,7 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr) { struct tm *tp; time_t atime = time (NULL); - + tp = localtime (&atime); es_fprintf_unlocked (logstream, "%04d-%02d-%02d %02d:%02d:%02d ", 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, @@ -674,7 +674,7 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr) case JNLIB_LOG_FATAL: es_fputs_unlocked ("Fatal: ",logstream ); break; case JNLIB_LOG_BUG: es_fputs_unlocked ("Ohhhh jeeee: ", logstream); break; case JNLIB_LOG_DEBUG: es_fputs_unlocked ("DBG: ", logstream ); break; - default: + default: es_fprintf_unlocked (logstream,"[Unknown log level %d]: ", level); break; } @@ -712,7 +712,7 @@ void log_log (int level, const char *fmt, ...) { va_list arg_ptr ; - + va_start (arg_ptr, fmt) ; do_logv (level, 0, fmt, arg_ptr); va_end (arg_ptr); @@ -750,7 +750,7 @@ void log_info (const char *fmt, ...) { va_list arg_ptr ; - + va_start (arg_ptr, fmt); do_logv (JNLIB_LOG_INFO, 0, fmt, arg_ptr); va_end (arg_ptr); @@ -761,7 +761,7 @@ void log_error (const char *fmt, ...) { va_list arg_ptr ; - + va_start (arg_ptr, fmt); do_logv (JNLIB_LOG_ERROR, 0, fmt, arg_ptr); va_end (arg_ptr); @@ -775,7 +775,7 @@ void log_fatal (const char *fmt, ...) { va_list arg_ptr ; - + va_start (arg_ptr, fmt); do_logv (JNLIB_LOG_FATAL, 0, fmt, arg_ptr); va_end (arg_ptr); @@ -799,7 +799,7 @@ void log_debug (const char *fmt, ...) { va_list arg_ptr ; - + va_start (arg_ptr, fmt); do_logv (JNLIB_LOG_DEBUG, 0, fmt, arg_ptr); va_end (arg_ptr); @@ -810,7 +810,7 @@ void log_printf (const char *fmt, ...) { va_list arg_ptr; - + va_start (arg_ptr, fmt); do_logv (fmt ? JNLIB_LOG_CONT : JNLIB_LOG_BEGIN, 0, fmt, arg_ptr); va_end (arg_ptr); @@ -861,4 +861,3 @@ bug_at( const char *file, int line ) abort (); /* Never called; just to make the compiler happy. */ } #endif - diff --git a/common/logging.h b/common/logging.h index 9493841ae..fa5d4cfd7 100644 --- a/common/logging.h +++ b/common/logging.h @@ -87,8 +87,3 @@ void log_printhex (const char *text, const void *buffer, size_t length); #endif /*LIBJNLIB_LOGGING_H*/ - - - - - diff --git a/common/membuf.c b/common/membuf.c index 8648044a7..d1ddbb9e6 100644 --- a/common/membuf.c +++ b/common/membuf.c @@ -85,7 +85,7 @@ put_membuf (membuf_t *mb, const void *buf, size_t len) if (mb->len + len >= mb->size) { char *p; - + mb->size += len + 1024; p = xtryrealloc (mb->buf, mb->size); if (!p) @@ -94,7 +94,7 @@ put_membuf (membuf_t *mb, const void *buf, size_t len) /* Wipe out what we already accumulated. This is required in case we are storing sensitive data here. The membuf API does not provide another way to cleanup after an - error. */ + error. */ wipememory (mb->buf, mb->len); return; } @@ -158,4 +158,3 @@ peek_membuf (membuf_t *mb, size_t *len) *len = mb->len; return p; } - diff --git a/common/membuf.h b/common/membuf.h index 9f1a7a33b..f99b4dcfb 100644 --- a/common/membuf.h +++ b/common/membuf.h @@ -22,12 +22,12 @@ /* The definition of the structure is private, we only need it here, so it can be allocated on the stack. */ -struct private_membuf_s +struct private_membuf_s { - size_t len; - size_t size; - char *buf; - int out_of_core; + size_t len; + size_t size; + char *buf; + int out_of_core; }; typedef struct private_membuf_s membuf_t; diff --git a/common/miscellaneous.c b/common/miscellaneous.c index 0ff7d98d7..1bab1515e 100644 --- a/common/miscellaneous.c +++ b/common/miscellaneous.c @@ -31,7 +31,7 @@ static void my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr) { (void)dummy; - + /* Map the log levels. */ switch (level) { @@ -42,7 +42,7 @@ my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr) case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break; case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break; case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break; - default: level = JNLIB_LOG_ERROR; break; + default: level = JNLIB_LOG_ERROR; break; } log_logv (level, fmt, arg_ptr); } @@ -102,7 +102,7 @@ setup_libgcrypt_logging (void) and "AES256". We can't fix that in libgcrypt but it is pretty safe to do it in an application. */ const char * -gnupg_cipher_algo_name (int algo) +gnupg_cipher_algo_name (int algo) { const char *s; @@ -139,7 +139,7 @@ void print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim) { char tmp[2]; - + tmp[0] = delim; tmp[1] = 0; es_write_sanitized_utf8_buffer (stream, p, n, tmp, NULL); @@ -197,7 +197,7 @@ is_file_compressed (const char *s, int *ret_rc) { 3, { 0x1f, 0x8b, 0x08, 0x00 } }, /* gzip */ { 4, { 0x50, 0x4b, 0x03, 0x04 } }, /* (pk)zip */ }; - + if ( iobuf_is_pipe_filename (s) || !ret_rc ) return 0; /* We can't check stdin or no file was given */ @@ -225,7 +225,7 @@ is_file_compressed (const char *s, int *ret_rc) } } -leave: +leave: iobuf_close( a ); return rc; } @@ -262,7 +262,7 @@ static const char* parse_version_number (const char *s, int *number) { int val = 0; - + if (*s == '0' && digitp (s+1)) return NULL; /* Leading zeros are not allowed. */ for (; digitp (s); s++ ) @@ -330,4 +330,3 @@ gnupg_compare_version (const char *a, const char *b) && a_micro == b_micro && strcmp (a_plvl, b_plvl) >= 0)); } - diff --git a/common/mischelp.c b/common/mischelp.c index 5c8f1cfab..57688d767 100644 --- a/common/mischelp.c +++ b/common/mischelp.c @@ -53,13 +53,13 @@ int same_file_p (const char *name1, const char *name2) { int yes; - + /* First try a shortcut. */ if (!compare_filenames (name1, name2)) yes = 1; else { -#ifdef HAVE_W32_SYSTEM +#ifdef HAVE_W32_SYSTEM HANDLE file1, file2; BY_HANDLE_FILE_INFORMATION info1, info2; @@ -72,7 +72,7 @@ same_file_p (const char *name1, const char *name2) file1 = INVALID_HANDLE_VALUE; jnlib_free (wname); } -#else +#else file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL); #endif if (file1 == INVALID_HANDLE_VALUE) @@ -106,7 +106,7 @@ same_file_p (const char *name1, const char *name2) } #else /*!HAVE_W32_SYSTEM*/ struct stat info1, info2; - + yes = (!stat (name1, &info1) && !stat (name2, &info2) && info1.st_dev == info2.st_dev && info1.st_ino == info2.st_ino); #endif /*!HAVE_W32_SYSTEM*/ @@ -180,7 +180,7 @@ timegm (struct tm *tm) } } if (old_zone) - putenv (old_zone); + putenv (old_zone); } else gnupg_unsetenv("TZ"); @@ -190,4 +190,3 @@ timegm (struct tm *tm) #endif } #endif /*!HAVE_TIMEGM*/ - diff --git a/common/mkerrors b/common/mkerrors index 48c6b896a..138d3c1d1 100755 --- a/common/mkerrors +++ b/common/mkerrors @@ -28,12 +28,12 @@ cat <<EOF /** * gnupg_strerror: - * @err: Error code - * + * @err: Error code + * * This function returns a textual representaion of the given * errorcode. If this is an unknown value, a string with the value * is returned (Beware: it is hold in a static buffer). - * + * * Return value: String with the error description. **/ const char * diff --git a/common/mkerrtok b/common/mkerrtok index b804ffca7..e6310722a 100755 --- a/common/mkerrtok +++ b/common/mkerrtok @@ -24,13 +24,13 @@ cat <<EOF /** * gnupg_error_token: - * @err: Error code - * + * @err: Error code + * * This function returns a textual representaion of the given * errorcode. If this is an unknown value, a static string is returned. - * This function differs from gnupg_strerror that it yields the string + * This function differs from gnupg_strerror that it yields the string * representation of the macro which is never subject to i18n. - * + * * Return value: String with the error token. **/ const char * diff --git a/common/mkstrtable.awk b/common/mkstrtable.awk index 56e9bb881..b5d4ef07a 100644 --- a/common/mkstrtable.awk +++ b/common/mkstrtable.awk @@ -1,6 +1,6 @@ # mkstrtable.awk # Copyright (C) 2003, 2004 g10 Code GmbH -# +# # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of @@ -181,5 +181,5 @@ END { print " : " stop + 1 " - " skip ")"; else print " : -1)"; - + } diff --git a/common/openpgpdefs.h b/common/openpgpdefs.h index e8121b12a..586f6fd9c 100644 --- a/common/openpgpdefs.h +++ b/common/openpgpdefs.h @@ -21,7 +21,7 @@ #ifndef GNUPG_COMMON_OPENPGPDEFS_H #define GNUPG_COMMON_OPENPGPDEFS_H -typedef enum +typedef enum { PKT_NONE = 0, PKT_PUBKEY_ENC = 1, /* Public key encrypted packet. */ @@ -44,11 +44,11 @@ typedef enum PKT_MDC = 19, /* Manipulation detection code packet. */ PKT_COMMENT = 61, /* new comment packet (GnuPG specific). */ PKT_GPG_CONTROL = 63 /* internal control packet (GnuPG specific). */ - } + } pkttype_t; -typedef enum +typedef enum { SIGSUBPKT_TEST_CRITICAL = -3, SIGSUBPKT_LIST_UNHASHED = -2, @@ -76,11 +76,11 @@ typedef enum SIGSUBPKT_SIGNERS_UID = 28, /* Signer's user id. */ SIGSUBPKT_REVOC_REASON = 29, /* Reason for revocation. */ SIGSUBPKT_FEATURES = 30, /* Feature flags. */ - + SIGSUBPKT_SIGNATURE = 32, /* Embedded signature. */ - + SIGSUBPKT_FLAG_CRITICAL = 128 - } + } sigsubpkttype_t; diff --git a/common/percent.c b/common/percent.c index e0c359289..172d7b765 100644 --- a/common/percent.c +++ b/common/percent.c @@ -46,13 +46,13 @@ percent_plus_escape (const char *string) for (length=1, s=string; *s; s++) { - if (*s == '+' || *s == '\"' || *s == '%' + if (*s == '+' || *s == '\"' || *s == '%' || *(const unsigned char *)s < 0x20) length += 3; else length++; } - + buffer = p = xtrymalloc (length); if (!buffer) return NULL; @@ -82,7 +82,7 @@ percent_plus_escape (const char *string) done if WITHPLUS is true. An escaped Nul character will be replaced by NULREPL. */ static size_t -do_unescape (unsigned char *buffer, const unsigned char *string, +do_unescape (unsigned char *buffer, const unsigned char *string, int withplus, int nulrepl) { unsigned char *p = buffer; @@ -90,7 +90,7 @@ do_unescape (unsigned char *buffer, const unsigned char *string, while (*string) { if (*string == '%' && string[1] && string[2]) - { + { string++; *p = xtoi_2 (string); if (!*p) @@ -119,7 +119,7 @@ count_unescape (const unsigned char *string) while (*string) { if (*string == '%' && string[1] && string[2]) - { + { string++; string++; } @@ -181,7 +181,7 @@ do_unescape_inplace (char *string, int withplus, int nulrepl) while (*string) { if (*string == '%' && string[1] && string[2]) - { + { string++; *p = xtoi_2 (string); if (!*p) @@ -226,4 +226,3 @@ percent_unescape_inplace (char *string, int nulrepl) { return do_unescape_inplace (string, 0, nulrepl); } - diff --git a/common/pka.c b/common/pka.c index 5cdc323e6..7ac70d9c4 100644 --- a/common/pka.c +++ b/common/pka.c @@ -47,7 +47,7 @@ /* Parse the TXT resource record. Format is: v=pka1;fpr=a4d94e92b0986ab5ee9dcd755de249965b0358a2;uri=string - + For simplicity white spaces are not allowed. Because we expect to use a new RRTYPE for this in the future we define the TXT really strict for simplicity: No white spaces, case sensitivity of the @@ -70,7 +70,7 @@ parse_txt_record (char *buffer, unsigned char *fpr) *pend++ = 0; if (strcmp (p, "v=pka1")) return -1; /* Wrong or missing version. */ - + p = pend; pend = strchr (p, ';'); if (pend) @@ -82,11 +82,11 @@ parse_txt_record (char *buffer, unsigned char *fpr) fpr[i] = xtoi_2 (p); if (i != 20) return -1; /* Fingerprint consists not of exactly 40 hexbytes. */ - + p = pend; if (!p || !*p) { - *buffer = 0; + *buffer = 0; return 0; /* Success (no URI given). */ } if (strncmp (p, "uri=", 4)) @@ -119,7 +119,7 @@ get_pka_info (const char *address, unsigned char *fpr) char *name; adns_answer *answer = NULL; char *buffer = NULL; - + domain = strrchr (address, '@'); if (!domain || domain == address || !domain[1]) return NULL; /* Invalid mail address given. */ @@ -146,7 +146,7 @@ get_pka_info (const char *address, unsigned char *fpr) adns_finish (state); return NULL; } - if (answer->status != adns_s_ok + if (answer->status != adns_s_ok || answer->type != adns_r_txt || !answer->nrrs) { log_error ("DNS query returned an error: %s (%s)\n", @@ -209,7 +209,7 @@ get_pka_info (const char *address, unsigned char *fpr) expansion of the buffer. */ if (anslen > PACKETSZ) return NULL; /* DNS resolver returned a too long answer */ - + qdcount = ntohs (header.qdcount); ancount = ntohs (header.ancount); nscount = ntohs (header.nscount); @@ -226,7 +226,7 @@ get_pka_info (const char *address, unsigned char *fpr) rc = dn_skipname (p, pend); if (rc == -1) return NULL; - p += rc + QFIXEDSZ; + p += rc + QFIXEDSZ; } if (ancount > 1) diff --git a/common/session-env.c b/common/session-env.c index d719a7b87..7f4ca5eea 100644 --- a/common/session-env.c +++ b/common/session-env.c @@ -49,8 +49,8 @@ struct session_environment_s /* A list of environment vribales we pass from the acual user (e.g. gpgme) down to the pinentry. We do not handle the locale settings because they do not only depend on envvars. */ -static struct -{ +static struct +{ const char *name; const char *assname; /* Name used by Assuan or NULL. */ } stdenvnames[] = { @@ -64,7 +64,7 @@ static struct modules (eg "scim-bridge"). */ { "QT_IM_MODULE" }, /* Used by Qt to select qt input modules (eg "xim"). */ - { "PINENTRY_USER_DATA", "pinentry-user-data"} + { "PINENTRY_USER_DATA", "pinentry-user-data"} /* Used for communication with non-standard Pinentries. */ }; @@ -109,7 +109,7 @@ session_env_new (void) se = xtrycalloc (1, sizeof *se); if (se) { - se->arraysize = (lastallocatedarraysize? + se->arraysize = (lastallocatedarraysize? lastallocatedarraysize : INITIAL_ARRAYSIZE); se->array = xtrycalloc (se->arraysize, sizeof *se->array); if (!se->array) @@ -132,7 +132,7 @@ session_env_release (session_env_t se) if (!se) return; - if (se->arraysize > INITIAL_ARRAYSIZE + if (se->arraysize > INITIAL_ARRAYSIZE && se->arraysize <= MAXDEFAULT_ARRAYSIZE && se->arraysize > lastallocatedarraysize) lastallocatedarraysize = se->arraysize; @@ -249,7 +249,7 @@ gpg_error_t session_env_putenv (session_env_t se, const char *string) { const char *s; - + if (!string || !*string) return gpg_error (GPG_ERR_INV_VALUE); s = strchr (string, '='); @@ -325,7 +325,7 @@ session_env_getenv_or_default (session_env_t se, const char *name, *r_default = 1; return se->array[idx]->value; } - + /* Get the default value with an additional fallback for GPG_TTY. */ defvalue = getenv (name); if ((!defvalue || !*defvalue) && !strcmp (name, "GPG_TTY") && ttyname (0)) @@ -339,7 +339,7 @@ session_env_getenv_or_default (session_env_t se, const char *name, explicit error anyway and the following scan would then fail anyway. */ update_var (se, name, strlen (name), defvalue, 1); - + for (idx=0; idx < se->arrayused; idx++) if (se->array[idx] && !strcmp (se->array[idx]->name, name)) { @@ -359,7 +359,7 @@ session_env_getenv_or_default (session_env_t se, const char *name, R_DEFAULT is not NULL, the default flag is stored on return. The default flag indicates that the value has been taken from the process' environment. The caller must not change the returned - name or value. */ + name or value. */ char * session_env_listenv (session_env_t se, int *iterator, const char **r_value, int *r_default) @@ -381,5 +381,3 @@ session_env_listenv (session_env_t se, int *iterator, } return NULL; } - - diff --git a/common/session-env.h b/common/session-env.h index 031fe1d7c..79245ba4e 100644 --- a/common/session-env.h +++ b/common/session-env.h @@ -23,20 +23,20 @@ struct session_environment_s; typedef struct session_environment_s *session_env_t; -const char *session_env_list_stdenvnames (int *iterator, +const char *session_env_list_stdenvnames (int *iterator, const char **r_assname); session_env_t session_env_new (void); void session_env_release (session_env_t se); gpg_error_t session_env_putenv (session_env_t se, const char *string); -gpg_error_t session_env_setenv (session_env_t se, +gpg_error_t session_env_setenv (session_env_t se, const char *name, const char *value); char *session_env_getenv (session_env_t se, const char *name); char *session_env_getenv_or_default (session_env_t se, const char *name, int *r_default); -char *session_env_listenv (session_env_t se, int *iterator, +char *session_env_listenv (session_env_t se, int *iterator, const char **r_value, int *r_default); diff --git a/common/sexp-parse.h b/common/sexp-parse.h index 5ec7c7f71..008c2d221 100644 --- a/common/sexp-parse.h +++ b/common/sexp-parse.h @@ -51,7 +51,7 @@ sskip (unsigned char const **buf, int *depth) const unsigned char *s = *buf; size_t n; int d = *depth; - + while (d > 0) { if (*s == '(') @@ -70,7 +70,7 @@ sskip (unsigned char const **buf, int *depth) return gpg_error (GPG_ERR_INV_SEXP); n = snext (&s); if (!n) - return gpg_error (GPG_ERR_INV_SEXP); + return gpg_error (GPG_ERR_INV_SEXP); s += n; } } @@ -123,6 +123,6 @@ smklen (char *help_buffer, size_t help_buflen, size_t value, size_t *length) *length = (help_buffer + help_buflen) - p; return p; } - + #endif /*SEXP_PARSE_H*/ diff --git a/common/sexputil.c b/common/sexputil.c index 1e9c766e9..87f984ff4 100644 --- a/common/sexputil.c +++ b/common/sexputil.c @@ -52,7 +52,7 @@ make_canon_sexp (gcry_sexp_t sexp, unsigned char **r_buffer, size_t *r_buflen) *r_buffer = NULL; if (r_buflen) *r_buflen = 0;; - + len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); if (!len) return gpg_error (GPG_ERR_BUG); @@ -83,7 +83,7 @@ make_canon_sexp_pad (gcry_sexp_t sexp, int secure, *r_buffer = NULL; if (r_buflen) *r_buflen = 0;; - + len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); if (!len) return gpg_error (GPG_ERR_BUG); @@ -189,7 +189,7 @@ make_simple_sexp_from_hexstr (const char *line, size_t *nscanned) *nscanned = n; if (!n) return NULL; - len = ((n+1) & ~0x01)/2; + len = ((n+1) & ~0x01)/2; numbufp = smklen (numbuf, sizeof numbuf, len, &numbuflen); buf = xtrymalloc (1 + numbuflen + len + 1 + 1); if (!buf) @@ -252,7 +252,7 @@ hash_algo_from_sigval (const unsigned char *sigval) return 0; /* Algorithm string is missing or too long. */ memcpy (buffer, s, n); buffer[n] = 0; - + return gcry_md_map_name (buffer); } @@ -283,7 +283,7 @@ make_canon_sexp_from_rsa_pk (const void *m_arg, size_t mlen, ; for (; elen && !*e; elen--, e++) ; - + /* Insert a leading zero if the number would be zero or interpreted as negative. */ if (!mlen || (m[0] & 0x80)) @@ -300,7 +300,7 @@ make_canon_sexp_from_rsa_pk (const void *m_arg, size_t mlen, + strlen (part3) + 1); if (!keybuf) return NULL; - + p = stpcpy (keybuf, part1); p = stpcpy (p, mlen_str); if (m_extra) @@ -314,7 +314,7 @@ make_canon_sexp_from_rsa_pk (const void *m_arg, size_t mlen, memcpy (p, e, elen); p += elen; p = stpcpy (p, part3); - + if (r_len) *r_len = p - keybuf; @@ -373,8 +373,8 @@ get_rsa_pk_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, switch (*tok) { - case 'n': mpi = &rsa_n; mpi_len = &rsa_n_len; break; - case 'e': mpi = &rsa_e; mpi_len = &rsa_e_len; break; + case 'n': mpi = &rsa_n; mpi_len = &rsa_n_len; break; + case 'e': mpi = &rsa_e; mpi_len = &rsa_e_len; break; default: mpi = NULL; mpi_len = NULL; break; } if (mpi && *mpi) @@ -425,7 +425,7 @@ get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen, const unsigned char *buf, *tok; size_t buflen, toklen; int depth; - + *r_algo = 0; buf = keydata; diff --git a/common/signal.c b/common/signal.c index ee55f1917..9f11b9922 100644 --- a/common/signal.c +++ b/common/signal.c @@ -45,7 +45,7 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign ) { # ifdef HAVE_SIGACTION struct sigaction oact, nact; - + if (check_ign) { /* we don't want to change an IGN handler */ @@ -58,11 +58,11 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign ) sigemptyset (&nact.sa_mask); nact.sa_flags = 0; sigaction ( sig, &nact, NULL); -# else +# else RETSIGTYPE (*ohandler)(int); - + ohandler = signal (sig, handler); - if (check_ign && ohandler == SIG_IGN) + if (check_ign && ohandler == SIG_IGN) { /* Change it back if it was already set to IGN */ signal (sig, SIG_IGN); @@ -96,7 +96,7 @@ got_fatal_signal (int sig) if (caught_fatal_sig) raise (sig); caught_fatal_sig = 1; - + if (cleanup_fnc) cleanup_fnc (); /* Better don't translate these messages. */ @@ -118,7 +118,7 @@ got_fatal_signal (int sig) this is a bug in that system, we will protect against it. */ if (sig < 0 || sig >= 100000) res = write (2, "?", 1); - else + else { int i, value, any=0; @@ -135,7 +135,7 @@ got_fatal_signal (int sig) } } res = write (2, " caught ... exiting\n", 20); - + /* Reset action to default action and raise signal again */ init_one_signal (sig, SIG_DFL, 0); /* Fixme: remove_lockfiles ();*/ diff --git a/common/simple-pwquery.c b/common/simple-pwquery.c index fd48b6f5a..2d2bfa21f 100644 --- a/common/simple-pwquery.c +++ b/common/simple-pwquery.c @@ -99,7 +99,7 @@ writen (int fd, const void *buf, size_t nbytes) { size_t nleft = nbytes; int nwritten; - + while (nleft > 0) { #ifdef HAVE_W32_SYSTEM @@ -121,7 +121,7 @@ writen (int fd, const void *buf, size_t nbytes) nleft -= nwritten; buf = (const char*)buf + nwritten; } - + return 0; } @@ -155,7 +155,7 @@ readline (int fd, char *buf, size_t buflen) nleft -= n; buf += n; nread += n; - + for (; n && *p != '\n'; n--, p++) ; if (n) @@ -166,7 +166,7 @@ readline (int fd, char *buf, size_t buflen) } } - return nread; + return nread; } @@ -177,8 +177,8 @@ agent_send_option (int fd, const char *name, const char *value) char buf[200]; int nread; char *line; - int i; - + int i; + line = spwq_malloc (7 + strlen (name) + 1 + strlen (value) + 2); if (!line) return SPWQ_OUT_OF_CORE; @@ -188,15 +188,15 @@ agent_send_option (int fd, const char *name, const char *value) spwq_free (line); if (i) return i; - + /* get response */ nread = readline (fd, buf, DIM(buf)-1); if (nread < 0) return -nread; if (nread < 3) return SPWQ_PROTOCOL_ERROR; - - if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n')) + + if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n')) return 0; /* okay */ return SPWQ_ERR_RESPONSE; @@ -204,7 +204,7 @@ agent_send_option (int fd, const char *name, const char *value) /* Send all available options to the agent. */ -static int +static int agent_send_all_options (int fd) { char *dft_display = NULL; @@ -239,7 +239,7 @@ agent_send_all_options (int fd) return rc; } -#if defined(HAVE_SETLOCALE) +#if defined(HAVE_SETLOCALE) { char *old_lc = NULL; char *dft_lc = NULL; @@ -330,9 +330,9 @@ agent_open (int *rfd) *rfd = -1; infostr = getenv ( "GPG_AGENT_INFO" ); - if ( !infostr || !*infostr ) + if ( !infostr || !*infostr ) infostr = default_gpg_agent_info; - if ( !infostr || !*infostr ) + if ( !infostr || !*infostr ) { #ifdef SPWQ_USE_LOGGING log_error (_("gpg-agent is not available in this session\n")); @@ -346,7 +346,7 @@ agent_open (int *rfd) infostr = p; if ( !(p = strchr ( infostr, PATHSEP_C)) || p == infostr - || (p-infostr)+1 >= sizeof client_addr.sun_path ) + || (p-infostr)+1 >= sizeof client_addr.sun_path ) { #ifdef SPWQ_USE_LOGGING log_error ( _("malformed GPG_AGENT_INFO environment variable\n")); @@ -366,25 +366,25 @@ agent_open (int *rfd) return SPWQ_PROTOCOL_ERROR; } -#ifdef HAVE_W32_SYSTEM +#ifdef HAVE_W32_SYSTEM fd = _w32_sock_new (AF_UNIX, SOCK_STREAM, 0); #else fd = socket (AF_UNIX, SOCK_STREAM, 0); #endif - if (fd == -1) + if (fd == -1) { #ifdef SPWQ_USE_LOGGING log_error ("can't create socket: %s\n", strerror(errno) ); #endif return SPWQ_SYS_ERROR; } - + memset (&client_addr, 0, sizeof client_addr); client_addr.sun_family = AF_UNIX; strcpy (client_addr.sun_path, infostr); len = SUN_LEN (&client_addr); - -#ifdef HAVE_W32_SYSTEM + +#ifdef HAVE_W32_SYSTEM rc = _w32_sock_connect (fd, (struct sockaddr*)&client_addr, len ); #else rc = connect (fd, (struct sockaddr*)&client_addr, len ); @@ -400,7 +400,7 @@ agent_open (int *rfd) nread = readline (fd, line, DIM(line)); if (nread < 3 || !(line[0] == 'O' && line[1] == 'K' - && (line[2] == '\n' || line[2] == ' ')) ) + && (line[2] == '\n' || line[2] == ' ')) ) { #ifdef SPWQ_USE_LOGGING log_error ( _("communication problem with gpg-agent\n")); @@ -434,7 +434,7 @@ copy_and_escape (char *buffer, const char *text) int i; const unsigned char *s = (unsigned char *)text; char *p = buffer; - + for (i=0; s[i]; i++) { @@ -453,7 +453,7 @@ copy_and_escape (char *buffer, const char *text) /* Set the name of the default socket to NAME. */ -int +int simple_pw_set_socket (const char *name) { spwq_free (default_gpg_agent_info); @@ -482,7 +482,7 @@ simple_pw_set_socket (const char *name) errorcode; this error code might be 0 if the user canceled the operation. The function returns NULL to indicate an error. */ char * -simple_pwquery (const char *cacheid, +simple_pwquery (const char *cacheid, const char *tryagain, const char *prompt, const char *description, @@ -494,7 +494,7 @@ simple_pwquery (const char *cacheid, char *result = NULL; char *pw = NULL; char *p; - int rc, i; + int rc, i; rc = agent_open (&fd); if (rc) @@ -555,11 +555,11 @@ simple_pwquery (const char *cacheid, rc = SPWQ_PROTOCOL_ERROR; goto leave; } - - if (pw[0] == 'O' && pw[1] == 'K' && pw[2] == ' ') + + if (pw[0] == 'O' && pw[1] == 'K' && pw[2] == ' ') { /* we got a passphrase - convert it back from hex */ size_t pwlen = 0; - + for (i=3; i < nread && hexdigitp (pw+i); i+=2) pw[pwlen++] = xtoi_2 (pw+i); pw[pwlen] = 0; /* make a C String */ @@ -569,7 +569,7 @@ simple_pwquery (const char *cacheid, else if ((nread > 7 && !memcmp (pw, "ERR 111", 7) && (pw[7] == ' ' || pw[7] == '\n') ) || ((nread > 4 && !memcmp (pw, "ERR ", 4) - && (strtoul (pw+4, NULL, 0) & 0xffff) == 99)) ) + && (strtoul (pw+4, NULL, 0) & 0xffff) == 99)) ) { /* 111 is the old Assuan code for canceled which might still be in use by old installations. 99 is GPG_ERR_CANCELED as @@ -588,14 +588,14 @@ simple_pwquery (const char *cacheid, default: rc = SPWQ_GENERAL_ERROR; break; } } - else + else { #ifdef SPWQ_USE_LOGGING log_error (_("problem with the agent\n")); #endif rc = SPWQ_ERR_RESPONSE; } - + leave: if (errorcode) *errorcode = rc; @@ -659,13 +659,13 @@ simple_query (const char *query) rc = SPWQ_PROTOCOL_ERROR; goto leave; } - - if (response[0] == 'O' && response[1] == 'K') + + if (response[0] == 'O' && response[1] == 'K') /* OK, do nothing. */; else if ((nread > 7 && !memcmp (response, "ERR 111", 7) && (response[7] == ' ' || response[7] == '\n') ) || ((nread > 4 && !memcmp (response, "ERR ", 4) - && (strtoul (response+4, NULL, 0) & 0xffff) == 99)) ) + && (strtoul (response+4, NULL, 0) & 0xffff) == 99)) ) { /* 111 is the old Assuan code for canceled which might still be in use by old installations. 99 is GPG_ERR_CANCELED as @@ -675,14 +675,14 @@ simple_query (const char *query) log_info (_("canceled by user\n") ); #endif } - else + else { #ifdef SPWQ_USE_LOGGING log_error (_("problem with the agent\n")); #endif rc = SPWQ_ERR_RESPONSE; } - + leave: if (fd != -1) close (fd); diff --git a/common/simple-pwquery.h b/common/simple-pwquery.h index edd834ef4..04ae1f04e 100644 --- a/common/simple-pwquery.h +++ b/common/simple-pwquery.h @@ -50,7 +50,7 @@ If ERRORCODE is not NULL it should point a variable receiving an errorcode; this errocode might be 0 if the user canceled the operation. The function returns NULL to indicate an error. */ -char *simple_pwquery (const char *cacheid, +char *simple_pwquery (const char *cacheid, const char *tryagain, const char *prompt, const char *description, @@ -71,7 +71,7 @@ int simple_pw_set_socket (const char *name); #define SPWQ_OUT_OF_CORE 1 #define SPWQ_IO_ERROR 2 -#define SPWQ_PROTOCOL_ERROR 3 +#define SPWQ_PROTOCOL_ERROR 3 #define SPWQ_ERR_RESPONSE 4 #define SPWQ_NO_AGENT 5 #define SPWQ_SYS_ERROR 6 @@ -108,8 +108,8 @@ int simple_pw_set_socket (const char *name); default: \ return gpg_error (GPG_ERR_GENERAL); \ } \ - } -/* End of MAP_SPWQ_ERROR_IMPL. */ + } +/* End of MAP_SPWQ_ERROR_IMPL. */ #endif /*SIMPLE_PWQUERY_H*/ diff --git a/common/srv.c b/common/srv.c index 79ffc7862..1b8248bf3 100644 --- a/common/srv.c +++ b/common/srv.c @@ -72,7 +72,7 @@ getsrv (const char *name,struct srventry **list) { adns_state state; adns_answer *answer = NULL; - + rc = adns_init (&state, adns_if_noerrprint, NULL); if (rc) { @@ -88,7 +88,7 @@ getsrv (const char *name,struct srventry **list) adns_finish (state); return -1; } - if (answer->status != adns_s_ok + if (answer->status != adns_s_ok || answer->type != adns_r_srv || !answer->nrrs) { log_error ("DNS query returned an error or no records: %s (%s)\n", @@ -109,7 +109,7 @@ getsrv (const char *name,struct srventry **list) log_info ("hostname in SRV record too long - skipped\n"); continue; } - + newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry)); if (!newlist) goto fail; @@ -117,7 +117,7 @@ getsrv (const char *name,struct srventry **list) memset (&(*list)[srvcount], 0, sizeof(struct srventry)); srv = &(*list)[srvcount]; srvcount++; - + srv->priority = answer->rrs.srvha[count].priority; srv->weight = answer->rrs.srvha[count].weight; srv->port = answer->rrs.srvha[count].port; @@ -134,29 +134,29 @@ getsrv (const char *name,struct srventry **list) unsigned char *pt, *emsg; int r; u16 dlen; - + r = res_query (name, C_IN, T_SRV, answer, sizeof answer); if (r < sizeof (HEADER) || r > sizeof answer) return -1; if (header->rcode != NOERROR || !(count=ntohs (header->ancount))) return 0; /* Error or no record found. */ - + emsg = &answer[r]; pt = &answer[sizeof(HEADER)]; - + /* Skip over the query */ rc = dn_skipname (pt, emsg); if (rc == -1) goto fail; - + pt += rc + QFIXEDSZ; - + while (count-- > 0 && pt < emsg) { struct srventry *srv=NULL; u16 type,class; struct srventry *newlist; - + newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry)); if (!newlist) goto fail; @@ -164,28 +164,28 @@ getsrv (const char *name,struct srventry **list) memset(&(*list)[srvcount],0,sizeof(struct srventry)); srv=&(*list)[srvcount]; srvcount++; - + rc = dn_skipname(pt,emsg); /* the name we just queried for */ if (rc == -1) goto fail; pt+=rc; - + /* Truncated message? */ if((emsg-pt)<16) goto fail; - + type=*pt++ << 8; type|=*pt++; /* We asked for SRV and got something else !? */ if(type!=T_SRV) goto fail; - + class=*pt++ << 8; class|=*pt++; /* We asked for IN and got something else !? */ if(class!=C_IN) goto fail; - + pt+=4; /* ttl */ dlen=*pt++ << 8; dlen|=*pt++; @@ -195,7 +195,7 @@ getsrv (const char *name,struct srventry **list) srv->weight|=*pt++; srv->port=*pt++ << 8; srv->port|=*pt++; - + /* Get the name. 2782 doesn't allow name compression, but dn_expand still works to pull the name out of the packet. */ @@ -215,17 +215,17 @@ getsrv (const char *name,struct srventry **list) } } #endif /*!USE_ADNS*/ - + /* Now we have an array of all the srv records. */ - + /* Order by priority */ qsort(*list,srvcount,sizeof(struct srventry),priosort); - + /* For each priority, move the zero-weighted items first. */ for (i=0; i < srvcount; i++) { int j; - + for (j=i;j < srvcount && (*list)[i].priority == (*list)[j].priority; j++) { if((*list)[j].weight==0) @@ -234,12 +234,12 @@ getsrv (const char *name,struct srventry **list) if(j!=i) { struct srventry temp; - + memcpy (&temp,&(*list)[j],sizeof(struct srventry)); memcpy (&(*list)[j],&(*list)[i],sizeof(struct srventry)); memcpy (&(*list)[i],&temp,sizeof(struct srventry)); } - + break; } } @@ -255,15 +255,15 @@ getsrv (const char *name,struct srventry **list) { int j; float prio_count=0,chose; - + for (j=i; j < srvcount && (*list)[i].priority == (*list)[j].priority; j++) { prio_count+=(*list)[j].weight; (*list)[j].run_count=prio_count; } - + chose=prio_count*rand()/RAND_MAX; - + for (j=i;j<srvcount && (*list)[i].priority==(*list)[j].priority;j++) { if (chose<=(*list)[j].run_count) @@ -272,7 +272,7 @@ getsrv (const char *name,struct srventry **list) if(j!=i) { struct srventry temp; - + memcpy(&temp,&(*list)[j],sizeof(struct srventry)); memcpy(&(*list)[j],&(*list)[i],sizeof(struct srventry)); memcpy(&(*list)[i],&temp,sizeof(struct srventry)); @@ -281,7 +281,7 @@ getsrv (const char *name,struct srventry **list) } } } - + return srvcount; fail: diff --git a/common/status.c b/common/status.c index 7b9f4a3ae..435279ccf 100644 --- a/common/status.c +++ b/common/status.c @@ -27,7 +27,7 @@ /* Return the status string for code NO. */ const char * -get_status_string ( int no ) +get_status_string ( int no ) { int idx = statusstr_msgidxof (no); if (idx == -1) @@ -41,7 +41,7 @@ const char * get_inv_recpsgnr_code (gpg_error_t err) { const char *errstr; - + switch (gpg_err_code (err)) { case GPG_ERR_NO_PUBKEY: errstr = "1"; break; diff --git a/common/stringhelp.c b/common/stringhelp.c index 5f66c7b66..15ca9d7fa 100644 --- a/common/stringhelp.c +++ b/common/stringhelp.c @@ -230,7 +230,7 @@ length_sans_trailing_chars (const unsigned char *line, size_t len, { const unsigned char *p, *mark; size_t n; - + for( mark=NULL, p=line, n=0; n < len; n++, p++ ) { if (strchr (trimchars, *p )) @@ -241,8 +241,8 @@ length_sans_trailing_chars (const unsigned char *line, size_t len, else mark = NULL; } - - if (mark) + + if (mark) return mark - line; return len; } @@ -363,16 +363,16 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr) { const char *argv[32]; int argc; - size_t n; + size_t n; int skip = 1; char *home_buffer = NULL; - char *name, *home, *p; - - n = strlen (first_part) + 1; + char *name, *home, *p; + + n = strlen (first_part) + 1; argc = 0; - while ( (argv[argc] = va_arg (arg_ptr, const char *)) ) + while ( (argv[argc] = va_arg (arg_ptr, const char *)) ) { - n += strlen (argv[argc]) + 1; + n += strlen (argv[argc]) + 1; if (argc >= DIM (argv)-1) { if (xmode) @@ -380,11 +380,11 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr) jnlib_set_errno (EINVAL); return NULL; } - argc++; + argc++; } n++; - - home = NULL; + + home = NULL; if (*first_part == '~') { if (first_part[1] == '/' || !first_part[1]) @@ -394,13 +394,13 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr) if (!home) home = home_buffer = get_pwdir (xmode, NULL); if (home && *home) - n += strlen (home); + n += strlen (home); } else { /* This is the "~username/" or "~username" case. */ char *user; - + if (xmode) user = jnlib_xstrdup (first_part+1); else @@ -413,7 +413,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr) if (p) *p = 0; skip = 1 + strlen (user); - + home = home_buffer = get_pwdir (xmode, user); jnlib_free (user); if (home) @@ -434,7 +434,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr) return NULL; } } - + if (home) p = stpcpy (stpcpy (name, home), first_part + skip); else @@ -489,9 +489,9 @@ int compare_filenames (const char *a, const char *b) { #ifdef HAVE_DOSISH_SYSTEM - for ( ; *a && *b; a++, b++ ) + for ( ; *a && *b; a++, b++ ) { - if (*a != *b + if (*a != *b && (toupper (*(const unsigned char*)a) != toupper (*(const unsigned char*)b) ) && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))) @@ -500,7 +500,7 @@ compare_filenames (const char *a, const char *b) if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')) return 0; else - return (toupper (*(const unsigned char*)a) + return (toupper (*(const unsigned char*)a) - toupper (*(const unsigned char*)b)); #else return strcmp(a,b); @@ -539,7 +539,7 @@ hextobyte (const char *s) /* Print a BUFFER to stream FP while replacing all control characters and the characters DELIM and DELIM2 with standard C escape sequences. Returns the number of characters printed. */ -size_t +size_t print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length, int delim, int delim2) { @@ -548,9 +548,9 @@ print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length, for (; length; length--, p++, count++) { - if (*p < 0x20 + if (*p < 0x20 || *p == 0x7f - || *p == delim + || *p == delim || *p == delim2 || ((delim || delim2) && *p=='\\')) { @@ -603,7 +603,7 @@ print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length, } /* Same as print_sanitized_buffer2 but with just one delimiter. */ -size_t +size_t print_sanitized_buffer (FILE *fp, const void *buffer, size_t length, int delim) { @@ -611,7 +611,7 @@ print_sanitized_buffer (FILE *fp, const void *buffer, size_t length, } -size_t +size_t print_sanitized_utf8_buffer (FILE *fp, const void *buffer, size_t length, int delim) { @@ -619,7 +619,7 @@ print_sanitized_utf8_buffer (FILE *fp, const void *buffer, size_t i; /* We can handle plain ascii simpler, so check for it first. */ - for (i=0; i < length; i++ ) + for (i=0; i < length; i++ ) { if ( (p[i] & 0x80) ) break; @@ -638,20 +638,20 @@ print_sanitized_utf8_buffer (FILE *fp, const void *buffer, } -size_t +size_t print_sanitized_string2 (FILE *fp, const char *string, int delim, int delim2) { return string? print_sanitized_buffer2 (fp, string, strlen (string), delim, delim2):0; } -size_t +size_t print_sanitized_string (FILE *fp, const char *string, int delim) { return string? print_sanitized_buffer (fp, string, strlen (string), delim):0; } -size_t +size_t print_sanitized_utf8_string (FILE *fp, const char *string, int delim) { return string? print_sanitized_utf8_buffer (fp, @@ -671,7 +671,7 @@ sanitize_buffer (const void *p_arg, size_t n, int delim) char *buffer, *d; /* First count length. */ - for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) + for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) { if ( *p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\')) { @@ -743,7 +743,7 @@ const char * w32_strerror (int ec) { static char strerr[256]; - + if (ec == -1) ec = (int)GetLastError (); #ifdef HAVE_W32CE_SYSTEM @@ -755,7 +755,7 @@ w32_strerror (int ec) MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), strerr, DIM (strerr)-1, NULL); #endif - return strerr; + return strerr; } #endif /*HAVE_W32_SYSTEM*/ @@ -776,7 +776,7 @@ ascii_islower (int c) return c >= 'a' && c <= 'z'; } -int +int ascii_toupper (int c) { if (c >= 'a' && c <= 'z') @@ -784,7 +784,7 @@ ascii_toupper (int c) return c; } -int +int ascii_tolower (int c) { if (c >= 'A' && c <= 'Z') @@ -806,7 +806,7 @@ ascii_strcasecmp( const char *a, const char *b ) return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b)); } -int +int ascii_strncasecmp (const char *a, const char *b, size_t n) { const unsigned char *p1 = (const unsigned char *)a; @@ -828,7 +828,7 @@ ascii_strncasecmp (const char *a, const char *b, size_t n) ++p2; } while (c1 == c2); - + return c1 - c2; } @@ -874,7 +874,7 @@ ascii_memcasemem (const void *haystack, size_t nhaystack, { const char *a = haystack; const char *b = a + nhaystack - nneedle; - + for (; a <= b; a++) { if ( !ascii_memcasecmp (a, needle, nneedle) ) @@ -1152,4 +1152,3 @@ xstrconcat (const char *s1, ...) } return result; } - diff --git a/common/stringhelp.h b/common/stringhelp.h index a560b163e..28cbdab72 100644 --- a/common/stringhelp.h +++ b/common/stringhelp.h @@ -103,7 +103,7 @@ void *memrchr (const void *buffer, int c, size_t n); #ifndef HAVE_ISASCII -static inline int +static inline int isascii (int c) { return (((c) & ~0x7f) == 0); diff --git a/common/strlist.c b/common/strlist.c index b31e6213a..93a58d5a0 100644 --- a/common/strlist.c +++ b/common/strlist.c @@ -63,7 +63,7 @@ strlist_t add_to_strlist_try (strlist_t *list, const char *string) { strlist_t sl; - + sl = jnlib_malloc (sizeof *sl + strlen (string)); if (sl) { @@ -84,10 +84,10 @@ strlist_t add_to_strlist2( strlist_t *list, const char *string, int is_utf8 ) { strlist_t sl; - + if (is_utf8) sl = add_to_strlist( list, string ); - else + else { char *p = native_to_utf8( string ); sl = add_to_strlist( list, p ); @@ -125,7 +125,7 @@ strlist_t append_to_strlist2( strlist_t *list, const char *string, int is_utf8 ) { strlist_t sl; - + if( is_utf8 ) sl = append_to_strlist( list, string ); else @@ -201,4 +201,3 @@ strlist_pop (strlist_t *list) return str; } - diff --git a/common/strlist.h b/common/strlist.h index 1e2ffa8da..3640da63d 100644 --- a/common/strlist.h +++ b/common/strlist.h @@ -20,7 +20,7 @@ #ifndef LIBJNLIB_STRLIST_H #define LIBJNLIB_STRLIST_H -struct string_list +struct string_list { struct string_list *next; unsigned int flags; diff --git a/common/sysutils.c b/common/sysutils.c index b75c5e1e5..a94d1fca5 100644 --- a/common/sysutils.c +++ b/common/sysutils.c @@ -46,7 +46,7 @@ # define WINVER 0x0500 /* Required for AllowSetForegroundWindow. */ # include <windows.h> #endif -#ifdef HAVE_PTH +#ifdef HAVE_PTH # include <pth.h> #endif #include <fcntl.h> @@ -140,7 +140,7 @@ get_session_marker (size_t *rlen) { static byte marker[SIZEOF_UNSIGNED_LONG*2]; static int initialized; - + if (!initialized) { gcry_create_nonce (marker, sizeof marker); @@ -253,7 +253,7 @@ gnupg_sleep (unsigned int seconds) the process will give up its timeslot. */ if (!seconds) { -# ifdef HAVE_W32_SYSTEM +# ifdef HAVE_W32_SYSTEM Sleep (0); # else sleep (0); @@ -262,7 +262,7 @@ gnupg_sleep (unsigned int seconds) pth_sleep (seconds); #else /* Fixme: make sure that a sleep won't wake up to early. */ -# ifdef HAVE_W32_SYSTEM +# ifdef HAVE_W32_SYSTEM Sleep (seconds*1000); # else sleep (seconds); @@ -287,7 +287,7 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write) if (fd == GNUPG_INVALID_FD) return -1; - + /* Note that _open_osfhandle is currently defined to take and return a long. */ x = _open_osfhandle ((long)fd, for_write ? 1 : 0); @@ -437,7 +437,7 @@ gnupg_tmpfile (void) Must be called before we open any files! */ void gnupg_reopen_std (const char *pgmname) -{ +{ #if defined(HAVE_STAT) && !defined(HAVE_W32_SYSTEM) struct stat statbuf; int did_stdin = 0; @@ -452,7 +452,7 @@ gnupg_reopen_std (const char *pgmname) else did_stdin = 2; } - + if (fstat (STDOUT_FILENO, &statbuf) == -1 && errno == EBADF) { if (open ("/dev/null",O_WRONLY) == STDOUT_FILENO) @@ -501,7 +501,7 @@ gnupg_reopen_std (const char *pgmname) /* Hack required for Windows. */ -void +void gnupg_allow_set_foregound_window (pid_t pid) { if (!pid) @@ -543,7 +543,7 @@ gnupg_remove (const char *fname) defined on all systems. The format of the modestring is "-rwxrwxrwx" - + '-' is a don't care or not set. 'r', 'w', 'x' are read allowed, write allowed, execution allowed with the first group for the user, the second for the group and the third for all others. If the @@ -555,7 +555,7 @@ gnupg_mkdir (const char *name, const char *modestr) #ifdef HAVE_W32CE_SYSTEM wchar_t *wname; (void)modestr; - + wname = utf8_to_wchar (name); if (!wname) return -1; @@ -615,7 +615,7 @@ gnupg_setenv (const char *name, const char *value, int overwrite) #endif } -int +int gnupg_unsetenv (const char *name) { #ifdef HAVE_W32CE_SYSTEM @@ -633,7 +633,7 @@ gnupg_unsetenv (const char *name) #ifdef HAVE_W32CE_SYSTEM /* There is a isatty function declaration in cegcc but it does not make sense, thus we redefine it. */ -int +int _gnupg_isatty (int fd) { (void)fd; @@ -651,10 +651,10 @@ _gnupg_getenv (const char *name) { static int initialized; static char *assuan_debug; - + if (!initialized) { - assuan_debug = read_w32_registry_string (NULL, + assuan_debug = read_w32_registry_string (NULL, "\\Software\\GNU\\libassuan", "debug"); initialized = 1; @@ -667,4 +667,3 @@ _gnupg_getenv (const char *name) } #endif /*HAVE_W32CE_SYSTEM*/ - diff --git a/common/t-b64.c b/common/t-b64.c index a230dc033..b5659cafd 100644 --- a/common/t-b64.c +++ b/common/t-b64.c @@ -17,7 +17,7 @@ * along with this program; if not, see <http://www.gnu.org/licenses/>. */ -/* +/* As of now this is only a test program for manual tests. @@ -179,4 +179,3 @@ main (int argc, char **argv) return !!errcount; } - diff --git a/common/t-convert.c b/common/t-convert.c index 4b04f3a32..d6056b9a6 100644 --- a/common/t-convert.c +++ b/common/t-convert.c @@ -72,8 +72,8 @@ test_hex2bin (void) unsigned char buffer[20]; int len; int i; - - + + for (i=0; valid[i]; i++) { len = hex2bin (valid[i], buffer, sizeof buffer); @@ -87,7 +87,7 @@ test_hex2bin (void) fail (0); if (hex2bin (valid[2], buffer, sizeof buffer) != 41) fail (0); - + for (i=0; invalid[i]; i++) { len = hex2bin (invalid[i], buffer, sizeof buffer); @@ -107,7 +107,7 @@ test_hex2bin (void) fail (0); if (hex2bin (valid2[1], buffer, 1) != 3) fail (0); - + for (i=0; invalid2[i]; i++) { len = hex2bin (invalid2[i], buffer, 1); @@ -164,8 +164,8 @@ test_hexcolon2bin (void) unsigned char buffer[20]; int len; int i; - - + + for (i=0; valid[i]; i++) { len = hexcolon2bin (valid[i], buffer, sizeof buffer); @@ -179,7 +179,7 @@ test_hexcolon2bin (void) fail (0); if (hexcolon2bin (valid[3], buffer, sizeof buffer) != 41) fail (0); - + for (i=0; invalid[i]; i++) { len = hexcolon2bin (invalid[i], buffer, sizeof buffer); @@ -199,7 +199,7 @@ test_hexcolon2bin (void) fail (0); if (hexcolon2bin (valid2[1], buffer, 1) != 3) fail (0); - + for (i=0; invalid2[i]; i++) { len = hexcolon2bin (invalid2[i], buffer, 1); @@ -234,10 +234,10 @@ test_bin2hex (void) fail (0); if (strcmp (p, hexstuff)) fail (0); - + p = bin2hex (stuff, (size_t)(-1), NULL); if (p) - fail (0); + fail (0); if (errno != ENOMEM) fail (1); } @@ -263,13 +263,13 @@ test_bin2hexcolon (void) p = bin2hexcolon (stuff, 20, NULL); if (!p) - fail (0); + fail (0); if (strcmp (p, hexstuff)) fail (0); - + p = bin2hexcolon (stuff, (size_t)(-1), NULL); if (p) - fail (0); + fail (0); if (errno != ENOMEM) fail (1); } @@ -384,10 +384,10 @@ test_hex2str (void) for (idx=0; tests[idx].hex; idx++) { char tmpbuf[100]; - + assert (strlen (tests[idx].hex)+1 < sizeof tmpbuf); strcpy (tmpbuf, tests[idx].hex); - + /* Note: we still need to use 20 as buffer length because our tests assume that. */ tail = hex2str (tmpbuf, tmpbuf, 20, &count); @@ -449,7 +449,7 @@ main (int argc, char **argv) { (void)argc; (void)argv; - + test_hex2bin (); test_hexcolon2bin (); test_bin2hex (); @@ -458,4 +458,3 @@ main (int argc, char **argv) return 0; } - diff --git a/common/t-exechelp.c b/common/t-exechelp.c index 5c5c5d311..e4c88d126 100644 --- a/common/t-exechelp.c +++ b/common/t-exechelp.c @@ -150,7 +150,7 @@ test_close_all_fds (void) print_open_fds (array); free (array); } - + /* Check whether the except list works. */ close_all_fds (3, except); array = xget_all_open_fds (); @@ -181,9 +181,8 @@ main (int argc, char **argv) verbose = 1; argc--; argv++; } - + test_close_all_fds (); return 0; } - diff --git a/common/t-gettime.c b/common/t-gettime.c index a4401d8ae..1cfde69c7 100644 --- a/common/t-gettime.c +++ b/common/t-gettime.c @@ -68,7 +68,7 @@ test_isotime2epoch (void) fail (idx); if (verbose) fprintf (stderr, "string `%s' exp: %ld got: %ld\n", - array[idx].string, (long)array[idx].expected, + array[idx].string, (long)array[idx].expected, (long)val); } if (array[idx].expected != INVALID) @@ -100,4 +100,3 @@ main (int argc, char **argv) return !!errcount; } - diff --git a/common/t-helpfile.c b/common/t-helpfile.c index fa5d27a1c..960252bbd 100644 --- a/common/t-helpfile.c +++ b/common/t-helpfile.c @@ -52,7 +52,7 @@ main (int argc, char **argv) result = gnupg_get_help_string (argc? argv[0]:NULL, 0); if (!result) { - fprintf (stderr, + fprintf (stderr, "Error: nothing found for `%s'\n", argc?argv[0]:"(null)"); errcount++; } @@ -64,4 +64,3 @@ main (int argc, char **argv) return !!errcount; } - diff --git a/common/t-percent.c b/common/t-percent.c index b8641b90b..c148c228f 100644 --- a/common/t-percent.c +++ b/common/t-percent.c @@ -37,31 +37,31 @@ test_percent_plus_escape (void) const char *string; const char *expect; } tbl[] = { - { + { "", - "" - }, { + "" + }, { "a", "a", - }, { + }, { " ", "+", - }, { + }, { " ", "++" - }, { + }, { "+ +", "%2B+%2B" - }, { + }, { "\" \"", "%22+%22" - }, { + }, { "%22", "%2522" - }, { + }, { "%% ", "%25%25+" - }, { + }, { "\n ABC\t", "%0A+ABC%09" }, { NULL, NULL } @@ -69,7 +69,7 @@ test_percent_plus_escape (void) char *buf, *buf2; int i; size_t len; - + for (i=0; tbl[i].string; i++) { buf = percent_plus_escape (tbl[i].string); @@ -105,11 +105,10 @@ main (int argc, char **argv) { (void)argc; (void)argv; - + /* FIXME: We escape_unescape is not tested - only percent_plus_unescape. */ test_percent_plus_escape (); return 0; } - diff --git a/common/t-session-env.c b/common/t-session-env.c index 94b668328..46c655229 100644 --- a/common/t-session-env.c +++ b/common/t-session-env.c @@ -46,7 +46,7 @@ listall (session_env_t se) while ( (name = session_env_listenv (se, &iterator, &value, &def)) ) if (verbose) printf (" %s%s=%s\n", def? "[def] ":" ", name, value); - + } @@ -150,7 +150,7 @@ test_all (void) fprintf (stderr, "failed to get default of HOME\n"); exit (1); } - + s = session_env_getenv (se, "HOME"); if (s) fail(0); /* This is a default value, thus we should not see it. */ @@ -194,7 +194,7 @@ test_all (void) /* Check that the other object is clean. */ { int iterator = 0; - + if (session_env_listenv (se_0, &iterator, NULL, NULL)) fail (0); } @@ -211,7 +211,7 @@ test_all (void) for (idx=0; idx < 500; idx++) { char buf[100]; - + snprintf (buf, sizeof buf, "FOO_%d=Value for %x", idx, idx); err = session_env_putenv (se, buf); if (err) @@ -230,7 +230,7 @@ test_all (void) for (idx=0; idx < 500; idx++) { char buf[100]; - + snprintf (buf, sizeof buf, "FOO_%d", idx); err = session_env_putenv (se, buf); if (err) @@ -243,7 +243,7 @@ test_all (void) /* Check that all are deleted. */ { int iterator = 0; - + if (session_env_listenv (se, &iterator, NULL, NULL)) fail (0); } @@ -252,7 +252,7 @@ test_all (void) for (idx=0; idx < 500; idx++) { char buf[100]; - + if (!(idx % 10)) { if ( !(idx % 3)) @@ -266,7 +266,7 @@ test_all (void) } listall (se); - + session_env_release (se); session_env_release (se_0); @@ -291,4 +291,3 @@ main (int argc, char **argv) return 0; } - diff --git a/common/t-sexputil.c b/common/t-sexputil.c index 05da162bf..987b06255 100644 --- a/common/t-sexputil.c +++ b/common/t-sexputil.c @@ -35,7 +35,7 @@ test_hash_algo_from_sigval (void) { int algo; /* A real world example. */ - unsigned char example1_rsa_sha1[] = + unsigned char example1_rsa_sha1[] = ("\x28\x37\x3A\x73\x69\x67\x2D\x76\x61\x6C\x28\x33\x3A\x72\x73\x61" "\x28\x31\x3A\x73\x31\x32\x38\x3A\x17\xD2\xE9\x5F\xB4\x24\xD4\x1E" "\x8C\xEE\x94\xDA\x41\x42\x1F\x26\x5E\xF4\x6D\xEC\x5B\xBD\x5B\x89" @@ -48,7 +48,7 @@ test_hash_algo_from_sigval (void) "\x27\xAC\x43\x45\xFA\x04\xD1\x22\x29\x29\x28\x34\x3A\x68\x61\x73" "\x68\x34\x3A\x73\x68\x61\x31\x29\x29"); /* The same but without the hash algo. */ - unsigned char example1_rsa[] = + unsigned char example1_rsa[] = ("\x28\x37\x3A\x73\x69\x67\x2D\x76\x61\x6C\x28\x33\x3A\x72\x73\x61" "\x28\x31\x3A\x73\x31\x32\x38\x3A\x17\xD2\xE9\x5F\xB4\x24\xD4\x1E" "\x8C\xEE\x94\xDA\x41\x42\x1F\x26\x5E\xF4\x6D\xEC\x5B\xBD\x5B\x89" @@ -105,7 +105,7 @@ test_make_canon_sexp_from_rsa_pk (void) "\x3d\x14\xbb\xea\x63\x65\xa7\xf1\xf2\xf8\x97\x74\xa7\x29\x28\x31" "\x3a\x65\x34\x3a\x40\x00\x00\x81\x29\x29\x29", 171 - }, + }, { "\x63\xB4\x12\x48\x08\x48\xC0\x76\xAA\x8E\xF1\xF8\x7F\x5E\x9B\x89", 16, @@ -116,7 +116,7 @@ test_make_canon_sexp_from_rsa_pk (void) "\x48\xc0\x76\xaa\x8e\xf1\xf8\x7f\x5e\x9b\x89\x29\x28\x31\x3a\x65" "\x31\x3a\x03\x29\x29\x29", 54, - }, + }, { "", 0, @@ -149,7 +149,7 @@ test_make_canon_sexp_from_rsa_pk (void) fprintf (stderr, "%s:%d: out of core\n", __FILE__, __LINE__); exit (1); } - + if (length != tests[idx].resultlen) fail (idx); if (memcmp (sexp, tests[idx].result, tests[idx].resultlen)) @@ -189,4 +189,3 @@ main (int argc, char **argv) return 0; } - diff --git a/common/t-stringhelp.c b/common/t-stringhelp.c index 0c921b03d..d7b25e9b0 100644 --- a/common/t-stringhelp.c +++ b/common/t-stringhelp.c @@ -42,14 +42,14 @@ gethome (void) if (!home_buffer) { char *home = getenv("HOME"); - + if(home) home_buffer = xstrdup (home); #if defined(HAVE_GETPWUID) && defined(HAVE_PWD_H) else { struct passwd *pwd; - + pwd = getpwuid (getuid()); if (pwd) home_buffer = xstrdup (pwd->pw_dir); @@ -65,10 +65,10 @@ test_percent_escape (void) { char *result; static struct { - const char *extra; - const char *value; + const char *extra; + const char *value; const char *expected; - } tests[] = + } tests[] = { { NULL, "", "" }, { NULL, "%", "%25" }, @@ -183,7 +183,7 @@ test_strconcat (void) fail (0); else if (errno != EINVAL) fail (0); - + #if __GNUC__ < 4 /* gcc 4.0 has a sentinel attribute. */ out = strconcat (NULL); if (!out || *out) @@ -322,10 +322,10 @@ test_make_filename_try (void) "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", NULL); - if (!out || strcmp (out, - "1/2/3/4/5/6/7/8/9/10/" - "1/2/3/4/5/6/7/8/9/10/" - "1/2/3/4/5/6/7/8/9/10/" + if (!out || strcmp (out, + "1/2/3/4/5/6/7/8/9/10/" + "1/2/3/4/5/6/7/8/9/10/" + "1/2/3/4/5/6/7/8/9/10/" "1/2")) fail (0); xfree (out); @@ -411,4 +411,3 @@ main (int argc, char **argv) xfree (home_buffer); return 0; } - diff --git a/common/t-support.c b/common/t-support.c index bf05c4c06..755e15611 100644 --- a/common/t-support.c +++ b/common/t-support.c @@ -142,6 +142,3 @@ gpg_err_code_from_syserror (void) return -1; } #endif /*GPG_ERROR_H*/ - - - diff --git a/common/t-sysutils.c b/common/t-sysutils.c index 9b19d88ce..d13bdfe41 100644 --- a/common/t-sysutils.c +++ b/common/t-sysutils.c @@ -86,4 +86,3 @@ main (int argc, char **argv) return !!errcount; } - diff --git a/common/t-timestuff.c b/common/t-timestuff.c index 46816765d..c9c8fe5b8 100644 --- a/common/t-timestuff.c +++ b/common/t-timestuff.c @@ -36,8 +36,8 @@ cmp_time_s (struct tm *a, struct tm *b) || a->tm_mon != b->tm_mon || a->tm_mday != b->tm_mday || a->tm_hour != b->tm_hour - || a->tm_min != b->tm_min - || a->tm_sec != b->tm_sec + || a->tm_min != b->tm_min + || a->tm_sec != b->tm_sec || a->tm_wday != b->tm_wday || a->tm_yday != b->tm_yday || !a->tm_isdst != !b->tm_isdst) @@ -51,7 +51,7 @@ static void test_timegm (void) { static struct { - int year, mon, mday, hour, min, sec; + int year, mon, mday, hour, min, sec; } tvalues[] = { { -1 }, { -2, 1 }, @@ -103,12 +103,12 @@ test_timegm (void) tbuf.tm_mday = tvalues[tidx].mday; tbuf.tm_hour = tvalues[tidx].hour; tbuf.tm_min = tvalues[tidx].min; - tbuf.tm_sec = tvalues[tidx].sec; + tbuf.tm_sec = tvalues[tidx].sec; now = mktime (&tbuf); } if (now == (time_t)(-1)) fail (tidx); - + tp = gmtime (&now); if (!tp) fail (tidx); @@ -119,7 +119,7 @@ test_timegm (void) fail (tidx); if (atime != now) fail (tidx); - + tp = gmtime (&atime); if (!tp) fail (tidx); @@ -142,4 +142,3 @@ main (int argc, char **argv) return 0; } - diff --git a/common/t-w32-reg.c b/common/t-w32-reg.c index f4848cbaa..9a6a61d39 100644 --- a/common/t-w32-reg.c +++ b/common/t-w32-reg.c @@ -67,4 +67,3 @@ main (int argc, char **argv) return 0; } - diff --git a/common/tlv.c b/common/tlv.c index 3453b29f6..54ef6fca6 100644 --- a/common/tlv.c +++ b/common/tlv.c @@ -45,7 +45,7 @@ do_find_tlv (const unsigned char *buffer, size_t length, size_t len; int this_tag; int composite; - + for (;;) { buffer = s; @@ -97,7 +97,7 @@ do_find_tlv (const unsigned char *buffer, size_t length, nesting. */ const unsigned char *tmp_s; size_t tmp_len; - + tmp_s = do_find_tlv (s, len, tag, &tmp_len, nestlevel+1); if (tmp_s) { @@ -152,7 +152,7 @@ find_tlv_unchecked (const unsigned char *buffer, size_t length, on success. */ gpg_error_t _parse_ber_header (unsigned char const **buffer, size_t *size, - int *r_class, int *r_tag, + int *r_class, int *r_tag, int *r_constructed, int *r_ndef, size_t *r_length, size_t *r_nhdr, gpg_err_source_t errsource) @@ -220,11 +220,11 @@ _parse_ber_header (unsigned char const **buffer, size_t *size, } *r_length = len; } - + /* Without this kludge some example certs can't be parsed. */ if (*r_class == CLASS_UNIVERSAL && !*r_tag) *r_length = 0; - + *buffer = buf; *size = length; return 0; @@ -251,7 +251,7 @@ _parse_ber_header (unsigned char const **buffer, size_t *size, while (!(err = parse_sexp (&buf, &buflen, &depth, &tok, &toklen)) && depth) process_token (tok, toklen); - if (err) + if (err) handle_error (); */ gpg_error_t @@ -302,4 +302,3 @@ _parse_sexp (unsigned char const **buf, size_t *buflen, *buflen = n; return 0; } - diff --git a/common/tlv.h b/common/tlv.h index a04af93ad..c7fafd547 100644 --- a/common/tlv.h +++ b/common/tlv.h @@ -81,7 +81,7 @@ const unsigned char *find_tlv_unchecked (const unsigned char *buffer, and the length part from the TLV triplet. Update BUFFER and SIZE on success. */ gpg_error_t _parse_ber_header (unsigned char const **buffer, size_t *size, - int *r_class, int *r_tag, + int *r_class, int *r_tag, int *r_constructed, int *r_ndef, size_t *r_length, size_t *r_nhdr, gpg_err_source_t errsource); diff --git a/common/ttyio.c b/common/ttyio.c index 92671f112..fb0fd5e56 100644 --- a/common/ttyio.c +++ b/common/ttyio.c @@ -186,7 +186,7 @@ init_ttyfp(void) if (my_rl_init_stream) my_rl_init_stream (ttyfp); #endif - + #ifdef HAVE_TCGETATTR atexit( cleanup ); @@ -225,7 +225,7 @@ tty_printf( const char *fmt, ... ) va_start( arg_ptr, fmt ) ; #ifdef USE_W32_CONSOLE - { + { char *buf = NULL; int n; DWORD nwritten; @@ -233,7 +233,7 @@ tty_printf( const char *fmt, ... ) n = vasprintf(&buf, fmt, arg_ptr); if( !buf ) log_bug("vasprintf() failed\n"); - + if( !WriteConsoleA( con.out, buf, n, &nwritten, NULL ) ) log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() ); if( n != nwritten ) @@ -272,15 +272,15 @@ tty_fprintf (estream_t fp, const char *fmt, ... ) va_start (arg_ptr, fmt); #ifdef USE_W32_CONSOLE - { + { char *buf = NULL; int n; DWORD nwritten; - + n = vasprintf(&buf, fmt, arg_ptr); if (!buf) log_bug("vasprintf() failed\n"); - + if (!WriteConsoleA( con.out, buf, n, &nwritten, NULL )) log_fatal("WriteConsole failed: rc=%d", (int)GetLastError() ); if (n != nwritten) @@ -545,7 +545,7 @@ tty_get( const char *prompt ) { char *line; char *buf; - + if (!initialized) init_ttyfp(); diff --git a/common/types.h b/common/types.h index 62fa0470d..fcba737c2 100644 --- a/common/types.h +++ b/common/types.h @@ -103,10 +103,10 @@ /* Some GCC attributes. Note that we use also define some in mischelp.h, but this header and types.h are not always included. Should eventually be put into one file (e.g. nlib-common.h). */ -#if __GNUC__ >= 4 +#if __GNUC__ >= 4 # define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a))) #else -# define GNUPG_GCC_A_SENTINEL(a) +# define GNUPG_GCC_A_SENTINEL(a) #endif diff --git a/common/userids.c b/common/userids.c index 9a072dd80..9cc29f3b4 100644 --- a/common/userids.c +++ b/common/userids.c @@ -43,8 +43,8 @@ * must be in the range 0..9), this is considered a fingerprint. * - If the username starts with a left angle, we assume it is a complete * email address and look only at this part. - * - If the username starts with a colon we assume it is a unified - * key specfification. + * - If the username starts with a colon we assume it is a unified + * key specfification. * - If the username starts with a '.', we assume it is the ending * part of an email address * - If the username starts with an '@', we assume it is a part of an @@ -66,12 +66,12 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) const char *s; int hexprefix = 0; int hexlength; - int mode = 0; + int mode = 0; KEYDB_SEARCH_DESC dummy_desc; if (!desc) desc = &dummy_desc; - + /* Clear the structure so that the mode field is set to zero unless we set it to the correct value right at the end of this function. */ @@ -81,7 +81,7 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) for(s = name; *s && spacep (s); s++ ) ; - switch (*s) + switch (*s) { case 0: /* Empty string is an error. */ return gpg_error (GPG_ERR_INV_USER_ID); @@ -133,19 +133,19 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) break; case '#': /* S/N with optional issuer id or just issuer id. */ - { + { const char *si; - + s++; if ( *s == '/') { /* "#/" indicates an issuer's DN. */ s++; if (!*s || spacep (s)) /* No DN or prefixed with a space. */ - return gpg_error (GPG_ERR_INV_USER_ID); + return gpg_error (GPG_ERR_INV_USER_ID); desc->u.name = s; mode = KEYDB_SEARCH_MODE_ISSUER; } - else + else { /* Serialnumber + optional issuer ID. */ for (si=s; *si && *si != '/'; si++) { @@ -170,10 +170,10 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) break; case ':': /* Unified fingerprint. */ - { + { const char *se, *si; int i; - + se = strchr (++s,':'); if (!se) return gpg_error (GPG_ERR_INV_USER_ID); @@ -184,21 +184,21 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) } if (i != 32 && i != 40) return gpg_error (GPG_ERR_INV_USER_ID); /* Invalid length of fpr. */ - for (i=0,si=s; si < se; i++, si +=2) + for (i=0,si=s; si < se; i++, si +=2) desc->u.fpr[i] = hextobyte(si); for (; i < 20; i++) desc->u.fpr[i]= 0; s = se + 1; mode = KEYDB_SEARCH_MODE_FPR; - } + } break; case '&': /* Keygrip*/ - { + { if (hex2bin (s+1, desc->u.grip, 20) < 0) return gpg_error (GPG_ERR_INV_USER_ID); /* Invalid. */ mode = KEYDB_SEARCH_MODE_KEYGRIP; - } + } break; default: @@ -214,33 +214,33 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) desc->exact = 1; hexlength++; /* Just for the following check. */ } - + /* Check if a hexadecimal number is terminated by EOS or blank. */ - if (hexlength && s[hexlength] && !spacep (s+hexlength)) + if (hexlength && s[hexlength] && !spacep (s+hexlength)) { if (hexprefix) /* A "0x" prefix without a correct termination is an error. */ - return gpg_error (GPG_ERR_INV_USER_ID); + return gpg_error (GPG_ERR_INV_USER_ID); /* The first characters looked like a hex number, but the entire string is not. */ - hexlength = 0; + hexlength = 0; } - + if (desc->exact) hexlength--; /* Remove the bang. */ if (hexlength == 8 || (!hexprefix && hexlength == 9 && *s == '0')) - { + { /* Short keyid. */ if (hexlength == 9) - s++; + s++; desc->u.kid[1] = strtoul( s, NULL, 16 ); mode = KEYDB_SEARCH_MODE_SHORT_KID; } else if (hexlength == 16 || (!hexprefix && hexlength == 17 && *s == '0')) - { + { /* Long keyid. */ char buf[9]; if (hexlength == 17) @@ -252,13 +252,13 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) } else if (hexlength == 32 || (!hexprefix && hexlength == 33 && *s == '0')) - { + { /* MD5 fingerprint. */ int i; if (hexlength == 33) s++; - memset (desc->u.fpr+16, 0, 4); - for (i=0; i < 16; i++, s+=2) + memset (desc->u.fpr+16, 0, 4); + for (i=0; i < 16; i++, s+=2) { int c = hextobyte(s); if (c == -1) @@ -269,12 +269,12 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) } else if (hexlength == 40 || (!hexprefix && hexlength == 41 && *s == '0')) - { + { /* SHA1/RMD160 fingerprint. */ int i; if (hexlength == 41) s++; - for (i=0; i < 20; i++, s+=2) + for (i=0; i < 20; i++, s+=2) { int c = hextobyte(s); if (c == -1) @@ -284,16 +284,16 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) mode = KEYDB_SEARCH_MODE_FPR20; } else if (!hexprefix) - { + { /* The fingerprint in an X.509 listing is often delimited by colons, so we try to single this case out. */ mode = 0; hexlength = strspn (s, ":0123456789abcdefABCDEF"); - if (hexlength == 59 && (!s[hexlength] || spacep (s+hexlength))) + if (hexlength == 59 && (!s[hexlength] || spacep (s+hexlength))) { int i; - for (i=0; i < 20; i++, s += 3) + for (i=0; i < 20; i++, s += 3) { int c = hextobyte(s); if (c == -1 || (i < 19 && s[2] != ':')) @@ -304,19 +304,19 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc) mode = KEYDB_SEARCH_MODE_FPR20; } if (!mode) /* Default to substring search. */ - { + { desc->exact = 0; desc->u.name = s; - mode = KEYDB_SEARCH_MODE_SUBSTR; + mode = KEYDB_SEARCH_MODE_SUBSTR; } } else - { + { /* Hex number with a prefix but with a wrong length. */ return gpg_error (GPG_ERR_INV_USER_ID); } } - + desc->mode = mode; return 0; } diff --git a/common/utf8conv.c b/common/utf8conv.c index 16baa0d4d..a5765f6a6 100644 --- a/common/utf8conv.c +++ b/common/utf8conv.c @@ -59,7 +59,7 @@ static size_t (* __stdcall iconv) (iconv_t cd, char **outbuf, size_t *outbytesleft); static int (* __stdcall iconv_close) (iconv_t cd); -static int +static int load_libiconv (void) { #ifdef HAVE_W32CE_SYSTEM @@ -67,21 +67,21 @@ load_libiconv (void) is at all required. */ #else static int done; - + if (!done) { void *handle; done = 1; /* Do it right now because we might get called recursivly through gettext. */ - + handle = dlopen ("iconv.dll", RTLD_LAZY); if (handle) { iconv_open = dlsym (handle, "libiconv_open"); if (iconv_open) iconv = dlsym (handle, "libiconv"); - if (iconv) + if (iconv) iconv_close = dlsym (handle, "libiconv_close"); } if (!handle || !iconv_close) @@ -99,7 +99,7 @@ load_libiconv (void) } return iconv_open? 0: -1; #endif -} +} #endif /*HAVE_W32_SYSTEM*/ @@ -157,13 +157,13 @@ set_native_charset (const char *newset) { const char *full_newset; - if (!newset) + if (!newset) { #ifdef HAVE_W32_SYSTEM static char codepage[30]; unsigned int cpno; const char *aliases; - + /* We are a console program thus we need to use the GetConsoleOutputCP function and not the the GetACP which would give the codepage for a GUI program. Note this is not @@ -208,7 +208,7 @@ set_native_charset (const char *newset) } #else /*!HAVE_W32_SYSTEM*/ - + #ifdef HAVE_LANGINFO_CODESET newset = nl_langinfo (CODESET); #else /*!HAVE_LANGINFO_CODESET*/ @@ -232,7 +232,7 @@ set_native_charset (const char *newset) mod = strchr (++dot, '@'); if (!mod) mod = dot + strlen (dot); - if (mod - dot < sizeof codepage && dot != mod) + if (mod - dot < sizeof codepage && dot != mod) { memcpy (codepage, dot, mod - dot); codepage [mod - dot] = 0; @@ -279,21 +279,21 @@ set_native_charset (const char *newset) else { iconv_t cd; - + #ifdef HAVE_W32_SYSTEM if (load_libiconv ()) return -1; -#endif /*HAVE_W32_SYSTEM*/ +#endif /*HAVE_W32_SYSTEM*/ cd = iconv_open (full_newset, "utf-8"); - if (cd == (iconv_t)-1) + if (cd == (iconv_t)-1) { handle_iconv_error (full_newset, "utf-8", 0); return -1; } iconv_close (cd); cd = iconv_open ("utf-8", full_newset); - if (cd == (iconv_t)-1) + if (cd == (iconv_t)-1) { handle_iconv_error ("utf-8", full_newset, 0); return -1; @@ -313,7 +313,7 @@ get_native_charset () } /* Return true if the native charset is utf-8. */ -int +int is_native_utf8 (void) { return no_translation; @@ -360,13 +360,13 @@ native_to_utf8 (const char *orig_string) *p = 0; } else - { + { /* Need to use iconv. */ iconv_t cd; const char *inptr; char *outptr; size_t inbytes, outbytes; - + cd = iconv_open ("utf-8", active_charset_name); if (cd == (iconv_t)-1) { @@ -374,14 +374,14 @@ native_to_utf8 (const char *orig_string) return native_to_utf8 (string); } - for (s=string; *s; s++ ) + for (s=string; *s; s++ ) { length++; if ((*s & 0x80)) length += 5; /* We may need up to 6 bytes for the utf8 output. */ } buffer = jnlib_xmalloc (length + 1); - + inptr = string; inbytes = strlen (string); outptr = buffer; @@ -455,10 +455,10 @@ do_utf8_to_native (const char *string, size_t length, int delim, if (!nleft) { if (!(*s & 0x80)) - { + { /* Plain ascii. */ if ( delim != -1 - && (*s < 0x20 || *s == 0x7f || *s == delim + && (*s < 0x20 || *s == 0x7f || *s == delim || (delim && *s == '\\'))) { n++; @@ -497,35 +497,35 @@ do_utf8_to_native (const char *string, size_t length, int delim, encbuf[encidx++] = *s; } else if ((*s & 0xf0) == 0xe0) /* 1110 xxxx */ - { + { val = *s & 0x0f; nleft = 2; encidx = 0; encbuf[encidx++] = *s; } else if ((*s & 0xf8) == 0xf0) /* 1111 0xxx */ - { + { val = *s & 0x07; nleft = 3; encidx = 0; encbuf[encidx++] = *s; } else if ((*s & 0xfc) == 0xf8) /* 1111 10xx */ - { + { val = *s & 0x03; nleft = 4; encidx = 0; encbuf[encidx++] = *s; } else if ((*s & 0xfe) == 0xfc) /* 1111 110x */ - { + { val = *s & 0x01; nleft = 5; encidx = 0; encbuf[encidx++] = *s; } else /* Invalid encoding: print as \xNN. */ - { + { if (p) { sprintf (p, "\\x%02x", *s); @@ -558,7 +558,7 @@ do_utf8_to_native (const char *string, size_t length, int delim, val <<= 6; val |= *s & 0x3f; if (!--nleft) /* Ready. */ - { + { if (no_translation) { if (p) @@ -597,12 +597,12 @@ do_utf8_to_native (const char *string, size_t length, int delim, if (val >= 0x80 && val < 256) { /* We can simply print this character */ - n++; + n++; if (p) *p++ = val; } else - { + { /* We do not have a translation: print utf8. */ if (p) { @@ -632,7 +632,7 @@ do_utf8_to_native (const char *string, size_t length, int delim, const char *inptr; char *outbuf, *outptr; size_t inbytes, outbytes; - + *p = 0; /* Terminate the buffer. */ cd = iconv_open (active_charset_name, "utf-8"); @@ -649,14 +649,14 @@ do_utf8_to_native (const char *string, size_t length, int delim, inbytes = n - 1;; inptr = buffer; outbytes = n * MB_LEN_MAX; - if (outbytes / MB_LEN_MAX != n) + if (outbytes / MB_LEN_MAX != n) BUG (); /* Actually an overflow. */ outbuf = outptr = jnlib_xmalloc (outbytes); if ( iconv (cd, (ICONV_CONST char **)&inptr, &inbytes, - &outptr, &outbytes) == (size_t)-1) + &outptr, &outbytes) == (size_t)-1) { static int shown; - + if (!shown) log_info (_("conversion from `%s' to `%s' failed: %s\n"), "utf-8", active_charset_name, strerror (errno)); @@ -668,7 +668,7 @@ do_utf8_to_native (const char *string, size_t length, int delim, outbuf = do_utf8_to_native (string, length, delim, 0); } else /* Success. */ - { + { *outptr = 0; /* Make sure it is a string. */ /* We could realloc the buffer now but I doubt that it makes much sense given that it will get freed @@ -703,13 +703,13 @@ utf8_to_native (const char *string, size_t length, int delim) /* Wrapper function for iconv_open, required for W32 as we dlopen that library on that system. */ -jnlib_iconv_t +jnlib_iconv_t jnlib_iconv_open (const char *tocode, const char *fromcode) { #ifdef HAVE_W32_SYSTEM if (load_libiconv ()) return (jnlib_iconv_t)(-1); -#endif /*HAVE_W32_SYSTEM*/ +#endif /*HAVE_W32_SYSTEM*/ return (jnlib_iconv_t)iconv_open (tocode, fromcode); } @@ -726,7 +726,7 @@ jnlib_iconv (jnlib_iconv_t cd, #ifdef HAVE_W32_SYSTEM if (load_libiconv ()) return 0; -#endif /*HAVE_W32_SYSTEM*/ +#endif /*HAVE_W32_SYSTEM*/ return iconv ((iconv_t)cd, (char**)inbuf, inbytesleft, outbuf, outbytesleft); } @@ -739,7 +739,7 @@ jnlib_iconv_close (jnlib_iconv_t cd) #ifdef HAVE_W32_SYSTEM if (load_libiconv ()) return 0; -#endif /*HAVE_W32_SYSTEM*/ +#endif /*HAVE_W32_SYSTEM*/ return iconv_close ((iconv_t)cd); } @@ -797,7 +797,7 @@ utf8_to_wchar (const char *string) } nbytes = (size_t)(n+1) * sizeof(*result); - if (nbytes / sizeof(*result) != (n+1)) + if (nbytes / sizeof(*result) != (n+1)) { jnlib_set_errno (ENOMEM); return NULL; diff --git a/common/w32-afunix.c b/common/w32-afunix.c index 920561b92..690e95176 100644 --- a/common/w32-afunix.c +++ b/common/w32-afunix.c @@ -105,20 +105,20 @@ _w32_sock_connect (int sockfd, struct sockaddr *addr, int addrlen) int ret; (void)addrlen; - + unaddr = (struct sockaddr_un *)addr; if (read_port_and_nonce (unaddr->sun_path, &port, nonce)) return -1; - + myaddr.sin_family = AF_INET; - myaddr.sin_port = htons (port); + myaddr.sin_port = htons (port); myaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - + /* Set return values. */ unaddr->sun_family = myaddr.sin_family; unaddr->sun_port = myaddr.sin_port; unaddr->sun_addr.s_addr = myaddr.sin_addr.s_addr; - + ret = connect (sockfd, (struct sockaddr *)&myaddr, sizeof myaddr); if (!ret) { diff --git a/common/w32-reg.c b/common/w32-reg.c index 5809c32bb..5dc2be584 100644 --- a/common/w32-reg.c +++ b/common/w32-reg.c @@ -36,7 +36,7 @@ static HKEY get_root_key(const char *root) { HKEY root_key; - + if (!root) root_key = HKEY_CURRENT_USER; else if (!strcmp( root, "HKEY_CLASSES_ROOT" ) ) @@ -53,7 +53,7 @@ get_root_key(const char *root) root_key = HKEY_CURRENT_CONFIG; else return NULL; - + return root_key; } @@ -69,10 +69,10 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) DWORD n1, nbytes, type; char *result = NULL; wchar_t *wdir, *wname; - + if ( !(root_key = get_root_key(root) ) ) return NULL; - + wdir = utf8_to_wchar (dir); if (!wdir) return NULL; @@ -115,7 +115,7 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) goto leave; } result[nbytes] = 0; /* Make sure it is a string. */ - result[nbytes+1] = 0; + result[nbytes+1] = 0; if (type == REG_SZ || type == REG_EXPAND_SZ) { wchar_t *tmp = (void*)result; @@ -131,10 +131,10 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) HKEY root_key, key_handle; DWORD n1, nbytes, type; char *result = NULL; - + if ( !(root_key = get_root_key(root) ) ) return NULL; - + if (RegOpenKeyEx (root_key, dir, 0, KEY_READ, &key_handle) ) { if (root) @@ -160,7 +160,7 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) if (type == REG_EXPAND_SZ && strchr (result, '%')) { char *tmp; - + n1 += 1000; tmp = jnlib_malloc (n1+1); if (!tmp) @@ -177,7 +177,7 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) if (nbytes && nbytes > n1) { /* Oops - truncated, better don't expand at all. */ - jnlib_free (tmp); + jnlib_free (tmp); goto leave; } tmp[nbytes] = 0; @@ -192,14 +192,14 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) result = jnlib_malloc (strlen (tmp)+1); if (!result) result = tmp; - else + else { strcpy (result, tmp); jnlib_free (tmp); } } - else - { + else + { /* Error - don't expand. */ jnlib_free (tmp); } @@ -215,7 +215,7 @@ read_w32_registry_string (const char *root, const char *dir, const char *name) /* Note: This code is not well tested. However, it is not used in GnuPG. */ int -write_w32_registry_string (const char *root, const char *dir, +write_w32_registry_string (const char *root, const char *dir, const char *name, const char *value) { HKEY root_key, reg_key; @@ -236,7 +236,7 @@ write_w32_registry_string (const char *root, const char *dir, return -1; } jnlib_free (wdir); - + if (name) { wname = utf8_to_wchar (name); @@ -253,12 +253,12 @@ write_w32_registry_string (const char *root, const char *dir, return -1; } - if (RegSetValueEx (reg_key, wname, 0, REG_SZ, + if (RegSetValueEx (reg_key, wname, 0, REG_SZ, (BYTE *)wvalue, wcslen (wvalue)) != ERROR_SUCCESS ) { if (RegCreateKeyEx (root_key, wname, 0, NULL, 0, 0, NULL, - ®_key, &disp) != ERROR_SUCCESS) + ®_key, &disp) != ERROR_SUCCESS) { RegCloseKey(reg_key); jnlib_free (wname); @@ -274,7 +274,7 @@ write_w32_registry_string (const char *root, const char *dir, return -1; } } - + jnlib_free (wname); jnlib_free (wvalue); RegCloseKey (reg_key); @@ -283,15 +283,15 @@ write_w32_registry_string (const char *root, const char *dir, if ( !(root_key = get_root_key(root) ) ) return -1; - - if ( RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, ®_key ) + + if ( RegOpenKeyEx( root_key, dir, 0, KEY_WRITE, ®_key ) != ERROR_SUCCESS ) return -1; - - if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value, + + if ( RegSetValueEx (reg_key, name, 0, REG_SZ, (BYTE *)value, strlen( value ) ) != ERROR_SUCCESS ) { - if ( RegCreateKey( root_key, name, ®_key ) != ERROR_SUCCESS ) + if ( RegCreateKey( root_key, name, ®_key ) != ERROR_SUCCESS ) { RegCloseKey(reg_key); return -1; @@ -303,7 +303,7 @@ write_w32_registry_string (const char *root, const char *dir, return -1; } } - + RegCloseKey (reg_key); return 0; #endif /*!HAVE_W32CE_SYSTEM*/ diff --git a/common/xmalloc.c b/common/xmalloc.c index eb6d5ab11..c0d5d1d6d 100644 --- a/common/xmalloc.c +++ b/common/xmalloc.c @@ -84,4 +84,3 @@ xstrcat2( const char *a, const char *b ) strcpy(p+n1, b ); return p; } - diff --git a/common/xreadline.c b/common/xreadline.c index 4ea10d75b..5a9a5270f 100644 --- a/common/xreadline.c +++ b/common/xreadline.c @@ -30,7 +30,7 @@ considered a byte stream ending in a LF. If MAX_LENGTH is not NULL, it shall point to a value with the - maximum allowed allocation. + maximum allowed allocation. Returns the length of the line. EOF is indicated by a line of length zero. A truncated line is indicated by setting the value at @@ -45,7 +45,7 @@ append a CR,LF,Nul */ ssize_t -read_line (FILE *fp, +read_line (FILE *fp, char **addr_of_buffer, size_t *length_of_buffer, size_t *max_length) { @@ -94,7 +94,7 @@ read_line (FILE *fp, if (!*addr_of_buffer) { int save_errno = errno; - xfree (buffer); + xfree (buffer); *length_of_buffer = 0; if (max_length) *max_length = 0; @@ -103,7 +103,7 @@ read_line (FILE *fp, } buffer = *addr_of_buffer; *length_of_buffer = length; - length -= 3; + length -= 3; p = buffer + nbytes; } *p++ = c; diff --git a/common/yesno.c b/common/yesno.c index a7131b7d5..821df4b9f 100644 --- a/common/yesno.c +++ b/common/yesno.c @@ -104,7 +104,7 @@ answer_is_yes_no_quit ( const char *s ) } /* - Return 1 for okay, 0 for for cancel or DEF_ANSWER for default. + Return 1 for okay, 0 for for cancel or DEF_ANSWER for default. */ int answer_is_okay_cancel (const char *s, int def_answer) @@ -115,7 +115,7 @@ answer_is_okay_cancel (const char *s, int def_answer) const char *long_cancel = _("cancel|cancel"); const char *short_okay = _("oO"); const char *short_cancel = _("cC"); - + /* Note: We have to use the locale dependent compare. */ if ( match_multistr(long_okay,s) ) return 1; @@ -138,4 +138,3 @@ answer_is_okay_cancel (const char *s, int def_answer) return 0; return def_answer; } - |