X-Git-Url: http://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/007a739d8b37ab00b749e72301f09f44e1c1cdeb..52c1b4699e8f5c396e3316a813d73de8075df97a:/src/libupkg.c diff --git a/src/libupkg.c b/src/libupkg.c index 6964ee2..ed652ac 100644 --- a/src/libupkg.c +++ b/src/libupkg.c @@ -1,21 +1,22 @@ /* - * upkg: tool for manipulating Unreal Tournament packages. - * Copyright © 2009-2011 Nick Bowler + * upkg: tool for manipulating Unreal Tournament packages. + * Copyright © 2009-2012, 2022 Nick Bowler * - * 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 3 of the License, or - * (at your option) any later version. + * 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 3 of the License, or + * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ +#include #include #include #include @@ -46,7 +47,7 @@ struct upkg_name { struct upkg_export_priv { struct upkg_export pub; - long class, super; + long super; unsigned long size, offset; }; @@ -282,7 +283,7 @@ static int pkg_init_exports(struct upkg_priv *pkg) } len = 0; - rc = upkg_decode_index(&export->class, buf+len, nbuf-len); + rc = upkg_decode_index(&export->pub.class, buf+len, nbuf-len); if (rc == 0) goto err; len += rc; @@ -533,47 +534,13 @@ const struct upkg_export *upkg_get_export(struct upkg *pub, unsigned long idx) return NULL; } -const char *upkg_export_class(struct upkg *pub, unsigned long idx, - const char **package) +const struct upkg_import *upkg_get_import(struct upkg *pub, unsigned long idx) { struct upkg_priv *pkg = (struct upkg_priv *)pub; - const struct upkg_import *iclass, *ipackage; - struct upkg_export_priv *export; - unsigned long pkg_idx; - if (idx >= pkg->pub.export_count) - return NULL; - - export = &pkg->exports[idx]; - - /* Assumption: class references are always imports. */ - format_assert(export->class <= 0, return NULL); - - /* Get the class. */ - if (export->class == 0) { - if (package) *package = "Core"; - return "Class"; - } - - pkg_idx = -(export->class + 1); - if (pkg_idx >= pkg->pub.import_count) - return NULL; - iclass = &pkg->imports[pkg_idx]; - - /* Assumption: class references are always Core.Class. */ - format_assert(!strcmp(iclass->class_package, "Core"), return NULL); - format_assert(!strcmp(iclass->class_name, "Class"), return NULL); - - ipackage = iclass->parent; - if (!ipackage) - return NULL; - - /* Assumption: package references are always Core.Package. */ - format_assert(!strcmp(ipackage->class_package, "Core"), return NULL); - format_assert(!strcmp(ipackage->class_name, "Package"), return NULL); - - if (package) *package = ipackage->name; - return iclass->name; + if (idx < pkg->pub.import_count) + return &pkg->imports[idx]; + return NULL; } struct upkg_file *upkg_export_open(struct upkg *pub, unsigned long idx)