~ubuntu-branches/ubuntu/hardy/gnupg/hardy-updates

« back to all changes in this revision

Viewing changes to util/assuan-errors.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2005-12-16 16:57:39 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051216165739-v0m2d1you6hd8jho
Tags: upstream-1.4.2
ImportĀ upstreamĀ versionĀ 1.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* assuan-errors.c - error codes
 
2
 *      Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
3
 *      Copyright (C) 2005 Free Software Foundation, Inc.
 
4
 *
 
5
 * This file is part of Assuan.
 
6
 *
 
7
 * Assuan is free software; you can redistribute it and/or modify it
 
8
 * under the terms of the GNU Lesser General Public License as
 
9
 * published by the Free Software Foundation; either version 2.1 of
 
10
 * the License, or (at your option) any later version.
 
11
 *
 
12
 * Assuan is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
 
20
 * USA. 
 
21
 */
 
22
 
 
23
/* Please note that this is a stripped down and modified version of
 
24
   the orginal Assuan code from libassuan. */ 
 
25
 
 
26
#include <stdio.h>
 
27
#include "assuan.h"
 
28
 
 
29
/* This function returns a textual representaion of the given error
 
30
   code.  If this is an unknown value, a string with the value is
 
31
   returned (Beware: it is hold in a static buffer).  Return value:
 
32
   String with the error description.
 
33
 */
 
34
const char *
 
35
assuan_strerror (assuan_error_t err)
 
36
{
 
37
  const char *s;
 
38
  static char buf[50];
 
39
 
 
40
  switch (err)
 
41
    {
 
42
    case ASSUAN_No_Error: s="no error"; break;
 
43
    case ASSUAN_General_Error: s="general error"; break;
 
44
    case ASSUAN_Out_Of_Core: s="out of core"; break;
 
45
    case ASSUAN_Invalid_Value: s="invalid value"; break;
 
46
    case ASSUAN_Timeout: s="timeout"; break;
 
47
    case ASSUAN_Read_Error: s="read error"; break;
 
48
    case ASSUAN_Write_Error: s="write error"; break;
 
49
    case ASSUAN_Problem_Starting_Server: s="problem starting server"; break;
 
50
    case ASSUAN_Not_A_Server: s="not a server"; break;
 
51
    case ASSUAN_Not_A_Client: s="not a client"; break;
 
52
    case ASSUAN_Nested_Commands: s="nested commands"; break;
 
53
    case ASSUAN_Invalid_Response: s="invalid response"; break;
 
54
    case ASSUAN_No_Data_Callback: s="no data callback"; break;
 
55
    case ASSUAN_No_Inquire_Callback: s="no inquire callback"; break;
 
56
    case ASSUAN_Connect_Failed: s="connect failed"; break;
 
57
    case ASSUAN_Accept_Failed: s="accept failed"; break;
 
58
    case ASSUAN_Not_Implemented: s="not implemented"; break;
 
59
    case ASSUAN_Server_Fault: s="server fault"; break;
 
60
    case ASSUAN_Invalid_Command: s="invalid command"; break;
 
61
    case ASSUAN_Unknown_Command: s="unknown command"; break;
 
62
    case ASSUAN_Syntax_Error: s="syntax error"; break;
 
63
    case ASSUAN_Parameter_Error: s="parameter error"; break;
 
64
    case ASSUAN_Parameter_Conflict: s="parameter conflict"; break;
 
65
    case ASSUAN_Line_Too_Long: s="line too long"; break;
 
66
    case ASSUAN_Line_Not_Terminated: s="line not terminated"; break;
 
67
    case ASSUAN_No_Input: s="no input"; break;
 
68
    case ASSUAN_No_Output: s="no output"; break;
 
69
    case ASSUAN_Canceled: s="canceled"; break;
 
70
    case ASSUAN_Unsupported_Algorithm: s="unsupported algorithm"; break;
 
71
    case ASSUAN_Server_Resource_Problem: s="server resource problem"; break;
 
72
    case ASSUAN_Server_IO_Error: s="server io error"; break;
 
73
    case ASSUAN_Server_Bug: s="server bug"; break;
 
74
    case ASSUAN_No_Data_Available: s="no data available"; break;
 
75
    case ASSUAN_Invalid_Data: s="invalid data"; break;
 
76
    case ASSUAN_Unexpected_Command: s="unexpected command"; break;
 
77
    case ASSUAN_Too_Much_Data: s="too much data"; break;
 
78
    case ASSUAN_Inquire_Unknown: s="inquire unknown"; break;
 
79
    case ASSUAN_Inquire_Error: s="inquire error"; break;
 
80
    case ASSUAN_Invalid_Option: s="invalid option"; break;
 
81
    case ASSUAN_Invalid_Index: s="invalid index"; break;
 
82
    case ASSUAN_Unexpected_Status: s="unexpected status"; break;
 
83
    case ASSUAN_Unexpected_Data: s="unexpected data"; break;
 
84
    case ASSUAN_Invalid_Status: s="invalid status"; break;
 
85
    case ASSUAN_Locale_Problem: s="locale problem"; break;
 
86
    case ASSUAN_Not_Confirmed: s="not confirmed"; break;
 
87
    case ASSUAN_USER_ERROR_FIRST: s="user error first"; break;
 
88
    case ASSUAN_USER_ERROR_LAST: s="user error last"; break;
 
89
    default: 
 
90
      {
 
91
        unsigned int source, code;
 
92
 
 
93
        source = ((err >> 24) & 0xff);
 
94
        code = (err & 0x00ffffff);
 
95
        if (source) /* Assume this is an libgpg-error. */
 
96
          sprintf (buf, "ec=%u.%u", source, code ); 
 
97
        else
 
98
          sprintf (buf, "ec=%d", err ); 
 
99
        s=buf; break;
 
100
      }
 
101
    }
 
102
 
 
103
  return s;
 
104
}
 
105