141 |
getpx (gchar *checkcall) |
getpx (gchar *checkcall) |
142 |
{ |
{ |
143 |
|
|
144 |
gchar *pxstr, **split; |
gchar *pxstr = NULL, **split; |
145 |
|
|
146 |
/* characters after '/' might contain a country */ |
/* characters after '/' might contain a country */ |
147 |
if (strchr(checkcall, '/')) |
if (strchr(checkcall, '/')) |
168 |
static gint |
static gint |
169 |
lookup_dxcc (gchar * callsign) |
lookup_dxcc (gchar * callsign) |
170 |
{ |
{ |
171 |
gint ipx, country = -1; |
gint ipx, country = 0; |
172 |
gchar *px, *searchpx = NULL; |
gchar *px, *searchpx = NULL; |
173 |
|
|
174 |
px = getpx(callsign); |
px = getpx(callsign); |
|
|
|
175 |
for (ipx = strlen(px); ipx > 0; ipx--) |
for (ipx = strlen(px); ipx > 0; ipx--) |
176 |
{ |
{ |
177 |
searchpx = g_strndup (px, ipx); |
searchpx = g_strndup (px, ipx); |
178 |
country = GPOINTER_TO_INT (g_hash_table_lookup (prefixes, searchpx)); |
country = GPOINTER_TO_INT (g_hash_table_lookup (prefixes, searchpx)); |
179 |
if (country >= 0) break; |
if (country > 0) break; |
180 |
} |
} |
181 |
|
|
182 |
g_free (px); |
if (strlen(px) > 0) g_free (px); |
183 |
if (strlen(searchpx) > 0) g_free(searchpx); |
if (strlen(searchpx) > 0) g_free(searchpx); |
184 |
|
|
185 |
return (country); |
return (country); |