void type_ext2_inode___file (char *command_line) { char buffer [80]; if (!S_ISREG (type_data.u.t_ext2_inode.i_mode)) { wprintw (command_win,"Error - Inode type is not file\n");refresh_command_win (); return; } if (!init_file_info ()) { wprintw (command_win,"Error - Unable to show file\n");refresh_command_win (); return; } sprintf (buffer,"settype file");dispatch (buffer); }
static int start_server(struct server *s) { WSADATA wsadata; WSAStartup(MAKEWORD(2,2), &wsadata); s->udp_port = connect_udp(s->sd); if(s->udp_port < 0) { fprintf(stderr, "Failed to open UDP port\n"); return -1; } init_file_info(&s->finfo); if(pthread_create(&s->tid, NULL, &message_thread, s) < 0) { perror("pthread_create"); close(s->sd[0]); close(s->sd[1]); return -1; } return 0; }
void onAccept(int sockfd) { char receive_buffer[RECEIVE_BUFFER_SIZE]={0,}; recv(sockfd,receive_buffer,RECEIVE_BUFFER_SIZE,0); printf("%s\n",receive_buffer); uufile_t req_file_info; init_file_info(&req_file_info); get_requested_file_info(receive_buffer,&req_file_info); int need_buffer_size = SEND_BUFFER_SIZE; if(( FILE_TEXT == req_file_info.type) || (FILE_BINARY == req_file_info.type)){ need_buffer_size = req_file_info.size; } char *send_buffer=(char *)malloc((need_buffer_size)*sizeof(char)); if(send_buffer != NULL){ memset(send_buffer,0,need_buffer_size); if( OP_SUCCESS == handle_request_file(&req_file_info,send_buffer,SEND_BUFFER_SIZE)){ send(sockfd,send_buffer,req_file_info.size,0); } free(send_buffer); } }
void merge_vcf(int n_vcf, char **vcf_filenames) { FileInfo *f_info; int n_done, n_chrom, i, *is_lowest, *lowest, n_lowest; int ret, use_geno_probs, use_haplotypes; Chromosome *chrom_tab; f_info = init_file_info(n_vcf, vcf_filenames); /* find chromosomes that are present in ALL VCFs */ chrom_tab = chrom_table_intersect(f_info, n_vcf, &n_chrom); n_done = 0; is_lowest = my_malloc(sizeof(int) * n_vcf); lowest = my_malloc(sizeof(int) * n_vcf); /* only use genotypes and haplotypes if they are present in ALL files */ use_geno_probs = TRUE; use_haplotypes = TRUE; /* read first SNP from all files */ for(i = 0; i < n_vcf; i++) { ret = vcf_read_line(f_info[i].gzf, f_info[i].vcf, &f_info[i].cur_snp); if(ret == -1) { /* file is over */ n_done += 1; f_info[i].is_done = TRUE; my_warn("file %s contains no SNPs\n", vcf_filenames[i]); f_info[i].cur_chrom = NULL; } else { set_cur_chrom(&f_info[i], chrom_tab, n_chrom); if(!f_info[i].cur_snp.has_geno_probs) { if(use_geno_probs) { fprintf(stderr, "Not using genotype likelihoods (GL) because " "not present in file %s\n", vcf_filenames[i]); } use_geno_probs = FALSE; } if(!f_info[i].cur_snp.has_haplotypes) { if(use_haplotypes) { fprintf(stderr, "Not using genotypes (GT) because " "not present in file %s\n", vcf_filenames[i]); } use_haplotypes = FALSE; } } } fprintf(stderr, "parsing files\n"); while(n_done < n_vcf) { /* find SNP(s) with lowest (chrom, pos) */ find_lowest(f_info, n_vcf, is_lowest, lowest, &n_lowest); /* merge counts and write line for these SNPs */ write_output(stdout, f_info, n_vcf, is_lowest, lowest, use_geno_probs, use_haplotypes); /* advance files with lowest SNPs */ for(i = 0; i < n_vcf; i++) { if(!f_info[i].is_done && is_lowest[i]) { if(vcf_read_line(f_info[i].gzf, f_info[i].vcf, &f_info[i].cur_snp) == -1) { /* have reached end of this file */ n_done += 1; f_info[i].is_done = TRUE; } } } } fprintf(stderr, "done!\n"); free_file_info(f_info, n_vcf); for(i = 0; i < n_chrom; i++) { my_free(chrom_tab[i].name); my_free(chrom_tab[i].assembly); } my_free(chrom_tab); my_free(is_lowest); }