manifest

manifest — Retrieving information from manifest files.

Synopsis


#include <jclass/manifest.h>


typedef     Manifest;
typedef     ManifestSection;
typedef     ManifestEntry;
Manifest*   jclass_manifest_new_from_buffer (const char *buf,
                                             uint32_t length);
void        jclass_manifest_free            (Manifest *manifest);
const char* jclass_manifest_get_entry       (Manifest *manifest,
                                             const char *section_name,
                                             const char *key);

Description

Manifest files are used in jar files to set various attributes for the jar file or individual classes.

Details

Manifest

typedef struct {
	int section_count;
	ManifestSection *sections;
} Manifest;

The top-level structure for a manifest. It contains the various sections for the manifest.


ManifestSection

typedef struct {
	char *name;
	int entry_count;
	ManifestEntry *entries;
} ManifestSection;

A section in a manifest typically represents attributes for a single class. The NULL section represents attributes for all classes and resources.


ManifestEntry

typedef struct {
	char *key;
	char *value;
} ManifestEntry;

A manifest entry is a key-value pair. The key is the name of the attribute and value is the value. The current parser is rather limited because it doesn't support multi-line values. Only the first line is returned.


jclass_manifest_new_from_buffer ()

Manifest*   jclass_manifest_new_from_buffer (const char *buf,
                                             uint32_t length);

Creates a Manifest struct representing the given memory buffer. If the length given is 0 it is assumed that the buffer is NULL terminated.

buf : A memory buffer containing a manifest file.
length : The length of the buffer in bytes. If the buffer is NULL terminated set to 0.
Returns : A Manifest struct or NULL if something went wrong.

jclass_manifest_free ()

void        jclass_manifest_free            (Manifest *manifest);

Frees the given manifest structure.

manifest : The manifest to free.

jclass_manifest_get_entry ()

const char* jclass_manifest_get_entry       (Manifest *manifest,
                                             const char *section_name,
                                             const char *key);

Gets the value of the given entry from a manifest.

manifest : The manifest to get the entry from.
section_name : The name of the section containing the entry or NULL for the main section.
key : The name of the entry.
Returns : A NULL terminated string you should not modify.