struct t_proxy * proxy_new_with_options (const char *name, struct t_config_option *type, struct t_config_option *ipv6, struct t_config_option *address, struct t_config_option *port, struct t_config_option *username, struct t_config_option *password) { struct t_proxy *new_proxy; /* create proxy */ new_proxy = proxy_alloc (name); if (new_proxy) { new_proxy->options[PROXY_OPTION_TYPE] = type; new_proxy->options[PROXY_OPTION_IPV6] = ipv6; new_proxy->options[PROXY_OPTION_ADDRESS] = address; new_proxy->options[PROXY_OPTION_PORT] = port; new_proxy->options[PROXY_OPTION_USERNAME] = username; new_proxy->options[PROXY_OPTION_PASSWORD] = password; /* add proxy to proxies list */ new_proxy->prev_proxy = last_weechat_proxy; if (weechat_proxies) last_weechat_proxy->next_proxy = new_proxy; else weechat_proxies = new_proxy; last_weechat_proxy = new_proxy; new_proxy->next_proxy = NULL; } return new_proxy; }
/** * Initiate global resource. * * Return 0 if success, -1 on error. */ static int _initiate(void) { struct sigaction act; g_maintid = pthread_self(); /* using SIGINT as stop signal */ act.sa_handler = _sig_int; sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_restorer = NULL; if (sigaction(SIGINT, &act, NULL)) ERR_RET(-1, "sigaction error: %s\n", ERRSTR); /* ignore SIGPIPE signal */ act.sa_handler = SIG_IGN; sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_restorer = NULL; if (sigaction(SIGPIPE, &act, NULL)) ERR_RET(-1, "sigaction error: %s\n", ERRSTR); _s_proxy = proxy_alloc(); if (!_s_proxy) ERR_RET(-1, "alloc proxy failed\n"); return 0; }