Exemplo n.º 1
0
int main(int argc, char * argv[])
{
    /*
     * use example :
     * make
     * ./reader https://pilotweb.nas.faa.gov/common/nat.html
     */

    if (argc != 2)
        return EXIT_FAILURE;

    char * page = read_page(argv[1]);

    if (page == NULL)
        return EXIT_FAILURE;

    stack_t * stack = get_tracks(page);
    char * track = (char *)s_pop(&stack);

    while(track != NULL)
    {
        printf("%s\n", track);
        free(track);
        track = (char *)s_pop(&stack);
    }

    free(page);

    return EXIT_SUCCESS;
}
Exemplo n.º 2
0
static void
lookup_cd_info (char *device, album_info_t *album)
{
    MbDisc disc;
    MbQuery q;
    MbReleaseFilter f;
    MbResultList results;
    MbRelease release;
    char discid[100];
    int num_albums;

    memset(album, 1, sizeof(*album));

    disc = mb_read_disc(device);
    if (!disc) {
        fprintf(stderr, "unable to identify disc.\n");
        exit(1);
    }

    mb_disc_get_id(disc, discid, 100);
    fprintf(stderr, "got disc id: %s\n\n", discid);

    q = mb_query_new(NULL, NULL);
    f = mb_release_filter_new();

    mb_release_filter_disc_id(f, discid);
    results = mb_query_get_releases(q,f);

    mb_release_filter_free(f);
    mb_query_free(q);

    if (!results) {
        fprintf(stderr, "no results found\n");
        exit(1);
    }

    num_albums = mb_result_list_get_size(results);
    if (num_albums < 1) {
        char buf[256];
        mb_get_submission_url(disc, 0, 0, buf, sizeof(buf));
        fprintf(stderr, "nothing in musicbrainz for this one. add it via: %s\n", buf);
        exit(1);
    }

    if (num_albums > 1) {
        fprintf(stderr, "multiple albums!!! picking the last one\n");
    }

    release = mb_result_list_get_release(results, num_albums-1);
    get_album(release, &album->album_id, &album->title, &album->disc_number);

    album->release_date = get_release_date(release);

    get_album_artist(
        release, &album->artist_id, &album->artist, &album->artist_sortname
    );

    get_tracks(release, album);


    /*
    musicbrainz_t mb;
    char buf[256];
    int num_albums;

    mb = mb_New();
    mb_SetDevice(mb, device);
    mb_UseUTF8(mb, TRUE);

#ifdef MB_DEBUG
    mb_SetDebug(mb, TRUE);
#endif

    memset(album, 1, sizeof(*album));
    if (!mb_Query(mb, MBQ_GetCDInfo)) {
        mb_GetQueryError(mb, buf, sizeof(buf));
        fprintf(stderr, "unable to query cd: %s\n", buf);
        exit(1);
    }

    num_albums = mb_GetResultInt(mb, MBE_GetNumAlbums);

    if (num_albums < 1) {
        fprintf(stderr, "nothing in musicbrainz for this one. TODO add url\n");
        exit(1);
    }

    if (num_albums > 1) {
        fprintf(stderr, "multiple albums!!! picking the last one\n");
    }

    mb_Select1(mb, MBS_SelectAlbum, num_albums);

    get_album(mb, &album->album_id, &album->title, &album->disc_number);

    album->release_date = get_release_date(mb);
    
    get_album_artist(
        mb, &album->artist_id, &album->artist, &album->artist_sortname
    );

    get_tracks(mb, album);

    mb_Delete(mb);
    */
}
Exemplo n.º 3
0
int main() {
    int what_next, nodes_n, tracks_n, courses_n, entrants_n;
    //print title for the program
    printf("       __  ___   ____     _   __    ____  ______   ____     ____ \n");
    printf("      /  |/  /  / __ )   / | / /   /  _/ /_  __/  / __ (   / _  ( \n");
    printf("     / /|_/ /  / / / /  /  |/ /    / /    / /    / / / /  / /_/ / \n");
    printf("    / /  / /  / /_/ /  / /|  /   _/ /    / /    / /_/ /  / _, _/ \n");
    printf("   /_/  /_/   (____/  /_/ |_/   /___/   /_/     (____/  /_/ |_| \n\n\n");

    /*Set up arrays of structures for each of the groups of data, then pass these
     to the data functions which read in the information from the text files. 
     Populate the structs there.
     
     For the event structure, simply pass a pointer to the structure. */
    struct Event event_name;
    get_event(&event_name);

    struct Node nodes[30];
    nodes_n = get_nodes(nodes);

    struct Track tracks[30];
    tracks_n = get_tracks(tracks);

    struct Course courses[26];
    courses_n = get_courses(courses);

    struct Record entrants[30];
    entrants_n = get_entrants(entrants, courses, courses_n);

    //print the event information out
    printf("Welcome to system developed for:\n");
    printf("    %s\n", event_name.event);
    printf("    %s\n", event_name.date);
    printf("    %s\n\n", event_name.time);

    do {
        printf("       ******************************************************\n");
        printf("       *                                                    *\n");
        printf("       *             Please Select An Option:               *\n");
        printf("       *----------------------------------------------------*\n");
        printf("       * %2d.Locate Competitor                               *\n", LOCATE_COMPETITOR);
        printf("       * %2d.Count Competitors That Have Not Started         *\n", NOT_STARTED);
        printf("       * %2d.Count Competitors On Course                     *\n", ON_COURSE);
        printf("       * %2d.Count Competitors Finished                      *\n", HAVE_FINISHED);
        printf("       * %2d.Manually Supply Times                           *\n", MANUALLY_SUPPLY);
        printf("       * %2d.Supply Checkpoint Files                         *\n", CHECKPOINT);
        printf("       * %2d.Print Results                                   *\n", RESULTS_LIST);
        printf("       *----------------------------------------------------*\n");
        printf("       * %2d.Quit                                            *\n", QUIT);
        printf("       ******************************************************\n");
        scanf("%d", &what_next);
        //print out the options, using the header file options

        /* based on the user's choice, do what they want */

        switch (what_next) {
            case LOCATE_COMPETITOR: /*Check user input to check if
                                                 the entrant number actually 
                                                 exists*/
                printf("\nPlease Input Competitor Number: ");
                int comp;
                scanf("%d", &comp);
                while (comp > entrants_n || comp < 1) {
                    printf("\nInvalid Competitor Number. Try Again: ");
                    scanf("%d", &comp);
                } /* pass in the structure argument to the function, along
                         the selected entrant number*/
                locate_competitor(entrants, comp);
                printf("Type 'c' to continue..."); /* once complete, get the 
                                                       user to type 'c' to 
                                                       continue. then create
                                                       line space.*/
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case NOT_STARTED:
                count_competitors_not_started(entrants, entrants_n);
                printf("Type 'c' to continue...");
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case ON_COURSE:
                count_competitors_started(entrants, entrants_n);
                printf("Type 'c' to continue...");
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case HAVE_FINISHED:
                count_competitors_finished(entrants, entrants_n);
                printf("Type 'c' to continue...");
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case MANUALLY_SUPPLY:
                printf("\nPlease Input Competitor Number: ");
                scanf("%d", &comp);
                while (comp > entrants_n || comp < 1) {
                    printf("\nInvalid Competitor Number. Try Again: ");
                    scanf("%d", &comp);
                }
                if (entrants[comp].excluded == 0) {
                    supply_manually(entrants, comp, nodes, tracks, tracks_n);
                } else {
                    printf("Sorry, Competitor Excluded.\n");
                }
                printf("Type 'c' to continue...");
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case CHECKPOINT:
                supply_checkpoints(entrants, nodes, nodes_n, tracks, tracks_n);
                printf("Type 'c' to continue...");
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case RESULTS_LIST:
                print_results(entrants, entrants_n);
                printf("Type 'c' to continue...");
                while (getchar() != 'c') {
                }
                printf("\n\n\n\n\n\n\n\n");
                break;
            case QUIT:
                break;
            default: // if the user does not type a number from the list
                printf("Incorrect Input\n\n"); // inform them, and loop.
                break;
        }
    } while (what_next != QUIT);



    return (EXIT_SUCCESS);
}
Exemplo n.º 4
0
int main() {
    int sm_ret;
    EVENT *event = NULL;

    event = get_event();
    event->nodes = get_nodes();
    event->tracks = get_tracks(event->nodes);
    event->courses = get_courses(event->nodes, event->tracks);

    event->entrants = get_entrants();

/*
    event = read_event("data/name.txt");
    event->nodes = read_nodes("data/nodes.txt");
    event->tracks = read_tracks("data/tracks.txt", event->nodes);
    event->courses = read_courses("data/courses.txt", event->nodes, event->tracks);
    event->entrants = read_entrants("data/entrants.txt");

    read_event_data("data/cp_times_1.txt", event);*/


    do {
        sm_ret = show_menu();
        
        if(sm_ret == 1) {
            ENTRANT *ent = NULL;
            ent = query_entrant(event);

            if(ent == NULL) {
                continue;
            }
            
            print_entrant_header();
            print_entrant(ent);
        }
        
        else if (sm_ret == 2) {
            load_cp_data(event);
        }
        
        else if (sm_ret == 3) {
            print_all(event);
        }
        
        else if (sm_ret == 4) {
            not_started(event);
        }
        
        else if (sm_ret == 5) {
            finished(event);
        }
        
        else if (sm_ret == 6) {
            out_track(event);
        }
        
        else if(sm_ret == 0) {
            return EXIT_SUCCESS;
        }

    }while(1);
    
    return EXIT_SUCCESS;
}