PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|launcher|parse_manifest.c =

page 6 of 6



            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

1|2|3|4|5| < PREV = PAGE 6 =

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 

E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.010679 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)