コード例 #1
0
ファイル: httpClient.c プロジェクト: MessagePlus/httpClient
int main(int argc, char **argv) {
	int cf_index;
	Octstr *filename, *version;

	gwlib_init();
	list_dict = dict_create(32, msg_list_destroy_item);

	cf_index = get_and_set_debugs(argc, argv, check_args);
	setup_signal_handlers();

	if (argv[cf_index] == NULL)
		filename = octstr_create("httpClient.conf");
	else
		filename = octstr_create(argv[cf_index]);

	cfg = cfg_create(filename);

	/* Adding cfg-checks to core */
	cfg_add_hooks(smppbox_is_allowed_in_group, smppbox_is_single_group);

	if (cfg_read(cfg) == -1)
		panic(0, "Couldn't read configuration from `%s'.", octstr_get_cstr(filename));

	octstr_destroy(filename);

	version = octstr_format("httpClient version %s gwlib", GW_VERSION);
	report_versions(octstr_get_cstr(version));
	octstr_destroy(version);

	struct server_type *res = NULL;
	res = sqlbox_init_mysql(cfg);
	sqlbox_configure_mysql(cfg);

	init_smpp_server_box(cfg);
	http_client_box_run();

	//gwthread_join_every(sql_to_smpp);
	//gwthread_join_every(smpp_to_sql);
	smpp_server_box_shutdown();

	dict_destroy(list_dict);
	list_dict = NULL;

	cfg_destroy(cfg);

	if (restart_httpbox) {
		gwthread_sleep(1.0);
	}

	gw_smpp_leave();
	gwlib_shutdown();

	if (restart_httpbox)
		execvp(argv[0], argv);
	return 0;
}
コード例 #2
0
ファイル: sqlbox_sql.c プロジェクト: pruiz/kannel-sqlbox
struct server_type *sqlbox_init_sql(Cfg *cfg)
{
    CfgGroup *grp;
    Octstr *engine;
    struct server_type *res = NULL;

    grp = cfg_get_single_group(cfg, octstr_imm("sqlbox"));
    engine = cfg_get(grp, octstr_imm("sql-engine"));

    if (engine == NULL || octstr_compare(engine, octstr_imm("")) == 0)
        panic(0, "No sql engine defined.");

#ifdef HAVE_MSSQL
    if (octstr_compare(engine, octstr_imm("mssql")) == 0)
        res = (struct server_type *)sqlbox_init_mssql(cfg);

    if (res) {
        return res;
    }
#endif
#ifdef HAVE_MYSQL
    if (octstr_compare(engine, octstr_imm("mysql")) == 0)
         res = (struct server_type *)sqlbox_init_mysql(cfg);

    if (res) {
        return res;
    }
#endif
#ifdef HAVE_ORACLE
    if (octstr_compare(engine, octstr_imm("oracle")) == 0)
         res = (struct server_type *)sqlbox_init_oracle(cfg);

    if (res) {
        return res;
    }
#endif
#ifdef HAVE_PGSQL
    if (octstr_compare(engine, octstr_imm("pgsql")) == 0)
         res = (struct server_type *)sqlbox_init_pgsql(cfg);

    if (res) {
        return res;
    }
#endif
#ifdef HAVE_SDB
    if (octstr_compare(engine, octstr_imm("sdb")) == 0)
         res = (struct server_type *)sqlbox_init_sdb(cfg);

    if (res) {
        return res;
    }
#endif
#ifdef HAVE_SQLITE
    if (octstr_compare(engine, octstr_imm("sqlite")) == 0)
         res = (struct server_type *)sqlbox_init_sqlite(cfg);

    if (res) {
        return res;
    }
#endif
#ifdef HAVE_SQLITE3
    if (octstr_compare(engine, octstr_imm("sqlite")) == 0)
         res = (struct server_type *)sqlbox_init_sqlite3(cfg);

    if (res) {
        return res;
    }
#endif
    return res;
}