ftp.nice.ch/pub/next/unix/audio/cmusic.bs.N.tar.gz#/src/lib/libprocom/SCCS/s.addprop.c

This is s.addprop.c in view mode; [Download] [Up]

h33617
s 00000/00000/00049
d D 1.2 85/11/26 23:00:30 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 00049/00000/00000
d D 1.1 85/11/25 09:56:21 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>
#include <carl/defaults.h>

/*
 * addprop - add property on file's property list
 *	inserts the property before TAIL
 * takes:
 * 	iop - pointer to open file descriptor
 * 	name - name of property
 * 	value - value associated to that name
 * side effects:
 *	same as for putprop
 */

addprop(iop, name, value)
	FILE *iop; 
	char *name, *value;
{
	register struct fltbuf *f;
	register PROP *cpl, *opl, *pl;

	if (iop == NULL || name == NULL || value == NULL)
		return(-1);

	f = &fb[fileno(iop)];

	if (f->prop == NO_HEADER) {
		if (putprop(iop, H_HEAD, REV_LEVEL) != 0)
			return(-1);
		if (putprop(iop, name, value) != 0)
			return(-1);
		if (putprop(iop, H_TAIL, REV_LEVEL) != 0)
			return(-1);
	} else {
		if ((cpl = getpaddr(iop, H_TAIL)) == NULL)
			return(-1);
		if ((pl = mkprop(name, value)) == NULL)
			return(-1);
		cpl->lastprop->nextprop = pl;
		pl->lastprop = cpl->lastprop;
		cpl->lastprop = pl;
		pl->nextprop = cpl;
	}
	return(0);
}
E 1

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.