Example #1
0
int main(){
 	char search_for[80]; 
 	printf("Search for: "); 
 	fgets(search_for, 79, stdin); //The coder is not using the full lenght of the array. The subtraction of 1 is not needed in this case
 	find_track(search_for); 
 	return 0;
} 
Example #2
0
int main(){
	char search_for[80]; 
	printf("Search for: "); 
	scanf(search_for, 80, stdin);  //On the scanf the subtraction of 1 is needed
	find_track(search_for); 
	return 0;
}
Example #3
0
int main(){
 	char search_for[80]; 
 	printf("Search for: "); 
 	fgets(search_for, 80, stdin); 
 	find_track(); //Error, no argument being passed to the find_track function
	return 0;
}
Example #4
0
int main(){
	char search_for[80]; 
	printf("Search for: "); 
	fgets(search_for, 80, stdin); 
	find_track(search_for); 
	return 0; //This one would work
}
Example #5
0
int main()
{
	char search_for[80];
	printf("Search for: ");
	fgets(search_for, 80, stdin);
	find_track(strtok(search_for,"\n"));
	return 0;
}
Example #6
0
int main()
{
	char search_for[80];
	printf("Search for :");
	fgets(search_for,80,stdin);
	search_for[strlen(search_for) - 1] = '\0';
	find_track(search_for);
	return 0;
}
Example #7
0
int main (int argc, char *argv[])
{
    char *target = "F";
    char *pattern = "Fr.*Fr.*";

    find_track(target);
    find_track_regex(pattern);

    return 0;
}
int main()
{ 
    char search_for[80];
    printf("Enter regular expression: ");
    fgets(search_for, 80, stdin);
    interpret_input(search_for);
    find_track(search_for);

    return 0;
}
Example #9
0
int main()
{
	char search_for[80];
	printf("искать: ");
	fgets(search_for, 80, stdin);
	search_for[strlen(search_for)-1] = '\0';
	find_track(search_for);
	printf("%s\n", search_for);
	print_reverse(search_for);
	return 0;
}
Example #10
0
int main()
{
    char search_for[80];

    printf("Search for: ");
    fgets(search_for, 80, stdin);
    strip_newline(search_for);
    find_track(search_for);

    return 0;
}
Example #11
0
const struct sync_track *sync_get_track(struct sync_device *d,
    const char *name)
{
	struct sync_track *t;
	int idx = find_track(d, name);
	if (idx >= 0)
		return d->tracks[idx];

	idx = create_track(d, name);
	t = d->tracks[idx];

	get_track_data(d, t);
	return t;
}
Example #12
0
int main (int argc, char *argv[])
{
    char search_for[80];

    /* take input from the user and search */
    printf("Search for: ");
    fgets(search_for, 80, stdin);
    rstrip(search_for);

    find_track(search_for);
    //find_track_regex(search_for);

    return 0;
}
Example #13
0
static void *back_future3_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];

    while (stream_next_bit(s) != -1) {

        uint32_t raw[2], dat[ti->len/4], sum;
        unsigned int i;
        char *block;

        if ((uint16_t)s->word != 0x4489)
            continue;

        ti->data_bitoff = s->index_offset - 15;

        if (stream_next_bits(s, 32) == -1)
            goto fail;
        if (s->word != 0x552524a4)
            continue;
        if (stream_next_bits(s, 32) == -1)
            goto fail;
        if (s->word != 0x554a4945)
            continue;

        for (i = sum = 0; i < ti->len/4; i++) {
            if (stream_next_bytes(s, raw, 8) == -1)
                goto fail;
            mfm_decode_bytes(bc_mfm_even_odd, 4, raw, &dat[i]);
            if ( i < ti->len/4 - 1)
                sum += be32toh(dat[i]);
        }

        /* Only verify the checksum on those tracks that are not
         * listed in the track_array*/
        if (find_track(tracknr) == 0)
            if (sum != be32toh(dat[i-1]))
                continue;

        block = memalloc(ti->len);
        memcpy(block, dat, ti->len);
        set_all_sectors_valid(ti);
        return block;
    }

fail:
    return NULL;
}
Example #14
0
static int create_track(struct sync_device *d, const char *name)
{
	struct sync_track *t;
	assert(find_track(d, name) < 0);

	t = malloc(sizeof(*t));
	t->name = strdup(name);
	t->keys = NULL;
	t->num_keys = 0;

	d->num_tracks++;
	d->tracks = realloc(d->tracks, sizeof(d->tracks[0]) * d->num_tracks);
	d->tracks[d->num_tracks - 1] = t;

	return (int)d->num_tracks - 1;
}
Example #15
0
File: node.c Project: ssherar/c
/**
 * Finds the current track which the entrant is most likely to be between,
 * by checking their time compared to the estimated time for completion of that
 * track
 * @param head the head of the list
 * @param tracks the array holding the tracks
 * @param no_tracks the number of tracks
 * @return The current track.
 */
Track find_current_track(Course_Node** head, Track* tracks, int no_tracks) {
    Course_Node *last_node = find_current_node(head);
    Course_Node *current = (Course_Node*) head;
    int start_minutes = get_time_from_char(current->time);
    int end_minutes = get_time_from_char(last_node->time);
    int difference = end_minutes - start_minutes;
    int track_total = 0;
    while(current != NULL && current != last_node) {
        Track current_track = find_track(tracks, current->node_id, current->next->node_id, no_tracks);
        track_total += current_track.time;
        if(track_total > difference) {
            return current_track;
        }
        current = current->next;
    }
}
/* Function to read in a file of courses */
void read_courses (FILE *file, event *e) {
    int status, i;
   
    course *course_data;
    list_node *node, *track_node;
    track *track;
    
    while (!feof(file)) {
        course_data = malloc(sizeof(course));
        node = malloc(sizeof(list_node));
        
        status = fscanf(file, " %c", &course_data->name);
        if(status != EOF) {
            /*read in the number of nodes in the course*/
            fscanf(file, " %d", &course_data->path_size);

            /*setup an array of tracks*/
            course_data->nodes = malloc(course_data->path_size * sizeof(int));
            course_data->tracks.head = NULL;
            course_data->tracks.tail = NULL;
            
            /* Read in an array of all the nodes in this course. */
            for (i=0; i<course_data->path_size; i++) {
                fscanf(file, " %d", &course_data->nodes[i]);
            } 
            
            /*build a list of tracks that are part of this course*/
            for(i=0;i<course_data->path_size-1;i++) {
                track_node = (list_node *) malloc(sizeof(list_node));
                track = find_track(e->tracklist, course_data->nodes[i], course_data->nodes[i+1]);
                track_node->data = track;
                add_element(&course_data->tracks, track_node);
            }

            node->data = course_data;
            add_element(&e->courselist, node);
        }
    }
}
Example #17
0
/* takes a file handle, file position should be at the start of the Anadisk
   dump data.  reads the info for each sector and builds it into a list
   of sides.  each side holds a list of tracks, and each track a list of sectors */
struct disk_side *parse_image(FILE *fp)
{
	struct sect_info si;
	struct disk_side *sides = NULL;
	struct disk_side *curr_side, *new_side;
	struct disk_track *curr_track, *new_track;
	struct disk_sector *curr_sector, *new_sector;

	
	while (get_sector_info(fp, &si))
	{
		curr_side = find_side(sides, si.phy_side);
		if (curr_side == NULL)
		{
			new_side = make_side(si.phy_side);
			if (sides == NULL)
				sides = new_side;
			else
			{
				for (curr_side = sides; curr_side->next != NULL; curr_side = curr_side->next)
					;
				curr_side->next = new_side;
			}
			max_sides++;
			
			curr_side = new_side;
		}
		
		
		curr_track = find_track(curr_side->tracks, si.phy_cylinder);
		if (curr_track == NULL)
		{
			new_track = make_track(si.phy_cylinder, si.phy_side);
			if (curr_side->tracks == NULL)
				curr_side->tracks = new_track;
			else
			{
				for (curr_track = curr_side->tracks; curr_track->next != NULL; curr_track = curr_track->next)
					;
				curr_track->next = new_track;
			}
			curr_side->track_count++;
			if (curr_side->track_count > max_tracks)
				max_tracks = curr_side->track_count;
			
			curr_track = new_track;
		}
		
		
		new_sector = make_sector(si.log_sector, si.log_cylinder, si.log_side, si.size, ftell(fp));
		if (si.size > sector_size)
			sector_size = si.size;
		if (curr_track->sectors == NULL)
			curr_track->sectors = new_sector;
		else
		{
			for (curr_sector = curr_track->sectors; curr_sector->next != NULL; curr_sector = curr_sector->next)
				;
			curr_sector->next = new_sector;
		}
		curr_track->sector_count++;
		if (curr_track->sector_count > max_sectors)
			max_sectors = curr_track->sector_count;
				
		skip_sector(fp, &si);
	}
	
	return sides;
}