- register int c;
- register char *p;
-
- (void) puts("___________");
- if (argc > 1)
- while (p = *++argv)
- for (; *p; ++p)
- putppt((int)*p);
- else while ((c = getchar()) != EOF)
- putppt(c);
- (void) puts("___________");
+ char *p, buf[132];
+ int c, start, neednl, dflag;
+
+ /* Revoke setgid privileges */
+ setgid(getgid());
+
+ dflag = 0;
+ while ((c = getopt(argc, argv, "dh")) != -1)
+ switch(c) {
+ case 'd':
+ dflag = 1;
+ break;
+ case 'h':
+ case '?':
+ default:
+ usage();
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (dflag) {
+ if (argc > 0)
+ usage();
+
+ start = 0;
+ neednl = 0;
+ while (fgets(buf, sizeof(buf), stdin) != NULL) {
+ c = getppt(buf);
+ if (c < 0) {
+ if (start) {
+ /* lost sync? */
+ if (neednl)
+ putchar('\n');
+ exit(0);
+ } else
+ continue;
+ }
+ start = 1;
+ putchar(c);
+ neednl = (c != '\n');
+ }
+ if (!feof(stdin))
+ err(1, "fgets");
+ if (neednl)
+ putchar('\n');
+ } else {
+ (void) puts(EDGE);
+ if (argc > 0)
+ while ((p = *argv++)) {
+ for (; *p; ++p)
+ putppt((int)*p);
+ if ((*(argv)))
+ putppt((int)' ');
+ }
+ else while ((c = getchar()) != EOF)
+ putppt(c);
+ (void) puts(EDGE);
+ }