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 m

⟦7d2605265⟧ TextFile

    Length: 3416 (0xd58)
    Types: TextFile
    Names: »misc.c«

Derivation

└─⟦52210d11f⟧ Bits:30007239 EUUGD2: TeX 3 1992-12
    └─⟦af5ba6c8e⟧ »unix3.0/DVIWARE.tar.Z« 
        └─⟦ca79c7339⟧ 
            └─⟦this⟧ »DVIware/laser-setters/dvi-to-ps/maketd/misc.c« 

TextFile


/*
 * Written & hacked by Stephen Uitti, PUCC staff
 * 1985 maketd is Copyright (C) Purdue University, 1985 
 *
 * Permission is hereby given for its free reproduction and modification for
 * non-commercial purposes, provided that this notice and all embedded
 * copyright notices be retained. Commercial organizations may give away
 * copies as part of their systems provided that they do so without charge,
 * and that they acknowledge the source of the software. 
 */

#ifdef pdp11
#include <sys/types.h>
#include <signal.h>
#endif
#ifndef pdp11
#include <sys/signal.h>
#endif
#include <stdio.h>

#include "maketd.h"

/* VARARGS */
/* print and error and exit */
void
err(a, b, c, d)
char   *a;			/* the format string, as printf */
char   *b, *c, *d;		/* arguments, as printf */
{
	fprintf(stderr, "%s: ", prgnm);
	fprintf(stderr, a, b, c, d);
	fprintf(stderr, "\n");
	errrec();		/* clean up backup file, if any */
	exit(1);
}

/* errrec - error recovery: recover temp file */
static void
errrec()
{
	if (backedup) {
		backedup = FALSE;	/* prevent infinite error recursion */
		unlink(makename);	/* may or may not exist */
		if (link(backupfn, makename))
			err("can't link %s to %s during recovery", makename, backupfn);
		if (unlink(backupfn))
			err("can't delete %s during recovery", backupfn);
		err("edit of '%s' aborted - file unchanged.", makename);
	}
	exit(1);
}

/* signal trap routines, one for each */
static void
errhup()
{
	fprintf(stderr, "%s: SIGHUP recieved\n", prgnm);
	errrec();
}

static void
errint()
{
	fprintf(stderr, "%s: SIGINT recieved\n", prgnm);
	errrec();
}

static void
errill()
{
	fprintf(stderr, "%s: SIGILL recieved\n", prgnm);
	errrec();
}

static void
errtrap()
{
	fprintf(stderr, "%s: SIGTRAP recieved\n", prgnm);
	errrec();
}

static void
erriot()
{
	fprintf(stderr, "%s: SIGIOT recieved\n", prgnm);
	errrec();
}

static void
erremt()
{
	fprintf(stderr, "%s: SIGEMT recieved\n", prgnm);
	errrec();
}

static void
errfpe()
{
	fprintf(stderr, "%s: SIGFPE recieved\n", prgnm);
	errrec();
}

static void
errbus()
{
	fprintf(stderr, "%s: SIGBUS recieved\n", prgnm);
	errrec();
}

static void
errsegv()
{
	fprintf(stderr, "%s: SIGSEGV recieved\n", prgnm);
	errrec();
}

static void
errsys()
{
	fprintf(stderr, "%s: SIGSYS recieved\n", prgnm);
	errrec();
}

static void
errpipe()
{
	fprintf(stderr, "%s: SIGPIPE recieved\n", prgnm);
	errrec();
}

static void
erralrm()
{
	fprintf(stderr, "%s: SIGALRM recieved\n", prgnm);
	errrec();
}

static void
errterm()
{
	fprintf(stderr, "%s: SIGTERM recieved\n", prgnm);
	errrec();
}

/* catchsig - init signal traps */
catchsig()
{
	signal(SIGHUP, errhup);
	signal(SIGINT, errint);
	signal(SIGILL, errill);
	signal(SIGTRAP, errtrap);
	signal(SIGIOT, erriot);
	signal(SIGEMT, erremt);
	signal(SIGFPE, errfpe);
	signal(SIGBUS, errbus);
	signal(SIGSEGV, errsegv);
	signal(SIGSYS, errsys);
	signal(SIGPIPE, errpipe);
	signal(SIGALRM, erralrm);
	signal(SIGTERM, errterm);

	/*
	 * Stock 2.9BSD has all the above, but not as many as 4.2BSD: Want
	 * SIGQUIT to drop core. Not worrying about:	SIGXCPU, SIGXFSZ,
	 * SIGVTALRM, SIGPROF cannot be caught: SIGKILL, SIGSTOP Leaving
	 * alone: SIGURG, SIGTSTP, SIGCONT, SIGCHLD, SIGTTIN, SIGTTOU, SIGIO 
	 */
}

/* lastlnch - return last char before newline or NULL in string */
char
lastlnch(p)
register char *p;
{
	register char *q;

	q = p;
	while (*p != '\0' && *p != '\n')
		q = p++;
	return *q;
}