![]() |
pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
|
00001 /* 00002 ------------------------------------------------------------------------------- 00003 This file is part of the Plink, Plonk, Plank libraries 00004 by Martin Robinson 00005 00006 http://code.google.com/p/pl-nk/ 00007 00008 Copyright University of the West of England, Bristol 2011-14 00009 All rights reserved. 00010 00011 Redistribution and use in source and binary forms, with or without 00012 modification, are permitted provided that the following conditions are met: 00013 00014 * Redistributions of source code must retain the above copyright 00015 notice, this list of conditions and the following disclaimer. 00016 * Redistributions in binary form must reproduce the above copyright 00017 notice, this list of conditions and the following disclaimer in the 00018 documentation and/or other materials provided with the distribution. 00019 * Neither the name of University of the West of England, Bristol nor 00020 the names of its contributors may be used to endorse or promote products 00021 derived from this software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00026 DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF THE WEST OF ENGLAND, BRISTOL BE 00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 00034 This software makes use of third party libraries. For more information see: 00035 doc/license.txt included in the distribution. 00036 ------------------------------------------------------------------------------- 00037 */ 00038 00039 #ifndef PLANK_TEXT_H 00040 #define PLANK_TEXT_H 00041 00042 #include "../containers/plank_DynamicArray.h" 00043 #include "plank_Path.h" 00044 00045 PLANK_BEGIN_C_LINKAGE 00046 00047 typedef struct PlankMulitFileReader* PlankMulitFileReaderRef; // would prefer to move this declaration 00048 00060 typedef struct PlankFile* PlankFileRef; 00061 00063 #define PLANKFILE_READ (1 << 0) 00064 00066 #define PLANKFILE_WRITE (1 << 1) 00067 00069 #define PLANKFILE_BINARY (1 << 2) 00070 00072 #define PLANKFILE_APPEND (1 << 3) 00073 00075 #define PLANKFILE_NEW (1 << 4) 00076 00078 #define PLANKFILE_BIGENDIAN (1 << 5) 00079 00081 #define PLANKFILE_OWNMULTI (1 << 6) 00082 00083 00084 #if PLANK_BIGENDIAN 00085 #define PLANKFILE_NATIVEENDIAN PLANKFILE_BIGENDIAN 00086 #elif PLANK_LITTLEENDIAN 00087 #define PLANKFILE_NATIVEENDIAN (0) 00088 #endif 00089 00091 #define PLANKFILE_DYNAMICARRAYOWNED (1 << 6) 00092 00094 #define PLANKFILE_MASK (PLANKFILE_READ | PLANKFILE_WRITE | PLANKFILE_BINARY | PLANKFILE_APPEND | PLANKFILE_NEW) 00095 00097 #define PLANKFILE_ALL (PLANKFILE_MASK | PLANKFILE_BIGENDIAN) 00098 00099 #define PLANKFILE_STATUS_EOF 1 00100 #define PLANKFILE_STATUS_ISPOSITIONABLE 2 00101 00102 #define PLANKFILE_STREAMTYPE_UNKNOWN 0 00103 #define PLANKFILE_STREAMTYPE_FILE 1 00104 #define PLANKFILE_STREAMTYPE_MEMORY 2 00105 #define PLANKFILE_STREAMTYPE_DYNAMICARRAY 3 00106 #define PLANKFILE_STREAMTYPE_NETWORK 4 00107 #define PLANKFILE_STREAMTYPE_MULTI 5 00108 #define PLANKFILE_STREAMTYPE_OTHER 999 00109 00110 #define PLANKFILE_SETPOSITION_ABSOLUTE SEEK_SET 00111 #define PLANKFILE_SETPOSITION_RELATIVE SEEK_CUR 00112 #define PLANKFILE_SETPOSITION_RELATIVEEND SEEK_END 00113 00115 PlankResult pl_FileErase (const char* filepath); 00116 00117 PlankB pl_FileExists (const char* filepath, const PlankB isDirectory); 00118 PlankResult pl_FileMakeDirectory (const char* filepath); 00119 00120 00121 typedef PlankResult (*PlankFileOpenFunction)(PlankFileRef); 00122 typedef PlankResult (*PlankFileCloseFunction)(PlankFileRef); 00123 typedef PlankResult (*PlankFileClearFunction)(PlankFileRef); 00124 typedef PlankResult (*PlankFileGetStatusFunction)(PlankFileRef, int, int*); 00125 typedef PlankResult (*PlankFileReadFunction)(PlankFileRef, PlankP ptr, int, int*); 00126 typedef PlankResult (*PlankFileWriteFunction)(PlankFileRef, const void*, const int); 00127 typedef PlankResult (*PlankFileSetPositionFunction)(PlankFileRef, PlankLL, int); 00128 typedef PlankResult (*PlankFileGetPositionFunction)(PlankFileRef, PlankLL*); 00129 00132 PlankFileRef pl_File_CreateAndInit(); 00133 00136 PlankFileRef pl_File_Create(); 00137 00141 PlankResult pl_File_Init (PlankFileRef p); 00142 00147 PlankResult pl_File_DeInit (PlankFileRef p); 00148 00153 PlankResult pl_File_Destroy (PlankFileRef p); 00154 00155 PlankResult pl_File_SetFunction (PlankFileRef p, 00156 PlankFileOpenFunction openFunction, 00157 PlankFileCloseFunction closeFunction, 00158 PlankFileClearFunction clearFunction, 00159 PlankFileGetStatusFunction statusFunction, 00160 PlankFileReadFunction readFunction, 00161 PlankFileWriteFunction writeFunction, 00162 PlankFileSetPositionFunction setPosFunction, 00163 PlankFileGetPositionFunction getPosFunction); 00164 00170 PlankResult pl_File_Open (PlankFileRef p, const char* filepath, const int mode); 00171 00177 PlankResult pl_File_OpenTextRead (PlankFileRef p, const char* filepath, const PlankB andWrite); 00178 00186 PlankResult pl_File_OpenTextWrite (PlankFileRef p, const char* filepath, const PlankB andRead, const PlankB replaceExistingFile); 00187 00195 PlankResult pl_File_OpenBinaryRead (PlankFileRef p, const char* filepath, const PlankB andWrite, const PlankB isBigEndian); 00196 00206 PlankResult pl_File_OpenBinaryWrite (PlankFileRef p, const char* filepath, const PlankB andRead, const PlankB replaceExistingFile, const PlankB isBigEndian); 00207 00215 PlankResult pl_File_OpenBinaryNativeEndianRead (PlankFileRef p, const char* filepath, const PlankB andWrite); 00216 00226 PlankResult pl_File_OpenBinaryNativeEndianWrite (PlankFileRef p, const char* filepath, const PlankB andRead, const PlankB replaceExistingFile); 00227 00228 PlankResult pl_File_OpenMemory (PlankFileRef p, void* memory, const PlankLL size, const int mode); 00229 00230 PlankResult pl_File_OpenDynamicArray (PlankFileRef p, PlankDynamicArrayRef memory, const int mode); 00231 00232 PlankResult pl_File_OpenMulti (PlankFileRef p, PlankMulitFileReaderRef multi, const int mode); 00233 00234 PlankResult pl_File_Copy (PlankFileRef p, PlankFileRef source, const PlankLL size); 00235 00236 PlankResult pl_File_Clear (PlankFileRef p); 00237 00242 PlankB pl_File_IsBigEndian (PlankFileRef p); 00243 00248 PlankB pl_File_IsLittleEndian (PlankFileRef p); 00249 00254 PlankB pl_File_IsNativeEndian (PlankFileRef p); 00255 00256 PlankB pl_File_IsPositionable (PlankFileRef p); 00257 00261 PlankResult pl_File_Close (PlankFileRef p); 00262 00267 PlankResult pl_File_SetPosition (PlankFileRef p, const PlankLL position); 00268 00273 PlankResult pl_File_OffsetPosition (PlankFileRef p, const PlankLL offset); 00274 00278 PlankResult pl_File_ResetPosition (PlankFileRef p); 00279 00283 PlankResult pl_File_SetPositionEnd (PlankFileRef p); 00284 00289 PlankB pl_File_IsValid (PlankFileRef p); 00290 00295 PlankB pl_File_IsEOF (PlankFileRef p); 00296 00300 PlankResult pl_File_SetEOF (PlankFileRef p); 00301 00306 PlankResult pl_File_GetPosition (PlankFileRef p, PlankLL* position); 00307 00312 PlankResult pl_File_SetMode (PlankFileRef p, const int mode); 00313 00314 PlankResult pl_File_GetMode (PlankFileRef p, int* mode); 00315 00316 PlankResult pl_File_GetStreamType (PlankFileRef p, int* type); 00317 00319 PlankResult pl_File_SetEndian (PlankFileRef p, const PlankB isBigEndian); 00320 00329 PlankResult pl_File_Read (PlankFileRef p, PlankP data, const int maximumBytes, int* bytesRead); 00330 00335 PlankResult pl_File_ReadC (PlankFileRef p, char* data); 00336 00341 PlankResult pl_File_ReadS (PlankFileRef p, short* data); 00342 00347 PlankResult pl_File_ReadI (PlankFileRef p, int* data); 00348 00353 PlankResult pl_File_ReadI24 (PlankFileRef p, PlankI24* data); 00354 00355 00363 //PlankResult pl_File_ReadL (PlankFileRef p, PlankL* data); 00364 00369 PlankResult pl_File_ReadLL (PlankFileRef p, PlankLL* data); 00370 00375 PlankResult pl_File_ReadUC (PlankFileRef p, unsigned char* data); 00376 00381 PlankResult pl_File_ReadUS (PlankFileRef p, unsigned short* data); 00382 00387 PlankResult pl_File_ReadUI (PlankFileRef p, unsigned int* data); 00388 00393 PlankResult pl_File_ReadUI24 (PlankFileRef p, PlankUI24* data); 00394 00402 PlankResult pl_File_ReadUL (PlankFileRef p, PlankUL* data); 00403 00408 PlankResult pl_File_ReadULL (PlankFileRef p, PlankULL* data); 00409 00414 PlankResult pl_File_ReadF (PlankFileRef p, float* data); 00415 00420 PlankResult pl_File_ReadD (PlankFileRef p, double* data); 00421 00423 PlankResult pl_File_ReadFourCharCode (PlankFileRef p, PlankFourCharCode* data); 00424 00425 PlankResult pl_File_ReadGUID (PlankFileRef p, PlankGUIDRef guid); 00426 00427 00429 PlankResult pl_File_ReadPascalString255 (PlankFileRef p, PlankPascalString255* string); 00430 00431 00437 PlankResult pl_File_ReadLine (PlankFileRef p, char* text, const int maximumLength); 00438 00443 PlankResult pl_File_SkipBytes (PlankFileRef p, const int numBytes); 00444 00445 00453 PlankResult pl_File_Write (PlankFileRef p, const void* data, const int maximumBytes); 00454 00455 PlankResult pl_File_WriteDynamicArray (PlankFileRef p, PlankDynamicArrayRef array); 00456 00457 PlankResult pl_File_WriteZeros (PlankFileRef p, const int numBytes); 00458 00463 PlankResult pl_File_WriteC (PlankFileRef p, char data); 00464 00469 PlankResult pl_File_WriteS (PlankFileRef p, short data); 00470 00475 PlankResult pl_File_WriteI (PlankFileRef p, int data); 00476 00481 PlankResult pl_File_WriteI24 (PlankFileRef p, PlankI24 data); 00482 00490 //PlankResult pl_File_WriteL (PlankFileRef p, PlankL data); 00491 00496 PlankResult pl_File_WriteLL (PlankFileRef p, PlankLL data); 00497 00502 PlankResult pl_File_WriteUC (PlankFileRef p, unsigned char data); 00503 00508 PlankResult pl_File_WriteUS (PlankFileRef p, unsigned short data); 00509 00514 PlankResult pl_File_WriteUI (PlankFileRef p, unsigned int data); 00515 00520 PlankResult pl_File_WriteUI24 (PlankFileRef p, PlankUI24 data); 00521 00529 PlankResult pl_File_WriteUL (PlankFileRef p, PlankUL data); 00530 00535 PlankResult pl_File_WriteULL (PlankFileRef p, PlankULL data); 00536 00541 PlankResult pl_File_WriteF (PlankFileRef p, float data); 00542 00547 PlankResult pl_File_WriteD (PlankFileRef p, double data); 00548 00550 PlankResult pl_File_WriteFourCharCode (PlankFileRef p, PlankFourCharCode data); 00551 00552 PlankResult pl_File_WriteGUID (PlankFileRef p, const PlankGUID* guid); 00553 00554 00560 PlankResult pl_File_WriteString (PlankFileRef p, const char* text); 00561 00568 PlankResult pl_File_WriteLine (PlankFileRef p, const char* text); 00569 00571 PlankResult pl_File_WritePascalString255 (PlankFileRef p, PlankPascalString255* string); 00572 00573 PlankResult pl_FileDefaultOpenCallback (PlankFileRef p); 00574 PlankResult pl_FileDefaultCloseCallback (PlankFileRef p); 00575 PlankResult pl_FileDefaultGetStatusCallback (PlankFileRef p, int type, int* status); 00576 PlankResult pl_FileDefaultReadCallback (PlankFileRef p, PlankP ptr, int maximumBytes, int* bytesRead); 00577 PlankResult pl_FileDefaultWriteCallback (PlankFileRef p, const void* data, const int maximumBytes); 00578 PlankResult pl_FileDefaultSetPositionCallback (PlankFileRef p, PlankLL offset, int code); 00579 PlankResult pl_FileDefaultGetPositionCallback (PlankFileRef p, PlankLL* position); 00580 00581 00583 00584 PLANK_END_C_LINKAGE 00585 00586 #if !DOXYGEN 00587 typedef struct PlankFile 00588 { 00589 void *stream; // must be first? 00590 PlankUS mode; 00591 PlankUS type; 00592 PlankLL size; 00593 PlankLL position; 00594 char path[PLANKPATH_MAXLENGTH]; 00595 00596 PlankFileOpenFunction openFunction; 00597 PlankFileCloseFunction closeFunction; 00598 PlankFileClearFunction clearFunction; 00599 PlankFileGetStatusFunction statusFunction; 00600 PlankFileReadFunction readFunction; 00601 PlankFileWriteFunction writeFunction; 00602 PlankFileSetPositionFunction setPositionFunction; 00603 PlankFileGetPositionFunction getPositionFunction; 00604 } PlankFile; 00605 #endif 00606 00607 00608 00609 #endif // PLANK_TEXT_H