6 * Tennix Archive File Format
7 * Copyright (C) 2009-2010 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,
31 #define TENNIX_ARCHIVE_HEADER "thpinfo.com/2009/tennix/afmt "
32 #define TENNIX_ARCHIVE_HEADER_LEN 30
34 #define TENNIX_ARCHIVE_VERSIONMAJOR 1
35 #define TENNIX_ARCHIVE_VERSIONMINOR 0
37 #define TENNIX_ARCHIVE_ITEM_MAXNAME 86
40 /* architecture-independent (in-file) structs */
42 struct _TennixArchiveItem
{
43 char filename
[TENNIX_ARCHIVE_ITEM_MAXNAME
];
44 uint32_t offset
; /* network byte order */
45 uint32_t length
; /* network byte order */
49 typedef struct _TennixArchiveItem TennixArchiveItem
;
51 struct _TennixArchiveHeader
{
52 char header
[TENNIX_ARCHIVE_HEADER_LEN
];
53 uint8_t versionmajor
; /* major file version */
54 uint8_t versionminor
; /* minor file version */
56 uint8_t items
; /* maximum 255 files per archive */
59 typedef struct _TennixArchiveHeader TennixArchiveHeader
;
65 TennixArchiveHeader header
;
66 TennixArchiveItem
* items
;
72 static void xormem(char* mem
, uint32_t length
, char key
);
76 strcpy(header
.header
, TENNIX_ARCHIVE_HEADER
);
82 TennixArchive(const char* filename
);
91 int setItemFilename(const char* filename
);
93 const char* getItemFilename() {
94 return items
[current_item
].filename
;
99 size_t getItemSize() {
100 return items
[current_item
].length
;
104 return current_item
>= header
.items
;
111 /* only for building/utility mode: */
112 void appendItem(char* filename
, char* data
, uint32_t length
);
113 void buildFile(char* filename
);