/[xlog]/xlog/src/dxcc.c
ViewVC logotype

Diff of /xlog/src/dxcc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by pa4tu, Sun Nov 24 21:06:22 2002 UTC revision 1.18 by pa4tu, Mon Nov 25 20:12:27 2002 UTC
# Line 197  readctydata (void) Line 197  readctydata (void)
197    prefixes = g_hash_table_new (g_str_hash, g_str_equal);    prefixes = g_hash_table_new (g_str_hash, g_str_equal);
198    
199    /* first field in case hash_table_lookup returns NULL */    /* first field in case hash_table_lookup returns NULL */
200    dxcc[0].countryname = g_strdup ("Unknown Country");    dxcc[0].countryname = g_strdup ("");
201    dxcc[0].waz = -1;    dxcc[0].waz = -1;
202    dxcc[0].itu = -1;    dxcc[0].itu = -1;
203    dxcc[0].continent = g_strdup ("--");    dxcc[0].continent = g_strdup ("");
204    dxcc[0].latitude = 0;    dxcc[0].latitude = 0;
205    dxcc[0].longitude = 0;    dxcc[0].longitude = 0;
206    dxcc[0].timezone = 0;    dxcc[0].timezone = 0;
207    dxcc[0].px = g_strdup ("--");    dxcc[0].px = g_strdup ("");
208    dxcc[0].exceptions = NULL;    dxcc[0].exceptions = g_strdup ("");
209    
210    state.countries = 1;    state.countries = 1;
211    
# Line 241  readctydata (void) Line 241  readctydata (void)
241        dxcc[state.countries].px = g_strdup (split[7]);        dxcc[state.countries].px = g_strdup (split[7]);
242        dxcc[state.countries].exceptions = g_strdup (split[8]);        dxcc[state.countries].exceptions = g_strdup (split[8]);
243    
244          /* official prefix */
245          g_strup(split[7]); /* some chars are lowercase */
246          g_hash_table_insert (prefixes, g_strdup (split[7]),
247              GINT_TO_POINTER (state.countries));
248    
249          /* exception list */
250        for (ipfx = 0;; ipfx++)        for (ipfx = 0;; ipfx++)
251          {          {
252            if (!pfxsplit[ipfx])            if (!pfxsplit[ipfx])
253              break;              break;
254            pfx = findpfx (pfxsplit[ipfx]);            pfx = findpfx (pfxsplit[ipfx]);
255            g_hash_table_insert (prefixes, g_strdup (pfx),            if (g_strcasecmp(pfx, split[7]) != 0)
256                                 GINT_TO_POINTER (state.countries));              g_hash_table_insert (prefixes, g_strdup (pfx),
257                  GINT_TO_POINTER (state.countries));
258          }          }
259    
260        g_strfreev (pfxsplit);        g_strfreev (pfxsplit);
# Line 264  readxlogdata (void) Line 271  readxlogdata (void)
271  {  {
272    gchar *dat_location, buf[4096], **split;    gchar *dat_location, buf[4096], **split;
273    FILE *fp;    FILE *fp;
274    gint ichar = 0, ch = 0, country;    gint ichar = 0, ch = 0, country, newcountry;
275    
276    dat_location = g_strconcat (PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S, "dxcc",    dat_location = g_strconcat (PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S, "dxcc",
277                                G_DIR_SEPARATOR_S, "xlog.dat", NULL);                                G_DIR_SEPARATOR_S, "xlog.dat", NULL);
# Line 293  readxlogdata (void) Line 300  readxlogdata (void)
300        if ((g_strncasecmp(buf, "#", 1) != 0) &&        if ((g_strncasecmp(buf, "#", 1) != 0) &&
301          (g_strncasecmp(buf, "\n", 1) != 0))          (g_strncasecmp(buf, "\n", 1) != 0))
302        {        {
303            g_strdelimit(buf, "\n", ' ');
304          split = g_strsplit (buf, " ", 2);          split = g_strsplit (buf, " ", 2);
305          g_strup(split[1]);          g_strup(split[1]);
306          country = lookup_dxcc(split[1]);          country = GPOINTER_TO_INT (g_hash_table_lookup (prefixes, split[1]));;
307          if (country > 0)          if (country > 0)
308          {          { /* search and replace */
309            g_strup(split[0]);            g_strup(split[0]);
310            g_hash_table_insert (prefixes, g_strdup (split[0]),            newcountry = GPOINTER_TO_INT (g_hash_table_lookup (prefixes, split[0]));
311              GINT_TO_POINTER (country));            if (newcountry == 0)
312              {
313                g_hash_table_insert (prefixes, g_strdup (split[0]),
314                  GINT_TO_POINTER (country));
315              }
316              else
317              {
318                g_hash_table_remove (prefixes, split[0]);
319                g_hash_table_insert (prefixes, g_strdup (split[0]),
320                  GINT_TO_POINTER (country));
321              }
322          }          }
323          g_strfreev (split);          g_strfreev (split);
324        }        }

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26