- extern int errno;
- register int ch, dot, i, nread, winnerdot;
- register char *inbuf;
- int obs[26], try, winner;
- char *malloc(), *strerror();
-
- if (argc > 1)
- printit(argv[1]);
-
- if (!(inbuf = malloc(LINELENGTH))) {
- (void)fprintf(stderr, "caesar: out of memory.\n");
- exit(1);
+ int ch;
+ long rot;
+ char *endp;
+
+ errno = 0;
+ rot = strtol(arg, &endp, 10);
+ if (*endp != '\0') {
+ errx(EXIT_FAILURE, "bad rotation value: %s", arg);
+ /* NOTREACHED */
+ }
+ if (errno == ERANGE || rot < 0 || rot > INT_MAX) {
+ errx(EXIT_FAILURE, "rotation value out of range: %s", arg);
+ /* NOTREACHED */
+ }
+ init_rottbl((int)rot);
+
+ while ((ch = getchar()) != EOF) {
+ if (putchar(rottbl[ch]) == EOF) {
+ err(EXIT_FAILURE, "writing to stdout");
+ /* NOTREACHED */
+ }
+ }
+ exit(EXIT_SUCCESS);
+ /* NOTREACHED */
+}
+
+int
+main(int argc, char **argv)
+{
+ ssize_t i, nread, ntotal;
+ double dot, winnerdot;
+ int try, winner;
+ unsigned char inbuf[2048];
+ unsigned int obs[NCHARS];
+
+ /* revoke setgid privileges */
+ (void)setgid(getgid());
+
+ if (argc > 1) {
+ printrot(argv[1]);
+ /* NOTREACHED */