• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PRINT_ERROR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PRINT_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ PRINT_ERROR函数的具体用法?C++ PRINT_ERROR怎么用?C++ PRINT_ERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PRINT_ERROR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse_command_line

int parse_command_line(int argc, char *argv[], char ***params, int switcher_no, char *switchers[])
{
FILE *ptr	= NULL;
int i		= 0;
int j		= 0;

	if (argc!=(switcher_no*2+1))
	{
		printf("\n----------- Rencryption software for BMD 1.7.1 (Unizeto Technologies SA) ------------\n");
		printf("executive parameters:\n");
		printf("\t%s level\t\tdebug level\n",switchers[0]);
		printf("\t%s file\t\t\tbmd config file\n",switchers[1]);
		printf("\t%s .pfx file\t\tcertificate for rencrypting from\n",switchers[2]);
		printf("\t%s .pfx file\t\tcertificate for rencrypting to\n",switchers[3]);
		printf("\t%s password\t\tpassword for certificate for rencrypting from\n",switchers[4]);
		printf("\t%s password\t\tpassword for certificate for rencrypting to\n",switchers[5]);
		printf("\t%s id number\tfile's id number to rencrypt database from\n",switchers[6]);
		printf("\t%s id number\tfile's id number to rencrypt database to\n",switchers[7]);
		printf("-------------------------------------------------------------------------------------\n\n");
		printf("Error: Invalid parameters\n");
		return -1;
	}
	/********************************/
	/*	pasowanie linii polecen	*/
	/********************************/
	(*params)=(char **)malloc(switcher_no*sizeof(char*));
	for (i=1; i<argc; i++)
	{
		for (j=0; j<switcher_no; j++)
		{
			if (strcmp(argv[i],switchers[j])==0)
			{
				asprintf(&((*params)[j]),"%s",argv[i+1]);
				break;
			}
		}
	}

	/************************************************/
	/*	sprawdzenie poprawnosci parametrow	*/
	/************************************************/
	for (i=0; i<strlen((*params)[0]); i++)
	{
		if ((((*params)[0][i]<'0') || ((*params)[0][i]>'9')) && (*params)[0][i]!='-')
		{
			PRINT_ERROR("Invalid debug level format\n");
			return -2;
		}
	}

	_GLOBAL_debug_level = atoi((*params)[0]);
	if ((ptr=fopen((*params)[1],"r"))==NULL)
	{
		PRINT_ERROR("Cannot open configuration file\n");
		return -3;
	}
	else fclose(ptr);

	if ((ptr=fopen((*params)[2],"r"))==NULL)
	{
		PRINT_ERROR("Cannot open pfx file %s\n",(*params)[2]);
		return -4;
	}
	else fclose(ptr);

	if ((ptr=fopen((*params)[3],"r"))==NULL)
	{
		PRINT_ERROR("Cannot open pfx file %s\n",(*params)[3]);
		return -5;
	}
	else fclose(ptr);

	return 0;
}
开发者ID:unizeto,项目名称:bmd,代码行数:74,代码来源:rencryption.c


示例2: state_bcm

void state_bcm() {
	int i, j, ret;
	struct sockaddr_can caddr;
	socklen_t caddrlen = sizeof(caddr);
	struct ifreq ifr;
	char rxmsg[RXLEN];
	char buf[MAXLEN];

	struct {
		struct bcm_msg_head msg_head;
		struct can_frame frame;
	} msg;

	struct {
		struct bcm_msg_head msg_head;
		struct can_frame frame[257]; /* MAX_NFRAMES + MUX MASK */
	} muxmsg;

	if(previous_state != STATE_BCM) {
		/* open BCM socket */
		if ((sc = socket(PF_CAN, SOCK_DGRAM, CAN_BCM)) < 0) {
			PRINT_ERROR("Error while opening BCM socket %s\n", strerror(errno));
			state = STATE_SHUTDOWN;
			return;
		}

		memset(&caddr, 0, sizeof(caddr));
		caddr.can_family = PF_CAN;
		/* can_ifindex is set to 0 (any device) => need for sendto() */

		PRINT_VERBOSE("connecting BCM socket...\n")
			if (connect(sc, (struct sockaddr *)&caddr, sizeof(caddr)) < 0) {
				PRINT_ERROR("Error while connecting BCM socket %s\n", strerror(errno));
				state = STATE_SHUTDOWN;
				return;
			}
		previous_state = STATE_BCM;
	}

	FD_ZERO(&readfds);
	FD_SET(sc, &readfds);
	FD_SET(client_socket, &readfds);

	/*
	 * Check if there are more elements in the element buffer before calling select() and
	 * blocking for new packets.
	 */
	if(more_elements) {
		FD_CLR(sc, &readfds);
	} else {
		ret = select((sc > client_socket)?sc+1:client_socket+1, &readfds, NULL, NULL, NULL);

		if(ret < 0) {
			PRINT_ERROR("Error in select()\n")
				state = STATE_SHUTDOWN;
			return;
		}
	}

	if (FD_ISSET(sc, &readfds)) {

		ret = recvfrom(sc, &msg, sizeof(msg), 0,
			       (struct sockaddr*)&caddr, &caddrlen);

		/* read timestamp data */
		if(ioctl(sc, SIOCGSTAMP, &tv) < 0) {
			PRINT_ERROR("Could not receive timestamp\n");
		}

		/* Check if this is an error frame */
		if(msg.msg_head.can_id & CAN_ERR_FLAG) {
			if(msg.frame.can_dlc != CAN_ERR_DLC) {
				PRINT_ERROR("Error frame has a wrong DLC!\n")
					} else {
				snprintf(rxmsg, RXLEN, "< error %03X %ld.%06ld ", msg.msg_head.can_id, tv.tv_sec, tv.tv_usec);

				for ( i = 0; i < msg.frame.can_dlc; i++)
					snprintf(rxmsg + strlen(rxmsg), RXLEN - strlen(rxmsg), "%02X ",
						 msg.frame.data[i]);

				snprintf(rxmsg + strlen(rxmsg), RXLEN - strlen(rxmsg), " >");
				send(client_socket, rxmsg, strlen(rxmsg), 0);
			}
		} else {
			if(msg.msg_head.can_id & CAN_EFF_FLAG) {
开发者ID:btolfa,项目名称:socketcand,代码行数:85,代码来源:state_bcm.c


示例3: kuhl_m_vault_list_descItem_PINLogonOrPicturePasswordOrBiometric

void CALLBACK kuhl_m_vault_list_descItem_PINLogonOrPicturePasswordOrBiometric(const VAULT_GUID_STRING * pGuidString, PVOID enumItem, PVOID getItem, BOOL is8)
{
	PVAULT_ITEM_8 enumItem8 = (PVAULT_ITEM_8) enumItem, getItem8 = (PVAULT_ITEM_8) getItem;
	PWSTR name, domain, sid, bgPath = NULL;
	UNICODE_STRING uString;
	DWORD i, dwError, szNeeded;
	PVAULT_PICTURE_PASSWORD_ELEMENT pElements;
	PVAULT_BIOMETRIC_ELEMENT bElements;
	PWCHAR bufferStart;
	HKEY hPicturePassword, hUserPicturePassword;

	if(enumItem8->Identity && (enumItem8->Identity->Type == ElementType_ByteArray))
	{
		kprintf(L"\t\tUser : ");
		if(kull_m_token_getNameDomainFromSID((PSID) enumItem8->Identity->data.ByteArray.Value, &name, &domain, NULL))
		{
			kprintf(L"\t\tUser            : %s\\%s\n", domain, name);
			LocalFree(name);
			LocalFree(domain);
		}
		else kull_m_string_displaySID((PSID) enumItem8->Identity->data.ByteArray.Value);
		kprintf(L"\n");

		if(pGuidString->guid.Data1 == 0x0b4b8a12b)
		{
			dwError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Authentication\\LogonUI\\PicturePassword", 0, KEY_ENUMERATE_SUB_KEYS, &hPicturePassword);
			if(dwError == STATUS_SUCCESS)
			{
				if(ConvertSidToStringSid((PSID) enumItem8->Identity->data.ByteArray.Value, &sid))
				{
					dwError = RegOpenKeyEx(hPicturePassword, sid, 0, KEY_QUERY_VALUE, &hUserPicturePassword);
					if(dwError == STATUS_SUCCESS)
					{
						dwError = RegQueryValueEx(hUserPicturePassword, L"bgPath", NULL, NULL, NULL, &szNeeded);
						if(dwError == STATUS_SUCCESS)
						{
							if(bgPath = (PWSTR) LocalAlloc(LPTR, szNeeded))
							{
								dwError = RegQueryValueEx(hUserPicturePassword, L"bgPath", NULL, NULL, (LPBYTE) bgPath, &szNeeded);
								if(dwError != STATUS_SUCCESS)
								{
									PRINT_ERROR(L"RegQueryValueEx 2 : %08x\n", dwError);
									bgPath = (PWSTR) LocalFree(bgPath);
								}
							}
						}
						else PRINT_ERROR(L"RegQueryValueEx 1 : %08x\n", dwError);
						RegCloseKey(hUserPicturePassword);
					}
					else PRINT_ERROR(L"RegOpenKeyEx SID : %08x\n", dwError);
					LocalFree(sid);
				}
				else PRINT_ERROR_AUTO(L"ConvertSidToStringSid");
				RegCloseKey(hPicturePassword);
			}
			else PRINT_ERROR(L"RegOpenKeyEx PicturePassword : %08x\n", dwError);
		}
	}

	if(getItem8 && getItem8->Authenticator && (getItem8->Authenticator->Type == ElementType_ByteArray))
	{
		uString.Length = uString.MaximumLength = (USHORT) getItem8->Authenticator->data.ByteArray.Length;
		uString.Buffer = (PWSTR) getItem8->Authenticator->data.ByteArray.Value;
		kprintf(L"\t\tPassword        : ");
		if(kull_m_string_suspectUnicodeString(&uString))
			kprintf(L"%s", uString.Buffer);
		else 
			kull_m_string_wprintf_hex(uString.Buffer, uString.Length, 1);
		kprintf(L"\n");
	}

	if(enumItem8->Properties && (enumItem8->cbProperties > 0) && enumItem8->Properties + 0)
	{
		switch(pGuidString->guid.Data1)
		{
		case 0x0b2e033f5:	// pin
			if((enumItem8->Properties + 0)->Type == ElementType_UnsignedShort)
				kprintf(L"\t\tPIN Code        : %04hu\n", (enumItem8->Properties + 0)->data.UnsignedShort);
			break;
		case 0x0b4b8a12b:	// picture
			if((enumItem8->Properties + 0)->Type == ElementType_ByteArray)
			{
				pElements = (PVAULT_PICTURE_PASSWORD_ELEMENT) (enumItem8->Properties + 0)->data.ByteArray.Value;
				if(bgPath)
				{
					kprintf(L"\t\tBackground path : %s\n", bgPath);
					LocalFree(bgPath);
				}
				kprintf(L"\t\tPicture password (grid is 150*100)\n");

				for(i = 0; i < 3; i++)
				{
					kprintf(L"\t\t [%u] ", i);
					switch(pElements[i].Type)
					{
					case PP_Point:
						kprintf(L"point  (x = %3u ; y = %3u)", pElements[i].point.coord.x, pElements[i].point.coord.y);
						break;
					case PP_Circle:
						kprintf(L"circle (x = %3u ; y = %3u ; r = %3u) - %s", pElements[i].circle.coord.x, pElements[i].circle.coord.y, pElements[i].circle.size, (pElements[i].circle.clockwise ? L"clockwise" : L"anticlockwise"));
//.........这里部分代码省略.........
开发者ID:AnwarMohamed,项目名称:meterpreter,代码行数:101,代码来源:kuhl_m_vault.c


示例4: rtm_read_param_reply

void rtm_read_param_reply(struct fins_module *module, struct finsFrame *ff) {
	PRINT_DEBUG("Entered: module=%p, ff=%p, meta=%p", module, ff, ff->metaData);
	struct rtm_data *md = (struct rtm_data *) module->data;

	secure_sem_wait(&md->shared_sem);
	struct rtm_command *cmd = (struct rtm_command *) list_find1(md->cmd_list, rtm_cmd_serial_test, &ff->ctrlFrame.serial_num);
	if (cmd != NULL) {
		list_remove(md->cmd_list, cmd);

		struct rtm_console *console = (struct rtm_console *) list_find1(md->console_list, rtm_console_id_test, &cmd->console_id);
		if (console != NULL) {
			//TODO extract answer
			if (ff->ctrlFrame.ret_val == FCF_TRUE) {
				char temp[100];

				int32_t val_int32;
				int64_t val_int64;
				float val_float;
				char *val_str;

				switch (cmd->param_type) {
				case META_TYPE_INT32:
					secure_metadata_readFromElement(ff->metaData, "value", &val_int32);
					sprintf(temp, "'%s'=%d", cmd->param_str, val_int32);
					break;
				case META_TYPE_INT64:
					secure_metadata_readFromElement(ff->metaData, "value", &val_int64);
					sprintf(temp, "'%s'=%lld", cmd->param_str, val_int64);
					break;
				case META_TYPE_FLOAT:
					secure_metadata_readFromElement(ff->metaData, "value", &val_float);
					sprintf(temp, "'%s'=%f", cmd->param_str, val_float);
					break;
				case META_TYPE_STRING:
					secure_metadata_readFromElement(ff->metaData, "value", &val_str);
					sprintf(temp, "'%s'='%s'", cmd->param_str, val_str);
					break;
				default:
					PRINT_ERROR("todo error");
					exit(-1);
				}

				rtm_send_text(console->fd, temp);
			} else {
				//send error
				uint32_t ret_msg;
				secure_metadata_readFromElement(ff->metaData, "ret_msg", &ret_msg);

				char temp[100];
				sprintf(temp, "unsuccessful, returned error=%u", ret_msg);
				rtm_send_text(console->fd, temp);
			}
		} else {
			PRINT_WARN("todo error");
		}
		sem_post(&md->shared_sem);

		free(cmd);
	} else {
		sem_post(&md->shared_sem);
		PRINT_WARN("todo error");
		//TODO error, drop
		freeFinsFrame(ff);
	}
}
开发者ID:c-ong,项目名称:FINS-Framework,代码行数:65,代码来源:rtm.c


示例5: kull_m_rpc_drsr_free_DRS_MSG_GETCHGREPLY_data

void kull_m_rpc_drsr_free_DRS_MSG_GETCHGREPLY_data(DWORD dwOutVersion, DRS_MSG_GETCHGREPLY * reply)
{
	DWORD i, j;
	REPLENTINFLIST *pReplentinflist, *pNextReplentinflist;
	if(reply)
	{
		switch(dwOutVersion)
		{
		case 6:
			if(reply->V6.pNC)
				MIDL_user_free(reply->V6.pNC);
			if(reply->V6.pUpToDateVecSrc)
				MIDL_user_free(reply->V6.pUpToDateVecSrc);
			if(reply->V6.PrefixTableSrc.pPrefixEntry)
			{
				for(i = 0; i < reply->V6.PrefixTableSrc.PrefixCount; i++)
					if(reply->V6.PrefixTableSrc.pPrefixEntry[i].prefix.elements)
						MIDL_user_free(reply->V6.PrefixTableSrc.pPrefixEntry[i].prefix.elements);
				MIDL_user_free(reply->V6.PrefixTableSrc.pPrefixEntry);
			}
			pNextReplentinflist = reply->V6.pObjects;
			while(pReplentinflist = pNextReplentinflist)
			{
				pNextReplentinflist = pReplentinflist->pNextEntInf;
				if(pReplentinflist->Entinf.pName)
					MIDL_user_free(pReplentinflist->Entinf.pName);
				if(pReplentinflist->Entinf.AttrBlock.pAttr)
				{
					for(i = 0; i < pReplentinflist->Entinf.AttrBlock.attrCount; i++)
					{
						if(pReplentinflist->Entinf.AttrBlock.pAttr[i].AttrVal.pAVal)
						{
							for(j = 0; j < pReplentinflist->Entinf.AttrBlock.pAttr[i].AttrVal.valCount; j++)
								if(pReplentinflist->Entinf.AttrBlock.pAttr[i].AttrVal.pAVal[j].pVal)
									MIDL_user_free(pReplentinflist->Entinf.AttrBlock.pAttr[i].AttrVal.pAVal[j].pVal);
							MIDL_user_free(pReplentinflist->Entinf.AttrBlock.pAttr[i].AttrVal.pAVal);
						}
					}
					MIDL_user_free(pReplentinflist->Entinf.AttrBlock.pAttr);
				}
				if(pReplentinflist->pParentGuid)
					MIDL_user_free(pReplentinflist->pParentGuid);
				if(pReplentinflist->pMetaDataExt)
					MIDL_user_free(pReplentinflist->pMetaDataExt);
				MIDL_user_free(pReplentinflist);
			}
			if(reply->V6.rgValues)
			{
				for(i = 0; i < reply->V6.cNumValues; i++)
				{
					if(reply->V6.rgValues[i].pObject)
						MIDL_user_free(reply->V6.rgValues[i].pObject);
					if(reply->V6.rgValues[i].Aval.pVal)
						MIDL_user_free(reply->V6.rgValues[i].Aval.pVal);
				}
				MIDL_user_free(reply->V6.rgValues);
			}
			break;
		case 1:
		case 2:
		case 7:
		case 9:
			PRINT_ERROR(L"TODO (maybe?)\n");
			break;
		default:
			PRINT_ERROR(L"dwOutVersion not valid (0x%08x - %u)\n", dwOutVersion, dwOutVersion);
			break;
		}
	}
}
开发者ID:0x4e38,项目名称:mimikatz,代码行数:70,代码来源:kull_m_rpc_drsr.c


示例6: switch

	RenderBuffer* D3DRenderFactory::MakeRenderBuffer( InitData& init_data, AccessType access_type, BufferUsage usage, uint32_t width, uint32_t type_size)
	{
		//TODO : Change BufferUsage to support OR operation
		D3DRenderEngine* d3d_re = static_cast<D3DRenderEngine*>(&Context::Instance().GetRenderFactory().GetRenderEngine());
		D3D11_BUFFER_DESC buffer_desc;
		buffer_desc.ByteWidth = type_size * width;
		buffer_desc.Usage = D3D11_USAGE_DEFAULT;
		buffer_desc.BindFlags = 0;
		buffer_desc.CPUAccessFlags = 0;
		buffer_desc.MiscFlags = 0;
		buffer_desc.StructureByteStride = 0;
		D3D11_SUBRESOURCE_DATA data;
		data.pSysMem = init_data.data;
		data.SysMemPitch = init_data.row_pitch;
		data.SysMemSlicePitch = init_data.slice_pitch;
		switch (usage)
		{
		case BU_VERTEX:
			{
				buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
				break;
			}
		case BU_INDEX:
			{				
				buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
				break;
			}
		case BU_SHADER_RES:
			{
				buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
				break;
			}
		case BU_SHADER_CONST:
			break;
		case  BU_STRUCTURED_BUFFER:
			break;
		case BU_SR_SB:
			{
				buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
				buffer_desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
				buffer_desc.StructureByteStride = type_size;
			}
			break;
		default:
			break;
		}

		switch (access_type)
		{
		case AT_CPU_GPU_ALL:
			buffer_desc.Usage = D3D11_USAGE_STAGING;
			buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
			break;
		case AT_CPU_WRITE_GPU_READ:
			buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
			buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
			break;
		case AT_GPU_READ_ONLY:
			buffer_desc.Usage = D3D11_USAGE_IMMUTABLE;
			buffer_desc.CPUAccessFlags = 0;
			break;
		case AT_GPU_READ_WRITE:
			buffer_desc.Usage = D3D11_USAGE_DEFAULT;
			buffer_desc.CPUAccessFlags = 0;
			break;
		default:
			buffer_desc.Usage = D3D11_USAGE_DEFAULT;
			buffer_desc.CPUAccessFlags = 0;
			break;
		}
		ID3D11Buffer* buffer;
		HRESULT result = d3d_re->D3DDevice()->CreateBuffer(&buffer_desc, &data, &buffer);
		if(FAILED(result))
		{
			PRINT_ERROR("Cannot create Buffer");
		}
		D3DRenderBuffer* d3d_render_buffer = new D3DRenderBuffer(buffer, usage, access_type);
		return d3d_render_buffer;
		
	}
开发者ID:vanish87,项目名称:vEngine,代码行数:80,代码来源:D3DRenderFactory.cpp


示例7: kuhl_m_net_user

NTSTATUS kuhl_m_net_user(int argc, wchar_t * argv[])
{
	NTSTATUS status, enumDomainStatus, enumUserStatus;
	UNICODE_STRING serverName, *groupName;
	SAMPR_HANDLE hServerHandle, hBuiltinHandle = NULL, hDomainHandle, hUserHandle;
	DWORD domainEnumerationContext, domainCountRetourned, userEnumerationContext, userCountRetourned, groupsCountRetourned, i, j, k, *usage, aliasCountRetourned, *alias;
	PSAMPR_RID_ENUMERATION pEnumDomainBuffer, pEnumUsersBuffer;
	PSID domainSid, userSid;
	PGROUP_MEMBERSHIP pGroupMemberShip;
	SID builtin = {1, 1, {0, 0, 0, 0, 0, 5}, {32}};

	RtlInitUnicodeString(&serverName, argc ? argv[0] : L"");
	status = SamConnect(&serverName, &hServerHandle, SAM_SERVER_CONNECT | SAM_SERVER_ENUMERATE_DOMAINS | SAM_SERVER_LOOKUP_DOMAIN, FALSE);
	if(NT_SUCCESS(status))
	{
		status = SamOpenDomain(hServerHandle, DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, &builtin, &hBuiltinHandle);
		if(!NT_SUCCESS(status))
			PRINT_ERROR(L"SamOpenDomain Builtin (?) %08x\n", status);
		
		domainEnumerationContext = 0;
		do
		{
			enumDomainStatus = SamEnumerateDomainsInSamServer(hServerHandle, &domainEnumerationContext, &pEnumDomainBuffer, 1, &domainCountRetourned);
			if(NT_SUCCESS(enumDomainStatus) || enumDomainStatus == STATUS_MORE_ENTRIES)
			{
				for(i = 0; i < domainCountRetourned; i++)
				{
					kprintf(L"\nDomain name : %wZ", &pEnumDomainBuffer[i].Name);
					status = SamLookupDomainInSamServer(hServerHandle, &pEnumDomainBuffer[i].Name, &domainSid);
					if(NT_SUCCESS(status))
					{
						kprintf(L"\nDomain SID  : ");
						kull_m_string_displaySID(domainSid);
						
						status = SamOpenDomain(hServerHandle, DOMAIN_LIST_ACCOUNTS | DOMAIN_LOOKUP, domainSid, &hDomainHandle);
						if(NT_SUCCESS(status))
						{
							userEnumerationContext = 0;
							do
							{
								enumUserStatus = SamEnumerateUsersInDomain(hDomainHandle, &userEnumerationContext, 0/*UF_NORMAL_ACCOUNT*/, &pEnumUsersBuffer, 1, &userCountRetourned);
								if(NT_SUCCESS(enumUserStatus) || enumUserStatus == STATUS_MORE_ENTRIES)
								{
									for(j = 0; j < userCountRetourned; j++)
									{
										kprintf(L"\n %-5u %wZ", pEnumUsersBuffer[j].RelativeId, &pEnumUsersBuffer[j].Name);
										status = SamOpenUser(hDomainHandle, USER_READ_GROUP_INFORMATION | USER_LIST_GROUPS | USER_READ_ACCOUNT | USER_READ_LOGON |  USER_READ_PREFERENCES | USER_READ_GENERAL, pEnumUsersBuffer[j].RelativeId, &hUserHandle);
										if(NT_SUCCESS(status))
										{
											status = SamGetGroupsForUser(hUserHandle, &pGroupMemberShip, &groupsCountRetourned);
											if(NT_SUCCESS(status))
											{
												for(k = 0; k < groupsCountRetourned; k++)
												{
													kprintf(L"\n | %-5u ", pGroupMemberShip[k].RelativeId);
													status = SamLookupIdsInDomain(hDomainHandle, 1, &pGroupMemberShip[k].RelativeId, &groupName, &usage);
													if(NT_SUCCESS(status))
													{
														kprintf(L"%wZ", groupName);
														SamFreeMemory(groupName);
														SamFreeMemory(usage);
													} else PRINT_ERROR(L"SamLookupIdsInDomain %08x", status);
												}
												SamFreeMemory(pGroupMemberShip);
											} else PRINT_ERROR(L"SamGetGroupsForUser %08x", status);

											status = SamRidToSid(hUserHandle, pEnumUsersBuffer[j].RelativeId, &userSid);
											if(NT_SUCCESS(status))
											{
												status = SamGetAliasMembership(hDomainHandle, 1, &userSid, &aliasCountRetourned, &alias);
												if(NT_SUCCESS(status))
												{
													for(k = 0; k < aliasCountRetourned; k++)
													{
														kprintf(L"\n |`%-5u ", alias[k]);
														status = SamLookupIdsInDomain(hDomainHandle, 1, &alias[k], &groupName, &usage);
														if(NT_SUCCESS(status))
														{
															kprintf(L"%wZ", groupName);
															SamFreeMemory(groupName);
															SamFreeMemory(usage);
														} else PRINT_ERROR(L"SamLookupIdsInDomain %08x", status);
													}
													SamFreeMemory(alias);
												} else PRINT_ERROR(L"SamGetAliasMembership %08x", status);

												if(hBuiltinHandle)
												{
													status = SamGetAliasMembership(hBuiltinHandle, 1, &userSid, &aliasCountRetourned, &alias);
													if(NT_SUCCESS(status))
													{
														for(k = 0; k < aliasCountRetourned; k++)
														{
															kprintf(L"\n |´%-5u ", alias[k]);
															status = SamLookupIdsInDomain(hBuiltinHandle, 1, &alias[k], &groupName, &usage);
															if(NT_SUCCESS(status))
															{
																kprintf(L"%wZ", groupName);
																SamFreeMemory(groupName);
																SamFreeMemory(usage);
//.........这里部分代码省略.........
开发者ID:smile921,项目名称:ocker,代码行数:101,代码来源:kuhl_m_net.c


示例8: cdrom_attach

static int cdrom_attach(struct scst_device *dev)
{
	int res, rc;
	uint8_t cmd[10];
	const int buffer_size = 512;
	uint8_t *buffer = NULL;
	int retries;
	unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE];
	enum dma_data_direction data_dir;

	TRACE_ENTRY();

	if (dev->scsi_dev == NULL ||
	    dev->scsi_dev->type != dev->type) {
		PRINT_ERROR("%s", "SCSI device not define or illegal type");
		res = -ENODEV;
		goto out;
	}

	buffer = kmalloc(buffer_size, GFP_KERNEL);
	if (!buffer) {
		PRINT_ERROR("Buffer memory allocation (size %d) failure",
			buffer_size);
		res = -ENOMEM;
		goto out;
	}

	/* Clear any existing UA's and get cdrom capacity (cdrom block size) */
	memset(cmd, 0, sizeof(cmd));
	cmd[0] = READ_CAPACITY;
	cmd[1] = (dev->scsi_dev->scsi_level <= SCSI_2) ?
	    ((dev->scsi_dev->lun << 5) & 0xe0) : 0;
	retries = SCST_DEV_RETRIES_ON_UA;
	while (1) {
		memset(buffer, 0, buffer_size);
		memset(sense_buffer, 0, sizeof(sense_buffer));
		data_dir = SCST_DATA_READ;

		TRACE_DBG("%s", "Doing READ_CAPACITY");
		rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer,
				   buffer_size, sense_buffer,
				   SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
				   , NULL
#endif
				  );

		TRACE_DBG("READ_CAPACITY done: %x", rc);

		if ((rc == 0) ||
		    !scst_analyze_sense(sense_buffer,
				sizeof(sense_buffer), SCST_SENSE_KEY_VALID,
				UNIT_ATTENTION, 0, 0))
			break;

		if (!--retries) {
			PRINT_ERROR("UA not cleared after %d retries",
				SCST_DEV_RETRIES_ON_UA);
			dev->block_shift = CDROM_DEF_BLOCK_SHIFT;
			res = -ENODEV;
			goto out_free_buf;
		}
	}

	if (rc == 0) {
		uint32_t sector_size = get_unaligned_be32(&buffer[4]);
		if (sector_size == 0)
			dev->block_shift = CDROM_DEF_BLOCK_SHIFT;
		else
			dev->block_shift = scst_calc_block_shift(sector_size);
		TRACE_DBG("Sector size is %i scsi_level %d(SCSI_2 %d)",
			sector_size, dev->scsi_dev->scsi_level, SCSI_2);
		if (dev->block_shift < 9) {
			PRINT_ERROR("READ CAPACITY reported an invalid sector size: %d",
				    sector_size);
			res = -EINVAL;
			goto out_free_buf;
		}
	} else {
		dev->block_shift = CDROM_DEF_BLOCK_SHIFT;
		TRACE(TRACE_MINOR, "Read capacity failed: %x, using default "
			"sector size %d", rc, dev->block_shift);
		PRINT_BUFF_FLAG(TRACE_MINOR, "Returned sense", sense_buffer,
			sizeof(sense_buffer));
	}
	dev->block_size = 1 << dev->block_shift;

	res = scst_obtain_device_parameters(dev, NULL);
	if (res != 0) {
		PRINT_ERROR("Failed to obtain control parameters for device "
			"%s", dev->virt_name);
		goto out_free_buf;
	}

out_free_buf:
	kfree(buffer);

out:
	TRACE_EXIT();
	return res;
//.........这里部分代码省略.........
开发者ID:qtsky89,项目名称:scst,代码行数:101,代码来源:scst_cdrom.c


示例9: changeServerConfiguration

void changeServerConfiguration( int signal ) {

   /* ----------------------------------------- */

      long 	        longRet         =    0; 
      GenBuf_t* 	certFile 	= NULL;

   /* ----------------------------------------- */

	PRINT_INFO("AWIZOJMSSERVERINF CHANGE AWIZO CONFIGURATION.\n" );

	if (strlen((_GLOBAL_shptr->config).smtpAddr) > 0) {
		free0(_GLOBAL_awizoConfig.smtpAddr);
		asprintf( &(_GLOBAL_awizoConfig.smtpAddr), "%s", (_GLOBAL_shptr->config).smtpAddr);
	}

	if (strlen((_GLOBAL_shptr->config).smtpPort) > 0) {
		free0(_GLOBAL_awizoConfig.smtpPort);
		asprintf( &(_GLOBAL_awizoConfig.smtpPort), "%s", (_GLOBAL_shptr->config).smtpPort);
	}

	if (strlen((_GLOBAL_shptr->config).smtpUser) > 0) {
		free0(_GLOBAL_awizoConfig.user);
		asprintf( &(_GLOBAL_awizoConfig.user), "%s", (_GLOBAL_shptr->config).smtpUser);
	}

	if (strlen((_GLOBAL_shptr->config).smtpPswd) > 0) {
		free0(_GLOBAL_awizoConfig.password);
		asprintf( &(_GLOBAL_awizoConfig.password), "%s", (_GLOBAL_shptr->config).smtpPswd);
	}

	if ( strlen((_GLOBAL_shptr->config).awizoSuccess ) > 0) {
		free0(_GLOBAL_awizoConfig.awizoSuccess);
		asprintf( &(_GLOBAL_awizoConfig.awizoSuccess), "%s", (_GLOBAL_shptr->config).awizoSuccess);
	}

	if ( strlen((_GLOBAL_shptr->config).awizoFailed ) > 0) {
		free0(_GLOBAL_awizoConfig.awizoFailed);
		asprintf( &(_GLOBAL_awizoConfig.awizoFailed), "%s", (_GLOBAL_shptr->config).awizoFailed);
	}

	if ( strlen((_GLOBAL_shptr->config).awizoFailed ) > 0) {
		free0(_GLOBAL_awizoConfig.awizoFailed);
		asprintf( &(_GLOBAL_awizoConfig.awizoFailed), "%s", (_GLOBAL_shptr->config).awizoFailed);
	}

	if ( strlen((_GLOBAL_shptr->config).csvDir ) > 0) {
		free0(_GLOBAL_awizoConfig.csvDir);
		asprintf( &(_GLOBAL_awizoConfig.csvDir), "%s", (_GLOBAL_shptr->config).csvDir);
	}

	if ( strlen((_GLOBAL_shptr->config).csvSeparator ) > 0) {
		free0(_GLOBAL_awizoConfig.csvSeparator);
		asprintf( &(_GLOBAL_awizoConfig.csvSeparator), "%s", (_GLOBAL_shptr->config).csvSeparator);
	}

	if ((_GLOBAL_shptr->config).maxImageSize > -1) {
		_GLOBAL_awizoConfig.maxImageSize = (_GLOBAL_shptr->config).maxImageSize; 
	}

	if ((_GLOBAL_shptr->config).allowImageAbsent > -1) {
		_GLOBAL_awizoConfig.allowImageAbsent = (_GLOBAL_shptr->config).allowImageAbsent;
	}

	if ((_GLOBAL_shptr->config).awizoAction > -1) {
		_GLOBAL_awizoConfig.awizoAction = (_GLOBAL_shptr->config).awizoAction;
	}

	if ((_GLOBAL_shptr->config).mailqueue > -1) {
		_GLOBAL_awizoConfig.mailqueue = (_GLOBAL_shptr->config).mailqueue;
	}

	if ((_GLOBAL_shptr->config).maxcachesize > -1) {
		_GLOBAL_awizoConfig.maxcachesize = (_GLOBAL_shptr->config).maxcachesize;
	}

	if ((_GLOBAL_shptr->config).maxmailqueue > -1) {
		_GLOBAL_awizoConfig.maxmailqueue = (_GLOBAL_shptr->config).maxmailqueue;
	}

	if (strlen((_GLOBAL_shptr->config).pfxfile) > 0 && strlen((_GLOBAL_shptr->config).pfxPin) > 0) {
		bmd_ctx_destroy(&(_GLOBAL_awizoConfig.ctx));

		/* **************************************************************** */
		/*       Pobieranie ceryfikatu podpisującego z bazy danych          */
		/* **************************************************************** */

 		longRet = bmd_db_import_blob(_GLOBAL_awizoConfig.dbase_handler, \
						(_GLOBAL_shptr->config).pfxfile, &certFile);
 
		if (longRet != BMD_OK) {
			PRINT_ERROR("Błąd pobierania certyfikatu do podpisu z bazy danych. Error = %d\n", BMD_ERR_OP_FAILED);
 		}

		longRet = bmd_set_ctx_fileInMem( certFile, (_GLOBAL_shptr->config).pfxPin, \
						 strlen((_GLOBAL_shptr->config).pfxPin), \
						 &(_GLOBAL_awizoConfig.ctx) );

 		if (longRet != BMD_OK) {
			PRINT_ERROR("Błąd w trakcie ustawiania kontekstu do podpisywania wiadomości. Error = %d\n", BMD_ERR_OP_FAILED);
//.........这里部分代码省略.........
开发者ID:unizeto,项目名称:bmd,代码行数:101,代码来源:awizo_signal.c


示例10: PRINT_ERROR

/* Initializes the console */
ConsoleInformation *CON_Init(SDL_Surface *Surface, SDL_Surface *DisplayScreen, int lines, SDL_Rect rect) {
    int loop;
    SDL_Surface *Temp;
    ConsoleInformation *newinfo;


    /* Create a new console struct and init it. */
    if((newinfo = (ConsoleInformation *) malloc(sizeof(ConsoleInformation))) == NULL) {
        PRINT_ERROR("Could not allocate the space for a new console info struct.\n");
        return NULL;
    }
    newinfo->Visible = CON_CLOSED;
    newinfo->WasUnicode = 0;
    newinfo->RaiseOffset = 0;
    newinfo->ConsoleLines = NULL;
    newinfo->CommandLines = NULL;
    newinfo->TotalConsoleLines = 0;
    newinfo->ConsoleScrollBack = 0;
    newinfo->TotalCommands = 0;
    newinfo->BackgroundImage = NULL;
    newinfo->ConsoleAlpha = SDL_ALPHA_OPAQUE;
    newinfo->Offset = 0;
    newinfo->InsMode = 1;
    newinfo->CursorPos = 0;
    newinfo->CommandScrollBack = 0;
    newinfo->OutputScreen = DisplayScreen;
    newinfo->Prompt = CON_DEFAULT_PROMPT;
    newinfo->HideKey = CON_DEFAULT_HIDEKEY;

    CON_SetExecuteFunction(newinfo, Default_CmdFunction);
    CON_SetTabCompletion(newinfo, Default_TabFunction);

    /* Load the consoles font */
    if (-1 == (newinfo->FontNumber = DT_LoadFontFromSurface(Surface, TRANS_FONT, DisplayScreen))) {
        PRINT_ERROR("Could not load the font ");
        PRINT_ERROR("for the console!");
        return NULL;
    }

    newinfo->FontHeight = DT_FontHeight(newinfo->FontNumber);
    newinfo->FontWidth = DT_FontWidth(newinfo->FontNumber);

    /* make sure that the size of the console is valid */
    if(rect.w > newinfo->OutputScreen->w || rect.w < newinfo->FontWidth * 32)
        rect.w = newinfo->OutputScreen->w;
    if(rect.h > newinfo->OutputScreen->h || rect.h < newinfo->FontHeight)
        rect.h = newinfo->OutputScreen->h;
    if(rect.x < 0 || rect.x > newinfo->OutputScreen->w - rect.w)
        newinfo->DispX = 0;
    else
        newinfo->DispX = rect.x;
    if(rect.y < 0 || rect.y > newinfo->OutputScreen->h - rect.h)
        newinfo->DispY = 0;
    else
        newinfo->DispY = rect.y;

    /* load the console surface */
    Temp = SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, newinfo->OutputScreen->format->BitsPerPixel, 0, 0, 0, 0);
    if(Temp == NULL) {
        PRINT_ERROR("Couldn't create the ConsoleSurface\n");
        return NULL;
    }
    newinfo->ConsoleSurface = SDL_ConvertSurfaceFormat(Temp, DisplayScreen->format->format, DisplayScreen->flags);
    SDL_FreeSurface(Temp);
    SDL_FillRect(newinfo->ConsoleSurface, NULL, SDL_MapRGBA(newinfo->ConsoleSurface->format, 0, 0, 0, newinfo->ConsoleAlpha));

    /* Load the dirty rectangle for user input */
    Temp = SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, newinfo->FontHeight, newinfo->OutputScreen->format->BitsPerPixel, 0, 0, 0, SDL_ALPHA_OPAQUE);
    if(Temp == NULL) {
        PRINT_ERROR("Couldn't create the InputBackground\n");
        return NULL;
    }
    newinfo->InputBackground = SDL_ConvertSurfaceFormat(Temp, DisplayScreen->format->format, DisplayScreen->flags);
    SDL_FreeSurface(Temp);
    SDL_FillRect(newinfo->InputBackground, NULL, SDL_MapRGBA(newinfo->ConsoleSurface->format, 0, 0, 0, SDL_ALPHA_OPAQUE));

    /* calculate the number of visible characters in the command line */
    newinfo->VChars = (rect.w - CON_CHAR_BORDER) / newinfo->FontWidth;
    if(newinfo->VChars > CON_CHARS_PER_LINE)
        newinfo->VChars = CON_CHARS_PER_LINE;

    /* deprecated! Memory errors disabled by C.Wacha :-)
       We would like to have a minumum # of lines to guarentee we don't create a memory error */
    /*
    if(rect.h / newinfo->FontHeight > lines)
    	newinfo->LineBuffer = rect.h / newinfo->FontHeight;
    else
    	newinfo->LineBuffer = lines;
    */
    newinfo->LineBuffer = lines;

    newinfo->ConsoleLines = (char **)malloc(sizeof(char *) * newinfo->LineBuffer);
    newinfo->CommandLines = (char **)malloc(sizeof(char *) * newinfo->LineBuffer);
    for(loop = 0; loop <= newinfo->LineBuffer - 1; loop++) {
        newinfo->ConsoleLines[loop] = (char *)calloc(CON_CHARS_PER_LINE+1, sizeof(char));
        newinfo->CommandLines[loop] = (char *)calloc(CON_CHARS_PER_LINE+1, sizeof(char));
    }
    memset(newinfo->Command, 0, CON_CHARS_PER_LINE+1);
    memset(newinfo->LCommand, 0, CON_CHARS_PER_LINE+1);
//.........这里部分代码省略.........
开发者ID:Jedzia,项目名称:Humbug,代码行数:101,代码来源:SDL_console.c


示例11: CON_Resize

/* resizes the console, has to reset alot of stuff
 * returns 1 on error */
int CON_Resize(ConsoleInformation *console, SDL_Rect rect, SDL_Surface* displayScreen) {
    SDL_Surface *Temp;
    SDL_Rect backgroundsrc, backgrounddest;

    if(!console)
        return 1;

    /* make sure that the size of the console is valid */
    if(rect.w > console->OutputScreen->w || rect.w < console->FontWidth * 32)
        rect.w = console->OutputScreen->w;
    if(rect.h > console->OutputScreen->h || rect.h < console->FontHeight)
        rect.h = console->OutputScreen->h;
    if(rect.x < 0 || rect.x > console->OutputScreen->w - rect.w)
        console->DispX = 0;
    else
        console->DispX = rect.x;
    if(rect.y < 0 || rect.y > console->OutputScreen->h - rect.h)
        console->DispY = 0;
    else
        console->DispY = rect.y;

    /* load the console surface */
    SDL_FreeSurface(console->ConsoleSurface);
    Temp = SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, console->OutputScreen->format->BitsPerPixel, 0, 0, 0, 0);
    if(Temp == NULL) {
        PRINT_ERROR("Couldn't create the console->ConsoleSurface\n");
        return 1;
    }
    //console->ConsoleSurface = SDL_DisplayFormat(Temp);
    console->ConsoleSurface = SDL_ConvertSurfaceFormat(Temp, displayScreen->format->format, displayScreen->flags);
    SDL_FreeSurface(Temp);

    /* Load the dirty rectangle for user input */
    SDL_FreeSurface(console->InputBackground);
    Temp = SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, console->FontHeight, console->OutputScreen->format->BitsPerPixel, 0, 0, 0, 0);
    if(Temp == NULL) {
        PRINT_ERROR("Couldn't create the input background\n");
        return 1;
    }
    //console->InputBackground = SDL_DisplayFormat(Temp);
    console->InputBackground = SDL_ConvertSurfaceFormat(Temp, displayScreen->format->format, displayScreen->flags);
    SDL_FreeSurface(Temp);

    /* Now reset some stuff dependent on the previous size */
    console->ConsoleScrollBack = 0;

    /* Reload the background image (for the input text area) in the console */
    if(console->BackgroundImage) {
        backgroundsrc.x = 0;
        backgroundsrc.y = console->ConsoleSurface->h - console->FontHeight - console->BackY;
        backgroundsrc.w = console->BackgroundImage->w;
        backgroundsrc.h = console->InputBackground->h;

        backgrounddest.x = console->BackX;
        backgrounddest.y = 0;
        backgrounddest.w = console->BackgroundImage->w;
        backgrounddest.h = console->FontHeight;

        SDL_FillRect(console->InputBackground, NULL, SDL_MapRGBA(console->ConsoleSurface->format, 0, 0, 0, SDL_ALPHA_OPAQUE));
        SDL_BlitSurface(console->BackgroundImage, &backgroundsrc, console->InputBackground, &backgrounddest);
    }

    /* restore the alpha level */
    CON_Alpha(console, console->ConsoleAlpha);

    /* re-calculate the number of visible characters in the command line */
    console->VChars = (rect.w - CON_CHAR_BORDER) / console->FontWidth;
    if(console->VChars > CON_CHARS_PER_LINE)
        console->VChars = CON_CHARS_PER_LINE;

    CON_UpdateConsole(console);
    return 0;
}
开发者ID:Jedzia,项目名称:Humbug,代码行数:75,代码来源:SDL_console.c


示例12: CON_AlphaGL

/* CON_AlphaGL() -- sets the alpha channel of an SDL_Surface to the
 * specified value.  Preconditions: the surface in question is RGBA.
 * 0 <= a <= 255, where 0 is transparent and 255 is opaque. */
void CON_AlphaGL(SDL_Surface *s, int alpha) {
    Uint8 val;
    int x, y, w, h;
    Uint32 pixel;
    Uint8 r, g, b, a;
    SDL_PixelFormat *format;
    static char errorPrinted = 0;


    /* debugging assertions -- these slow you down, but hey, crashing sucks */
    if(!s) {
        PRINT_ERROR("NULL Surface passed to CON_AlphaGL\n");
        return;
    }

    /* clamp alpha value to 0...255 */
    if(alpha < SDL_ALPHA_TRANSPARENT)
        val = SDL_ALPHA_TRANSPARENT;
    else if(alpha > SDL_ALPHA_OPAQUE)
        val = SDL_ALPHA_OPAQUE;
    else
        val = alpha;

    /* loop over alpha channels of each pixel, setting them appropriately. */
    w = s->w;
    h = s->h;
    format = s->format;
    switch (format->BytesPerPixel) {
    case 2:
        /* 16-bit surfaces don't seem to support alpha channels. */
        if(!errorPrinted) {
            errorPrinted = 1;
            PRINT_ERROR("16-bit SDL surfaces do not support alpha-blending under OpenGL.\n");
        }
        break;
    case 4: {
        /* we can do this very quickly in 32-bit mode.  24-bit is more
         * difficult.  And since 24-bit mode is reall the same as 32-bit,
         * so it usually ends up taking this route too.  Win!  Unroll loop
         * and use pointer arithmetic for extra speed. */
        int numpixels = h * (w << 2);
        Uint8 *pix = (Uint8 *) (s->pixels);
        Uint8 *last = pix + numpixels;
        Uint8 *pixel;
        if((numpixels & 0x7) == 0)
            for(pixel = pix + 3; pixel < last; pixel += 32)
                *pixel = *(pixel + 4) = *(pixel + 8) = *(pixel + 12) = *(pixel + 16) = *(pixel + 20) = *(pixel + 24) = *(pixel + 28) = val;
        else
            for(pixel = pix + 3; pixel < last; pixel += 4)
                *pixel = val;
        break;
    }
    default:
        /* we have no choice but to do this slowly.  <sigh> */
        for(y = 0; y < h; ++y)
            for(x = 0; x < w; ++x) {
                char print = 0;
                /* Lock the surface for direct access to the pixels */
                if(SDL_MUSTLOCK(s) && SDL_LockSurface(s) < 0) {
                    PRINT_ERROR("Can't lock surface: ");
                    PRINT_ERROR(SDL_GetError());
                    return;
                }
                pixel = DT_GetPixel(s, x, y);
                if(x == 0 && y == 0)
                    print = 1;
                SDL_GetRGBA(pixel, format, &r, &g, &b, &a);
                pixel = SDL_MapRGBA(format, r, g, b, val);
                SDL_GetRGBA(pixel, format, &r, &g, &b, &a);
                DT_PutPixel(s, x, y, pixel);

                /* unlock surface again */
                if(SDL_MUSTLOCK(s))
                    SDL_UnlockSurface(s);
            }
        break;
    }
}
开发者ID:Jedzia,项目名称:Humbug,代码行数:81,代码来源:SDL_console.c


示例13: runserver

void runserver(int num_threads, unsigned short serverport) {
    struct node **sock_list[2]; //to contain pointers to head and tail for passing to threads
	struct node *head = NULL;
	struct node *tail = NULL;
	sock_list[0] = &head;
	sock_list[1] = &tail; //to pass to new threads

	pthread_t threads[num_threads];
    int i = 0;

    // start up the threads; they'll start trying to consume immeidately
    for (i = 0; i < num_threads; i++) {
        if (0 > pthread_create(&threads[i], NULL, worker, (void*)&sock_list)) {
            fprintf(stderr, "Error creating thread: %s\n", strerror(errno));
        }
    }
    
    int main_socket = prepare_server_socket(serverport);
    if (main_socket < 0){
        exit(-1);
    }
    signal(SIGINT, signal_handler);

    struct sockaddr_in client_address;
    socklen_t addr_len;

    fprintf(stderr, "Server listening on port %d.  Going into request loop.\n", serverport);


	//thread pool set up and a-okay by now
    while (still_running) {
        struct pollfd pfd = {main_socket, POLLIN};
        int prv = poll(&pfd, 1, 10000);

        if (prv == 0) {
            continue;
        } else if (prv < 0) {
            PRINT_ERROR("poll");
            still_running = FALSE;
            continue;
        }
        
        addr_len = sizeof(client_address);
        memset(&client_address, 0, addr_len);

        int new_sock = accept(main_socket, (struct sockaddr *)&client_address, &addr_len);
        if (new_sock > 0) {            
            fprintf(stderr, "Got connection from %s:%d\n", inet_ntoa(client_address.sin_addr), ntohs(client_address.sin_port));

			produce_cnct(new_sock, client_address, &head, &tail); //inserting socket at end of linked list. Only executed on main thread
        }
    }
    fprintf(stderr, "Server shutting down.\n");

	// threads are done doing work    
    // wait for workers to complete
	pthread_cond_broadcast(&consumer); //wakes up all the consumers, which will then escape and stop running
	for (i = 0; i < num_threads; i++) {
        pthread_join(threads[i], NULL);
    }
	printf("threads woken up");

    close(main_socket);
}
开发者ID:cwmahoney,项目名称:COSC-301A,代码行数:64,代码来源:main.c


示例14: kull_m_remotelib_create

BOOL kull_m_remotelib_create(PKULL_M_MEMORY_ADDRESS aRemoteFunc, PREMOTE_LIB_INPUT_DATA input, PREMOTE_LIB_OUTPUT_DATA output)
{
	BOOL success = FALSE;
	NTSTATUS status;
	HANDLE hThread;
	KULL_M_MEMORY_HANDLE  hLocalBuffer = {KULL_M_MEMORY_TYPE_OWN, NULL};
	KULL_M_MEMORY_ADDRESS aRemoteData = {NULL, aRemoteFunc->hMemory}, aSuppData = {NULL, aRemoteFunc->hMemory}, aLocalAddr = {NULL, &hLocalBuffer};
	PREMOTE_LIB_DATA data;
	REMOTE_LIB_OUTPUT_DATA oData;
	MIMIDRV_THREAD_INFO drvInfo = {(PTHREAD_START_ROUTINE) aRemoteFunc->address, NULL};
	DWORD size = FIELD_OFFSET(REMOTE_LIB_DATA, input.inputData) + input->inputSize;

	if(!output)
		output = &oData;
	//kprintf(L"\ninput\n"
	//	L".void   = 0x%p\n"
	//	L".dword  = 0x%08x - %u\n"
	//	L".size   = %u\n"
	//	L".data[] = [ ",
	//	input->inputVoid, input->inputDword, input->inputDword, input->inputSize);
	//kull_m_string_wprintf_hex(input->inputData, input->inputSize, 1);
	//kprintf(L"]\n");
	if(data = (PREMOTE_LIB_DATA) LocalAlloc(LPTR, size))
	{
		RtlCopyMemory(&data->input, input, FIELD_OFFSET(REMOTE_LIB_INPUT_DATA, inputData) + input->inputSize);
		if(kull_m_memory_alloc(&aRemoteData, size, PAGE_READWRITE))
		{
			aLocalAddr.address = data;
			if(kull_m_memory_copy(&aRemoteData, &aLocalAddr, size))
			{
				switch(aRemoteFunc->hMemory->type)
				{
				case KULL_M_MEMORY_TYPE_PROCESS:
					if(MIMIKATZ_NT_MAJOR_VERSION > 5)
					{
						status = RtlCreateUserThread(aRemoteFunc->hMemory->pHandleProcess->hProcess, NULL, 0, 0, 0, 0, (PTHREAD_START_ROUTINE) aRemoteFunc->address, aRemoteData.address, &hThread, NULL);
						if(!NT_SUCCESS(status))
						{
							hThread = NULL;
							PRINT_ERROR(L"RtlCreateUserThread (0x%08x)\n", status);
						}
					}
					else if(!(hThread = CreateRemoteThread(aRemoteFunc->hMemory->pHandleProcess->hProcess, NULL, 0, (PTHREAD_START_ROUTINE) aRemoteFunc->address, aRemoteData.address, 0, NULL)))
						PRINT_ERROR_AUTO(L"CreateRemoteThread");

					if(hThread)
					{
						WaitForSingleObject(hThread, INFINITE);
						success = CloseHandle(hThread);
					}
					break;

				case KULL_M_MEMORY_TYPE_KERNEL:
					drvInfo.pArg = aRemoteData.address;
					kprintf(L"Th @ %p\nDa @ %p\n", drvInfo.pRoutine, drvInfo.pArg);
					if(!(success = kull_m_kernel_ioctl_handle(aRemoteFunc->hMemory->pHandleDriver->hDriver, IOCTL_MIMIDRV_CREATEREMOTETHREAD, &drvInfo, sizeof(MIMIDRV_THREAD_INFO), NULL, NULL, FALSE)))
						PRINT_ERROR_AUTO(L"kull_m_kernel_ioctl_handle");
					break;
				}
				
				if(success)
				{
					aLocalAddr.address = output;
					if(success = kull_m_memory_copy(&aLocalAddr, &aRemoteData, sizeof(REMOTE_LIB_OUTPUT_DATA)))
					{
						//kprintf(L"\noutput\n"
						//	L".void   = 0x%p\n"
		 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PRINT_ERROR_AUTO函数代码示例发布时间:2022-05-30
下一篇:
C++ PRINT_DEBUG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap