#define HELPTEXT \ " Copy files to stdout with all but the first header removed.\n\
\n\
-x Don't write a header.\n\
In the absence of -x, a header is written if\n\
there is one in the first input file.\n\
\n\
-v Summarize to stderr.\n"
static FILE*
openfile_head(char *filename, char **header) /* Open the file for reading and return a FILE*. If open fails, or the header is malformed, write a message and return NULL. Set *header to point to the header string (statically allocated).
A filename of NULL or "-" means stdin. */
{ int c,i; char *actname;
FILE *f;
DYNALLSTAT(char,head,head_sz);
if (filename == NULL || strcmp(filename,"-") == 0)
{
f = stdin;
actname = "stdin";
} else
{
f = fopen(filename,"r");
actname = filename;
}
if (f == NULL)
{
fprintf(stderr,">E catg: can't open file %s\n",actname); return NULL;
}
DYNALLOC1(char,head,head_sz,100,"catg");
c = getc(f); if (c == '>')
{
i = 0;
head[i++] = (char)c;
c = getc(f); if (c != '>')
{
fprintf(stderr,">E catg: bad header in %s\n",actname);
fclose(f); return NULL;
}
head[i++] = (char)c;
do
{
c = getc(f); if (c == EOF)
{
fprintf(stderr,">E catg: bad header in %s\n",actname);
fclose(f); return NULL;
}
if (i >= head_sz-1)
DYNREALLOC(char,head,head_sz,head_sz+100,"catg");
head[i++] = (char)c;
} while (c != '<' || head[i-2] != '<');
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.