1 /* 2 * Copyright (c) 2014-2015, The University of Oxford 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * 3. Neither the name of the University of Oxford nor the names of its 13 * contributors may be used to endorse or promote products derived from this 14 * software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef OSKAR_BINARY_H_ 30 #define OSKAR_BINARY_H_ 31 32 /** 33 * @file oskar_binary.h 34 */ 35 36 /* Public interface. */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 struct oskar_Binary; 43 #ifndef OSKAR_BINARY_TYPEDEF_ 44 #define OSKAR_BINARY_TYPEDEF_ 45 typedef struct oskar_Binary oskar_Binary; 46 #endif /* OSKAR_BINARY_TYPEDEF_ */ 47 48 #define OSKAR_BINARY_FORMAT_VERSION 2 49 50 /* 51 * IMPORTANT: 52 * To maintain binary data compatibility, do not modify any numbers 53 * that appear in the lists below! 54 */ 55 56 /* Standard tag groups. */ 57 enum OSKAR_TAG_GROUPS 58 { 59 OSKAR_TAG_GROUP_METADATA = 1, 60 OSKAR_TAG_GROUP_SYSTEM_INFO = 2, 61 OSKAR_TAG_GROUP_SETTINGS = 3, 62 OSKAR_TAG_GROUP_RUN = 4, 63 OSKAR_TAG_GROUP_VISIBILITY = 5, /* DEPRECATED. */ 64 OSKAR_TAG_GROUP_IMAGE = 6, /* DEPRECATED. */ 65 OSKAR_TAG_GROUP_SKY_MODEL = 7, 66 OSKAR_TAG_GROUP_TIME_FREQ_DATA = 8, 67 OSKAR_TAG_GROUP_SPLINE_DATA = 9, 68 OSKAR_TAG_GROUP_ELEMENT_DATA = 10, 69 OSKAR_TAG_GROUP_VIS_HEADER = 11, 70 OSKAR_TAG_GROUP_VIS_BLOCK = 12 71 }; 72 73 /* Standard metadata tags. */ 74 enum OSKAR_TAG_METADATA 75 { 76 OSKAR_TAG_METADATA_DATE_TIME_STRING = 1, 77 OSKAR_TAG_METADATA_OSKAR_VERSION_STRING = 2, 78 OSKAR_TAG_METADATA_USERNAME = 3, 79 OSKAR_TAG_METADATA_CWD = 4 80 }; 81 82 /* Standard settings tags. */ 83 enum OSKAR_TAG_SETTINGS 84 { 85 OSKAR_TAG_SETTINGS_PATH = 1, 86 OSKAR_TAG_SETTINGS = 2 87 }; 88 89 /* Standard run info tags. */ 90 enum OSKAR_TAG_RUN 91 { 92 OSKAR_TAG_RUN_LOG = 1 93 }; 94 95 /* Binary file error codes are in the range -100 to -149. */ 96 enum OSKAR_BINARY_ERROR_CODES 97 { 98 OSKAR_ERR_BINARY_OPEN_FAIL = -100, 99 OSKAR_ERR_BINARY_SEEK_FAIL = -101, 100 OSKAR_ERR_BINARY_READ_FAIL = -102, 101 OSKAR_ERR_BINARY_WRITE_FAIL = -103, 102 OSKAR_ERR_BINARY_NOT_OPEN_FOR_READ = -104, 103 OSKAR_ERR_BINARY_NOT_OPEN_FOR_WRITE = -105, 104 OSKAR_ERR_BINARY_FILE_INVALID = -106, 105 OSKAR_ERR_BINARY_FORMAT_BAD = -107, 106 OSKAR_ERR_BINARY_ENDIAN_MISMATCH = -108, 107 OSKAR_ERR_BINARY_VERSION_UNKNOWN = -109, 108 OSKAR_ERR_BINARY_TYPE_UNKNOWN = -110, 109 OSKAR_ERR_BINARY_INT_UNKNOWN = -111, 110 OSKAR_ERR_BINARY_FLOAT_UNKNOWN = -112, 111 OSKAR_ERR_BINARY_DOUBLE_UNKNOWN = -113, 112 OSKAR_ERR_BINARY_MEMORY_NOT_ALLOCATED = -114, 113 OSKAR_ERR_BINARY_TAG_NOT_FOUND = -115, 114 OSKAR_ERR_BINARY_TAG_TOO_LONG = -116, 115 OSKAR_ERR_BINARY_TAG_OUT_OF_RANGE = -117, 116 OSKAR_ERR_BINARY_CRC_FAIL = -118 117 }; 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #include <binary/oskar_binary_data_types.h> 124 #include <binary/oskar_binary_create.h> 125 #include <binary/oskar_binary_free.h> 126 #include <binary/oskar_binary_query.h> 127 #include <binary/oskar_binary_read.h> 128 #include <binary/oskar_binary_write.h> 129 #include <binary/oskar_endian.h> 130 131 #endif /* OSKAR_BINARY_H_ */ 132