telnetd/Station.cpp
/*--- function CStationTable::FindStation -----------------------------------
 *
 *  Find a station in the station table.
 *
 *  Entry:  pszStation  points to the station name to search for.
 *
 *  Exit:   Returns TRUE if the station name or "Default" was found,
 *           in which case 
 *          station  contains the parsed entry.
 */
function CStationTable::FindStation
Find a station in the station table.

pszStation  points to the station name to search for.

Returns TRUE if the station name or "Default" was found,
in which case
station  contains the parsed entry.
function CStationTable :: FindStation Find a station in the station table . pszStation points to the station name to search for . Returns TRUE if the station name or " Default " was found in which case station contains the parsed entry .
BOOL CStationTable::FindStation(const char *pszStation, CStation &station)
{
   BOOL bFound=FALSE, bFoundDefault=FALSE;
   char szMyStation[32];
   CStation stnDefault, stnCurrent;
   strncpy(szMyStation, pszStation, sizeof szMyStation);
   TrimTrailingSpaces(szMyStation);
   FILE *sttable = fopen(m_szStationFile,"r");
   char line[256];
   if(sttable) {
      while(fgets(line,sizeof line, sttable)) {
         CrackLine(line, stnCurrent);
         if(0==stricmp(stnCurrent.st_name,szMyStation)) {
            station = stnCurrent;
            bFound = TRUE;
            break;
         } else if(0==stricmp(stnCurrent.st_name,"Default")) {
            stnDefault = stnCurrent;
            bFoundDefault = TRUE;
         }
      }
      fclose(sttable);
   }
   if(!bFound && bFoundDefault) {
      station = stnDefault;
      bFound = TRUE;
   }
   return bFound;
}
BOOL CStationTable :: FindStation ( const char * pszStation , CStation & station ) { BOOL bFound = FALSE , bFoundDefault = FALSE ; char szMyStation [ 32 ] ; CStation stnDefault , stnCurrent ; strncpy ( szMyStation , pszStation , sizeof szMyStation ) ; TrimTrailingSpaces ( szMyStation ) ; FILE * sttable = fopen ( m_szStationFile , " " ) ; char line [ 256 ] ; if ( sttable ) { while ( fgets ( line , sizeof line , sttable ) ) { CrackLine ( line , stnCurrent ) ; if ( 0 == stricmp ( stnCurrent . st_name , szMyStation ) ) { station = stnCurrent ; bFound = TRUE ; break ; } else if ( 0 == stricmp ( stnCurrent . st_name , " " ) ) { stnDefault = stnCurrent ; bFoundDefault = TRUE ; } } fclose ( sttable ) ; } if ( ! bFound && bFoundDefault ) { station = stnDefault ; bFound = TRUE ; } return bFound ; }
function CStationTable::FindStation
  Find a station in the station table.
function CStationTable :: FindStation Find a station in the station table .