[PATCH 1/2] Common: Added new fileparser module


Frank Quinn <fquinn@...>
 

The new internal fileparser module allows the caller to open a file in

either mmap or file stream mode. The module will then allow the caller to

read through the file and copy the output to a provided buffer. This is to

modularise some functionality which was previously contained within

playbackFileParser.c

 

Also added this module to the build scripts for Windows (no modifications

were required for linux).

 

Signed-off-by: Frank Quinn <fquinn@...>

---

common/c_cpp/src/c/SConscript.win      |   1 +

common/c_cpp/src/c/commonc.vcproj      |   4 +

common/c_cpp/src/c/fileparser.c        | 429 +++++++++++++++++++++++++++++++++

common/c_cpp/src/c/wombat/fileparser.h | 223 +++++++++++++++++

4 files changed, 657 insertions(+)

create mode 100644 common/c_cpp/src/c/fileparser.c

create mode 100644 common/c_cpp/src/c/wombat/fileparser.h

 

diff --git a/common/c_cpp/src/c/SConscript.win b/common/c_cpp/src/c/SConscript.win

index dc920de..2ee1a19 100644

--- a/common/c_cpp/src/c/SConscript.win

+++ b/common/c_cpp/src/c/SConscript.win

@@ -18,6 +18,7 @@ windows/wUuid.c

property.c

wMessageStats.c

libyywrap.c

+fileparser.c

windows/strpcasecmp.c

windows/strptime.c

windows/platform.c

diff --git a/common/c_cpp/src/c/commonc.vcproj b/common/c_cpp/src/c/commonc.vcproj

index 1c45014..9032c09 100644

--- a/common/c_cpp/src/c/commonc.vcproj

+++ b/common/c_cpp/src/c/commonc.vcproj

@@ -413,6 +413,10 @@

                                                               >

                                               </File>

                                               <File

+                                                             RelativePath=".\fileparser.c"

+                                                             >

+                                             </File>

+                                             <File

                                                               RelativePath=".\windows\network.c"

                                                               >

                                               </File>

diff --git a/common/c_cpp/src/c/fileparser.c b/common/c_cpp/src/c/fileparser.c

new file mode 100644

index 0000000..978d133

--- /dev/null

+++ b/common/c_cpp/src/c/fileparser.c

@@ -0,0 +1,429 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+/*************************************************************************

+ * Includes

+**************************************************************************/

+

+#include <wombat/fileparser.h>

+#include <wombat/port.h>

+

+#include <fcntl.h>

+#include <sys/stat.h>

+#include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

+#include <errno.h>

+

+/*************************************************************************

+ * Typedefs, structs, enums and globals

+**************************************************************************/

+

+/* Internal implementation */

+typedef struct

+{

+    int                 mMmapOpenFlags;         /* Used for mmap */

+    int                 mMmapOpenMode;          /* Used for mmap */

+    int                 mMmapProtect;           /* Used for mmap */

+    int                 mMmapFlags;             /* Used for mmap */

+    int                 mFileDescriptor;        /* Used for mmap */

+    uint8_t*            mFileRootPosition;      /* Used for mmap */

+    uint8_t*            mFileCurrentPosition;   /* Used for mmap */

+    FILE*               mFileHandle;            /* Used for file streams */

+    const char*         mFileMode;              /* Used for file streams */

+    uint64_t            mFileSize;

+    uint64_t            mFileCurrentOffset;

+    const char*         mFileName;

+    fileParserType      mType;

+} fileParserImpl;

+

+

+/*************************************************************************

+ * Public implementation functions

+**************************************************************************/

+

+fileParserStatus

+fileParser_allocate (fileParser* parser)

+{

+    fileParserImpl* newReader = NULL;

+

+    if (NULL == parser)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+

+    newReader = (fileParserImpl*) calloc (1, sizeof(fileParserImpl));

+    if (NULL == newReader)

+    {

+        return FILE_PARSER_STATUS_NOMEM;

+    }

+    newReader->mMmapOpenFlags = O_RDONLY;

+    newReader->mMmapProtect = PROT_READ;

+    newReader->mMmapFlags = MAP_SHARED;

+    newReader->mType = FILE_PARSER_TYPE_UNKNOWN;

+    newReader->mFileMode = strdup ("rb");

+    if (NULL == newReader->mFileMode)

+    {

+        free (newReader);

+        return FILE_PARSER_STATUS_NOMEM;

+    }

+    *parser = (fileParser) newReader;

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_create (fileParser parser, fileParserType type, const char* fileName)

+{

+    struct stat     fileInfo;

+    int             result  = 0;

+    fileParserImpl* impl    = (fileParserImpl*) parser;

+

+    if (NULL == impl || NULL == fileName)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == strlen(fileName))

+    {

+        return FILE_PARSER_STATUS_INVALID_ARG;

+    }

+

+    result = stat(fileName, &fileInfo);

+    /* If we failed to access the file */

+    if (result)

+    {

+        return FILE_PARSER_STATUS_NO_FILE;

+    }

+

+    impl->mFileSize = fileInfo.st_size;

+    impl->mFileName = strdup (fileName);

+    if (NULL == impl->mFileName)

+    {

+        /* Clean up what we can */

+        fileParser_destroy (parser);

+        return FILE_PARSER_STATUS_NOMEM;

+    }

+

+    impl->mType = type;

+

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /* Open up the file */

+        impl->mFileDescriptor = open (fileName, impl->mMmapOpenFlags);

+        if (impl->mFileDescriptor < 0)

+        {

+            return FILE_PARSER_STATUS_NO_HANDLE;

+        }

+

+        /* Map the file to memory */

+        impl->mFileRootPosition =

+            (uint8_t*) mmap (NULL,

+                             (size_t) impl->mFileSize,

+                             impl->mMmapProtect,

+                             impl->mMmapFlags,

+                             impl->mFileDescriptor,

+                             0); /* 0 = Map from the first byte */

+        if (MAP_FAILED == impl->mFileRootPosition)

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+

+        /* Mark current position as the start */

+        impl->mFileCurrentPosition = impl->mFileRootPosition;

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+        /* Open the file handle */

+        impl->mFileHandle = fopen (fileName, impl->mFileMode);

+        if (NULL == impl->mFileHandle)

+        {

+            return FILE_PARSER_STATUS_NO_HANDLE;

+        }

+        break;

+    default:

+        return FILE_PARSER_STATUS_INVALID_ARG;

+        break;

+    }

+    return FILE_PARSER_STATUS_OK;

+}

+

+uint64_t

+fileParser_getFileSize (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+    if (NULL == impl)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    return impl->mFileSize;

+}

+

+fileParserStatus

+fileParser_readFileToBuffer (fileParser parser,

+                            void* destBuffer,

+                            uint64_t destBufferSize,

+                            uint64_t* bytesWritten)

+{

+    fileParserImpl* impl        = (fileParserImpl*) parser;

+    char*           destAsBytes = (char*) destBuffer;

+    int             i           = 0;

+    uint64_t        bytesToCopy = destBufferSize;

+

+    if (NULL == parser || NULL == destBuffer || NULL == bytesWritten)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == destBufferSize)

+    {

+        return FILE_PARSER_STATUS_INVALID_ARG;

+    }

+

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /* If there are fewer bytes in the file than requested, copy only the

+         * bytes remaining in the file to avoid overrun. */

+        if (impl->mFileSize < (impl->mFileCurrentOffset + bytesToCopy))

+        {

+            bytesToCopy = impl->mFileSize - impl->mFileCurrentOffset;

+        }

+

+        memcpy (destBuffer, impl->mFileCurrentPosition, (size_t) bytesToCopy);

+        impl->mFileCurrentPosition += bytesToCopy;

+        impl->mFileCurrentOffset += bytesToCopy;

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+    {

+        /* Returns the number of bytes read / written */

+        *bytesWritten = fread (destBuffer, 1, (size_t) bytesToCopy, impl->mFileHandle);

+

+        /* Find out where the file handle position is now */

+        impl->mFileCurrentOffset = ftell (impl->mFileHandle);

+        break;

+    }

+    default:

+        /* This would indicate an unknown or unpopulated parser type */

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_readFileToBufferUntilCharacter (fileParser parser,

+                            void* destBuffer,

+                            uint64_t destBufferSize,

+                            char delim,

+                            uint64_t* bytesWritten)

+{

+    fileParserImpl* impl        = (fileParserImpl*) parser;

+    char*           destAsBytes = (char*) destBuffer;

+    int             i           = 0;

+

+    if (NULL == parser || NULL == destBuffer || NULL == bytesWritten)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == destBufferSize)

+    {

+        return FILE_PARSER_STATUS_INVALID_ARG;

+    }

+

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /*  While we have bytes remaining in destination and we have not yet

+         * reached the delimiter */

+        do

+        {

+            destAsBytes[i] = (char) *(impl->mFileCurrentPosition);

+            impl->mFileCurrentOffset++;

+            impl->mFileCurrentPosition++;

+        } while (i < destBufferSize

+            && impl->mFileCurrentOffset < impl->mFileSize

+            && destAsBytes[i++] != delim);

+

+        /* Update the bytes written for the calling function */

+        *bytesWritten = i - 1;

+

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+    {

+        /*  While we have bytes remaining in destination and we have not yet

+         * reached the delimiter */

+        do

+        {

+            destAsBytes[i] = fgetc (impl->mFileHandle);

+        } while (i < destBufferSize && destAsBytes[i++] != delim);

+

+        /* Find out where the file handle position is now */

+        impl->mFileCurrentOffset = (uint64_t) ftell (impl->mFileHandle);

+

+        /* The position we are in now relative to the original offset */

+        *bytesWritten = i - 1;

+

+        break;

+    }

+    default:

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_rewindFile (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+    if (NULL == parser)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (FILE_PARSER_TYPE_UNKNOWN == impl->mType)

+    {

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /* For mmap, we just point back to the first byte again */

+        impl->mFileCurrentPosition = impl->mFileRootPosition;

+        impl->mFileCurrentOffset   = 0;

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+        /* For file streams, set file pointer to start of file */

+        if (0 != fseek (impl->mFileHandle, 0, SEEK_SET))

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+        impl->mFileCurrentOffset = 0;

+        break;

+    default:

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+int

+fileParser_isEndOfFile (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+

+    if (impl->mFileCurrentOffset >= impl->mFileSize)

+    {

+        return 1;

+    }

+    else

+    {

+        return 0;

+    }

+}

+

+const char*

+fileParser_stringForStatus (fileParserStatus status)

+{

+    switch (status)

+    {

+    case FILE_PARSER_STATUS_OK : return "FILE_PARSER_STATUS_OK";

+    case FILE_PARSER_STATUS_NOMEM : return "FILE_PARSER_STATUS_NOMEM";

+    case FILE_PARSER_STATUS_ERRNO : return "FILE_PARSER_STATUS_ERRNO";

+    case FILE_PARSER_STATUS_NULL_ARG : return "FILE_PARSER_STATUS_NULL_ARG";

+    case FILE_PARSER_STATUS_INVALID_ARG : return "FILE_PARSER_STATUS_INVALID_ARG";

+    case FILE_PARSER_STATUS_INVALID_STATE : return "FILE_PARSER_STATUS_INVALID_STATE";

+    case FILE_PARSER_STATUS_NO_HANDLE : return "FILE_PARSER_STATUS_NO_HANDLE";

+    case FILE_PARSER_STATUS_NO_FILE : return "FILE_PARSER_STATUS_NO_FILE";

+    case FILE_PARSER_STATUS_EOF : return "FILE_PARSER_STATUS_EOF";

+    case FILE_PARSER_STATUS_FAILURE : return "FILE_PARSER_STATUS_FAILURE";

+    default : return "unknown";

+    }

+}

+

+fileParserStatus

+fileParser_closeFile (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+    if (NULL == parser)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == (int) impl->mType)

+    {

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    /* If the file handle is set, close it */

+    if (NULL != impl->mFileHandle)

+    {

+        if (0 != fclose (impl->mFileHandle))

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+        impl->mFileHandle = NULL;

+    }

+

+    /* If the file descriptor is set, close it */

+    if (0 != impl->mFileDescriptor)

+    {

+        if (0 != munmap (impl->mFileRootPosition, (size_t) impl->mFileSize))

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+        impl->mFileDescriptor = 0;

+    }

+

+    /* Reset type to unknown as this is in an unusable state until create is

+     * called again */

+    impl->mType = FILE_PARSER_TYPE_UNKNOWN;

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_destroy (fileParser parser)

+{

+    fileParserImpl*     impl    = (fileParserImpl*) parser;

+    fileParserStatus    status  = FILE_PARSER_STATUS_OK;

+

+    if (NULL == impl)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+

+    /* File mode was strdup'd - free it before impl is free'd */

+    if (NULL != impl->mFileMode)

+    {

+        free ((void*) impl->mFileMode);

+    }

+

+    /* File name was strdup'd - free it before impl is free'd */

+    if (NULL != impl->mFileName)

+    {

+        free ((void*) impl->mFileName);

+    }

+

+    /* Close the file. If already closed, this should still be safe */

+    status = fileParser_closeFile (parser);

+

+    free (impl);

+

+    return status;

+}

+

diff --git a/common/c_cpp/src/c/wombat/fileparser.h b/common/c_cpp/src/c/wombat/fileparser.h

new file mode 100644

index 0000000..6e9a70f

--- /dev/null

+++ b/common/c_cpp/src/c/wombat/fileparser.h

@@ -0,0 +1,223 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef WOMBAT_FILEREADER_H__

+#define WOMBAT_FILEREADER_H__

+

+

+/*************************************************************************

+ * Includes

+**************************************************************************/

+

+#include <wombat/port.h>

+

+#if defined (__cplusplus)

+extern "C"

+{

+#endif

+

+

+/*************************************************************************

+ * Typedefs, structs, enums and globals

+**************************************************************************/

+

+/* fileParser is opaque */

+typedef void* fileParser;

+

+/* Possible return codes */

+typedef enum

+{

+    FILE_PARSER_STATUS_OK,

+    FILE_PARSER_STATUS_NOMEM,

+    FILE_PARSER_STATUS_ERRNO, /* Underlying failure has set errno */

+    FILE_PARSER_STATUS_NULL_ARG,

+    FILE_PARSER_STATUS_INVALID_ARG,

+    FILE_PARSER_STATUS_INVALID_STATE,

+    FILE_PARSER_STATUS_NO_HANDLE,

+    FILE_PARSER_STATUS_NO_FILE,

+    FILE_PARSER_STATUS_EOF,

+    FILE_PARSER_STATUS_FAILURE

+} fileParserStatus;

+

+/* Which type of file parser to use */

+typedef enum

+{

+    FILE_PARSER_TYPE_UNKNOWN,

+    FILE_PARSER_TYPE_MMAP, /* Start at 1 so 0 is invalid value */

+    FILE_PARSER_TYPE_FILE_STREAM

+} fileParserType;

+

+

+/*************************************************************************

+ * Public implementation functions

+**************************************************************************/

+

+/**

+ * Allocate a fileParser. A file may then be opened with it at a later point

+ * using a fileParser_create call.

+ *

+ * @param parser This pointer will be populated with the address of the newly

+ *               created fileParser implementation on function success.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_allocate (fileParser* parser);

+

+/**

+ * Creates a fileParser and associates it with a file and a parser type. This

+ * call will also open the file and perform any additional initialization

+ * required for the specified parser type.

+ *

+ * @param parser   The fileParser to perform this operation on.

+ * @param type     The type of fileParser to initialize (FILE_PARSER_TYPE_MMAP

+ *                 / FILE_PARSER_TYPE_FILE_STREAM.

+ * @param fileName The file to create a fileParser for and associate it with.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_create (fileParser parser, fileParserType type, const char* fileName);

+

+/**

+ * This will return the size of the opened file. Note this must be called

+ * after fileParser_create.

+ *

+ * @param parser   The fileParser to perform this operation on.

+ *

+ * @return uint64_t representing the size of the file being parser.

+ */

+COMMONExpDLL uint64_t

+fileParser_getFileSize (fileParser parser);

+

+/**

+ * Read from the current position of the fileParser provided up to a maximum

+ * of destBufferSize bytes. The bytesWritten value will then be populated by

+ * the function to reflect the number of bytes which have been copied to

+ * destBuffer.

+ *

+ * Calling this function will move the internal parser position of the provided

+ * fileParser object by bytesWritten bytes.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ * @param destBuffer     The the destination to copy the file contents to.

+ * @param destBufferSize The writable size of destBuffer.

+ * @param bytesWritten   Pointer to a value which will be populated with the

+ *                       number of bytes copied across on completion.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_readFileToBuffer (fileParser parser,

+                             void* destBuffer,

+                             uint64_t destBufferSize,

+                             uint64_t* bytesWritten);

+

+/**

+ * Read from the current position of the fileParser provided up to a maximum

+ * of destBufferSize bytes, up to and including the first detected instance of

+ * the delim character. The bytesWritten value will then be populated by

+ * the function to reflect the number of bytes which have been copied to

+ * destBuffer.

+ *

+ * Calling this function will move the internal parser position of the provided

+ * fileParser object by bytesWritten bytes.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ * @param destBuffer     The the destination to copy the file contents to.

+ * @param destBufferSize The writable size of destBuffer.

+ * @param delim          The character which, when encountered, will cause

+ *                       copying to stop (destination buffer will then include

+ *                       this delimiter).

+ * @param bytesWritten   Pointer to a value which will be populated with the

+ *                       number of bytes copied across on completion.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_readFileToBufferUntilCharacter (

+                             fileParser parser,

+                             void* destBuffer,

+                             uint64_t destBufferSize,

+                             char delim,

+                             uint64_t* bytesWritten);

+

+/**

+ * Calling this function will move the internal parser position of the provided

+ * fileParser object to the beginning of its file.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_rewindFile (fileParser parser);

+

+/**

+ * This function will return '1' if the file being parsed is at EOF. Otherwise

+ * this will return '0'.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return int (acting as a boolean) indicating whether the method succeeded or

+ *         failed.

+ */

+COMMONExpDLL int

+fileParser_isEndOfFile (fileParser parser);

+

+/**

+ * This will return a string representation of the provided fileParser status

+ * code.

+ *

+ * @param status         The status to perform this operation on.

+ *

+ * @return const char* referencing a string representation of the status.

+ */

+COMMONExpDLL const char*

+fileParser_stringForStatus (fileParserStatus status);

+

+/**

+ * This will close the file being parsed by the file parser and perform any

+ * additional cleanup required which is associated with the fileParser's type.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_closeFile (fileParser parser);

+

+/**

+ * Destroy the fileParser implementation and close any open files associated

+ * with it.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_destroy (fileParser parser);

+

+#if defined (__cplusplus)

+}

+#endif

+

+#endif /* WOMBAT_FILEREADER_H__ */

\ No newline at end of file

--

1.8.4.msysgit.0

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


Damian Maguire <DMaguire@...>
 

Bugzilla raised for tracking. Ticket Number: http://bugs.openmama.org/show_bug.cgi?id=79

Cheers, 

D

From: Frank Quinn <fquinn@...>
Date: Wednesday, March 12, 2014 1:47 PM
To: "openmama-dev@..." <openmama-dev@...>
Subject: [Openmama-dev] [PATCH 1/2] Common: Added new fileparser module

The new internal fileparser module allows the caller to open a file in

either mmap or file stream mode. The module will then allow the caller to

read through the file and copy the output to a provided buffer. This is to

modularise some functionality which was previously contained within

playbackFileParser.c

 

Also added this module to the build scripts for Windows (no modifications

were required for linux).

 

Signed-off-by: Frank Quinn <fquinn@...>

---

common/c_cpp/src/c/SConscript.win      |   1 +

common/c_cpp/src/c/commonc.vcproj      |   4 +

common/c_cpp/src/c/fileparser.c        | 429 +++++++++++++++++++++++++++++++++

common/c_cpp/src/c/wombat/fileparser.h | 223 +++++++++++++++++

4 files changed, 657 insertions(+)

create mode 100644 common/c_cpp/src/c/fileparser.c

create mode 100644 common/c_cpp/src/c/wombat/fileparser.h

 

diff --git a/common/c_cpp/src/c/SConscript.win b/common/c_cpp/src/c/SConscript.win

index dc920de..2ee1a19 100644

--- a/common/c_cpp/src/c/SConscript.win

+++ b/common/c_cpp/src/c/SConscript.win

@@ -18,6 +18,7 @@ windows/wUuid.c

property.c

wMessageStats.c

libyywrap.c

+fileparser.c

windows/strpcasecmp.c

windows/strptime.c

windows/platform.c

diff --git a/common/c_cpp/src/c/commonc.vcproj b/common/c_cpp/src/c/commonc.vcproj

index 1c45014..9032c09 100644

--- a/common/c_cpp/src/c/commonc.vcproj

+++ b/common/c_cpp/src/c/commonc.vcproj

@@ -413,6 +413,10 @@

                                                               >

                                               </File>

                                               <File

+                                                             RelativePath=".\fileparser.c"

+                                                             >

+                                             </File>

+                                             <File

                                                               RelativePath=".\windows\network.c"

                                                               >

                                               </File>

diff --git a/common/c_cpp/src/c/fileparser.c b/common/c_cpp/src/c/fileparser.c

new file mode 100644

index 0000000..978d133

--- /dev/null

+++ b/common/c_cpp/src/c/fileparser.c

@@ -0,0 +1,429 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+/*************************************************************************

+ * Includes

+**************************************************************************/

+

+#include <wombat/fileparser.h>

+#include <wombat/port.h>

+

+#include <fcntl.h>

+#include <sys/stat.h>

+#include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

+#include <errno.h>

+

+/*************************************************************************

+ * Typedefs, structs, enums and globals

+**************************************************************************/

+

+/* Internal implementation */

+typedef struct

+{

+    int                 mMmapOpenFlags;         /* Used for mmap */

+    int                 mMmapOpenMode;          /* Used for mmap */

+    int                 mMmapProtect;           /* Used for mmap */

+    int                 mMmapFlags;             /* Used for mmap */

+    int                 mFileDescriptor;        /* Used for mmap */

+    uint8_t*            mFileRootPosition;      /* Used for mmap */

+    uint8_t*            mFileCurrentPosition;   /* Used for mmap */

+    FILE*               mFileHandle;            /* Used for file streams */

+    const char*         mFileMode;              /* Used for file streams */

+    uint64_t            mFileSize;

+    uint64_t            mFileCurrentOffset;

+    const char*         mFileName;

+    fileParserType      mType;

+} fileParserImpl;

+

+

+/*************************************************************************

+ * Public implementation functions

+**************************************************************************/

+

+fileParserStatus

+fileParser_allocate (fileParser* parser)

+{

+    fileParserImpl* newReader = NULL;

+

+    if (NULL == parser)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+

+    newReader = (fileParserImpl*) calloc (1, sizeof(fileParserImpl));

+    if (NULL == newReader)

+    {

+        return FILE_PARSER_STATUS_NOMEM;

+    }

+    newReader->mMmapOpenFlags = O_RDONLY;

+    newReader->mMmapProtect = PROT_READ;

+    newReader->mMmapFlags = MAP_SHARED;

+    newReader->mType = FILE_PARSER_TYPE_UNKNOWN;

+    newReader->mFileMode = strdup ("rb");

+    if (NULL == newReader->mFileMode)

+    {

+        free (newReader);

+        return FILE_PARSER_STATUS_NOMEM;

+    }

+    *parser = (fileParser) newReader;

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_create (fileParser parser, fileParserType type, const char* fileName)

+{

+    struct stat     fileInfo;

+    int             result  = 0;

+    fileParserImpl* impl    = (fileParserImpl*) parser;

+

+    if (NULL == impl || NULL == fileName)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == strlen(fileName))

+    {

+        return FILE_PARSER_STATUS_INVALID_ARG;

+    }

+

+    result = stat(fileName, &fileInfo);

+    /* If we failed to access the file */

+    if (result)

+    {

+        return FILE_PARSER_STATUS_NO_FILE;

+    }

+

+    impl->mFileSize = fileInfo.st_size;

+    impl->mFileName = strdup (fileName);

+    if (NULL == impl->mFileName)

+    {

+        /* Clean up what we can */

+        fileParser_destroy (parser);

+        return FILE_PARSER_STATUS_NOMEM;

+    }

+

+    impl->mType = type;

+

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /* Open up the file */

+        impl->mFileDescriptor = open (fileName, impl->mMmapOpenFlags);

+        if (impl->mFileDescriptor < 0)

+        {

+            return FILE_PARSER_STATUS_NO_HANDLE;

+        }

+

+        /* Map the file to memory */

+        impl->mFileRootPosition =

+            (uint8_t*) mmap (NULL,

+                             (size_t) impl->mFileSize,

+                             impl->mMmapProtect,

+                             impl->mMmapFlags,

+                             impl->mFileDescriptor,

+                             0); /* 0 = Map from the first byte */

+        if (MAP_FAILED == impl->mFileRootPosition)

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+

+        /* Mark current position as the start */

+        impl->mFileCurrentPosition = impl->mFileRootPosition;

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+        /* Open the file handle */

+        impl->mFileHandle = fopen (fileName, impl->mFileMode);

+        if (NULL == impl->mFileHandle)

+        {

+            return FILE_PARSER_STATUS_NO_HANDLE;

+        }

+        break;

+    default:

+        return FILE_PARSER_STATUS_INVALID_ARG;

+        break;

+    }

+    return FILE_PARSER_STATUS_OK;

+}

+

+uint64_t

+fileParser_getFileSize (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+    if (NULL == impl)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    return impl->mFileSize;

+}

+

+fileParserStatus

+fileParser_readFileToBuffer (fileParser parser,

+                            void* destBuffer,

+                            uint64_t destBufferSize,

+                            uint64_t* bytesWritten)

+{

+    fileParserImpl* impl        = (fileParserImpl*) parser;

+    char*           destAsBytes = (char*) destBuffer;

+    int             i           = 0;

+    uint64_t        bytesToCopy = destBufferSize;

+

+    if (NULL == parser || NULL == destBuffer || NULL == bytesWritten)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == destBufferSize)

+    {

+        return FILE_PARSER_STATUS_INVALID_ARG;

+    }

+

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /* If there are fewer bytes in the file than requested, copy only the

+         * bytes remaining in the file to avoid overrun. */

+        if (impl->mFileSize < (impl->mFileCurrentOffset + bytesToCopy))

+        {

+            bytesToCopy = impl->mFileSize - impl->mFileCurrentOffset;

+        }

+

+        memcpy (destBuffer, impl->mFileCurrentPosition, (size_t) bytesToCopy);

+        impl->mFileCurrentPosition += bytesToCopy;

+        impl->mFileCurrentOffset += bytesToCopy;

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+    {

+        /* Returns the number of bytes read / written */

+        *bytesWritten = fread (destBuffer, 1, (size_t) bytesToCopy, impl->mFileHandle);

+

+        /* Find out where the file handle position is now */

+        impl->mFileCurrentOffset = ftell (impl->mFileHandle);

+        break;

+    }

+    default:

+        /* This would indicate an unknown or unpopulated parser type */

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_readFileToBufferUntilCharacter (fileParser parser,

+                            void* destBuffer,

+                            uint64_t destBufferSize,

+                            char delim,

+                            uint64_t* bytesWritten)

+{

+    fileParserImpl* impl        = (fileParserImpl*) parser;

+    char*           destAsBytes = (char*) destBuffer;

+    int             i           = 0;

+

+    if (NULL == parser || NULL == destBuffer || NULL == bytesWritten)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == destBufferSize)

+    {

+        return FILE_PARSER_STATUS_INVALID_ARG;

+    }

+

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /*  While we have bytes remaining in destination and we have not yet

+         * reached the delimiter */

+        do

+        {

+            destAsBytes[i] = (char) *(impl->mFileCurrentPosition);

+            impl->mFileCurrentOffset++;

+            impl->mFileCurrentPosition++;

+        } while (i < destBufferSize

+            && impl->mFileCurrentOffset < impl->mFileSize

+            && destAsBytes[i++] != delim);

+

+        /* Update the bytes written for the calling function */

+        *bytesWritten = i - 1;

+

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+    {

+        /*  While we have bytes remaining in destination and we have not yet

+         * reached the delimiter */

+        do

+        {

+            destAsBytes[i] = fgetc (impl->mFileHandle);

+        } while (i < destBufferSize && destAsBytes[i++] != delim);

+

+        /* Find out where the file handle position is now */

+        impl->mFileCurrentOffset = (uint64_t) ftell (impl->mFileHandle);

+

+        /* The position we are in now relative to the original offset */

+        *bytesWritten = i - 1;

+

+        break;

+    }

+    default:

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_rewindFile (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+    if (NULL == parser)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (FILE_PARSER_TYPE_UNKNOWN == impl->mType)

+    {

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+    switch (impl->mType)

+    {

+    case FILE_PARSER_TYPE_MMAP:

+        /* For mmap, we just point back to the first byte again */

+        impl->mFileCurrentPosition = impl->mFileRootPosition;

+        impl->mFileCurrentOffset   = 0;

+        break;

+    case FILE_PARSER_TYPE_FILE_STREAM:

+        /* For file streams, set file pointer to start of file */

+        if (0 != fseek (impl->mFileHandle, 0, SEEK_SET))

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+        impl->mFileCurrentOffset = 0;

+        break;

+    default:

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+int

+fileParser_isEndOfFile (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+

+    if (impl->mFileCurrentOffset >= impl->mFileSize)

+    {

+        return 1;

+    }

+    else

+    {

+        return 0;

+    }

+}

+

+const char*

+fileParser_stringForStatus (fileParserStatus status)

+{

+    switch (status)

+    {

+    case FILE_PARSER_STATUS_OK : return "FILE_PARSER_STATUS_OK";

+    case FILE_PARSER_STATUS_NOMEM : return "FILE_PARSER_STATUS_NOMEM";

+    case FILE_PARSER_STATUS_ERRNO : return "FILE_PARSER_STATUS_ERRNO";

+    case FILE_PARSER_STATUS_NULL_ARG : return "FILE_PARSER_STATUS_NULL_ARG";

+    case FILE_PARSER_STATUS_INVALID_ARG : return "FILE_PARSER_STATUS_INVALID_ARG";

+    case FILE_PARSER_STATUS_INVALID_STATE : return "FILE_PARSER_STATUS_INVALID_STATE";

+    case FILE_PARSER_STATUS_NO_HANDLE : return "FILE_PARSER_STATUS_NO_HANDLE";

+    case FILE_PARSER_STATUS_NO_FILE : return "FILE_PARSER_STATUS_NO_FILE";

+    case FILE_PARSER_STATUS_EOF : return "FILE_PARSER_STATUS_EOF";

+    case FILE_PARSER_STATUS_FAILURE : return "FILE_PARSER_STATUS_FAILURE";

+    default : return "unknown";

+    }

+}

+

+fileParserStatus

+fileParser_closeFile (fileParser parser)

+{

+    fileParserImpl* impl = (fileParserImpl*) parser;

+    if (NULL == parser)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+    if (0 == (int) impl->mType)

+    {

+        return FILE_PARSER_STATUS_INVALID_STATE;

+    }

+

+    /* If the file handle is set, close it */

+    if (NULL != impl->mFileHandle)

+    {

+        if (0 != fclose (impl->mFileHandle))

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+        impl->mFileHandle = NULL;

+    }

+

+    /* If the file descriptor is set, close it */

+    if (0 != impl->mFileDescriptor)

+    {

+        if (0 != munmap (impl->mFileRootPosition, (size_t) impl->mFileSize))

+        {

+            return FILE_PARSER_STATUS_FAILURE;

+        }

+        impl->mFileDescriptor = 0;

+    }

+

+    /* Reset type to unknown as this is in an unusable state until create is

+     * called again */

+    impl->mType = FILE_PARSER_TYPE_UNKNOWN;

+

+    return FILE_PARSER_STATUS_OK;

+}

+

+fileParserStatus

+fileParser_destroy (fileParser parser)

+{

+    fileParserImpl*     impl    = (fileParserImpl*) parser;

+    fileParserStatus    status  = FILE_PARSER_STATUS_OK;

+

+    if (NULL == impl)

+    {

+        return FILE_PARSER_STATUS_NULL_ARG;

+    }

+

+    /* File mode was strdup'd - free it before impl is free'd */

+    if (NULL != impl->mFileMode)

+    {

+        free ((void*) impl->mFileMode);

+    }

+

+    /* File name was strdup'd - free it before impl is free'd */

+    if (NULL != impl->mFileName)

+    {

+        free ((void*) impl->mFileName);

+    }

+

+    /* Close the file. If already closed, this should still be safe */

+    status = fileParser_closeFile (parser);

+

+    free (impl);

+

+    return status;

+}

+

diff --git a/common/c_cpp/src/c/wombat/fileparser.h b/common/c_cpp/src/c/wombat/fileparser.h

new file mode 100644

index 0000000..6e9a70f

--- /dev/null

+++ b/common/c_cpp/src/c/wombat/fileparser.h

@@ -0,0 +1,223 @@

+/* $Id$

+ *

+ * OpenMAMA: The open middleware agnostic messaging API

+ * Copyright (C) 2011 NYSE Technologies, Inc.

+ *

+ * This library is free software; you can redistribute it and/or

+ * modify it under the terms of the GNU Lesser General Public

+ * License as published by the Free Software Foundation; either

+ * version 2.1 of the License, or (at your option) any later version.

+ *

+ * This library is distributed in the hope that it will be useful,

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of

+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

+ * Lesser General Public License for more details.

+ *

+ * You should have received a copy of the GNU Lesser General Public

+ * License along with this library; if not, write to the Free Software

+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

+ * 02110-1301 USA

+ */

+

+#ifndef WOMBAT_FILEREADER_H__

+#define WOMBAT_FILEREADER_H__

+

+

+/*************************************************************************

+ * Includes

+**************************************************************************/

+

+#include <wombat/port.h>

+

+#if defined (__cplusplus)

+extern "C"

+{

+#endif

+

+

+/*************************************************************************

+ * Typedefs, structs, enums and globals

+**************************************************************************/

+

+/* fileParser is opaque */

+typedef void* fileParser;

+

+/* Possible return codes */

+typedef enum

+{

+    FILE_PARSER_STATUS_OK,

+    FILE_PARSER_STATUS_NOMEM,

+    FILE_PARSER_STATUS_ERRNO, /* Underlying failure has set errno */

+    FILE_PARSER_STATUS_NULL_ARG,

+    FILE_PARSER_STATUS_INVALID_ARG,

+    FILE_PARSER_STATUS_INVALID_STATE,

+    FILE_PARSER_STATUS_NO_HANDLE,

+    FILE_PARSER_STATUS_NO_FILE,

+    FILE_PARSER_STATUS_EOF,

+    FILE_PARSER_STATUS_FAILURE

+} fileParserStatus;

+

+/* Which type of file parser to use */

+typedef enum

+{

+    FILE_PARSER_TYPE_UNKNOWN,

+    FILE_PARSER_TYPE_MMAP, /* Start at 1 so 0 is invalid value */

+    FILE_PARSER_TYPE_FILE_STREAM

+} fileParserType;

+

+

+/*************************************************************************

+ * Public implementation functions

+**************************************************************************/

+

+/**

+ * Allocate a fileParser. A file may then be opened with it at a later point

+ * using a fileParser_create call.

+ *

+ * @param parser This pointer will be populated with the address of the newly

+ *               created fileParser implementation on function success.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_allocate (fileParser* parser);

+

+/**

+ * Creates a fileParser and associates it with a file and a parser type. This

+ * call will also open the file and perform any additional initialization

+ * required for the specified parser type.

+ *

+ * @param parser   The fileParser to perform this operation on.

+ * @param type     The type of fileParser to initialize (FILE_PARSER_TYPE_MMAP

+ *                 / FILE_PARSER_TYPE_FILE_STREAM.

+ * @param fileName The file to create a fileParser for and associate it with.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_create (fileParser parser, fileParserType type, const char* fileName);

+

+/**

+ * This will return the size of the opened file. Note this must be called

+ * after fileParser_create.

+ *

+ * @param parser   The fileParser to perform this operation on.

+ *

+ * @return uint64_t representing the size of the file being parser.

+ */

+COMMONExpDLL uint64_t

+fileParser_getFileSize (fileParser parser);

+

+/**

+ * Read from the current position of the fileParser provided up to a maximum

+ * of destBufferSize bytes. The bytesWritten value will then be populated by

+ * the function to reflect the number of bytes which have been copied to

+ * destBuffer.

+ *

+ * Calling this function will move the internal parser position of the provided

+ * fileParser object by bytesWritten bytes.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ * @param destBuffer     The the destination to copy the file contents to.

+ * @param destBufferSize The writable size of destBuffer.

+ * @param bytesWritten   Pointer to a value which will be populated with the

+ *                       number of bytes copied across on completion.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_readFileToBuffer (fileParser parser,

+                             void* destBuffer,

+                             uint64_t destBufferSize,

+                             uint64_t* bytesWritten);

+

+/**

+ * Read from the current position of the fileParser provided up to a maximum

+ * of destBufferSize bytes, up to and including the first detected instance of

+ * the delim character. The bytesWritten value will then be populated by

+ * the function to reflect the number of bytes which have been copied to

+ * destBuffer.

+ *

+ * Calling this function will move the internal parser position of the provided

+ * fileParser object by bytesWritten bytes.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ * @param destBuffer     The the destination to copy the file contents to.

+ * @param destBufferSize The writable size of destBuffer.

+ * @param delim          The character which, when encountered, will cause

+ *                       copying to stop (destination buffer will then include

+ *                       this delimiter).

+ * @param bytesWritten   Pointer to a value which will be populated with the

+ *                       number of bytes copied across on completion.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_readFileToBufferUntilCharacter (

+                             fileParser parser,

+                             void* destBuffer,

+                             uint64_t destBufferSize,

+                             char delim,

+                             uint64_t* bytesWritten);

+

+/**

+ * Calling this function will move the internal parser position of the provided

+ * fileParser object to the beginning of its file.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_rewindFile (fileParser parser);

+

+/**

+ * This function will return '1' if the file being parsed is at EOF. Otherwise

+ * this will return '0'.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return int (acting as a boolean) indicating whether the method succeeded or

+ *         failed.

+ */

+COMMONExpDLL int

+fileParser_isEndOfFile (fileParser parser);

+

+/**

+ * This will return a string representation of the provided fileParser status

+ * code.

+ *

+ * @param status         The status to perform this operation on.

+ *

+ * @return const char* referencing a string representation of the status.

+ */

+COMMONExpDLL const char*

+fileParser_stringForStatus (fileParserStatus status);

+

+/**

+ * This will close the file being parsed by the file parser and perform any

+ * additional cleanup required which is associated with the fileParser's type.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_closeFile (fileParser parser);

+

+/**

+ * Destroy the fileParser implementation and close any open files associated

+ * with it.

+ *

+ * @param parser         The fileParser to perform this operation on.

+ *

+ * @return fileParserStatus indicating whether the method succeeded or failed.

+ */

+COMMONExpDLL fileParserStatus

+fileParser_destroy (fileParser parser);

+

+#if defined (__cplusplus)

+}

+#endif

+

+#endif /* WOMBAT_FILEREADER_H__ */

\ No newline at end of file

--

1.8.4.msysgit.0

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.