/* add a new prefix description */ void prefix_add (char *pfxstr) { gchar *loc; gint last_index = dxcc_count() - 1; dxcc_data *last_dx = dxcc_by_index(last_index); prefix_data *new_prefix = g_new (prefix_data, 1); loc = strchr(pfxstr, '['); if (loc != NULL) { new_prefix -> itu = atoi(loc + 1); *loc = '\0'; } else new_prefix -> itu = last_dx -> itu; loc = strchr(pfxstr, '('); if (loc != NULL) { new_prefix -> cq = atoi(loc + 1); *loc = '\0'; } else new_prefix -> cq = last_dx -> cq; new_prefix -> pfx = g_strdup(pfxstr); new_prefix -> dxcc_index = last_index; g_ptr_array_add (prefix, new_prefix); }
int getwwv(void) { extern char lastwwv[]; extern char backgrnd_str[]; extern double r; extern int mycountrynr; extern int timeoffset; char printbuffer[81] = ""; char *i; char r_value[6]; char sf_value[6]; char timebuff[80]; double sfi, d; time_t now; struct tm *ptr1; attron(COLOR_PAIR(C_HEADER) | A_STANDOUT); mvprintw(24, 0, backgrnd_str); if (strlen(lastwwv) >= 2) { lastwwv[78] = '\0'; /* cut the bell chars */ if ((strncmp(lastwwv, "WCY", 3) == 0) || (strncmp(lastwwv, "WWV", 3) == 0)) { strcat(printbuffer, "Condx: "); i = strstr(lastwwv, "<"); if (i != NULL) { strncat(printbuffer, i + 1, 2); strcat(printbuffer, " GMT "); } i = strstr(lastwwv, "R="); if (i != NULL) { strncat(printbuffer, i, 5); r_value[0] = '\0'; strncat(r_value, i + 2, 3); r = atof(r_value); } strcat(printbuffer, " "); i = strstr(lastwwv, "SFI="); if (i != NULL) { strncat(printbuffer, i, 7); sf_value[0] = '\0'; strncat(sf_value, i + 4, 3); sfi = atof(sf_value); r = ((sfi - 70.0) * (200.0 / 180.0)); } i = strstr(lastwwv, "eru"); if (i != NULL) strcat(printbuffer, " eruptive "); i = strstr(lastwwv, "act"); if (i != NULL) strcat(printbuffer, " act "); i = strstr(lastwwv, "Au=au"); if (i != NULL) strcat(printbuffer, " AURORA!"); strcpy(lastwwv, printbuffer); mvprintw(24, 0, lastwwv); /* print WWV info */ d = dxcc_by_index(mycountrynr) -> timezone; // d -= timeoffset; now = (time(0) + ((timeoffset - d) * 3600)); ptr1 = gmtime(&now); strftime(timebuff, 80, "%H:%M", ptr1); printbuffer[0] = '\0'; mvprintw(24, 64, "local time %s", timebuff); } printcall(); } return (0); }
int show_mults(void) { extern int use_rxvt; extern int countries[MAX_DATALINES]; extern int bandinx; extern int cqww; int i, j, k, l, bandmask = 0; static char prefix[5]; static char zonecmp[3] = ""; int ch; int iMax = dxcc_count(); if (cqww == 1) { mvprintw(12, 29, "E,A,F,N,S,O"); refreshp(); ch = getchar(); while (ch != '\015') { if (ch == 27) break; zonecmp[0] = '\0'; if (ch == 'E' || ch == 'e') strcat(zonecmp, "EU"); else if (ch == 'A' || ch == 'a') strcat(zonecmp, "AS"); else if (ch == 'F' || ch == 'f') strcat(zonecmp, "AF"); else if (ch == 'N' || ch == 'n') strcat(zonecmp, "NA"); else if (ch == 'S' || ch == 's') strcat(zonecmp, "SA"); else if (ch == 'O' || ch == 'o') strcat(zonecmp, "OC"); else strcat(zonecmp, "EU"); attron(COLOR_PAIR(C_LOG) | A_STANDOUT); for (l = 1; l < 6; l++) mvprintw(l, 0, " "); i = 0; for (k = 1; k < 6; k++) { for (j = 0; j <= 19; j++) { while ((i < iMax) && ((strncmp(dxcc_by_index(i) -> continent, zonecmp, 2)) != 0)) { i++; } if (i == iMax) break; switch (bandinx) { case BANDINDEX_160:{ bandmask = BAND160; break; } case BANDINDEX_80:{ bandmask = BAND80; break; } case BANDINDEX_40:{ bandmask = BAND40; break; } case BANDINDEX_20:{ bandmask = BAND20; break; } case BANDINDEX_15:{ bandmask = BAND15; break; } case BANDINDEX_10:{ bandmask = BAND10; break; } } if ((countries[i] & bandmask) == 0) { prefix[0] = '\0'; strncat(prefix, dxcc_by_index(i)->pfx, 3); strncat(prefix, " ", 4 - strlen(prefix)); if (use_rxvt == 0) attron(COLOR_PAIR(C_INPUT) | A_BOLD); else attron(COLOR_PAIR(C_INPUT)); mvprintw(k, j * 4, prefix); refreshp(); i++; } else { mvprintw(k, j * 4, " "); refreshp(); i++; } } if (i == iMax) break; } ch = getchar(); attron(COLOR_PAIR(C_LOG) | A_STANDOUT); } // end while for (l = 1; l < 6; l++) mvprintw(l, 0, " "); } else multiplierinfo(); return (0); }
int getctydata(char *checkcallptr) { char checkbuffer[17] = ""; char checkncall[17] = ""; char checkcall[17] = ""; char findcall[17] = ""; prefix_data *pfx; int pfxmax = prefix_count(); int i = 0, w = 0, x = 0, abnormal_call = 0; char portable = '\0'; int pp = 0; size_t loc; g_strlcpy(checkcall, checkcallptr, 17); portable = '\0'; if (strstr(checkcall, "/QRP") != NULL) /* drop QRP suffix */ checkcall[strlen(checkcall) - 4] = '\0'; if (strstr(checkcall, "/AM") != NULL) // airborne mobile, no country (0), no zone (0) checkcall[0] = '\0'; if (strstr(checkcall, "/MM") != NULL) // maritime mobile, no country, no zone checkcall[0] = '\0'; strncpy(findcall, checkcall, 16); loc = strcspn(checkcall, "/"); if (loc != strlen(checkcall)) { char call1[17]; char call2[17]; strncpy(call1, checkcall, loc); /* 1st part before '/' */ call1[loc] = '\0'; strcpy(call2, checkcall + loc + 1); /* 2nd part after '/' */ if (strlen(call2) < strlen(call1) && strlen(call2) > 1) { sprintf(checkcall, "%s/%s", call2, call1); abnormal_call = 1; loc = strcspn(checkcall, "/"); } if (loc > 3) { strncpy(checkbuffer, (checkcall + loc + 1), (strlen(checkcall) + 1) - loc); if (strlen(checkbuffer) == 1) checkcall[loc] = '\0'; if (checkbuffer[0] == 'M' && strlen(checkbuffer) <= 3) checkcall[loc] = '\0'; if (checkbuffer[0] == 'Q' && strlen(checkbuffer) == 3) /* /QRP */ checkcall[loc] = '\0'; if (checkbuffer[0] == 'A' && strlen(checkbuffer) <= 3) /* /A, /AM etc */ checkcall[loc] = '\0'; if ((strlen(checkbuffer) <= 3) && (checkbuffer[0] <= '9') && (checkbuffer[0] >= '0')) /* /3, etc */ portable = checkbuffer[0]; loc = strcspn(checkcall, "/"); } if (loc != strlen(checkcall)) { if (loc < 5) checkcall[loc] = '\0'; /* "PA/DJ0LN/P */ else { /* DJ0LN/P */ strncpy(checkcall, checkcall, loc + 1); } } /* ------------------------------------------------------------ */ if ((strlen(checkbuffer) == 1) && isdigit(checkbuffer[0])) { /* /3 */ for (pp = strlen(checkcall) - 1; pp > 0; pp--) { if (isdigit(checkcall[pp])) { checkcall[pp] = checkbuffer[0]; break; } } } else if (strlen(checkbuffer) > 1) strcpy(checkcall, checkbuffer); } if (wpx == 1 || pfxmult == 1) /* needed for wpx and other pfx contests */ getpx(checkcall); /* -------------check full call exceptions first...--------------------- */ w = -1; if (abnormal_call == 1) { // pa3fwm 20040111: is pp guaranteed to be properly initialized // if/when we get here?? // pa0r 20040117: It is not. Code changed... // strncpy(checkncall , findcall, pp); strncpy(checkncall, findcall, sizeof(checkncall) - 1); for (i = 0; i < pfxmax; i++) { pfx = prefix_by_index(i); if (strcmp(checkncall, pfx->pfx) == 0) { w = i; x = pfx->dxcc_index; break; } } } else { int bestlen = 0; for (i = 0; i < pfxmax; i++) { int l; pfx = prefix_by_index(i); if (*pfx->pfx != findcall[0]) continue; l = strlen(pfx->pfx); if (l <= bestlen) continue; if (strncmp(pfx->pfx, findcall, l) == 0) { bestlen = l; w = i; } } if (w >= 0) x = prefix_by_index(w)->dxcc_index; } if (w < 0 && 0 != strcmp(findcall, checkcall)) { // only if not found in prefix full call exception list int bestlen = 0; for (i = 0; i < pfxmax; i++) { int l; pfx = prefix_by_index(i); if (*pfx->pfx != checkcall[0]) continue; l = strlen(pfx->pfx); if (l <= bestlen) continue; if (strncmp(pfx->pfx, checkcall, l) == 0) { bestlen = l; w = i; } } if (w >= 0) x = prefix_by_index(w)->dxcc_index; } if (w > 0 ) { sprintf(cqzone, "%02d", prefix_by_index(w) -> cq); sprintf(ituzone, "%02d", prefix_by_index(w) -> itu); } if (itumult != 1) strcpy(zone_export, cqzone); else strcpy(zone_export, ituzone); // w must be >0 tb 17feb2011 // strncpy(ituzone, ituarray[w], 2); countrynr = x; strncpy(continent, dxcc_by_index(countrynr) -> continent , 3); continent[2] = '\0'; return (x); }
int showinfo(int x) { extern int use_rxvt; extern char cqzone[]; extern char ituzone[]; extern char C_DEST_Lat[]; extern char C_DEST_Long[]; extern double bearing; extern double range; extern int timeoffset; extern int timecorr; extern char itustr[]; extern int mycountrynr; int cury, curx; char pxstr[16]; char countrystr[26]; char zonestr[3]; char contstr[3] = ""; char timebuff[80]; dxcc_data *dx; double d; time_t now; struct tm *ptr1; dx = dxcc_by_index(x); strcpy(pxstr, dx->pfx); strcpy(countrystr, dx->countryname); /* country */ if (strlen(cqzone) < 2) { sprintf(zonestr, "%02d", dx->cq); /* cqzone */ strcpy(cqzone, zonestr); } else { strncpy(zonestr, cqzone, 2); zonestr[2] = '\0'; } if (strlen(ituzone) < 2) { sprintf(itustr, "%02d", dx->itu); /* itu zone */ } else { strncpy(itustr, ituzone, 2); itustr[2] = '\0'; } d = dx->timezone; /* GMT difference */ now = (time(0) + ((timeoffset - d) * 3600) + timecorr); ptr1 = gmtime(&now); strftime(timebuff, 80, "%H:%M", ptr1); sprintf(C_DEST_Lat, "%6.2f", dx->lat); /* where is he? */ sprintf(C_DEST_Long, "%7.2f", dx->lon); strncpy(contstr, dx->continent, 2); /* continent */ contstr[2] = '\0'; getyx(stdscr, cury, curx); attron(COLOR_PAIR(C_HEADER) | A_STANDOUT); mvprintw(24, 0, " %s %s ", pxstr, countrystr); mvprintw(24, 26, " %s %s ", contstr, zonestr); if (x != 0 && x != mycountrynr) { qrb(); mvprintw(24, 35, "%.0f km/%.0f deg ", range, bearing); } mvprintw(24, 64, " DX time: %s", timebuff); if (use_rxvt == 0) attron(COLOR_PAIR(NORMCOLOR) | A_BOLD); else attron(COLOR_PAIR(NORMCOLOR)); mvprintw(cury, curx, ""); return (0); }