예제 #1
0
// Future file format versions will always still compare greater than MAX_STACKFILE_VERSION,
// so it is ok that r_version does not accurately reflect future version values.
// TODO: change this, and comparisons for version >= 7000 / 5500, etc
bool MCStackFileParseVersionNumber(const char *p_buffer, uint32_t &r_version)
{
	if (!MCCStringBeginsWith(p_buffer, kMCStackFileVersionStringPrefix))
		return false;
	
	p_buffer += kMCStackFileVersionStringPrefixLength;
	
	uint32_t t_version;
	t_version = 0;
	
	for (uint32_t i = 0; i < 4; i++)
	{
		t_version *= 10;
		
		// The header version can now consist of any alphanumeric characters
		// They map to numbers as follows:
		// 0-9 -> 0-9
		// A-Z -> 10-35
		// a-z -> 36-61
		
		char t_char;
		t_char = p_buffer[i];
		if ('0' <= t_char && t_char <= '9')
			t_version += (uint1)(t_char - '0');
		else if ('A' <= t_char && t_char <= 'Z')
			t_version += (uint1)(t_char - 'A' + 10);
		else if ('a' <= t_char && t_char <= 'z')
			t_version += (uint1)(t_char - 'a' + 36);
		else
			return false;
	}
	
	r_version = t_version;
	
	return true;
}
예제 #2
0
static void compute_simulator_redirect(const char *p_input, char*& r_output)
{
	if (s_redirects == nil)
	{
		r_output = (char *)p_input;
		return;
	}

	char *t_resolved_input;
	t_resolved_input = nil;
	if (*p_input != '/')
	{
		char *t_cwd;
		t_cwd = getcwd(nil, 0);
		MCCStringFormat(t_resolved_input, "%s/%s", t_cwd, p_input);
		free(t_cwd);
	}
	else
		MCCStringClone(p_input, t_resolved_input);
	
	char **t_components;
	uint32_t t_component_count;
	MCCStringSplit(t_resolved_input, '/', t_components, t_component_count);
	MCCStringFree(t_resolved_input);
	
	uint32_t t_count;
	t_count = 1;
	for(uint32_t j = 1; j < t_component_count; j++)
	{
		if (MCCStringEqual(t_components[j], ".") ||
			MCCStringEqual(t_components[j], ""))
		{
			MCCStringFree(t_components[j]);
			continue;
		}
		
		if (MCCStringEqual(t_components[j], ".."))
		{
			MCCStringFree(t_components[j]);
			if (t_count > 1)
			{
				MCCStringFree(t_components[t_count - 1]);
				t_count -= 1;
			}
			continue;
		}
		
		t_components[t_count] = t_components[j];
		t_count += 1;
	}
	
	MCCStringCombine(t_components, t_count, '/', t_resolved_input);
	MCCStringArrayFree(t_components, t_count);
	
	r_output = t_resolved_input;
	
	if (MCCStringBeginsWith(t_resolved_input, s_redirect_base))
	{
		const char *t_input_leaf;
		t_input_leaf = t_resolved_input + strlen(s_redirect_base) + 1;
		for(uint32_t i = 0; i < s_redirect_count; i++)
		{
			if (MCCStringEqual(s_redirects[i] . src, t_input_leaf))
			{
				r_output = strdup(s_redirects[i] . dst);
				break;
			}
			
			if (MCCStringBeginsWith(t_input_leaf, s_redirects[i] . src) &&
				t_input_leaf[MCCStringLength(s_redirects[i] . src)] == '/')
			{
				MCCStringFormat(r_output, "%s%s", s_redirects[i] . dst, t_input_leaf + MCCStringLength(s_redirects[i] . src));
				break;
			}
		}
	
	}
	
	if (r_output != t_resolved_input)
		MCCStringFree(t_resolved_input);
}
예제 #3
0
Exec_stat MCAndroidPlayerControl::Set(MCNativeControlProperty p_property, MCExecPoint &ep)
{
    bool t_bool = false;
    int32_t t_integer;
    
    jobject t_view;
    t_view = GetView();
    
    switch (p_property)
    {
        case kMCNativeControlPropertyContent:
        {
            bool t_success = true;
            MCCStringFree(m_path);
            t_success = MCCStringClone(ep.getcstring(), m_path);
            if (MCCStringBeginsWith(m_path, "http://") || MCCStringBeginsWith(m_path, "https://"))
            {
                MCAndroidObjectRemoteCall(t_view, "setUrl", "bs", &t_success, m_path);
            }
            else
            {
                char *t_resolved_path = nil;
                bool t_is_asset = false;
                const char *t_asset_path = nil;
                
                t_resolved_path = MCS_resolvepath(m_path);
                t_is_asset = path_to_apk_path(t_resolved_path, t_asset_path);
                
                MCAndroidObjectRemoteCall(t_view, "setFile", "bsb", &t_success, t_is_asset ? t_asset_path : t_resolved_path, t_is_asset);
                
                MCCStringFree(t_resolved_path);
            }
            return ES_NORMAL;
        }
            
        case kMCNativeControlPropertyShowController:
        {
            if (!ParseBoolean(ep, t_bool))
                return ES_ERROR;
            MCAndroidObjectRemoteCall(t_view, "setShowController", "vb", nil, t_bool);
            return ES_NORMAL;
        }
            
        case kMCNativeControlPropertyCurrentTime:
        {
            if (!ParseInteger(ep, t_integer))
                return ES_ERROR;
            MCAndroidObjectRemoteCall(t_view, "setCurrentTime", "vi", nil, t_integer);
            return ES_NORMAL;
        }
            
        case kMCNativeControlPropertyLooping:
        {
            if (!ParseBoolean(ep, t_bool))
                return ES_ERROR;
            MCAndroidObjectRemoteCall(t_view, "setLooping", "vb", nil, t_bool);
            return ES_NORMAL;
        }
            
        default:
            break;
    }
    
    return MCAndroidControl::Set(p_property, ep);
}