5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2003 - 2005 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:
60 SilcClientID client_id;
61 tmp = silc_argument_get_arg_type(args, 2, &len);
64 if (silc_id_payload_parse_id(tmp, len, NULL, &client_id,
67 *ret_arg1 = silc_id_dup(&client_id, SILC_ID_CLIENT);
74 case SILC_STATUS_ERR_NO_SUCH_SERVER_ID:
75 case SILC_STATUS_ERR_BAD_SERVER_ID:
77 SilcServerID server_id;
78 tmp = silc_argument_get_arg_type(args, 2, &len);
81 if (silc_id_payload_parse_id(tmp, len, NULL, &server_id,
84 *ret_arg1 = silc_id_dup(&server_id, SILC_ID_SERVER);
91 case SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID:
92 case SILC_STATUS_ERR_BAD_CHANNEL_ID:
93 case SILC_STATUS_ERR_NOT_ON_CHANNEL:
94 case SILC_STATUS_ERR_CHANNEL_IS_FULL:
95 case SILC_STATUS_ERR_NOT_INVITED:
96 case SILC_STATUS_ERR_BANNED_FROM_CHANNEL:
97 case SILC_STATUS_ERR_NO_CHANNEL_PRIV:
98 case SILC_STATUS_ERR_NO_CHANNEL_FOPRIV:
100 SilcChannelID channel_id;
101 tmp = silc_argument_get_arg_type(args, 2, &len);
104 if (silc_id_payload_parse_id(tmp, len, NULL, &channel_id,
107 *ret_arg1 = silc_id_dup(&channel_id, SILC_ID_CHANNEL);
114 case SILC_STATUS_ERR_USER_NOT_ON_CHANNEL:
115 case SILC_STATUS_ERR_USER_ON_CHANNEL:
117 SilcClientID client_id;
118 SilcChannelID channel_id;
120 tmp = silc_argument_get_arg_type(args, 2, &len);
123 if (silc_id_payload_parse_id(tmp, len, &type, &client_id,
126 *ret_arg1 = silc_id_dup(&client_id, type);
130 tmp = silc_argument_get_arg_type(args, 3, &len);
133 if (silc_id_payload_parse_id(tmp, len, &type, &channel_id,
136 *ret_arg2 = silc_id_dup(&channel_id, type);