Exemplo n.º 1
0
void Track_station_now(Widget w, XtPointer clientData, XtPointer callData) {
    char temp[MAX_CALLSIGN+1];
    char temp2[200];
    int found = 0;
    char *temp_ptr;


    temp_ptr = XmTextFieldGetString(track_station_data);
    xastir_snprintf(temp,
        sizeof(temp),
        "%s",
        temp_ptr);
    XtFree(temp_ptr);

    (void)remove_trailing_spaces(temp);
    (void)remove_trailing_dash_zero(temp);

    xastir_snprintf(tracking_station_call,
        sizeof(tracking_station_call),
        "%s",
        temp);
    track_case  = (int)XmToggleButtonGetState(track_case_data);
    track_match = (int)XmToggleButtonGetState(track_match_data);
    found = locate_station(da, temp, track_case, track_match, 0);

    if ( valid_object(tracking_station_call)    // Name of object is legal
            || valid_call(tracking_station_call)
            || valid_item(tracking_station_call ) ) {
        track_station_on = 1;   // Track it whether we've seen it yet or not
        if (!found) {
            xastir_snprintf(temp2, sizeof(temp2), langcode("POPEM00026"), temp);
            popup_message_always(langcode("POPEM00025"),temp2);
        }
        // Check for exact match, includes SSID
        if ( track_me & !is_my_call( tracking_station_call, 1) ) {
            XmToggleButtonSetState( trackme_button, FALSE, FALSE );
            track_me = 0;
        }
    } else {
        tracking_station_call[0] = '\0';    // Empty it out again
        track_station_on = 0;
        xastir_snprintf(temp2, sizeof(temp2), langcode("POPEM00002"), temp);
        popup_message_always(langcode("POPEM00003"),temp2);
    }

    track_station_destroy_shell(w, clientData, callData);
    display_zoom_status();
}
Exemplo n.º 2
0
void Download_trail_now(Widget w, XtPointer clientData, XtPointer callData) {
    char temp[MAX_CALLSIGN+1];
    static char fileimg[400];
    static char log_filename[200];
    char *temp_ptr;
    pthread_t download_trail_thread;
    static XtPointer download_client_data = NULL;

    char tmp_base_dir[MAX_VALUE];

    get_user_base_dir("tmp",tmp_base_dir, sizeof(tmp_base_dir));

    // If we're already fetching a trail, we shouldn't be calling
    // this callback function.  Get out.
    if (fetching_findu_trail_now)
        return;

    // Pass two parameters to findu_transfer_thread via a struct
    track_ptrs.download_client_ptrs[0] = log_filename;
    track_ptrs.download_client_ptrs[1] = fileimg;
    download_client_data = &track_ptrs;

    // Check whether it's ok to do a download currently.
    if (read_file) {
        // No, we're already in the middle of reading in some file.
        // Skip trying to download yet another file.

        fprintf(stderr,"Processing another file.  Wait a bit, then try again\n");

        popup_message_always(langcode("POPEM00035"),
            langcode("POPEM00041"));

        return;
    }
 
//    busy_cursor(appshell);

    xastir_snprintf(log_filename,
        sizeof(log_filename),
        "%s/map.log",
        tmp_base_dir);

    // Erase any previously existing local file by the same name.
    // This avoids the problem of having an old tracklog here and
    // the code trying to display it when the download fails.
    unlink( log_filename );


    XmScaleGetValue(posit_start_value , &posit_start);
    XmScaleGetValue(posit_length_value , &posit_length);

    temp_ptr = XmTextFieldGetString(download_trail_station_data);
    xastir_snprintf(temp,
        sizeof(temp),
        "%s",
        temp_ptr);
    XtFree(temp_ptr);

    (void)remove_trailing_spaces(temp);
    (void)remove_trailing_dash_zero(temp);
   
    xastir_snprintf(download_trail_station_call,
        sizeof(download_trail_station_call),
        "%s",
        temp);        
    //Download_trail_destroy_shell(w, clientData, callData);


// New URL's for findu.  The second one looks very promising.
//http://www.findu.com/cgi-bin/raw.cgi?call=k4hg-8&time=1
//http://www.findu.com/cgi-bin/rawposit.cgi?call=k4hg-8&time=1
//
// The last adds this to the beginning of the line:
//
//      "20030619235323,"
//
// which is a date/timestamp.  We'll need to do some extra stuff
// here in order to actually use that date/timestamp though.
// Setting the read_file_ptr to the downloaded file won't do it.



//        "http://www.findu.com/cgi-bin/rawposit.cgi?call=%s&start=%d&length=%d&time=1", // New, with timestamp
    xastir_snprintf(fileimg, sizeof(fileimg),
        //
        // Posits only:
        // "http://www.findu.com/cgi-bin/rawposit.cgi?call=%s&start=%d&length=%d",
        //
        // Posits plus timestamps (we can't handle timestamps yet):
        // "http://www.findu.com/cgi-bin/rawposit.cgi?call=%s&start=%d&length=%d&time=1", // New, with timestamp
        // 
        // Download all packets, not just posits:
        "http://www.findu.com/cgi-bin/raw.cgi?call=%s&start=%d&length=%d",
        //
        download_trail_station_call,posit_start,posit_length);

    if (debug_level & 1024) {
        fprintf(stderr, "%s\n", fileimg);
    }


//----- Start New Thread -----

    if (pthread_create(&download_trail_thread,
            NULL,
            findu_transfer_thread,
            download_client_data)) {

        fprintf(stderr,"Error creating findu transfer thread\n");
    }
    else {
        // We're off and running with the new thread!
    }

    display_zoom_status();

    Download_trail_destroy_shell(w, clientData, callData);
}
Exemplo n.º 3
0
// This is the separate execution thread that fetches the track from
// findu.  The thread is started up by the Download_trail_now()
// function below.
//
static void* findu_transfer_thread(void *arg) {
    char *fileimg;
    char *log_filename;
//    char log_filename_tmp[210];
    char **ptrs;
    char sys_cmd[128];


    // Get fileimg and log_filename from parameters
    ptrs = arg;
    log_filename = ptrs[0];
    fileimg = ptrs[1];

    // Set global "busy" variable
    fetching_findu_trail_now = 1;
 
    if (fetch_remote_file(fileimg, log_filename)) {

        // Had trouble getting the file.  Abort.

// We may not be able to do any GUI stuff from multiple
// threads/processes at the same time.  If that is found to be the
// case we can write to STDERR instead.
 
        // Dump a message to STDERR
//        fprintf(stderr,
//            "%s  %s\n",
//            langcode("POPEM00035"),
//            langcode("POPEM00044"));

        // Fetch Findu Trail: Failed
        popup_message_always(langcode("POPEM00035"),
            langcode("POPEM00044"));

        // Reset global "busy" variable
        fetching_findu_trail_now = 0;

        // End the thread
        return(NULL);
    }

// We need to move this message up to the main thread if possible so
// that we don't have multiple threads writing to the GUI.  This
// sort of operation can cause segfaults.  In practice I haven't
// seen any segfaults due to this particular popup though.

    // Fetch Findu Trail: Complete
    popup_message_always(langcode("POPEM00036"),
        langcode("POPEM00045"));

    // Set permissions on the file so that any user can overwrite it.
    chmod(log_filename, 0666);

#if defined(HAVE_SED)
    // Add three spaces before each "<br>" and axe the "<br>".  This
    // is so that Base-91 compressed packets with no comment and no
    // speed/course/altitude will get decoded ok.  Otherwise the
    // spaces that are critical to the Base-91 packets won't be
    // there due to findu.com filtering them out.
    //
// "sed -i -e \"s/<br>/   <br>/\" %s",
    sprintf(sys_cmd,
        "%s -i -e \"s/<br>/   /\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);
//fprintf(stderr,"%s\n", sys_cmd);

// Greater-than symbol '>'
    sprintf(sys_cmd,
        "%s -i -e \"s/&gt;/>/\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Less-than symbol '<'
    sprintf(sys_cmd,
        "%s -i -e \"s/&lt;/</\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Ampersand '&' (A difficult character to escape from the shell!)
    sprintf(sys_cmd,
        "%s -i -e \"s/&amp;/\\&/\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Double-quote symbol '"'
    sprintf(sys_cmd,
        "%s -i -e \"s/&quot;/""/\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Remove whitespace at the start of a line
// sed 's/^[ \t]*//'
    sprintf(sys_cmd,
        "%s -i -e \"s/^[ \t]*//\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Remove any lines that start with '<'
    sprintf(sys_cmd,
        "%s -i -e \"s/^<.*$//\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Remove any lines that start with '"http'
    sprintf(sys_cmd,
        "%s -i -e \"/^\\\"http.*$/d\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);

// Remove any blank lines from the file
// sed '/^$/d'
    sprintf(sys_cmd,
        "%s -i -e \"/^$/d\" %s",
        SED_PATH,
        log_filename);
    system(sys_cmd);
#endif  // HAVE_SED

/*
#ifdef HAVE_HTML2TEXT
    // Create temp filename
    snprintf(log_filename_tmp, sizeof(log_filename_tmp), "%s%s",
        log_filename,
        ".tmp");
    // Create html2text command
    sprintf(sys_cmd,
        "%s -width 300 -o %s %s",
        HTML2TEXT_PATH,
        log_filename_tmp,
        log_filename);
    // Convert the newly-downloaded file from html to text format
    system(sys_cmd);
    // Rename the file so that we can keep the static char* name
    // pointing to it, needed for the read_file_ptr code in the main
    // thread.
#if defined(HAVE_MV)
    sprintf(sys_cmd,
        "%s %s %s",
        MV_PATH,
        log_filename_tmp,
        log_filename);
    system(sys_cmd);
#endif  // HAVE_MV
#endif  // HAVE_HTML2TEXT
*/

    // Here we do the findu stuff, if the findu_flag is set.  Else we do an imagemap.
    // We have the log data we're interested in within the log_filename file.
    // Cause that file to be read by the "File->Open Log File" routine.  HTML
    // tags will be ignored just fine.
    read_file_ptr = fopen(log_filename, "r");

    if (read_file_ptr != NULL) {
        read_file = 1;
    }
    else {
        fprintf(stderr,"Couldn't open file: %s\n", log_filename);
    }

    // Reset global "busy" variable
    fetching_findu_trail_now = 0;
 
    // End the thread
    return(NULL);
}
Exemplo n.º 4
0
/* ******************************************************************** */
int search_rac_data(char *callsign, rac_record *data) {
    FILE *fdb;
    FILE *fndx;
    char *rc;
    long call_offset = 0l;
    char char_offset[16];
    char index[32];
    int found = 0;
    rac_record racdata;
    /*char        filler[8];*/
    char amacall_path[MAX_VALUE];

    get_user_base_dir("data/AMACALL.ndx", amacall_path, sizeof(amacall_path));


    xastir_snprintf(index, sizeof(index)," ");
    xastir_snprintf(racdata.callsign, sizeof(racdata.callsign)," ");

    /* ====================================================================    */
    /*    Search thru the index, get the RBA                */
    /*                                    */

    fndx = fopen(amacall_path, "r");
    if(fndx != NULL) {
        rc = fgets(index, (int)sizeof(index), fndx);
        xastir_snprintf(char_offset, sizeof(char_offset), "%s", &index[6]);
        while (!feof(fndx) && strncmp(callsign, index, 6) > 0) {
            xastir_snprintf(char_offset, sizeof(char_offset), "%s", &index[6]);
            rc = fgets(index, (int)sizeof(index), fndx);
        }
    } else {
        fprintf(stderr,
            "Search:Could not open RAC data base index: %s\n",
            amacall_path );

        return (0);
    }
    call_offset = atol(char_offset);
 
    (void)fclose(fndx);

    /* ====================================================================    */
    /*    Now we have our pointer into the main database (text) file.    */
    /*    Start from there and linear search the data.            */
    /*    This will take an avg of 1/2 of the # skipped making the index    */
    /*                                    */

    fdb = fopen(get_data_base_dir("fcc/AMACALL.LST"), "r");
    if (fdb != NULL) {
        (void)fseek(fdb, call_offset, SEEK_SET);
        if (callsign[5] == '-')
            (void)chomp(callsign,5);

        while (!feof(fdb) && strncmp((char *)&racdata, callsign, 6) < 0)

//WE7U
// Problem here:  We're sticking 8 bytes too many into racdata!
            rc = fgets((char *)&racdata, sizeof(racdata), fdb);

    } else
        fprintf(stderr,"Search:Could not open RAC data base: %s\n", get_data_base_dir("fcc/AMACALL.LST") );

    /*  || (callsign[5] == '-' && strncmp((char *)&racdata,callsign,5) < 0)) */
    (void)chomp(racdata.callsign, 6);

    if (!strncmp((char *)racdata.callsign, callsign, 6)) {
        found = 1;

// Some of these cause problems on 64-bit processors, so commented
// them out for now.
//        (void)chomp(racdata.first_name, 35);
//        (void)chomp(racdata.last_name, 35);
//        (void)chomp(racdata.address, 70);
//        (void)chomp(racdata.city, 35);
//        (void)chomp(racdata.province, 2);
//        (void)chomp(racdata.postal_code, 10);
//        (void)chomp(racdata.qual_a, 1);
//        (void)chomp(racdata.qual_b, 1);
//        (void)chomp(racdata.qual_c, 1);
//        (void)chomp(racdata.qual_d, 1);
//        (void)chomp(racdata.club_name, 141);
//        (void)chomp(racdata.club_address, 70);
//        (void)chomp(racdata.club_city, 35);
//        (void)chomp(racdata.club_province, 2);
//        (void)chomp(racdata.club_postal_code, 9);

        xastir_snprintf(data->callsign,
            sizeof(data->callsign),
            "%s",
            racdata.callsign);

        xastir_snprintf(data->first_name,
            sizeof(data->first_name),
            "%s",
            racdata.first_name);
 
        xastir_snprintf(data->last_name,
            sizeof(data->last_name),
            "%s",
            racdata.last_name);
 
        xastir_snprintf(data->address,
            sizeof(data->address),
            "%s",
            racdata.address);
 
        xastir_snprintf(data->city,
            sizeof(data->city),
            "%s",
            racdata.city);
 
        xastir_snprintf(data->province,
            sizeof(data->province),
            "%s",
            racdata.province);
 
        xastir_snprintf(data->postal_code,
            sizeof(data->postal_code),
            "%s",
            racdata.postal_code);
 
        xastir_snprintf(data->qual_a,
            sizeof(data->qual_a),
            "%s",
            racdata.qual_a);
 
        xastir_snprintf(data->qual_b,
            sizeof(data->qual_b),
            "%s",
            racdata.qual_b);
 
        xastir_snprintf(data->qual_c,
            sizeof(data->qual_c),
            "%s",
            racdata.qual_c);
 
        xastir_snprintf(data->qual_d,
            sizeof(data->qual_d),
            "%s",
            racdata.qual_d);
 
        xastir_snprintf(data->club_name,
            sizeof(data->club_name),
            "%s",
            racdata.club_name);
 
        xastir_snprintf(data->club_address,
            sizeof(data->club_address),
            "%s",
            racdata.club_address);
 
        xastir_snprintf(data->club_city,
            sizeof(data->club_city),
            "%s",
            racdata.club_city);
 
        xastir_snprintf(data->club_province,
            sizeof(data->club_province),
            "%s",
            racdata.club_province);
 
        xastir_snprintf(data->club_postal_code,
            sizeof(data->club_postal_code),
            "%s",
            racdata.club_postal_code);
 
    }
    (void)fclose(fdb);

    if (!found) {

        // "Callsign Search", "Callsign Not Found!"
        popup_message_always(langcode("STIFCC0101"),
            langcode("STIFCC0102") );
    }
 
    return(found);
}
Exemplo n.º 5
0
void location_add(/*@unused@*/ Widget w, XtPointer clientData, /*@unused@*/ XtPointer callData) {
    char name[100];
    char s_long[20];
    char s_lat[20];
    FILE *f, *fout;
    char temp[200];
    char *temp_ptr;
    Widget my_text = (Widget) clientData;
    int len,n,found;
    char location_file_path[MAX_VALUE];
    char location_db_path[MAX_VALUE];

    get_user_base_dir("config/locations.sys", location_file_path, 
                      sizeof(location_file_path));

    get_user_base_dir("data/locations_db.dat", location_db_path, 
                      sizeof(location_db_path));


    temp_ptr = XmTextFieldGetString(my_text);
    xastir_snprintf(name,
        sizeof(name),
        "%s",
        temp_ptr);
    XtFree(temp_ptr);

    (void)remove_trailing_spaces(name);
    XmTextFieldSetString(my_text,"");
    /* should check for name used already */
    found=0;
    f=fopen(location_file_path,"r");
    if (f!=NULL) {
        while (!feof(f) && !found) {
            (void)get_line(f,temp,200);
            if (!feof(f) && strlen(temp)>8) {
                temp_ptr=strtok(temp,"|");  /* get the name */
                if (temp_ptr!=NULL) {
                    if (strcmp(name,temp)==0)
                        found=1;
                }
            }
        }
        (void)fclose(f);
    }
    else
        fprintf(stderr,"Couldn't open file: %s\n", location_file_path );

    if (!found) {
        /* delete entire list available */
        XmListDeleteAllItems(location_list);
        len = (int)strlen(name);
        if (len>0 && len<100){
            fout = fopen(location_file_path,"a");
            if (fout!=NULL) {
                convert_lat_l2s(center_latitude, s_lat, sizeof(s_lat), CONVERT_HP_NOSP);
                convert_lon_l2s(center_longitude, s_long, sizeof(s_long), CONVERT_HP_NOSP);
                fprintf(fout,"%s|%s %s %ld\n",name,s_lat,s_long,scale_y);
                (void)fclose(fout);
            }
            else
                fprintf(stderr,"Couldn't open file: %s\n", location_file_path );
        } else
            popup_message_always(langcode("POPEM00022"),langcode("POPEM00023"));

        /* resort the list and put it back up */
        n=1;
        clear_sort_file(location_db_path);
        jump_sort();
        sort_list(location_db_path,200,location_list,&n);
    } else
        popup_message_always(langcode("POPEM00022"),langcode("POPEM00024")); /* dupe name */
}
Exemplo n.º 6
0
//
// The user wishes to see popup error messages.  Call the routine
// above which does so.
//
void popup_message(char *banner, char *message) {
    popup_message_always(banner, message);
}