File:  [Research Unix] / researchv9 / jtools / src / sunlib / muxbuf.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

#include "jerq.h"
#ifdef SUNTOOLS
static char *buffile = "/tmp/muxbuf";
#include <sys/file.h>
#endif SUNTOOLS

typedef struct String{
	char *s;	/* pointer to string */
	short n;	/* number used, no terminal null */
	short size;	/* size of allocated area */
} String;

getmuxbuf (pmb)
String *pmb;
{
	char *ans;
	int n;

#ifdef X11
	ans = XFetchBytes(dpy, &n);
#endif X11
#ifdef SUNTOOLS
#define BSIZE 4096
	char buffer[BSIZE];
	int fd;

	fd = open(buffile, O_RDONLY);
	if (fd < 0)
		return;
	n = read(fd, buffer, BSIZE);
	close(fd);
	if (n < 0)
		return;
	ans = buffer;
#endif SUNTOOLS
	if (pmb->size < (n+1)) {
		pmb->size = n+1;
		gcalloc(pmb->size, &(pmb->s));
	}
	pmb->n = n;
	strncpy(pmb->s, ans, n+1);
#ifdef X11
	free(ans);
#endif X11
}

setmuxbuf(pmb)
String *pmb;
{
#ifdef X11
	XStoreBytes(dpy, pmb->s, pmb->n);
#endif X11
#ifdef SUNTOOLS
	int fd = open(buffile, O_WRONLY|O_CREAT|O_TRUNC, 0666);
	if (fd < 0)
		return;
	write(fd, pmb->s, pmb->n);
	close(fd);
#endif SUNTOOLS
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.