예제 #1
0
void glk_main(void)
{
  z_file *story_stream;

  if (init_err) {
    glkint_fatal_error_handler(init_err, NULL, init_err2, FALSE, 0);
    return;
  }

  set_configuration_value("savegame-path", NULL);
  /*set_configuration_value("transcript-filename", "transcript.txt");*/
  set_configuration_value("savegame-default-filename", "");

  fizmo_register_screen_interface(&glkint_screen_interface);
  fizmo_register_blorb_interface(&glkint_blorb_interface);

  story_stream = glkint_open_interface(&glkunix_open_game_stream);
  if (!story_stream)
    return;
  fizmo_start(story_stream, NULL, NULL, -1, -1);

#ifdef ENABLE_TRACING
  turn_off_trace();
#endif // ENABLE_TRACING
}
예제 #2
0
파일: config.c 프로젝트: dfjdejulio/fizmo
int append_path_value(char *key, char *value_to_append)
{
  char *str, *str2;
  int result;

  if ((str = get_configuration_value(key)) != NULL)
  {
    str2 = fizmo_malloc(strlen(str) + strlen(value_to_append) + 2);
    strcpy(str2, str);
    strcat(str2, ":");
    strcat(str2, value_to_append);
    TRACE_LOG("Appended path: %s.\n", str2);
    result = set_configuration_value(key, str2);
    free(str2);
    return result;
  }
  else
    return set_configuration_value(key, value_to_append);
}
예제 #3
0
static void look_up_and_set_configuration_value(LibMame_RunningGame *game,
                                                int gamenum,
                                                const char *tag,
                                                uint32_t mask,
                                                const char *value)
{
    int count = LibMame_Get_Game_Dipswitch_Count(gamenum);
    /* Find the descriptor */
    for (int i = 0; i < count; i++) {
        LibMame_Dipswitch desc = LibMame_Get_Game_Dipswitch(gamenum, i);
        if ((desc.mask == mask) && !strcmp(desc.tag, tag)) {
            /* Found the descriptor, now find the value */
            for (int j = 0; j < desc.value_count; j++) {
                if (!strcmp(desc.value_names[j], value)) {
                    set_configuration_value(game, tag, mask, j);
                    break;
                }
            }
            break;
        }
    }
}
예제 #4
0
struct z_story_list *update_fizmo_story_list()
{
#ifdef DISABLE_CONFIGFILES
  return NULL;
#else // DISABLE_CONFIGFILES
  struct z_story_list *result;
  struct z_story_list_entry *entry;
  char *str, *str_copy, *path;
  z_file *file;
  struct babel_info *babel;
  int i;

  nof_files_found = 0;
  nof_files_searched = 0;
  nof_directories_searched = 0;

  ensure_dot_fizmo_dir_exists();

  babel = load_babel_info();

  if (babel_files_have_changed(babel) == true)
  {
    // Don't load current list of story, rebuild index with the newly
    // changed babel data.
    result = get_empty_z_story_list();
    store_babel_info_timestamps(babel);
  }
  else
  {
    // Babel data is the same, use pre-indexed story list.
    result = get_z_story_list();
    i = 0;
    while (i < result->nof_entries)
    {
      entry = result->entries[i];
      if ((file = fsi->openfile(
              entry->filename, FILETYPE_DATA, FILEACCESS_READ)) == NULL)
        remove_entry_from_list(result, entry);
      else
      {
        fsi->closefile(file);
        i++;
      }
    }
  }

  if ((str = getenv("ZCODE_PATH")) == NULL)
    str = getenv("INFOCOM_PATH");
  if (str != NULL)
    set_configuration_value("z-code-path", str);

  if ((str = getenv("ZCODE_ROOT_PATH")) != NULL)
    set_configuration_value("z-code-root-path", str);

  if ((str = get_configuration_value("z-code-path")) != NULL)
  {
    path = strtok(str, ":");
    while (path != NULL)
    {
      TRACE_LOG("Counting for token \"%s\".\n", path);
      nof_files_found += count_files(path, false);
      path = strtok(NULL, ":");
    }
  }

  if ((str = get_configuration_value("z-code-root-path")) != NULL)
  {
    str_copy = strdup(str);
    path = strtok(str_copy, ":");
    while (path != NULL)
    {
      TRACE_LOG("Counting for token \"%s\".\n", path);
      nof_files_found += count_files(path, true);
      path = strtok(NULL, ":");
    }
    free(str_copy);
  }

  TRACE_LOG("nof_files_found: %d, %d\n", nof_files_found,
      NUMBER_OF_FILES_TO_SHOW_PROGRESS_FOR);
  if (nof_files_found >= NUMBER_OF_FILES_TO_SHOW_PROGRESS_FOR)
    show_progress = true;
  else
    show_progress = false;

  //printf("\n"); // newline for \r-progress indicator

  //build_filelist(".", result, false, babel);

  if ((str = get_configuration_value("z-code-path")) != NULL)
  {
    str_copy = strdup(str);
    path = strtok(str_copy, ":");
    while (path != NULL)
    {
      build_filelist(path, result, false, babel);
      path = strtok(NULL, ":");
    }
    free(str_copy);
  }

  if ((str = get_configuration_value("z-code-root-path")) != NULL)
  {
    str_copy = strdup(str);
    path = strtok(str_copy, ":");
    while (path != NULL)
    {
      build_filelist(path, result, true, babel);
      path = strtok(NULL, ":");
    }
    free(str_copy);
  }

  if (show_progress == true)
    printf("\n");

  TRACE_LOG("noffiles: %d\n", result->nof_entries);

  save_story_list(result);
  store_babel_info_timestamps(babel);

  free_babel_info(babel);

  return result;
#endif // DISABLE_CONFIGFILES
}