Example #1
0
/*
Ritorna lo schema del table_type.
*/
Pschema table_type(Pnode type_node){
#ifdef DEBUG_TABLE_TYPE
	printf( "TABLE_TYPE - enter\n");
#endif
	//Creo lo schema
	Pschema schema = (Pschema) newmem(sizeof(Schema));
	schema->name = NULL;

	//Imposto il type (che sarà TABLE)
	schema->type = qualifier(type_node);
	
	//Genero la lista di attributi
	schema->next = attr_list(type_node->child);
	
#ifdef DEBUG_TABLE_TYPE
	printf( "TABLE_TYPE - ok attr_list definition\n");
#endif
	return schema;
}
Example #2
0
static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t size, int flags)
{
	int retval = 0, index;
	attrlist_cursor_t *cursor = 0;
	int total_size = 0;
	attrlist_t * al = (attrlist_t *)attr_buffer;
	attrlist_ent_t *ae;
	size_t ent_size, left = size;
	char *bp = list;

	while (True) {
	    if (filedes)
		retval = attr_listf(filedes, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
	    else
		retval = attr_list(path, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
	    if (retval) break;
	    for (index = 0; index < al->al_count; index++) {
		ae = ATTR_ENTRY(attr_buffer, index);
		ent_size = strlen(ae->a_name) + sizeof("user.");
		if (left >= ent_size) {
		    strncpy(bp, "user.", sizeof("user."));
		    strncat(bp, ae->a_name, ent_size - sizeof("user."));
		    bp += ent_size;
		    left -= ent_size;
		} else if (size) {
		    errno = ERANGE;
		    retval = -1;
		    break;
		}
		total_size += ent_size;
	    }
	    if (al->al_more == 0) break;
	}
	if (retval == 0) {
	    flags |= ATTR_ROOT;
	    cursor = 0;
	    while (True) {
		if (filedes)
		    retval = attr_listf(filedes, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
		else
		    retval = attr_list(path, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
		if (retval) break;
		for (index = 0; index < al->al_count; index++) {
		    ae = ATTR_ENTRY(attr_buffer, index);
		    ent_size = strlen(ae->a_name) + sizeof("system.");
		    if (left >= ent_size) {
			strncpy(bp, "system.", sizeof("system."));
			strncat(bp, ae->a_name, ent_size - sizeof("system."));
			bp += ent_size;
			left -= ent_size;
		    } else if (size) {
			errno = ERANGE;
			retval = -1;
			break;
		    }
		    total_size += ent_size;
		}
		if (al->al_more == 0) break;
	    }
	}
	return (ssize_t)(retval ? retval : total_size);
}
Example #3
0
void table_type(){
	match(TABLE);
	match('(');
	attr_list();
	match(')');	
}
Example #4
0
pair<shared_ptr<process>, shared_ptr<thread_suspension> > restricted_env::create_process(
	const string &executable_path, const string &command_line, const path_a &current_dir,
	HANDLE stdin_handle, HANDLE stdout_handle, HANDLE stderr_handle)
{
	string desktop_name = window_station_.name() + "\\" + desktop_.name();
	PROCESS_INFORMATION process_info;
	BOOL result;

	if (!proc_thread_attribute_list::is_supported()) {
		STARTUPINFOA startup_info = {0};
		startup_info.cb = sizeof(startup_info);
		startup_info.lpDesktop = const_cast<LPSTR>(desktop_name.c_str());
		startup_info.dwFlags = STARTF_FORCEOFFFEEDBACK | STARTF_USESTDHANDLES;

		uintptr_t handle_value = 0;
		duplicate_handle stdin_h(stdin_handle, handle_value);
		duplicate_handle stdout_h(stdout_handle, handle_value);
		duplicate_handle stderr_h(stderr_handle, handle_value);
		startup_info.hStdInput = stdin_h.target();
		startup_info.hStdOutput = stdout_h.target();
		startup_info.hStdError = stderr_h.target();

		result = ::CreateProcessAsUserA(session_.handle(), executable_path.empty() ? NULL : executable_path.c_str(),
			const_cast<LPSTR>(command_line.c_str()), NULL, NULL, FALSE,
			CREATE_BREAKAWAY_FROM_JOB | CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW | CREATE_SUSPENDED,
			NULL, current_dir.c_str(), &startup_info, &process_info);

		if (result) {
			try {
				stdin_h(process_info.hProcess);
				stdout_h(process_info.hProcess);
				stderr_h(process_info.hProcess);
			} catch (...) {
				::TerminateProcess(process_info.hProcess, 1);
				::CloseHandle(process_info.hProcess);
				::CloseHandle(process_info.hThread);
				throw;
			}
		}

	} else {
		inherit_handle stdin_h(stdin_handle);
		inherit_handle stdout_h(stdout_handle);
		inherit_handle stderr_h(stderr_handle);

		proc_thread_attribute_list attr_list(1);
		vector<HANDLE> handle_list;
		if (stdin_handle) handle_list.push_back(stdin_handle);
		if (stdout_handle) handle_list.push_back(stdout_handle);
		if (stderr_handle) handle_list.push_back(stderr_handle);
		sort(handle_list.begin(), handle_list.end());
		handle_list.erase(unique(handle_list.begin(), handle_list.end()), handle_list.end());
		attr_list.update(PROC_THREAD_ATTRIBUTE_HANDLE_LIST, handle_list.data(), handle_list.size() * sizeof(HANDLE));

		STARTUPINFOEXA info = {0};
		info.StartupInfo.cb = sizeof(info);
		info.StartupInfo.lpDesktop = const_cast<LPSTR>(desktop_name.c_str());
		info.StartupInfo.dwFlags = STARTF_FORCEOFFFEEDBACK | STARTF_USESTDHANDLES;
		info.StartupInfo.hStdInput = stdin_handle;
		info.StartupInfo.hStdOutput = stdout_handle;
		info.StartupInfo.hStdError = stderr_handle;
		info.lpAttributeList = attr_list.pointer();

		result = ::CreateProcessAsUserA(session_.handle(), executable_path.empty() ? NULL : executable_path.c_str(),
			const_cast<LPSTR>(command_line.c_str()), NULL, NULL, TRUE,
			CREATE_BREAKAWAY_FROM_JOB | CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW | CREATE_SUSPENDED | EXTENDED_STARTUPINFO_PRESENT,
			NULL, current_dir.c_str(), &info.StartupInfo, &process_info);
	}

	if (!result) {
		throw win32_exception(::GetLastError());
	}

	shared_ptr<process> p;
	try {
		p.reset(new process(process_info.hProcess));
	} catch (...) {
		::TerminateProcess(process_info.hProcess, 1);
		::CloseHandle(process_info.hProcess);
		::CloseHandle(process_info.hThread);
		throw;
	}

	shared_ptr<thread_suspension> t;
	try {
		t.reset(new thread_suspension(process_info.hThread));
	} catch (...) {
		::TerminateProcess(process_info.hProcess, 1);
		::CloseHandle(process_info.hThread);
		throw;
	}

	return make_pair(move(p), move(t));
}