H bnddir('QC2LE') D getRecord PR 10I 0 D file like(fopen) D record 65535A VARYING D OPTIONS(*VARSIZE) D maxSize 10I 0 VALUE D recordStart... D 10A VARYING D CONST D recordEnd... D 10A VARYING D CONST D fopen... D PR * extproc('_C_IFS_fopen') D fname... D * value D options(*string) D openMode... D * options(*string) D value D fclose... D PR 10I 0 extproc('_C_IFS_fclose') D fileHandle... D * value D ferror PR 10I 0 extproc('_C_IFS_ferror') D fh * value D D strerror PR * extproc('strerror') D errno 10I 0 value D D get_errno PR * ExtProc('__errno') /copy QCOPYSRC,UTTIFS D fh... D S like(fopen) D reclen... D S like(getRecord) D record... D S 500A varying D start... D S z D end... D S z D runtime... D S 11A dtaara('RUNTIME') D errno... D S 10I 0 based(pErrno) /free start = %timestamp(); fh = fopen('/home/adamg/readtest/onebig' + x'00' : 'r'); if (fh = *NULL); pErrno = get_errno(); return; endif; recLen = getRecord(fh : record : %size(record) -2 : '<B>' : '<E>'); dow (reclen > 0); recLen = getRecord(fh : record : %size(record) -2 : '<B>' : '<E>'); enddo; callp fclose(fh); end = %timestamp(); in *lock runTime; runTime = %char(%diff(end : start : *ms)); out runTime; *inlr = *on; return; /end-free P*-------------------------------------------------- P* Procedure name: getRecord P* Purpose: Retrieve one event or alarm record from the file P* Returns: The number of bytes in the record, -1 if an error o... P* ccurred P* Parameter: file => The file from which to read P* Parameter: record => The variable which will receive the record P* Parameter: maxSize => The maximum number of bytes that the rec... P* ord variable can hold P*-------------------------------------------------- P getRecord B D getRecord PI 10I 0 D fileHandle like(fopen) D record 65535A VARYING D OPTIONS(*VARSIZE) D maxSize 10I 0 VALUE D recordStart... D 10A VARYING D CONST D recordEnd... D 10A VARYING D CONST D fread... D PR 10U 0 extproc('_C_IFS_fread') D readBuff... D * value D buffSize... D 10U 0 value D readSize... D 10U 0 value D fileHandle... D * value D* Local fields D miniBuff... D DS D mbChar... D 1A dim(10) D D recordStarted... D S N D recordEnded... D S N D bytesRead S 10U 0 D totalRead... D S 10U 0 D miniBuffLen... D S 3U 0 D errno... D S like(ferror) D pErrString... D S * D errString... D S 15A /free %len(record) = 0; if (%len(recordStart) > %len(recordEnd)); miniBuffLen = %len(recordStart); else; miniBuffLen = %len(recordEnd); endif; bytesRead = fread(%addr(miniBuff) : 1 : miniBuffLen : fileHandle); if (bytesRead = 0); errno = ferror(fileHandle); pErrString = strerror(errno); endif; doW (bytesRead > 0 AND NOT recordEnded AND totalRead < maxSize); if (NOT recordStarted); recordStarted = (%subst(miniBuff : 1 : %len(recordStart)) = recordStart); if (recordStarted); if (miniBuffLen = %len(recordStart)); %subst(miniBuff : 1 : %len(recordStart)) = *blanks; bytesRead = fread(%addr(miniBuff) : 1 : miniBuffLen : fileHandle); else; miniBuff = %subst(miniBuff : %len(recordStart) + 1); bytesRead = fread( %addr(mbChar(%len(recordStart) + 1)) : 1 : miniBuffLen - %len(recordStart) : fileHandle ); endif; endif; endif; if (recordStarted AND NOT recordEnded); record += mbChar(1); totalRead += 1; endif; miniBuff = %subst(miniBuff : 2); bytesRead = fread(%addr(mbChar(miniBuffLen)) : 1 : 1 : fileHandle); recordEnded = (%subst(miniBuff : 1 : %len(recordEnd)) = recordEnd); enddo; return totalRead; /end-free P getRecord E