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

📄 route_guide_update.c

📁 道路导航系统程序
💻 C
字号:
/***************************************************************************
  FileName      :	     route_guide_sort.c

  Date          :	     2006.04.09
  
  Author        :	     QZYTM Developing Group
	
  Content       :      Route Guide System Sort Proc
	  
  Copyright     :	     QZYTM-GROUP @ SIST_S0527
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		Modify History
		NO       Date           Modifier         Modified Content
		
****************************************************************************/

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*																		   */
/*                        Include File Section                             */
/*																		   */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#include <stdio.h>
#include <memory.h>
#include <malloc.h>
#include <string.h>
#include <conio.h>
#include "route_guide_common.h"
#include "route_guide_s.h"
#include "route_guide_p.h"
#include "route_guide_in_s.h"
#include "route_guide_in_c.h"
/********opinion the read into the record whether equal the source file LinkID*****/
STATUS CheckData( 
				 S_LNKHEADER*      strRecHeader,  //the link head
				 S_LNKHEADER*      strUpdataRecHeader  //the new link head
				 
				 )
{
	STATUS          iRet = RET_SUCCESS;   //the result value
	UDWORD			count= strRecHeader->udwNumOfRecs ; //the take count of source the record
	UDWORD			icount = strUpdataRecHeader->udwNumOfRecs ; //the take count of new the record
	UDWORD			Lnkid ;    //memory the link id
	S_LNKTBL*		pTempUpdate = strUpdataRecHeader->pNxtNode ; //memory the head pointer
	S_LNKTBL*		pTemp       = NULL ;  //the temp point 


	while(icount --)  //taugog all of source node
	{
		Lnkid		= pTempUpdate->stLnkTblRec.udwLinkID ; // memory the link id
		pTemp       = strRecHeader->pNxtNode;  //memory the the first record
		while(count--)   //taugog  the new node
		{
			/****judge the link id whether equal ***/
			if(pTemp->stLnkTblRec.udwLinkID == Lnkid)
			{
								
				free((pTemp->stLnkTblRec).pvRtLnk);	//release the node
				/*********the assign the memory space ***/
                (pTemp->stLnkTblRec).pvRtLnk = malloc(pTempUpdate->stLnkTblRec.uwRecSize) ;
								
			   /*******the road size memory the temp node******/
				pTemp->stLnkTblRec.uwRecSize = 
					pTempUpdate->stLnkTblRec.uwRecSize;
				/******the assign the memory the space ***/
				memcpy((pTemp->stLnkTblRec).pvRtLnk,
					(pTempUpdate->stLnkTblRec).pvRtLnk,
					pTempUpdate->stLnkTblRec.uwRecSize);
				break;
			}
			/******whether the node note exist insert the node******/
			if( (pTemp->stLnkTblRec.udwLinkID < Lnkid) &&
				(pTemp->pNxtNode->stLnkTblRec.udwLinkID > Lnkid ) )
			{
				/*******insert  the new the node****/
				pTempUpdate->pNxtNode = pTemp->pNxtNode->pNxtNode ;
				pTemp->pNxtNode = pTempUpdate->pNxtNode ;
				break;
			}
			else
			{
				/******tautog the every the node*****/
				pTemp = pTemp->pNxtNode ;
			}
			
		}
		/*****the number take acount of *****/
		strRecHeader->udwNumOfRecs++;
		/*******the node pointer the next the node****/
		pTempUpdate = pTempUpdate->pNxtNode ;	
	
	}
	/******have a result****/
	return iRet;
	
	
}


/********read the text file and conversation the node information ****/
STATUS CreateUpdataRecLnk(
						  S_LNKHEADER*      strUpdataRecHeader,//the new head link
						  char*             filename  //the text file name
						  )
{
	
	STATUS           iRet = RET_SUCCESS; //the return the value
	STATUS			 iResult = 1 ; // the flag whether
	STATUS			 i		 = 1 ;   // the take acount of number
	char			 roadname[80] = {'\0'}, c ; //the space memory 

	UDWORD			 linkid,roadnameflag,brunch,dispclass; //the information the node
	UDWORD			 temp ;  //the  temp memory the road infomation
	UWORD			 TempSize = 0 ; //memory the size
	S_DATA_INFO		 ptrInfo ;	 //the struct the information
	S_LNKTBL*        ptrRouteUpDateRec = NULL; //the new link 
	FILE*			 fptrUpDateInfo; //the file handle
	UWORD			 length ; //the length memory the temp
	/*****the memory the initiazation *****/
	memset(&ptrInfo,0,100);
	/********the file name open exist*****/
	if( !(fptrUpDateInfo = fopen(filename,"r")) )
	{ 
		/************the file prompt the information***/
		printf( "\n%s File is not exist. Error found!!",filename);
		iRet = RET_FAILED;
	}
	/**********the promp for user******/
	puts("\nNotice:press the Enter key to read infomation, and other key to back.\n") ;
	/**memory the return ****/
	getch();
	/****memory the user input****/
	c = getchar();
	/***dimension the user opioin**/
	while(iResult != 0 && c == '\n' )
	{
		length = 0 ; //the length is null
		/********read the  the memory the file information ****/
		iResult = fscanf(fptrUpDateInfo,"#linkid=%u;roadnameflag=%u;brunch=%u;dispclass=%u;",
			&linkid,
			&roadnameflag,
			&brunch,
			&dispclass);
		/****opinion the read the information whether success****/
		if(iResult == 0)
		{
			break ;
		}
		/****output the screen the information*****/
		printf("#linkid=%d;roadnameflag=%d;brunch=%d;dispclass=%d;",
			linkid,
			roadnameflag,
			brunch,
			dispclass); 
        /********the information conversatin binary file format*****/
		ptrInfo.udwLinkID[0] =(char)(linkid>>24);
		ptrInfo.udwLinkID[1] =(char)(linkid>>16);
		ptrInfo.udwLinkID[2] =(char)(linkid>>8); 
        ptrInfo.udwLinkID[3] =(char)(linkid);

		temp	=   (roadnameflag<<7)|(brunch<<4)|dispclass  ;
		ptrInfo.udwStaNodeInfo	=   MC_GET_LONG( (char*) &(temp) );
	    /*the road name whether exist**/
		if(1 != roadnameflag)
		{   
			/****point move the end of information***/
			fseek(fptrUpDateInfo,1,SEEK_CUR);
			/***the name size conversation***/
			ptrInfo.uwRoadNameSize = 0xffff;
			roadname[88] = 0 ;
			//printf("#\n") ;
			/*****the road name memory***/
			memcpy(ptrInfo.pcRoadName,roadname,0);
		} 
		else
		{
			/******the read the road name***/
			i = fscanf(fptrUpDateInfo,"roadname=%s",roadname);
			/******the road name length***/
			length = (UWORD)strlen(roadname);
                /**********output the screen the prompt infomation*****/
			printf("roadname=%s\n",roadname);
			/******the name conversation***/
			ptrInfo.uwRoadNameSize = ( (UWORD)(4+strlen(roadname)) ) << 8 ;
		   /*********the road name memory**/
			memcpy(ptrInfo.pcRoadName,roadname,(UWORD)(length+1));


		}
		/********the information conversation **/
		ptrInfo.uwRecSize[0]=(char)((12+length)>>8);
		ptrInfo.uwRecSize[1]=(char)((12+length)&0x00FF);
	
		TempSize		  = 12+length ;
		/*****allot the memery the space****/
		ptrRouteUpDateRec = ( S_LNKTBL* )malloc( TempSize+6) ;
           /*****opinion the allot the memery whether success****/
		if ( ptrRouteUpDateRec == NULL )
		{
			return RET_FAILED;
		}
         /*****the name space allot space**/
 		ptrRouteUpDateRec->stLnkTblRec.pvRtLnk   = (BYTE*)malloc(TempSize );
		if ( ptrRouteUpDateRec->stLnkTblRec.pvRtLnk == NULL )
		{
			return RET_FAILED;
		}
          /******memory the information update link***/
		ptrRouteUpDateRec->stLnkTblRec.udwLinkID = linkid ;
		ptrRouteUpDateRec->stLnkTblRec.uwRecSize = TempSize ;
		/****the name space memory ***********/
		memset(( ptrRouteUpDateRec->stLnkTblRec ).pvRtLnk, 0, TempSize)	 ;					
		memcpy( ( ptrRouteUpDateRec->stLnkTblRec ).pvRtLnk,
			&ptrInfo, TempSize );
		/**the link next node is null***/
		ptrRouteUpDateRec->pNxtNode = NULL;
		/*************insert the new node information*******/
		iRet = InsertList( strUpdataRecHeader, ptrRouteUpDateRec );
		
		/****assign the result value ***/
		if ( iRet == RET_FAILED )
		{
			return iRet;
		}
		/*********the name initinzation***/
		memset( ptrInfo.pcRoadName,0,50);
		while ( '#'!=fgetc(fptrUpDateInfo)  );
        /****the file pointer remove the front the space***/
		fseek(fptrUpDateInfo,-1,SEEK_CUR);


        /**get return***/	
		c = getchar();	
	}
	
	return RET_SUCCESS;
	
}

⌨️ 快捷键说明

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