]> git.draconx.ca Git - upkg.git/blob - src/upkg.h
libupkg: Add signed integer unpacking to fix incorrect signedness issue.
[upkg.git] / src / upkg.h
1 /*
2  *  upkg: tool for manipulating Unreal Tournament packages.
3  *  Copyright (C) 2009 Nick Bowler
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef UPKG_H_
21 #define UPKG_H_
22
23 #include <stddef.h>
24
25 #define UPKG_FLAG_ALLOW_DOWNLOAD  0x0001
26 #define UPKG_FLAG_CLIENT_OPTIONAL 0x0002
27 #define UPKG_FLAG_SERVER_ONLY     0x0004
28 #define UPKG_FLAG_BROKEN_LINKS    0x0008
29 #define UPKG_FLAG_INSECURE        0x0010
30 #define UPKG_FLAG_REQUIRED        0x8000
31
32 #define UPKG_OBJ_FLAG_TRANSACTIONAL   0x00000001
33 #define UPKG_OBJ_FLAG_UNREACHABLE     0x00000002
34 #define UPKG_OBJ_FLAG_PUBLIC          0x00000004
35 #define UPKG_OBJ_FLAG_TAG_IMPORT      0x00000008
36 #define UPKG_OBJ_FLAG_TAG_EXPORT      0x00000010
37 #define UPKG_OBJ_FLAG_SOURCE_MODIFIED 0x00000020
38 #define UPKG_OBJ_FLAG_TAG_GARBAGE     0x00000040
39 #define UPKG_OBJ_FLAG_NEED_LOAD       0x00000200
40 #define UPKG_OBJ_FLAG_HIGHLIGHT_NAME  0x00000400
41
42 #define UPKG_HDR_MAGIC 0x9e2a83c1
43 #define UPKG_HDR_SIZE  36
44
45 struct upkg {
46         unsigned version, license;
47         unsigned char guid[16];
48         unsigned long flags;
49
50         unsigned long name_count, export_count, import_count;
51
52         struct upkg_private *priv;
53 };
54
55 struct upkg_file {
56         const char *name;
57
58         int eof;
59
60         struct upkg *pkg;
61         unsigned long base, offset, len;
62 };
63
64 struct upkg *upkg_fopen(const char *path);
65 int upkg_close(struct upkg *pkg);
66
67 const char *upkg_get_name(struct upkg *pkg, unsigned long idx);
68
69 long   upkg_export_find(struct upkg *pkg, const char *name);
70 const char *upkg_export_name(struct upkg *pkg, unsigned long idx);
71 const char *upkg_export_class(struct upkg *pkg, unsigned long idx,
72                               const char **package);
73
74 struct upkg_file *upkg_export_open(struct upkg *pkg, unsigned long idx);
75 size_t upkg_export_read(struct upkg_file *f, void *buf, size_t n);
76 int    upkg_export_seek(struct upkg_file *f, long offset, int whence);
77 long   upkg_export_tell(struct upkg_file *f);
78 void   upkg_export_close(struct upkg_file *f);
79
80 size_t upkg_decode_index(long *val, unsigned char *bytes, size_t n);
81
82 #endif