static int fill_io_u(struct thread_data *td, struct io_u *io_u) { if (td->io_ops->flags & FIO_NOIO) goto out; set_rw_ddir(td, io_u); /* * fsync() or fdatasync() or trim etc, we are done */ if (!ddir_rw(io_u->ddir)) goto out; /* * See if it's time to switch to a new zone */ if (td->zone_bytes >= td->o.zone_size && td->o.zone_skip) { td->zone_bytes = 0; io_u->file->file_offset += td->o.zone_range + td->o.zone_skip; io_u->file->last_pos = io_u->file->file_offset; td->io_skip_bytes += td->o.zone_skip; } /* * No log, let the seq/rand engine retrieve the next buflen and * position. */ if (get_next_offset(td, io_u)) { dprint(FD_IO, "io_u %p, failed getting offset\n", io_u); return 1; } io_u->buflen = get_next_buflen(td, io_u); if (!io_u->buflen) { dprint(FD_IO, "io_u %p, failed getting buflen\n", io_u); return 1; } if (io_u->offset + io_u->buflen > io_u->file->real_file_size) { dprint(FD_IO, "io_u %p, offset too large\n", io_u); dprint(FD_IO, " off=%llu/%lu > %llu\n", io_u->offset, io_u->buflen, io_u->file->real_file_size); return 1; } /* * mark entry before potentially trimming io_u */ if (td_random(td) && file_randommap(td, io_u->file)) mark_random_map(td, io_u); /* * If using a write iolog, store this entry. */ out: dprint_io_u(io_u, "fill_io_u"); td->zone_bytes += io_u->buflen; log_io_u(td, io_u); return 0; }
int main(int argc, char **argv){ char *filename = argv[1]; FILE *maf_file; if((maf_file= fopen(filename, "rb")) == NULL){ fprintf(stderr, "Unable to open file: %s\nError: %s", filename,strerror(errno)); return 1; } maf_array_parser parser = get_array_parser(maf_file,filename); int j=0; for(; j < parser->size; ++j) printf("%d\n",parser->alignment_blocks[j]); j=0; char buffer[3000]; while(1){ int offset = get_next_offset(parser); if(offset==-1)break; int check =fseek(maf_file, offset,SEEK_SET); if(check!=0)fprintf(stderr, "File seek error: %s\nError: %s", filename,strerror(errno)); char *fc = fgets(buffer,3000,maf_file); printf("Alignment block %d\n%s\n",++j,buffer); } parser->curr_block=1; int offset=get_next_offset(parser); int check =fseek(maf_file, offset,SEEK_SET); if(check!=0)fprintf(stderr, "File seek error: %s\nError: %s", filename,strerror(errno)); char *fc = fgets(buffer,3000,maf_file); fc = fgets(buffer,3000,maf_file); printf("%s\n",buffer); alignment_block aln = get_next_alignment(parser); // seq test=aln->sequences[0]; // printf("Alignment 1 sequence 1: \n%s %lu %u %c %lu %s\n" // ,test->src,test->start,test->size,test->strand, // test->srcSize,test->sequence); free_alignment_block(aln); free_parser(parser); fclose(maf_file); return 0; }