Move weather settings to Location from GameState
[tennix.git] / archive.h
blob5688895f74b9745377db5d9b71ecca870a1d043e
1 #ifndef __ARCHIVE_H
2 #define __ARCHIVE_H
4 /**
6 * Tennix Archive File Format
7 * Copyright (C) 2009 Thomas Perl <thp@thpinfo.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301, USA.
24 **/
27 #include <stdint.h>
29 #define TENNIX_ARCHIVE_HEADER "thpinfo.com/2009/tennix/afmt "
30 #define TENNIX_ARCHIVE_HEADER_LEN 30
32 #define TENNIX_ARCHIVE_VERSIONMAJOR 1
33 #define TENNIX_ARCHIVE_VERSIONMINOR 0
35 #define TENNIX_ARCHIVE_ITEM_MAXNAME 86
38 /* architecture-independent (in-file) structs */
40 struct _TennixArchiveItem {
41 char filename[TENNIX_ARCHIVE_ITEM_MAXNAME];
42 uint32_t offset; /* network byte order */
43 uint32_t length; /* network byte order */
44 uint8_t key;
47 typedef struct _TennixArchiveItem TennixArchiveItem;
49 struct _TennixArchiveHeader {
50 char header[TENNIX_ARCHIVE_HEADER_LEN];
51 uint8_t versionmajor; /* major file version */
52 uint8_t versionminor; /* minor file version */
53 uint8_t key;
54 uint8_t items; /* maximum 255 files per archive */
57 typedef struct _TennixArchiveHeader TennixArchiveHeader;
61 /* architecture-dependent (in-memory) structs */
63 struct _TennixArchive {
64 FILE *fp;
65 TennixArchiveHeader header;
66 TennixArchiveItem *items;
67 char** blobs;
68 size_t offset;
69 int current_item;
72 typedef struct _TennixArchive TennixArchive;
74 /* reading existing archives */
75 TennixArchive* tnxar_open(const char* filename);
76 int tnxar_set_current_filename(TennixArchive* tnxar, const char* filename);
77 char* tnxar_get_current_filename(TennixArchive* tnxar);
78 char* tnxar_read_current(TennixArchive* tnxar);
79 size_t tnxar_size_current(TennixArchive* tnxar);
80 int tnxar_eof(TennixArchive* tnxar);
81 void tnxar_next(TennixArchive* tnxar);
82 void tnxar_close(TennixArchive* tnxar);
84 /* utility functions */
85 void tnxar_xormem(char* mem, uint32_t length, char key);
88 #ifdef TENNIXAR_STANDALONE
89 /* for debugging */
90 void tnxar_dump(TennixArchive* tnxar);
92 /* creating new archives */
93 TennixArchive* tnxar_create();
94 void tnxar_append(TennixArchive *tnxar, char* filename, char* mem, uint32_t length);
95 void tnxar_build(TennixArchive *tnxar, char* filename);
96 #endif
98 #endif