[svn] GnuPG - r4249 - in trunk: . agent common g10 kbx scd sm tools

svn author wk cvs at cvs.gnupg.org
Thu Sep 14 18:50:41 CEST 2006


Author: wk
Date: 2006-09-14 18:50:33 +0200 (Thu, 14 Sep 2006)
New Revision: 4249

Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/NEWS
   trunk/README
   trunk/acinclude.m4
   trunk/agent/ChangeLog
   trunk/agent/call-pinentry.c
   trunk/agent/call-scd.c
   trunk/agent/command-ssh.c
   trunk/agent/command.c
   trunk/agent/divert-scd.c
   trunk/agent/findkey.c
   trunk/agent/preset-passphrase.c
   trunk/common/ChangeLog
   trunk/common/asshelp.c
   trunk/common/b64enc.c
   trunk/common/exechelp.c
   trunk/common/http.c
   trunk/common/iobuf.c
   trunk/common/miscellaneous.c
   trunk/common/util.h
   trunk/configure.ac
   trunk/g10/ChangeLog
   trunk/g10/call-agent.c
   trunk/g10/dearmor.c
   trunk/g10/decrypt.c
   trunk/g10/encode.c
   trunk/g10/exec.c
   trunk/g10/gpg.c
   trunk/g10/keydb.c
   trunk/g10/keygen.c
   trunk/g10/keyring.c
   trunk/g10/keyserver.c
   trunk/g10/openfile.c
   trunk/g10/plaintext.c
   trunk/g10/sign.c
   trunk/g10/tdbio.c
   trunk/g10/verify.c
   trunk/kbx/ChangeLog
   trunk/kbx/keybox-openpgp.c
   trunk/scd/ChangeLog
   trunk/scd/app-openpgp.c
   trunk/scd/app-p15.c
   trunk/scd/app.c
   trunk/scd/command.c
   trunk/scd/iso7816.c
   trunk/sm/ChangeLog
   trunk/sm/base64.c
   trunk/sm/certchain.c
   trunk/sm/export.c
   trunk/sm/import.c
   trunk/sm/keylist.c
   trunk/sm/qualified.c
   trunk/tools/ChangeLog
   trunk/tools/gpgkey2ssh.c
Log:
Take advantage of newer gpg-error features.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,11 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+	
+	* configure.ac: Build gpg by default.
+	(GNUPG_SYS_SO_PEERCRED): Removed.
+
 2006-09-13  Werner Koch  <wk at g10code.com>
 
 	* autogen.sh: Better detection of the cross compiler kit.

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/Makefile.am	2006-09-14 16:50:33 UTC (rev 4249)
@@ -24,7 +24,7 @@
 AUTOMAKE_OPTIONS = dist-bzip2
 DISTCHECK_CONFIGURE_FLAGS = --enable-gpg
 
-EXTRA_DIST = scripts/config.rpath autogen.sh README.CVS
+EXTRA_DIST = scripts/config.rpath autogen.sh README.SVN
 DISTCLEANFILES = g10defs.h 
 
 if BUILD_GPGSM

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/NEWS	2006-09-14 16:50:33 UTC (rev 4249)
@@ -2,7 +2,7 @@
 -------------------------------------------------
 
  * Regular man pages for most tools are now build directly from the
-   texinfo source.
+   Texinfo source.
 
  * The gpg code from 1.4.5 has been fully merged into this release.
    The configure option --enable-gpg is still required to build this

Modified: trunk/README
===================================================================
--- trunk/README	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/README	2006-09-14 16:50:33 UTC (rev 4249)
@@ -5,9 +5,7 @@
 
 GnuPG 1.9 is the future version of GnuPG; it is based on some gnupg-1.3
 code and the previous newpg package.  It will eventually lead to a
-GnuPG 2.0 release.  Note that GnuPG 1.4 and 1.9 are not always in sync
-and thus features and bug fixes done in 1.4 are not necessary
-available in 1.9.
+GnuPG 2.0 release.  
 
 You should use this GnuPG version if you want to use the gpg-agent or
 gpgsm (the S/MIME variant of gpg).  Note that the gpg-agent is also

Modified: trunk/acinclude.m4
===================================================================
--- trunk/acinclude.m4	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/acinclude.m4	2006-09-14 16:50:33 UTC (rev 4249)
@@ -157,26 +157,7 @@
 
 
 
-# Check for the getsockopt SO_PEERCRED
-AC_DEFUN([GNUPG_SYS_SO_PEERCRED],
-  [ AC_MSG_CHECKING(for SO_PEERCRED)
-    AC_CACHE_VAL(gnupg_cv_sys_so_peercred,
-      [AC_TRY_COMPILE([#include <sys/socket.h>], 
-                    [struct ucred cr; 
-                     int cl = sizeof cr;
-                     getsockopt (1, SOL_SOCKET, SO_PEERCRED, &cr, &cl);],
-                    gnupg_cv_sys_so_peercred=yes,
-                    gnupg_cv_sys_so_peercred=no)
-      ])
-    AC_MSG_RESULT($gnupg_cv_sys_so_peercred) 
-    if test $gnupg_cv_sys_so_peercred = yes; then
-         AC_DEFINE(HAVE_SO_PEERCRED, 1,
-                            [Defined if SO_PEERCRED is supported (Linux)])
-    fi
-  ])
 
-
-
 # GNUPG_BUILD_PROGRAM(NAME,DEFAULT)
 # Add a --enable-NAME option to configure an set the
 # shell variable build_NAME either to "yes" or "no".  DEFAULT must

Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,14 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+
+	* call-pinentry.c (start_pinentry): Replaced pipe_connect2 by
+	pipe_connect_ext.
+	* call-scd.c (start_scd): Ditto.
+	* command.c (start_command_handler): Replaced
+	init_connected_socket_server by init_socket_server_ext.
+
 2006-09-13  Werner Koch  <wk at g10code.com>
 
 	* preset-passphrase.c (main) [W32]: Check for WSAStartup error.

Modified: trunk/agent/call-pinentry.c
===================================================================
--- trunk/agent/call-pinentry.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/call-pinentry.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -238,8 +238,8 @@
   no_close_list[i] = -1;
 
   /* Connect to the pinentry and perform initial handshaking */
-  rc = assuan_pipe_connect2 (&ctx, opt.pinentry_program, argv,
-                             no_close_list, atfork_cb, NULL);
+  rc = assuan_pipe_connect_ext (&ctx, opt.pinentry_program, argv,
+                                no_close_list, atfork_cb, NULL, 0);
   if (rc)
     {
       log_error ("can't connect to the PIN entry module: %s\n",
@@ -649,7 +649,7 @@
   popup_tid = pth_spawn (tattr, popup_message_thread, NULL);
   if (!popup_tid)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error ("error spawning popup message handler: %s\n",
                  strerror (errno) );
       pth_attr_destroy (tattr);

Modified: trunk/agent/call-scd.c
===================================================================
--- trunk/agent/call-scd.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/call-scd.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -217,7 +217,7 @@
     {
       ctrl->scd_local = xtrycalloc (1, sizeof *ctrl->scd_local);
       if (!ctrl->scd_local)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       ctrl->scd_local->ctrl_backlink = ctrl;
       ctrl->scd_local->next_local = scd_local_list;
       scd_local_list = ctrl->scd_local;
@@ -316,8 +316,8 @@
   no_close_list[i] = -1;
 
   /* Connect to the pinentry and perform initial handshaking */
-  rc = assuan_pipe_connect2 (&ctx, opt.scdaemon_program, argv,
-                             no_close_list, atfork_cb, NULL);
+  rc = assuan_pipe_connect_ext (&ctx, opt.scdaemon_program, argv,
+                                no_close_list, atfork_cb, NULL, 0);
   if (rc)
     {
       log_error ("can't connect to the SCdaemon: %s\n",

Modified: trunk/agent/command-ssh.c
===================================================================
--- trunk/agent/command-ssh.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/command-ssh.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -294,7 +294,7 @@
   if (ret == EOF)
     {
       if (es_ferror (stream))
-	err = gpg_error_from_errno (errno);
+	err = gpg_error_from_syserror ();
       else
 	err = gpg_error (GPG_ERR_EOF);
       *b = 0;
@@ -317,7 +317,7 @@
 
   ret = es_fputc (b, stream);
   if (ret == EOF)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     err = 0;
 
@@ -335,7 +335,7 @@
 
   ret = es_read (stream, buffer, sizeof (buffer), &bytes_read);
   if (ret)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     {
       if (bytes_read != sizeof (buffer))
@@ -368,7 +368,7 @@
 
   ret = es_write (stream, buffer, sizeof (buffer), NULL);
   if (ret)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     err = 0;
 
@@ -385,7 +385,7 @@
 
   ret = es_read (stream, buffer, size, &bytes_read);
   if (ret)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     {
       if (bytes_read != size)
@@ -406,7 +406,7 @@
 
   ret = es_write (stream, buffer, size, NULL);
   if (ret)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     err = 0;
 
@@ -438,7 +438,7 @@
     buffer = xtrymalloc (length + 1);
   if (! buffer)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -587,13 +587,13 @@
       if (ret || (! bytes_read))
 	{
 	  if (ret)
-	    err = gpg_error_from_errno (errno);
+	    err = gpg_error_from_syserror ();
 	  break;
 	}
       ret = es_write (dst, buffer, bytes_read, NULL);
       if (ret)
 	{
-	  err = gpg_error_from_errno (errno);
+	  err = gpg_error_from_syserror ();
 	  break;
 	}
     }
@@ -623,21 +623,21 @@
   stream = es_fopen (filename, "r");
   if (! stream)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
   ret = fstat (es_fileno (stream), &statbuf);
   if (ret)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
   buffer_new = xtrymalloc (statbuf.st_size);
   if (! buffer_new)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -865,7 +865,7 @@
   mpis = xtrycalloc (elems_n + 1, sizeof *mpis );
   if (!mpis)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1040,7 +1040,7 @@
   sexp_template = xtrymalloc (sexp_template_n);
   if (! sexp_template)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1048,7 +1048,7 @@
   arg_list = xtrymalloc (sizeof (*arg_list) * (2 + elems_n + 1));
   if (! arg_list)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1153,7 +1153,7 @@
   mpis_new = xtrycalloc (elems_n + 1, sizeof *mpis_new );
   if (!mpis_new)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1204,7 +1204,7 @@
   comment_new = make_cstring (data, data_n);
   if (! comment_new)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1401,7 +1401,7 @@
   stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
   if (! stream)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1417,7 +1417,7 @@
   blob_size_new = es_ftell (stream);
   if (blob_size_new == -1)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
   
@@ -1428,7 +1428,7 @@
   blob_new = xtrymalloc (blob_size_new);
   if (! blob_new)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1520,7 +1520,7 @@
   blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
   if (! blob_stream)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1684,7 +1684,7 @@
       shadow_info = make_shadow_info (serialno, authkeyid);
       if (!shadow_info)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           xfree (pkbuf);
           gcry_sexp_release (s_pk);
           xfree (serialno);
@@ -1734,7 +1734,7 @@
         *cardsn = xtryasprintf ("cardno:%s", serialno);
       if (!*cardsn)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           xfree (pkbuf);
           gcry_sexp_release (s_pk);
           xfree (serialno);
@@ -1801,7 +1801,7 @@
   key_blobs = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
   if (! key_blobs)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -1925,7 +1925,7 @@
   ret = es_fseek (key_blobs, 0, SEEK_SET);
   if (ret)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2032,7 +2032,7 @@
   stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
   if (! stream)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2046,7 +2046,7 @@
   identifier = make_cstring (identifier_raw, identifier_n);
   if (! identifier)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2064,7 +2064,7 @@
   mpis = xtrycalloc (elems_n + 1, sizeof *mpis);
   if (!mpis)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2098,21 +2098,21 @@
   sig_blob_n = es_ftell (stream);
   if (sig_blob_n == -1)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
   sig_blob = xtrymalloc (sig_blob_n);
   if (! sig_blob)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
   ret = es_fseek (stream, 0, SEEK_SET);
   if (ret)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }    
 
@@ -2269,7 +2269,7 @@
   comment_new = make_cstring (data, data_n);
   if (! comment_new)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2299,7 +2299,7 @@
   buffer_new = xtrymalloc_secure (buffer_new_n);
   if (! buffer_new)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
   
@@ -2356,7 +2356,7 @@
                    "within gpg-agent's key storage"),
                  comment ? comment : "?") < 0)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2364,7 +2364,7 @@
   pi = gcry_calloc_secure (1, sizeof (*pi) + 100 + 1);
   if (!pi)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
   pi->max_length = 100;
@@ -2720,13 +2720,13 @@
     request = es_mopen (NULL, 0, 0, 1, gcry_realloc, gcry_free, "r+");
   if (! request)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
   ret = es_setvbuf (request, NULL, _IONBF, 0);
   if (ret)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
   err = stream_write_data (request, request_data + 1, request_data_size - 1);
@@ -2737,7 +2737,7 @@
   response = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
   if (! response)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto out;
     }
 
@@ -2853,7 +2853,7 @@
   stream_sock = es_fdopen (sock_client, "r+");
   if (!stream_sock)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("failed to create stream from socket: %s\n"),
 		 gpg_strerror (err));
       goto out;
@@ -2863,7 +2863,7 @@
   ret = es_setvbuf (stream_sock, NULL, _IONBF, 0);
   if (ret)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("failed to disable buffering "
                    "on socket stream: %s\n"), gpg_strerror (err));
       goto out;

Modified: trunk/agent/command.c
===================================================================
--- trunk/agent/command.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/command.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -585,7 +585,7 @@
       assert (len);
       buf = xtrymalloc (len);
       if (!buf)
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
       else
         {
           len = gcry_sexp_sprint (s_pkey, GCRYSEXP_FMT_CANON, buf, len);
@@ -1038,7 +1038,7 @@
     {
       vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen);
       if (!vl)
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
       else
         {
           vl->len = valuelen;
@@ -1221,11 +1221,11 @@
     }
   else if (listen_fd != -1)
     {
-      rc = assuan_init_socket_server (&ctx, listen_fd);
+      rc = assuan_init_socket_server_ext (&ctx, listen_fd, 0);
     }
   else 
     {
-      rc = assuan_init_connected_socket_server (&ctx, fd);
+      rc = assuan_init_socket_server_ext (&ctx, fd, 2);
       ctrl.connection_fd = fd;
     }
   if (rc)

Modified: trunk/agent/divert-scd.c
===================================================================
--- trunk/agent/divert-scd.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/divert-scd.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -248,7 +248,7 @@
  again:
   pi = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10);
   if (!pi)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   pi->max_length = maxbuf-1;
   pi->min_digits = 0;  /* we want a real passphrase */
   pi->max_digits = 8;
@@ -264,7 +264,7 @@
           pi2 = gcry_calloc_secure (1, sizeof (*pi) + maxbuf + 10);
           if (!pi2)
             {
-              rc = gpg_error_from_errno (errno);
+              rc = gpg_error_from_syserror ();
               xfree (pi);
               return rc;
             }

Modified: trunk/agent/findkey.c
===================================================================
--- trunk/agent/findkey.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/findkey.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -215,7 +215,7 @@
         {
           *result = out = xtrymalloc (out_len + 1);
           if (!out)
-            return gpg_error_from_errno (errno);
+            return gpg_error_from_syserror ();
         }
     }
 
@@ -270,7 +270,7 @@
   
   pi = gcry_calloc_secure (1, sizeof (*pi) + 100);
   if (!pi)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   pi->max_length = 100;
   pi->min_digits = 0;  /* we want a real passphrase */
   pi->max_digits = 8;
@@ -318,7 +318,7 @@
   fp = fopen (fname, "rb");
   if (!fp)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error ("can't open `%s': %s\n", fname, strerror (errno));
       xfree (fname);
       return rc;
@@ -326,7 +326,7 @@
   
   if (fstat (fileno(fp), &st))
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error ("can't stat `%s': %s\n", fname, strerror (errno));
       xfree (fname);
       fclose (fp);
@@ -337,7 +337,7 @@
   buf = xtrymalloc (buflen+1);
   if (!buf || fread (buf, buflen, 1, fp) != 1)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error ("error reading `%s': %s\n", fname, strerror (errno));
       xfree (fname);
       fclose (fp);
@@ -394,7 +394,7 @@
   buf = xtrymalloc (len);
   if (!buf)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       gcry_sexp_release (s_skey);
       return rc;
     }
@@ -435,7 +435,7 @@
                    shouldn't be a problem.  */
                 char *tmp = xtrymalloc (comment_length+1);
                 if (!tmp)
-                  rc = gpg_error_from_errno (errno);
+                  rc = gpg_error_from_syserror ();
                 else
                   {
                     memcpy (tmp, comment, comment_length);
@@ -593,7 +593,7 @@
   array = xtrycalloc (strlen(elems) + 1, sizeof *array);
   if (!array)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       gcry_sexp_release (list);
       gcry_sexp_release (s_skey);
       return rc;
@@ -655,7 +655,7 @@
   format = xtrymalloc (15+7*strlen (elems)+10+15+1+1);
   if (!format)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       for (i=0; array[i]; i++)
         gcry_mpi_release (array[i]);
       xfree (array);

Modified: trunk/agent/preset-passphrase.c
===================================================================
--- trunk/agent/preset-passphrase.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/agent/preset-passphrase.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -144,7 +144,7 @@
     case SPWQ_NO_AGENT:
       return gpg_error (GPG_ERR_NO_AGENT);
     case SPWQ_SYS_ERROR:
-      return gpg_error_from_errno (errno);
+      return gpg_error_from_syserror ();
     case SPWQ_GENERAL_ERROR:
     default:
       return gpg_error (GPG_ERR_GENERAL);
@@ -165,7 +165,7 @@
   if (!dst)
     {
       log_error ("can not escape string: %s\n",
-		 gpg_strerror (gpg_error_from_errno (errno)));
+		 gpg_strerror (gpg_error_from_syserror ()));
       return NULL;
     }
 
@@ -199,7 +199,7 @@
       if (rc < 0)
         {
           log_error ("reading passphrase failed: %s\n",
-                     gpg_strerror (gpg_error_from_errno (errno)));
+                     gpg_strerror (gpg_error_from_syserror ()));
           return;
         }
       passphrase[rc] = '\0';
@@ -230,7 +230,7 @@
   if (rc < 0)
     {
       log_error ("caching passphrase failed: %s\n",
-		 gpg_strerror (gpg_error_from_errno (errno)));
+		 gpg_strerror (gpg_error_from_syserror ()));
       return;
     }
   if (!opt_passphrase)
@@ -258,7 +258,7 @@
   if (rc < 0)
     {
       log_error ("clearing passphrase failed: %s\n",
-		 gpg_strerror (gpg_error_from_errno (errno)));
+		 gpg_strerror (gpg_error_from_syserror ()));
       return;
     }
   free (line);

Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,11 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+	* util.h (out_of_core): Use new gpg_error_from_syserror function.
+
+	* http.c (init_sockets): Changed it to require 2.2 unless it is
+	build within gnupg 1 where we require 1.1 (and not anymore allow
+	for 1.0).
+
 2006-09-07  Werner Koch  <wk at g10code.com>
 
 	* exechelp.c (gnupg_spawn_process): Factor out post fork code to ..

Modified: trunk/common/asshelp.c
===================================================================
--- trunk/common/asshelp.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/asshelp.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -44,7 +44,7 @@
   if (!value || !*value)
     err = 0;  /* Avoid sending empty strings.  */
   else if (asprintf (&optstr, "OPTION %s=%s", name, value ) < 0)
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     {
       err = assuan_transact (ctx, optstr, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -116,7 +116,7 @@
     {
       old_lc = strdup (old_lc);
       if (!old_lc)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
     }
   dft_lc = setlocale (LC_CTYPE, "");
 #endif
@@ -142,7 +142,7 @@
     {
       old_lc = strdup (old_lc);
       if (!old_lc)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
     }
   dft_lc = setlocale (LC_MESSAGES, "");
 #endif

Modified: trunk/common/b64enc.c
===================================================================
--- trunk/common/b64enc.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/b64enc.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -57,7 +57,7 @@
     {
       state->title = xtrystrdup (title);
       if (!state->title)
-        return  gpg_error_from_errno (errno);
+        return  gpg_error_from_syserror ();
     }
   return 0;
 }
@@ -130,7 +130,7 @@
   return 0;
 
  write_error:
-  return gpg_error_from_errno (errno);
+  return gpg_error_from_syserror ();
 }
 
 gpg_error_t
@@ -200,7 +200,7 @@
   goto cleanup;
 
  write_error:
-  err = gpg_error_from_errno (errno);
+  err = gpg_error_from_syserror ();
 
  cleanup:
   if (state->title)

Modified: trunk/common/exechelp.c
===================================================================
--- trunk/common/exechelp.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/exechelp.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -96,7 +96,7 @@
 
   buf = p = xtrymalloc (n);
   if (!buf)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   /* fixme: PGMNAME may not contain spaces etc. */
   p = stpcpy (p, pgmname);
@@ -342,7 +342,7 @@
   }
   if (!*statusfile)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("can't fdopen pipe for reading: %s\n"), gpg_strerror (err));
       CloseHandle (pi.hProcess);
       return err;
@@ -366,7 +366,7 @@
 
   if (pipe (rp) == -1)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error creating a pipe: %s\n"), strerror (errno));
       return err;
     }
@@ -378,7 +378,7 @@
 #endif
   if (*pid == (pid_t)(-1))
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error forking process: %s\n"), strerror (errno));
       close (rp[0]);
       close (rp[1]);
@@ -399,7 +399,7 @@
   *statusfile = fdopen (rp[0], "r");
   if (!*statusfile)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("can't fdopen pipe for reading: %s\n"), strerror (errno));
       kill (*pid, SIGTERM);
       *pid = (pid_t)(-1);
@@ -528,7 +528,7 @@
     return gpg_error (GPG_ERR_BUG);
 
   if (access (pgmname, X_OK))
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
 #ifdef USE_GNU_PTH      
   pid = pth_fork? pth_fork () : fork ();
@@ -538,7 +538,7 @@
   if (pid == (pid_t)(-1))
     {
       log_error (_("error forking process: %s\n"), strerror (errno));
-      return gpg_error_from_errno (errno);
+      return gpg_error_from_syserror ();
     }
   if (!pid)
     {

Modified: trunk/common/http.c
===================================================================
--- trunk/common/http.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/http.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -200,6 +200,16 @@
 
 
 #ifdef HAVE_W32_SYSTEM
+
+#if GNUPG_MAJOR_VERSION == 1
+#define REQ_WINSOCK_MAJOR  1
+#define REQ_WINSOCK_MINOR  1
+#else
+#define REQ_WINSOCK_MAJOR  2
+#define REQ_WINSOCK_MINOR  2
+#endif
+
+
 static void
 deinit_sockets (void)
 {
@@ -215,16 +225,18 @@
   if (initialized)
     return;
 
-  if ( WSAStartup( 0x0101, &wsdata ) ) 
+  if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) ) 
     {
       log_error ("error initializing socket library: ec=%d\n", 
                  (int)WSAGetLastError () );
       return;
     }
-  if ( wsdata.wVersion < 0x0001 ) 
+  if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR  
+       || HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR ) 
     {
-      log_error ("socket library version is %x.%x - but 1.1 needed\n",
-                 LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion));
+      log_error ("socket library version is %x.%x - but %d.%d needed\n",
+                 LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion)
+                 REQ_WINSOCK_MAJOR, REQ_WINSOCK_MINOR);
       WSACleanup();
       return;
     }
@@ -313,7 +325,7 @@
   /* Create the handle. */
   hd = xtrycalloc (1, sizeof *hd);
   if (!hd)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   hd->sock = -1;
   hd->req_type = reqtype;
   hd->flags = flags;
@@ -383,7 +395,7 @@
     {
       hd->sock = dup (hd->sock);
       if (hd->sock == -1)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
     }
   P_ES(fclose) (hd->fp_write);
   hd->fp_write = NULL;
@@ -401,7 +413,7 @@
 
     cookie = xtrycalloc (1, sizeof *cookie);
     if (!cookie)
-      return gpg_error_from_errno (errno);
+      return gpg_error_from_syserror ();
     cookie->fd = hd->sock;
     if (hd->uri->use_tls)
       cookie->tls_session = hd->tls_context;
@@ -410,13 +422,13 @@
     if (!hd->fp_read)
       {
         xfree (cookie);
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       }
   }
 #else /*!HTTP_USE_ESTREAM*/
   hd->fp_read = fdopen (hd->sock, "r");
   if (!hd->fp_read)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 #endif /*!HTTP_USE_ESTREAM*/
 
   err = parse_response (hd);
@@ -851,7 +863,7 @@
                                             uri->auth, strlen(uri->auth));
           if (!proxy_authstr)
             {
-              err = gpg_error_from_errno (errno);
+              err = gpg_error_from_syserror ();
               http_release_parsed_uri (uri);
               return err;
             }
@@ -919,7 +931,7 @@
           if (!myauth)
             {
               xfree (proxy_authstr);
-              return gpg_error_from_errno (errno);
+              return gpg_error_from_syserror ();
             }
           remove_escapes (myauth);
         }
@@ -937,13 +949,13 @@
       if (!authstr)
         {
           xfree (proxy_authstr);
-          return gpg_error_from_errno (errno);
+          return gpg_error_from_syserror ();
         }
     }
   
   p = build_rel_path (hd->uri);
   if (!p)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
 
   request = xtrymalloc (2 * strlen (server) 
                         + strlen (p)
@@ -952,7 +964,7 @@
                         + 100);
   if (!request)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       xfree (p);
       xfree (authstr);
       xfree (proxy_authstr);
@@ -997,7 +1009,7 @@
     cookie = xtrycalloc (1, sizeof *cookie);
     if (!cookie)
       {
-        err = gpg_error_from_errno (errno);
+        err = gpg_error_from_syserror ();
         goto leave;
       }
     cookie->fd = hd->sock;
@@ -1011,10 +1023,10 @@
     if (!hd->fp_write)
       {
         xfree (cookie);
-        err = gpg_error_from_errno (errno);
+        err = gpg_error_from_syserror ();
       }
     else if (es_fputs (request, hd->fp_write) || es_fflush (hd->fp_write))
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
     else
       err = 0;
   }
@@ -1030,7 +1042,7 @@
     {
       hd->fp_write = fdopen (hd->sock, "w");
       if (!hd->fp_write)
-        err = gpg_error_from_errno (errno);
+        err = gpg_error_from_syserror ();
     }
 #endif /*!HTTP_USE_ESTREAM*/
 
@@ -1237,7 +1249,7 @@
       n += strlen (hd->headers->value);
       p = xtrymalloc (n+1);
       if (!p)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       strcpy (stpcpy (p, hd->headers->value), line);
       xfree (hd->headers->value);
       hd->headers->value = p;
@@ -1262,7 +1274,7 @@
          it is a comma separated list and merge them.  */
       p = xtrymalloc (strlen (h->value) + 1 + strlen (value)+ 1);
       if (!p)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       strcpy (stpcpy (stpcpy (p, h->value), ","), value);
       xfree (h->value);
       h->value = p;
@@ -1272,13 +1284,13 @@
   /* Append a new header. */
   h = xtrymalloc (sizeof *h + strlen (line));
   if (!h)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   strcpy (h->name, line);
   h->value = xtrymalloc (strlen (value)+1);
   if (!h->value)
     {
       xfree (h);
-      return gpg_error_from_errno (errno);
+      return gpg_error_from_syserror ();
     }
   strcpy (h->value, value);
   h->next = hd->headers;
@@ -1334,7 +1346,7 @@
       len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen);
       line = hd->buffer;
       if (!line)
-	return gpg_error_from_errno (errno); /* Out of core. */
+	return gpg_error_from_syserror (); /* Out of core. */
       if (!maxlen)
 	return gpg_error (GPG_ERR_TRUNCATED); /* Line has been truncated. */
       if (!len)
@@ -1378,7 +1390,7 @@
       len = my_read_line (hd->fp_read, &hd->buffer, &hd->buffer_size, &maxlen);
       line = hd->buffer;
       if (!line)
-	return gpg_error_from_errno (errno); /* Out of core. */
+	return gpg_error_from_syserror (); /* Out of core. */
       /* Note, that we can silently ignore truncated lines. */
       if (!len)
 	return gpg_error (GPG_ERR_EOF);
@@ -1700,7 +1712,7 @@
 	      continue;
 	    }
 	  log_info ("network write failed: %s\n", strerror (errno));
-	  return gpg_error_from_errno (errno);
+	  return gpg_error_from_syserror ();
 	}
 #endif /*!HAVE_W32_SYSTEM*/
       nleft -= nwritten;

Modified: trunk/common/iobuf.c
===================================================================
--- trunk/common/iobuf.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/iobuf.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -392,7 +392,7 @@
 	    }
 	  else if (ferror (f) && errno != EPIPE)
 	    {
-	      rc = gpg_error_from_errno (errno);
+	      rc = gpg_error_from_syserror ();
 	      log_error ("%s: read error: %s\n", a->fname, strerror (errno));
 	    }
 	  *ret_len = nbytes;
@@ -406,7 +406,7 @@
 	  nbytes = fwrite (buf, 1, size, f);
 	  if (ferror (f))
 	    {
-	      rc = gpg_error_from_errno (errno);
+	      rc = gpg_error_from_syserror ();
 	      log_error ("%s: write error: %s\n", a->fname, strerror (errno));
 	    }
 	}
@@ -481,7 +481,7 @@
 	    {			/* error */
 	      if (errno != EPIPE)
 		{
-		  rc = gpg_error_from_errno (errno);
+		  rc = gpg_error_from_syserror ();
 		  log_error ("%s: read error: %s\n",
 			     a->fname, strerror (errno));
 		}
@@ -543,7 +543,7 @@
 	  while (n != -1 && nbytes);
 	  if (n == -1)
 	    {
-	      rc = gpg_error_from_errno (errno);
+	      rc = gpg_error_from_syserror ();
 	      log_error ("%s: write error: %s\n", a->fname, strerror (errno));
 	    }
 	  nbytes = p - buf;
@@ -849,14 +849,14 @@
 		    {		/* write stuff from the buffer */
 		      assert (n == OP_MIN_PARTIAL_CHUNK);
 		      if (iobuf_write (chain, a->buffer, n))
-			rc = gpg_error_from_errno (errno);
+			rc = gpg_error_from_syserror ();
 		      a->buflen = 0;
 		      nbytes -= n;
 		    }
 		  if ((n = nbytes) > blen)
 		    n = blen;
 		  if (n && iobuf_write (chain, p, n))
-		    rc = gpg_error_from_errno (errno);
+		    rc = gpg_error_from_syserror ();
 		  p += n;
 		  nbytes -= n;
 		}
@@ -935,7 +935,7 @@
 		{
 		  log_error ("block_filter: write error: %s\n",
 			     strerror (errno));
-		  rc = gpg_error_from_errno (errno);
+		  rc = gpg_error_from_syserror ();
 		}
 	      xfree (a->buffer);
 	      a->buffer = NULL;
@@ -1649,7 +1649,7 @@
       if (len < a->d.size)
 	{
 	  if (ferror (fp))
-	    a->error = gpg_error_from_errno (errno);
+	    a->error = gpg_error_from_syserror ();
 	}
       a->d.len = len;
       a->d.start = 0;

Modified: trunk/common/miscellaneous.c
===================================================================
--- trunk/common/miscellaneous.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/miscellaneous.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -99,7 +99,7 @@
 
     a = iobuf_open( s );
     if ( a == NULL ) {
-        *ret_rc = gpg_error_from_errno (errno);
+        *ret_rc = gpg_error_from_syserror ();
         return 0;
     }
 

Modified: trunk/common/util.h
===================================================================
--- trunk/common/util.h	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/common/util.h	2006-09-14 16:50:33 UTC (rev 4249)
@@ -71,9 +71,7 @@
 static inline gpg_error_t
 out_of_core (void)
 {
-  return gpg_error (errno
-                    ? gpg_err_code_from_errno(errno)
-                    : GPG_ERR_MISSING_ERRNO);
+  return gpg_error_from_syserror ();
 }
 
 /* A type to hold the ISO time.  Note that this this is the same as

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/configure.ac	2006-09-14 16:50:33 UTC (rev 4249)
@@ -76,7 +76,7 @@
 disable_keyserver_path=no
 
 
-GNUPG_BUILD_PROGRAM(gpg, no)
+GNUPG_BUILD_PROGRAM(gpg, yes)
 GNUPG_BUILD_PROGRAM(gpgsm, yes)
 GNUPG_BUILD_PROGRAM(agent, yes)
 GNUPG_BUILD_PROGRAM(scdaemon, yes)
@@ -946,12 +946,7 @@
     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
 fi
 
-#
-# fixme: do we really need this - it should be encapsulated in libassuan
-#
-GNUPG_SYS_SO_PEERCRED
 
-
 #
 # Checks for library functions.
 #

Modified: trunk/g10/ChangeLog
===================================================================
--- trunk/g10/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,8 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+
 2006-09-13  Werner Koch  <wk at g10code.com>
 
 	* gpg.c (main): Made --require-cross-certification the default. 

Modified: trunk/g10/call-agent.c
===================================================================
--- trunk/g10/call-agent.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/call-agent.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -104,7 +104,7 @@
 
       if (fflush (NULL))
         {
-          gpg_error_t tmperr = gpg_error_from_errno (errno);
+          gpg_error_t tmperr = gpg_error_from_syserror ();
           log_error ("error flushing pending output: %s\n", strerror (errno));
           return tmperr;
         }
@@ -191,7 +191,7 @@
       char *optstr;
       if (asprintf (&optstr, "OPTION display=%s",
 		    opt.display ? opt.display : dft_display) < 0)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
       rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
       free (optstr);
@@ -209,7 +209,7 @@
       char *optstr;
       if (asprintf (&optstr, "OPTION ttyname=%s",
 		    opt.ttyname ? opt.ttyname : dft_ttyname) < 0)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
       rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
       free (optstr);
@@ -222,7 +222,7 @@
       char *optstr;
       if (asprintf (&optstr, "OPTION ttytype=%s",
 		    opt.ttyname ? opt.ttytype : dft_ttytype) < 0)
-	return gpg_error_from_errno (errno);
+	return gpg_error_from_syserror ();
       rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
 			    NULL);
       free (optstr);
@@ -235,7 +235,7 @@
     {
       old_lc = strdup (old_lc);
       if (!old_lc)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
 
     }
   dft_lc = setlocale (LC_CTYPE, "");
@@ -245,7 +245,7 @@
       char *optstr;
       if (asprintf (&optstr, "OPTION lc-ctype=%s",
 		    opt.lc_ctype ? opt.lc_ctype : dft_lc) < 0)
-	rc = gpg_error_from_errno (errno);
+	rc = gpg_error_from_syserror ();
       else
 	{
 	  rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,
@@ -268,7 +268,7 @@
     {
       old_lc = strdup (old_lc);
       if (!old_lc)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
     }
   dft_lc = setlocale (LC_MESSAGES, "");
 #endif
@@ -277,7 +277,7 @@
       char *optstr;
       if (asprintf (&optstr, "OPTION lc-messages=%s",
 		    opt.lc_messages ? opt.lc_messages : dft_lc) < 0)
-	rc = gpg_error_from_errno (errno);
+	rc = gpg_error_from_syserror ();
       else
 	{
 	  rc = assuan_transact (agent_ctx, optstr, NULL, NULL, NULL, NULL, NULL,

Modified: trunk/g10/dearmor.c
===================================================================
--- trunk/g10/dearmor.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/dearmor.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -58,7 +58,7 @@
         errno = EPERM;
       }
     if (!inp) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
 					strerror(errno) );
 	goto leave;
@@ -107,7 +107,7 @@
         errno = EPERM;
       }
     if (!inp) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"), fname? fname: "[stdin]",
                   strerror(errno) );
 	goto leave;

Modified: trunk/g10/decrypt.c
===================================================================
--- trunk/g10/decrypt.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/decrypt.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -66,7 +66,7 @@
         errno = EPERM;
       }
     if( !fp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error (_("can't open `%s': %s\n"), print_fname_stdin(filename),
                    gpg_strerror (rc));
 	return rc;

Modified: trunk/g10/encode.c
===================================================================
--- trunk/g10/encode.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/encode.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -189,7 +189,7 @@
         errno = EPERM;
       }
     if( !inp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"), filename? filename: "[stdin]",
                   strerror(errno) );
 	return rc;
@@ -481,7 +481,7 @@
         errno = EPERM;
       }
     if( !inp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"),
                   filename? filename: "[stdin]",
                   gpg_strerror (rc) );

Modified: trunk/g10/exec.c
===================================================================
--- trunk/g10/exec.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/exec.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -441,7 +441,7 @@
       (*info)->tochild=fdopen(to[1],binary?"wb":"w");
       if((*info)->tochild==NULL)
 	{
-          ret = gpg_error_from_errno (errno);
+          ret = gpg_error_from_syserror ();
 	  close(to[1]);
 	  goto fail;
 	}
@@ -451,7 +451,7 @@
       (*info)->fromchild=iobuf_fdopen(from[0],"r");
       if((*info)->fromchild==NULL)
 	{
-          ret = gpg_error_from_errno (errno);
+          ret = gpg_error_from_syserror ();
 	  close(from[0]);
 	  goto fail;
 	}
@@ -476,7 +476,7 @@
     (*info)->tochild=fopen((*info)->tempfile_in,binary?"wb":"w");
   if((*info)->tochild==NULL)
     {
-      ret = gpg_error_from_errno (errno);
+      ret = gpg_error_from_syserror ();
       log_error(_("can't create `%s': %s\n"),
 		(*info)->tempfile_in,strerror(errno));
       goto fail;
@@ -550,7 +550,7 @@
             }
 	  if(info->fromchild==NULL)
 	    {
-              ret = gpg_error_from_errno (errno);
+              ret = gpg_error_from_syserror ();
 	      log_error(_("unable to read external program response: %s\n"),
 			strerror(errno));
 	      goto fail;

Modified: trunk/g10/gpg.c
===================================================================
--- trunk/g10/gpg.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/gpg.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1834,7 +1834,7 @@
     opt.rfc2440_text=1;
     opt.def_sig_expire="0";
     opt.def_cert_expire="0";
-    opt.require_cross_cert = 1;
+    opt.flags.require_cross_cert = 1;
     set_homedir ( default_homedir () );
 
     /* Check whether we have a config file on the command line.  */

Modified: trunk/g10/keydb.c
===================================================================
--- trunk/g10/keydb.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/keydb.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -112,7 +112,7 @@
         }
       if (access (filename, F_OK))
         {
-          rc = gpg_error_from_errno (errno);
+          rc = gpg_error_from_syserror ();
           *last_slash_in_filename = DIRSEP_C;
           goto leave;
         }
@@ -166,7 +166,7 @@
   umask (oldmask);
   if (!iobuf) 
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error ( _("error creating keyring `%s': %s\n"),
                   filename, strerror(errno));
       goto leave;

Modified: trunk/g10/keygen.c
===================================================================
--- trunk/g10/keygen.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/keygen.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -3732,7 +3732,7 @@
     umask (oldmask);
     if (!fp) 
       {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error (_("can't create backup file `%s': %s\n"),
                    fname, strerror(errno) );
         xfree (fname);

Modified: trunk/g10/keyring.c
===================================================================
--- trunk/g10/keyring.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/keyring.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -661,7 +661,7 @@
     hd->current.iobuf = iobuf_open (hd->current.kr->fname);
     if (!hd->current.iobuf)
       {
-        hd->current.error = gpg_error_from_errno (errno);
+        hd->current.error = gpg_error_from_syserror ();
         log_error(_("can't open `%s'\n"), hd->current.kr->fname );
         return hd->current.error;
       }
@@ -1200,7 +1200,7 @@
     umask(oldmask);
     if (!*r_fp)
       {
-        int rc = gpg_error_from_errno (errno);
+        int rc = gpg_error_from_syserror ();
 	log_error(_("can't create `%s': %s\n"), tmpfname, strerror(errno) );
         xfree (tmpfname);
         xfree (bakfname);
@@ -1232,7 +1232,7 @@
 #endif
       if (rename (fname, bakfname) )
         {
-          rc = gpg_error_from_errno (errno);
+          rc = gpg_error_from_syserror ();
           log_error ("renaming `%s' to `%s' failed: %s\n",
                      fname, bakfname, strerror(errno) );
           return rc;
@@ -1247,7 +1247,7 @@
     unregister_secured_file (fname);
   if (rename (tmpfname, fname) )
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error (_("renaming `%s' to `%s' failed: %s\n"),
                  tmpfname, fname, strerror(errno) );
       register_secured_file (fname);
@@ -1317,7 +1317,7 @@
           iobuf_put (fp, 0);    /* unused */
           if (iobuf_put (fp, cacheval)) 
             {
-              rc = gpg_error_from_errno (errno);
+              rc = gpg_error_from_syserror ();
               log_error ("writing sigcache packet failed\n");
               return rc;
             }
@@ -1362,7 +1362,7 @@
             {
               if (iobuf_close (tmpfp))
                 {
-                  rc = gpg_error_from_errno (errno);
+                  rc = gpg_error_from_syserror ();
                   log_error ("error closing `%s': %s\n",
                              tmpfilename, strerror (errno));
                   goto leave;
@@ -1442,7 +1442,7 @@
     {
       if (iobuf_close (tmpfp))
         {
-          rc = gpg_error_from_errno (errno);
+          rc = gpg_error_from_syserror ();
           log_error ("error closing `%s': %s\n",
                      tmpfilename, strerror (errno));
           goto leave;
@@ -1486,7 +1486,7 @@
     /* Open the source file. Because we do a rename, we have to check the 
        permissions of the file */
     if (access (fname, W_OK))
-      return gpg_error_from_errno (errno);
+      return gpg_error_from_syserror ();
 
     fp = iobuf_open (fname);
     if (mode == 1 && !fp && errno == ENOENT) { 
@@ -1504,7 +1504,7 @@
 	umask(oldmask);
 	if( !newfp )
 	  {
-            rc = gpg_error_from_errno (errno);
+            rc = gpg_error_from_syserror ();
 	    log_error (_("can't create `%s': %s\n"), fname, strerror(errno));
 	    return rc;
 	  }
@@ -1521,7 +1521,7 @@
 	    }
 	}
 	if( iobuf_close(newfp) ) {
-            rc = gpg_error_from_errno (errno);
+            rc = gpg_error_from_syserror ();
 	    log_error ("%s: close failed: %s\n", fname, strerror(errno));
 	    return rc;
 	}
@@ -1530,7 +1530,7 @@
 
     if( !fp )
       {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
 	goto leave;
       }
@@ -1613,12 +1613,12 @@
 
     /* close both files */
     if( iobuf_close(fp) ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error("%s: close failed: %s\n", fname, strerror(errno) );
 	goto leave;
     }
     if( iobuf_close(newfp) ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error("%s: close failed: %s\n", tmpfname, strerror(errno) );
 	goto leave;
     }

Modified: trunk/g10/keyserver.c
===================================================================
--- trunk/g10/keyserver.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/keyserver.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1406,7 +1406,7 @@
       maxlen=1024;
       if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0)
 	{
-	  ret = gpg_error_from_errno (errno);
+	  ret = gpg_error_from_syserror ();
 	  goto fail; /* i.e. EOF */
 	}
 

Modified: trunk/g10/openfile.c
===================================================================
--- trunk/g10/openfile.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/openfile.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -184,7 +184,7 @@
   if( iobuf_is_pipe_filename (iname) && !opt.outfile ) {
     *a = iobuf_create(NULL);
     if( !*a ) {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error(_("can't open `%s': %s\n"), "[stdout]", strerror(errno) );
     }
     else if( opt.verbose )
@@ -261,7 +261,7 @@
           *a = iobuf_create( name );
         if( !*a )
           {
-            rc = gpg_error_from_errno (errno);
+            rc = gpg_error_from_syserror ();
             log_error(_("can't create `%s': %s\n"), name, strerror(errno) );
           }
         else if( opt.verbose )

Modified: trunk/g10/plaintext.c
===================================================================
--- trunk/g10/plaintext.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/plaintext.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -132,12 +132,12 @@
     else if (is_secured_filename (fname))
       {
         errno = EPERM;
-	rc = gpg_error_from_errno (errno);
+	rc = gpg_error_from_syserror ();
 	log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
 	goto leave;
       }
     else if( !(fp = fopen(fname,"wb")) ) {
-	rc = gpg_error_from_errno (errno);
+	rc = gpg_error_from_syserror ();
 	log_error(_("error creating `%s': %s\n"), fname, strerror(errno) );
 	goto leave;
     }
@@ -187,7 +187,7 @@
 	if( convert ) { /* text mode */
 	    for( ; pt->len; pt->len-- ) {
 		if( (c = iobuf_get(pt->buf)) == -1 ) {
-                    rc = gpg_error_from_errno (errno);
+                    rc = gpg_error_from_syserror ();
 		    log_error ("problem reading source (%u bytes remaining)\n",
                                (unsigned)pt->len);
                     goto leave;
@@ -210,7 +210,7 @@
 		    else if( putc( c, fp ) == EOF )
 		      {
                         if (ferror (fp))
-                          rc = gpg_error_from_errno (errno);
+                          rc = gpg_error_from_syserror ();
                         else
                           rc = gpg_error (GPG_ERR_EOF);
 			log_error ("error writing to `%s': %s\n",
@@ -226,7 +226,7 @@
 		int len = pt->len > 32768 ? 32768 : pt->len;
 		len = iobuf_read( pt->buf, buffer, len );
 		if( len == -1 ) {
-                    rc = gpg_error_from_errno (errno);
+                    rc = gpg_error_from_syserror ();
 		    log_error ("problem reading source (%u bytes remaining)\n",
                                (unsigned)pt->len);
 		    xfree( buffer );
@@ -246,7 +246,7 @@
 		      }
 		    else if( fwrite( buffer, 1, len, fp ) != len )
 		      {
-                        rc = gpg_error_from_errno (errno);
+                        rc = gpg_error_from_syserror ();
 			log_error ("error writing to `%s': %s\n",
                                    fname, strerror(errno) );
 			xfree( buffer );
@@ -279,7 +279,7 @@
 		    else if( putc( c, fp ) == EOF )
 		      {
                         if ( ferror (fp ) )
-                          rc = gpg_error_from_errno (errno);
+                          rc = gpg_error_from_syserror ();
                         else
                           rc = gpg_error (GPG_ERR_EOF);
 			log_error("error writing to `%s': %s\n",
@@ -317,7 +317,7 @@
 			goto leave;
 		      }
 		    else if( fwrite( buffer, 1, len, fp ) != len ) {
-		      rc = (errno? gpg_error_from_errno (errno)
+		      rc = (errno? gpg_error_from_syserror ()
                             : gpg_error (GPG_ERR_INTERNAL));
 		      log_error ("error writing to `%s': %s\n",
 				fname, strerror(errno) );
@@ -345,7 +345,7 @@
 		  }
 		else if( putc( c, fp ) == EOF )
 		  {
-                    rc = (errno? gpg_error_from_errno (errno)
+                    rc = (errno? gpg_error_from_syserror ()
                           : gpg_error (GPG_ERR_INTERNAL));
 		    log_error ("error writing to `%s': %s\n",
 			      fname, strerror(errno) );
@@ -385,7 +385,7 @@
     }
 
     if( fp && fp != stdout && fclose(fp) ) {
-        rc = (errno? gpg_error_from_errno (errno)
+        rc = (errno? gpg_error_from_syserror ()
               : gpg_error (GPG_ERR_INTERNAL));
 	log_error ("error closing `%s': %s\n", fname, strerror(errno) );
 	fp = NULL;
@@ -487,7 +487,7 @@
 	    }
 	    else if( !fp )
 	      {
-                rc = gpg_error_from_errno (errno);
+                rc = gpg_error_from_syserror ();
 		log_error(_("can't open `%s': %s\n"), answer, strerror(errno));
 		goto leave;
 	      }
@@ -544,7 +544,7 @@
             errno = EPERM;
           }
 	if( !fp ) {
-            int rc = gpg_error_from_errno (errno);
+            int rc = gpg_error_from_syserror ();
 	    log_error(_("can't open signed data `%s'\n"),
 						print_fname_stdin(sl->d));
 	    return rc;

Modified: trunk/g10/sign.c
===================================================================
--- trunk/g10/sign.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/sign.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -808,7 +808,7 @@
         }
       if( !inp ) 
         {
-          rc = gpg_error_from_errno (errno);
+          rc = gpg_error_from_syserror ();
           log_error (_("can't open `%s': %s\n"), fname? fname: "[stdin]",
                      strerror(errno) );
           goto leave;
@@ -826,7 +826,7 @@
             out = iobuf_create( outfile );
 	if( !out )
 	  {
-            rc = gpg_error_from_errno (errno);
+            rc = gpg_error_from_syserror ();
 	    log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
 	    goto leave;
 	  }
@@ -1003,7 +1003,7 @@
                   }
 		if( !inp )
 		  {
-                    rc = gpg_error_from_errno (errno);
+                    rc = gpg_error_from_syserror ();
 		    log_error(_("can't open `%s': %s\n"),
 			      sl->d,strerror(errno));
 		    goto leave;
@@ -1116,7 +1116,7 @@
         errno = EPERM;
       }
     if( !inp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error (_("can't open `%s': %s\n"), 
                    fname? fname: "[stdin]", strerror(errno) );
 	goto leave;
@@ -1132,7 +1132,7 @@
             out = iobuf_create( outfile );
 	if( !out )
 	  {
-            rc = gpg_error_from_errno (errno);
+            rc = gpg_error_from_syserror ();
 	    log_error(_("can't create `%s': %s\n"), outfile, strerror(errno) );
 	    goto leave;
 	  }
@@ -1268,7 +1268,7 @@
         errno = EPERM;
       }
     if( !inp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error (_("can't open `%s': %s\n"), 
                    fname? fname: "[stdin]", strerror(errno) );
 	goto leave;

Modified: trunk/g10/tdbio.c
===================================================================
--- trunk/g10/tdbio.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/tdbio.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -126,14 +126,14 @@
     int n;
 
     if( lseek( db_fd, r->recno * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) {
-        err = gpg_error_from_errno (errno);
+        err = gpg_error_from_syserror ();
 	log_error(_("trustdb rec %lu: lseek failed: %s\n"),
 					    r->recno, strerror(errno) );
 	return err;
     }
     n = write( db_fd, r->data, TRUST_RECORD_LEN);
     if( n != TRUST_RECORD_LEN ) {
-        err = gpg_error_from_errno (errno);
+        err = gpg_error_from_syserror ();
 	log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"),
 					    r->recno, n, strerror(errno) );
 	return err;
@@ -1162,7 +1162,7 @@
     buf = get_record_from_cache( recnum );
     if( !buf ) {
 	if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) {
-            err = gpg_error_from_errno (errno);
+            err = gpg_error_from_syserror ();
 	    log_error(_("trustdb: lseek failed: %s\n"), strerror(errno) );
 	    return err;
 	}
@@ -1171,7 +1171,7 @@
 	    return -1; /* eof */
 	}
 	else if( n != TRUST_RECORD_LEN ) {
-            err = gpg_error_from_errno (errno);
+            err = gpg_error_from_syserror ();
 	    log_error(_("trustdb: read failed (n=%d): %s\n"), n,
 							strerror(errno) );
 	    return err;
@@ -1435,14 +1435,14 @@
 	rec.recnum = recnum;
 	rc = 0;
 	if( lseek( db_fd, recnum * TRUST_RECORD_LEN, SEEK_SET ) == -1 ) {
-            rc = gpg_error_from_errno (errno);
+            rc = gpg_error_from_syserror ();
 	    log_error(_("trustdb rec %lu: lseek failed: %s\n"),
 						recnum, strerror(errno) );
 	}
 	else {
 	    int n = write( db_fd, &rec, TRUST_RECORD_LEN);
 	    if( n != TRUST_RECORD_LEN ) {
-                rc = gpg_error_from_errno (errno);
+                rc = gpg_error_from_syserror ();
 		log_error(_("trustdb rec %lu: write failed (n=%d): %s\n"),
 						 recnum, n, strerror(errno) );
 	    }

Modified: trunk/g10/verify.c
===================================================================
--- trunk/g10/verify.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/g10/verify.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -98,7 +98,7 @@
         errno = EPERM;
       }
     if( !fp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"),
                   print_fname_stdin(sigfile), strerror (errno));
 	return rc;
@@ -154,7 +154,7 @@
         errno = EPERM;
       }
     if( !fp ) {
-        rc = gpg_error_from_errno (errno);
+        rc = gpg_error_from_syserror ();
 	log_error(_("can't open `%s': %s\n"),
                   print_fname_stdin(name), strerror (errno));
 	print_file_status( STATUS_FILE_ERROR, name, 1 );

Modified: trunk/kbx/ChangeLog
===================================================================
--- trunk/kbx/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/kbx/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,8 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+
 2005-10-08  Marcus Brinkmann  <marcus at g10code.de>
 
 	* Makefile.am (kbxutil_LDADD): Add ../gl/libgnu.a after

Modified: trunk/kbx/keybox-openpgp.c
===================================================================
--- trunk/kbx/keybox-openpgp.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/kbx/keybox-openpgp.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -405,7 +405,7 @@
               u = xtrycalloc (1, sizeof *u);
               if (!u)
                 {
-                  err = gpg_error_from_errno (errno);
+                  err = gpg_error_from_syserror ();
                   break;
                 }
               u->off = data - image_start;
@@ -447,7 +447,7 @@
               k = xtrycalloc (1, sizeof *k);
               if (!k)
                 {
-                  err = gpg_error_from_errno (errno);
+                  err = gpg_error_from_syserror ();
                   break;
                 }
               err = parse_key (data, datalen, k);

Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/scd/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,11 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+
+	* command.c (scd_command_handler): Replaced
+	init_connected_socket_server by init_socket_server_ext.
+
 2006-09-07  Werner Koch  <wk at g10code.com>
 
 	* command.c (update_reader_status_file): Execute an event handler

Modified: trunk/scd/app-openpgp.c
===================================================================
--- trunk/scd/app-openpgp.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/scd/app-openpgp.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -566,7 +566,7 @@
   n = 6 + 2 + mlen + 2 + elen;
   p = buffer = xtrymalloc (3 + n);
   if (!buffer)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   
   *p++ = 0x99;     /* ctb */
   *p++ = n >> 8;   /* 2 byte length header */
@@ -880,7 +880,7 @@
         break; /* EOF. */
       if (i < 0)
 	{
-	  err = gpg_error_from_errno (errno);
+	  err = gpg_error_from_syserror ();
 	  goto leave; /* Error. */
 	}
       if (!max_length)
@@ -1036,7 +1036,7 @@
           mbuf = xtrymalloc ( mlen + 1);
           if (!mbuf)
             {
-              err = gpg_error_from_errno (errno);
+              err = gpg_error_from_syserror ();
               goto leave;
             }
           *mbuf = 0;
@@ -1049,7 +1049,7 @@
           ebuf = xtrymalloc ( elen + 1);
           if (!ebuf)
             {
-              err = gpg_error_from_errno (errno);
+              err = gpg_error_from_syserror ();
               goto leave;
             }
           *ebuf = 0;
@@ -1091,7 +1091,7 @@
 		      fpr);
       if (ret < 0)
 	{
-	  err = gpg_error_from_errno (errno);
+	  err = gpg_error_from_syserror ();
 	  goto leave;
 	}
 
@@ -1099,7 +1099,7 @@
       free (command);
       if (!fp)
 	{
-	  err = gpg_error_from_errno (errno);
+	  err = gpg_error_from_syserror ();
 	  log_error ("running gpg failed: %s\n", gpg_strerror (err));
 	  goto leave;
 	}
@@ -1120,7 +1120,7 @@
   keybuf = xtrymalloc (50 + 2*35 + mlen + elen + 1);
   if (!keybuf)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto leave;
     }
   
@@ -1260,7 +1260,7 @@
   *pk = xtrymalloc (*pklen);
   if (!*pk)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       *pklen = 0;
       return err;
     }
@@ -1819,7 +1819,7 @@
   template = tp = xtrymalloc_secure (template_len);
   if (!template)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto leave;
     }
   *tp++ = 0xC0;
@@ -2185,7 +2185,7 @@
 
         prompt = malloc (strlen (PROMPTSTRING) + 50);
         if (!prompt)
-          return gpg_error_from_errno (errno);
+          return gpg_error_from_syserror ();
         sprintf (prompt, PROMPTSTRING, sigcount);
         rc = pincb (pincb_arg, prompt, &pinvalue); 
         free (prompt);

Modified: trunk/scd/app-p15.c
===================================================================
--- trunk/scd/app-p15.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/scd/app-p15.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -520,7 +520,7 @@
   objidlen /= 2;
   objid = xtrymalloc (objidlen);
   if (!objid)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   for (s=certid, i=0; i < objidlen; i++, s+=2)
     objid[i] = xtoi_2 (s);
   *r_objid = objid;
@@ -1130,14 +1130,14 @@
                               + objlen/2 * sizeof(unsigned short)));
       if (!prkdf)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           goto leave;
         }
       prkdf->objidlen = objidlen;
       prkdf->objid = xtrymalloc (objidlen);
       if (!prkdf->objid)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           xfree (prkdf);
           goto leave;
         }
@@ -1148,7 +1148,7 @@
           prkdf->authid = xtrymalloc (authidlen);
           if (!prkdf->authid)
             {
-              err = gpg_error_from_errno (errno);
+              err = gpg_error_from_syserror ();
               xfree (prkdf->objid);
               xfree (prkdf);
               goto leave;
@@ -1416,14 +1416,14 @@
                             + objlen/2 * sizeof(unsigned short)));
       if (!cdf)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           goto leave;
         }
       cdf->objidlen = objidlen;
       cdf->objid = xtrymalloc (objidlen);
       if (!cdf->objid)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           xfree (cdf);
           goto leave;
         }
@@ -2135,7 +2135,7 @@
       continue; /* Ready. */
 
     no_core:
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       release_aodf_object (aodf);
       goto leave;
 
@@ -2272,7 +2272,7 @@
   app->app_local->serialno = xtrymalloc (objlen);
   if (!app->app_local->serialno)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       goto leave;
     }
   memcpy (app->app_local->serialno, p, objlen);
@@ -2368,7 +2368,7 @@
 
       buf = xtrymalloc (9 + certinfo->objidlen*2 + 1);
       if (!buf)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       p = stpcpy (buf, "P15");
       if (app->app_local->home_df)
         {
@@ -2463,7 +2463,7 @@
 
       buf = xtrymalloc (9 + keyinfo->objidlen*2 + 1);
       if (!buf)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       p = stpcpy (buf, "P15");
       if (app->app_local->home_df)
         {
@@ -2544,7 +2544,7 @@
     {
       *r_cert = xtrymalloc (cdf->imagelen);
       if (!*r_cert)
-        return gpg_error_from_errno (errno);
+        return gpg_error_from_syserror ();
       memcpy (*r_cert, cdf->image, cdf->imagelen);
       *r_certlen = cdf->imagelen;
       return 0;
@@ -2687,7 +2687,7 @@
         {
           buf = xtrymalloc (9 + prkdf->objidlen*2 + 1);
           if (!buf)
-            return gpg_error_from_errno (errno);
+            return gpg_error_from_syserror ();
           p = stpcpy (buf, "P15");
           if (app->app_local->home_df)
             {
@@ -3059,7 +3059,7 @@
           paddedpin = xtrymalloc (aodf->stored_length+1);
           if (!paddedpin)
             {
-              err = gpg_error_from_errno (errno);
+              err = gpg_error_from_syserror ();
               xfree (pinvalue);
               return err;
             }
@@ -3087,7 +3087,7 @@
           paddedpin = xtrymalloc (aodf->stored_length+1);
           if (!paddedpin)
             {
-              err = gpg_error_from_errno (errno);
+              err = gpg_error_from_syserror ();
               xfree (pinvalue);
               return err;
             }
@@ -3345,7 +3345,7 @@
       app->app_local = xtrycalloc (1, sizeof *app->app_local);
       if (!app->app_local)
         {
-          rc = gpg_error_from_errno (errno);
+          rc = gpg_error_from_syserror ();
           goto leave;
         }
 

Modified: trunk/scd/app.c
===================================================================
--- trunk/scd/app.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/scd/app.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -69,7 +69,7 @@
     {
       if (!pth_mutex_init (&lock_table[slot].lock))
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           log_error ("error initializing mutex: %s\n", strerror (errno));
           return err;
         }
@@ -80,7 +80,7 @@
   
   if (!pth_mutex_acquire (&lock_table[slot].lock, 0, NULL))
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error ("failed to acquire APP lock for slot %d: %s\n",
                  slot, strerror (errno));
       return err;
@@ -278,7 +278,7 @@
   app = xtrycalloc (1, sizeof *app);
   if (!app)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_info ("error allocating context: %s\n", gpg_strerror (err));
       unlock_reader (slot);
       return err;
@@ -480,7 +480,7 @@
 
   buf = xtrymalloc (app->serialnolen * 2 + 1);
   if (!buf)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   for (p=buf, i=0; i < app->serialnolen; p +=2, i++)
     sprintf (p, "%02X", app->serialno[i]);
   *p = 0;

Modified: trunk/scd/command.c
===================================================================
--- trunk/scd/command.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/scd/command.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1504,7 +1504,7 @@
   apdu = hex_to_buffer (line, &apdulen);
   if (!apdu)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       goto leave;
     }
   if (apdulen)
@@ -1603,7 +1603,7 @@
     }
   else
     {
-      rc = assuan_init_connected_socket_server (&ctx, fd);
+      rc = assuan_init_socket_server_ext (&ctx, fd, 2);
     }
   if (rc)
     {

Modified: trunk/scd/iso7816.c
===================================================================
--- trunk/scd/iso7816.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/scd/iso7816.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -677,7 +677,7 @@
           unsigned char *p = xtryrealloc (*result, *resultlen + bufferlen);
           if (!p)
             {
-              gpg_error_t err = gpg_error_from_errno (errno);
+              gpg_error_t err = gpg_error_from_syserror ();
               xfree (buffer);
               xfree (*result);
               *result = NULL;

Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,3 +1,8 @@
+2006-09-14  Werner Koch  <wk at g10code.com>
+
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+
 2006-09-13  Werner Koch  <wk at g10code.com>
 
 	* keylist.c (list_internal_keys): Print marker line to FP and not

Modified: trunk/sm/base64.c
===================================================================
--- trunk/sm/base64.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/base64.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -451,7 +451,7 @@
   parm->base64.idx = idx;
   parm->base64.quad_count = quad_count;
 
-  return ferror (fp) ? gpg_error_from_errno (errno) : 0;
+  return ferror (fp) ? gpg_error_from_syserror () : 0;
 }
 
 static int

Modified: trunk/sm/certchain.c
===================================================================
--- trunk/sm/certchain.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/certchain.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -351,7 +351,7 @@
 
   pattern = xtrymalloc (strlen (s)+2);
   if (!pattern)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   strcpy (stpcpy (pattern, "/"), s);
   add_to_strlist (&names, pattern);
   xfree (pattern);

Modified: trunk/sm/export.c
===================================================================
--- trunk/sm/export.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/export.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -117,7 +117,7 @@
   /* Insert that fingerprint. */
   t = xtrymalloc (sizeof *t);
   if (!t)
-    return gpg_error_from_errno (errno);
+    return gpg_error_from_syserror ();
   memcpy (t->fpr, fpr+1, 19);
   t->next = table[idx];
   table[idx] = t;
@@ -558,14 +558,14 @@
   infp = tmpfile ();
   if (!infp)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error creating temporary file: %s\n"), strerror (errno));
       goto cleanup;
     }
 
   if (fwrite (certimg, certimglen, 1, infp) != 1)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error writing to temporary file: %s\n"),
                  strerror (errno));
       goto cleanup;
@@ -574,7 +574,7 @@
   outfp = tmpfile ();
   if (!outfp)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error creating temporary file: %s\n"), strerror (errno));
       goto cleanup;
     }

Modified: trunk/sm/import.c
===================================================================
--- trunk/sm/import.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/import.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -521,7 +521,7 @@
   tmpfp = tmpfile ();
   if (!tmpfp)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error creating temporary file: %s\n"), strerror (errno));
       goto cleanup;
     }
@@ -529,7 +529,7 @@
     {
       if (nread && fwrite (buffer, nread, 1, tmpfp) != 1)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           log_error (_("error writing to temporary file: %s\n"),
                      strerror (errno));
           goto cleanup;
@@ -546,7 +546,7 @@
   certfp = tmpfile ();
   if (!certfp)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       log_error (_("error creating temporary file: %s\n"), strerror (errno));
       goto cleanup;
     }

Modified: trunk/sm/keylist.c
===================================================================
--- trunk/sm/keylist.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/keylist.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1164,7 +1164,7 @@
   desc = xtrycalloc (ndesc, sizeof *desc);
   if (!ndesc)
     {
-      rc = gpg_error_from_errno (errno);
+      rc = gpg_error_from_syserror ();
       log_error ("out of core\n");
       goto leave;
     }

Modified: trunk/sm/qualified.c
===================================================================
--- trunk/sm/qualified.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/sm/qualified.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -70,7 +70,7 @@
       listfp = fopen (listname, "r");
       if (!listfp && errno != ENOENT)
         {
-          err = gpg_error_from_errno (errno);
+          err = gpg_error_from_syserror ();
           log_error (_("can't open `%s': %s\n"), listname, gpg_strerror (err));
           return err;
         }
@@ -85,7 +85,7 @@
         {
           if (feof (listfp))
             return gpg_error (GPG_ERR_EOF);
-          return gpg_error_from_errno (errno);
+          return gpg_error_from_syserror ();
         }
 
       if (!*line || line[strlen(line)-1] != '\n')
@@ -234,7 +234,7 @@
                   "to create or verify such signatures.\n"),
                 opt.qualsig_approval? "":"\n"
                 ) < 0 )
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     err = 0;
 
@@ -251,7 +251,7 @@
   buffer = p = xtrymalloc (strlen (name) * 3 + 1);
   if (!buffer)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       free (name);
       return err;
     }
@@ -324,7 +324,7 @@
                   "Note, that this certificate will NOT create a "
                   "qualified signature!"),
                 subject? subject:"?") < 0 )
-    err = gpg_error_from_errno (errno);
+    err = gpg_error_from_syserror ();
   else
     err = 0;
 
@@ -341,7 +341,7 @@
   buffer = p = xtrymalloc (strlen (name) * 3 + 1);
   if (!buffer)
     {
-      err = gpg_error_from_errno (errno);
+      err = gpg_error_from_syserror ();
       free (name);
       return err;
     }

Modified: trunk/tools/ChangeLog
===================================================================
--- trunk/tools/ChangeLog	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/tools/ChangeLog	2006-09-14 16:50:33 UTC (rev 4249)
@@ -1,5 +1,8 @@
 2006-09-12  Werner Koch  <wk at g10code.com>
 
+ 	Replaced all call gpg_error_from_errno(errno) by
+	gpg_error_from_syserror().
+
 	* gpg-connect-agent.c (read_and_print_response): With verbosity
 	level 2 also print comment lines.
 

Modified: trunk/tools/gpgkey2ssh.c
===================================================================
--- trunk/tools/gpgkey2ssh.c	2006-09-13 15:57:30 UTC (rev 4248)
+++ trunk/tools/gpgkey2ssh.c	2006-09-14 16:50:33 UTC (rev 4249)
@@ -85,7 +85,7 @@
         break; /* EOF. */
       if (i < 0)
 	{
-	  err = gpg_error_from_errno (errno);
+	  err = gpg_error_from_syserror ();
 	  goto leave; /* Error. */
 	}
       if (!max_length)




More information about the Gnupg-commits mailing list