#include <getopt.h>
#include "config.h"
+#include "save-config.h"
#include "browsers.h"
extern struct swb_config_option swb_config_options[];
}
static int set_config_value(char *name, char *value) {
- struct swb_config cfg;
+ struct swb_config orig_cfg, cfg;
struct swb_config_option *optinfo;
ptrdiff_t i;
int retval = 1;
- swb_config_init(&cfg);
+ swb_config_init(&orig_cfg);
- if (!swb_config_load(&cfg))
+ if (!swb_config_load(&orig_cfg))
return 1;
+ swb_config_copy(&cfg, &orig_cfg);
+
for (optinfo = swb_config_options; optinfo->name; ++optinfo) {
if (strcmp(name, optinfo->name))
continue;
i = optinfo - swb_config_options;
switch (optinfo->type) {
case SWB_CONFIG_OPT_STRING:
- /* Free any existing string */
- if (cfg.flags & optinfo->set_mask)
- free(*(char **)cfg.entries[i]);
-
if (strlen(value) == 0) {
/* If the new value is empty, clear the config
setting */
if (!swb_config_save(&cfg))
retval = 1;
- swb_config_free(&cfg);
+ /* Reconfigure a running browser-switchboard, if present */
+ swb_reconfig(&orig_cfg, &cfg);
- /* Try to send SIGHUP to any running browser-switchboard process
- This causes it to reread config files if in continuous_mode, or
- die so that the config will be reloaded on next start otherwise */
- system("kill -HUP `pidof browser-switchboard` > /dev/null 2>&1");
+ swb_config_free(&orig_cfg);
+ /* XXX can't free all of cfg, it contains pointers to memory we just
+ freed above
+ swb_config_free(&cfg); */
+ if (optinfo->name && optinfo->type == SWB_CONFIG_OPT_STRING)
+ free(*(char **)cfg.entries[i]);
return retval;
}