12e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/**
22e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * Copyright(c) 2011 Trusted Logic.   All rights reserved.
32e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *
42e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * Redistribution and use in source and binary forms, with or without
52e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * modification, are permitted provided that the following conditions
62e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * are met:
72e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *
82e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *  * Redistributions of source code must retain the above copyright
92e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *    notice, this list of conditions and the following disclaimer.
102e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *  * Redistributions in binary form must reproduce the above copyright
112e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *    notice, this list of conditions and the following disclaimer in
122e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *    the documentation and/or other materials provided with the
132e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *    distribution.
142e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *  * Neither the name Trusted Logic nor the names of its
152e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *    contributors may be used to endorse or promote products derived
162e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *    from this software without specific prior written permission.
172e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley *
182e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
192e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
202e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
212e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
222e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
232e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
242e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
252e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
262e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
272e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
282e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
292e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley */
302e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
312e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifndef __SST_H__
322e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define __SST_H__
332e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
342e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifdef __cplusplus
352e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckleyextern "C" {
362e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif
372e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
382e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
392e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#include "s_type.h"
402e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#include "s_error.h"
412e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
422e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifdef SST_EXPORTS
432e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_EXPORT_API S_DLL_EXPORT
442e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#else
452e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_EXPORT_API S_DLL_IMPORT
462e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif
472e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
482e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/* -----------------------------------------------------------------------------
492e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                          Service SST Types
502e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley----------------------------------------------------------------------------- */
512e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
522e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifndef EXCLUDE_SERVICE_SST_TYPES
532e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
542e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/** The SST_ERROR type */
552e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckleytypedef uint32_t  SST_ERROR;
562e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
572e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/** The SST_HANDLE type */
582e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckleytypedef uint32_t  SST_HANDLE;
592e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
602e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckleytypedef struct SST_FILE_INFO
612e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley{
622e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley   char* pName;
632e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley   uint32_t nSize;
642e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley} SST_FILE_INFO;
652e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
662e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif /* EXCLUDE_SERVICE_SST_TYPES */
672e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
682e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckleytypedef enum
692e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley{
702e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley   SST_SEEK_SET = 0,
712e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley   SST_SEEK_CUR,
722e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley   SST_SEEK_END
732e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley} SST_WHENCE;
742e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
752e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
762e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/* -----------------------------------------------------------------------------
772e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                          Constants
782e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley----------------------------------------------------------------------------- */
792e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
802e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifndef EXCLUDE_SERVICE_SST_CONSTANTS
812e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
822e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/** The Invalid SST_FILE_HANDLE */
832e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_NULL_HANDLE     0
842e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
852e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/* Legacy constant name */
862e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_HANDLE_INVALID    SST_NULL_HANDLE
872e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
882e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/** Max length for file names */
892e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_MAX_FILENAME 0x40
902e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
912e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/** Maximum pointer position in a file */
922e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_MAX_FILE_POSITION    0xFFFFFFFF
932e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
942e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/** File access modes */
952e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_READ               0x00000001
962e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_WRITE              0x00000002
972e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_WRITE_META         0x00000004
982e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_SHARE_READ         0x00000010
992e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_SHARE_WRITE        0x00000020
1002e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_CREATE             0x00000200
1012e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#define SST_O_EXCLUSIVE          0x00000400
1022e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1032e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1042e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif /* EXCLUDE_SERVICE_SST_CONSTANTS */
1052e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1062e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1072e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley/* -----------------------------------------------------------------------------
1082e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                        Functions
1092e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley----------------------------------------------------------------------------- */
1102e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1112e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifndef EXCLUDE_SERVICE_SST_FUNCTIONS
1122e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1132e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTInit(void);
1142e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1152e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTTerminate(void);
1162e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1172e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTOpen(const char*       pFilename,
1182e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 uint32_t    nFlags,
1192e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 uint32_t    nReserved,
1202e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 SST_HANDLE* phFile);
1212e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1222e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTCloseHandle(SST_HANDLE  hFile);
1232e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1242e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTWrite(SST_HANDLE hFile,
1252e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                  const uint8_t*   pBuffer,
1262e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                  uint32_t   nSize);
1272e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1282e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTRead(SST_HANDLE  hFile,
1292e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 uint8_t*    pBuffer,
1302e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 uint32_t    nSize,
1312e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 uint32_t*   pnCount);
1322e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1332e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTSeek(SST_HANDLE  hFile,
1342e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 int32_t     nOffset,
1352e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 SST_WHENCE  eWhence);
1362e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1372e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTTell(SST_HANDLE  hFile,
1382e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 uint32_t*   pnPos);
1392e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1402e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTGetSize(const char*        pFilename,
1412e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                    uint32_t*    pnSize);
1422e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1432e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTEof( SST_HANDLE   hFile,
1442e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                 bool*        pbEof);
1452e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1462e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTCloseAndDelete(SST_HANDLE hFile);
1472e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1482e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTTruncate(  SST_HANDLE  hFile,
1492e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                       uint32_t    nSize);
1502e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1512e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTRename(SST_HANDLE hFile,
1522e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                   const char* pNewFilename);
1532e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1542e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTEnumerationStart(const char*     pFilenamePattern,
1552e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                             uint32_t  nReserved1,
1562e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                             uint32_t  nReserved2,
1572e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                             SST_HANDLE* phFileEnumeration);
1582e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1592e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTEnumerationCloseHandle(SST_HANDLE hFileEnumeration);
1602e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1612e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTEnumerationGetNext(SST_HANDLE      hFileEnumeration,
1622e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley                                               SST_FILE_INFO** ppFileInfo);
1632e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1642e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan BuckleySST_ERROR SST_EXPORT_API SSTDestroyFileInfo(SST_FILE_INFO*   pFileInfo);
1652e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1662e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif /* EXCLUDE_SERVICE_SST_FUNCTIONS */
1672e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1682e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#ifdef __cplusplus
1692e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley}
1702e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif
1712e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley
1722e9e9eca83c3dee85b7815573a8cf1e6d1780741Bryan Buckley#endif /* __SST_H__ */
173