⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 route_guide_src.c

📁 道路导航系统程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	       default :
			   isExiting = 1;
		    break;
		}
		if(isExiting == 0)
			   {
			   /**newsreel the node the amount***/
			   iSrcRsltNum++;
			   /****insert the node of the accord with the node into the link */
			    InsertNewList(&strNewHeader, &ptrNewcLnk,strLnkData, strNode);
				isExiting = 1;
			  }	
		/**tautog the link */
		ptrCurLnk = ptrCurLnk->pNxtNode ;
	}
	/*******save the head node***/
	tempNewcLnk = strNewHeader.next;
	/**the result whether accord with condtion*/
	while(iSrcRsltNum < 5 && iSrcRsltNum > 0)
			{
             while(tempNewcLnk != NULL )
			 {	 
			    
				/******the road name being exist**/
				 if((tempNewcLnk->strDsp.bRoadNameFlg)  == 1)
				{
				/*******out put the result to screen ****/
				printf("#linked=%d;roadnameflag=%d;brunch=%d;roadname=%s#\n",
				  tempNewcLnk->strDsp.udwLinkID,tempNewcLnk->strDsp.bRoadNameFlg,
				  tempNewcLnk->strDsp.bBranchNum,tempNewcLnk->strDsp.pstRoadName->pbStr);
			   	  tempNewcLnk  = tempNewcLnk->next  ;  
				}
				else
				{
					
					/*the name not exist put the no road name*/
					printf("#linked=%d;roadnameflag=%d;brunch=%d;\n",tempNewcLnk->strDsp.udwLinkID,tempNewcLnk->strDsp.bRoadNameFlg,tempNewcLnk->strDsp.bBranchNum);
				     tempNewcLnk  = tempNewcLnk->next  ;	
				}
			 }
			  return RET_SUCCESS;
			}
	
 		if( iSrcRsltNum > 0 )
	{
		/**whether contion greater the contion input file and have a dynamic name**/
		
		RouteLink_Src_Save_Sub(&strNewHeader, ptrNewcLnk, iSrcCnt);
		iSrcCnt = iSrcCnt + 1;
		/*the screen promp */
		printf( "\nSearch Ok! %d route link is matched!\n", iSrcRsltNum );
		printf("Search result has been output into file searchresult%03d.txt\n", iSrcCnt );
	}
	else
	{
	     /**the contion not exist*/
		printf( "\nSearch NG! No matched route link is found!\n" );
	}
	/******release the link   node ****/
	DeleteNewList(strRecHeader ,&strNewHeader);
   
	return RET_SUCCESS;

}
/*********save the record the file *****/
STATUS RouteLink_Src_Save_Sub(S_LNKDATA_NODE *strNewHeader , S_LNKDATA_NODE *ptrcNewLnk, STATUS iSrcCnt)
{
    
	S_LNKDATA_NODE *     tempNewcLnk  = NULL;  //the temp node eomery the infomation
	FILE* ptrFilePointer;                    // the file pointer
	STATUS iRet= RET_SUCCESS;         //the result the value
    	
//	iSrcCnt++;
	char name[18] = "searchresult";    //file name dynamic realization
	name [14] = (iSrcCnt - 100)/100 + '0';
	name [13] = iSrcCnt / 10 % 10 + '0';
	name [12] = iSrcCnt %  10 + '0';
	name[15] = '.';
	name[16] = 't';
	name[17] = 'x';
	name[18] = 't';
	name[19] = '\0';

	
	ptrFilePointer = fopen( name, "w" );  // open the file

	if ( ptrFilePointer == NULL )   //whether the return pointer
	{
		printf( "open file error" );  //prompt  the information
		iRet = RET_FAILED;
	}
    //i++;  //the file name add        
    printf("input the file \n");   
    tempNewcLnk = strNewHeader->next;   //the node record
	while ( NULL != tempNewcLnk  )    //the link node  tautog
	{
	  if(tempNewcLnk->strDsp.pstRoadName  != 0)  //whether link name exist input the file 
	  {
       fprintf(ptrFilePointer,"#linked=%d;roadnameflag=%d;brunch=%d;roadname=%s#\n",
		 tempNewcLnk->strDsp.udwLinkID,tempNewcLnk->strDsp.bRoadNameFlg,tempNewcLnk->strDsp.bBranchNum,tempNewcLnk->strDsp.pstRoadName->pbStr );
	    
	  }
	  else
	  {   /******input the file name not exist ****/
        fprintf(ptrFilePointer,"#linked=%d;roadnameflag=%d;brunch=%d#\n",
		 tempNewcLnk->strDsp.udwLinkID,tempNewcLnk->strDsp.bRoadNameFlg,tempNewcLnk->strDsp.bBranchNum);
	  
	  }
   /*******the link tautog*****/
	 tempNewcLnk = tempNewcLnk->next;
    
	}
	/********close the file****/
	fclose( ptrFilePointer );
	

	return RET_SUCCESS;
	
}

/********initalization the new head  ***/
STATUS InitNewcLnk(S_LNKDATA_NODE* strNewHeader)
{
	strNewHeader->next = NULL ;  //the next the node NULL
	strNewHeader->strDsp.bBranchNum = 0;
	strNewHeader->strDsp.bRoadNameFlg =0;
	strNewHeader->strDsp.bDspClass = 0;
	strNewHeader->strDsp.pstRoadName = 0;
	strNewHeader->strDsp.udwLinkID = 0;
	printf( "Initialize resource...\n" );
	/**clear the buffer**/
	fflush( stdin );

	return RET_SUCCESS;
}
/***insert the contion the node **/
STATUS InsertNewList(S_LNKDATA_NODE* strNewHeader,S_LNKDATA_NODE**  ptrNewcLnk, S_LNKDATA_DSP   strLnkData,STATUS isNode)
{
	S_LNKDATA_NODE* temp = NULL;  //the temp node
	if ( strNewHeader == NULL || ptrNewcLnk == NULL )
	{
		return RET_FAILED;
	}
	 /**the header the next whether exist*/
	if ( strNewHeader->next   == NULL )
	{
		 /******create the new node insert the link head****/
		CreateNewNode( ptrNewcLnk,strLnkData,isNode);
		 strNewHeader->next = (*ptrNewcLnk) ;
		 (*ptrNewcLnk)->next = NULL;
	}
	else
	{
		temp = strNewHeader;
          /*tautog the link and insert the end of link**/
		while(temp->next != NULL)
		{
			temp = temp->next ; 
		}
		/*create the new node **/
		CreateNewNode( ptrNewcLnk,strLnkData,isNode);
		 /*****the new node  insert***/
		temp ->next = ( *ptrNewcLnk );
		/**the next node not exist*/
		(*ptrNewcLnk)->next = NULL;
	}


	return RET_SUCCESS;
}
/**create a new node */
STATUS  CreateNewNode(S_LNKDATA_NODE** ptrNewLnk,S_LNKDATA_DSP strLnkData,STATUS isNode)
{
	STATUS           iRet = RET_SUCCESS;
	/***assign the space for the new node*/
	( *ptrNewLnk ) = ( S_LNKDATA_NODE* )malloc( sizeof( S_LNKDATA_NODE ) );
     /*opinion the assign whether success*/
	if ( *ptrNewLnk == NULL )
	{
		return RET_FAILED;
	}
    /**every node evaluate**/
	( *ptrNewLnk )->strDsp.bBranchNum = strLnkData.bBranchNum;
	( *ptrNewLnk )->strDsp.bDspClass = strLnkData.bDspClass;
	( *ptrNewLnk )->strDsp.bRoadNameFlg = strLnkData.bRoadNameFlg ;   
    ( *ptrNewLnk )->strDsp.udwLinkID  = strLnkData.udwLinkID;
	/*****opinion the name whether exist****/
	if(strLnkData.pstRoadName != NULL)
	 {/*memory the name space **///
        (* ptrNewLnk )->strDsp.pstRoadName = (S_STRING*)malloc(sizeof(strLnkData.pstRoadName));
	( *ptrNewLnk )->strDsp.pstRoadName->uwSize = strLnkData.pstRoadName->uwSize ; 
		
		( *ptrNewLnk )->strDsp.pstRoadName->pbStr = (char*)malloc(strLnkData.pstRoadName->uwSize);
	  memcpy((*ptrNewLnk )->strDsp.pstRoadName->pbStr ,strLnkData.pstRoadName->pbStr ,strLnkData.pstRoadName->uwSize + 2); 
	 }
	else
		/**the name pointer evalute zero**/
       (*ptrNewLnk)->strDsp.pstRoadName = 0;
	
	( *ptrNewLnk )->next = NULL;
	return iRet;

}
/************release the node********/
STATUS DeleteNewList( 
	S_LNKHEADER      strRecHeader ,
	S_LNKDATA_NODE* strNewHeader
	)
{
	S_LNKTBL*        ptrCurLnk  = strRecHeader.pNxtNode;
    strRecHeader.pNxtNode =  NULL;  
    strRecHeader.pTailNode = NULL;
	while ( ptrCurLnk != NULL )
	{	
		free( ( ptrCurLnk->stLnkTblRec ).pvRtLnk );
		ptrCurLnk = ptrCurLnk->pNxtNode;
	}
    /*release the node*/
 	free( strRecHeader.pNxtNode );
	strRecHeader.pNxtNode = NULL;
	strRecHeader.pTailNode = NULL;
    
	return RET_SUCCESS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -