40 |
dxcc_data *dxcc; |
dxcc_data *dxcc; |
41 |
GHashTable *prefixes; |
GHashTable *prefixes; |
42 |
|
|
|
/* if there is an underscore in the prefix this means we have to substitute 0-9 */ |
|
|
static gboolean |
|
|
find_underscore (gchar * string, gchar * primaryprefix, guint i) |
|
|
{ |
|
|
gchar **underscore = NULL, *end, *j; |
|
|
guint k; |
|
|
|
|
|
underscore = g_strsplit (string, "_", 0); |
|
|
if (underscore[1] != NULL) |
|
|
{ |
|
|
end = string + strlen (string); |
|
|
for (j = string; j < end; ++j) |
|
|
{ |
|
|
switch (*j) |
|
|
{ |
|
|
case '_': |
|
|
for (k = 0; k <= 9; k++) |
|
|
{ |
|
|
*j = 48 + k; |
|
|
g_hash_table_insert (prefixes, g_strdup (string), |
|
|
GINT_TO_POINTER (i + 1)); |
|
|
state.prefixes++; |
|
|
} |
|
|
break; |
|
|
} |
|
|
} |
|
|
g_strfreev (underscore); |
|
|
return (TRUE); |
|
|
} |
|
|
else |
|
|
{ |
|
|
g_strfreev (underscore); |
|
|
return (FALSE); |
|
|
} |
|
|
} |
|
|
|
|
|
/* see if we can find a string like 4J-4K and substitute the prefixes in between */ |
|
|
static gboolean |
|
|
find_dash (gchar * string, gchar * primaryprefix, guint i) |
|
|
{ |
|
|
gchar **dash = NULL, *begin, *end, *common, *newprefix; |
|
|
gchar first, j; |
|
|
|
|
|
dash = g_strsplit (string, "-", 0); |
|
|
if (dash[1] != NULL) |
|
|
{ /*4J-4K */ |
|
|
begin = dash[0] + 1; /* J */ |
|
|
first = *begin; |
|
|
end = dash[1] + 1; /* K */ |
|
|
common = g_strndup (dash[0], 1); /* 4 */ |
|
|
for (j = *begin; j <= *end; j++) |
|
|
{ |
|
|
newprefix = g_strdup_printf ("%s%c", common, j); |
|
|
if (g_strcasecmp (newprefix, primaryprefix) != 0) |
|
|
{ /* only add new prefixes */ |
|
|
g_hash_table_insert (prefixes, g_strdup (newprefix), |
|
|
GINT_TO_POINTER (i + 1)); |
|
|
state.prefixes++; |
|
|
} |
|
|
} |
|
|
if (j - first == 26) /* we have A-Z, so first character also needs to be added */ |
|
|
if (g_strcasecmp (common, primaryprefix) != 0) |
|
|
{ |
|
|
g_hash_table_insert (prefixes, g_strdup (common), |
|
|
GINT_TO_POINTER (i + 1)); |
|
|
state.prefixes++; |
|
|
} |
|
|
g_free (common); |
|
|
g_strfreev (dash); |
|
|
return (TRUE); |
|
|
} |
|
|
else |
|
|
{ |
|
|
g_strfreev (dash); |
|
|
return (FALSE); |
|
|
} |
|
|
} |
|
|
|
|
43 |
|
|
44 |
static gchar * |
static gchar * |
45 |
findpfx (gchar * pfx) |
findpfx (gchar * pfx) |