1 #include <string.h> // strncpy()
3 #include <Main/globals.hxx>
4 #include <Airports/simple.hxx>
6 #include "AirportList.hxx"
9 AirportList::AirportList (int x, int y, int width, int height)
10 : puList(x, y, width, height)
14 _airports = globals->get_airports();
15 _nAirports = _airports->size();
17 _content = new char *[_nAirports+1];
18 for (int i = 0; i < _nAirports; i++) {
19 const FGAirport *airport = _airports->getAirport(i);
20 snprintf(buf, 1023, "%s %s\0",
22 airport->name.c_str());
24 unsigned int buf_len = (strlen(buf) > 1023) ? 1023 : strlen(buf);
26 _content[i] = new char[buf_len+1];
27 memcpy(_content[i], buf, buf_len);
28 _content[i][buf_len] = '\0';
30 _content[_nAirports] = 0;
34 AirportList::~AirportList ()
36 for (int i = 0; i < _nAirports; i++) {
44 AirportList::getStringValue ()
46 return (char *)_airports->getAirport(getIntegerValue())->id.c_str();
49 // end of AirportList.cxx