DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

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

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦453d86ad8⟧ TextFile

    Length: 633 (0x279)
    Types: TextFile
    Notes: UNIX file
    Names: »sleep.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »cmd/sleep.c« 

TextFile

/*
 * Sleep command
 */

#include <stdio.h>
#include <mdata.h>

long	numeric();
long	atol();

main(argc, argv)
char *argv[];
{
	if (argc > 2)
		usage();
	if (argc > 1)
		lsleep(numeric(argv[1]));
	return (0);
}

/*
 * Check if argument is numeric and
 * return it.
 */
long
numeric(s)
register char *s;
{
	long n;

	n = atol(s);
	for (; *s!='\0'; s++)
		if (*s<'0' || *s>'9')
			usage();
	return (n);
}

/*
 * Sleep that takes a long argument.
 */
lsleep(n)
long n;
{
	register unsigned i;

	while (n > 0) {
		i = n>MAXUINT ? MAXUINT : n;
		sleep(i);
		n -= i;
	}
}

usage()
{
	fprintf(stderr, "Usage: sleep seconds\n");
	exit(1);
}