Ejemplo n.º 1
0
static int fat32fs_init(vfs_config *conf) {
	if (!(ins = fat_instance_new(conf->disk_id, conf->partition_no))) {
		MESSAGE_ERROR("fat32fs initialize failed\n");
		return -1;
	}
	return 0;
}
Ejemplo n.º 2
0
ssize_t
cluster_data_read (fat_instance * ins, const cluster_t cluster_no, void *buffer, off_t o, size_t count)
{
	assert(!IS_BAD_CLUSTER(cluster_no));
	MESSAGE_DEBUG("ins:%p cluster_no:%u buffer:%p offset:%u\n", ins, cluster_no, buffer, o);
	MESSAGE_DEBUG("count:%u\n", count);
	if(IS_END_OF_CLUSTER(cluster_no))
		return 0;
	assert(o + count <=  bpb_cluster_size(ins->bpb));
	off_t offset = cluster_data_offset (ins, cluster_no) + o;
	ssize_t ret;
	if((ret = disk_read (ins->disk_id, buffer, offset, count)) != count)
		MESSAGE_ERROR("read failed\n");
	MESSAGE_DEBUG("return:%d\n", ret);
	return ret;
}
Ejemplo n.º 3
0
/**
 * Callback for `Sort order` menu item
 *
 * @param __user_data - associated file panel
 * @return zero if callback hasn't handled received character
 */
static int
menu_close_callback (void *__user_data)
{
  file_panel_t *panel;

  if (file_panel_get_count () <= 1)
    {
      MESSAGE_ERROR (_(L"You cannot close the only file panel"));
      return 0;
    }

  FPD_CHECK_PANEL_ASSOCIATED ();

  panel = __user_data;

  file_panel_destroy (panel);

  return 0;
}
Ejemplo n.º 4
0
/*
 * osd_gfx_init:
 * One time initialization of the main output screen
 */
int
osd_gfx_init(void)
{
	if (!SDL_WasInit(SDL_INIT_VIDEO)) {
		if (SDL_InitSubSystem(SDL_INIT_VIDEO)) {
			MESSAGE_ERROR("SDL: %s failed at %s:%d - %s\n",
				__func__, __FILE__, __LINE__, SDL_GetError());
			return 0;
		}
	}

	MESSAGE_INFO("Window Size: %d\n", option.window_size);
	MESSAGE_INFO("Fullscreen: %d\n", option.want_fullscreen);
	osd_gfx_init_normal_mode();

	if (option.want_fullscreen)
		SDL_ShowCursor(SDL_DISABLE);

	SetPalette();

	return 1;
}
Ejemplo n.º 5
0
/*****************************************************************************

		Function:	osd_gfx_init_normal_mode

		Description: initialize the classic 256*224 video mode for normal video_driver
		Parameters: none
		Return: 0 on error
						1 on success

*****************************************************************************/
int
osd_gfx_init_normal_mode()
{
	struct generic_rect rect;

#if ENABLE_TRACING_SDL
	printf("GFX: Mode change: %dx%d\n", io.screen_w, io.screen_h);
#endif

	if (sdlWindow == NULL) {
		// First start? Lets just set a fake screen w/h
		io.screen_w = 352;
		io.screen_h = 256;
	}

	if (io.screen_w < 160 || io.screen_w > 512) {
		MESSAGE_ERROR("Correcting out of range screen w %d\n", io.screen_w);
		io.screen_w = 256;
	}
	if (io.screen_h < 160 || io.screen_h > 256) {
		MESSAGE_ERROR("Correcting out of range screen h %d\n", io.screen_h);
		io.screen_h = 224;
	}


	struct generic_rect viewport;
	viewport.start_x = 0;
	viewport.start_y = 0;

	if (option.want_fullscreen) {
		SDL_DisplayMode current;
    	if (SDL_GetCurrentDisplayMode(0, &current)) {
			MESSAGE_ERROR("Unable to determine current DisplayMode");
		}

		calc_fullscreen_aspect(current.w, current.h, &viewport,
			io.screen_w, io.screen_h);

		MESSAGE_INFO("%dx%d , %dx%d\n", viewport.start_x, viewport.start_y,
			viewport.end_x, viewport.end_y);
	} else {
		
		viewport.end_x = io.screen_w * option.window_size;
		viewport.end_y = io.screen_h * option.window_size;
	}

	uint16 viewportWidth = viewport.end_x - viewport.start_x;
	uint16 viewportHeight = viewport.end_y - viewport.start_y;

	if (sdlWindow != NULL) {
		SDL_DestroyWindow(sdlWindow);
		sdlWindow = NULL;
	}

	uint32 windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;

	if (option.want_fullscreen) 
		windowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;

	sdlWindow = SDL_CreateWindow("HuExpress", SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED, viewport.end_x, viewport.end_y, windowFlags);

	if (sdlWindow == NULL) {
		MESSAGE_ERROR("SDL: %s failed at %s:%d - %s\n", __func__, __FILE__,
			__LINE__, SDL_GetError());
		return 0;
	}

	sdlGLContext = SDL_GL_CreateContext(sdlWindow);

	if (sdlGLContext == NULL) {
		MESSAGE_ERROR("SDL: %s failed at %s:%d - %s\n", __func__, __FILE__,
			__LINE__, SDL_GetError());
		return 0;
	}

	SDL_GL_MakeCurrent(sdlWindow, sdlGLContext);

	sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_ACCELERATED);
	//sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_SOFTWARE);

	if (sdlRenderer == NULL) {
		MESSAGE_ERROR("SDL: %s failed at %s:%d - %s\n", __func__, __FILE__,
			__LINE__, SDL_GetError());
		return 0;
	}

	SDL_GL_SetSwapInterval(1);

	if (screen != NULL) {
		SDL_FreeSurface(screen);
		screen = NULL;
	}

	//screen = SDL_CreateRGBSurface(0, io.screen_w, io.screen_h,
	//	32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);
	screen = SDL_CreateRGBSurface(0, viewportWidth, viewportHeight,
		32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0);

	if (screen == NULL) {
		MESSAGE_ERROR("SDL: CreateRGBSurface failed at %s:%d - %s\n",
			__FILE__, __LINE__, SDL_GetError());
	}

	osd_gfx_glinit(&viewport);

	return (screen) ? 1 : 0;
}
Ejemplo n.º 6
0
Archivo: tcllib.c Proyecto: Nazg-Gul/fm
/**
 *
 * Initialize Tcl embed library
 *
 * @return TCL_OK if successful, TCL_ERROR otherwise
 */
int
tcllib_init (void)
{
  /* NOTE: Keep order, config.tcl be loaded last */
  static wchar_t *important_files[] = { L"associations.tcl",
                                        L"config.tcl" };
  /* static wchar_t *unimportant_files[] = { L"custom.tcl" }; */
  int i, j, count;
  wchar_t **list;

  interpreter = Tcl_CreateInterp();
  if (interpreter == NULL)
    {
      return TCL_ERROR;
    }

  if (tcllib_init_commands (interpreter) != TCL_OK)
    {
      return TCL_ERROR;
    }

  for  (i = 0; i < sizeof (important_files) / sizeof (important_files[0]); ++i)
    {
      count = get_shared_files (important_files[i], NULL, &list);

      if (count == 0)
        {
          wchar_t msg[1024];
          swprintf (msg, BUF_LEN (msg),
                    _(L"Configuration file \"%ls\" not found"),
                    important_files[i]);
          MESSAGE_ERROR (msg);
          return TCL_ERROR;
        }

      for (j = 0; j < count; ++j)
        {
          if (tcllib_load_file (list[j]) != TCL_OK)
            {
              TCL_RUNTIME_ERROR;

              /* Free memory used by unseen items */
              while (j < count)
                {
                  SAFE_FREE (list[j]);
                  ++j;
                }
              SAFE_FREE (list);

              return TCL_ERROR;
            }
          SAFE_FREE (list[j]);
        }

      SAFE_FREE (list);
    }

  hook_register (L"open-file-hook", _file_associations_hook, 1);

  return TCL_OK;
}
Ejemplo n.º 7
0
Archivo: tcllib.c Proyecto: Nazg-Gul/fm
/**
 *
 * File associations hook
 * For details see about hook's on user documentation
 */
int
_file_associations_hook (dynstruct_t *__callData)
{
  extension_action_t *ext;
  wchar_t *executecmd, *filename, *cwd;

  if (dynstruct_get_field_val (__callData, L"filename",
                               (void **) &filename) != DYNST_OK)
    {
      message_box (L"Hook `open-file-hook' error",
                   L"variable `filename' not found", MB_OK|MB_CRITICAL);

      return HOOK_FAILURE;
    }

  filename = escape_string (filename);

  if (_get_file_associations (filename, (void *) &ext) != TCL_OK)
    {
      executecmd = filename;
    }
  else
    {
      if (dynstruct_get_field_val (__callData, L"cwd",
                                   (void **) &cwd) != DYNST_OK)
        {
          message_box (L"Hook `open-file-hook' error",
                       L"variable `cwd' not found", MB_OK|MB_CRITICAL);

          return HOOK_FAILURE;
        }

      if (!ext->opener)
        {
          wchar_t msg[1024];

          swprintf (msg, BUF_LEN (msg),
                    _(L"There is no command specified to open file \"%ls\""),
                    filename);

          MESSAGE_ERROR (msg);
          return HOOK_FAILURE;
        }

      cwd = escape_string (cwd);

      executecmd = prepare_exec_command (ext->opener, filename, cwd);

      SAFE_FREE (filename);
      SAFE_FREE (cwd);
    }

  if (run_shell_command (executecmd) == -1)
    {
      return HOOK_FAILURE;
    }

  SAFE_FREE (executecmd);

  return HOOK_SUCCESS;
}