evio  5.2
 All Data Structures Files Functions Variables Typedefs Macros Groups
open & close routines

These routines handle opening & closing the ev lib for reading or writing to a file, buffer, or socket. More...

Functions

int evOpen (char *filename, char *flags, int *handle)
 This function opens a file for either reading or writing evio format data. More...
 
int evOpenBuffer (char *buffer, uint32_t bufLen, char *flags, int *handle)
 This function allows for either reading or writing evio format data from a buffer. More...
 
int evOpenSocket (int sockFd, char *flags, int *handle)
 This function allows for either reading or writing evio format data from a TCP socket. More...
 
int evClose (int handle)
 This routine flushes any existing evio format data in an internal buffer (written to with evWrite) to the final destination file/socket/buffer opened with routines evOpen, evOpenBuffer, or evOpenSocket. More...
 

Detailed Description

These routines handle opening & closing the ev lib for reading or writing to a file, buffer, or socket.

Function Documentation

int evClose ( int  handle)

This routine flushes any existing evio format data in an internal buffer (written to with evWrite) to the final destination file/socket/buffer opened with routines evOpen, evOpenBuffer, or evOpenSocket.

It also frees up the handle so it cannot be used any more without calling evOpen again. Any data written is in evio version 4 format and any opened file is closed. If reading, nothing is done.

Parameters
handleevio handle
Returns
S_SUCCESS if successful
S_FAILURE if mapped memory does not unmap or write/close failed
S_EVFILE_TRUNC if not enough room writing to a user-given buffer in evOpen
S_EVFILE_BADHANDLE if bad handle arg or this function already called.
fclose error if fclose error

References evfilestruct::baseFileName, evfilestruct::blknum, evfilestruct::buf, evfilestruct::bufSize, evfilestruct::bytesToBuf, evfilestruct::dictBuf, evfilestruct::dictionary, EV_READFILE, EV_READPIPE, EV_WRITEBUF, EV_WRITEFILE, EV_WRITEPIPE, EV_WRITESOCK, evfilestruct::eventsToBuf, evfilestruct::file, evfilestruct::fileName, evfilestruct::lockingOn, evfilestruct::mmapFile, evfilestruct::mmapFileSize, evfilestruct::pBuf, evfilestruct::pTable, evfilestruct::randomAccess, evfilestruct::runType, evfilestruct::rw, S_EVFILE_BADHANDLE, S_FAILURE, and S_SUCCESS.

Referenced by evclose_().

int evOpen ( char *  filename,
char *  flags,
int *  handle 
)

This function opens a file for either reading or writing evio format data.

Works with all versions of evio for reading, but only writes version 4 format. A handle is returned for use with calling other evio routines.

Parameters
filenamename of file. Constructs of the form will be substituted with the given environmental variable or removed if nonexistent. Constructs of the form s will be substituted with the run type if specified in evIoctl or removed if nonexistent. Up to 2, C-style int format specifiers are allowed. The first is replaced with the run number (set in evIoctl). If splitting, the second is replaced by the split number, otherwise it's removed. If splitting and no second int specifier exists, a "." and split number are automatically appended to the end of the file name.
flagspointer to case-independent string of "w" for writing, "r" for reading, "a" for appending, "ra" for random access reading of a file which means memory mapping it, or "s" for splitting a file while writing. The w, r, a, s, or ra, may be followed by an x which means do not do any mutex locking (not thread safe).
handlepointer to int which gets filled with handle
Returns
S_SUCCESS if successful
S_FAILURE when splitting, if bad format specifiers or more that 2 specifiers found
S_EVFILE_BADARG if filename, flags or handle arg is NULL; unrecognizable flags;
S_EVFILE_ALLOCFAIL if memory allocation failed
S_EVFILE_BADFILE if error reading file, unsupported version, or contradictory data in file
errno if file could not be opened (handle = 0)

References S_EVFILE_BADARG.

Referenced by evopen_().

int evOpenBuffer ( char *  buffer,
uint32_t  bufLen,
char *  flags,
int *  handle 
)

This function allows for either reading or writing evio format data from a buffer.

Works with all versions of evio for reading, but only writes version 4 format. A handle is returned for use with calling other evio routines.

Parameters
bufferpointer to buffer
bufLenlength of buffer in 32 bit ints
flagspointer to case-independent string of "w", "r", "a", or "ra" for writing/reading/appending/random-access-reading to/from a buffer. The w, r, a, or ra, may be followed by an x which means do not do any mutex locking (not thread safe).
handlepointer to int which gets filled with handle
Returns
S_SUCCESS if successful
S_EVFILE_BADARG if buffer, flags or handle arg is NULL; unrecognizable flags; buffer size too small
S_EVFILE_ALLOCFAIL if memory allocation failed
S_EVFILE_BADFILE if error reading buffer, unsupported version, or contradictory data

References S_EVFILE_BADARG.

int evOpenSocket ( int  sockFd,
char *  flags,
int *  handle 
)

This function allows for either reading or writing evio format data from a TCP socket.

Works with all versions of evio for reading, but only writes version 4 format. A handle is returned for use with calling other evio routines.

Parameters
sockFdTCP socket file descriptor
flagspointer to case-independent string of "w" & "r" for writing/reading to/from a socket The w or r, may be followed by an x which means do not do any mutex locking (not thread safe).
handlepointer to int which gets filled with handle
Returns
S_SUCCESS if successful
S_EVFILE_BADARG if flags or handle arg is NULL; bad file descriptor arg; unrecognizable flags
S_EVFILE_ALLOCFAIL if memory allocation failed
S_EVFILE_BADFILE if error reading socket, unsupported version, or contradictory data
errno if socket read error

References S_EVFILE_BADARG.