Exemple #1
0
int main(int argc, char **argv) {
    sxc_client_t *sx;
    sxc_logger_t log;
    struct gengetopt_args_info args;
    char file[1024];
    const char *filter_dir;

    if(cmdline_parser(argc, argv, &args))
	return 1;

    if(args.version_given) {
	printf("%s %s\n", CMDLINE_PARSER_PACKAGE, SRC_VERSION);
	cmdline_parser_free(&args);
	return 0;
    }

    if(args.output_given)
        snprintf(file, sizeof(file), "%s", args.output_arg);
    else
	snprintf(file, sizeof(file), "sxreport-client-%ld.log", (long)time(NULL));

    umask(077);
    if(!(sx = sxc_init(SRC_VERSION, sxc_file_logger(&log, argv[0], file, 1), NULL, NULL))) {
	cmdline_parser_free(&args);
	return 1;
    }
    if(args.config_dir_given && sxc_set_confdir(sx, args.config_dir_arg)) {
        cmdline_parser_free(&args);
        sxc_shutdown(sx, 0);
        return 1;
    }
    sxc_set_verbose(sx, 1);

    filter_dir = get_filter_dir(sx, args.filter_dir_arg);
    if(sxc_filter_loadall(sx, filter_dir)) {
        cmdline_parser_free(&args);
        sxc_shutdown(sx, 0);
        return 1;
    }
    sxi_report_build_info(sx);
#define INFO_PKGCONFIG ""
#define INFO_PKGCONFIG_LIBDIR ""
#define INFO_PKGCONFIG_PATH ""
    sxi_report_build_flags(sx);
    sxi_report_library_versions(sx, SRC_VERSION);
    sxi_report_system_info(sx);
    sxi_report_limits(sx);
    sxi_report_section(sx, "Filters");
    sxi_info(sx,"Default filter directory: %s\n", SX_FILTER_DIR);
    sxi_info(sx,"Current filter directory: %s\n", filter_dir);
    filter_list(sx);
    sxi_report_configuration(sx, args.config_dir_arg);
    printf("Report stored in %s\n", file);
    printf("You can attach it to a bugreport at %s\n", PACKAGE_BUGREPORT);
    cmdline_parser_free(&args);
    sxc_shutdown(sx, 0);
    return 0;
}
Exemple #2
0
/* FIXME make the output stream settable, default to stderr */
void sxc_set_debug(sxc_client_t *sx, int enabled) {
    if (!sx)
        return;
    if(enabled) {
        sxi_log_enable_level(&sx->log, SX_LOG_DEBUG);
	SXDEBUG("Debug mode is now enabled");
    } else {
        if (sxi_log_is_debug(&sx->log))
	    SXDEBUG("Debug mode is now disabled");
        sxc_set_verbose(sx, sx->verbose);
    }
}
Exemple #3
0
sxc_client_t* server_init(const sxc_logger_t *custom_logger, const char *application, const char *logfile, int log_foreground, int argc, char *argv[])
{
    sxc_client_t *sx;
    log_init(&custom_logger, application ? application : argv[0], logfile, log_foreground);
    sx = sxc_init(src_version(), custom_logger, NULL);
    if (!sx) {
        CRIT("Cannot initialize SX");
        return NULL;
    }
    sxc_set_verbose(sx, 1);
    ERR_load_crypto_strings();
    if (application) {
        sxprocinit(argc, argv);
        sxsetproctitle(application);
    }
    return sx;
}