LCOV - code coverage report
Current view: top level - src - assuan-error.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 3 5 60.0 %
Date: 2016-11-29 14:54:18 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* assuan-error.c
       2             :    Copyright (C) 2009 Free Software Foundation, Inc.
       3             : 
       4             :    This file is part of Assuan.
       5             : 
       6             :    Assuan is free software; you can redistribute it and/or modify it
       7             :    under the terms of the GNU Lesser General Public License as
       8             :    published by the Free Software Foundation; either version 2.1 of
       9             :    the License, or (at your option) any later version.
      10             : 
      11             :    Assuan is distributed in the hope that it will be useful, but
      12             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :    Lesser General Public License for more details.
      15             : 
      16             :    You should have received a copy of the GNU Lesser General Public
      17             :    License along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : #ifdef HAVE_CONFIG_H
      21             : #include <config.h>
      22             : #endif
      23             : 
      24             : #include <stdio.h>
      25             : #include <assert.h>
      26             : #include <errno.h>
      27             : 
      28             : #undef _ASSUAN_IN_LIBASSUAN /* undef to get all error codes. */
      29             : #include "assuan.h"
      30             : #include "assuan-defs.h"
      31             : 
      32             : 
      33             : /* A small helper function to treat EAGAIN transparently to the
      34             :    caller.  */
      35             : int
      36          38 : _assuan_error_is_eagain (assuan_context_t ctx, gpg_error_t err)
      37             : {
      38          38 :   if (gpg_err_code (err) == GPG_ERR_EAGAIN)
      39             :     {
      40             :       /* Avoid spinning by sleeping for one tenth of a second.  */
      41           0 :       _assuan_usleep (ctx, 100000);
      42           0 :       return 1;
      43             :     }
      44             :   else
      45          38 :     return 0;
      46             : }
      47             : 
      48             : 
      49             : 
      50             : #ifdef HAVE_W32_SYSTEM
      51             : char *
      52             : _assuan_w32_strerror (assuan_context_t ctx, int ec)
      53             : {
      54             :   if (ec == -1)
      55             :     ec = (int)GetLastError ();
      56             : #ifdef HAVE_W32CE_SYSTEM
      57             :   snprintf (ctx->w32_strerror, sizeof (ctx->w32_strerror) - 1,
      58             :             "ec=%d", (int)GetLastError ());
      59             : #else
      60             :   FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, ec,
      61             :                  MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
      62             :                  ctx->w32_strerror, sizeof (ctx->w32_strerror) - 1, NULL);
      63             : #endif
      64             :   return ctx->w32_strerror;
      65             : }
      66             : #endif
      67             : 

Generated by: LCOV version 1.11