Exemplo n.º 1
0
int main(int UNUSED(argc), char *UNUSED(argv[]))
{
  z_ucs *path;
  z_ucs german_locale_name[] = { 'd', 'e', '_', 'D', 'E', 0 };

  printf("\nStarting tools-test.\n");

  turn_on_trace();

  if ((path = dup_latin1_string_to_zucs_string("../locales")) == NULL)
    return -1;
  set_i18n_search_path(path);
  free(path);

  register_i18n_stream_output_function(&i18n_test_stream_output);

  printf("\nTrying to display first localized error message:\n ");

  TRACE_LOG("Starting tools_test.\n");

  i18n_translate(
      libfizmo_module_name,
      i18n_libfizmo_COULD_NOT_OPEN_TRACE_FILE_P0S,
      "foo1");

  printf("\n\nTrying to display second localized error message:\n ");

  i18n_translate(
      libfizmo_module_name,
      i18n_libfizmo_INVALID_PARAMETER_TYPE_P0S,
      "foo2");

  if (set_current_locale_name(german_locale_name) != 0)
  {
    printf("set_current_locale_name() failed.\n");
    exit(-1);
  }

  printf("\n\nTrying to display german localized error message:\n ");

  i18n_translate(
      libfizmo_module_name,
      i18n_libfizmo_COULD_NOT_OPEN_TRACE_FILE_P0S,
      "foo1");

  printf("\n");

  TRACE_LOG("End of tools_test.\n");

  printf(
      "\nTools-test finished, you might want to examine \"tracelog.txt\".\n\n");

  return 0;
}
Exemplo n.º 2
0
int glkunix_startup_code(glkunix_startup_t *data)
{
  /* It turns out to be more convenient if we return TRUE from here, even 
     when an error occurs, and display an error in glk_main(). */
  int ix;
  char *filename = NULL;
  strid_t gamefile = NULL;
  fizmo_register_filesys_interface(&glkint_filesys_interface);

#ifdef ENABLE_TRACING
  turn_on_trace();
#endif // ENABLE_TRACING

  /* Parse out the arguments. They've already been checked for validity,
     and the library-specific ones stripped out.
     As usual for Unix, the zeroth argument is the executable name. */
  for (ix=1; ix<data->argc; ix++) {
    if (filename) {
      init_err = "You must supply exactly one game file.";
      return TRUE;
    }
    filename = data->argv[ix];
  }

  if (!filename) {
    init_err = "You must supply the name of a game file.";
    return TRUE;
  }

  gamefile = glkunix_stream_open_pathname(filename, FALSE, 1);
  if (!gamefile) {
    init_err = "The game file could not be opened.";
    init_err2 = filename;
    return TRUE;
  }

  gamefilestream = gamefile;
  gamefilename = filename;

  return TRUE;
}