As a Mac Newbie I need to convert about 5,000 lines of ANSI C to Objective C to be used in an iPad app. Most of the code is similar to the example below. To save time and minimize bugs I want to only change the original C code when absolutely necessary to port over to Obj C. To help me understand the conversion, what portions of the code below must be changed to connect into the iPhone/iPad User Interface? Any guidance would really be appreciated. Thanks for the help.
void GetLandingSpeeds(LandingSpeeds *mySpeeds, int PhenomType, LandingInterpolationParameters *InterParams, char *FlapLand, char *WingStab)
{
mySpeeds->LandingSpeedsOK = No;
sprintf(query_string,"SELECT * FROM Landing_Speeds WHERE Weight = %d AND FlapLand = '%s' AND WingStab = '%s'", InterParams->Weight_lower, FlapLand, WingStab);
Query* GetFlapsSpeeds_Lower = sql_select_query(query_string, AircraftDatabase);
if (InterParams->Weight_Interpolation_Percent == 0)
{
// single table
if (GetFlapsSpeeds_Lower->RecordCount == 1)
{
mySpeeds->Vac = atoi(sql_item(GetFlapsSpeeds_Lower, "Vac"));
mySpeeds->Vref = atoi(sql_item(GetFlapsSpeeds_Lower, "Vref"));
if (PhenomType == P300)
mySpeeds->Vfs = atoi(sql_item(GetFlapsSpeeds_Lower, "Vfs"));
mySpeeds->LandingSpeedsOK = Yes;
}
}
else
{
// simple linear interpolation
sprintf(query_string,"SELECT * FROM Landing_Speeds WHERE Weight = %d AND FlapLand = '%s' AND WingStab = '%s'", InterParams->Weight_upper, FlapLand, WingStab);
Query* GetFlapsSpeeds_Upper = sql_select_query(query_string, AircraftDatabase);
if ( (GetFlapsSpeeds_Lower->RecordCount == 1) && (GetFlapsSpeeds_Upper->RecordCount == 1) )
{
mySpeeds->Vac = atoi(sql_item(GetFlapsSpeeds_Lower, "Vac")) * (1-InterParams->Weight_Interpolation_Percent) + atoi(sql_item(GetFlapsSpeeds_Upper, "Vac")) * InterParams->Weight_Interpolation_Percent;
mySpeeds->Vref = atoi(sql_item(GetFlapsSpeeds_Lower, "Vref")) * (1-InterParams->Weight_Interpolation_Percent) + atoi(sql_item(GetFlapsSpeeds_Upper, "Vref")) * InterParams->Weight_Interpolation_Percent;
if (PhenomType == P300)
mySpeeds->Vfs = atoi(sql_item(GetFlapsSpeeds_Lower, "Vfs")) * (1 - InterParams->Weight_Interpolation_Percent) + atoi(sql_item(GetFlapsSpeeds_Upper, "Vfs")) * InterParams->Weight_Interpolation_Percent;
mySpeeds->LandingSpeedsOK = Yes;
}
}
}