Exemplo n.º 1
0
int main(int argc, char **argv)
{
    Editor e;
    GtkWidget *win;
    gtk_init(&argc, &argv);

    if (argc <= 1)
    {
        fprintf(stderr, "usage: %s [-r] <library>\n", argv[0]);
        exit(1);
    }

    if (!strcmp(argv[1], "-r"))
    {
        e.path = argv[2];
        e.library = library_open_recreating(e.path);
    }
    else
    {
        e.path = argv[1];
        e.library = library_open(e.path);
        library_read_prototypes(e.library);
    }
    e.shelf = 0;
    e.record = 0;
    if (!library_shelves_count(e.library))
    {
        fprintf(stderr, "the library %s is empty!\n", e.path);
        exit(1);
    }
    
    create_library_editor(&e);
    update_view(&e);
    win = e.window;
    gtk_window_set_title(GTK_WINDOW(win), e.path);
    g_signal_connect(G_OBJECT(win), "key_press_event", G_CALLBACK(on_key), &e);
    g_signal_connect(G_OBJECT(win), "delete_event", G_CALLBACK(on_quit), &e);
    gtk_widget_show_all(win);
    gtk_main();

    return 0;
}
Exemplo n.º 2
0
Arquivo: musicd.c Projeto: EQ4/musicd
int main(int argc, char* argv[])
{ 
  musicd_start_time = time(NULL);

  config_init();

  config_set_hook("log-level", log_level_changed);
  config_set_hook("log-time-format", log_time_format_changed);
  config_set("log-level", "debug");

  config_set_hook("directory", directory_changed);
  
  config_set("config", "~/.musicd.conf");
  config_set("directory", "~/.musicd");
  config_set("bind", "any");
  config_set("port", "6800");
  
  config_set_hook("image-prefix", scan_image_prefix_changed);
  config_set("image-prefix", "front,cover,jacket");

  config_set("server-name", "musicd server");

  if (config_load_args(argc, argv)) {
    musicd_log(LOG_FATAL, "main", "invalid command line arguments");
    print_usage(argv[0]);
    return -1;
  }
  
  if (config_get_value("help")) {
    print_usage(argv[0]);
    return 0;
  }
  if (config_get_value("version")) {
    print_version();
    return 0;
  }
  
  if (!config_to_bool("no-config")
   && config_load_file(config_to_path("config"))) {
    musicd_log(LOG_FATAL, "main", "could not read config file");
    return -1;
  }
  
  /* Reload command line arguments - this is because the config file might have
   * overwritten them, and the command line has the highest priority. */
  config_load_args(argc, argv);
  
  confirm_directory();
  
  musicd_log(LOG_INFO, "main", "musicd version %s", MUSICD_VERSION_STRING);
  
  srand(time(NULL));

  av_register_all();
  avcodec_register_all();
  av_lockmgr_register(&musicd_av_lockmgr);
  
  av_log_set_level(AV_LOG_QUIET);

  if (db_open()) {
    musicd_log(LOG_FATAL, "library", "can't open database");
    return -1;
  }

  if (library_open()) {
    musicd_log(LOG_FATAL, "main", "could not open library");
    return -1;
  }
  
  if (cache_open()) {
    musicd_log(LOG_FATAL, "main", "could not open cache");
    return -1;
  }
  
  if (server_start()) {
    musicd_log(LOG_FATAL, "main", "could not start server");
    return -1;
  }
  
  signal(SIGUSR1, start_scan_signal);
  scan_start();
  
  while (1) {
    sleep(1);
  }
  
  return 0;
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
    Job job;
    int i;
    FILE *pjf;

    init_job(&job);
    job.core = create_core();
    
    for (i = 1; i < argc; i++)
    {
        char *opt = argv[i];
        char *arg = argv[i + 1];
        if (opt[0] == '-' && strcmp(opt, "-"))
        {
            if (!strcmp(opt, "-L") || !strcmp(opt, "--letter"))
            {
                job.just_one_letter = 1;
                job.just_one_word = 0;
            }
            if (!strcmp(opt, "-t") || !strcmp(opt, "--truth"))
            {
                i++; if (!arg) usage();
                job.just_one_letter = 1;
                job.just_one_word = 0;
                job.ground_truth = arg;
            }
            if (!strcmp(opt, "-a") || !strcmp(opt, "--append"))
            {
                job.append = 1;
            }
            else if (!strcmp(opt, "-W") || !strcmp(opt, "--word"))
            {
                job.just_one_letter = 0;
                job.just_one_word = 1;
            }
            else if (!strcmp(opt, "-l") || !strcmp(opt, "--lib"))
            {
                Library l;
                i++; if (!arg) usage();
                l = library_open(arg);
                library_discard_prototypes(l);
                add_to_core(job.core, l);
            }
            else if (!strcmp(opt, "-p") || !strcmp(opt, "-j") || !strcmp(opt, "--pjf"))
            {
                i++; if (!arg) usage();
                job.job_file_path = arg;
            }
            else if (!strcmp(opt, "-i") || !strcmp(opt, "--in"))
            {
                i++; if (!arg) usage();
                job.input_path = arg;                
            }
            else if (!strcmp(opt, "-o") || !strcmp(opt, "--out"))
            {
                i++; if (!arg) usage();
                set_core_orange_policy(job.core, 1);
                job.out_library_path = arg;
            }
            else if (!strcmp(opt, "-c") || !strcmp(opt, "--color"))
            {
                job.colored_output = 1;
            }
            else if (!strcmp(opt, "-n") || !strcmp(opt, "--nocolor"))
            {
                job.colored_output = 0;
            }
        }
    }


    load_image(&job);

    if (job.just_one_letter)
    {
        process_letter(&job, 0, 0, job.width, job.height);
        putchar('\n');
        if (job.ground_truth && job.out_library_path)
        {
            Library l = get_core_orange_library(job.core);
            if (library_shelves_count(l))
            {
                Shelf *s = library_get_shelf(l, 0);
                if (s->count)
                {
                    strncpy(s->records[0].text, job.ground_truth, MAX_TEXT_SIZE);
                }
            }
        }
    }
    else if (job.just_one_word)
    {
        process_word(&job, 0, 0, job.width, job.height);
        putchar('\n');
    }
    else 
    {
        if (!job.job_file_path)
        {
            fprintf(stderr, "You must specify a pjf file (or either -L or -W).\n");
            usage();
        }
        pjf = fopen(job.job_file_path, "r");
        if (!pjf)
        {
            perror(job.job_file_path);
            exit(1);
        }
        go(&job, pjf);
    }

    if (job.out_library_path)
        library_save(get_core_orange_library(job.core), job.out_library_path, job.append);

    free_bitmap(job.pixels);
    free_core(job.core);
    return 0;
}
Exemplo n.º 4
0
void *SDL_LoadObject(const char *sofile)
{
	return library_open(sofile, sofile);
}