Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/bin/manifest_info.h
38767 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef _MANIFEST_INFO_H26#define _MANIFEST_INFO_H2728#include <sys/types.h>2930/*31* Zip file header signatures32*/33#define SIGSIZ 4 /* size of all header signatures */34#define LOCSIG 0x04034b50L /* "PK\003\004" */35#define EXTSIG 0x08074b50L /* "PK\007\008" */36#define CENSIG 0x02014b50L /* "PK\001\002" */37#define ENDSIG 0x06054b50L /* "PK\005\006" */3839#define ZIP64_ENDSIG 0x06064b50L /* "PK\006\006" */40#define ZIP64_LOCSIG 0x07064b50L /* "PK\006\007" */41/*42* Header sizes including signatures43*/44#define LOCHDR 3045#define EXTHDR 1646#define CENHDR 4647#define ENDHDR 224849#define ZIP64_ENDHDR 56 // ZIP64 end header size50#define ZIP64_LOCHDR 20 // ZIP64 end loc header size51#define ZIP64_EXTHDR 24 // EXT header size52#define ZIP64_EXTID 1 // Extra field Zip64 header ID5354#define ZIP64_MAGICVAL 0xffffffffLL55#define ZIP64_MAGICCOUNT 0xffff5657/*58* Header field access macros59*/60#define CH(b, n) (((unsigned char *)(b))[n])61#define SH(b, n) (CH(b, n) | (CH(b, n+1) << 8))62#define LG(b, n) ((SH(b, n) | (SH(b, n+2) << 16)) &0xffffffffUL)63#define LL(b, n) (((jlong)LG(b, n)) | (((jlong)LG(b, n+4)) << 32))64#define GETSIG(b) LG(b, 0)6566/*67* Macros for getting local file (LOC) header fields68*/69#define LOCVER(b) SH(b, 4) /* version needed to extract */70#define LOCFLG(b) SH(b, 6) /* general purpose bit flags */71#define LOCHOW(b) SH(b, 8) /* compression method */72#define LOCTIM(b) LG(b, 10) /* modification time */73#define LOCCRC(b) LG(b, 14) /* crc of uncompressed data */74#define LOCSIZ(b) LG(b, 18) /* compressed data size */75#define LOCLEN(b) LG(b, 22) /* uncompressed data size */76#define LOCNAM(b) SH(b, 26) /* filename length */77#define LOCEXT(b) SH(b, 28) /* extra field length */7879/*80* Macros for getting extra local (EXT) header fields81*/82#define EXTCRC(b) LG(b, 4) /* crc of uncompressed data */83#define EXTSIZ(b) LG(b, 8) /* compressed size */84#define EXTLEN(b) LG(b, 12) /* uncompressed size */8586/*87* Macros for getting central directory header (CEN) fields88*/89#define CENVEM(b) SH(b, 4) /* version made by */90#define CENVER(b) SH(b, 6) /* version needed to extract */91#define CENFLG(b) SH(b, 8) /* general purpose bit flags */92#define CENHOW(b) SH(b, 10) /* compression method */93#define CENTIM(b) LG(b, 12) /* modification time */94#define CENCRC(b) LG(b, 16) /* crc of uncompressed data */95#define CENSIZ(b) LG(b, 20) /* compressed size */96#define CENLEN(b) LG(b, 24) /* uncompressed size */97#define CENNAM(b) SH(b, 28) /* length of filename */98#define CENEXT(b) SH(b, 30) /* length of extra field */99#define CENCOM(b) SH(b, 32) /* file comment length */100#define CENDSK(b) SH(b, 34) /* disk number start */101#define CENATT(b) SH(b, 36) /* internal file attributes */102#define CENATX(b) LG(b, 38) /* external file attributes */103#define CENOFF(b) LG(b, 42) /* offset of local header */104105/*106* Macros for getting end of central directory header (END) fields107*/108#define ENDSUB(b) SH(b, 8) /* number of entries on this disk */109#define ENDTOT(b) SH(b, 10) /* total number of entries */110#define ENDSIZ(b) LG(b, 12) /* central directory size */111#define ENDOFF(b) LG(b, 16) /* central directory offset */112#define ENDCOM(b) SH(b, 20) /* size of zip file comment */113114/*115* Macros for getting Zip64 end of central directory header fields116*/117#define ZIP64_ENDLEN(b) LL(b, 4) /* size of zip64 end of central dir */118#define ZIP64_ENDVEM(b) SH(b, 12) /* version made by */119#define ZIP64_ENDVER(b) SH(b, 14) /* version needed to extract */120#define ZIP64_ENDNMD(b) LG(b, 16) /* number of this disk */121#define ZIP64_ENDDSK(b) LG(b, 20) /* disk number of start */122#define ZIP64_ENDTOD(b) LL(b, 24) /* total number of entries on this disk */123#define ZIP64_ENDTOT(b) LL(b, 32) /* total number of entries */124#define ZIP64_ENDSIZ(b) LL(b, 40) /* central directory size in bytes */125#define ZIP64_ENDOFF(b) LL(b, 48) /* offset of first CEN header */126127/*128* Macros for getting Zip64 end of central directory locator fields129*/130#define ZIP64_LOCDSK(b) LG(b, 4) /* disk number start */131#define ZIP64_LOCOFF(b) LL(b, 8) /* offset of zip64 end */132#define ZIP64_LOCTOT(b) LG(b, 16) /* total number of disks */133134/*135* A comment of maximum length of 64kb can follow the END record. This136* is the furthest the END record can be from the end of the file.137*/138#define END_MAXLEN (0xFFFF + ENDHDR)139140/*141* Supported compression methods.142*/143#define STORED 0144#define DEFLATED 8145146/*147* Information from the CEN entry to inflate a file.148*/149typedef struct zentry { /* Zip file entry */150size_t isize; /* size of inflated data */151size_t csize; /* size of compressed data (zero if uncompressed) */152jlong offset; /* position of compressed data */153int how; /* compression method (if any) */154} zentry;155156/*157* Information returned from the Manifest file by the ParseManifest() routine.158* Certainly (much) more could be returned, but this is the information159* currently of interest to the C based Java utilities (particularly the160* Java launcher).161*/162typedef struct manifest_info { /* Interesting fields from the Manifest */163char *manifest_version; /* Manifest-Version string */164char *main_class; /* Main-Class entry */165char *jre_version; /* Appropriate J2SE release spec */166char jre_restrict_search; /* Restricted JRE search */167char *splashscreen_image_file_name; /* splashscreen image file */168} manifest_info;169170/*171* Attribute closure to provide to manifest_iterate.172*/173typedef void (*attribute_closure)(const char *name, const char *value,174void *user_data);175176/*177* Function prototypes.178*/179int JLI_ParseManifest(char *jarfile, manifest_info *info);180void *JLI_JarUnpackFile(const char *jarfile, const char *filename,181int *size);182void JLI_FreeManifest(void);183int JLI_ManifestIterate(const char *jarfile, attribute_closure ac,184void *user_data);185186#endif /* _MANIFEST_INFO_H */187188189