コード例 #1
0
ファイル: archive.c プロジェクト: hemmecke/aldor
/*
 * arReadNumber(ar,plong,len,base) executes arReadText(ar,tmp,len)
 * on a temporary buffer "tmp". If the read was successful then the
 * ASCII number in base "base" stored in "tmp" is written to "*plong".
 * Requires that "len <= 1024".
 */
local void
arReadNumber(Archive ar, Offset *plong, int len, int base)
{
	char *endp;
	assert(len < sizeof ar_buffer);

	/* First read the text */
	arReadText(ar, ar_buffer, len);


	/* Must have something in the buffer */
	if (!*ar_buffer) {
		comsgError(NULL, ALDOR_E_ArBadNumber, arToString(ar));
		arPosition(ar) = 0;
		arItem(ar) = 0;
		*plong = 0;
		return;
	}


	/* Convert ASCII into binary */
	*plong = (Offset)strtol(ar_buffer, &endp, base);


	/* Validate the conversion (ignore ERANGE errors for now) */
	if (!*endp || *endp == ' ') return;
	comsgError(NULL, ALDOR_E_ArBadNumber, arToString(ar));
	arPosition(ar) = 0;
	arItem(ar) = 0;
	*plong = 0;
}
コード例 #2
0
ファイル: axlcomp.c プロジェクト: nilqed/aldor
void SignalModifier
compSignalHandler(int signo)
{
	int	sigerr;

	/* Can't use switch, since since several might be mapped to SIGFAKE. */

	if	(signo == SIGFAKE)	sigerr = ALDOR_E_SigUnknown;
	else if (signo == SIGHUP)	sigerr = ALDOR_E_SigHup;
	else if (signo == SIGINT)	sigerr = ALDOR_E_SigInt;
	else if (signo == SIGQUIT)	sigerr = ALDOR_E_SigQuit;
	else if (signo == SIGILL)	sigerr = ALDOR_E_SigIll;
	else if (signo == SIGTRAP)	sigerr = ALDOR_E_SigTrap;
	else if (signo == SIGABRT)	sigerr = ALDOR_E_SigAbrt;
	else if (signo == SIGEMT)	sigerr = ALDOR_E_SigEmt;
	else if (signo == SIGFPE)	sigerr = ALDOR_E_SigFpe;
	else if (signo == SIGBUS)	sigerr = ALDOR_E_SigBus;
	else if (signo == SIGSEGV)	sigerr = ALDOR_E_SigSegv;
	else if (signo == SIGSYS)	sigerr = ALDOR_E_SigSys;
	else if (signo == SIGPIPE)	sigerr = ALDOR_E_SigPipe;
	else if (signo == SIGTERM)	sigerr = ALDOR_E_SigTerm;
	else if (signo == SIGXCPU)	sigerr = ALDOR_E_SigXcpu;
	else if (signo == SIGXFSZ)	sigerr = ALDOR_E_SigXfsz;
 	else if (signo == SIGDANGER)	sigerr = ALDOR_E_SigDanger;
	else				sigerr = ALDOR_E_SigUnknown;

        osDisplayMessage(comsgString(sigerr));
        comsgError(NULL, sigerr, signo);
	fflush(dbOut);
	exitFailure();
}
コード例 #3
0
ファイル: archive.c プロジェクト: hemmecke/aldor
/*
 * arReadText(ar,buf,len) executes arReadString(ar,buf,len) but
 * generates an error if the read fails.
 */
local void
arReadText(Archive ar, String dst, int len)
{
	if (!arReadString(ar, dst, len)) return;
	comsgError(NULL, ALDOR_E_ArTruncated, arToString(ar));
	arPosition(ar) = 0;
	arItem(ar) = 0;
	(void)strcpy(dst, "");
}