jdk/src/share/bin/manifest_info.h
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef _MANIFEST_INFO_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define _MANIFEST_INFO_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include <sys/types.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Zip file header signatures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#define SIGSIZ 4                    /* size of all header signatures */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#define LOCSIG 0x04034b50L          /* "PK\003\004" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#define EXTSIG 0x08074b50L          /* "PK\007\008" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#define CENSIG 0x02014b50L          /* "PK\001\002" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#define ENDSIG 0x06054b50L          /* "PK\005\006" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * Header sizes including signatures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define LOCHDR 30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define EXTHDR 16
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define CENHDR 46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#define ENDHDR 22
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * Header field access macros
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define CH(b, n) (((unsigned char *)(b))[n])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define SH(b, n) (CH(b, n) | (CH(b, n+1) << 8))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define LG(b, n) (SH(b, n) | (SH(b, n+2) << 16))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define GETSIG(b) LG(b, 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * Macros for getting local file (LOC) header fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define LOCVER(b) SH(b, 4)          /* version needed to extract */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
#define LOCFLG(b) SH(b, 6)          /* general purpose bit flags */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
#define LOCHOW(b) SH(b, 8)          /* compression method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
#define LOCTIM(b) LG(b, 10)         /* modification time */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
#define LOCCRC(b) LG(b, 14)         /* crc of uncompressed data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#define LOCSIZ(b) LG(b, 18)         /* compressed data size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
#define LOCLEN(b) LG(b, 22)         /* uncompressed data size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#define LOCNAM(b) SH(b, 26)         /* filename length */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
#define LOCEXT(b) SH(b, 28)         /* extra field length */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * Macros for getting extra local (EXT) header fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
#define EXTCRC(b) LG(b, 4)          /* crc of uncompressed data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
#define EXTSIZ(b) LG(b, 8)          /* compressed size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#define EXTLEN(b) LG(b, 12)         /* uncompressed size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * Macros for getting central directory header (CEN) fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
#define CENVEM(b) SH(b, 4)          /* version made by */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#define CENVER(b) SH(b, 6)          /* version needed to extract */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#define CENFLG(b) SH(b, 8)          /* general purpose bit flags */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
#define CENHOW(b) SH(b, 10)         /* compression method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
#define CENTIM(b) LG(b, 12)         /* modification time */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
#define CENCRC(b) LG(b, 16)         /* crc of uncompressed data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
#define CENSIZ(b) LG(b, 20)         /* compressed size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
#define CENLEN(b) LG(b, 24)         /* uncompressed size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#define CENNAM(b) SH(b, 28)         /* length of filename */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#define CENEXT(b) SH(b, 30)         /* length of extra field */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
#define CENCOM(b) SH(b, 32)         /* file comment length */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
#define CENDSK(b) SH(b, 34)         /* disk number start */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
#define CENATT(b) SH(b, 36)         /* internal file attributes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
#define CENATX(b) LG(b, 38)         /* external file attributes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
#define CENOFF(b) LG(b, 42)         /* offset of local header */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * Macros for getting end of central directory header (END) fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
#define ENDSUB(b) SH(b, 8)          /* number of entries on this disk */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
#define ENDTOT(b) SH(b, 10)         /* total number of entries */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
#define ENDSIZ(b) LG(b, 12)         /* central directory size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
#define ENDOFF(b) LG(b, 16)         /* central directory offset */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
#define ENDCOM(b) SH(b, 20)         /* size of zip file comment */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * A comment of maximum length of 64kb can follow the END record. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * is the furthest the END record can be from the end of the file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
#define END_MAXLEN      (0xFFFF + ENDHDR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * Supported compression methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
#define STORED      0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
#define DEFLATED    8
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * Information from the CEN entry to inflate a file.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
typedef struct zentry { /* Zip file entry */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    size_t      isize;  /* size of inflated data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    size_t      csize;  /* size of compressed data (zero if uncompressed) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    off_t       offset; /* position of compressed data */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    int         how;    /* compression method (if any) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
} zentry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * Information returned from the Manifest file by the ParseManifest() routine.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * Certainly (much) more could be returned, but this is the information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * currently of interest to the C based Java utilities (particularly the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * Java launcher).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
typedef struct manifest_info {  /* Interesting fields from the Manifest */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    char        *manifest_version;      /* Manifest-Version string */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    char        *main_class;            /* Main-Class entry */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    char        *jre_version;           /* Appropriate J2SE release spec */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    char        jre_restrict_search;    /* Restricted JRE search */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    char        *splashscreen_image_file_name; /* splashscreen image file */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
} manifest_info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * Attribute closure to provide to manifest_iterate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
typedef void (*attribute_closure)(const char *name, const char *value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        void *user_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * Function prototypes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
int     JLI_ParseManifest(char *jarfile, manifest_info *info);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
void    *JLI_JarUnpackFile(const char *jarfile, const char *filename,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                int *size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
void    JLI_FreeManifest(void);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
int     JLI_ManifestIterate(const char *jarfile, attribute_closure ac,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                void *user_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
#endif  /* _MANIFEST_INFO_H */