Пример #1
0
Exec_stat MCHandleSetAllowedOrientations(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
	
	char *t_orientations;
	t_orientations = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_orientations);
	
	char **t_orientations_array;
	uint32_t t_orientations_count;
	t_orientations_array = nil;
	t_orientations_count = 0;
	if (t_success)
		t_success = MCCStringSplit(t_orientations, ',', t_orientations_array, t_orientations_count);
	
	uint32_t t_orientations_set;
	t_orientations_set = 0;
	if (t_success)
		for(uint32_t i = 0; i < t_orientations_count; i++)
			for(uint32_t j = 0; s_orientation_names[j] != nil; j++)
				if (MCCStringEqualCaseless(t_orientations_array[i], s_orientation_names[j]))
					t_orientations_set |= (1 << j);
	
	s_allowed_orientations = t_orientations_set;
	
	for(uint32_t i = 0; i < t_orientations_count; i++)
		MCCStringFree(t_orientations_array[i]);
	MCMemoryDeleteArray(t_orientations_array);
	
	MCCStringFree(t_orientations);
	
	return ES_NORMAL;
}
Пример #2
0
MCReferencedImageRep::~MCReferencedImageRep()
{
	MCCStringFree(m_file_name);
	MCCStringFree(m_search_key);
	
	MCMemoryDeallocate(m_url_data);
}
Пример #3
0
Exec_stat MCHandleAdSetTopLeft(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
    char *t_top_left_string;
    t_top_left_string = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "ss", &t_ad, &t_top_left_string);
    
    MCAdTopLeft t_top_left = {0,0};
    if (t_success)
        t_success = sscanf(t_top_left_string, "%u,%u", &t_top_left.x, &t_top_left.y);
    
	if (t_success)
		MCAdSetTopLeftOfAd(t_ctxt, t_ad, t_top_left);
    
    MCCStringFree(t_top_left_string);
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Пример #4
0
bool MCContactParseParams(MCParameter *p_params, MCVariableValue *&r_contact, char *&r_title, char *&r_message, char *&r_alternate_name)
{
	bool t_success = true;
	
	MCVariableValue *t_contact = nil;
	char *t_title = nil;
	char *t_message = nil;
	char *t_alternate_name = nil;
	
	t_success = MCParseParameters(p_params, "a|sss", &t_contact, &t_title, &t_message, &t_alternate_name);
	
	if (t_success)
	{
		r_contact = t_contact;
		r_title = t_title;
		r_message = t_message;
		r_alternate_name = t_alternate_name;
	}
	else
	{
		MCCStringFree(t_title);
		MCCStringFree(t_message);
		MCCStringFree(t_alternate_name);
	}
	
	return t_success;
}
Пример #5
0
bool MCSystemProcessUrl(const char *p_url, MCSystemUrlOperation p_operations, char *&r_processed_url)
{
    bool t_success = true;

    char *t_processed = nil;

    if (t_success && (p_operations & kMCSystemUrlOperationStrip))
    {
        char *t_stripped = nil;
        t_success = MCSystemStripUrl(t_processed != nil ? t_processed : p_url, t_stripped);
        if (t_success)
        {
            MCCStringFree(t_processed);
            t_processed = t_stripped;
        }
    }

    // if no processing, just return a copy of the input url
    if (t_success && t_processed == nil)
        t_success = MCCStringClone(p_url, t_processed);

    if (t_success)
        r_processed_url = t_processed;
    else
        MCCStringFree(t_processed);

    return t_success;
}
Пример #6
0
bool MCSystemPlaySound(const char *p_file, bool p_looping)
{
	//MCLog("MCSystemPlaySound(%s, %s)", p_file, p_looping?"true":"false");
	bool t_success;
	if (s_sound_file != nil)
	{
		MCCStringFree(s_sound_file);
		s_sound_file = nil;
	}
    
	s_sound_file = MCS_resolvepath(p_file);
    
	const char *t_apk_file = nil;
	if (path_to_apk_path(s_sound_file, t_apk_file))
		MCAndroidEngineCall("playSound", "bsbb", &t_success, t_apk_file, true, p_looping);
	else
		MCAndroidEngineCall("playSound", "bsbb", &t_success, s_sound_file, false, p_looping);
	if (!t_success)
	{
		MCCStringFree(s_sound_file);
		s_sound_file = nil;
	}
    
	return t_success;
}
Пример #7
0
static void MCTextLayoutLinkedFontDestroy(MCTextLayoutLinkedFont *self)
{
	for(uint32_t i = 0; i < self -> entry_count; i++)
		MCCStringFree(self -> entries[i] . face);
	MCMemoryDeleteArray(self -> entries);
	MCCStringFree(self ->  name);
	MCMemoryDelete(self);
}
Пример #8
0
void MCUrlProgressEvent::Destroy(void)
{
    MCCStringFree(m_url);
    if (m_status == kMCSystemUrlStatusError)
        MCCStringFree(m_error);
    if (m_object != nil)
        m_object->Release();
    delete this;
}
bool MCImageRepGetReferencedWithScale(const char *p_base, const char *p_extension, MCGFloat p_scale, MCImageRep *&r_rep)
{
	bool t_success;
	t_success = true;
	
	MCImageRep *t_rep;
	t_rep = nil;
	
	char *t_default_path;
	t_default_path = nil;
	
	const char **t_labels;
	t_labels = nil;
	
	if (t_success)
		t_success = MCImageGetLabelsForScale(p_scale, t_labels);
	
	// construct default path as base path with first tag for the given scale
	if (t_success)
		t_success = MCCStringFormat(t_default_path, "%s%s%s", p_base, t_labels[0], p_extension);
	
	if (t_success)
	{
		MCCachedImageRep *t_cached_rep;
		t_cached_rep = nil;
		
		if (MCCachedImageRep::FindWithKey(t_default_path, t_cached_rep))
			t_rep = t_cached_rep->Retain();
		// not in cache, so see if default path exists.
		else if (MCS_exists(t_default_path, True))
			t_success = MCImageRepCreateReferencedWithSearchKey(t_default_path, t_default_path, t_rep);
		// else loop through remaining labels and check for matching files
		else
		{
			for (uint32_t i = 1; t_success && t_rep == nil && t_labels[i] != nil; i++)
			{
				char *t_scaled_path;
				t_scaled_path = nil;
				
				t_success = MCCStringFormat(t_scaled_path, "%s%s%s", p_base, t_labels[i], p_extension);
				
				if (t_success && MCS_exists(t_scaled_path, True))
					t_success = MCImageRepCreateReferencedWithSearchKey(t_scaled_path, t_default_path, t_rep);
				
				MCCStringFree(t_scaled_path);
			}
		}
	}
	
	MCCStringFree(t_default_path);
	
	if (t_success)
		r_rep = t_rep;
	
	return t_success;
}
Пример #10
0
static void delete_custom_font(MCAndroidCustomFont *p_font)
{
    if (p_font != nil)
    {
        /*UNCHECKED */ MCCStringFree(p_font->path);
        /*UNCHECKED */ MCCStringFree(p_font->name);
        /*UNCHECKED */ MCCStringFree(p_font->family);
        /*UNCHECKED */ MCMemoryDelete(p_font);
    }
}
Пример #11
0
static void cgi_dispose_multipart_context(cgi_multipart_context_t *p_context)
{
	MCCStringFree(p_context->name);
	MCCStringFree(p_context->file_name);
	MCCStringFree(p_context->type);
	MCCStringFree(p_context->boundary);
	if (p_context->file_handle != NULL)
		MCS_close(p_context->file_handle);
	
	MCMemoryClear(p_context, sizeof(cgi_multipart_context_t));
}
Пример #12
0
void MCUrlLoadEvent::Destroy(void)
{
    MCCStringFree(m_url);
    MCNameDelete(m_message);
    if (m_status == kMCSystemUrlStatusFinished)
        MCMemoryDelete(m_data.bytes);
    else if (m_status == kMCSystemUrlStatusError)
        MCCStringFree(m_error);
    if (m_object != nil)
        m_object->Release();
    delete this;
}
Пример #13
0
void MCSessionDisposeSession(MCSession *p_session)
{
	if (p_session == NULL)
		return;
	
	MCCStringFree(p_session->id);
	MCCStringFree(p_session->ip);
	MCCStringFree(p_session->filename);

	MCMemoryDeallocate(p_session->data);
	
	MCMemoryDelete(p_session);
}
Пример #14
0
bool MCFileSystemListEntries(const char *p_folder, uint32_t p_options, MCFileSystemListCallback p_callback, void *p_context)
{
	bool t_success = true;
	
	char *t_resolved_path = nil;
	DIR *t_dir = nil;
	t_success = MCFileSystemPathResolve(p_folder, t_resolved_path);
	
	if (t_success)
	{
		t_dir = opendir(t_resolved_path);
		t_success = t_dir != nil;
	}
	
	if (t_success)
	{
		struct dirent *t_entry = nil;
		struct stat t_entry_stat;
		MCFileSystemEntry t_fs_entry;
		while (t_success && nil != (t_entry = readdir(t_dir)))
		{
			if (!MCCStringEqual(t_entry->d_name, ".") && !MCCStringEqual(t_entry->d_name, ".."))
			{
				char *t_child_path = nil;
				t_success = MCCStringFormat(t_child_path, "%s/%s", t_resolved_path, t_entry->d_name);
				if (t_success)
					t_success = -1 != lstat(t_child_path, &t_entry_stat);
				MCCStringFree(t_child_path);
				if (t_success)
				{
					t_fs_entry.filename = t_entry->d_name;
					if (S_ISLNK(t_entry_stat.st_mode))
						t_fs_entry.type = kMCFileSystemEntryLink;
					else if (S_ISDIR(t_entry_stat.st_mode))
						t_fs_entry.type = kMCFileSystemEntryFolder;
					else
						t_fs_entry.type = kMCFileSystemEntryFile;
					
					t_success = p_callback(p_context, t_fs_entry);
				}
			}
		}
		closedir(t_dir);
	}
	MCCStringFree(t_resolved_path);
	
	return t_success;
}
Пример #15
0
static MCAndroidCustomFont* look_up_custom_font(const char *p_name, bool p_bold, bool p_italic)
{
    char *t_styled_name;
    t_styled_name = nil;    
    if (!MCCStringClone(p_name, t_styled_name))
        return nil;    
    if (p_bold && !MCCStringAppend(t_styled_name, " Bold"))
        return nil;
    if (p_italic && !MCCStringAppend(t_styled_name, " Italic"))
        return nil;    
    
    // Fist of all, attempt to look the font up by taking into account its name and style.
    // e.g. textFont:Arial textStyle:Bold - look for a font named Arial Bold.
    // This will fail for textFonts which include style information e.g. textFont:Arial textStyle:Bold will search for Arial Bold Bold
    MCAndroidCustomFont *t_font;
    t_font = look_up_custom_font_by_name(t_styled_name);
    /*UNCHECKED */ MCCStringFree(t_styled_name);
    if (t_font != nil)
        return t_font;
    
    // If no font found, look up based purley on the name.  This will solve cases where style
    // information is included in the name e.g. Arial Bold.
    if (p_bold || p_italic)
    {
        t_font = look_up_custom_font_by_name(p_name);
        if (t_font != nil)
            return t_font;
    }
    
    // If we've still not found a matching font, look up based on the family and style.
    // This function will attempt to provide a closest match e.g. Arial Bold is requested but only Arial is installed.
    t_font = look_up_custom_font_by_family_and_style(p_name, p_bold, p_italic);
    return t_font;
}
Пример #16
0
static Exec_stat fetch_cstring_array(MCExecPoint& ep, MCVariableValue *array, const char *key, char**& r_strings, uint32_t& r_string_count)
{
	bool t_success;
	t_success = true;
	
	char *t_strings_list;
	t_strings_list = nil;
	if (t_success)
		if (fetch_opt_cstring(ep, array, key, t_strings_list) == ES_ERROR)
			t_success = false;
	
	char **t_strings;
	uint32_t t_string_count;
	t_strings = nil;
	t_string_count = 0;
	if (t_success)
		t_success = MCCStringSplit(t_strings_list, '\n', t_strings, t_string_count);
	
	if (t_success)
	{
		r_strings = t_strings;
		r_string_count = t_string_count;
	}
	
	MCCStringFree(t_strings_list);
	
	return t_success ? ES_NORMAL : ES_ERROR;
	
}
Пример #17
0
void MCCStringReplace(char *&src, char *&dest)
{
    if (dest != NULL)
        MCCStringFree(dest);
    dest = src;
    src = NULL;
}
Пример #18
0
static bool MCS_loadurl_callback(void *p_context, MCSystemUrlStatus p_status, const void *p_data)
{
    MCSLoadUrlState *context;
    context = static_cast<MCSLoadUrlState *>(p_context);

    context -> status = p_status;

    if (p_status == kMCSystemUrlStatusError)
        MCMemoryDelete(context->data.bytes);
    else if (p_status == kMCSystemUrlStatusLoading)
    {
        const MCString *t_data = static_cast<const MCString*>(p_data);
        MCMemoryReallocate(context->data.bytes, context->data.size + t_data->getlength(), context->data.bytes);
        MCMemoryCopy(static_cast<uint8_t*>(context->data.bytes) + context->data.size, t_data->getstring(), t_data->getlength());
        context->data.size += t_data->getlength();
    }

    send_url_progress(context -> object, p_status, context -> url, context -> data . size, context -> total, (const char *)p_data);

    if (p_status == kMCSystemUrlStatusError || p_status == kMCSystemUrlStatusFinished)
    {
        MCUrlLoadEvent *t_event;
        t_event = MCUrlLoadEvent::CreateUrlLoadEvent(context->object, context->message, context->url, p_status, context->data.bytes, context->data.size, static_cast<const char *>(p_data));
        if (t_event)
            MCEventQueuePostCustom(t_event);
        context->object->Release();
        MCCStringFree(context->url);
        MCNameDelete(context->message);
        MCMemoryDelete(context);
    }
    return true;
}
Пример #19
0
MCGFloat __MCGContextMeasurePlatformText(MCGContextRef self, const unichar_t *p_text, uindex_t p_length, const MCGFont &p_font, const MCGAffineTransform &p_transform)
{	
	//if (!MCGContextIsValid(self))
	//	return 0.0;
	
	bool t_success;
	t_success = true;	
	
	char *t_text;
	t_text = nil;
	if (t_success)
		t_success = MCCStringFromUnicodeSubstring(p_text, p_length / 2, t_text);
	
	MCGFloat t_width;
	t_width = 0.0;
	if (t_success)
	{
		SkPaint t_paint;
		t_paint . setTextSize(p_font . size);
		
		SkTypeface *t_typeface;
		t_typeface = (SkTypeface *) p_font . fid;
		t_paint . setTypeface(t_typeface);
		
		// MM-2013-12-05: [[ Bug 11527 ]] Make sure we calculate the UTF-8 string length correctly.
		uindex_t t_length;
		t_length = MCCStringLength(t_text);
		t_width =  (MCGFloat) t_paint . measureText(t_text, t_length);
    }
	
	MCCStringFree(t_text);
	//self -> is_valid = t_success;
	return t_width;
}
Пример #20
0
static void inline grab_string(char *&x_dest, char *&x_src)
{
	if (x_dest != NULL)
		MCCStringFree(x_dest);
	x_dest = x_src;
	x_src = NULL;
}
Пример #21
0
void MCS_loadurl(MCObject *p_object, const char *p_url, const char *p_message)
{
    bool t_success = true;
    MCSLoadUrlState *t_state = nil;
    char *t_processed = nil;
    MCNameRef t_message = nil;
    t_success = MCMemoryNew(t_state) &&
                MCSystemProcessUrl(p_url, kMCSystemUrlOperationStrip, t_processed) &&
                MCNameCreateWithCString(p_message, t_message);

    if (t_success)
    {
        t_state->url = t_processed;
        t_state->message = t_message;
        t_state->status = kMCSystemUrlStatusNone;
        t_state->object = p_object -> gethandle();
        t_state->data . bytes = nil;
        t_state->data . size = 0;

        t_success = MCSystemLoadUrl(t_processed, MCS_loadurl_callback, t_state);
    }

    if (t_success)
        MCresult->clear();
    else
    {
        MCCStringFree(t_processed);
        MCNameDelete(t_message);
        MCMemoryDelete(t_state);
        MCurlresult -> clear();
        MCresult->sets("error: load URL failed");
    }
}
Пример #22
0
void MCAdFinalize(void)
{
    MCCStringFree(s_inneractive_ad_key);
    MCAd::Finalize();
    s_ads = nil;
    s_last_ad_id = 0;  
}
Пример #23
0
MCGFloat __MCGContextMeasurePlatformText(MCGContextRef self, const unichar_t *p_text, uindex_t p_length, const MCGFont &p_font)
{	
	// MW-2013-12-19: [[ Bug 11559 ]] Do nothing if no text support.
	if (!s_has_text_support)
		return 0.0;
	
	bool t_success;
	t_success = true;		
	
	if (t_success)
		t_success = s_layout != NULL;
	
	char *t_text;
	t_text = nil;
	if (t_success)
		t_success = MCCStringFromUnicodeSubstring(p_text, p_length / 2, t_text);
	
	MCGFloat t_width;
	t_width = 0.0;
	if (t_success)
	{
		pango_layout_set_text(s_layout, t_text, -1);		
		pango_layout_set_font_description(s_layout, (PangoFontDescription *) p_font . fid);
		
		PangoRectangle t_bounds;
		pango_layout_get_pixel_extents(s_layout, NULL, &t_bounds);
		t_width = t_bounds . width;		
	}
	
	MCCStringFree(t_text);

	return t_width;
}
Пример #24
0
Exec_stat MCHandleAdGetTopLeft(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);
	
    MCAdTopLeft t_top_left = {0,0};
	if (t_success)
		t_success = MCAdGetTopLeftOfAd(t_ctxt, t_ad, t_top_left);
    
    if (t_success)
    {
        MCAutoRawCString t_top_left_string;
        t_success = MCCStringFormat(t_top_left_string, "%u,%u", t_top_left.x, t_top_left.y);
        if (t_success)
            if (t_top_left_string.Borrow() != nil)
                ep.copysvalue(t_top_left_string.Borrow());
    }
    
    if (t_success)
        MCresult->store(ep, False);
    
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Пример #25
0
Exec_stat MCHandleAdGetVisible(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
    
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);
	
    bool t_visible;
    t_visible = false;
	if (t_success)
		t_success = MCAdGetVisibleOfAd(t_ctxt, t_ad, t_visible);
    
    if (t_success)
        MCresult->sets(MCU_btos(t_visible));
    
    MCCStringFree(t_ad);
    
    return t_ctxt.GetStat();
}
Пример #26
0
Exec_stat MCHandleAdCreate(void *context, MCParameter *p_parameters)
{
	bool t_success;
	t_success = true;
		
    MCExecPoint ep(nil, nil, nil);
    MCExecContext t_ctxt(ep);
	t_ctxt . SetTheResultToEmpty();
    	
	char *t_ad;
	t_ad = nil;
	if (t_success)
		t_success = MCParseParameters(p_parameters, "s", &t_ad);	
    
    MCAdType t_type;
    t_type = kMCAdTypeUnknown;
    if (t_success)
    {
        char *t_type_string;
        t_type_string = nil;
        if (MCParseParameters(p_parameters, "s", &t_type_string))
            t_type = MCAdTypeFromCString(t_type_string);
        MCCStringFree(t_type_string);
    }
    
    MCAdTopLeft t_top_left = {0,0};
    if (t_success)
    {
        char *t_top_left_string;
        t_top_left_string = nil;
        if (MCParseParameters(p_parameters, "s", &t_top_left_string))
            /* UNCHECKED */ sscanf(t_top_left_string, "%u,%u", &t_top_left.x, &t_top_left.y);
        MCCStringFree(t_top_left_string);
    }
    
    MCVariableValue *t_meta_data;
    t_meta_data = nil;
    if (t_success)
        MCParseParameters(p_parameters, "a", &t_meta_data);

	if (t_success)
		MCAdExecCreateAd(t_ctxt, t_ad, t_type, t_top_left, t_meta_data);
    
    MCCStringFree(t_ad);
	    
    return t_ctxt.GetStat();
}
Пример #27
0
static bool cgi_multipart_get_boundary(char *&r_boundary)
{
	bool t_success = true;
	char *t_content_type;
	t_content_type = MCS_getenv("CONTENT_TYPE");

	char *t_params = NULL;
	uint32_t t_index = 0;
	
	char **t_names = NULL;
	char **t_values = NULL;
	uint32_t t_param_count = 0;
	
	t_success = MCCStringFirstIndexOf(t_content_type, ';', t_index);

	if (t_success)
		t_success = MCMultiPartParseHeaderParams(t_content_type + t_index + 1, t_names, t_values, t_param_count);

	r_boundary = NULL;
	
	if (t_success)
	{
		for (uint32_t i = 0; i < t_param_count; i++)
		{
			if (MCCStringEqualCaseless(t_names[i], "boundary") && MCCStringLength(t_values[i]) > 0)
			{
				r_boundary = t_values[i];
				t_values[i] = NULL;
				break;
			}
		}
	}
	
	if (t_success)
		t_success = r_boundary != NULL;
	
	for (uint32_t i = 0; i < t_param_count; i++)
	{
		MCCStringFree(t_names[i]);
		MCCStringFree(t_values[i]);
	}
	MCMemoryDeleteArray(t_names);
	MCMemoryDeleteArray(t_values);
	
	return t_success;
}
Пример #28
0
void deleteUrlInfo(MCUrlInfo *p_info)
{
	if (p_info != nil)
	{
		MCCStringFree(p_info->url);
		MCMemoryDelete(p_info);
	}
}
Пример #29
0
static bool load_custom_font_file_into_buffer_from_path(const char *p_path, char *&r_buffer, uint32_t &r_size)
{     
    bool t_success;
    t_success = true;
    
    char *t_font_path;
    t_font_path = nil;
    if (t_success)
        t_success = MCCStringFormat(t_font_path, "%s/%s%s", MCcmd, s_font_folder, p_path);
    
    if (t_success)
        t_success = MCS_exists(t_font_path, true);
    
    IO_handle t_font_file_handle;
    t_font_file_handle = nil;
    if (t_success)
	{
        t_font_file_handle = MCS_open(t_font_path, IO_READ_MODE, false, false, 0);
		t_success = t_font_file_handle != nil;
	}
    
    uint32_t t_file_size;
    t_file_size = 0;
    char *t_buffer;
    t_buffer = nil;
	if (t_success)
	{
		t_file_size = MCS_fsize(t_font_file_handle);
		t_success = MCMemoryAllocate(t_file_size + 1, t_buffer);
	}
    
	if (t_success)
	{
		IO_stat t_read_stat;
		uint32_t t_bytes_read;
        t_bytes_read = 0;
		while (t_success && t_bytes_read < t_file_size)
		{
			uint32_t t_count;
			t_count = t_file_size - t_bytes_read;
			t_read_stat = MCS_read(t_buffer + t_bytes_read, 1, t_count, t_font_file_handle);
			t_bytes_read += t_count;
			t_success = (t_read_stat == IO_NORMAL || (t_read_stat == IO_EOF && t_bytes_read == t_file_size));
		}
	}
    
    if (t_success)
    {
        r_buffer = t_buffer;
        r_size = t_file_size;
    }
    else
        /*UNCHECKED */ MCMemoryDelete(t_buffer);
    
    /*UNCHECKED */ MCCStringFree(t_font_path);
    
    return t_success;
}
Пример #30
0
MCUrlLoadEvent *MCUrlLoadEvent::CreateUrlLoadEvent(MCObjectHandle *p_object, MCNameRef p_message, const char *p_url, MCSystemUrlStatus p_status, void *p_data, uint32_t p_size, const char *p_error)
{
    MCUrlLoadEvent *t_event;
    t_event = new MCUrlLoadEvent();
    if (t_event == nil)
        return nil;

    t_event->m_url = nil;
    t_event->m_object = nil;
    t_event->m_status = kMCSystemUrlStatusNone;
    t_event->m_error = nil;
    t_event->m_message = nil;

    bool t_success;
    t_success = true;

    if (t_success)
        t_success = MCCStringClone(p_url, t_event->m_url);
    if (t_success)
        t_success = MCNameClone(p_message, t_event->m_message);
    if (t_success && p_status == kMCSystemUrlStatusError)
        t_success = MCCStringClone(p_error, t_event->m_error);

    if (t_success)
    {
        t_event->m_status = p_status;
        t_event->m_object = p_object;
        t_event->m_object->Retain();
        if (t_event->m_status == kMCSystemUrlStatusFinished)
        {
            t_event->m_data.bytes = p_data;
            t_event->m_data.size = p_size;
        }
    }
    else
    {
        MCCStringFree(t_event->m_url);
        MCNameDelete(t_event->m_message);
        MCCStringFree(t_event->m_error);
        delete t_event;
        return nil;
    }

    return t_event;
}