6 * Tennix Archive File Format
7 * Copyright (C) 2009 Thomas Perl <thp@thpinfo.com>
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,
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 */
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 */
54 uint8_t items
; /* maximum 255 files per archive */
57 typedef struct _TennixArchiveHeader TennixArchiveHeader
;
61 /* architecture-dependent (in-memory) structs */
63 struct _TennixArchive
{
65 TennixArchiveHeader header
;
66 TennixArchiveItem
*items
;
72 typedef struct _TennixArchive TennixArchive
;
74 /* reading existing archives */
75 TennixArchive
* tnxar_open(char* filename
);
76 int tnxar_set_current_filename(TennixArchive
* tnxar
, 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
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
);