|
|
1.1 ! root 1: /* ! 2: * Calculate serial numbers and print labels. ! 3: */ ! 4: #include <stdio.h> ! 5: #include "unumber.h" ! 6: ! 7: void ser_number(); ! 8: void nu_usage(); ! 9: ! 10: int c; /* Version of COHERENT */ ! 11: ! 12: main(argc, argv) ! 13: int argc; ! 14: char *argv[]; ! 15: { ! 16: int i, finish, start, total; ! 17: ! 18: if (argc != 4) ! 19: nu_usage(); ! 20: if ((c = atoi(argv[1])) < 1 || c > VERSIONS) { ! 21: fprintf(stderr, "Bad coh_version \"%s\".\n", argv[1]); ! 22: exit(1); ! 23: } ! 24: if ((start = atoi(argv[2])) < 1) { ! 25: fprintf(stderr, "Bad start_number \"%s\".\n", argv[2]); ! 26: exit(1); ! 27: } ! 28: if ((total = atoi(argv[3])) < 1) { ! 29: fprintf(stderr, "Bad total_number \"%s\".\n", argv[3]); ! 30: exit(1); ! 31: } ! 32: ! 33: finish = start + total; ! 34: c --; ! 35: ! 36: for (i = start; i < finish; i ++) ! 37: ser_number(i); ! 38: ! 39: exit(0); ! 40: } ! 41: ! 42: /* ! 43: * Calculate and print in stdout a serial number. ! 44: */ ! 45: void ! 46: ser_number(num) ! 47: int num; ! 48: { ! 49: printf( "%1d%03d%05d\n", c + 1, ! 50: magic1[c] ^ (num % magic2[c]), num ^ magic3[c]); ! 51: } ! 52: ! 53: /* ! 54: * Usage of program number. ! 55: */ ! 56: void ! 57: nu_usage() ! 58: { ! 59: printf("number coherent_version start_number total_number\n"); ! 60: exit(1); ! 61: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.