File:  [MW Coherent from dump] / coherent / d / support / serial_no / number.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:38 2019 UTC (7 years, 2 months ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * Calculate serial numbers and print labels.
 */
#include	<stdio.h>
#include 	"unumber.h"

void	ser_number();
void	nu_usage();

int	c;	/* Version of COHERENT */

main(argc, argv)
int	argc;
char	*argv[];
{
	int	i, finish, start, total;

	if (argc != 4)
		nu_usage();
	if ((c = atoi(argv[1])) < 1 || c > VERSIONS) {
			fprintf(stderr, "Bad coh_version \"%s\".\n", argv[1]);	
			exit(1);
	}
	if ((start = atoi(argv[2])) < 1) {
			fprintf(stderr, "Bad start_number \"%s\".\n", argv[2]);	
			exit(1);
	}
	if ((total = atoi(argv[3])) < 1) {
			fprintf(stderr, "Bad total_number \"%s\".\n", argv[3]);	
			exit(1);
	}

	finish = start + total;
	c --;

	for (i = start; i < finish; i ++)
		ser_number(i);

	exit(0);
}

/*
 * Calculate and print in stdout a serial number.
 */
void
ser_number(num)
int	num;
{	
	printf( "%1d%03d%05d\n", c + 1,
			magic1[c] ^ (num % magic2[c]), num ^ magic3[c]);
}

/*
 * Usage of program number.
 */
void 
nu_usage()
{
	printf("number coherent_version start_number total_number\n");
	exit(1);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.