예제 #1
0
static void SetupImpLib( void )
/*****************************/
{
    const char  *fname;
    size_t      namelen;

    ImpLib.bufsize = 0;
    ImpLib.handle = NIL_FHANDLE;
    ImpLib.buffer = NULL;
    ImpLib.dllname = NULL;
    ImpLib.didone = false;
    if( FmtData.make_implib ) {
        _ChkAlloc( ImpLib.buffer, IMPLIB_BUFSIZE );
        if( FmtData.make_impfile ) {
            ImpLib.fname = ChkStrDup( FmtData.implibname );
            ImpLib.handle = QOpenRW( ImpLib.fname );
        } else {
            ImpLib.handle = OpenTempFile( &ImpLib.fname );
        }
        /* GetBaseName results in the filename only   *
         * it trims both the path, and the extension */
        fname = GetBaseName( Root->outfile->fname, 0, &namelen );
        ImpLib.dlllen = namelen;
        /*
         * increase length to restore full extension if not OS2
         * sometimes the extension of the output name is important
         */
        ImpLib.dlllen += strlen( fname + namelen );
        _ChkAlloc( ImpLib.dllname, ImpLib.dlllen );
        memcpy( ImpLib.dllname, fname, ImpLib.dlllen );
    }
}
예제 #2
0
PtexMainWriter::PtexMainWriter(const char* path, PtexTexture* tex,
			       Ptex::MeshType mt, Ptex::DataType dt,
			       int nchannels, int alphachan, int nfaces, bool genmipmaps)
    : PtexWriterBase(path, mt, dt, nchannels, alphachan, nfaces,
		     /* compress */ true),
      _hasNewData(false),
      _genmipmaps(genmipmaps),
      _reader(0)
{
    _tmpfp = OpenTempFile(_tmppath);
    if (!_tmpfp) {
	setError(fileError("Error creating temp file: ", _tmppath.c_str()));
	return;
    }

    // data will be written to a ".new" path and then renamed to final location
    _newpath = path; _newpath += ".new";

    _levels.reserve(20);
    _levels.resize(1);

    // init faceinfo and set flags to -1 to mark as uninitialized
    _faceinfo.resize(nfaces);
    for (int i = 0; i < nfaces; i++) _faceinfo[i].flags = uint8_t(-1);

    _levels.front().pos.resize(nfaces);
    _levels.front().fdh.resize(nfaces);
    _rpos.resize(nfaces);
    _constdata.resize(nfaces*_pixelSize);

    if (tex) {
	// access reader implementation
	_reader = dynamic_cast<PtexReader*>(tex);
	if (!_reader) {
	    setError("Internal error: dynamic_cast<PtexReader*> failed");
	    tex->release();
	    return;
	}

	// copy border modes
	setBorderModes(tex->uBorderMode(), tex->vBorderMode());

	// copy meta data from existing file
	PtexPtr<PtexMetaData> meta ( _reader->getMetaData() );
	writeMeta(meta);

	// see if we have any edits
	_hasNewData = _reader->hasEdits();
    }
}
예제 #3
0
virt_mem_size SpillAlloc( virt_mem_size amt )
/*******************************************/
{
    virt_mem_size           stg;

    if( TempFile == NIL_FHANDLE ) {
        TempFile = OpenTempFile( &TFileName );
        LnkMsg( INF+MSG_USING_SPILL, NULL );
    }
    /* round up storage start to a disk sector boundry -- assumed power of 2 */
    TmpFSize = ROUND_UP( TmpFSize, SECTOR_SIZE - 1 );
    stg = TmpFSize;
    TmpFSize += amt;
    return( stg + 1 );  /* add 1 to prevent a NULL handle */
}
예제 #4
0
int DBFFAM::DeleteRecords(PGLOBAL g, int irc)
  {
  if (irc == RC_OK) {
    // T_Stream is the temporary stream or the table file stream itself
    if (!T_Stream)
      if (UseTemp) {
        if (OpenTempFile(g))
          return RC_FX;

        if (CopyHeader(g))           // For DBF tables
          return RC_FX;

      } else
        T_Stream = Stream;

    *Tdbp->GetLine() = '*';
    Modif++;                         // Modified line in Delete mode
    } // endif irc

  return RC_OK;
  } // end of DeleteRecords
예제 #5
0
PtexWriterBase::PtexWriterBase(const char* path,
			       Ptex::MeshType mt, Ptex::DataType dt,
			       int nchannels, int alphachan, int nfaces,
			       bool compress)
    : _ok(true),
      _path(path),
      _tilefp(0)
{
    memset(&_header, 0, sizeof(_header));
    _header.magic = Magic;
    _header.version = PtexFileMajorVersion;
    _header.minorversion = PtexFileMinorVersion;
    _header.meshtype = mt;
    _header.datatype = dt;
    _header.alphachan = alphachan;
    _header.nchannels = nchannels;
    _header.nfaces = nfaces;
    _header.nlevels = 0;
    _header.extheadersize = sizeof(_extheader);
    _pixelSize = _header.pixelSize();

    memset(&_extheader, 0, sizeof(_extheader));

    if (mt == mt_triangle)
	_reduceFn = &PtexUtils::reduceTri;
    else
	_reduceFn = &PtexUtils::reduce;

    memset(&_zstream, 0, sizeof(_zstream));
    deflateInit(&_zstream, compress ? Z_DEFAULT_COMPRESSION : 0);

    // create temp file for writing tiles
    // (must compress each tile before assembling a tiled face)
    std::string error;
    _tilefp = OpenTempFile(_tilepath);
    if (!_tilefp) {
	setError(fileError("Error creating temp file: ", _tilepath.c_str()));
    }
}
예제 #6
0
	void CEmfLogBrushEx::SetDibPattern(unsigned char* pBuffer, unsigned int ulWidth, unsigned int ulHeight)
	{
		DibBuffer = pBuffer;
		DibWidth  = ulWidth;
		DibHeigth = ulHeight;		

		if (ulWidth <= 0 || ulHeight <= 0)
			return;

		unsigned int ulBufferSize = 4 * ulWidth * ulHeight;
		Aggplus::CImage oImage;
		BYTE* pBufferPtr = new BYTE[ulBufferSize];
		oImage.Create(pBufferPtr, ulWidth, ulHeight, 4 * ulWidth);

		// Пишем данные в pBufferPtr
		for (unsigned int ulIndex = 0; ulIndex < ulBufferSize; ulIndex += 4)
		{
			pBufferPtr[0] = (unsigned char)pBuffer[ulIndex + 0];
			pBufferPtr[1] = (unsigned char)pBuffer[ulIndex + 1];
			pBufferPtr[2] = (unsigned char)pBuffer[ulIndex + 2];
			pBufferPtr[3] = (unsigned char)pBuffer[ulIndex + 3];
			pBufferPtr += 4;
		}

		FILE *pTempFile = NULL;
		std::wstring wsTempFileName;
		if (!OpenTempFile(&wsTempFileName, &pTempFile, L"wb", L".emf0", NULL))
			return;

		::fclose(pTempFile);

		oImage.SaveFile(wsTempFileName, _CXIMAGE_FORMAT_PNG);

		BrushStyle     = BS_DIBPATTERN;
		DibPatternPath = wsTempFileName;
	}
예제 #7
0
/* ----------------------------- MNI Header -----------------------------------
@NAME       : 
@INPUT      : 
@OUTPUT     : 
@RETURNS    : 
@DESCRIPTION: 
@METHOD     : 
@GLOBAL     : 
@CALLS      : 
@CREATED    : 
@MODIFIED   : 
---------------------------------------------------------------------------- */
int main (int argc, char *argv [])
{
   ImageInfoRec   ImInfo;
   long        Slice[MAX_WRITEABLE];
   long        Frame[MAX_WRITEABLE];
   long        NumSlices;
   long        NumFrames;
   FILE        *InFile;
   int         Result;
#ifdef DEBUG
   int         i;               /* loop to print out all slices and */
                                /* frames selected */
   ncopts = 0;
#endif

   ncopts = NC_VERBOSE;
   ErrMsg = (char *) malloc (256);

/* strcpy (ErrMsg, "Hello! I am an error message!"); */

   if (argc != NUM_ARGS + 1)        /* +1 because argv[0] counts! */
   {
      ErrAbort ("Incorrect number of arguments", TRUE, ERR_ARGS);
   }

#ifdef DEBUG
   printf ("Passing slice list %s to GetVector\n", SLICE_VECTOR);
   printf ("Passing frame list %s to GetVector\n", FRAME_VECTOR);
#endif

   /*
    * Parse the two lists of numbers first off
    */

   NumSlices = GetVector (SLICE_VECTOR, Slice, MAX_WRITEABLE);
   if (NumSlices < 0)
   {
      GVErrMsg (ErrMsg, "slices", NumSlices);
      ErrAbort (ErrMsg, TRUE, ERR_ARGS);
   }

   NumFrames = GetVector (FRAME_VECTOR, Frame, MAX_WRITEABLE);
   if (NumFrames < 0)
   {
      GVErrMsg (ErrMsg, "frames", NumFrames);
      ErrAbort (ErrMsg, TRUE, ERR_ARGS);
   }

#ifdef DEBUG
   printf ("Slices specified: ");
   for (i = 0; i < NumSlices; i++)
   {
      printf ("%8ld", Slice[i]);
   }
   printf ("\n");
   
   printf ("Frames specified: ");
   for (i = 0; i < NumFrames; i++)
   {
/*      printf ("i = %d, &(Frame) = %p, &(Frame[d]) = %p\n",
	      i, &Frame, &(Frame[i]));  */
      printf ("%8ld", Frame[i]); 
   }
   printf ("\n");
#endif

   if ((NumSlices > 1) && (NumFrames > 1))
   {
      ErrAbort ("Cannot specify both multiple frames and multiple slices", 
                TRUE, ERR_ARGS);
   }

   Result = OpenImage (MINC_FILE, &ImInfo, NC_WRITE, CreateNaN());
   if (Result != ERR_NONE)
   {
      ErrAbort (ErrMsg, TRUE, Result);
   }

   if (!CheckBounds (Slice, Frame, NumSlices, NumFrames, &ImInfo))
   {
      ErrAbort (ErrMsg, TRUE, ERR_ARGS);
   }

   if ((ImInfo.MaxID == MI_ERROR) || (ImInfo.MinID == MI_ERROR))
   {
      sprintf (ErrMsg, "Missing image-max or image-min variable in file %s", 
               MINC_FILE);
      ErrAbort (ErrMsg, TRUE, ERR_IN_MINC);
   }

   InFile = OpenTempFile (TEMP_FILE);
   if (InFile == NULL)
   {
      ErrAbort (ErrMsg, TRUE, ERR_IN_TEMP);
   }

   Result = WriteImages (InFile, &ImInfo, Slice, Frame, NumSlices, NumFrames);
   if (Result != ERR_NONE)
   {
      ErrAbort (ErrMsg, TRUE, Result);
   }

   fclose (InFile);

   miicv_free (ImInfo.ICV);
   ncclose (ImInfo.CDF);
   return (ERR_NONE);

}     /* main */
예제 #8
0
int DOSFAM::DeleteRecords(PGLOBAL g, int irc)
  {
  bool moved;
  int curpos = ftell(Stream);

  /*********************************************************************/
  /*  There is an alternative here:                                    */
  /*  1 - use a temporary file in which are copied all not deleted     */
  /*      lines, at the end the original file will be deleted and      */
  /*      the temporary file renamed to the original file name.        */
  /*  2 - directly move the not deleted lines inside the original      */
  /*      file, and at the end erase all trailing records.             */
  /*  This will be experimented, but method 1 must be used for Unix as */
  /*  the function needed to erase trailing records is not available.  */
  /*********************************************************************/
  if (trace)
    htrc(
  "DOS DeleteDB: rc=%d UseTemp=%d curpos=%d Fpos=%d Tpos=%d Spos=%d\n",
                irc, UseTemp, curpos, Fpos, Tpos, Spos);

  if (irc != RC_OK) {
    /*******************************************************************/
    /*  EOF: position Fpos at the end-of-file position.                */
    /*******************************************************************/
    fseek(Stream, 0, SEEK_END);
    Fpos = ftell(Stream);

    if (trace)
      htrc("Fpos placed at file end=%d\n", Fpos);

    } // endif irc

  if (Tpos == Spos) {
    /*******************************************************************/
    /*  First line to delete, Open temporary file.                     */
    /*******************************************************************/
    if (UseTemp) {
      if (OpenTempFile(g))
        return RC_FX;

    } else {
      /*****************************************************************/
      /*  Move of eventual preceeding lines is not required here.      */
      /*  Set the target file as being the source file itself.         */
      /*  Set the future Tpos, and give Spos a value to block copying. */
      /*****************************************************************/
      T_Stream = Stream;
      Spos = Tpos = Fpos;
    } // endif UseTemp

    } // endif Tpos == Spos

  /*********************************************************************/
  /*  Move any intermediate lines.                                     */
  /*********************************************************************/
  if (MoveIntermediateLines(g, &moved))
    return RC_FX;

  if (irc == RC_OK) {
    /*******************************************************************/
    /*  Reposition the file pointer and set Spos.                      */
    /*******************************************************************/
    if (!UseTemp || moved)
      if (fseek(Stream, curpos, SEEK_SET)) {
        sprintf(g->Message, MSG(FSETPOS_ERROR), 0);
        return RC_FX;
        } // endif

    Spos = GetNextPos();                     // New start position

    if (trace)
      htrc("after: Tpos=%d Spos=%d\n", Tpos, Spos);

  } else {
    /*******************************************************************/
    /*  Last call after EOF has been reached.                          */
    /*  The UseTemp case is treated in CloseTableFile.                 */
    /*******************************************************************/
    if (!UseTemp) {
      /*****************************************************************/
      /*  Because the chsize functionality is only accessible with a   */
      /*  system call we must close the file and reopen it with the    */
      /*  open function (_fopen for MS ??) this is still to be checked */
      /*  for compatibility with Text files and other OS's.            */
      /*****************************************************************/
      char filename[_MAX_PATH];
      int  h;                           // File handle, return code

      PlugSetPath(filename, To_File, Tdbp->GetPath());
      /*rc=*/ PlugCloseFile(g, To_Fb);

      if ((h= global_open(g, MSGID_OPEN_STRERROR, filename, O_WRONLY)) <= 0)
        return RC_FX;

      /*****************************************************************/
      /*  Remove extra records.                                        */
      /*****************************************************************/
#if defined(UNIX)
      if (ftruncate(h, (off_t)Tpos)) {
        sprintf(g->Message, MSG(TRUNCATE_ERROR), strerror(errno));
        close(h);
        return RC_FX;
        } // endif
#else
      if (chsize(h, Tpos)) {
        sprintf(g->Message, MSG(CHSIZE_ERROR), strerror(errno));
        close(h);
        return RC_FX;
        } // endif
#endif

      close(h);

      if (trace)
        htrc("done, h=%d irc=%d\n", h, irc);

      } // endif !UseTemp

  } // endif irc

  return RC_OK;                                      // All is correct
  } // end of DeleteRecords
예제 #9
0
int DOSFAM::ReadBuffer(PGLOBAL g)
  {
  char *p;
  int   rc;

  if (!Stream)
    return RC_EF;

  if (trace > 1)
    htrc("ReadBuffer: Tdbp=%p To_Line=%p Placed=%d\n",
                      Tdbp, Tdbp->To_Line, Placed); 

  if (!Placed) {
    /*******************************************************************/
    /*  Record file position in case of UPDATE or DELETE.              */
    /*******************************************************************/
    if (RecordPos(g))
      return RC_FX;

    CurBlk = (int)Rows++;

     if (trace > 1)
      htrc("ReadBuffer: CurBlk=%d\n", CurBlk); 

  } else
    Placed = false;

  if (trace > 1)
    htrc(" About to read: stream=%p To_Buf=%p Buflen=%d\n",
                          Stream, To_Buf, Buflen);

  if (fgets(To_Buf, Buflen, Stream)) {
    p = To_Buf + strlen(To_Buf) - 1;

    if (trace > 1)
      htrc(" Read: To_Buf=%p p=%c\n", To_Buf, To_Buf, p);

#if defined(UNIX)
    if (true) {
      // Data files can be imported from Windows (having CRLF)
#else
    if (Bin) {
      // Data file is read in binary so CRLF remains
#endif
      if (*p == '\n' || *p == '\r') {
        // is this enough for Unix ???
        *p = '\0';          // Eliminate ending CR or LF character

        if (p > To_Buf) {
          // is this enough for Unix ???
          p--;

          if (*p == '\n' || *p == '\r')
            *p = '\0';      // Eliminate ending CR or LF character

          } // endif To_Buf

        } // endif p

    } else if (*p == '\n')
      *p = '\0';          // Eliminate ending new-line character

    if (trace > 1)
      htrc(" To_Buf='%s'\n", To_Buf);

    strcpy(Tdbp->To_Line, To_Buf);
    num_read++;
    rc = RC_OK;
  } else if (feof(Stream)) {
    rc = RC_EF;
  } else {
#if defined(UNIX)
    sprintf(g->Message, MSG(READ_ERROR), To_File, strerror(0));
#else
    sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL));
#endif

    if (trace)
      htrc("%s\n", g->Message);

    rc = RC_FX;
  } // endif's fgets

  if (trace > 1)
    htrc("ReadBuffer: rc=%d\n", rc);

  IsRead = true;
  return rc;
  } // end of ReadBuffer

/***********************************************************************/
/*  WriteBuffer: File write routine for DOS access method.             */
/***********************************************************************/
int DOSFAM::WriteBuffer(PGLOBAL g)
  {
  char *crlf = "\n";
  int  curpos = 0;
  bool  moved = true;

  // T_Stream is the temporary stream or the table file stream itself
  if (!T_Stream)
    if (UseTemp && Tdbp->Mode == MODE_UPDATE) {
      if (OpenTempFile(g))
        return RC_FX;

    } else
      T_Stream = Stream;

  if (Tdbp->Mode == MODE_UPDATE) {
    /*******************************************************************/
    /*  Here we simply rewrite a record on itself. There are two cases */
    /*  were another method should be used, a/ when Update apply to    */
    /*  the whole file, b/ when updating the last field of a variable  */
    /*  length file. The method could be to rewrite a new file, then   */
    /*  to erase the old one and rename the new updated file.          */
    /*******************************************************************/
    curpos = ftell(Stream);

    if (trace)
      htrc("Last : %d cur: %d\n", Fpos, curpos);

    if (UseTemp) {
      /*****************************************************************/
      /*  We are using a temporary file. Before writing the updated    */
      /*  record, we must eventually copy all the intermediate records */
      /*  that have not been updated.                                  */
      /*****************************************************************/
      if (MoveIntermediateLines(g, &moved))
        return RC_FX;

      Spos = curpos;                          // New start position
    } else
      // Update is directly written back into the file,
      //   with this (fast) method, record size cannot change.
      if (fseek(Stream, Fpos, SEEK_SET)) {
        sprintf(g->Message, MSG(FSETPOS_ERROR), 0);
        return RC_FX;
        } // endif

    } // endif mode

  /*********************************************************************/
  /*  Prepare the write buffer.                                        */
  /*********************************************************************/
#if defined(WIN32)
  if (Bin)
    crlf = "\r\n";
#endif   // WIN32
  strcat(strcpy(To_Buf, Tdbp->To_Line), crlf);

  /*********************************************************************/
  /*  Now start the writing process.                                   */
  /*********************************************************************/
  if ((fputs(To_Buf, T_Stream)) == EOF) {
    sprintf(g->Message, MSG(FPUTS_ERROR), strerror(errno));
    return RC_FX;
    } // endif EOF

  if (Tdbp->Mode == MODE_UPDATE && moved)
    if (fseek(Stream, curpos, SEEK_SET)) {
      sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno));
      return RC_FX;
      } // endif

  if (trace)
    htrc("write done\n");

  return RC_OK;
  } // end of WriteBuffer
예제 #10
0
int BLKFAM::WriteBuffer(PGLOBAL g)
  {
  if (Tdbp->GetMode() == MODE_INSERT) {
    /*******************************************************************/
    /*  In Insert mode, blocks are added sequentially to the file end. */
    /*******************************************************************/
    if (!Closing) {                    // Add line to the write buffer
      strcat(strcpy(CurLine, Tdbp->GetLine()), CrLf);

      if (++CurNum != Rbuf) {
        CurLine += strlen(CurLine);
        return RC_OK;                  // We write only full blocks
        } // endif CurNum

      } // endif Closing

    //  Now start the writing process.
    NxtLine = CurLine + strlen(CurLine);
    BlkLen = NxtLine - To_Buf;

    if (fwrite(To_Buf, 1, BlkLen, Stream) != (size_t)BlkLen) {
      sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno));
      Closing = true;      // To tell CloseDB about a Write error
      return RC_FX;
      } // endif size

    CurBlk++;
    CurNum = 0;
    CurLine = To_Buf;
  } else {
    /*******************************************************************/
    /*  Mode == MODE_UPDATE.                                           */
    /*******************************************************************/
    char  *crlf;
    size_t len;
    int   curpos = ftell(Stream);
    bool   moved = true;

    // T_Stream is the temporary stream or the table file stream itself
    if (!T_Stream)
      if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
        if (OpenTempFile(g))
          return RC_FX;

      } else
        T_Stream = Stream;

    if (UseTemp) {
      /*****************************************************************/
      /*  We are using a temporary file. Before writing the updated    */
      /*  record, we must eventually copy all the intermediate records */
      /*  that have not been updated.                                  */
      /*****************************************************************/
      if (MoveIntermediateLines(g, &moved))
        return RC_FX;

      Spos = GetNextPos();                     // New start position

      // Prepare the output buffer
#if defined(WIN32)
      crlf = "\r\n";
#else
      crlf = "\n";
#endif   // WIN32
      strcat(strcpy(OutBuf, Tdbp->GetLine()), crlf);
      len = strlen(OutBuf);
    } else {
      if (fseek(Stream, Fpos, SEEK_SET)) {   // Fpos is last position
        sprintf(g->Message, MSG(FSETPOS_ERROR), 0);
        return RC_FX;
        } // endif fseek

      // Replace the line inside read buffer (length has not changed)
      memcpy(CurLine, Tdbp->GetLine(), strlen(Tdbp->GetLine()));
      OutBuf = CurLine;
      len = (size_t)(NxtLine - CurLine);
    } // endif UseTemp

    if (fwrite(OutBuf, 1, len, T_Stream) != (size_t)len) {
      sprintf(g->Message, MSG(FWRITE_ERROR), strerror(errno));
      return RC_FX;
      } // endif fwrite

    if (moved)
      if (fseek(Stream, curpos, SEEK_SET)) {
        sprintf(g->Message, MSG(FSEEK_ERROR), strerror(errno));
        return RC_FX;
        } // endif

  } // endif Mode

  return RC_OK;
  } // end of WriteBuffer
예제 #11
0
static int OpenMaxFiles(int argc,char *argv[])
{
    int a=0;
    while(argc) {
	fp_list_in=(FILE **)Realloc(fp_list_in,(a+1)*sizeof(FILE *));
	errno = 0;
	fp_list_in[a]=fopen(argv[a], FOPEN_READ);
	if(fp_list_in[a]==NULL) {
	    switch(errno) {
		case 0:
		    /* Solaris may not set errno if libc cannot create a stdio
		       stream because the underlying fd is greater than 255 */
		case ENFILE:
		case EMFILE:
/*more infiles than can be opened->close one and create a tempfile for output*/
		    if(argc>0) {
			Free(EventList[--a]->str_to_add);
			Free(EventList[  a]);
			fclose(fp_list_in[a]);
			temp_file_list = (char**)Realloc(temp_file_list,
			  (num_tempfiles + 1) * sizeof(*temp_file_list));
			fpout = OpenTempFile(temp_file_list + num_tempfiles);
			num_tempfiles++;
			fpout_is_closeable=1;
		    }
		    num_infiles=a;
		    return a;
		default:
		    fprintf(stderr,"%s: error opening input file %s: %s\n",
			progname, argv[a], strerror(errno));
		    exit(EXIT_FAILURE);
	    }
	} else {
	    EventList=(LogEvent **)Realloc(EventList,
		(a+1)*sizeof(LogEvent *));
	    EventList[a]=(LogEvent *)Malloc(sizeof(LogEvent));
	    if (infiles_processed) EventList[a]->str_to_add = NULL;
	    else {
		/* cutting the component identifier portion out from the
		 * file name */
		EventList[a]->str_to_add =
		    GetComponentIdentifier(name_list_in[a + start_file]);
	    }
	    EventList[a]->ignore=True;
	    EventList[a]->data=NULL;
	    EventList[a]->wrap=0;
	    EventList[a]->sec=0;
	    EventList[a]->usec=0L;
	    EventList[a]->line_ctr=1L;
	    EventList[a]->start_line=1L;
	    ++a;
	}
	argc--;
    }
    if (must_use_temp) {
	temp_file_list = (char**)Realloc(temp_file_list,
	    (num_tempfiles + 1) * sizeof(*temp_file_list));
	fpout = OpenTempFile(temp_file_list + num_tempfiles);
	num_tempfiles++;
	fpout_is_closeable = 1;
    } else {
	fpout = outfile;
	if (outfile!=stdout) fpout_is_closeable = 1;
	else fpout_is_closeable = 0;
    }
    num_infiles=a;
    return a;/*nr. of opened files*/
}