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

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

page 4 of 6



	/*
	 * Check if the name is the droid we are looking for; the jar file
	 * manifest.  If so, build the entry record from the data found in
	 * the header located and return success.
	 */
        if (CENNAM(p) == strlen(file_name) &&
          memcmp((p + CENHDR), file_name, strlen(file_name)) == 0) {
	    if (lseek(fd, base_offset + CENOFF(p), SEEK_SET) < (off_t)0)
		return (-1);
	    if (read(fd, locbuf, LOCHDR) < 0)
		return (-1);
	    if (GETSIG(locbuf) != LOCSIG)
		return (-1);
	    entry->isize = CENLEN(p);
	    entry->csize = CENSIZ(p);
	    entry->offset = base_offset + CENOFF(p) + LOCHDR +
		LOCNAM(locbuf) + LOCEXT(locbuf);
	    entry->how = CENHOW(p);
	    return (0);
	}

	/*
	 * Point to the next entry and decrement the count of valid remaining
	 * bytes.
	 */
	bytes -= entry_size;
	p += entry_size;
    }

    return (-1);	/* Fell off the end the loop without a Manifest */
}

/*
 * Parse a Manifest file header entry into a distinct "name" and "value".
 * Continuation lines are joined into a single "value". The documented
 * syntax for a header entry is:
 *
 *	header: name ":" value
 *
 *	name: alphanum *headerchar
 *
 *	value: SPACE *otherchar newline *continuation
 *
 *	continuation: SPACE *otherchar newline
 *
 *	newline: CR LF | LF | CR (not followed by LF)
 *
 *	alphanum: {"A"-"Z"} | {"a"-"z"} | {"0"-"9"}
 *
 *	headerchar: alphanum | "-" | "_"
 *
 *	otherchar: any UTF-8 character except NUL, CR and LF
 *
 * Note that a manifest file may be composed of multiple sections,
 * each of which may contain multiple headers.
 *
 *	section: *header +newline
 *
 *	nonempty-section: +header +newline
 *
 * (Note that the point of "nonempty-section" is unclear, because it isn't
 * referenced elsewhere in the full specification for the Manifest file.)
 *
 * Arguments:
 *	lp	pointer to a character pointer which points to the start
 *		of a valid header.
 *	name	pointer to a character pointer which will be set to point
 *		to the name portion of the header (nul terminated).
 *	value	pointer to a character pointer which will be set to point
 *		to the value portion of the header (nul terminated).
 *
 * Returns:
 *    1	Successful parsing of an NV pair.  lp is updated to point to the
 *	next character after the terminating newline in the string
 *	representing the Manifest file. name and value are updated to
 *	point to the strings parsed.
 *    0 A valid end of section indicator was encountered.  lp, name, and
 *	value are not modified.
 *   -1 lp does not point to a valid header. Upon return, the values of
 *      lp, name, and value are undefined.
 */
static int
parse_nv_pair(char **lp, char **name, char **value)
{
    char    *nl;
    char    *cp;

    /*
     * End of the section - return 0. The end of section condition is
     * indicated by either encountering a blank line or the end of the
     * Manifest "string" (EOF).
     */
    if (**lp == '\0' || **lp == '\n' || **lp == '\r')
	return (0);

    /*
     * Getting to here, indicates that *lp points to an "otherchar".
     * Turn the "header" into a string on its own.
     */
    nl = strpbrk(*lp, "\n\r");
=4=

1|2|3| < PREV = PAGE 4 = NEXT > |5|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.00986409 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)