#include "msg.h"
#include "parse.h"
#include "modules.h"
+#include "inline/stringops.h"
static rb_dlink_list safelisting_clients = { NULL, NULL, 0 };
static int m_list(struct Client *, struct Client *, int, const char **);
static int mo_list(struct Client *, struct Client *, int, const char **);
+static void list_one_channel(struct Client *source_p, struct Channel *chptr, int visible);
+
static void safelist_check_cliexit(hook_data_client_exit * hdata);
static void safelist_client_instantiate(struct Client *, struct ListClient *);
static void safelist_client_release(struct Client *);
return 0;
}
+/*
+ * list_one_channel()
+ *
+ * inputs - client pointer, channel pointer, whether normally visible
+ * outputs - none
+ * side effects - a channel is listed
+ */
+static void list_one_channel(struct Client *source_p, struct Channel *chptr,
+ int visible)
+{
+ char topic[TOPICLEN + 1];
+
+ if (chptr->topic != NULL)
+ rb_strlcpy(topic, chptr->topic, sizeof topic);
+ else
+ topic[0] = '\0';
+ strip_colour(topic);
+ sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
+ visible ? "" : "!",
+ chptr->chname, rb_dlink_list_length(&chptr->members),
+ topic);
+}
+
/*
* safelist_sendq_exceeded()
*
{
struct Channel *chptr;
char *p;
+ int visible;
sendto_one(source_p, form_str(RPL_LISTSTART), me.name, source_p->name);
return;
}
- if (!SecretChannel(chptr) || IsMember(source_p, chptr) || operspy)
- sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
- (operspy && SecretChannel(chptr)) ? "!" : "",
- chptr->chname, rb_dlink_list_length(&chptr->members),
- chptr->topic == NULL ? "" : chptr->topic);
+ visible = !SecretChannel(chptr) || IsMember(source_p, chptr);
+ if (visible || operspy)
+ list_one_channel(source_p, chptr, visible);
sendto_one(source_p, form_str(RPL_LISTEND), me.name, source_p->name);
return;
static void safelist_one_channel(struct Client *source_p, struct Channel *chptr)
{
struct ListClient *safelist_data = source_p->localClient->safelist_data;
+ int visible;
- if (SecretChannel(chptr) && !IsMember(source_p, chptr) && !safelist_data->operspy)
+ visible = !SecretChannel(chptr) || IsMember(source_p, chptr);
+ if (!visible && !safelist_data->operspy)
return;
if ((unsigned int)chptr->members.length < safelist_data->users_min
if (safelist_data->created_max && chptr->channelts > safelist_data->created_max)
return;
- sendto_one(source_p, form_str(RPL_LIST), me.name, source_p->name,
- (safelist_data->operspy && SecretChannel(chptr)) ? "!" : "",
- chptr->chname, rb_dlink_list_length(&chptr->members),
- chptr->topic == NULL ? "" : chptr->topic);
+ list_one_channel(source_p, chptr, visible);
}
/*