5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2003 - 2006 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
22 #include "silcstatus.h"
24 /* Returns arguments by the status type. */
26 SilcUInt32 silc_status_get_args(SilcStatus status,
27 SilcArgumentPayload args,
28 void **ret_arg1, void **ret_arg2)
33 assert(ret_arg1 && ret_arg2);
35 num = silc_argument_get_arg_num(args);
43 case SILC_STATUS_ERR_NO_SUCH_NICK:
44 case SILC_STATUS_ERR_NO_SUCH_CHANNEL:
45 case SILC_STATUS_ERR_NO_SUCH_SERVER:
46 case SILC_STATUS_ERR_NO_SUCH_SERVICE:
47 case SILC_STATUS_ERR_UNKNOWN_ALGORITHM:
48 tmp = silc_argument_get_arg_type(args, 2, &len);
51 *ret_arg1 = silc_memdup(tmp, len);
57 case SILC_STATUS_ERR_NO_SUCH_CLIENT_ID:
58 case SILC_STATUS_ERR_BAD_CLIENT_ID:
61 tmp = silc_argument_get_arg_type(args, 2, &len);
64 if (silc_id_payload_parse_id(tmp, len, &id))
66 *ret_arg1 = silc_id_dup(&id.u.client_id, SILC_ID_CLIENT);
73 case SILC_STATUS_ERR_NO_SUCH_SERVER_ID:
74 case SILC_STATUS_ERR_BAD_SERVER_ID:
77 tmp = silc_argument_get_arg_type(args, 2, &len);
80 if (silc_id_payload_parse_id(tmp, len, &id))
82 *ret_arg1 = silc_id_dup(&id.u.server_id, SILC_ID_SERVER);
89 case SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID:
90 case SILC_STATUS_ERR_BAD_CHANNEL_ID:
91 case SILC_STATUS_ERR_NOT_ON_CHANNEL:
92 case SILC_STATUS_ERR_CHANNEL_IS_FULL:
93 case SILC_STATUS_ERR_NOT_INVITED:
94 case SILC_STATUS_ERR_BANNED_FROM_CHANNEL:
95 case SILC_STATUS_ERR_NO_CHANNEL_PRIV:
96 case SILC_STATUS_ERR_NO_CHANNEL_FOPRIV:
99 tmp = silc_argument_get_arg_type(args, 2, &len);
102 if (silc_id_payload_parse_id(tmp, len, &id))
104 *ret_arg1 = silc_id_dup(&id.u.channel_id, SILC_ID_CHANNEL);
111 case SILC_STATUS_ERR_USER_NOT_ON_CHANNEL:
112 case SILC_STATUS_ERR_USER_ON_CHANNEL:
115 tmp = silc_argument_get_arg_type(args, 2, &len);
118 if (silc_id_payload_parse_id(tmp, len, &id))
120 *ret_arg1 = silc_id_dup(&id.u.client_id, id.type);
124 tmp = silc_argument_get_arg_type(args, 3, &len);
127 if (silc_id_payload_parse_id(tmp, len, &id))
129 *ret_arg2 = silc_id_dup(&id.u.channel_id, id.type);