Home | History | Annotate | Download | only in include
      1 /**
      2  * Copyright(c) 2011 Trusted Logic.   All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *  * Neither the name Trusted Logic nor the names of its
     15  *    contributors may be used to endorse or promote products derived
     16  *    from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef __SST_H__
     32 #define __SST_H__
     33 
     34 #ifdef __cplusplus
     35 extern "C" {
     36 #endif
     37 
     38 
     39 #include "s_type.h"
     40 #include "s_error.h"
     41 
     42 #ifdef SST_EXPORTS
     43 #define SST_EXPORT_API S_DLL_EXPORT
     44 #else
     45 #define SST_EXPORT_API S_DLL_IMPORT
     46 #endif
     47 
     48 /* -----------------------------------------------------------------------------
     49                           Service SST Types
     50 ----------------------------------------------------------------------------- */
     51 
     52 #ifndef EXCLUDE_SERVICE_SST_TYPES
     53 
     54 /** The SST_ERROR type */
     55 typedef uint32_t  SST_ERROR;
     56 
     57 /** The SST_HANDLE type */
     58 typedef uint32_t  SST_HANDLE;
     59 
     60 typedef struct SST_FILE_INFO
     61 {
     62    char* pName;
     63    uint32_t nSize;
     64 } SST_FILE_INFO;
     65 
     66 #endif /* EXCLUDE_SERVICE_SST_TYPES */
     67 
     68 typedef enum
     69 {
     70    SST_SEEK_SET = 0,
     71    SST_SEEK_CUR,
     72    SST_SEEK_END
     73 } SST_WHENCE;
     74 
     75 
     76 /* -----------------------------------------------------------------------------
     77                           Constants
     78 ----------------------------------------------------------------------------- */
     79 
     80 #ifndef EXCLUDE_SERVICE_SST_CONSTANTS
     81 
     82 /** The Invalid SST_FILE_HANDLE */
     83 #define SST_NULL_HANDLE     0
     84 
     85 /* Legacy constant name */
     86 #define SST_HANDLE_INVALID    SST_NULL_HANDLE
     87 
     88 /** Max length for file names */
     89 #define SST_MAX_FILENAME 0x40
     90 
     91 /** Maximum pointer position in a file */
     92 #define SST_MAX_FILE_POSITION    0xFFFFFFFF
     93 
     94 /** File access modes */
     95 #define SST_O_READ               0x00000001
     96 #define SST_O_WRITE              0x00000002
     97 #define SST_O_WRITE_META         0x00000004
     98 #define SST_O_SHARE_READ         0x00000010
     99 #define SST_O_SHARE_WRITE        0x00000020
    100 #define SST_O_CREATE             0x00000200
    101 #define SST_O_EXCLUSIVE          0x00000400
    102 
    103 
    104 #endif /* EXCLUDE_SERVICE_SST_CONSTANTS */
    105 
    106 
    107 /* -----------------------------------------------------------------------------
    108                         Functions
    109 ----------------------------------------------------------------------------- */
    110 
    111 #ifndef EXCLUDE_SERVICE_SST_FUNCTIONS
    112 
    113 SST_ERROR SST_EXPORT_API SSTInit(void);
    114 
    115 SST_ERROR SST_EXPORT_API SSTTerminate(void);
    116 
    117 SST_ERROR SST_EXPORT_API SSTOpen(const char*       pFilename,
    118                                  uint32_t    nFlags,
    119                                  uint32_t    nReserved,
    120                                  SST_HANDLE* phFile);
    121 
    122 SST_ERROR SST_EXPORT_API SSTCloseHandle(SST_HANDLE  hFile);
    123 
    124 SST_ERROR SST_EXPORT_API SSTWrite(SST_HANDLE hFile,
    125                                   const uint8_t*   pBuffer,
    126                                   uint32_t   nSize);
    127 
    128 SST_ERROR SST_EXPORT_API SSTRead(SST_HANDLE  hFile,
    129                                  uint8_t*    pBuffer,
    130                                  uint32_t    nSize,
    131                                  uint32_t*   pnCount);
    132 
    133 SST_ERROR SST_EXPORT_API SSTSeek(SST_HANDLE  hFile,
    134                                  int32_t     nOffset,
    135                                  SST_WHENCE  eWhence);
    136 
    137 SST_ERROR SST_EXPORT_API SSTTell(SST_HANDLE  hFile,
    138                                  uint32_t*   pnPos);
    139 
    140 SST_ERROR SST_EXPORT_API SSTGetSize(const char*        pFilename,
    141                                     uint32_t*    pnSize);
    142 
    143 SST_ERROR SST_EXPORT_API SSTEof( SST_HANDLE   hFile,
    144                                  bool*        pbEof);
    145 
    146 SST_ERROR SST_EXPORT_API SSTCloseAndDelete(SST_HANDLE hFile);
    147 
    148 SST_ERROR SST_EXPORT_API SSTTruncate(  SST_HANDLE  hFile,
    149                                        uint32_t    nSize);
    150 
    151 SST_ERROR SST_EXPORT_API SSTRename(SST_HANDLE hFile,
    152                                    const char* pNewFilename);
    153 
    154 SST_ERROR SST_EXPORT_API SSTEnumerationStart(const char*     pFilenamePattern,
    155                                              uint32_t  nReserved1,
    156                                              uint32_t  nReserved2,
    157                                              SST_HANDLE* phFileEnumeration);
    158 
    159 SST_ERROR SST_EXPORT_API SSTEnumerationCloseHandle(SST_HANDLE hFileEnumeration);
    160 
    161 SST_ERROR SST_EXPORT_API SSTEnumerationGetNext(SST_HANDLE      hFileEnumeration,
    162                                                SST_FILE_INFO** ppFileInfo);
    163 
    164 SST_ERROR SST_EXPORT_API SSTDestroyFileInfo(SST_FILE_INFO*   pFileInfo);
    165 
    166 #endif /* EXCLUDE_SERVICE_SST_FUNCTIONS */
    167 
    168 #ifdef __cplusplus
    169 }
    170 #endif
    171 
    172 #endif /* __SST_H__ */
    173