+/* Parse an invite or ban list */
+void silc_parse_inviteban_list(SilcClient client,
+ SilcClientConnection conn,
+ SILC_SERVER_REC *server,
+ SilcChannelEntry channel,
+ const char *list_type,
+ SilcArgumentPayload list)
+{
+ unsigned char *tmp;
+ SilcUInt32 type, len;
+ SILC_CHANNEL_REC *chanrec = silc_channel_find_entry(server, channel);
+ int counter=0, resolving = FALSE;
+
+ if (!silc_argument_get_arg_num(list)) {
+ printformat_module("fe-common/silc", server,
+ (chanrec ? chanrec->visible_name : NULL),
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_NO_INVITEBAN_LIST,
+ channel->channel_name, list_type);
+ return;
+ }
+
+ printformat_module("fe-common/silc", server,
+ (chanrec ? chanrec->visible_name : NULL),
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_LIST,
+ channel->channel_name, list_type);
+
+ /* parse the list */
+ tmp = silc_argument_get_first_arg(list, &type, &len);
+ while (tmp) {
+ switch (type) {
+ case 1:
+ {
+ /* an invite string */
+ unsigned char **list;
+ int i=0;
+
+ if (tmp[len-1] == ',')
+ tmp[len-1] = '\0';
+
+ list = g_strsplit(tmp, ",", -1);
+ while (list[i])
+ printformat_module("fe-common/silc", server,
+ (chanrec ? chanrec->visible_name : NULL),
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_STRING,
+ ++counter, channel->channel_name, list_type,
+ list[i++]);
+ g_strfreev(list);
+ }
+ break;
+
+ case 2:
+ {
+ /* a public key */
+ char *fingerprint, *babbleprint;
+
+ fingerprint = silc_hash_fingerprint(NULL, tmp, len);
+ babbleprint = silc_hash_fingerprint(NULL, tmp, len);
+
+ printformat_module("fe-common/silc", server,
+ (chanrec ? chanrec->visible_name : NULL),
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_PUBKEY,
+ ++counter, channel->channel_name, list_type,
+ fingerprint, babbleprint);
+ }
+ break;
+
+ case 3:
+ {
+ /* a client ID */
+ SilcClientID *client_id;
+ SilcClientEntry client_entry;
+
+ client_id = silc_id_payload_parse_id(tmp, len, NULL);
+
+ if (client_id == NULL) {
+ silc_say_error("Invalid data in %s list encountered", list_type);
+ break;
+ }
+
+ client_entry = silc_client_get_client_by_id(client, conn, client_id);
+
+ if (client_entry) {
+ printformat_module("fe-common/silc", server,
+ (chanrec ? chanrec->visible_name : NULL),
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_STRING,
+ ++counter, channel->channel_name, list_type,
+ client_entry->nickname);
+ } else {
+ resolving = TRUE;
+ silc_client_get_client_by_id_resolve(client, conn, client_id,
+ NULL, NULL, NULL);
+ }
+
+ silc_free(client_id);
+ }
+ break;
+
+ default:
+ /* "trash" */
+ silc_say_error("Unkown type in %s list: %u (len %u)",
+ list_type, type, len);
+ }
+ tmp = silc_argument_get_next_arg(list, &type, &len);
+ }
+
+ if (resolving)
+ printformat_module("fe-common/silc", server,
+ (chanrec ? chanrec->visible_name : NULL),
+ MSGLEVEL_CRAP, SILCTXT_CHANNEL_INVITEBAN_REGET,
+ list_type, channel->channel_name);
+}
+