当前位置: 首页>>代码示例>>C++>>正文


C++ PrintError函数代码示例

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


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

示例1: curl_easy_setopt

//----------------------------------------------------------------//
void MOAIHttpTaskCurl::SetCookieSrc	( const char *file ) {
	CURLcode result = curl_easy_setopt( this->mEasyHandle, CURLOPT_COOKIEJAR, file );
	PrintError ( result );
}
开发者ID:AzureRodrigo,项目名称:moai-dev,代码行数:5,代码来源:MOAIHttpTaskCurl.cpp

示例2: DeviceOpen

s32 DeviceOpen() {

  char tempname[256];

  UINT drivetype;

  DWORD errcode;



  if(conf.devicename[0] == 0)  return(-1);



  if(devicehandle != NULL)  return(0);



#ifdef VERBOSE_FUNCTION_DEVICE

  PrintLog("CDVDiso device: DeviceOpen()");

#endif /* VERBOSE_FUNCTION_DEVICE */



  // InitConf();

  // LoadConf(); // Should be done at least once before this call



  // Root Directory reference

  if(conf.devicename[1] == 0) {

    sprintf(tempname, "%s:\\", conf.devicename);

  } else if((conf.devicename[1] == ':') && (conf.devicename[2] == 0)) {

    sprintf(tempname, "%s\\", conf.devicename);

  } else {

    sprintf(tempname, "%s", conf.devicename);

  } // ENDIF- Not a single drive letter? (or a letter/colon?) Copy the name in.



  drivetype = GetDriveType(tempname);

  if(drivetype != DRIVE_CDROM) {

#ifdef VERBOSE_WARNING_DEVICE

    PrintLog("CDVDiso device:   Not a CD-ROM!");

    PrintLog("CDVDiso device:     (Came back: %u)", drivetype);

    errcode = GetLastError();

    if(errcode > 0)  PrintError("CDVDiso device", errcode);

#endif /* VERBOSE_WARNING_DEVICE */

    return(-1);

  } // ENDIF- Not a CD-ROM? Say so!

  // Hmm. Do we want to include DRIVE_REMOVABLE... just in case?



  // Device Reference

  if(conf.devicename[1] == 0) {

    sprintf(tempname, "\\\\.\\%s:", conf.devicename);

  } else if((conf.devicename[1] == ':') && (conf.devicename[2] == 0)) {

    sprintf(tempname, "\\\\.\\%s", conf.devicename);

  } else {

    sprintf(tempname, "%s", conf.devicename);

  } // ENDIF- Not a single drive letter? (or a letter/colon?) Copy the name in.



  devicehandle = CreateFile(tempname,

                            GENERIC_READ,

                            FILE_SHARE_READ,

                            NULL,

//.........这里部分代码省略.........
开发者ID:mfitz21,项目名称:pcsx2-rr,代码行数:101,代码来源:device.c

示例3: HTTPRequest

//Transmission and reception of HTTP protocol
size_t __fastcall HTTPRequest(
	const char *OriginalSend, 
	const size_t SendSize, 
	char *OriginalRecv, 
	const size_t RecvSize)
{
//Initialization
	SOCKET_DATA HTTPSocketData = {0};
	memset(OriginalRecv, 0, RecvSize);

//Socket initialization
	if (Parameter.HTTP_Address_IPv6.Storage.ss_family > 0 && //IPv6
		(Parameter.HTTP_Protocol == REQUEST_MODE_NETWORK_BOTH && GlobalRunningStatus.GatewayAvailable_IPv6 || //Auto select
		Parameter.HTTP_Protocol == REQUEST_MODE_IPV6 || //IPv6
		Parameter.HTTP_Protocol == REQUEST_MODE_IPV4 && Parameter.HTTP_Address_IPv4.Storage.ss_family == 0)) //Non-IPv4
	{
		HTTPSocketData.SockAddr.ss_family = AF_INET6;
		((PSOCKADDR_IN6)&HTTPSocketData.SockAddr)->sin6_addr = Parameter.HTTP_Address_IPv6.IPv6.sin6_addr;
		((PSOCKADDR_IN6)&HTTPSocketData.SockAddr)->sin6_port = Parameter.HTTP_Address_IPv6.IPv6.sin6_port;
		HTTPSocketData.AddrLen = sizeof(sockaddr_in6);
		HTTPSocketData.Socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
	}
	else if (Parameter.HTTP_Address_IPv4.Storage.ss_family > 0 && //IPv4
		(Parameter.HTTP_Protocol == REQUEST_MODE_NETWORK_BOTH && GlobalRunningStatus.GatewayAvailable_IPv4 || //Auto select
		Parameter.HTTP_Protocol == REQUEST_MODE_IPV4 || //IPv4
		Parameter.HTTP_Protocol == REQUEST_MODE_IPV6 && Parameter.HTTP_Address_IPv6.Storage.ss_family == 0)) //Non-IPv6
	{
		HTTPSocketData.SockAddr.ss_family = AF_INET;
		((PSOCKADDR_IN)&HTTPSocketData.SockAddr)->sin_addr = Parameter.HTTP_Address_IPv4.IPv4.sin_addr;
		((PSOCKADDR_IN)&HTTPSocketData.SockAddr)->sin_port = Parameter.HTTP_Address_IPv4.IPv4.sin_port;
		HTTPSocketData.AddrLen = sizeof(sockaddr_in);
		HTTPSocketData.Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	}
	else {
		return EXIT_FAILURE;
	}

//Socket check 
	if (!SocketSetting(HTTPSocketData.Socket, SOCKET_SETTING_INVALID_CHECK, nullptr))
	{
		PrintError(LOG_ERROR_NETWORK, L"HTTP socket initialization error", 0, nullptr, 0);
		return EXIT_FAILURE;
	}

//Non-blocking mode setting
	if (!SocketSetting(HTTPSocketData.Socket, SOCKET_SETTING_NON_BLOCKING_MODE, nullptr))
	{
		shutdown(HTTPSocketData.Socket, SD_BOTH);
		closesocket(HTTPSocketData.Socket);
		PrintError(LOG_ERROR_NETWORK, L"Socket non-blocking mode setting error", 0, nullptr, 0);

		return EXIT_FAILURE;
	}

//Selecting structure setting
	fd_set ReadFDS = {0}, WriteFDS = {0};
	timeval Timeout = {0};

//HTTP CONNECT request
	if (Parameter.HTTP_TargetDomain == nullptr || Parameter.HTTP_Version == nullptr || 
		!HTTP_CONNECTRequest(&HTTPSocketData, &ReadFDS, &WriteFDS, &Timeout, OriginalRecv, RecvSize))
	{
		shutdown(HTTPSocketData.Socket, SD_BOTH);
		closesocket(HTTPSocketData.Socket);

		return EXIT_FAILURE;
	}

//Add length of request packet(It must be written in header when transpot with TCP protocol).
	std::shared_ptr<char> SendBuffer(new char[LARGE_PACKET_MAXSIZE]());
	memset(SendBuffer.get(), 0, LARGE_PACKET_MAXSIZE);
	memcpy_s(SendBuffer.get(), RecvSize, OriginalSend, SendSize);
	SSIZE_T RecvLen = AddLengthDataToHeader(SendBuffer.get(), SendSize, RecvSize);
	if (RecvLen < (SSIZE_T)DNS_PACKET_MINSIZE)
	{
		shutdown(HTTPSocketData.Socket, SD_BOTH);
		closesocket(HTTPSocketData.Socket);

		return EXIT_FAILURE;
	}

//Socket timeout setting
#if defined(PLATFORM_WIN)
	Timeout.tv_sec = Parameter.HTTP_SocketTimeout / SECOND_TO_MILLISECOND;
	Timeout.tv_usec = Parameter.HTTP_SocketTimeout % SECOND_TO_MILLISECOND * MICROSECOND_TO_MILLISECOND;
#elif (defined(PLATFORM_LINUX) || defined(PLATFORM_MACX))
	Timeout.tv_sec = Parameter.HTTP_SocketTimeout.tv_sec;
	Timeout.tv_usec = Parameter.HTTP_SocketTimeout.tv_usec;
#endif

//Data exchange
	RecvLen = ProxySocketSelecting(HTTPSocketData.Socket, &ReadFDS, &WriteFDS, &Timeout, SendBuffer.get(), RecvLen, OriginalRecv, RecvSize, DNS_PACKET_MINSIZE, nullptr);
	shutdown(HTTPSocketData.Socket, SD_BOTH);
	closesocket(HTTPSocketData.Socket);

//Server response check
	if (RecvLen >= (SSIZE_T)DNS_PACKET_MINSIZE && ntohs(((uint16_t *)OriginalRecv)[0]) >= DNS_PACKET_MINSIZE && 
		RecvLen >= ntohs(((uint16_t *)OriginalRecv)[0]))
	{
//.........这里部分代码省略.........
开发者ID:PterX,项目名称:Pcap_DNSProxy,代码行数:101,代码来源:Proxy.cpp

示例4: p3d_create_read_jnt_data

/*! \brief Create a structure to store the parameters of the joints.
 *
 * \param type: the joint type.
 *
 * \return the joint data.
 */
p3d_read_jnt_data * p3d_create_read_jnt_data(p3d_type_joint type)
{
  p3d_read_jnt_data * data;
  int i;

  data = MY_ALLOC(p3d_read_jnt_data, 1);
  if (data == NULL) {
    PrintError(("Not enough memory !!!\n"));
    return NULL;
  }

  data->type = type;
  p3d_jnt_get_nb_param(type, &(data->nb_dof), &(data->nb_param));
  data->v         = MY_ALLOC(double, data->nb_dof);
  data->v_pos0    = MY_ALLOC(double, data->nb_dof);
  data->vmin      = MY_ALLOC(double, data->nb_dof);
  data->vmax      = MY_ALLOC(double, data->nb_dof);
  data->vmin_rand = MY_ALLOC(double, data->nb_dof);
  data->vmax_rand = MY_ALLOC(double, data->nb_dof);
  data->velocity_max = MY_ALLOC(double, data->nb_dof);
  data->acceleration_max = MY_ALLOC(double, data->nb_dof);
  data->jerk_max = MY_ALLOC(double, data->nb_dof);
  
  data->torque_max = MY_ALLOC(double, data->nb_dof);
  data->is_user   = MY_ALLOC(int,    data->nb_dof);
  data->is_active_for_planner   = MY_ALLOC(int,    data->nb_dof);
 
  if ((data->nb_dof>0) && 
      ((data->v == NULL) || (data->v_pos0 == NULL) ||
       (data->vmin == NULL) || (data->vmax == NULL) || 
       (data->vmin_rand == NULL) || (data->vmax_rand == NULL) ||
       (data->is_user == NULL) || (data->is_active_for_planner == NULL) ||
           ( data->velocity_max == NULL) || (data->acceleration_max == NULL) || ( data->jerk_max == NULL) )) {
    PrintError(("Not enough memory !!!\n"));
    return NULL;
  }
  data->flag_v            = FALSE;
  data->flag_v_pos0       = FALSE;
  data->flag_vmin         = FALSE;
  data->flag_vmax         = FALSE;
  data->flag_velocity_max = FALSE;
  data->flag_acceleration_max = FALSE;
  data->flag_jerk_max = FALSE;
  data->flag_torque_max   = FALSE;
  data->flag_vmin_rand    = FALSE;
  data->flag_vmax_rand    = FALSE;
  data->flag_is_user      = FALSE;
  data->flag_is_active_for_planner   = FALSE;
  for(i=0; i<data->nb_dof; i++)
    { data->v[i] = 0.0; }

  data->param      = MY_ALLOC(double, data->nb_param);
  if ((data->nb_param>0) && (data->param == NULL)) {
    PrintError(("Not enough memory !!!\n"));
    return NULL;
  }
  data->flag_param = FALSE;
  
  data->flag_pos = FALSE;
  data->flag_relative_pos = FALSE;

  data->prev_jnt = 0;
  data->flag_prev_jnt = FALSE;

  data->flag_name = FALSE;

  data->nb_links = 0;
  data->link_array = NULL;

  return data;
}
开发者ID:jmainpri,项目名称:libmove3d,代码行数:77,代码来源:p3d_rw_jnt.c

示例5: while

int TScaner::Scaner(TypeLex l) {
	int fl=0;
	int fl_len_const=0;
	int i; // текущая длина лексемы
	for (i=0;i<MAX_LEX;i++) l[i]=0; //очистили поле лексемы
	i=0; // лексема заполняется с позиции i

	start: // все игнорируемые элементы:
	while((t[uk]==' ') || (t[uk]=='\n') || (t[uk]=='\t')) {
		///////////////////////
		if (t[uk]=='\n'){
			if(i_mas==0){
				mass_str[i_mas++]=uk;
			}
			else{
				for(int j=0;j<i_mas;j++)
					if(mass_str[j]==uk){
						fl=1;
							break;
					}
				if(!fl){
					mass_str[i_mas++]=uk;
				}
				fl=0;

			}
			stroka++;
		}
		//////////////////////
		uk++;
	}
	// пропуск незначащих элементов
	if ( (t[uk]=='/') && (t[uk+1]=='/') )
	{ // начался комментарий, надо пропустить текст до "\n"
	uk=uk+2;
	while ( (t[uk]!='\n')/*&&(t[uk]!='\0')&&(t[uk]!='#')*/) uk++;
	///////////////////
		if (t[uk]=='\n'){

			if(i_mas==0){
				mass_str[i_mas++]=uk;
			}
			else{
				for(int j=0;j<i_mas;j++)
					if(mass_str[j]==uk){
						fl=1;
							break;
					}
				if(!fl){
					mass_str[i_mas++]=uk;
				}
				fl=0;

			}

		//stroka++;
		}
		//////////////////
	goto start;
	}
	
	// пропуск незначащих элементов
	if ( (t[uk]=='/') && (t[uk+1]=='*') )
	{ 
		uk=uk+2;////////////////////////////////////////////////////////////////
		// начался комментарий, надо пропустить текст до */
		while ( (t[uk]!='*')||(t[uk+1]!='/')) { 
			if(t[uk]=='#'||t[uk]=='\0') {fl=1; break;} 
			uk++; 
		} 
		if(fl){ 
			PrintError("Неоконченный комментарий",l); 
			return TError; 
		} 
		else{ uk=uk+2;} 
		goto start;
	}

	/*uk=uk+2;
	while ((t[uk]!='*')&&(t[uk+1]!='/')) 
		uk++;
	uk=uk+2;
	goto start;
	}*/


	if (t[uk]=='\0') {l[0]='#'; return TEnd;}
	
	if (Number)
	{
		l[i++]=t[uk++];
		while (Number)
			if (i<=MAX_CONST) l[i++]=t[uk++]; 
			else {uk++; fl_len_const=1;}
		if(!fl_len_const)
			return TConstInt10;
		else
		{PrintError("Длинная числовая константа",l);  
				return TError; }
	}
//.........这里部分代码省略.........
开发者ID:Irishka256,项目名称:TYP_5,代码行数:101,代码来源:Scaner.cpp

示例6: strcpy_s

bool j1Console::ProcessString(const char* input)
{
	bool ret = false;

	last_message.Clear();
	if(input != nullptr && strlen(input) > 0 && strlen(input) < MAX_INPUT_LINE_SIZE)
	{
		char line[MAX_INPUT_LINE_SIZE];
		strcpy_s(line, MAX_INPUT_LINE_SIZE, input);

		char* context = nullptr;
		char* token = strtok_s(line, " ", &context);

		arguments.Clear();
		do
		{
			arguments.PushBack(p2SString(token));
		} while(token = strtok_s(NULL, " ", &context));

		uint nargs = arguments.Count() - 1;

		const Command* com = FindCommand(arguments[0].GetString());

		if(com != nullptr && com->listener != nullptr)
		{
			if(nargs >= com->min_arguments && nargs <= com->max_arguments)
			{
				// If we reach this point we are ready to call a listener
				if(ret = com->listener->OnCommand(com, arguments, last_message))
					last_error.create("No error");
				else
				{
					last_error = last_message;
					last_message.Clear();
				}
			}
			else
				last_error.create("Command arguments mismatch");
		}
		else
		{
			const CVar* var = FindCVar(arguments[0].GetString());

			if(var == nullptr)
				last_error.create("Command / CVar not found");
			else
			{
				switch(nargs)
				{
					case 1:
					{
						if(((CVar*)var)->SetFromString(arguments[1].GetString()) == true)
						{
							if(var->listener != nullptr)
								var->listener->OnCVar(var);
						}
					}
					case 0:
					{
						char output[COMMAND_NAME_SIZE + 25];
						sprintf_s(output, COMMAND_NAME_SIZE + 25, "%s: %s", var->name, var->Printable());
						last_message += output;
						ret = true;
					} break;
					default:
					last_error.create("Command arguments mismatch");
					break;
				}
			}
		}
			
	}
	else
		last_error.create("Invalid input line");

	if(ret == true)
		Print(last_message.GetString());
	else
		PrintError(last_error.GetString());

	return ret;
}
开发者ID:cumus,项目名称:MVS-Basic-TDA-s,代码行数:82,代码来源:j1Console.cpp

示例7: wmain


//.........这里部分代码省略.........
            goto Exit;
        }
    
        const WS_XML_ELEMENT_NODE* elementNode = (WS_XML_ELEMENT_NODE*)node;
        printf("%.*s: ", elementNode->localName->length, elementNode->localName->bytes);
    
        ULONG index;
        hr = WsFindAttribute(
            reader, 
            &objectsDictionary.color, 
            &objectsDictionary.ns, 
            TRUE, 
            &index, 
            error);
        if (FAILED(hr))
        {
            goto Exit;
        }
    
        hr = WsReadStartAttribute(
            reader, 
            index, 
            error);
        if (FAILED(hr))
        {
            goto Exit;
        }
    
        WS_XML_STRING color;
        hr = WsReadType(
            reader, 
            WS_ATTRIBUTE_TYPE_MAPPING, 
            WS_XML_STRING_TYPE, 
            NULL, 
            WS_READ_REQUIRED_VALUE, 
            heap, 
            &color, 
            sizeof(color), 
            error);
        if (FAILED(hr))
        {
            goto Exit;
        }
    
        printf(
            "%.*s\n", 
            color.length, 
            color.bytes);
    
        hr = WsReadEndAttribute(
            reader, 
            error);
        if (FAILED(hr))
        {
            goto Exit;
        }
        
        hr = WsSkipNode(
            reader, 
            error);
        if (FAILED(hr))
        {
            goto Exit;
        }
    }
    
    hr = WsReadEndElement(
        reader, 
        error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    
Exit:
    if (FAILED(hr))
    {
        // Print out the error
        PrintError(hr, error);
    }
    
    if (writer != NULL)
    {
        WsFreeWriter(writer);
    }
    if (reader != NULL)
    {
        WsFreeReader(reader);
    }
    if (heap != NULL)
    {
        WsFreeHeap(heap);
    }
    if (error != NULL)
    {
        WsFreeError(error);
    }
    fflush(stdout);
    return SUCCEEDED(hr) ? 0 : -1;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:101,代码来源:XmlDictionary.cpp

示例8: PrintHistogram

/* TODO */
void PrintHistogram(RGIndex *index, 
		RGBinary *rg,
		int whichStrand,
		int numThreads)
{
	char *FnName = "PrintHistogram";
	int64_t i, j;
	int64_t *starts, *ends;
	pthread_t *threads=NULL;
	ThreadData *data=NULL;
	int errCode;
	void *status;
	FILE *fp;
	int64_t numDifferent, numTotal, cur, sum, totalForward, totalReverse;
	int numCountsLeft;

	/* Allocate memory for the thread starts and ends */
	starts = malloc(sizeof(int64_t)*numThreads);
	if(NULL == starts) {
		PrintError(FnName, "starts", "Could not allocate memory", Exit, OutOfRange);
	}
	ends = malloc(sizeof(int64_t)*numThreads);
	if(NULL == ends) {
		PrintError(FnName, "ends", "Could not allocate memory", Exit, OutOfRange);
	}

	/* Allocate memory for threads */
	threads=malloc(sizeof(pthread_t)*numThreads);
	if(NULL==threads) {
		PrintError(FnName, "threads", "Could not allocate memory", Exit, MallocMemory);
	}
	/* Allocate memory to pass data to threads */
	data=malloc(sizeof(ThreadData)*numThreads);
	if(NULL==data) {
		PrintError(FnName, "data", "Could not allocate memory", Exit, MallocMemory);
	}

	/* Get pivots */
	GetPivots(index,
			rg,
			starts,
			ends,
			numThreads);

	/* Initialize thread data */
	numTotal = 0;
	for(i=0;i<numThreads;i++) {
		data[i].startIndex = starts[i];
		data[i].endIndex = ends[i];
		numTotal += ends[i] - starts[i] + 1;
		data[i].index = index;
		data[i].rg = rg;
		data[i].c.counts = NULL;
		data[i].c.maxCount = NULL;
		data[i].whichStrand = whichStrand;
		data[i].numDifferent = 0;
		data[i].threadID = i+1;
	}
	assert(numTotal == index->length || (ColorSpace == rg->space && numTotal == index->length - 1));

	fprintf(stderr, "In total, will examine %lld reads.\n",
			(long long int)(index->length));
	fprintf(stderr, "For a given thread, out of %lld, currently on:\n0",
			(long long int)(index->length/numThreads)
		   );

	/* Open threads */
	for(i=0;i<numThreads;i++) {
		/* Start thread */
		errCode = pthread_create(&threads[i], /* thread struct */
				NULL, /* default thread attributes */
				PrintHistogramThread, /* start routine */
				&data[i]); /* data to routine */
		if(0!=errCode) {
			PrintError(FnName, "pthread_create: errCode", "Could not start thread", Exit, ThreadError);
		}
	}
	/* Wait for threads to return */
	for(i=0;i<numThreads;i++) {
		/* Wait for the given thread to return */
		errCode = pthread_join(threads[i],
				&status);
		/* Check the return code of the thread */
		if(0!=errCode) {
			PrintError(FnName, "pthread_join: errCode", "Thread returned an error", Exit, ThreadError);
		}
	}
	fprintf(stderr, "\n");

	/* Get the total number of different */
	numDifferent = 0;
	totalForward = 0;
	totalReverse = 0;
	for(i=0;i<numThreads;i++) {
		numDifferent += data[i].numDifferent;
		totalForward += data[i].totalForward;
		totalReverse += data[i].totalReverse;
	}

//.........这里部分代码省略.........
开发者ID:alecw,项目名称:TS,代码行数:101,代码来源:bindexhist.c

示例9: malloc

void *PrintHistogramThread(void *arg)
{
	char *FnName = "PrintHistogramThread";

	/* Get thread data */
	ThreadData *data = (ThreadData*)arg;
	int64_t startIndex = data->startIndex;
	int64_t endIndex = data->endIndex;
	RGIndex *index = data->index;
	RGBinary *rg = data->rg;
	Counts *c = &data->c;
	int whichStrand = data->whichStrand;
	int threadID = data->threadID;
	int numMismatchesEnd = 0;
	int numMismatchesStart = 0;

	/* Local variables */
	int skip;
	int64_t i=0;
	int64_t j=0;
	int64_t curIndex=0, nextIndex=0;
	int64_t counter=0;
	int64_t numDifferent = 0;
	int64_t numReadsNoMismatches = 0;
	int64_t numReadsNoMismatchesTotal = 0;
	int64_t numForward, numReverse;
	int64_t totalForward, totalReverse; 
	int64_t numMatches;

	/* Allocate memory to hold histogram data */
	c->counts = malloc(sizeof(int64_t*)*(numMismatchesEnd - numMismatchesStart + 1));
	if(NULL == c->counts) {
		PrintError(FnName, "c->counts", "Could not allocate memory", Exit, MallocMemory);
	}
	c->maxCount = malloc(sizeof(int64_t)*(numMismatchesEnd - numMismatchesStart + 1));
	if(NULL == c->maxCount) {
		PrintError(FnName, "c->maxCount", "Could not allocate memory", Exit, MallocMemory);
	}

	/* Initialize counts */
	for(i=0;i<(numMismatchesEnd - numMismatchesStart + 1);i++) {
		c->counts[i] = malloc(sizeof(int64_t));
		if(NULL == c->counts[i]) {
			PrintError(FnName, "c->counts[i]", "Could not allocate memory", Exit, MallocMemory);
		}
		c->counts[i][0] = 0;
		c->maxCount[i] = 0;
	}

	/* Go through every possible read in the genome using the index */
	/* Go through the index */
	totalForward = 0;
	totalReverse = 0;
	for(curIndex=startIndex, nextIndex=startIndex, counter=0, numDifferent=0;
			curIndex <= endIndex;
			curIndex = nextIndex) {
		if(counter >= BINDEXHIST_ROTATE_NUM) {
			fprintf(stderr, "\rthreadID:%2d\t%10lld", 
					threadID,
					(long long int)(curIndex-startIndex));
			counter -= BINDEXHIST_ROTATE_NUM;
		}
		/* Try each mismatch */
		skip=0;
		i=0;

		/* Get the matches for the contig/pos */
		if(0==GetMatchesFromContigPos(index,
					rg,
					(index->contigType == Contig_8)?(index->contigs_8[curIndex]):(index->contigs_32[curIndex]),
					index->positions[curIndex],
					&numForward, 
					&numReverse) && 0 == i) {
			/* Skip over the rest */
			skip =1 ;
			nextIndex++;
		}
		else {
			numMatches = numForward + numReverse;
			assert(numMatches > 0);

			/* Update the value of numReadsNoMismatches and numDifferent
			 * if we have the results for no mismatches */
			if(i==0) {
				assert(numForward > 0);
				totalForward += numForward;
				assert(numReverse >= 0);
				totalReverse += numReverse;
				/* If the reverse compliment does not match the + strand then it will only match the - strand.
				 * Count it as unique as well as the + strand read.
				 * */
				if((BothStrands == whichStrand || ReverseStrand == whichStrand) &&
						numReverse == 0) {
					numDifferent+=2;
					numReadsNoMismatches = 2;
				}
				else {
					/* Count only the + strand as a unique read. */
					numReadsNoMismatches = 1;
					numDifferent++;
//.........这里部分代码省略.........
开发者ID:alecw,项目名称:TS,代码行数:101,代码来源:bindexhist.c

示例10: wmain

// Main entry point
int __cdecl wmain()
{

    HRESULT hr = S_OK;
    WS_SERVICE_HOST* host = NULL;
    WS_SERVICE_ENDPOINT serviceEndpoint = {};
    const WS_SERVICE_ENDPOINT* serviceEndpoints[1];
    WS_ERROR* error = NULL;
    WS_SERVICE_ENDPOINT_PROPERTY serviceProperties[1];
    const ULONG maxConcurrency = 100;
    serviceEndpoints[0] = &serviceEndpoint;
    serviceProperties[0].id = WS_SERVICE_ENDPOINT_PROPERTY_MAX_CONCURRENCY;
    serviceProperties[0].value = (void*)&maxConcurrency;
    serviceProperties[0].valueSize = sizeof(maxConcurrency);

    // Create Event object for closing the server
    closeServer = CreateEvent(
                      NULL,
                      TRUE,
                      FALSE,
                      NULL);
    if (closeServer == NULL)
    {
        hr = HRESULT_FROM_WIN32(GetLastError());
        goto Exit;
    }

    // Initialize service endpoint
    serviceEndpoint.address.url.chars = L"net.tcp://+/example"; // address given as uri
    serviceEndpoint.address.url.length = (ULONG)wcslen(serviceEndpoint.address.url.chars);
    serviceEndpoint.channelBinding = WS_TCP_CHANNEL_BINDING; // channel binding for the endpoint
    serviceEndpoint.channelType = WS_CHANNEL_TYPE_DUPLEX_SESSION; // the channel type
    serviceEndpoint.contract = &blockServiceContract;  // the contract
    serviceEndpoint.properties = serviceProperties;
    serviceEndpoint.propertyCount = WsCountOf(serviceProperties);
    // Create an error object for storing rich error information
    hr = WsCreateError(
             NULL,
             0,
             &error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    // Creating a service host
    hr = WsCreateServiceHost(
             serviceEndpoints,
             1,
             NULL,
             0,
             &host,
             error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    // WsOpenServiceHost to start the listeners in the service host
    hr = WsOpenServiceHost(
             host,
             NULL,
             error);
    if (FAILED(hr))
    {
        goto Exit;
    }


    WaitForSingleObject(closeServer, INFINITE);

    // Aborts the service host so that the blocked method can complete.
    WsAbortServiceHost(host, NULL);
    // Close the service host
    hr = WsCloseServiceHost(host, NULL, error);
    if (FAILED(hr))
    {
        goto Exit;
    }

Exit:
    if (FAILED(hr))
    {
        // Print out the error
        PrintError(hr, error);
    }
    if (host != NULL)
    {
        WsFreeServiceHost(host);
    }


    if (error != NULL)
    {
        WsFreeError(error);
    }
    if (closeServer != NULL)
    {
        CloseHandle(closeServer);
    }
    fflush(stdout);
//.........这里部分代码省略.........
开发者ID:dhanzhang,项目名称:Windows-classic-samples,代码行数:101,代码来源:CancellingService.cpp

示例11: wmain


//.........这里部分代码省略.........
    // NOTE: At the server, the SSL certificate for the listen URI must be
    // registered with http.sys using a tool such as httpcfg.exe.
    
    // declare and initialize the array of all security bindings
    WS_SECURITY_BINDING* securityBindings[2] = { &sslBinding.binding, &usernameBinding.binding };
    
    // declare and initialize the security description
    WS_SECURITY_DESCRIPTION securityDescription = {}; // zero out the struct
    securityDescription.securityBindings = securityBindings;
    securityDescription.securityBindingCount = WsCountOf(securityBindings);
    WS_SERVICE_ENDPOINT_PROPERTY serviceEndpointProperties[1];
    WS_SERVICE_PROPERTY_CLOSE_CALLBACK closeCallbackProperty = {CloseChannelCallback};
    serviceEndpointProperties[0].id = WS_SERVICE_ENDPOINT_PROPERTY_CLOSE_CHANNEL_CALLBACK;
    serviceEndpointProperties[0].value = &closeCallbackProperty;
    serviceEndpointProperties[0].valueSize = sizeof(closeCallbackProperty);
    
    
    // Initialize service endpoint
    serviceEndpoint.address.url.chars = L"https://localhost:8443/example"; // address given as uri
    serviceEndpoint.address.url.length = (ULONG)wcslen(serviceEndpoint.address.url.chars);
    serviceEndpoint.channelBinding = WS_HTTP_CHANNEL_BINDING; // channel binding for the endpoint
    serviceEndpoint.channelType = WS_CHANNEL_TYPE_REPLY; // the channel type
    serviceEndpoint.securityDescription = &securityDescription; // security description
    serviceEndpoint.contract = &calculatorContract;  // the contract
    serviceEndpoint.properties = serviceEndpointProperties;
    serviceEndpoint.propertyCount = WsCountOf(serviceEndpointProperties);
    serviceEndpoint.authorizationCallback = AuthorizationCallback;
    
    // Create an error object for storing rich error information
    hr = WsCreateError(
        NULL, 
        0, 
        &error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    // Create Event object for closing the server
    closeServer = CreateEvent(
        NULL, 
        TRUE, 
        FALSE, 
        NULL);
    if (closeServer == NULL)
    {
        hr = HRESULT_FROM_WIN32(GetLastError());
        goto Exit;
    }   
    // Creating a service host
    hr = WsCreateServiceHost(
        serviceEndpoints, 
        1, 
        NULL, 
        0, 
        &host, 
        error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    // WsOpenServiceHost to start the listeners in the service host 
    hr = WsOpenServiceHost(
        host, 
        NULL, 
        error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    WaitForSingleObject(closeServer, INFINITE);
    // Close the service host
    hr = WsCloseServiceHost(host, NULL, error);
    if (FAILED(hr))
    {
        goto Exit;
    }
    
Exit:
    if (FAILED(hr))
    {
        // Print out the error
        PrintError(hr, error);
    }
    if (host != NULL)
    {
        WsFreeServiceHost(host);
    }
    
    
    if (error != NULL)
    {
        WsFreeError(error);
    }
    if (closeServer != NULL)
    {
        CloseHandle(closeServer);
    }
    fflush(stdout);
    return SUCCEEDED(hr) ? 0 : -1;
}
开发者ID:FrankAlbis,项目名称:Win7_SDK_Samples,代码行数:101,代码来源:CalculatorServiceUserNameOverSsl.cpp

示例12: ActualFileSeek

int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {

  // int retval;

  LARGE_INTEGER realpos;

  DWORD errcode;



  if(handle == NULL)  return(-1);

  if(handle == INVALID_HANDLE_VALUE)  return(-1);

  if(position < 0)  return(-1);



#ifdef VERBOSE_FUNCTION_ACTUALFILE

  PrintLog("CDVDiso file: ActualFileSeek(%llu)", position);

#endif /* VERBOSE_FUNCTION_ACTUALFILE */



  realpos.QuadPart = position;

////// WinXP code for seek

//   retval = SetFilePointerEx(handle,

//                             realpos,

//                             NULL,

//                             FILE_BEGIN);

//   if(retval == 0) {



////// Win98 code for seek

  realpos.LowPart = SetFilePointer(handle,

                                   realpos.LowPart,

                                   &realpos.HighPart,

                                   FILE_BEGIN);

  errcode = GetLastError();

  if((realpos.LowPart == 0xFFFFFFFF) && (errcode != NO_ERROR)) {



#ifdef VERBOSE_WARNING_ACTUALFILE

    PrintLog("CDVDiso file:   Error on seek (%llu)", position);

    PrintError("CDVDiso file", errcode);

#endif /* VERBOSE_WARNING_ACTUALFILE */

    return(-1);

  } // ENDIF- Error? Abort



  return(0);

} // END ActualFileSeek()
开发者ID:0xZERO3,项目名称:PCSX2-rr-lua,代码行数:75,代码来源:actualfile.c

示例13: main

int main(int argc, char *argv[]) 
{
	char *indexFileName=NULL;
	char *fastaFileName=NULL;
	int numThreads = 1;
	int whichStrand = 0;
	int space = NTSpace;
	int c;
	RGBinary rg;
	RGIndex index;

	while((c = getopt(argc, argv, "f:i:n:s:A:h")) >= 0) {
		switch(c) {
			case 'f': fastaFileName=strdup(optarg); break;
			case 'h': return PrintUsage();
			case 'i': indexFileName=strdup(optarg); break;
			case 's': whichStrand=atoi(optarg); break;
			case 'n': numThreads=atoi(optarg); break;
			case 'A': space=atoi(optarg); break;
			default: fprintf(stderr, "Unrecognized option: -%c\n", c); return 1;
		}
	}

	if(1 == argc || argc != optind) {
		return PrintUsage();
	}

	if(NULL == indexFileName) {
		PrintError(Name, "indexFileName", "Command line option", Exit, InputArguments);
	}
	if(NULL == fastaFileName) {
		PrintError(Name, "fastaFileName", "Command line option", Exit, InputArguments);
	}

	assert(whichStrand == BothStrands || whichStrand == ForwardStrand || whichStrand == ReverseStrand);

	/* Read in the rg binary file */
	RGBinaryReadBinary(&rg, space, fastaFileName);

	/* Read the index */
	RGIndexRead(&index, indexFileName);

	assert(index.space == rg.space);

	fprintf(stderr, "%s", BREAK_LINE);
	PrintHistogram(&index, 
			&rg, 
			whichStrand,
			numThreads);
	fprintf(stderr, "%s", BREAK_LINE);

	fprintf(stderr, "%s", BREAK_LINE);
	fprintf(stderr, "Cleaning up.\n");
	/* Delete the index */
	RGIndexDelete(&index);
	/* Delete the rg */
	RGBinaryDelete(&rg);
	fprintf(stderr, "%s", BREAK_LINE);
	fprintf(stderr, "Terminating successfully!\n");
	fprintf(stderr, "%s", BREAK_LINE);

	return 0;
}
开发者ID:alecw,项目名称:TS,代码行数:63,代码来源:bindexhist.c

示例14: ActualFileRead

int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {

  int retval;

  DWORD bytesread;

#ifdef VERBOSE_WARNING_ACTUALFILE

  DWORD errcode;

#endif /* VERBOSE_WARNING_ACTUALFILE */



  if(handle == NULL)  return(-1);

  if(handle == INVALID_HANDLE_VALUE)  return(-1);

  if(bytes < 1)  return(-1);

  if(buffer == NULL)  return(-1);



#ifdef VERBOSE_FUNCTION_ACTUALFILE

  PrintLog("CDVDiso file: ActualFileRead(%i)", bytes);

#endif /* VERBOSE_FUNCTION_ACTUALFILE */



  retval = ReadFile(handle, buffer, bytes, &bytesread, NULL);

  if(retval == 0) {

#ifdef VERBOSE_WARNING_ACTUALFILE

    errcode = GetLastError();

    PrintLog("CDVDiso file:   Error reading from file");

    PrintError("CDVDiso file", errcode);

#endif /* VERBOSE_WARNING_ACTUALFILE */

    return(-1);

  } // ENDIF- Error? Abort

  if(bytesread < bytes) {

#ifdef VERBOSE_WARNING_ACTUALFILE

    PrintLog("CDVDiso file:   Short Block! Only read %i out of %i bytes", bytesread, bytes);

#endif /* VERBOSE_WARNING_ACTUALFILE */

  } // ENDIF- Error? Abort



  return(bytesread); // Send back how many bytes read

} // END ActualFileRead()
开发者ID:0xZERO3,项目名称:PCSX2-rr-lua,代码行数:65,代码来源:actualfile.c

示例15: GetMatchesFromContigPos

/* Get the matches for the contig/pos */
int GetMatchesFromContigPos(RGIndex *index,
		RGBinary *rg,
		uint32_t curContig,
		uint32_t curPos,
		int64_t *numForward,
		int64_t *numReverse)
{
	char *FnName = "GetMatchesFromContigPos";
	int returnLength, returnPosition;
	char *read=NULL;
	RGRanges ranges;
	RGMatch match;
	int readLength = index->width;
	int8_t readInt[SEQUENCE_LENGTH];
	int32_t i;

	/* Initialize */
	RGRangesInitialize(&ranges);
	RGMatchInitialize(&match);

	/* Get the read */
	RGBinaryGetReference(rg,
			curContig,
			curPos,
			FORWARD,
			0,
			&read,
			readLength,
			&returnLength,
			&returnPosition);
	assert(returnLength == readLength);
	assert(returnPosition == curPos);

	ConvertSequenceToIntegers(read, readInt, readLength);

	RGIndexGetRangesBothStrands(index,
			rg,
			readInt,
			readLength,
			0,
			INT_MAX,
			INT_MAX,
			rg->space,
			BothStrands,
			&ranges);

	/* Transfer ranges to matches */
	RGRangesCopyToRGMatch(&ranges,
			index,
			&match,
			rg->space,
			0);

	/* Remove duplicates */
	RGMatchRemoveDuplicates(&match,
			INT_MAX);

	assert(0 < match.numEntries);
	(*numForward) = (*numReverse) = 0;

	for(i=0;i<match.numEntries;i++) {
		switch(match.strands[i]) {
			case FORWARD:
				(*numForward)++;
				break;
			case REVERSE:
				(*numReverse)++;
				break;
			default:
				PrintError(FnName, NULL, "Could not understand strand", Exit, OutOfRange);
				break;
		}
	}

	assert((*numForward) > 0); /* It should at least match itself ! */
	assert((*numReverse) >= 0);

	RGRangesFree(&ranges);
	RGMatchFree(&match);
	free(read);
	read=NULL;

	return 1;
}
开发者ID:alecw,项目名称:TS,代码行数:85,代码来源:bindexhist.c


注:本文中的PrintError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。