/*
* upkg: tool for manipulating Unreal Tournament packages.
- * Copyright (C) 2009 Nick Bowler
+ * Copyright © 2009-2011 Nick Bowler
*
- * This program is free software; you can redistribute it and/or modify
+ * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UPKG_H_
#define UPKG_HDR_MAGIC 0x9e2a83c1
#define UPKG_HDR_SIZE 36
+struct upkg_file_ops {
+ size_t (*read)(void *buf, size_t size, void *handle);
+ int (*seek)(void *handle, long offset, int whence);
+ long (*tell)(void *handle);
+ int (*eof) (void *handle);
+};
+
struct upkg {
unsigned version, license;
unsigned char guid[16];
unsigned long flags;
unsigned long name_count, export_count, import_count;
+};
+
+struct upkg_export {
+ const struct upkg_export *parent;
+
+ const char *name;
+ unsigned long flags;
+ long class;
+};
+
+struct upkg_import {
+ const struct upkg_import *parent;
- struct upkg_private *priv;
+ const char *name;
+ const char *class_package, *class_name;
};
struct upkg_file {
unsigned long base, offset, len;
};
+/* Default I/O operations for ordinary files. */
+extern const struct upkg_file_ops upkg_default_fops;
+
+struct upkg *upkg_open(void *handle, const struct upkg_file_ops *fops,
+ int (*destructor)(void *handle));
struct upkg *upkg_fopen(const char *path);
int upkg_close(struct upkg *pkg);
const char *upkg_get_name(struct upkg *pkg, unsigned long idx);
+const struct upkg_export *upkg_get_export(struct upkg *pkg, unsigned long idx);
+const struct upkg_import *upkg_get_import(struct upkg *pkg, unsigned long idx);
-long upkg_export_find(struct upkg *pkg, const char *name);
-
-unsigned long upkg_export_flags(struct upkg *pkg, unsigned long idx);
-const char *upkg_export_name(struct upkg *pkg, unsigned long idx);
-const char *upkg_export_class(struct upkg *pkg, unsigned long idx,
- const char **package);
+long upkg_export_find(struct upkg *pkg, long parent, const char *name);
struct upkg_file *upkg_export_open(struct upkg *pkg, unsigned long idx);
size_t upkg_export_read(struct upkg_file *f, void *buf, size_t n);
long upkg_export_tell(struct upkg_file *f);
void upkg_export_close(struct upkg_file *f);
-size_t upkg_decode_index(long *val, unsigned char *bytes, size_t n);
+size_t upkg_decode_index(long *val, const unsigned char *bytes, size_t n);
#endif