File: error.c

package info (click to toggle)
meanwhile 1.0.2-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,732 kB
  • ctags: 3,503
  • sloc: ansic: 13,856; sh: 8,360; makefile: 145
file content (97 lines) | stat: -rw-r--r-- 3,528 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

/*
  Meanwhile - Unofficial Lotus Sametime Community Client Library
  Copyright (C) 2004  Christopher (siege) O'Brien
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.
  
  This library 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
  Library General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <stdio.h>
#include <string.h>

#include "mw_error.h"


static char *err_to_str(guint32 code) {
  static char b[11]; /* 0x12345678 + NULL terminator */
  sprintf((char *) b, "0x%08x", code);
  b[10] = '\0';
  return b;
}


#define CASE(val, str) \
case val: \
  m = str; \
  break;


char* mwError(guint32 code) {
  const char *m;

  switch(code) {

    /* 8.3.1.1 General error/success codes */
    CASE(ERR_SUCCESS, "Success");
    CASE(ERR_FAILURE, "General failure");
    CASE(ERR_REQUEST_DELAY, "Request delayed");
    CASE(ERR_REQUEST_INVALID, "Request is invalid");
    CASE(ERR_NOT_AUTHORIZED, "Not authorized");
    CASE(ERR_NO_USER, "User is not online");
    CASE(ERR_CHANNEL_NO_SUPPORT, "Requested channel is not supported");
    CASE(ERR_CHANNEL_EXISTS, "Requested channel already exists");
    CASE(ERR_SERVICE_NO_SUPPORT, "Requested service is not supported");
    CASE(ERR_PROTOCOL_NO_SUPPORT, "Requested protocol is not supported");
    CASE(ERR_VERSION_NO_SUPPORT, "Version is not supported");
    CASE(ERR_USER_SKETCHY, "User is invalid or not trusted");
    CASE(ERR_ALREADY_INITIALIZED, "Already initialized");
    CASE(ERR_ENCRYPT_NO_SUPPORT, "Encryption method not supported");
    CASE(ERR_NO_COMMON_ENCRYPT, "No common encryption method");
    
    /* 8.3.1.2 Connection/disconnection errors */
    CASE(VERSION_MISMATCH, "Version mismatch");
    CASE(FAT_MESSAGE, "Message is too large");
    CASE(CONNECTION_BROKEN, "Connection broken");
    CASE(CONNECTION_ABORTED, "Connection aborted");
    CASE(CONNECTION_REFUSED, "Connection refused");
    CASE(CONNECTION_RESET, "Connection reset");
    CASE(CONNECTION_TIMED, "Connection timed out");
    CASE(CONNECTION_CLOSED, "Connection closed");
    CASE(INCORRECT_LOGIN, "Incorrect Username/Password");
    CASE(VERIFICATION_DOWN, "Login verification down or unavailable");
    CASE(GUEST_IN_USE, "The guest name is currently being used");
    CASE(MULTI_SERVER_LOGIN, "Login to two different servers concurrently");
    CASE(MULTI_SERVER_LOGIN2, "Login to two different servers concurrently");
    CASE(SERVER_BROKEN, "Server misconfiguration");

    /* 8.3.1.3 Client error codes */
    CASE(ERR_CLIENT_USER_GONE, "User is not online");
    CASE(ERR_CLIENT_USER_DND, "User is in Do Not Disturb mode");
    CASE(ERR_CLIENT_USER_ELSEWHERE, "Already logged in elsewhere");

    /* 8.3.1.4 IM error codes */
    CASE(ERR_IM_COULDNT_REGISTER, "Cannot register a reserved type");
    CASE(ERR_IM_ALREADY_REGISTERED, "Requested type is already registered");
    CASE(ERR_IM_NOT_REGISTERED, "Requested type is not registered");

  default:
    m = err_to_str(code);
  }

  return g_strdup(m);
}


#undef CASE