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

📄 route_guide_src.c

📁 道路导航系统程序
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <string.h>
#include <stdlib.h>
#include <memory.h>
#include "route_guide_common.h"
#include "route_guide_p.h"
#include "route_guide_c.h"
#include "route_guide_in_s.h"
#include "route_guide_in_p.h"
//////////////////////////////////////////////
////查找界面//////////////////////
/////////////////////////////
/***************************************************************************
	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                             */
/*																		   */
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
STATUS              iSrcCnt         = 100;
STATUS RouteLink_Src( 
	FILE**               pOrgFile 
	)
{
	/****************return the  result*******/
	STATUS				iSrcType		= RG_SRC_LNKID;	
	STATUS				iRet			= RET_SUCCESS;
	STATUS				iResult			= RET_FAILED;
	int                 isExiting       = 0;
	
	/****************** Prompt the user to select an operation ********************/
	while ( isExiting == 0 )
	{
		printf( "\n+-----------------------------------------------------------------+\n" );
		printf(   "| PLEAESE CHOOSE THE SELECT TYPE IN THE FOLLOWING LIST:|\n" );
		printf(   "| < 1     : SEARCH BY LINK DISPLAYED ID |\n" );
		printf(   "| < 2     : SEARCH BY CROSS LINK DISPLAYS CLASS NO |\n" );
		printf(   "| < 3     : SEARCH BY BRANCH NUMBER (0~9)|\n" );
		printf(   "| < 4     : SEARCH BY ROAD NAME |\n" );
		printf(   "| < OTHERS: RETURN  |\n" );
		printf(   "+-----------------------------------------------------------------+\n" );
		printf(   "\nPLEASE INPUT YOUR CHOICE: >>>>>>>  " );
		/************************the input the number opinion********/	
		iResult = scanf( "%d", &iSrcType );
		while( iResult <= 0 )
		{
			fflush( stdin );
			printf( "Invalid input! Please input again:\n");
			printf( "\nPlease input your choice: >>>>>>>  " );
			iResult = scanf( "%d", &iSrcType);
		}

		/**************into the selected the condiction**********/
		switch( iSrcType )
		{
		case RG_SRC_LNKID:	
		case RG_SRC_CLASS:
		case RG_SRC_BRUNCH:
		case RG_SRC_NAME:
			iRet = RouteLink_Src_Sub( *pOrgFile, iSrcType );
	default:
			isExiting = 1;
			break;
		}
	}
	/*************close the file *********/
	fclose( (*pOrgFile) );
	pOrgFile = NULL;
     
	return RET_SUCCESS;
}

/*******************the select condition function *******/
STATUS RouteLink_Src_Sub( 
	FILE*              pOrgFile, //the file handle
	int                 iSrcType //the type of you selected
	)
{
	int                 iQue			= 0;
	STATUS              n				= 0;
	STATUS              iRet            = RET_SUCCESS;  // the file return value
	STATUS              iSrcRsltNum     = 0;
	STATUS              isExiting       = 1;          
	int                 iGetChrNum      = 0;           //the return the value
	UDWORD				udwBaseNameFlg  = 0;		  // the memory the name flag
	UDWORD				udwBaseBranch   = 0;		 //the memory the branch the no	
	S_LNKDATA_NODE *    tempNewcLnk     = NULL;     //the memory the temp link space
	UDWORD				udwBaseClass    = 0;	    //	the user input the class no				
	UDWORD              udwBaseLnkID    = 0;        // the  user input the link id 
	BYTE*               ptrRecBlock     = NULL;     //the memory the binary system temp space
	char *              GetChuName      = NULL;     // the user input the road name 
	S_LNKHEADER         strRecHeader;              //the source the file of head
	S_LNKDATA_FMT       strRouteFMT;               //the struct of type memory the node information
	S_LNKDATA_DSP       strLnkData;               //the struct of type memory the road information 
    S_LNKDATA_NODE       strNewHeader;           //the memory the link head
	STATUS               strNode        = 0;  
	S_LNKTBL*           ptrCurLnk;               //the source the file of node
    S_LNKDATA_NODE  *       ptrNewcLnk;          //the memory the link node
	
	/**********opinion the type whether the linkId *****/
	if(iSrcType == RG_SRC_LNKID)
	{
	printf( "\nPlease input the Link ID you want to search: >>>>>>>  " );
	iGetChrNum = scanf( "%8d", &udwBaseLnkID );
	/**************admit the error the input *********/
	while ( iGetChrNum <= 0 )
	{
		/**********clear the buffer ***************/
		fflush( stdin );
		/********************the screen prompt **********/
		printf( "Invalid input! Please input again:\n");
		printf( "\nPlease input the link ID : >>>>>>>  " );
		iGetChrNum = scanf( "%8d", &udwBaseLnkID);
	}	
	
    }
	/************opinion the type whether the class no ***********************/
	else if(iSrcType == RG_SRC_CLASS)
	{
		printf("\nplease input the Link class No: >>>>>>>>>>>>>  ");
		iGetChrNum = scanf("%8d",&udwBaseClass );
		/****************the screen the prompt the error the input ******/
		while ( iGetChrNum <= 0 )
	{
		fflush( stdin );
		printf( "Invalid input! Please input again:\n");
		printf( "\nPlease input the Cross link displayed class No: >>>>>>>  " );
		iGetChrNum = scanf( "%8d", &udwBaseClass);
	}	
	
	}
	/*************opinion the type  whether the branch the error******/
	else if(iSrcType == RG_SRC_BRUNCH )
	{
		printf("\nplease input the Branch number(over the specified number): >>>>>  ");
		iGetChrNum = scanf("%8d", &udwBaseBranch );
		/****admit the error input ****/
		while ( iGetChrNum <= 0 )
	{
		fflush( stdin );
		printf( "Invalid input! Please input again:\n");
		printf( "\nPlease input the Branch number(over the specified number): >>>>>>>  " );
		iGetChrNum = scanf( "%8d", &udwBaseBranch);
	}	
	
	}
	/***********opinion the type whether the name the error ****/
	else if(iSrcType == RG_SRC_NAME)
	{
		printf("\nplease input the Road name: >>>>>>>>>>>>>>>   ");
		iGetChrNum = scanf("%12s", &GetChuName);
		/**the admit the error user input the name**/
		while ( iGetChrNum <= 0 )
	{
		fflush( stdin );
		printf( "Invalid input! Please input again:\n");
		printf( "\nPlease input the Road name : >>>>>>>  " );
		iGetChrNum = scanf( "%8s", &iSrcType);
	}	
	

	}
	/***initialization the link head from the source the file***/
	InitRecLnk( &strRecHeader );
	/*inititalization the memory the link for output the result*/
	InitNewcLnk( &strNewHeader );
	/*create the link from the source the file */
	CreateRecLnk( &strRecHeader, &pOrgFile);
	/** save the head link information*/
	ptrCurLnk = strRecHeader.pNxtNode;
	printf( "\nRoute link searching. Please be waitting...\n" );
    /********tautog the link find the result*****/
	while ( ptrCurLnk->pNxtNode  != NULL )
	{		
		
	    /**conversion the link node******/
		TranslateRec( &strRouteFMT,  ( BYTE* ) ptrCurLnk->stLnkTblRec.pvRtLnk);
         /*****conversion the link information**/
	    TranslateInfData( &strLnkData, strRouteFMT);
		/**opinion the user input the type*******/
		switch (iSrcType) 
		{
	       case RG_SRC_LNKID:
			  /**********find the result of user input the link id****/
			   if(strLnkData.udwLinkID == udwBaseLnkID )
			 {
			   isExiting = 0; 
			 }
			 break;
		   case RG_SRC_CLASS:
			   /**********find the result of user input the class no ***/
			 if((UDWORD)(strLnkData.bDspClass)  == udwBaseClass )
			 {
				 isExiting = 0;
				
			 }
			break;
		   case RG_SRC_BRUNCH:
			   /****find the result of user input the branch ****/
			  if((UDWORD)strLnkData.bBranchNum  == udwBaseBranch  )
				  isExiting = 0;
			  break;
			  
		   case RG_SRC_NAME:
			   /*****find the result of user input the name**/
	           if(strLnkData.pstRoadName != NULL)
			   {
				  iQue = strcmp(strLnkData.pstRoadName->pbStr, &GetChuName );
			      /*******opinion the input the name *****/
				  if( iQue == 0)
				   isExiting = 0;
			   }
			   break;

⌨️ 快捷键说明

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