summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/commands.c20
-rw-r--r--src/core/commands.h7
-rw-r--r--src/core/core.c4
-rw-r--r--src/core/memdebug.c19
-rw-r--r--src/core/settings.c23
-rw-r--r--src/core/settings.h4
6 files changed, 40 insertions, 37 deletions
diff --git a/src/core/commands.c b/src/core/commands.c
index 8f02db89..1dfd8b71 100644
--- a/src/core/commands.c
+++ b/src/core/commands.c
@@ -436,8 +436,24 @@ static void cmd_cd(const char *data)
g_free(str);
}
+static void cmd_rehash(const char *data)
+{
+ char *fname;
+
+ fname = *data != '\0' ? g_strdup(data) :
+ g_strdup_printf("%s/.irssi/config", g_get_home_dir());
+ settings_reread(fname);
+ g_free(fname);
+}
+
+static void cmd_save(const char *data)
+{
+ settings_save(*data != '\0' ? data : NULL);
+}
+
void commands_init(void)
{
+ commands = NULL;
cmdget_funcs = NULL;
current_command = NULL;
@@ -448,6 +464,8 @@ void commands_init(void)
command_bind("eval", NULL, (SIGNAL_FUNC) cmd_eval);
command_bind("cd", NULL, (SIGNAL_FUNC) cmd_cd);
+ command_bind("rehash", NULL, (SIGNAL_FUNC) cmd_rehash);
+ command_bind("save", NULL, (SIGNAL_FUNC) cmd_save);
}
void commands_deinit(void)
@@ -459,4 +477,6 @@ void commands_deinit(void)
command_unbind("eval", (SIGNAL_FUNC) cmd_eval);
command_unbind("cd", (SIGNAL_FUNC) cmd_cd);
+ command_unbind("rehash", (SIGNAL_FUNC) cmd_rehash);
+ command_unbind("save", (SIGNAL_FUNC) cmd_save);
}
diff --git a/src/core/commands.h b/src/core/commands.h
index b4577e70..554a60e5 100644
--- a/src/core/commands.h
+++ b/src/core/commands.h
@@ -10,16 +10,11 @@ typedef struct {
COMMAND_REC;
enum {
- CMDERR_PARAM, /* invalid parameter */
+ CMDERR_ERRNO, /* get the error from errno */
CMDERR_NOT_ENOUGH_PARAMS, /* not enough parameters given */
CMDERR_NOT_CONNECTED, /* not connected to IRC server */
CMDERR_NOT_JOINED, /* not joined to any channels in this window */
- CMDERR_GETSOCKNAME, /* getsockname() failed */
- CMDERR_LISTEN, /* listen() failed */
- CMDERR_MULTIPLE_MATCHES, /* multiple matches found, didn't do anything */
- CMDERR_NICK_NOT_FOUND, /* nick not found */
CMDERR_CHAN_NOT_FOUND, /* channel not found */
- CMDERR_SERVER_NOT_FOUND, /* server not found */
CMDERR_CHAN_NOT_SYNCED, /* channel not fully synchronized yet */
CMDERR_NOT_GOOD_IDEA /* not good idea to do, -yes overrides this */
};
diff --git a/src/core/core.c b/src/core/core.c
index c850a572..2102ebcd 100644
--- a/src/core/core.c
+++ b/src/core/core.c
@@ -43,9 +43,9 @@ void core_init(void)
net_disconnect_init();
signals_init();
settings_init();
+ commands_init();
servers_init();
- commands_init();
log_init();
rawlog_init();
special_vars_init();
@@ -56,9 +56,9 @@ void core_deinit(void)
special_vars_deinit();
rawlog_deinit();
log_deinit();
- commands_deinit();
servers_deinit();
+ commands_deinit();
settings_deinit();
signals_deinit();
net_disconnect_deinit();
diff --git a/src/core/memdebug.c b/src/core/memdebug.c
index 1be7bbd8..fcd92659 100644
--- a/src/core/memdebug.c
+++ b/src/core/memdebug.c
@@ -132,35 +132,26 @@ static void *data_remove(void *p, const char *file, int line)
void *ig_malloc(int size, const char *file, int line)
{
-#if 1
void *p;
size += BUFFER_CHECK_SIZE*2;
p = g_malloc(size);
data_add(p, size, file, line);
return p+BUFFER_CHECK_SIZE;
-#else
- return g_malloc(size);
-#endif
}
void *ig_malloc0(int size, const char *file, int line)
{
-#if 1
void *p;
size += BUFFER_CHECK_SIZE*2;
p = g_malloc0(size);
data_add(p, size, file, line);
return p+BUFFER_CHECK_SIZE;
-#else
- return g_malloc0(size);
-#endif
}
void *ig_realloc(void *mem, unsigned long size, const char *file, int line)
{
-#if 1
void *p;
size += BUFFER_CHECK_SIZE*2;
@@ -169,9 +160,6 @@ void *ig_realloc(void *mem, unsigned long size, const char *file, int line)
p = g_realloc(mem, size);
data_add(p, size, file, line);
return p+BUFFER_CHECK_SIZE;
-#else
- return g_realloc(mem, size);
-#endif
}
char *ig_strdup(const char *str, const char *file, int line)
@@ -264,12 +252,11 @@ char *ig_strdup_vprintf(const char *file, int line, const char *format, va_list
void ig_free(void *p)
{
-#if 1
+ if (p == NULL) g_error("ig_free() : trying to free NULL");
+
p -= BUFFER_CHECK_SIZE;
p = data_remove(p, "??", 0);
- if (p != NULL)
-#endif
- g_free(p);
+ if (p != NULL) g_free(p);
}
GString *ig_string_new(const char *file, int line, const char *str)
diff --git a/src/core/settings.c b/src/core/settings.c
index a7e27a63..5133dd6b 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -21,6 +21,7 @@
#include "module.h"
#include "signals.h"
#include "commands.h"
+#include "misc.h"
#include "lib-config/iconfig.h"
#include "settings.h"
@@ -278,15 +279,16 @@ static void init_configfile(void)
signal(SIGTERM, sig_term);
}
-static void cmd_rehash(const char *data)
+void settings_reread(const char *fname)
{
CONFIG_REC *tempconfig;
- char *str, *fname;
+ char *str;
- fname = *data != '\0' ? g_strdup(data) :
- g_strdup_printf("%s/.irssi/config", g_get_home_dir());
- tempconfig = parse_configfile(fname);
- g_free(fname);
+ if (fname == NULL) fname = "~/.irssi/config";
+
+ str = convert_home(fname);
+ tempconfig = parse_configfile(str);
+ g_free(str);
if (tempconfig == NULL) {
signal_emit("gui dialog", 2, "error", g_strerror(errno));
@@ -310,11 +312,11 @@ static void cmd_rehash(const char *data)
signal_emit("setup reread", 0);
}
-static void cmd_save(const char *data)
+void settings_save(const char *fname)
{
char *str;
- if (config_write(mainconfig, *data == '\0' ? NULL : data, 0660) == 0)
+ if (config_write(mainconfig, fname, 0660) == 0)
return;
/* error */
@@ -329,8 +331,6 @@ void settings_init(void)
settings = g_hash_table_new((GHashFunc) g_str_hash, (GCompareFunc) g_str_equal);
init_configfile();
- command_bind("rehash", NULL, (SIGNAL_FUNC) cmd_rehash);
- command_bind("save", NULL, (SIGNAL_FUNC) cmd_save);
}
static void settings_hash_free(const char *key, SETTINGS_REC *rec)
@@ -340,9 +340,6 @@ static void settings_hash_free(const char *key, SETTINGS_REC *rec)
void settings_deinit(void)
{
- command_unbind("rehash", (SIGNAL_FUNC) cmd_rehash);
- command_unbind("save", (SIGNAL_FUNC) cmd_save);
-
g_free_not_null(last_error_msg);
g_hash_table_foreach(settings, (GHFunc) settings_hash_free, NULL);
g_hash_table_destroy(settings);
diff --git a/src/core/settings.h b/src/core/settings.h
index 6f29de6e..583e0dd6 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -53,6 +53,10 @@ GSList *settings_get_sorted(void);
/* Get the record of the setting */
SETTINGS_REC *settings_get_record(const char *key);
+/* if `fname' is NULL, the default is used */
+void settings_reread(const char *fname);
+void settings_save(const char *fname);
+
void settings_init(void);
void settings_deinit(void);