예제 #1
0
void MCSecurityGetSslCertificates(MCExecContext& ctxt, MCStringRef& r_value)
{
	if (MCStringCreateWithCString(MCsslcertificates, r_value))
		return;

	ctxt . Throw();
}
예제 #2
0
bool MCExternalHandlerList::ListExternals(MCStringRef& r_list)
{
	bool t_success;
	t_success = true;

	MCAutoListRef t_external_list;

	if (t_success)
		t_success = MCListCreateMutable('\n', &t_external_list);

	for(uindex_t i = 0; i < m_externals . Count(); i++)
	{
		MCAutoStringRef t_name_string;

		if (t_success)
			t_success = MCStringCreateWithCString(m_externals[i] -> GetName(), &t_name_string);
		if (t_success)
			t_success = MCListAppend(*t_external_list, *t_name_string);
	}

	if (t_success)
		t_success = MCListCopyAsString(*t_external_list, r_list);

	return t_success;
}
예제 #3
0
bool MCSessionStart(MCStringRef p_session_id, MCSessionRef &r_session)
{
	bool t_success = true;
	
	MCSessionIndexRef t_index = NULL;
	MCSession *t_session = NULL;
	MCSession *t_index_session = NULL;
	
	t_success = MCSessionOpenIndex(t_index);
	
	if (t_success)
	{
		if (p_session_id != NULL  && MCSessionFindMatchingSession(t_index, p_session_id, t_index_session))
		{
			t_success = MCSessionCopySession(t_index_session, t_session);
		}
		else
		{
			t_success = MCSessionCreateSession(t_index, p_session_id, t_session);
		}
		
		MCAutoStringRef t_session_name;
		if (t_success)
			t_success = MCS_get_session_name(&t_session_name);
			
		if (t_success)
		{
			MCAutoStringRef t_session_id_str;
			/* UNCHECKED */ MCStringCreateWithCString(t_session->id, &t_session_id_str);
			t_success = MCServerSetCookie(*t_session_name, *t_session_id_str, 0, nil, nil, false, true);
		}
		
		if (t_success)
			t_success = MCSessionOpenSession(t_index, t_session);
		
		if (t_success)
			MCSessionRefreshExpireTime(t_session);
	}

	if (t_index != NULL)
		t_success &= MCSessionCloseIndex(t_index, t_success);
	
	if (t_success)
		r_session = t_session;
	else
	{
		if (t_session != NULL)
			MCSessionCloseSession(t_session, false);
	}
	
	return t_success;
}
예제 #4
0
bool MCSessionCloseSession(MCSession *p_session, bool p_update)
{
	bool t_success = true;
	
	if (p_session == NULL)
		return true;
	
	if (p_update)
	{
		MCSessionIndexRef t_index = NULL;
		MCSession *t_index_session = NULL;
		
		t_success = MCSessionOpenIndex(t_index);
		if (t_success)
		{
			MCAutoStringRef t_session_id;
			/* UNCHECKED */ MCStringCreateWithCString(p_session->id, &t_session_id);
			if (!MCSessionFindMatchingSession(t_index, *t_session_id, t_index_session))
			{
				t_success = MCSessionIndexAddSession(t_index, p_session);
				if (t_success)
					t_success = MCSessionFindMatchingSession(t_index, *t_session_id, t_index_session);
			}
		}
		if (t_success)
			MCSessionRefreshExpireTime(t_index_session);

		if (t_success)
			t_success = MCSessionCloseIndex(t_index, true);
	}
	if (p_session->filehandle != NULL)
	{
		if (p_update)
		{
			if (t_success)
				t_success = p_session->filehandle->Seek(0, 1);
			if (t_success)
				t_success = MCSessionWriteSession(p_session);
			if (t_success)
				t_success = p_session->filehandle->Flush();
			if (t_success)
				t_success = p_session->filehandle->Truncate();
		}
		p_session->filehandle->Close();
	}
	
	MCSessionDisposeSession(p_session);
	
	return t_success;
}
예제 #5
0
void MCButton::GetAcceleratorKey(MCExecContext& ctxt, MCStringRef& r_key)
{
	if (accelkey & 0xFF00)
	{
		const char *t_keyname = MCLookupAcceleratorName(accelkey);
		if (t_keyname == NULL || MCStringCreateWithCString(t_keyname, r_key))
			return;
	}
    else if (accelkey)
    {
        char t_accel_key = (char)accelkey;
        if (MCStringFormat(r_key, "%c", t_accel_key))
            return;
    }
    else
        return;

	ctxt . Throw();
}
예제 #6
0
파일: rtf.cpp 프로젝트: alilloyd/livecode
void RTFReader::ProcessField(void)
{
	if (m_field_inst == nil)
		return;

	char *t_type, *t_data;
	t_type = m_field_inst;
	while(isspace(*t_type))
		t_type++;
	t_data = strchr(t_type, ' ');
	if (t_data != nil)
	{
		char *t_type_end;
		t_type_end = t_data;

		while(isspace(*t_data))
			t_data++;
	
		*t_type_end = '\0';

		if (*t_data == '"')
		{
			char *t_data_end;
			t_data += 1;
			t_data_end = t_data;
			while(*t_data_end != '\0' && *t_data_end != '\"')
				t_data_end++;
			if (*t_data_end == '\"')
				*t_data_end = '\0';
			else
				t_data = nil;
		}
		else
			t_data = nil;		
	}

	if (t_type != nil && t_data != nil)
	{
		MCNameRef t_name;
		/* UNCHECKED */ MCNameCreateWithCString(t_data, t_name);
        MCAutoStringRef t_string;
        /* UNCHECKED */ MCStringCreateWithCString(t_data, &t_string);
		if (MCU_strcasecmp(t_type, "HYPERLINK") == 0)
		{
            m_state . SetHyperlink(t_name);
			m_state . SetFontStyle(m_state . GetFontStyle() | kRTFFontStyleLink);
		}
		else if (MCU_strcasecmp(t_type, "LCANCHOR") == 0)
		{
			m_state . SetHyperlink(t_name);
		}
		else if (MCU_strcasecmp(t_type, "LCMETADATA") == 0)
        {
            m_state . SetMetadata(*t_string);
		}
		else if (MCU_strcasecmp(t_type, "LCLINEMETADATA") == 0)
        {
            m_state . SetParagraphMetadata(*t_string);
		}
		MCNameDelete(t_name);
	}

	free(m_field_inst);
	m_field_inst = nil;
}
예제 #7
0
// This call is primarily designed to be used by the plugin installer. As this
// is generally installed 'per-user', we simply scan '/proc' for processes owned
// by the calling user.
bool MCSystemListProcesses(MCSystemListProcessesCallback p_callback, void* p_context)
{
	bool t_success;
	t_success = true;

	DIR *t_dir;
	t_dir = nil;
	if (t_success)
	{
		t_dir = opendir("/proc");
		if (t_dir == nil)
			t_success = false;
	}

	if (t_success)
	{
		dirent *t_entry;
		while(t_success)
		{
			// Fetch the next entry
			t_entry = readdir(t_dir);
			if (t_entry == nil)
				break;

			// Work out if the entry is a process id
			int32_t t_pid;
            MCAutoStringRef t_dname;
            /* UNCHECKED */ MCStringCreateWithCString(t_entry -> d_name, &t_dname);
			if (!MCU_strtol(*t_dname, t_pid))
				continue;

			// Work out the full path ("/proc/<int>") and stat so we can
			// check ownership.
			char t_path[6 + I4L + 1];
			struct stat64 t_stat;
			sprintf(t_path, "/proc/%u", t_pid);
			stat64(t_path, &t_stat);
			if (t_stat . st_uid != getuid())
				continue;

			// We have a viable process to report. First fetch its path
            MCAutoStringRef t_exe_link, t_exe_path;
            /* UNCHECKED */ MCStringFormat(&t_exe_link, "/proc/%u/exe", t_pid);
			if (!MCS_resolvepath(*t_exe_link, &t_exe_path))
			{
				t_success = false;
				break;
			}

			// Next fetch its 'description' from the first line of the status
			// file.
			char t_status_file[6 + I4L + 7 + 1];
			char t_status[256];
			FILE *t_stream;
			sprintf(t_status_file, "/proc/%u/status", t_pid);
			t_stream = fopen(t_status_file, "r");
			if (t_stream != nil)
			{
				if (fgets(t_status, 256, t_stream) != nil)
				{
					char *t_tab;
					t_tab = strchr(t_status, '\t');
					if (t_tab != nil)
						MCMemoryMove(t_status, t_tab + 1, MCCStringLength(t_tab + 1));
				}
				else
					t_status[0] = '\0';
				fclose(t_stream);
			}
			else
				t_status[0] = '\0';

            MCAutoStringRef t_status_str;
            /* UNCHECKED */ MCStringCreateWithSysString(t_status, &t_status_str);
			t_success = p_callback(p_context, t_pid, *t_exe_path, *t_status_str);
		}
	}

	if (t_dir != nil)
		closedir(t_dir);

	return t_success;
}
예제 #8
0
bool MCFileSystemListEntries(const char *p_folder, uint32_t p_options, MCFileSystemListCallback p_callback, void *p_context)
{
	bool t_success;
	t_success = true;

	char *t_pattern;
	t_pattern = nil;
	if (t_success)
		t_success = MCCStringFormat(t_pattern, "%s%s", p_folder, MCCStringEndsWith(p_folder, "/") ? "*" : "/*");

	void *t_native_pattern;
	t_native_pattern = nil;
	if (t_success)
		t_success = MCFileSystemPathToNative(t_pattern, t_native_pattern);

	HANDLE t_find_handle;
	WIN32_FIND_DATAW t_find_data;
	t_find_handle = INVALID_HANDLE_VALUE;
	if (t_success)
	{
		t_find_handle = FindFirstFileW((LPCWSTR)t_native_pattern, &t_find_data);
		if (t_find_handle == INVALID_HANDLE_VALUE)
			t_success = false;
	}

	while(t_success)
	{
		char *t_entry_filename;
		if (t_success)
			t_success = MCFileSystemPathFromNative(t_find_data . cFileName, t_entry_filename);

		MCFileSystemEntry t_entry;
		if (t_success)
		{
			t_entry . type = (t_find_data . dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0 ? kMCFileSystemEntryFolder : kMCFileSystemEntryFile;
			MCStringCreateWithCString(t_entry_filename, t_entry.filename);
			//t_entry . filename = t_entry_filename;

			t_success = p_callback(p_context, t_entry);
		}

		MCCStringFree(t_entry_filename);

		////

		if (!FindNextFileW(t_find_handle, &t_find_data))
		{
			if (GetLastError() == ERROR_NO_MORE_FILES)
				break;

			t_success = false;
		}
	}

	if (t_find_handle != INVALID_HANDLE_VALUE)
		FindClose(t_find_handle);

	MCMemoryDeallocate(t_native_pattern);
	MCCStringFree(t_pattern);

	return t_success;
}