while (1) {
sprintf(buf, "SELECT * FROM prefix WHERE prefix LIKE '%%:%s:%%'",
callsign);
if (! SQLQuery(0, buf))
return;
for (i = 0; row = SQLFetchRow(0); i++) {
countries[i] = (char*)malloc(strlen(row[0]) + 1);
strcpy(countries[i], row[0]);
}
if (i)
break;
else
SQLEndQuery(0);
*(callsign + (--end)) = '\0';
if (! (*callsign)) {
MessageBox(NULL, "No match found", "SQLBase",
MB_OK | MB_ICONINFORMATION);
return;
}
}
SQLEndQuery(0);
countries[i] = NULL;
n = 0;
if (i > 1) {
dd.lbTitle = "Select Country";
dd.lbData = countries;
if (! (n = DialogBoxParam(hInst, "ListBox", v->hwndMain,
DlgProc, (LPARAM)&dd)))
goto end;
n--;
}
SetWindowText(v->hwndEdit[6], countries[n]);
end:
for (i = 0; countries[i]; i++)
free(countries[i]);
}
void CheckCountry(VARS *v)
{
MYSQL_ROW row;
char country[50];
char buf[4096];
int i;
BOOL found = FALSE, confirmed = FALSE;
memset(country, 0, 50);
GetWindowText(v->hwndEdit[6], country, 50);
if (! strlen(country))
return;
sprintf(buf, "SELECT * FROM %s WHERE country='%s'",
v->table, country);
if (! SQLQuery(0, buf))
return;
for (i = 0; row = SQLFetchRow(0); i++) {
found = TRUE;
if (strcmp(row[13], "Yes")) {
confirmed = TRUE;
break;
}
}
SQLEndQuery(0);
if (! found) {
sprintf(buf, "'%s' is a new country", country);
} else if (! confirmed) {
sprintf(buf, "'%s' worked but not confirmed", country);
} else {
sprintf(buf, "'%s' worked and confirmed", country);
}