Пример #1
0
static int attr_callback(void *user_data, const char *attr, const char *val)
{
    TagsContext *ctx = (TagsContext *) user_data;
    if (!strcmp(attr, "name"))
        ctx->name = val;
    else if (!strcmp(attr, "version")) {
        gzputs(ctx->packages, "##----------------------------------------\n");
        gzputs(ctx->packages, "=Pkg: ");
        gzprintf(ctx->packages, "%s %s %d %s\n", join2(&ctx->pctx->jd, "rubygem", "-", ctx->name), val, 0, "x86_64");
        gzputs(ctx->packages_en, "##----------------------------------------\n");
        gzputs(ctx->packages_en, "=Pkg: ");
        gzprintf(ctx->packages_en, "%s %s %d %s\n", join2(&ctx->pctx->jd, "rubygem", "-", ctx->name), val, 0, "x86_64");
    }
    else if (!strcmp(attr, "summary")) {
        gzputs(ctx->packages_en, "=Sum: ");
        gzputs(ctx->packages_en, val);
        gzputs(ctx->packages_en, "\n");
    }
    else if (!strcmp(attr, "description")) {
        gzputs(ctx->packages_en, "+Des:\n");
        gzputs(ctx->packages_en, val);
        gzputs(ctx->packages_en, "\n-Des:\n");
    }

    return 0;
}
Пример #2
0
int32_t SDDS_GZipPrintNamelistField(gzFile *gzfp, char *name, char *value)
{
  char *buffer = NULL, *bPtr, *vPtr;
  if (!name)
    return 0;
  if (!value || !strlen(name))
    return 1;
  if (!strlen(value))
    gzprintf(gzfp, "%s=\"\", ", name);
  else {
    if (strchr(value, '"')) {
      if (!(buffer=SDDS_Malloc(sizeof(*buffer)*2*strlen(value))))
        return 0;
      vPtr = value;
      bPtr = buffer;
      while (*vPtr) {
        if (*vPtr=='"')
          *bPtr++ = '\\';
        *bPtr++ = *vPtr++;
      }
      *bPtr = 0;
      value = buffer;
    }
    if (strpbrk(value, " ,*$\t\n\b"))
      gzprintf(gzfp, "%s=\"%s\", ", name, value);
    else
      gzprintf(gzfp, "%s=%s, ", name, value);
    if (buffer)
      free(buffer);
  }
  return 1;
}
Пример #3
0
void uninit_plugin(void *self) {
    // Save any that we haven't flushed yet
    for (auto &kvp : read_text_tracker) {
        if (kvp.second.nch > min_strlen) {
            gzprintf(mem_report, "%llu:%.*s\n", rr_get_guest_instr_count(), kvp.second.nch, kvp.second.ch);
        }
    }
    for (auto &kvp : write_text_tracker) {
        if (kvp.second.nch > min_strlen) {
            gzprintf(mem_report, "%llu:%.*s\n", rr_get_guest_instr_count(), kvp.second.nch, kvp.second.ch);
        }
    }
    for (auto &kvp : read_utext_tracker) {
        if (kvp.second.nch > min_strlen) {
            gsize bytes_written = 0;
            gchar *out_str = g_convert((gchar *)kvp.second.ch, kvp.second.nch*2,
                "UTF-8", "UTF-16LE", NULL, &bytes_written, NULL);
            gzprintf(mem_report, "%llu:%s\n", rr_get_guest_instr_count(), out_str);
            g_free(out_str);
        }
    }
    for (auto &kvp : write_utext_tracker) {
        if (kvp.second.nch > min_strlen) {
            gsize bytes_written = 0;
            gchar *out_str = g_convert((gchar *)kvp.second.ch, kvp.second.nch*2,
                "UTF-8", "UTF-16LE", NULL, &bytes_written, NULL);
            gzprintf(mem_report, "%llu:%s\n", rr_get_guest_instr_count(), out_str);
            g_free(out_str);
        }
    }

    gzclose(mem_report);
}
Пример #4
0
abbababa::~abbababa(){

  if(doAbbababa==0)
    return;

  if(doAbbababa==1){
    for(int i=0;i<nInd;i++){
      for(int j=0;j<125;j++)
	gzprintf(outfileZ,"%lu\t",alleleCounts[i][j]);
      gzprintf(outfileZ,"\n");
    }
  }


  for(int i=0;i<nInd;i++)
    delete[]  alleleCounts[i];
  delete [] alleleCounts; 

  for(int i=0;i<nInd;i++)
    delete[]  alleleCountsChr[i];
  delete [] alleleCountsChr; 

  gzclose(outfileZ);
  fclose(outfile);
}
Пример #5
0
void SymbolMap::SaveSymbolMap(const char *filename) const {
	lock_guard guard(lock_);

	// Don't bother writing a blank file.
	if (!File::Exists(filename) && functions.empty() && data.empty()) {
		return;
	}

#if defined(_WIN32) && defined(UNICODE)
	gzFile f = gzopen_w(ConvertUTF8ToWString(filename).c_str(), "w9");
#else
	gzFile f = gzopen(filename, "w9");
#endif

	if (f == Z_NULL)
		return;

	gzprintf(f, ".text\n");

	for (auto it = modules.begin(), end = modules.end(); it != end; ++it) {
		const ModuleEntry &mod = *it;
		gzprintf(f, ".module %x %08x %08x %s\n", mod.index, mod.start, mod.size, mod.name);
	}

	for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
		const FunctionEntry& e = it->second;
		gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_FUNCTION, GetLabelNameRel(e.start, e.module));
	}

	for (auto it = data.begin(), end = data.end(); it != end; ++it) {
		const DataEntry& e = it->second;
		gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module));
	}
	gzclose(f);
}
Пример #6
0
/* void readFile()
 * Control the I/O.
 */
void readFile(File in, File out, int len, float qual,
    float avg, int minLen, int opt5, int opt3,
    int gz, int verbose) {
  char* head = (char*) memalloc(MAX_SIZE);
  char* seq = (char*) memalloc(MAX_SIZE);
  char* line = (char*) memalloc(MAX_SIZE);

  int count = 0, elim = 0;
  while (getLine(head, MAX_SIZE, in, gz) != NULL) {
    if (head[0] != '@')
      continue;

    // load sequence and quality scores
    if (getLine(seq, MAX_SIZE, in, gz) == NULL)
      exit(error("", ERRSEQ));
    for (int i = 0; i < 2; i++)
      if (getLine(line, MAX_SIZE, in, gz) == NULL)
        exit(error("", ERRSEQ));
    int end = strlen(line) - 1;
    if (line[end] == '\n')
      line[end] = '\0';
    if (end < len) {
      elim++;
      continue;
    }

    // trim read
    int st = 0;
    if (len)
      st = trimQual(line, len, qual, &end, opt5, opt3);
    if (avg && checkQual(line, st, end, avg)) {
      elim++;
      continue;
    }

    // print output
    if (st < end && end - st >= minLen) {
      gz ? gzprintf(out.gzf, "%s", head)
        : fprintf(out.f, "%s", head);
      for (int i = st; i < end; i++)
        gz ? gzputc(out.gzf, seq[i]) : putc(seq[i], out.f);
      gz ? gzprintf(out.gzf, "\n+\n")
        : fprintf(out.f, "\n+\n");
      for (int i = st; i < end; i++)
        gz ? gzputc(out.gzf, line[i]) : putc(line[i], out.f);
      gz ? gzprintf(out.gzf, "\n")
        : fprintf(out.f, "\n");
      count++;
    } else
      elim++;
  }

  if (verbose)
    printf("Reads printed: %d\nReads eliminated: %d\n",
      count, elim);

  free(seq);
  free(line);
  free(head);
}
Пример #7
0
/**
 * Writes a feature vector to a file stream
 * @param f Feature vector
 * @param z File pointer
 */
void fvec_write(fvec_t *f, gzFile z)
{
    assert(f && z);
    int i;

    gzprintf(z, "fvec: len=%lu, total=%lu, label=%12.10f, src=%s\n",
             f->len, f->total, f->label, f->src ? f->src : "(null)");
    for (i = 0; i < f->len; i++)
        gzprintf(z, "  feat=%.16llx:%12.10f\n",
                 (unsigned long long) f->dim[i], (double) f->val[i]);
}
Пример #8
0
/**
 * Saves a feature vector to a file stream
 * @param f Feature vector
 * @param z Stream pointer
 */
void fvec_save(fvec_t *f, gzFile * z)
{
    assert(f && z);
    int i;

    gzprintf(z, "feature vector: len=%lu, total=%lu, mem=%lu, src=%s\n",
             f->len, f->total, f->mem, f->src);
    for (i = 0; i < f->len; i++)
        gzprintf(z, "  %.16llx:%.16g\n", (unsigned long long) f->dim[i],
                 (float) f->val[i]);
}
Пример #9
0
Файл: msg.c Проект: goneri/burp
int send_msg_zp(gzFile zp, char cmd, const char *buf, size_t s)
{
	if(gzprintf(zp, "%c%04X", cmd, s)!=5
	  || gzwrite(zp, buf, s)!=(int)s
	  || gzprintf(zp, "\n")!=1)
	{
		logp("Unable to write message to compressed file: %s\n",
			strerror(errno));
		return -1;
	}
	return 0;
}
Пример #10
0
static int dep_callback(void *user_data, const char *name, const char *op, const char *version)
{
    TagsContext *ctx = (TagsContext *) user_data;
    if (*op == '~') {
      char *bumped = gem_version_bump(version);
      gzprintf(ctx->packages, "%s %s %s\n", join2(&ctx->pctx->jd, "rubygem", "-", name), ">=", version);
      gzprintf(ctx->packages, "%s %s %s\n", join2(&ctx->pctx->jd, "rubygem", "-", name), "<", bumped);
      free(bumped);
      return 0;
    }
    gzprintf(ctx->packages, "%s %s %s\n", name, op, version);
}
Пример #11
0
static void process_contig(BreakpointCaller *caller,
                           const uint32_t *cols, size_t ncols,
                           const dBNodeBuffer *flank5p,
                           const dBNodeBuffer *allelebuf,
                           const KOccurRun *flank5p_runs, size_t num_flank5p_runs,
                           const KOccurRun *flank3p_runs, size_t num_flank3p_runs)
{
  gzFile gzout = caller->gzout;
  KOGraph kograph = caller->kograph;
  const size_t kmer_size = caller->db_graph->kmer_size;

  ctx_assert(ncols > 0);

  // we never re-met the ref
  if(num_flank3p_runs == 0) return;

  // Find first place we meet the ref
  size_t callid = __sync_fetch_and_add((volatile size_t*)caller->callid, 1);

  // Swallow up some of the path into the 3p flank
  size_t i, flank3pidx = flank3p_runs[0].qoffset;
  size_t extra3pbases = MIN2(kmer_size-1, flank3pidx);
  size_t num_path_kmers = flank3pidx - extra3pbases;
  size_t kmer3poffset = kmer_size-1-extra3pbases;

  pthread_mutex_lock(caller->out_lock);

  // 5p flank with list of ref intersections
  gzprintf(gzout, ">brkpnt.%zu.5pflank chr=", callid);
  koruns_gzprint(gzout, kmer_size, kograph, flank5p_runs, num_flank5p_runs, 0, 0);
  gzputc(gzout, '\n');
  db_nodes_gzprint(flank5p->data, flank5p->len, caller->db_graph, gzout);
  gzputc(gzout, '\n');

  // 3p flank with list of ref intersections
  gzprintf(gzout, ">brkpnt.%zu.3pflank chr=", callid);
  koruns_gzprint(gzout, kmer_size, kograph, flank3p_runs, num_flank3p_runs,
                 flank3pidx, kmer3poffset);
  gzputc(gzout, '\n');
  db_nodes_gzprint_cont(allelebuf->data+num_path_kmers,
                        allelebuf->len-num_path_kmers,
                        caller->db_graph, gzout);
  gzputc(gzout, '\n');

  // Print path with list of colours
  gzprintf(gzout, ">brkpnt.%zu.path cols=%zu", callid, cols[0]);
  for(i = 1; i < ncols; i++) gzprintf(gzout, ",%zu", cols[i]);
  gzputc(gzout, '\n');
  db_nodes_gzprint_cont(allelebuf->data, num_path_kmers, caller->db_graph, gzout);
  gzprintf(gzout, "\n\n");

  pthread_mutex_unlock(caller->out_lock);
}
Пример #12
0
int32_t SDDS_GZipWriteDataMode(DATA_MODE *data_mode, gzFile *gzfp) 
{
  if (!gzfp || data_mode->mode<0 || data_mode->mode>SDDS_NUM_DATA_MODES)
    return(0);

  gzputs(gzfp,"&data ");
  SDDS_GZipPrintNamelistField(gzfp, "mode", SDDS_data_mode[data_mode->mode-1]);
  if (data_mode->lines_per_row>1)
    gzprintf(gzfp, "lines_per_row=%" PRId32 ", ", data_mode->lines_per_row);
  if (data_mode->no_row_counts)
    gzprintf(gzfp, "no_row_counts=1, ");
  gzputs(gzfp,"&end\n");
  return(1);
}
Пример #13
0
void write_addedback(int filenumber)
{
  FILE	*FILEOUT;
  gzFile fileGz;
  char	fileout[256];
  int	i, set;

  set = 0;

  if (filenumber < 10)       sprintf (fileout, "res/added.00%1d", filenumber);
  else if (filenumber< 100)  sprintf (fileout, "res/added.0%2d",  filenumber);
  else       sprintf (fileout, "res/added.%3d",  filenumber);

  /*  printf ("write file: %s\n",fileout); */
  if( useCompression ) {
	  sprintf( filename, "%s.gz", fileout );
	  fileGz = gzopen (filename, "wb");
	  if (! fileGz) printf("Can't open ascii file for writing\n");

	  gzprintf(fileGz, "%d\n", m[set]);

	  for(i=0; i<m[set]; i++)
	  {
		  /*read dataset row by row, prev/next order changed because backwards*/
		  gzprintf(fileGz, "%4d %4d %10.3f %10.3f %10.3f %d %10.3f\n",
				  mega[set][i].prev, mega[set][i].next, mega[set][i].x[0],
				  mega[set][i].x[1], mega[set][i].x[2], mega[set][i].prio, mega[set][i].finaldecis); /* Alex 24.11.03 */
	  }
	  gzclose(fileGz);
  } else {
	  FILEOUT = fopen (fileout, "w");
	  if (! FILEOUT) printf("Can't open ascii file for writing\n");

	  fprintf(FILEOUT, "%d\n", m[set]);

	  for(i=0; i<m[set]; i++)
	  {
		  /*read dataset row by row, prev/next order changed because backwards*/
		  fprintf(FILEOUT, "%4d %4d %10.3f %10.3f %10.3f %d %10.3f\n",
				  mega[set][i].prev, mega[set][i].next, mega[set][i].x[0],
				  mega[set][i].x[1], mega[set][i].x[2], mega[set][i].prio, mega[set][i].finaldecis); /* Alex 24.11.03 */
	  }
	  fclose(FILEOUT);
  }



}
Пример #14
0
int
flushstruct (int i, char add)
{
  if (add != 1)
    if (theipz[i]->flags != N0L0G)
      if ((theipz[i]->time + 7000) > time (NULL))
	if (strlen (theipz[i]->data) > 4011)
	  {
#ifndef COMPRESS
      		  fprintf (filez, "\n--=[ %s:%i --> ", myinet_ntoa (theipz[i]->sip), ntohs (theipz[i]->sport));
              fprintf (filez, "%s:%i ]=--\n", myinet_ntoa (theipz[i]->dip), ntohs(theipz[i]->dport));
                  fwrite (theipz[i]->data, strlen (theipz[i]->data), 1, filez);
		  fflush(filez);
#else
		  gzprintf(filez, "\n--=[ %s:%i --> ", myinet_ntoa (theipz[i]->sip), ntohs (theipz[i]->sport));
	    	gzprintf (filez, "%s:%i ]=--\n", myinet_ntoa (theipz[i]->dip), ntohs (theipz[i]->dport));
	    gzwrite (filez,theipz[i]->data, strlen (theipz[i]->data));
#endif
	    theipz[i]->flags = N0L0G;
	    return (0);
	  }

  if ((theipz[i]->time + 7000) < time (NULL) || add == 1)
    {
      if (theipz[i]->flags != N0L0G)
	{

#ifndef COMPRESS
	  fprintf (filez, "\n--=[ %s:%i --> ", myinet_ntoa (theipz[i]->sip), ntohs (theipz[i]->sport));
	  fprintf (filez, "%s:%i ]=--\n", myinet_ntoa (theipz[i]->dip), ntohs (theipz[i]->dport));
	  fwrite (theipz[i]->data, strlen (theipz[i]->data), 1, filez);
	  fprintf (filez, ".\n");
	  fflush(filez);
#else
          gzprintf (filez, "\n--=[ %s:%i --> ", myinet_ntoa (theipz[i]->sip), ntohs (theipz[i]->sport));
	  gzprintf (filez, "%s:%i ]=--\n", myinet_ntoa (theipz[i]->dip), ntohs (theipz[i]->dport));
          gzwrite (filez,theipz[i]->data, strlen (theipz[i]->data));
          gzprintf (filez, ".\n");
#endif
	  
	  theipz[i]->flags = N0L0G;
	}
      free (theipz[i]);
      theipz[i] = NULL;
      return (0);
    }
  return (0);
}
Пример #15
0
int address_table_write_update(address_table_t* const table, gzFile handle) {
  if (!gzprintf(handle,
                "%d %d\n",
                NORM(table->last - table->added_since_last_update + 1),
                MAC_TABLE_ENTRIES)) {
#ifndef NDEBUG
    perror("Error writing update");
#endif
    return -1;
  }
  int idx;
  for (idx = table->added_since_last_update; idx > 0; --idx) {
    int mac_id = NORM(table->last - idx + 1);
#ifndef DISABLE_ANONYMIZATION
    uint64_t digest_ip;
    uint8_t digest_mac[ETH_ALEN];
    if (anonymize_ip(table->entries[mac_id].ip_address, &digest_ip)
        || anonymize_mac(table->entries[mac_id].mac_address, digest_mac)) {
#ifndef NDEBUG
      fprintf(stderr, "Error anonymizing MAC mapping\n");
#endif
      return -1;
    }
    if (!gzprintf(handle,
                  "%s %" PRIx64 "\n",
                  buffer_to_hex(digest_mac, ETH_ALEN),
                  digest_ip)) {
#else
    if (!gzprintf(handle,
                  "%s %" PRIx32 "\n",
                  buffer_to_hex(table->entries[mac_id].mac_address, ETH_ALEN),
                  table->entries[mac_id].ip_address)) {
#endif
#ifndef NDEBUG
      perror("Error writing update");
#endif
      return -1;
    }
  }
  if (!gzprintf(handle, "\n")) {
#ifndef NDEBUG
    perror("Error writing update");
#endif
    return -1;
  }
  table->added_since_last_update = 0;
  return 0;
}
Пример #16
0
int znzprintf(znzFile stream, const char *format, ...)
{
  int retval=0;
  char *tmpstr;
  va_list va;
  if (stream==NULL) { return 0; }
  va_start(va, format);
#ifdef HAVE_ZLIB
  if (stream->zfptr!=NULL) {
    int size;  /* local to HAVE_ZLIB block */
    size = strlen(format) + 1000000;  /* overkill I hope */
    tmpstr = (char *)calloc(1, size);
    if( tmpstr == NULL ){
       Rc_fprintf_stderr("** ERROR: znzprintf failed to alloc %d bytes\n", size);
       return retval;
    }
    vsprintf(tmpstr,format,va);
    retval=gzprintf(stream->zfptr,"%s",tmpstr);
    free(tmpstr);
  } else
#endif
  {
   retval=vfprintf(stream->nzfptr,format,va);
  }
  va_end(va);
  return retval;
}
Пример #17
0
int32_t SDDS_GZipWriteVersion(int32_t version_number, gzFile *gzfp)
{
  if (!gzfp)
    return(0);
  gzprintf(gzfp, "SDDS%" PRId32 "\n", version_number);
  return(1);
}
Пример #18
0
hwe::hwe(const char *outfiles,argStruct *arguments,int inputtype){

  doHWE=0;
  
  if(arguments->argc==2){
    if(!strcmp(arguments->argv[1],"-doHWE")){
      printArg(stdout);
      exit(0);
    }else
      return;
  }




  getOptions(arguments);
  printArg(arguments->argumentFile);
  if(doHWE==0)
    return;

  //make output files
  const char* postfix;
  postfix=".hwe.gz";
  if(doHWE>0){
    outfileZ = openFileGz(outfiles,postfix,GZOPT);
    //print header
    gzprintf(outfileZ,"Chromo\tPosition\tMajor\tMinor\tFreq\thweFreq\tF\tLRT\n");
  }
}
Пример #19
0
// fallback - write ppm
int writePng(const char *fileName, unsigned char **rowsp, int w, int h)
{
	gzFile gzf;
	string filentemp(fileName);
	// remove suffix
	if((filentemp.length()>4) && (filentemp[filentemp.length()-4]=='.')) {
		filentemp[filentemp.length()-4] = '\0';
	}
	std::ostringstream filennew;
	filennew << filentemp.c_str();
	filennew << ".ppm.gz";

	gzf = gzopen(filennew.str().c_str(), "wb9");
	if(!gzf) goto fail;

	gzprintf(gzf,"P6\n%d %d\n255\n",w,h);
	// output binary pixels
	for(int j=0;j<h;j++) {
		for(int i=0;i<h;i++) {
			// remove alpha values
			gzwrite(gzf,&rowsp[j][i*4],3);
		}
	}

	gzclose( gzf );
	errMsg("writePng/ppm","Write_png/ppm: wrote to "<<filennew.str()<<".");
	return 0;

fail:	
	errMsg("writePng/ppm","Write_png/ppm: could not write to "<<filennew.str()<<" !");
	return -1;
}
Пример #20
0
int fzp_printf(struct fzp *fzp, const char *format, ...)
{
	static char buf[4096];
	int ret=-1;
	va_list ap;
	va_start(ap, format);
	vsnprintf(buf, sizeof(buf), format, ap);

	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			ret=fprintf(fzp->fp, "%s", buf);
			break;
		case FZP_COMPRESSED:
			ret=gzprintf(fzp->zp, "%s", buf);
			break;
		default:
			unknown_type(fzp->type, __func__);
			break;
	}
	else
		not_open(__func__);
	va_end(ap);
	return ret;
}
Пример #21
0
void Printer::write_pdb(Mol *Cmol, vector<vector<vector<double> > > xyz, double energy, double rmsd, string outname) {
    gzFile outpdb;
    outpdb = gzopen((outname+".pdb.gz").c_str(), "w");
    gzprintf(outpdb, "REMARK\n");
    gzprintf(outpdb, "REMARK %-9s energy = %9.2f rmsd   = %12.3f\n", outname.c_str(), energy, rmsd);
    int atom_count=1;
    for (unsigned i=0; i<Cmol->mymol.size(); i++) {
        for (unsigned j=0; j< Cmol->mymol[i].atomnames.size(); j++) {
            gzprintf(outpdb, "ATOM   %4d %-3s  %3.3s  %4d    % 8.3f % 7.3f % 7.3f  0.00    0.00  1\n", atom_count, Cmol->mymol[i].atomnames[j].c_str(),
                     Cmol->mymol[i].resname.c_str(),  Cmol->mymol[i].resnumber, xyz[i][j][0], xyz[i][j][1], xyz[i][j][2]);
            atom_count++;
        }
    }
    gzprintf(outpdb, "TER\n");
    gzclose(outpdb);
}
Пример #22
0
int anonymization_write_update(gzFile handle)
{
  if (!gzprintf(handle, "%s\n\n", seed_hex_digest)) {
    perror("Error writing update");
    return -1;
  }
  return 0;
}
Пример #23
0
void ini_updateFile(int compress)
{
   gzFile zf = NULL;
   FILE *f = NULL;
   iniElem *aux;
   
   if (ini.comment == NULL) return ;
   
   if (compress) 
     {
	zf = gzopen(get_ini_path(), "wb");
	gzprintf(zf, "%s", ini.comment);
     }
   else
     {
	f = fopen(get_ini_path(), "wb");
	fprintf(f, "%s", ini.comment);
     }
   
   aux = ini.list;
   while (aux != NULL)
     {
	if (compress) 
	  {
	     gzprintf(zf, "[%s]\n", aux->entry.MD5);
	     gzprintf(zf, "Good Name=%s\n", aux->entry.goodname);
	     gzprintf(zf, "Header Code=%s\n", aux->entry.CRC);
	     if (strcmp(aux->entry.refMD5, ""))
	       gzprintf(zf, "Reference=%s\n", aux->entry.refMD5);
	     if (aux->entry.eeprom16kb == 1)
	       gzprintf(zf, "Eeprom=16k\n");
	     if (strcmp(aux->entry.comments, ""))
	       gzprintf(zf, "Comments=%s\n", aux->entry.comments);
	     gzprintf(zf, "\n");
	  }
	else
	  {
	     fprintf(f, "[%s]\n", aux->entry.MD5);
	     fprintf(f, "Good Name=%s\n", aux->entry.goodname);
	     fprintf(f, "Header Code=%s\n", aux->entry.CRC);
	     if (strcmp(aux->entry.refMD5, ""))
	       fprintf(f, "Reference=%s\n", aux->entry.refMD5);
	     if (aux->entry.eeprom16kb == 1)
	       fprintf(f, "Eeprom=16k\n");
	     if (strcmp(aux->entry.comments, ""))
	       fprintf(f, "Comments=%s\n", aux->entry.comments);
	     fprintf(f, "\n");
	  }
	
	aux = aux->next_entry;
     }
   
   if (compress) gzclose(zf);
   else fclose(f);
}
Пример #24
0
void QtWriter::write_pdb(Mol2 *Cmol, vector<vector<double> >xyz, double energy, double rmsd, string outname){
	gzFile outpdb;
	outpdb = gzopen((outname+".pdb.gz").c_str(), "w");
	gzprintf(outpdb, "MDL\n");
	gzprintf(outpdb, "REMARK\n");
	gzprintf(outpdb, "REMARK %-9s energy = %9.2f rmsd   = %12.3f\n", outname.c_str(), energy, rmsd);
	int i=0;
	unsigned resn=0;

	while (resn < Cmol->residue_pointer.size()-1){
		while(i < Cmol->residue_pointer[resn+1]-1){
			gzprintf(outpdb, "%6s%5d %-4s%1s%3.3s%1s%4d%5s%8.3f%8.3f%8.3f%6.2f%6.2f\n", "ATOM  ", i+1, Cmol->atomnames[i].c_str(), " ",Cmol->resnames[resn].c_str()," ",resn+1," ",xyz[i][0], xyz[i][1], xyz[i][2], 1.0, Cmol->charges[i]);
			i++;
		}
		resn++;
	}

	while (i < Cmol->N){
		gzprintf(outpdb, "%6s%5d %-4s%1s%3.3s%1s%4d%5s%8.3f%8.3f%8.3f%6.2f%6.2f\n", "ATOM  ", i+1, Cmol->atomnames[i].c_str(), " ",Cmol->resnames[resn].c_str()," ",resn+1," ",xyz[i][0], xyz[i][1], xyz[i][2], 1.0, Cmol->charges[i]);
		i++;
	}
	gzprintf(outpdb, "TER\n");
	gzprintf(outpdb, "ENDMDL\n");
	gzclose(outpdb);
	QApplication::processEvents();
}
Пример #25
0
inline long replace_dots(long long start,char* seq, char *hdr1, char *hdr2, char *qual,gzFile fd) {
  // FIX .
  long replaced=0;
  if ( fix_dot ) {
    replaced+=replace_dot_by_N(seq);
    gzprintf(fd,"%s%s%s%s",hdr1,seq,hdr2,qual);
  }
  return(replaced);
}
Пример #26
0
void trace_logger_log0(int line_number, char *name, char *bbid, char *instid,
                       int opcode) {
  if (!initp) {
    trace_logger_init();
    initp = 1;
  }
  gzprintf(full_trace_file, "\n0,%d,%s,%s,%s,%d,%d\n", line_number, name, bbid,
           instid, opcode, inst_count);
  inst_count++;
}
Пример #27
0
int csv_compressed_write_vector_grid(char *filename_csv, char *dataset_name, long int ni, long int nj, long int nk,
                          double *v0, double *v1, double *v2) {
  gzFile *fp;
  long int i, j, k;
  char filename[1024];

  const double emf = 0.000001;

  if(filename_csv == NULL || v0 == NULL || v1 == NULL || v2 == NULL) {
    printf("error: passed null arguments to csv_write_scalar_grid\n");
    return 1;
  }

  csv_remove(filename_csv);
  strncpy(filename, filename_csv, strlen(filename_csv) + 1);
  strncat(filename, ".gz", 3);
  fp = gzopen(filename, "w");

  if(fp == NULL) {
    printf("error: csv_compressed_write_vector_grid cannot open %s to write\n", filename);
    return 1;
  }

  gzprintf(fp,"x, y, z, %s\n",dataset_name);

  for(i=0; i<ni; i++) {
    for(j=0; j<nj; j++) {
      for(k=0; k<nk; k++) {
        
        if(fabs(v0[CELL_INDEX(i,j,k)]) > emf || fabs(v1[CELL_INDEX(i,j,k)]) > emf ||  
           fabs(v2[CELL_INDEX(i,j,k)]) > emf )
          gzprintf(fp, "%ld, %ld, %ld, %lf, %lf, %lf\n", i, j, k, 
                v0[CELL_INDEX(i,j,k)], v1[CELL_INDEX(i,j,k)], 
                v2[CELL_INDEX(i,j,k)]); 
     
      }
    }
  }

  gzclose(fp);

  return 0;
}
Пример #28
0
static int write_hook_header(struct manio *manio, gzFile zp, const char *comp)
{
	const char *cp;
	char *tmp=NULL;
	cp=manio->directory+strlen(manio->base_dir);
	while(cp && *cp=='/') cp++;
	if(!(tmp=prepend_s(cp, comp))) return -1;
	gzprintf(zp, "%c%04X%s\n", CMD_MANIFEST, strlen(tmp), tmp);
	free(tmp);
	return 0;
}
Пример #29
0
void
write_gzip_file(string gzip_file_name, unsigned size, vector<int>& output) {
  gzFile gzip_file;
#ifdef DDEBUG
  cerr << gzip_file_name << endl;
#endif
  gzip_file = gzopen(gzip_file_name.c_str(), "w");
  for (unsigned i = 0; i < size; ++i)
    gzprintf(gzip_file, "%d\n", output.at(i));
  gzclose(gzip_file);
}
Пример #30
0
bool csv_tp_writer_write_v1(const stat_throughput_t *tp, gru_status_t *status) {
	char *str = gru_time_write_format(&tp->duration.end, "%Y-%m-%d %H:%M:%S", status);

	if (unlikely(!str)) {
		return false;
	}

	gzprintf(tp_file, "\"%s\",%" PRIu64 ",%.2f\n", str, tp->count, tp->rate);
	gru_dealloc_string(&str);
	return true;
}