Пример #1
0
/**
 * Initialization code to be run after command-line parsing.
 */
int common_init(void)
{
#if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL)
    set_path_env();
#endif
    sanitize_os();

#ifdef CONFIG_PRIORITY
    set_priority();
#endif

    if (codec_path)
        set_codec_path(codec_path);

    /* Check codecs.conf. */
    if (!codecs_file || !parse_codec_cfg(codecs_file)) {
        char *conf_path = get_path("codecs.conf");
        if (!parse_codec_cfg(conf_path)) {
            if (!parse_codec_cfg(MPLAYER_CONFDIR "/codecs.conf")) {
                if (!parse_codec_cfg(NULL)) {
                    free(conf_path);
                    return 0;
                }
                mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_BuiltinCodecsConf);
            }
        }
        free(conf_path);
    }

    // check font
#ifdef CONFIG_FREETYPE
    init_freetype();
#endif
#ifdef CONFIG_FONTCONFIG
    if (font_fontconfig <= 0)
#endif
    {
#ifdef CONFIG_BITMAP_FONT
        if (font_name) {
            vo_font = read_font_desc(font_name, font_factor, verbose>1);
            if (!vo_font)
                mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,
                       filename_recode(font_name));
        } else {
            // try default:
            char *desc_path = get_path("font/font.desc");
            vo_font = read_font_desc(desc_path, font_factor, verbose>1);
            free(desc_path);
            if (!vo_font)
                vo_font = read_font_desc(MPLAYER_DATADIR "/font/font.desc", font_factor, verbose>1);
        }
        if (sub_font_name)
            sub_font = read_font_desc(sub_font_name, font_factor, verbose>1);
        else
            sub_font = vo_font;
#endif
    }

    vo_init_osd();

#ifdef CONFIG_ASS
    ass_library = ass_init();
#endif
    return 1;
}
Пример #2
0
int main (int argc, char **argv)
{
    if (argc <= 1) {
        usage ();
        exit (1);
    }
    
    char *bin_dir = NULL;
    char *config_dir = DEFAULT_CONFIG_DIR;
    char *seafile_dir = NULL;
    char *logfile = NULL;
    char *ccnet_debug_level_str = "info";
    char *seafile_debug_level_str = "debug";
    int daemon_mode = 1;
    gboolean cloud_mode = FALSE;

    int c;
    while ((c = getopt_long (argc, argv, short_opts,
                             long_opts, NULL)) != EOF)
    {
        switch (c) {
        case 'h':
            usage ();
            exit(1);
            break;
        case 'v':
            fprintf (stderr, "seafile-controller version 1.0\n");
            break;
        case 'b':
            bin_dir = optarg;
            break;
        case 'c':
            config_dir = optarg;
            break;
        case 'd':
            seafile_dir = g_strdup(optarg);
            break;
        case 'f':
            daemon_mode = 0;
            break;
        case 'l':
            logfile = g_strdup(optarg);
            break;
        case 'C':
            cloud_mode = TRUE;
            break;
        case 'g':
            ccnet_debug_level_str = optarg;
            break;
        case 'G':
            seafile_debug_level_str = optarg;
            break;
        default:
            usage ();
            exit (1);
        }
    }

    if (daemon_mode)
        daemon (1, 0);

    g_type_init ();
#if !GLIB_CHECK_VERSION(2,32,0)
    g_thread_init (NULL);
#endif

    if (!seafile_dir) {
        seaf_warning ("<seafile_dir> must be specified with --seafile-dir\n");
        controller_exit(1);
    }

    if (bin_dir)
        bin_dir = ccnet_expand_path(bin_dir);

    config_dir = ccnet_expand_path (config_dir);
    seafile_dir = ccnet_expand_path(seafile_dir);

    ctl = g_new0 (SeafileController, 1);
    if (seaf_controller_init (ctl, bin_dir, config_dir, seafile_dir, cloud_mode) < 0) {
        controller_exit(1);
    }

    if (!logfile) {
        logfile = g_build_filename (seafile_dir, "controller.log", NULL);
    }

    if (seafile_log_init (logfile, ccnet_debug_level_str,
                          seafile_debug_level_str) < 0) {
        seaf_warning ("Failed to init log.\n");
        controller_exit (1);
    }

    set_signal_handlers ();

    if (ctl->bin_dir) 
        set_path_env (ctl->bin_dir);

    if (seaf_controller_start (ctl) < 0)
        controller_exit (1);

    run_controller_loop ();

    return 0;
}