char buf[BUFSIZ];
char buf[BUFSIZ+1] = {0};
xpmParseHeader(data)    xpmData *data;{    char buf[BUFSIZ];    int l, n = 0;    if (data->type) {	data->Bos = '\0';	data->Eos = '\n';	data->Bcmt = data->Ecmt = NULL;	l = xpmNextWord(data, buf, BUFSIZ);	if (l == 7 && !strncmp("#define", buf, 7)) {	    /* this maybe an XPM 1 file */	    char *ptr;	    l = xpmNextWord(data, buf, BUFSIZ);	    if (!l)		return (XpmFileInvalid);	    buf[l] = '\0';	    ptr = rindex(buf, '_');	    if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))		return XpmFileInvalid;	    /* this is definitely an XPM 1 file */	    data->format = 1;	    n = 1;			/* handle XPM1 as mainly XPM2 C */	} else {	    /*	     * skip the first word, get the second one, and see if this is	     * XPM 2 or 3	     */	    l = xpmNextWord(data, buf, BUFSIZ);	    if ((l == 3 && !strncmp("XPM", buf, 3)) ||		(l == 4 && !strncmp("XPM2", buf, 4))) {		if (l == 3)		    n = 1;		/* handle XPM as XPM2 C */		else {		    /* get the type key word */		    l = xpmNextWord(data, buf, BUFSIZ);		    /*		     * get infos about this type		     */		    while (xpmDataTypes[n].type			   && strncmp(xpmDataTypes[n].type, buf, l))			n++;		}		data->format = 0;	    } else		/* nope this is not an XPM file */		return XpmFileInvalid;	}	if (xpmDataTypes[n].type) {	    if (n == 0) {		/* natural type */		data->Bcmt = xpmDataTypes[n].Bcmt;		data->Ecmt = xpmDataTypes[n].Ecmt;		xpmNextString(data);	/* skip the end of the headerline */		data->Bos = xpmDataTypes[n].Bos;		data->Eos = xpmDataTypes[n].Eos;	    } else {		data->Bcmt = xpmDataTypes[n].Bcmt;		data->Ecmt = xpmDataTypes[n].Ecmt;		if (!data->format) {	/* XPM 2 or 3 */		    data->Bos = xpmDataTypes[n].Bos;		    data->Eos = '\0';		    /* get to the beginning of the first string */		    xpmNextString(data);		    data->Eos = xpmDataTypes[n].Eos;		} else			/* XPM 1 skip end of line */		    xpmNextString(data);	    }	} else	    /* we don't know about that type of XPM file... */	    return XpmFileInvalid;    }    return XpmSuccess;}