Example #1
0
int Meta::gmarker (void *p, double c, double r, int color, int type)
{	if (!Active) return 1;
	commandwrite(20);
	longwrite(c); longwrite(r);
	shortwrite(color); shortwrite(type);
    return 1;
}
Example #2
0
int Meta::gvutext (void *p, double c, double r, char *text, int color, int alignment)
{	if (!Active) return 1;
	commandwrite(42); longwrite(c);
	longwrite(r); shortwrite(color); shortwrite(alignment);
	stringwrite(text);
    return 1;
}
Example #3
0
int Meta::gbar1 (void *p, double c, double r, double c1, double r1,
	int color, int style)
{	if (!Active) return 1;
	commandwrite(33);
	longwrite(c); longwrite(r);
	longwrite(c1); longwrite(r1);
	shortwrite(color);
	shortwrite(style);
    return 1;
}
Example #4
0
int Meta::gline (void *p, double c, double r, double c1, double r1, int color,
	int st, int width)
{   if (!Active) return 1;
	if (fabs(r)>10000.0) return 0;
	if (fabs(c)>10000.0) return 0;
	if (fabs(r1)>10000.0) return 0;
	if (fabs(c1)>10000.0) return 0;
	commandwrite(10);
	longwrite(c); longwrite(r); longwrite(c1); longwrite(r1);
	shortwrite(color); shortwrite(st); shortwrite(width);
    return 1;
}
Example #5
0
int Meta::gfill (void *p, double c[], int st, int n, int connect[])
{	if (!Active) return 1;
	int i;
	for (i=0; i<2*n; i++) if (fabs(c[i])>10000.0) return 0;
	commandwrite(30);
	shortwrite(n);
	for (i=0; i<n; i++)
	{	longwrite(c[2*i]); longwrite(c[2*i+1]);
		shortwrite(connect[i]);
	}
	shortwrite(st);
    return 1;
}
Example #6
0
int Meta::gfillh (void *p, double c[8], double hue, int color, int connect)
{	if (!Active) return 1;
	int i;
	for (i=0; i<8; i++) if (fabs(c[i])>10000.0) return 0;
	hue-=floor(hue);
	commandwrite(31);
	for (i=0; i<8; i+=2)
	{	longwrite(c[i]); longwrite(c[i+1]);
	}
	longwrite(hue);
	shortwrite(color); shortwrite(connect);
    return 1;
}
Example #7
0
int Meta::gclip (void *p, double c, double r, double c1, double r1)
{
	if (!Active) return 1;
	if (fabs(r)>10000.0) return 0;
	if (fabs(c)>10000.0) return 0;
	if (fabs(r1)>10000.0) return 0;
	if (fabs(c1)>10000.0) return 0;
	commandwrite(2);
	longwrite(c);
	longwrite(r);
	longwrite(c1);
	longwrite(r1);
	return 1;
}
Example #8
0
static	void	page_out(VMHEAD	HUGE *h)
{
	FNAME(page_out);

	if (!(h->type &	MT_MEMORY))
		error(fun, "not MT_MEMORY");
	if (h->type & MT_FREEZE)
		error(fun, "can't page out frozen memory");
	if (h->type & MT_DIRTY)	 {
		if (h->diskadd == -1L)
			h->diskadd = disk_next((long) h->size, h->mem);
		else  {
			if (-1L	== lseek(DMhandle, h->diskadd, SEEK_SET))
				error(fun, "lseek");
			if (h->size != longwrite(DMhandle, h->mem, (long) h->size))
				error(fun, "write");
		}
	}
	rmfree((RMHEAD_PTR) h->mem, h->size);
	h->type	= MT_DISK;
	VMlive--;
	VMdisk++;
	VM_newadd = 1;
}
Example #9
0
int Meta::gscale (void *p, double s)
{	if (!Active) return 1;
	commandwrite(50);
	longwrite(s*1000);
    return 1;
}
Example #10
0
static	long	disk_next(long s, char HUGE *buf)
{
	/* variable prefix:  b=best,  c=current	 */
	/* variable suffix:  a=address,	s=size,	i=index	 */

	register int	ci, bi;
	long	bs, cs,	da = -1L;
	DFREE HUGE *ca, HUGE *ba;
	int	rtf = 1;
	FNAME(disk_next);

retry:
	if (DMnfree >= s) {
		bi = -1;
		bs = 0L;
		ca = DMflist;
		for ( ;	ca  &&	bs != s	; ca = ca->next)
			for (ci=0 ; ci != DHEADSIZE  ; ++ci)
				if ((cs=ca->nfree[ci]) == s)  {
					bi = ci;
					bs = cs;
					ba = ca;
					break;
				}  else	if (cs > s  &&	(cs < bs || bi == -1))	{
					bi = ci;
					bs = cs;
					ba = ca;
				}
		if (bs >= s)  {
			da = ba->diskaddr[bi];
			DMnfree	-= s;
			if (bs == s)  {
				DMnfblks--;
				ba->diskaddr[bi] = -1L;
			}  else
				ba->diskaddr[bi] += s;
			ba->nfree[bi] -= s;
		}
	}
	if (da == -1L)	{
		long	sw;

		if (-1L	== lseek(DMhandle, 0L, SEEK_END))
			error(fun, "lseek");
		if ((long) s != (sw = longwrite(DMhandle, buf, (long) s)))

/*  by checking	DMflist	I know that d_compact1 will not	rmalloc	which is something disk_next must NEVER	do */

			if (rtf	 &&  DMflist)  {
				long	ta = DMnext;
				int	add;

				if (sw != -1L)  {
					DMnext += sw;
					add = free_disk((MAX_SIZ_TYP) sw, ta, 1);
				}
				d_compact1();
				if (sw != -1L  &&  add)
					if (free_disk((MAX_SIZ_TYP) sw,	ta, 1))
						error(fun, "internal");
				rtf = 0;
				goto retry;
			}  else
				error(fun, "write");
		DMneedflg = 1;	/* I had to extend the swap file to meet system	needs  */
		da = DMnext;
		DMnext += s;
	}  else	 {
		DMneedflg = 0;	/* no need to extend swap file	*/
		if (-1L	== lseek(DMhandle, da, SEEK_SET))
			error(fun, "lseek");
		if ((long) s != longwrite(DMhandle, buf, (long) s))
			error(fun, "write");
	}
	return(da);
}
Example #11
0
int	VM_dump(char *f)
{
	short	mb;
	register int	i, b;
	int	h, s = (sizeof(VMHEAD) * VMLEGSIZ);
#ifdef NO_ALLOCA
	char	dbuf[NO_ALLOCA];
	unsigned	bufsiz = NO_ALLOCA;
#else
	char	*dbuf;
	unsigned	bufsiz = 2048;
#endif
	VMHEAD	HUGE *v;
	FNAME(VM_dump);

	TEST(fun, 0);
	h = OPEN(f, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, S_IREAD | S_IWRITE);
	if (h == -1)		return(1);
#ifndef NO_ALLOCA
	while (NULL == (dbuf = alloca(bufsiz)))
		bufsiz /= 2;
#endif
	if (sizeof(VMfree) != write(h, (char *)	&VMfree, sizeof(VMfree)))
		goto er2;

	for (mb=0 ; mb != VMBASESIZ  &&	 VMbase[mb] ; ++mb);
	if (sizeof(mb) != write(h, (char *) &mb, sizeof(mb)))
		goto er2;
	for (i=0 ; i !=	mb ; ++i)
		if (s != write(h, (char	HUGE *) VMbase[i], s))
			goto er2;
	for (b=0 ; b !=	mb ; ++b)  {
		v = VMbase[b];
		for (i=b?0:1 ; i != VMLEGSIZ  ;	++i)  {
			if (v[i].type &	MT_MEMORY)  {
				if ((long) v[i].size != longwrite(h, v[i].mem, (long) v[i].size))
					goto er2;
			}  else	 if (v[i].type & MT_DISK  &&  v[i].diskadd != -1L)  {
				unsigned int n = bufsiz	< v[i].size ? bufsiz : v[i].size;
				MAX_SIZ_TYP	m = v[i].size;

				if (-1L	== lseek(DMhandle, v[i].diskadd, SEEK_SET))
					error(fun, "lseek");
				while (m)  {
					n = n >	m ? m :	n;
					if (n != read(DMhandle,	dbuf, n))
						error(fun, "read");
					if (n != write(h, dbuf,	n))
						goto er2;
					m -= n;
				}
			}
		}
	}
	if (-1 == close(h))
		error(fun, "close");
	TEST(fun, 1);
	return(0);
er2:
	if (-1 == close(h))
		error(fun, "close");
	if (-1 == unlink(f))
		error(fun, "unlink");
	TEST(fun, 2);
	return(2);		/*  write error	*/
}