info->splashscreen_image_file_name = value;
}
}
close(fd);
if (rc == 0)
return (0);
else
return (-2);
}
/*
* Opens the jar file and unpacks the specified file from its contents.
* Returns NULL on failure.
*/
void *
JLI_JarUnpackFile(const char *jarfile, const char *filename, int *size) {
int fd;
zentry entry;
void *data = NULL;
fd = open(jarfile, O_RDONLY
#ifdef O_BINARY
| O_BINARY /* use binary mode on windows */
#endif
);
if (fd != -1 && find_file(fd, &entry, filename) == 0) {
data = inflate_file(fd, &entry, size);
}
close(fd);
return (data);
}
/*
* Specialized "free" function.
*/
void
JLI_FreeManifest()
{
if (manifest)
free(manifest);
}
/*
* Iterate over the manifest of the specified jar file and invoke the provided
* closure function for each attribute encountered.
*
* Error returns are as follows:
* 0 Success
* -1 Unable to open jarfile
* -2 Error accessing the manifest from within the jarfile (most likely
* this means a manifest is not present, or it isn't a valid zip/jar file).
*/
int
JLI_ManifestIterate(const char *jarfile, attribute_closure ac, void *user_data)
{
int fd;
zentry entry;
char *mp; /* manifest pointer */
char *lp; /* pointer into manifest, updated during iteration */
char *name;
char *value;
int rc;
if ((fd = open(jarfile, O_RDONLY
#ifdef O_BINARY
| O_BINARY /* use binary mode on windows */
#endif
)) == -1)
return (-1);
if (rc = find_file(fd, &entry, manifest_name) != 0) {
close(fd);
return (-2);
}
mp = inflate_file(fd, &entry, NULL);
if (mp == NULL) {
close(fd);
return (-2);
}
lp = mp;
while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
(*ac)(name, value, user_data);
}
free(mp);
close(fd);
if (rc == 0)
return (0);
else
return (-2);
}
=6=
THE END |