static void config_keybind(void) { int i, n; size_t j; struct conf_sec *sec, **ks; struct opt_type *opt; char *cmd; struct keybind *k; /* [keys] */ sec = fetch_section_first(NULL, "keys"); ks = fetch_section(sec, "key"); n = fetch_section_count(ks); SLIST_INIT(&W->h.keybind); /* [key] */ for(i = 0; i < n; ++i) { k = (struct keybind*)xcalloc(1, sizeof(struct keybind)); /* mod = {} */ opt = fetch_opt(ks[i], "", "mod"); for(j = k->mod = 0; j < fetch_opt_count(opt); ++j) k->mod |= modkey_keysym(opt[j].str); free(opt); /* key = */ k->keysym = XStringToKeysym(fetch_opt_first(ks[i], "None", "key").str); /* func = */ if(!(k->func = uicb_name_func(fetch_opt_first(ks[i], "", "func").str))) { warnxl("configuration: Unknown Function \"%s\".", fetch_opt_first(ks[i], "", "func").str); k->func = uicb_spawn; } /* cmd = */ if((cmd = fetch_opt_first(ks[i], "", "cmd").str)) k->cmd = xstrdup(cmd); SLIST_INSERT_HEAD(&W->h.keybind, k, next); } wmfs_grab_keys(); free(ks); }
static void config_server(void) { int i, j, n = 0; struct conf_sec **serv; struct opt_type *opt; ServInfo defsi = { "Hft", "irc.freenode.net", "", 6667, "hftircuser", " ", "HFTIrcuser", "HFTIrcuser"}; if(!(serv = fetch_section(fetch_section_first(NULL, "servers"), "server")) || !(hftirc.conf.nserv = fetch_section_count(serv))) { hftirc.conf.serv = malloc(sizeof(ServInfo)); hftirc.conf.serv[0] = defsi; hftirc.conf.nserv = 1; return; } hftirc.conf.serv = malloc(sizeof(ServInfo) * hftirc.conf.nserv); for(i = 0; i < hftirc.conf.nserv; ++i) { SSTRCPY(hftirc.conf.serv[i].adress, fetch_opt_first(serv[i], "irc.hft-community.org", "adress").str); SSTRCPY(hftirc.conf.serv[i].name, fetch_opt_first(serv[i], hftirc.conf.serv[i].adress, "name").str); SSTRCPY(hftirc.conf.serv[i].password, fetch_opt_first(serv[i], "", "password").str); SSTRCPY(hftirc.conf.serv[i].nick, fetch_opt_first(serv[i], "hftircuser", "nickname").str); SSTRCPY(hftirc.conf.serv[i].username, fetch_opt_first(serv[i], "hftircuser", "username").str); SSTRCPY(hftirc.conf.serv[i].realname, fetch_opt_first(serv[i], "hftircuser", "realname").str); hftirc.conf.serv[i].port = fetch_opt_first(serv[i], "6667", "port").num; hftirc.conf.serv[i].ipv6 = fetch_opt_first(serv[i], "false", "ipv6").boolean; opt = fetch_opt(serv[i], "", "channel_autojoin"); if((n = fetch_opt_count(opt))) { if((hftirc.conf.serv[i].nautojoin = n) > 127) ui_print_buf(0, "HFTIrc configuration: section serv (%d), too many channel_autojoin (%d).", i, n); else for(j = 0; j < n; ++j) SSTRCPY(hftirc.conf.serv[i].autojoin[j], opt[j].str); } } }