Changeset - 80816f9517d4
[Not reviewed]
Merge
0 8 0
Jan Kaluza - 13 years ago 2012-09-06 08:43:25
hanzz.k@gmail.com
Merge branch 'master' of github.com:hanzz/libtransport
7 files changed with 71 insertions and 7 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/main.cpp
Show inline comments
 
@@ -1507,59 +1507,61 @@ static void buddyTyped(PurpleAccount *account, const char *who, gpointer null) {
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleBuddyTyped(np->m_accounts[account], w);
 
}
 

	
 
static void buddyTypingStopped(PurpleAccount *account, const char *who, gpointer null){
 
	std::string w = purple_normalize_wrapped(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleBuddyStoppedTyping(np->m_accounts[account], w);
 
}
 

	
 
static void gotAttention(PurpleAccount *account, const char *who, PurpleConversation *conv, guint type) {
 
	std::string w = purple_normalize_wrapped(account, who);
 
	size_t pos = w.find("/");
 
	if (pos != std::string::npos)
 
		w.erase((int) pos, w.length() - (int) pos);
 
	np->handleAttention(np->m_accounts[account], w, "");
 
}
 

	
 
static bool initPurple() {
 
	bool ret;
 

	
 
	if (!resolvePurpleFunctions()) {
 
	std::string libPurpleDllPath = CONFIG_STRING_DEFAULTED(config, "purple.libpurple_dll_path", "");
 

	
 
	if (!resolvePurpleFunctions(libPurpleDllPath)) {
 
		LOG4CXX_ERROR(logger, "Unable to load libpurple.dll or some of the needed methods");
 
		return false;
 
	}
 

	
 
	std::string pluginsDir = CONFIG_STRING_DEFAULTED(config, "purple.plugins_dir", "./plugins");
 
	LOG4CXX_INFO(logger, "Setting libpurple plugins directory to: " << pluginsDir);
 
	purple_plugins_add_search_path_wrapped(pluginsDir.c_str());
 

	
 
	std::string cacertsDir = CONFIG_STRING_DEFAULTED(config, "purple.cacerts_dir", "./ca-certs");
 
	LOG4CXX_INFO(logger, "Setting libpurple plugins directory to: " << cacertsDir);
 
	LOG4CXX_INFO(logger, "Setting libpurple cacerts directory to: " << cacertsDir);
 
	purple_certificate_add_ca_search_path_wrapped(cacertsDir.c_str());
 
 
 
	std::string userDir = CONFIG_STRING_DEFAULTED(config, "service.working_dir", "./");
 
	LOG4CXX_INFO(logger, "Setting libpurple user directory to: " << userDir);
 

	
 
	purple_util_set_user_dir_wrapped(userDir.c_str());
 
	remove("./accounts.xml");
 
	remove("./blist.xml");
 

	
 
	purple_debug_set_ui_ops_wrapped(&debugUiOps);
 
	purple_debug_set_verbose_wrapped(true);
 

	
 
	purple_core_set_ui_ops_wrapped(&coreUiOps);
 
	if (CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev") {
 
		LOG4CXX_INFO(logger, "Will use libev based event loop");
 
	}
 
	else {
 
		LOG4CXX_INFO(logger, "Will use glib based event loop");
 
	}
 
	purple_eventloop_set_ui_ops_wrapped(getEventLoopUiOps(CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev"));
 

	
 
	ret = purple_core_init_wrapped("spectrum");
 
	if (ret) {
 
		static int blist_handle;
backends/libpurple/purple_defs.cpp
Show inline comments
 
#include "purple_defs.h"
 
#include "utils.h"
 

	
 
#if PURPLE_RUNTIME
 

	
 
using std::string;
 
using std::wstring;
 

	
 
static HMODULE f_hPurple = NULL;
 
purple_debug_set_ui_ops_wrapped_fnc purple_debug_set_ui_ops_wrapped = NULL;
 
purple_debug_set_verbose_wrapped_fnc purple_debug_set_verbose_wrapped = NULL;
 
purple_request_set_ui_ops_wrapped_fnc purple_request_set_ui_ops_wrapped = NULL;
 
purple_imgstore_get_data_wrapped_fnc purple_imgstore_get_data_wrapped = NULL;
 
purple_imgstore_get_size_wrapped_fnc purple_imgstore_get_size_wrapped = NULL;
 
purple_imgstore_unref_wrapped_fnc purple_imgstore_unref_wrapped = NULL;
 
purple_markup_escape_text_wrapped_fnc purple_markup_escape_text_wrapped = NULL;
 
purple_markup_strip_html_wrapped_fnc purple_markup_strip_html_wrapped = NULL;
 
purple_normalize_wrapped_fnc purple_normalize_wrapped = NULL;
 
purple_strdup_withhtml_wrapped_fnc purple_strdup_withhtml_wrapped = NULL;
 
purple_markup_html_to_xhtml_wrapped_fnc purple_markup_html_to_xhtml_wrapped = NULL;
 
purple_utf8_try_convert_wrapped_fnc purple_utf8_try_convert_wrapped = NULL;
 
purple_util_set_user_dir_wrapped_fnc purple_util_set_user_dir_wrapped = NULL;
 
purple_blist_node_get_type_wrapped_fnc purple_blist_node_get_type_wrapped = NULL;
 
purple_buddy_get_alias_wrapped_fnc purple_buddy_get_alias_wrapped = NULL;
 
purple_buddy_get_server_alias_wrapped_fnc purple_buddy_get_server_alias_wrapped = NULL;
 
purple_find_buddy_wrapped_fnc purple_find_buddy_wrapped = NULL;
 
purple_buddy_get_group_wrapped_fnc purple_buddy_get_group_wrapped = NULL;
 
purple_blist_remove_buddy_wrapped_fnc purple_blist_remove_buddy_wrapped = NULL;
 
purple_blist_alias_buddy_wrapped_fnc purple_blist_alias_buddy_wrapped = NULL;
 
purple_blist_server_alias_buddy_wrapped_fnc purple_blist_server_alias_buddy_wrapped = NULL;
 
purple_find_group_wrapped_fnc purple_find_group_wrapped = NULL;
 
purple_group_new_wrapped_fnc purple_group_new_wrapped = NULL;
 
@@ -117,51 +122,61 @@ purple_conversations_get_handle_wrapped_fnc purple_conversations_get_handle_wrap
 
purple_plugin_action_free_wrapped_fnc purple_plugin_action_free_wrapped = NULL;
 
purple_plugins_add_search_path_wrapped_fnc purple_plugins_add_search_path_wrapped = NULL;
 
purple_connection_get_state_wrapped_fnc purple_connection_get_state_wrapped = NULL;
 
purple_connection_get_account_wrapped_fnc purple_connection_get_account_wrapped = NULL;
 
purple_connection_get_display_name_wrapped_fnc purple_connection_get_display_name_wrapped = NULL;
 
purple_connections_set_ui_ops_wrapped_fnc purple_connections_set_ui_ops_wrapped = NULL;
 
purple_connections_get_handle_wrapped_fnc purple_connections_get_handle_wrapped = NULL;
 
purple_core_set_ui_ops_wrapped_fnc purple_core_set_ui_ops_wrapped = NULL;
 
purple_core_init_wrapped_fnc purple_core_init_wrapped = NULL;
 
purple_input_add_wrapped_fnc purple_input_add_wrapped = NULL;
 
purple_timeout_add_wrapped_fnc purple_timeout_add_wrapped = NULL;
 
purple_timeout_add_seconds_wrapped_fnc purple_timeout_add_seconds_wrapped = NULL;
 
purple_timeout_remove_wrapped_fnc purple_timeout_remove_wrapped = NULL;
 
purple_eventloop_set_ui_ops_wrapped_fnc purple_eventloop_set_ui_ops_wrapped = NULL;
 
purple_input_remove_wrapped_fnc purple_input_remove_wrapped = NULL;
 
purple_privacy_deny_wrapped_fnc purple_privacy_deny_wrapped = NULL;
 
purple_privacy_allow_wrapped_fnc purple_privacy_allow_wrapped = NULL;
 
purple_privacy_check_wrapped_fnc purple_privacy_check_wrapped = NULL;
 
purple_find_prpl_wrapped_fnc purple_find_prpl_wrapped = NULL;
 
purple_prpl_send_attention_wrapped_fnc purple_prpl_send_attention_wrapped = NULL;
 
purple_account_option_get_type_wrapped_fnc purple_account_option_get_type_wrapped = NULL;
 
purple_account_option_get_setting_wrapped_fnc purple_account_option_get_setting_wrapped = NULL;
 
wpurple_g_io_channel_win32_new_socket_wrapped_fnc wpurple_g_io_channel_win32_new_socket_wrapped = NULL;
 
#endif
 
bool resolvePurpleFunctions() {
 
bool resolvePurpleFunctions(const std::string& libPurpleDllPath) {
 
#if PURPLE_RUNTIME
 
	f_hPurple = LoadLibrary(L"libpurple.dll");
 
	std::wstring dllPath;
 
	if (!libPurpleDllPath.empty())
 
	{
 
		dllPath = utf8ToUtf16(libPurpleDllPath);
 
	}
 
	else
 
	{
 
		// No path was specified, so try loading libpurple from the current working directory
 
		dllPath = L"libpurple.dll";
 
	}
 
	f_hPurple = LoadLibrary(dllPath.c_str());
 
	if (!f_hPurple)
 
			return false;
 
	purple_debug_set_ui_ops_wrapped = (purple_debug_set_ui_ops_wrapped_fnc)GetProcAddress(f_hPurple, "purple_debug_set_ui_ops");
 
	if (!purple_debug_set_ui_ops_wrapped)
 
		return false;
 

	
 
	purple_debug_set_verbose_wrapped = (purple_debug_set_verbose_wrapped_fnc)GetProcAddress(f_hPurple, "purple_debug_set_verbose");
 
	if (!purple_debug_set_verbose_wrapped)
 
		return false;
 

	
 
	purple_request_set_ui_ops_wrapped = (purple_request_set_ui_ops_wrapped_fnc)GetProcAddress(f_hPurple, "purple_request_set_ui_ops");
 
	if (!purple_request_set_ui_ops_wrapped)
 
		return false;
 

	
 
	purple_imgstore_get_data_wrapped = (purple_imgstore_get_data_wrapped_fnc)GetProcAddress(f_hPurple, "purple_imgstore_get_data");
 
	if (!purple_imgstore_get_data_wrapped)
 
		return false;
 

	
 
	purple_imgstore_get_size_wrapped = (purple_imgstore_get_size_wrapped_fnc)GetProcAddress(f_hPurple, "purple_imgstore_get_size");
 
	if (!purple_imgstore_get_size_wrapped)
 
		return false;
 

	
 
	purple_imgstore_unref_wrapped = (purple_imgstore_unref_wrapped_fnc)GetProcAddress(f_hPurple, "purple_imgstore_unref");
 
	if (!purple_imgstore_unref_wrapped)
backends/libpurple/purple_defs.h
Show inline comments
 
#pragma once
 
#include <string>
 

	
 
#if PURPLE_RUNTIME
 

	
 
#include <Windows.h>
 
#include <purple.h>
 

	
 
#define PURPLE_BLIST_NODE_IS_CHAT_WRAPPED(n)    (purple_blist_node_get_type_wrapped(n) == PURPLE_BLIST_CHAT_NODE)
 
#define PURPLE_BLIST_NODE_IS_BUDDY_WRAPPED(n)   (purple_blist_node_get_type_wrapped(n) == PURPLE_BLIST_BUDDY_NODE)
 
#define PURPLE_BLIST_NODE_IS_CONTACT_WRAPPED(n) (purple_blist_node_get_type_wrapped(n) == PURPLE_BLIST_CONTACT_NODE)
 
#define PURPLE_BLIST_NODE_IS_GROUP_WRAPPED(n)   (purple_blist_node_get_type_wrapped(n) == PURPLE_BLIST_GROUP_NODE)
 

	
 
#define PURPLE_CONV_IM_WRAPPED(c) (purple_conversation_get_im_data_wrapped(c))
 
#define PURPLE_CONV_CHAT_WRAPPED(c) (purple_conversation_get_chat_data_wrapped(c))
 

	
 
#define PURPLE_CONNECTION_IS_CONNECTED_WRAPPED(gc) 	(purple_connection_get_state_wrapped(gc) == PURPLE_CONNECTED)
 

	
 
typedef void  (_cdecl * purple_debug_set_ui_ops_wrapped_fnc)(PurpleDebugUiOps *ops);
 
extern purple_debug_set_ui_ops_wrapped_fnc purple_debug_set_ui_ops_wrapped;
 

	
 
typedef void  (_cdecl * purple_debug_set_verbose_wrapped_fnc)(gboolean verbose);
 
extern purple_debug_set_verbose_wrapped_fnc purple_debug_set_verbose_wrapped;
 

	
 
typedef void  (_cdecl * purple_request_set_ui_ops_wrapped_fnc)(PurpleRequestUiOps *ops);
 
extern purple_request_set_ui_ops_wrapped_fnc purple_request_set_ui_ops_wrapped;
 

	
 
@@ -549,26 +551,26 @@ extern wpurple_g_io_channel_win32_new_socket_wrapped_fnc wpurple_g_io_channel_wi
 
#define purple_plugins_add_search_path_wrapped purple_plugins_add_search_path
 
#define purple_connection_get_state_wrapped purple_connection_get_state
 
#define purple_connection_get_account_wrapped purple_connection_get_account
 
#define purple_connection_get_display_name_wrapped purple_connection_get_display_name
 
#define purple_connections_set_ui_ops_wrapped purple_connections_set_ui_ops
 
#define purple_connections_get_handle_wrapped purple_connections_get_handle
 
#define purple_core_set_ui_ops_wrapped purple_core_set_ui_ops
 
#define purple_core_init_wrapped purple_core_init
 
#define purple_input_add_wrapped purple_input_add
 
#define purple_timeout_add_wrapped purple_timeout_add
 
#define purple_timeout_add_seconds_wrapped purple_timeout_add_seconds
 
#define purple_timeout_remove_wrapped purple_timeout_remove
 
#define purple_eventloop_set_ui_ops_wrapped purple_eventloop_set_ui_ops
 
#define purple_input_remove_wrapped purple_input_remove
 
#define purple_privacy_deny_wrapped purple_privacy_deny
 
#define purple_privacy_allow_wrapped purple_privacy_allow
 
#define purple_privacy_check_wrapped purple_privacy_check
 
#define purple_find_prpl_wrapped purple_find_prpl
 
#define purple_prpl_send_attention_wrapped purple_prpl_send_attention
 
#define purple_account_option_get_type_wrapped purple_account_option_get_type
 
#define purple_account_option_get_setting_wrapped purple_account_option_get_setting
 
#define wpurple_g_io_channel_win32_new_socket_wrapped wpurple_g_io_channel_win32_new_socket
 
#endif
 

	
 
bool resolvePurpleFunctions();
 
bool resolvePurpleFunctions(const std::string& libPurpleDllPath);
 

	
backends/libpurple/utils.cpp
Show inline comments
 
@@ -7,74 +7,79 @@
 
 * it under the terms of the GNU General Public License as published by
 
 * the Free Software Foundation; either version 2 of the License, or
 
 * (at your option) any later version.
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
// win32/libc_interface.h defines its own socket(), read() and so on.
 
// We don't want to use it here.
 
#define _LIBC_INTERFACE_H_ 1
 

	
 
#include "utils.h"
 

	
 
#include "glib.h"
 
#include "purple.h"
 
#include <algorithm>
 
#include <iostream>
 
#include <vector>
 

	
 
#include "errno.h"
 

	
 
#ifndef WIN32 
 
#include "sys/wait.h"
 
#include "sys/signal.h"
 
#include <netinet/if_ether.h>
 
#include <netinet/ip.h>
 
#include <netinet/ip6.h>
 
#include <netinet/udp.h>
 
#include <netinet/tcp.h>
 
#include <netinet/ether.h>
 
#include "sys/socket.h"
 
#include <netdb.h>
 
#include <unistd.h>
 
#include <fcntl.h>
 
#else 
 
#include <process.h>
 
#define getpid _getpid 
 
#define ssize_t SSIZE_T
 
#include "win32/win32dep.h"
 
#define close closesocket
 
#endif
 

	
 
#include "purple_defs.h"
 

	
 
#include <boost/numeric/conversion/cast.hpp>
 

	
 
using std::vector;
 

	
 
static GHashTable *ui_info = NULL;
 

	
 
void execute_purple_plugin_action(PurpleConnection *gc, const std::string &name) {
 
	PurplePlugin *plugin = gc && PURPLE_CONNECTION_IS_CONNECTED_WRAPPED(gc) ? gc->prpl : NULL;
 
	if (plugin && PURPLE_PLUGIN_HAS_ACTIONS(plugin)) {
 
		PurplePluginAction *action = NULL;
 
		GList *actions, *l;
 

	
 
		actions = PURPLE_PLUGIN_ACTIONS(plugin, gc);
 

	
 
		for (l = actions; l != NULL; l = l->next) {
 
			if (l->data) {
 
				action = (PurplePluginAction *) l->data;
 
				action->plugin = plugin;
 
				action->context = gc;
 
				if ((std::string) action->label == name) {
 
					action->callback(action);
 
				}
 
				purple_plugin_action_free_wrapped(action);
 
			}
 
		}
 
	}
 
}
 

	
 
@@ -135,24 +140,55 @@ int create_socket(const char *host, int portno) {
 
	
 
	int main_socket = socket(AF_INET, SOCK_STREAM, 0);
 
	memset((char *) &serv_addr, 0, sizeof(serv_addr));
 
	serv_addr.sin_family = AF_INET;
 
	serv_addr.sin_port = htons(portno);
 

	
 
	hostent *hos;  // Resolve name
 
	if ((hos = gethostbyname(host)) == NULL) {
 
		// strerror() will not work for gethostbyname() and hstrerror() 
 
		// is supposedly obsolete
 
		exit(1);
 
	}
 
	serv_addr.sin_addr.s_addr = *((unsigned long *) hos->h_addr_list[0]);
 

	
 
	if (connect(main_socket, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
 
		close(main_socket);
 
		main_socket = 0;
 
	}
 

	
 
// 	int flags = fcntl(main_socket, F_GETFL);
 
// 	flags |= O_NONBLOCK;
 
// 	fcntl(main_socket, F_SETFL, flags);
 
	return main_socket;
 
}
 

	
 
#ifdef _WIN32
 
std::wstring utf8ToUtf16(const std::string& str)
 
{
 
	try
 
	{
 
		if (str.empty())
 
			return L"";
 

	
 
		// First request the size of the required UTF-16 buffer
 
		int numRequiredBytes = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), boost::numeric_cast<int>(str.size()), NULL, 0);
 
		if (!numRequiredBytes)
 
			return L"";
 

	
 
		// Allocate memory for the UTF-16 string
 
		std::vector<wchar_t> utf16Str(numRequiredBytes);
 

	
 
		int numConverted = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), boost::numeric_cast<int>(str.size()), &utf16Str[0], numRequiredBytes);
 
		if (!numConverted)
 
			return L"";
 

	
 
		std::wstring wstr(&utf16Str[0], numConverted);
 
		return wstr;
 
	}
 
	catch (...)
 
	{
 
		// I don't believe libtransport is exception-safe so we'll just return an empty string instead
 
		return L"";
 
	}
 
}
 
#endif // _WIN32
backends/libpurple/utils.h
Show inline comments
 
@@ -10,24 +10,28 @@
 
 *
 
 * This program is distributed in the hope that it will be useful,
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
 * GNU General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU General Public License
 
 * along with this program; if not, write to the Free Software
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#pragma once
 

	
 
#include "purple.h"
 
#include <string>
 

	
 
#ifndef WIN32
 
void spectrum_sigchld_handler(int sig);
 
#endif
 

	
 
int create_socket(const char *host, int portno);
 
GHashTable *spectrum_ui_get_info(void);
 

	
 
void execute_purple_plugin_action(PurpleConnection *gc, const std::string &name);
 

	
 
#ifdef _WIN32
 
	std::wstring utf8ToUtf16(const std::string& str);
 
#endif
cmake_modules/purpleConfig.cmake
Show inline comments
 
FIND_LIBRARY(PURPLE_LIBRARY NAMES purple)
 
FIND_PATH(PURPLE_INCLUDE_DIR NAMES "purple.h" PATH_SUFFIXES libpurple )
 

	
 
if(WIN32 AND PURPLE_INCLUDE_DIR )
 
	if (PURPLE_NOT_RUNTIME)
 
	if (NOT PURPLE_NOT_RUNTIME)
 
		set(PURPLE_LIBRARY "")
 
	endif(PURPLE_NOT_RUNTIME)
 
	endif(NOT PURPLE_NOT_RUNTIME)
 
	set(PURPLE_FOUND 1)
 
	message(STATUS "Using purple: ${PURPLE_INCLUDE_DIR} ${PURPLE_LIBRARY}")
 
else()
 

	
 
if( PURPLE_LIBRARY AND PURPLE_INCLUDE_DIR )
 
    message( STATUS "Found libpurple: ${PURPLE_LIBRARY}, ${PURPLE_INCLUDE_DIR}")
 
    set( PURPLE_FOUND 1 )
 
else( PURPLE_LIBRARY AND PURPLE_INCLUDE_DIR )
 
    message( STATUS "Could NOT find libpurple" )
 
endif( PURPLE_LIBRARY AND PURPLE_INCLUDE_DIR )
 

	
 
endif()
src/config.cpp
Show inline comments
 
@@ -117,48 +117,53 @@ bool Config::load(std::istream &ifs, boost::program_options::options_description
 
		("database.type", value<std::string>()->default_value("none"), "Database type.")
 
		("database.database", value<std::string>()->default_value("/var/lib/spectrum2/$jid/database.sql"), "Database used to store data")
 
		("database.server", value<std::string>()->default_value("localhost"), "Database server.")
 
		("database.user", value<std::string>()->default_value(""), "Database user.")
 
		("database.password", value<std::string>()->default_value(""), "Database Password.")
 
		("database.port", value<int>()->default_value(0), "Database port.")
 
		("database.prefix", value<std::string>()->default_value(""), "Prefix of tables in database")
 
		("database.encryption_key", value<std::string>()->default_value(""), "Encryption key.")
 
		("logging.config", value<std::string>()->default_value(""), "Path to log4cxx config file which is used for Spectrum 2 instance")
 
		("logging.backend_config", value<std::string>()->default_value(""), "Path to log4cxx config file which is used for backends")
 
		("backend.default_avatar", value<std::string>()->default_value(""), "Full path to default avatar")
 
		("backend.avatars_directory", value<std::string>()->default_value(""), "Path to directory with avatars")
 
		("backend.no_vcard_fetch", value<bool>()->default_value(false), "True if VCards for buddies should not be fetched. Only avatars will be forwarded.")
 
		("proxy.server", value<std::string>()->default_value("localhost"), "Proxy IP.")
 
		("proxy.user", value<std::string>()->default_value(""), "Proxy user.")
 
		("proxy.password", value<std::string>()->default_value(""), "Proxy Password.")
 
		("proxy.port", value<int>()->default_value(0), "Proxy port.")
 

	
 
	;
 

	
 
	// Load configs passed by command line
 
	if (m_argc != 0 && m_argv) {
 
		basic_command_line_parser<char> parser = command_line_parser(m_argc, m_argv).options(opts).allow_unregistered();
 
		parsed_options parsed = parser.run();
 
		BOOST_FOREACH(option &opt, parsed.options) {
 
			if (opt.unregistered && !opt.value.empty()) {
 
				m_unregistered[opt.string_key] = variable_value(opt.value[0], false);
 
			}
 
		}
 
		store(parsed, m_variables);
 
	}
 

	
 
	parsed_options parsed = parse_config_file(ifs, opts, true);
 

	
 
	bool found_working = false;
 
	bool found_pidfile = false;
 
	bool found_portfile = false;
 
	bool found_backend_port = false;
 
	bool found_database = false;
 
	std::string jid = "";
 
	BOOST_FOREACH(option &opt, parsed.options) {
 
		if (opt.string_key == "service.jid") {
 
			if (_jid.empty()) {
 
				jid = opt.value[0];
 
			}
 
			else {
 
				opt.value[0] = _jid;
 
				jid = _jid;
 
			}
 
		}
 
		else if (opt.string_key == "service.backend_port") {
 
			found_backend_port = true;
 
			if (opt.value[0] == "0") {
0 comments (0 inline, 0 general)