- extern fputchar();
- char *malloc();
- char *getenv();
- char *tgetstr(), *tgoto();
- float ranf();
- register int x, y;
- register int n;
- register struct worm *w;
- register struct options *op;
- register int h;
- register short *ip;
- char *AL, *BC, *CM, *EI, *HO, *IC, *IM, *IP, *SR;
- int CO, IN, LI, last, bottom;
- char *tcp;
- register char *term;
- char tcb[100];
- struct sgttyb sg;
- setbuf(stdout,malloc(BUFSIZ));
- for (x=1;x<argc;x++) {
- register char *p;
- p=argv[x];
- if (*p=='-') p++;
- switch (*p) {
- case 'f':
- field="WORM";
- break;
- case 'l':
- if (++x==argc) goto usage;
- if ((length=atoi(argv[x]))<2||length>1024) {
- fprintf(stderr,"%s: Invalid length\n",*argv);
+ extern int optind;
+ extern short ospeed;
+ extern char *optarg, *UP;
+ register int x, y, h, n;
+ register struct worm *w;
+ register struct options *op;
+ register short *ip;
+ register char *term;
+ int CO, IN, LI, last, bottom, ch, length, number, trail, Wrap,
+ onsig();
+ short **ref;
+ char *AL, *BC, *CM, *EI, *HO, *IC, *IM, *IP, *SR, *tcp,
+ *field, tcb[100], *mp, *malloc(), *getenv(), *tgetstr(),
+ *tgoto();
+ long random();
+#ifdef USG
+ struct termio sg;
+#else
+ struct sgttyb sg;
+#endif
+
+ length = 16;
+ number = 3;
+ trail = ' ';
+ field = NULL;
+ while ((ch = getopt(argc, argv, "fl:n:t")) != EOF)
+ switch((char)ch) {
+ case 'f':
+ field = "WORM";
+ break;
+ case 'l':
+ if ((length = atoi(optarg)) < 2 || length > 1024) {
+ fprintf(stderr, "%s: invalid length; range %d - %d.\n", *argv, 2, 1024);
+ exit(1);
+ }
+ break;
+ case 'n':
+ if ((number = atoi(optarg)) < 1 || number > 40) {
+ fprintf(stderr, "%s: invalid number of worms; range %d - %d.\n", *argv, 1, 40);
+ exit(1);
+ }
+ break;
+ case 't':
+ trail = '.';
+ break;
+ case '?':
+ default:
+ fprintf(stderr, "usage: %s [-ft] [-length #] [-number #]\n", *argv);
+ exit(1);
+ }
+
+ if (!(term = getenv("TERM"))) {
+ fprintf(stderr, "%s: TERM: parameter not set\n", *argv);
+ exit(1);
+ }
+ if (!(mp = malloc((u_int)1024))) {
+ fprintf(stderr, "%s: out of space.\n", *argv);
+ exit(1);
+ }
+ if (tgetent(mp, term) <= 0) {
+ fprintf(stderr, "%s: %s: unknown terminal type\n", *argv, term);