/* File: cities.c
 * Desc: implementation of the stringToCity() function
 * Cristina Cifuentes
 * 10 August 1997
*/

#include "cities.h"
#include "strlib.h"


City stringToCity (String S)
/* Converts a string name to a City enumerate type and returns it.
 * If there is no city that matches in the enumerated type, NoCity
 * is returned 
*/
{ City returnCity = NoCity;
  String uS, uSTest;
  int i;

    stringCopy (uS, S);
    upperCase (uS);

    /* Scans through the cities until it finds a match between the given string
       and the city name of a city, both of which have been converted to
       uppercase */
    i=0;
    while ((i <= NUMCITIES) && (returnCity == NoCity))
    {
        stringCopy (uSTest, cityName[i]);
        upperCase (uSTest);
 
        if (stringCompare (uS, uSTest) == 0)
            returnCity = (City) i;
        i++;
    }
 
  return returnCity;
}


