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

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

h33128
s 00000/00000/00051
d D 1.2 85/11/26 23:01:35 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 00051/00000/00000
d D 1.1 85/11/25 09:58:09 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/defaults.h>
#include <carl/carl.h>
#include <carl/procom.h>

/*
 * fputsbuf - put buffer of shortsams
 * takes:
 * 	sp - pointer to a buffer of shorts
 *	n - number of shorts
 * 	iop - file descriptor
 * returns:
 * 	count of shorts written
 * 	-1 on errors
 * 	0 if no output
 * side effects:
 * 	sets up buffer for samples
 * 	if a header is present, it is written.
 */

fputsbuf(sp, n, iop)
	short *sp;
	short n;
	FILE *iop;
{
	register struct fltbuf *fbp;
	register short i;
	register short *sx;

	fbp = &fb[fileno(iop)];		/* get fid buffer pointer */
	if (fbp->gpflt == 0) {		/* first time? */
		set_sample_size(sizeof(short));
		if (pinit(iop))		/* make sure everything is set up */
			return(-1);
	}

	sx = (short *) fbp->fbuf;
	for (i = 0; i < n; i++) {
		if (fbp->pos >= fbp->bufsiz) {
			fbp->n = write(fileno(iop), sx, P_BUFSIZE);
			if (fbp->n <= 0)
				return(fbp->n);
			fbp->n /= fbp->ssize;
			fbp->pos = 0;
		}
		sx[fbp->pos++] = *sp++;
	}
	return(n);
}
E 1

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