1 /*
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
571 #endif
572 )) == -1) {
573 return (-1);
574 }
575 info->manifest_version = NULL;
576 info->main_class = NULL;
577 info->jre_version = NULL;
578 info->jre_restrict_search = 0;
579 info->splashscreen_image_file_name = NULL;
580 if (rc = find_file(fd, &entry, manifest_name) != 0) {
581 close(fd);
582 return (-2);
583 }
584 manifest = inflate_file(fd, &entry, NULL);
585 if (manifest == NULL) {
586 close(fd);
587 return (-2);
588 }
589 lp = manifest;
590 while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
591 if (JLI_StrCaseCmp(name, "Manifest-Version") == 0)
592 info->manifest_version = value;
593 else if (JLI_StrCaseCmp(name, "Main-Class") == 0)
594 info->main_class = value;
595 else if (JLI_StrCaseCmp(name, "JRE-Version") == 0)
596 info->jre_version = value;
597 else if (JLI_StrCaseCmp(name, "JRE-Restrict-Search") == 0) {
598 if (JLI_StrCaseCmp(value, "true") == 0)
599 info->jre_restrict_search = 1;
600 } else if (JLI_StrCaseCmp(name, "Splashscreen-Image") == 0) {
601 info->splashscreen_image_file_name = value;
602 }
603 }
604 close(fd);
605 if (rc == 0)
606 return (0);
607 else
608 return (-2);
609 }
610
611 /*
612 * Opens the jar file and unpacks the specified file from its contents.
613 * Returns NULL on failure.
614 */
615 void *
616 JLI_JarUnpackFile(const char *jarfile, const char *filename, int *size) {
617 int fd;
618 zentry entry;
619 void *data = NULL;
|
1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
571 #endif
572 )) == -1) {
573 return (-1);
574 }
575 info->manifest_version = NULL;
576 info->main_class = NULL;
577 info->jre_version = NULL;
578 info->jre_restrict_search = 0;
579 info->splashscreen_image_file_name = NULL;
580 if (rc = find_file(fd, &entry, manifest_name) != 0) {
581 close(fd);
582 return (-2);
583 }
584 manifest = inflate_file(fd, &entry, NULL);
585 if (manifest == NULL) {
586 close(fd);
587 return (-2);
588 }
589 lp = manifest;
590 while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
591 if (JLI_StrCaseCmp(name, "Manifest-Version") == 0) {
592 info->manifest_version = value;
593 } else if (JLI_StrCaseCmp(name, "Main-Class") == 0) {
594 info->main_class = value;
595 } else if (JLI_StrCaseCmp(name, "JRE-Version") == 0) {
596 /*
597 * Manifest specification overridden by command line option
598 * so we will silently override there with no specification.
599 */
600 info->jre_version = 0;
601 } else if (JLI_StrCaseCmp(name, "Splashscreen-Image") == 0) {
602 info->splashscreen_image_file_name = value;
603 }
604 }
605 close(fd);
606 if (rc == 0)
607 return (0);
608 else
609 return (-2);
610 }
611
612 /*
613 * Opens the jar file and unpacks the specified file from its contents.
614 * Returns NULL on failure.
615 */
616 void *
617 JLI_JarUnpackFile(const char *jarfile, const char *filename, int *size) {
618 int fd;
619 zentry entry;
620 void *data = NULL;
|