Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "core.h"
#include "module.h"
#include "modules.h"
#include "signals.h"
static EXPANDO_REC *char_expandos[255];
static GHashTable *expandos;
-static time_t client_start_time;
static char *last_sent_msg, *last_sent_msg_body;
static char *last_privmsg_from, *last_public_from;
static char *sysname, *sysrelease, *sysarch;
/* Destroy expando */
void expando_destroy(const char *key, EXPANDO_FUNC func)
{
- gpointer origkey;
+ gpointer origkey, value;
EXPANDO_REC *rec;
g_return_if_fail(key != NULL || *key == '\0');
char_expandos[(int) (unsigned char) *key] = NULL;
g_free(rec);
}
- } else if (g_hash_table_lookup_extended(expandos, key, &origkey,
- (gpointer *) &rec)) {
+ } else if (g_hash_table_lookup_extended(expandos, key,
+ &origkey, &value)) {
+ rec = value;
if (rec->func == func) {
g_hash_table_remove(expandos, key);
g_free(origkey);
return rec == NULL ? NULL : rec->func;
}
+static gboolean free_expando(gpointer key, gpointer value, gpointer user_data)
+{
+ g_free(key);
+ g_free(value);
+ return TRUE;
+}
+
/* last person who sent you a MSG */
static char *expando_lastmsg(SERVER_REC *server, void *item, int *free_ret)
{
/* modes of current channel, if any */
static char *expando_chanmode(SERVER_REC *server, void *item, int *free_ret)
-{
- return !IS_CHANNEL(item) ? NULL : CHANNEL(item)->mode;
+{
+ char *cmode;
+
+ *free_ret = FALSE;
+
+ if (!IS_CHANNEL(item))
+ return NULL;
+
+ if (!settings_get_bool("chanmode_expando_strip"))
+ return CHANNEL(item)->mode;
+
+ *free_ret = TRUE;
+ cmode = g_strdup(CHANNEL(item)->mode);
+ if (strchr(cmode, ' ') != NULL)
+ *(strchr(cmode, ' ')) = 0;
+
+ return cmode;
}
/* current nickname */
#endif
settings_add_str("misc", "STATUS_OPER", "*");
settings_add_str("lookandfeel", "timestamp_format", "%H:%M");
+ settings_add_bool("lookandfeel", "chanmode_expando_strip", FALSE);
- client_start_time = time(NULL);
last_sent_msg = NULL; last_sent_msg_body = NULL;
last_privmsg_from = NULL; last_public_from = NULL;
last_timestamp = 0;
for (n = 0; n < sizeof(char_expandos)/sizeof(char_expandos[0]); n++)
g_free_not_null(char_expandos[n]);
- expando_destroy("sysname", expando_sysname);
- expando_destroy("sysrelease", expando_sysrelease);
- expando_destroy("sysarch", expando_sysarch);
- expando_destroy("topic", expando_topic);
- expando_destroy("tag", expando_servertag);
- expando_destroy("chatnet", expando_chatnet);
-
+ g_hash_table_foreach_remove(expandos, free_expando, NULL);
g_hash_table_destroy(expandos);
g_free_not_null(last_sent_msg); g_free_not_null(last_sent_msg_body);