Esempio n. 1
0
BOOL LoadDIB(LPCTSTR filename, HGLOBAL *phDIB, HPALETTE *pPal, int pic_type)
{
	mame_file *mfile;
	BOOL success;
	const char *zip_name = NULL;

	switch (pic_type)
	{
	case TAB_SCREENSHOT :
		set_pathlist(FILETYPE_ARTWORK,GetImgDir());
		zip_name = "snap";
		break;
	case TAB_FLYER :
		set_pathlist(FILETYPE_ARTWORK,GetFlyerDir());
		zip_name = "flyers";
		break;
	case TAB_CABINET :
		set_pathlist(FILETYPE_ARTWORK,GetCabinetDir());
		zip_name = "cabinets";
		break;
	case TAB_MARQUEE :
		set_pathlist(FILETYPE_ARTWORK,GetMarqueeDir());
		zip_name = "marquees";
		break;
	case TAB_TITLE :
		set_pathlist(FILETYPE_ARTWORK,GetTitlesDir());
		zip_name = "titles";
		break;
	case TAB_CONTROL_PANEL :
		set_pathlist(FILETYPE_ARTWORK,GetControlPanelDir());
		zip_name = "cpanel";
		break;
	case BACKGROUND :
		set_pathlist(FILETYPE_ARTWORK,GetBgDir());
		zip_name = "bkground";
		break;
	default :
		// in case a non-image tab gets here, which can happen
		return FALSE;
	}
	
	// look for the raw file
	mfile = mame_fopen(NULL,filename,FILETYPE_ARTWORK,0);
	if (mfile == NULL)
	{
		// and look for the zip
		mfile = mame_fopen(zip_name,filename,FILETYPE_ARTWORK,0);
	}

	if (mfile == NULL)
		return FALSE;

	success = png_read_bitmap(mfile, phDIB, pPal);

	mame_fclose(mfile);

	return success;
}
Esempio n. 2
0
static struct tmplpro_param*
process_tmplpro_options(VALUE self)
{
    struct tmplpro_param* param = tmplpro_param_init();
    const char* tmpstring;
    int default_escape=HTML_TEMPLATE_OPT_ESCAPE_NO;

    tmplpro_set_option_WriterFuncPtr(param, &write_chars_to_string);
    tmplpro_set_option_GetAbstractValFuncPtr(param, &get_ABSTRACT_VALUE_impl);
    tmplpro_set_option_AbstractVal2pstringFuncPtr(param, &ABSTRACT_VALUE2PSTRING_impl);
    tmplpro_set_option_AbstractVal2abstractArrayFuncPtr(param, &ABSTRACT_VALUE2ABSTRACT_ARRAY_impl);
    tmplpro_set_option_GetAbstractArrayLengthFuncPtr(param, &get_ABSTRACT_ARRAY_length_impl);
    tmplpro_set_option_IsAbstractValTrueFuncPtr(param, &is_ABSTRACT_VALUE_true_impl);
    tmplpro_set_option_GetAbstractMapFuncPtr(param, &get_ABSTRACT_MAP_impl);
    tmplpro_set_option_LoadFileFuncPtr(param, &load_file);
    tmplpro_set_option_UnloadFileFuncPtr(param, &unload_file);

    /*   setting initial Expr hooks */
    tmplpro_set_option_InitExprArglistFuncPtr(param, &init_expr_arglist);
    tmplpro_set_option_FreeExprArglistFuncPtr(param, &free_expr_arglist);
    tmplpro_set_option_PushExprArglistFuncPtr(param, &push_expr_arglist);
    tmplpro_set_option_CallExprUserfncFuncPtr(param, &call_expr_userfnc);
    tmplpro_set_option_IsExprUserfncFuncPtr(param, &is_expr_userfnc);
    /* end setting initial hooks */

    /*   setting ruby globals */
    tmplpro_set_option_ext_findfile_state(param, (ABSTRACT_FINDFILE *)self);
    tmplpro_set_option_ext_filter_state(param, (ABSTRACT_FILTER *)self);
    tmplpro_set_option_ext_calluserfunc_state(param, (ABSTRACT_CALLER *)self);
    tmplpro_set_option_ext_data_state(param, (ABSTRACT_DATASTATE *)self);
    /*  end setting ruby globals */

    if ((void*)self == NULL) {
        rb_raise(rb_eRuntimeError, "FATAL:SELF:self was expected but not found");
    }
    Check_Type(self, T_OBJECT);

    /* checking main arguments */
    PSTRING filename = get_string_from_value(self, "@filename");
    PSTRING scalarref = get_string_from_value(self, "@scalarref");
    tmplpro_set_option_filename(param, filename.begin);
    tmplpro_set_option_scalarref(param, scalarref);
    if (filename.begin==NULL && scalarref.begin==NULL) {
        rb_raise(rb_eRuntimeError, "bad arguments: expected filename or scalarref");
    }

    VALUE options = rb_ivar_get(self, rb_intern("@options"));
    Check_Type(options, T_HASH);

    /* setting expr_func */
    VALUE expr_key = ID2SYM(rb_intern("expr_func"));
    VALUE expr = rb_hash_aref(options, expr_key);
    if (!expr || NIL_P(expr) || TYPE(expr) != T_HASH) {
        rb_raise(rb_eRuntimeError, "FATAL:output:EXPR user functions not found");
    }
    tmplpro_set_option_expr_func_map(param, (ABSTRACT_FUNCMAP *)expr);
    /* end setting expr_func */

    /* setting param_map */
    tmplpro_clear_option_param_map(param);
    VALUE map = rb_ivar_get(self, rb_intern("@params"));
    Check_Type(map, T_HASH);
    tmplpro_push_option_param_map(param, (ABSTRACT_MAP*)map, 0);
    /* end setting param_map */

    /* setting filter */
    VALUE filter_key = ID2SYM(rb_intern("filter"));
    VALUE filter = rb_hash_aref(options, filter_key);
    Check_Type(filter, T_ARRAY);
    if (RARRAY_LEN(filter) >= 0) tmplpro_set_option_filters(param, 1);
    /* end setting filter */

    if (!get_boolean_from_hash(options, "case_sensitive")) {
        tmplpro_set_option_tmpl_var_case(param, ASK_NAME_LOWERCASE);
    }

    set_integer_from_hash(options,"tmpl_var_case",param,tmplpro_set_option_tmpl_var_case);
    set_integer_from_hash(options,"max_includes",param,tmplpro_set_option_max_includes);
    set_boolean_from_hash(options,"no_includes",param,tmplpro_set_option_no_includes);
    set_boolean_from_hash(options,"search_path_on_include",param,tmplpro_set_option_search_path_on_include);
    set_boolean_from_hash(options,"global_vars",param,tmplpro_set_option_global_vars);
    set_integer_from_hash(options,"debug",param,tmplpro_set_option_debug);
    debuglevel = tmplpro_get_option_debug(param);
    set_boolean_from_hash(options,"loop_context_vars",param,tmplpro_set_option_loop_context_vars);
    set_boolean_from_hash(options,"path_like_variable_scope",param,tmplpro_set_option_path_like_variable_scope);
    /* still unsupported */
    set_boolean_from_hash(options,"strict",param,tmplpro_set_option_strict);

    tmpstring = get_string_from_hash(options, "default_escape").begin;
    if (tmpstring && *tmpstring) {
        switch (*tmpstring) {
        case '1': case 'H': case 'h': 	/* HTML*/
            default_escape = HTML_TEMPLATE_OPT_ESCAPE_HTML;
            break;
        case 'U': case 'u': 		/* URL */
            default_escape = HTML_TEMPLATE_OPT_ESCAPE_URL;
            break;
        case 'J': case 'j':		/* JS  */
            default_escape = HTML_TEMPLATE_OPT_ESCAPE_JS;
            break;
        case '0': case 'N': case 'n': /* 0 or NONE */
            default_escape = HTML_TEMPLATE_OPT_ESCAPE_NO;
            break;
        default:
            rb_warn("unsupported value of default_escape=%s. Valid values are HTML, URL or JS.\n",tmpstring);
        }
        tmplpro_set_option_default_escape(param, default_escape);
    }

    /* set path */
    tmplpro_set_option_path(param, set_pathlist(self, options, "path"));
    tmplpro_set_option_FindFileFuncPtr(param, NULL);

    return param;
}