/** Search partialcall in filtered bandmap * * Lookup given partial call in the list of filtered bandmap spots. * Return a copy of the first entry found (means with teh lowest frequency). * * \param partialcall - part of call to look up * \return spot * structure with a copy of the found spot * or NULL if not found (You have to free the structure * after use). */ spot *bandmap_lookup(char *partialcall) { spot *result = NULL; if ((*partialcall != '\0') && (spots->len > 0)) { int i; pthread_mutex_lock( &bm_mutex ); for (i = 0; i < spots->len; i++) { spot *data; data = g_ptr_array_index( spots, i ); if (strstr(data->call, partialcall) != NULL) { /* copy data into a new Spot structure */ result = copy_spot(data); break; } } pthread_mutex_unlock( &bm_mutex ); } return result; }
spot *bandmap_next(unsigned int upwards, unsigned int freq) { spot *result = NULL; if (spots->len > 0) { int i; pthread_mutex_lock( &bm_mutex ); if (upwards) { for (i = 0; i < spots->len; i++) { spot *data; data = g_ptr_array_index( spots, i ); if ((data->freq > freq + TOLERANCE/2) && (!bm_config.skipdupes || data->dupe == 0)) { /* copy data into a new Spot structure */ result = copy_spot(data); break; } } } else { for (i = spots->len-1; i >= 0; i--) { spot *data; data = g_ptr_array_index( spots, i ); if ((data->freq < freq - TOLERANCE/2) && (!bm_config.skipdupes || data->dupe == 0)) { /* copy data into a new Spot structure */ result = copy_spot(data); break; } } } pthread_mutex_unlock( &bm_mutex ); } return result; }
static void copy_zone (RndfOverlay * r, RndfOverlayZone * z, RndfZone * rndf_z) { z->parent = r; z->zone = rndf_z; z->num_spots = rndf_z->num_spots; z->spots = calloc (rndf_z->num_spots, sizeof (RndfOverlaySpot)); int i; for (i = 0; i < rndf_z->num_spots; i++) copy_spot (z, z->spots + i, rndf_z->spots + i); z->num_peripoints = rndf_z->num_peripoints; z->peripoints = calloc (rndf_z->num_peripoints, sizeof (RndfOverlayWaypoint)); for (i = 0; i < rndf_z->num_peripoints; i++) copy_waypoint (r, (RndfOverlayParent) z, z->peripoints + i, rndf_z->peripoints + i, i > 0 ? z->peripoints + i - 1 : NULL); if (z->num_peripoints) { z->peripoints[0].prev = z->peripoints + z->num_peripoints - 1; z->peripoints[z->num_peripoints-1].next = z->peripoints; } }