struct upkg_export_priv {
struct upkg_export pub;
- long class, super;
+ long super;
unsigned long size, offset;
};
while (index < pkg->pub.export_count) {
struct upkg_export_priv *export = &pkg->exports[index];
- unsigned long parent_index;
long tmp;
/* Read some data into buffer. */
}
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;
len += rc;
if (nbuf-len < 4) goto err;
- parent_index = unpack_32_le(buf+len);
+ tmp = unpack_s32_le(buf+len);
+ if (tmp < 0)
+ goto err;
len += 4;
export->pub.parent = NULL;
- if (parent_index > 0) {
- parent_index--;
- if (parent_index >= pkg->pub.export_count)
+ if (tmp > 0) {
+ tmp--;
+ if (tmp >= pkg->pub.export_count)
goto err;
- export->pub.parent = &pkg->exports[parent_index].pub;
+ export->pub.parent = &pkg->exports[tmp].pub;
}
rc = upkg_decode_index(&tmp, buf+len, nbuf-len);
return NULL;
}
+const struct upkg_import *upkg_get_import(struct upkg *pub, unsigned long idx)
+{
+ struct upkg_priv *pkg = (struct upkg_priv *)pub;
+
+ if (idx < pkg->pub.import_count)
+ return &pkg->imports[idx];
+ return NULL;
+}
+
const char *upkg_export_class(struct upkg *pub, unsigned long idx,
const char **package)
{
export = &pkg->exports[idx];
/* Assumption: class references are always imports. */
- format_assert(export->class <= 0, return NULL);
+ format_assert(export->pub.class <= 0, return NULL);
/* Get the class. */
- if (export->class == 0) {
+ if (export->pub.class == 0) {
if (package) *package = "Core";
return "Class";
}
- pkg_idx = -(export->class + 1);
+ pkg_idx = -(export->pub.class + 1);
if (pkg_idx >= pkg->pub.import_count)
return NULL;
iclass = &pkg->imports[pkg_idx];