This is s.putheader.c in view mode; [Download] [Up]
h64120
s 00000/00000/00070
d D 1.2 85/11/26 23:02:11 dgl 2 1
c eliminated LOOKED_ALREADY from getheader to cure bug
c re. trying to add property to stdin if no header exists yet.
e
s 00070/00000/00000
d D 1.1 85/11/25 09:59:27 dgl 1 0
c original version
e
u
U
f i
t
T
I 1
/* %M% %I% (CARL) %G% %U% */
#include <stdio.h>
#include <carl/carl.h>
#include <carl/procom.h>
/*
* putheader - write header on file
* side effects:
* sets fb[fileno(iop)]->prop == HAS_HEADER to indicate header sent.
* returns:
* 0 if header exists and is successfully written,
* -1 if no header, or error writing header is encountered.
*/
putheader(iop)
FILE *iop;
{
register PROP *p;
register struct fltbuf *f;
f = &fb[fileno(iop)];
if (f->prop == HAS_HEADER)
return(0); /* already accomplished */
else if (f->prop == NO_HEADER) {
/* fprintf(stderr, "putheader: no header to put\n"); */
return(-1); /* no header to put */
}
for (p = f->p; p != NULL; p = p->nextprop) {
if (wprop(p, iop) != 0)
return(-1);
}
/* signal putfc to finish header */
if (putfc(EOF, iop) != sizeof(char))
return(-1);
f->prop = HAS_HEADER; /* say we've sent header */
return(0);
}
/*
* wprop - write property on file
* returns:
* -1 if p or iop are NULL, or i/o error
* 0 on success
*/
wprop(p, iop)
struct proplist *p;
FILE *iop;
{
register char *c;
if (p->propname == NULL || p->propval == NULL)
return(-1);
for (c = p->propname; *c != NULL; c++) {
if (putfc(*c, iop) != sizeof(char))
return(-1);
}
if (putfc(NULL, iop) != sizeof(char))
return(-1);
for (c = p->propval; *c != NULL; c++) {
if (putfc(*c, iop) != sizeof(char))
return(-1);
}
if (putfc(NULL, iop) != sizeof(char))
return(-1);
return(0);
}
E 1
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.