DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T c

⟦ea86b0148⟧ TextFile

    Length: 4223 (0x107f)
    Types: TextFile
    Names: »c.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Empire/c.c« 

TextFile

#include <curses.h>
#include <ctype.h>

#include "c_common.h"

int	debug = 0;

FILE	*fileerr;

#undef move
move(y, x)
{
	if (debug) { fprintf(fileerr, "DEBUG: move to %d, %d\n", x, y); fflush(fileerr); }
	wmove(stdscr, y, x);
}

cr_()
{
	if (debug) { fprintf(fileerr, "DEBUG: newline\n"); fflush(fileerr); }
	addch('\n');
}

clreol_(linep, colp, eolcolp)
	int	*linep, *colp, *eolcolp;
{
	if (debug) { fprintf(fileerr, "DEBUG: clrtoeol\n"); fflush(fileerr); }
	move(*linep, *colp);
	clrtoeol();
}

csleep_(secs)
	int	*secs;
{
	sleep(*secs + 1);
}

clear_()
{
	if (debug) { fprintf(fileerr, "DEBUG: clear\n"); fflush(fileerr); }
	erase();
}

ttinit_()
{
	if (debug)
		fileerr = fopen("LOG", "w");
	initscr();
	noecho();
	crmode();
	lines_ = LINES;
	cols_ = COLS;
	if (lines_ > 64)
		lines_ = 64;
	if (cols_ > 110)
		cols_ = 110;
}

cflush_()
{
	if (debug) { fprintf(fileerr, "DEBUG: refresh\n"); fflush(fileerr); }
	refresh();
}

caddch_(c)
	char	*c;
{
	if (debug) { fprintf(fileerr, "DEBUG: addch - %x\n", *c); fflush(fileerr); }
	addch(*c);
}

bufout_(str, countp)
	char	*str;
	int	*countp;
{
	char	buf[BUFSIZ];

	if (debug) { fprintf(fileerr, "DEBUG: (%d) '%s'\n", *countp, str); fflush(fileerr); }
	strncpy(buf, str, *countp);
	buf[*countp] = '\0';
	addstr(buf);
}

tpos_(yp, xp)
	int	*yp, *xp;
{
	move(*yp - 1, *xp - 1);
}

#undef getstr
getstr_(buf, sizep, countp)
	char	*buf;
	int	*sizep, *countp;
{
	if (debug) { fprintf(fileerr, "DEBUG: getstr\n"); fflush(fileerr); }
	echo();
	getstrq_(buf, sizep, countp);
	noecho();
}

getstrq_(buf, sizep, countp)
	char	*buf;
	int	*sizep, *countp;
{
	int	count = 0;

	if (debug) { fprintf(fileerr, "DEBUG: getstrq\n"); fflush(fileerr); }

	fflush(stdout);		/* because the fortran routine did */
	nocrmode();
	if (fgets(buf, *sizep, stdin) == NULL) {
		fputs("Unexpected EOF", stderr);
		exit(1);
	} else {
		*countp = strlen(buf) - 1;
		buf[*countp] = '\0';
	}
	crmode();
}

encpri_(str, startp, endp)
	int	*str;
	int	*startp, *endp;
{
	int	i;
	char	buf[BUFSIZ], *bp = buf;

	if (debug) { fprintf(fileerr, "DEBUG: encpri(%c, %d, %d)\n", str[*startp], *startp, *endp); fflush(fileerr); }
	for (i = *startp - 1; i < *endp; i++, bp++)
		*bp = str[i];
	*bp = '\0';
	waddstr(stdscr, buf);
}

#define NUMTOPS		3

int	len[NUMTOPS];

topini_()
{
	int	i;

	for (i = 0; i < NUMTOPS; i++) {	
		len[i] = 0;
		move(i, 0);
		clrtoeol();
	}
}

topmsg_(linep, buf)
	int	*linep;
	char	*buf;
{
	if (*linep < 1 || *linep > NUMTOPS)
		*linep = 1;
	move(*linep - 1, 0);
	waddstr(stdscr, buf);
	clrtoeol();
	len[*linep] = strlen(buf);
}

addcnt_(linep, addp)
	int	*linep, *addp;
{
	if (*linep < 0 || *linep > NUMTOPS)
		*linep = 1;
	len[*linep] += *addp;
}

addint_(nump, buf, endp)
	int	*nump, *endp;
	char	*buf;
{
	sprintf(&buf[*endp], "%d", *nump);
	*endp = strlen(buf);
}

/* maybe add real?  */
addrel_(nump, widthp, buf, endp)
	int	*nump, *widthp, *endp;
	char	*buf;
{
	/* what's the width for?? */
	sprintf(&buf[*endp], "%d", *nump);
	*endp = strlen(buf);
}

rndini_()
{
	srand(time(0));
}

irand_(high)
	int	*high;
{
	if (*high < 2) {
		if (debug) { fprintf(fileerr, "DEBUG: irand %d\n", *high); fflush(fileerr); }
		return (0);
	}
	return (rand() % *high);
}

rndint_(retval, minp, maxp)
	int	*retval, *minp, *maxp;
{
	int	size = *maxp - *minp + 1;

	*retval = (rand() % size) + *minp;
}

addstr_(from, to, tolen)
	char	*from, *to;
	int	*tolen;
{
	to[*tolen] = '\0';
	strcat(to, from);
	*tolen = strlen(to);
}

getchx_()
{
	char	c;

	if (debug) { fprintf(fileerr, "DEBUG: getchx\n"); fflush(fileerr); }
	if ((c = getchar()) == EOF) {
		fputs("Unexpected EOF\n", stderr);
		exit(1);
	}
	if (islower(c))
		return (toupper(c));
	else
		return (c);
}

readi_(ip)
	int	*ip;
{
	char	buf[BUFSIZ];
	int	size = sizeof (buf), count = sizeof (buf);

	if (debug) { fprintf(fileerr, "DEBUG: readi\n"); fflush(fileerr); }
	*ip = 0;
	getstr_(buf, &size, &count);
	if (count != 0)
		scanf("%d", ip);
}

tupper_(str, lenp)
	char	*str;
	int	*lenp;
{
	int	i;

	for (i = 0; i < *lenp; i++)
		if (islower(str[i]))
			str[i] = toupper(str[i]);
}

printit_(hits)
	int	*hits;
{
	int	i;

	for (i = 0; i < 15; i++)
		printf("%d ", hits[i]);
}

close_disp()
{
	move(LINES - 1, 0);
	clrtoeol();
	refresh();
	endwin();
}