/[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.13 by pa4tu, Sat Nov 23 16:09:30 2002 UTC revision 1.14 by pa4tu, Sat Nov 23 18:11:08 2002 UTC
# Line 39  extern preferencestype preferences; Line 39  extern preferencestype preferences;
39  extern statetype state;  extern statetype state;
40  dxcc_data *dxcc;  dxcc_data *dxcc;
41  GHashTable *prefixes;  GHashTable *prefixes;
42    gchar *searchpx = NULL;
43    gint excwaz, excitu;
44    
45  static gchar *  static gchar *
46  findpfx (gchar * pfx)  findpfx (gchar * pfx)
# Line 202  static gint Line 203  static gint
203  lookup_dxcc (gchar * callsign)  lookup_dxcc (gchar * callsign)
204  {  {
205    gint ipx, country = 0;    gint ipx, country = 0;
206    gchar *px, *searchpx = NULL;    gchar *px;
207    
208    px = getpx(callsign);    px = getpx(callsign);
209    if (px)    if (px)
# Line 211  lookup_dxcc (gchar * callsign) Line 212  lookup_dxcc (gchar * callsign)
212      {      {
213        searchpx = g_strndup (px, ipx);        searchpx = g_strndup (px, ipx);
214        country = GPOINTER_TO_INT (g_hash_table_lookup (prefixes, searchpx));        country = GPOINTER_TO_INT (g_hash_table_lookup (prefixes, searchpx));
       g_free(searchpx);  
215        if (country > 0) break;        if (country > 0) break;
216      }      }
217      g_free (px);      g_free (px);
218    }    }
219    else country = 0;    else country = 0;
220      if (country == 0) searchpx = NULL;
221      
222    return (country);    return (country);
223  }  }
224    
225    
226    static gchar *findexc(gchar *exc)
227    {
228      gchar *end, *j;
229    
230      g_strstrip(exc);
231      end = exc + strlen(exc);
232      for (j = exc; j < end; ++j)
233      {
234        switch (*j)
235        {
236          case '(':
237            if (*(j+2) == 41)
238              excwaz = *(j+1) - 48;
239            else if (*(j+3) == 41)
240              excwaz = ((*(j+1) - 48) * 10) + (*(j+2) - 48);
241          case '[':
242            if (*(j+2) == 93)
243              excitu = *(j+1) - 48;
244            else if (*(j+3) == 93)
245              excitu = ((*(j+1) - 48) * 10) + (*(j+2) - 48);
246          case ';':
247            *j = '\0';
248          break;
249        }
250      }
251      return exc;
252    }
253    
254    
255  void  void
256  updatedxccframe (gchar * callsign)  updatedxccframe (gchar * callsign)
257  {  {
258    GtkWidget *dxcclabel1, *dxcclabel2, *dxcclabel3, *dxcclabel4,    GtkWidget *dxcclabel1, *dxcclabel2, *dxcclabel3, *dxcclabel4,
259      *dxcclabel5, *dxccframe;      *dxcclabel5, *dxccframe;
260    gchar *labeltext1, *labeltext2, *labeltext3, *labeltext4;    gchar *labeltext1, *labeltext2, *labeltext3, *labeltext4, *gcresult;
261    gint country = -1;    gint country = -1, iexc;
262    gchar *gcresult;    gchar **excsplit, *exc;
263      gboolean exception = FALSE;
264    
265    dxcclabel1 = lookup_widget (mainwindow, "dxcclabel1");    dxcclabel1 = lookup_widget (mainwindow, "dxcclabel1");
266    dxcclabel2 = lookup_widget (mainwindow, "dxcclabel2");    dxcclabel2 = lookup_widget (mainwindow, "dxcclabel2");
# Line 253  updatedxccframe (gchar * callsign) Line 284  updatedxccframe (gchar * callsign)
284    if (country > 0)    if (country > 0)
285      {      {
286        labeltext1 = g_strdup (dxcc[country].countryname);        labeltext1 = g_strdup (dxcc[country].countryname);
287        labeltext2 =        /* look for exceptions */
288          g_strdup_printf ("%s - ITU %d - CQ %d", dxcc[country].continent,        if (strchr(dxcc[country].exceptions, '(') ||
289            dxcc[country].itu, dxcc[country].waz);          strchr(dxcc[country].exceptions, '['))
290          {
291            excsplit = g_strsplit(dxcc[country].exceptions, ",", 0);
292            for (iexc = 0;; iexc++)
293            {
294              if (!excsplit[iexc]) break;
295              exc = findexc(excsplit[iexc]);
296              if (g_strcasecmp(searchpx, exc) == 0)
297              {
298                labeltext2 = g_strdup_printf ("%s - ITU %d - CQ %d",
299                  dxcc[country].continent, excitu, excwaz);
300                exception = TRUE;
301              }
302            }
303            g_strfreev(excsplit);
304          }
305    
306          if (! exception)
307          labeltext2 = g_strdup_printf ("%s - ITU %d - CQ %d",
308            dxcc[country].continent, dxcc[country].itu, dxcc[country].waz);
309    
310  /*      labeltext3 = g_strdup_printf (_("Timezone: %s"), dxccsplit[5]);  /*      labeltext3 = g_strdup_printf (_("Timezone: %s"), dxccsplit[5]);
311        labeltext4 =        labeltext4 =
312          g_strdup_printf (_("Location: %s, %s"), dxccsplit[6], dxccsplit[7]);          g_strdup_printf (_("Location: %s, %s"), dxccsplit[6], dxccsplit[7]);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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