ftp.nice.ch/pub/next/games/fun/cookie.s.tar.gz#/Cookie/_Cookie/CookieV1.0/cookie.filters/BSDfortunes2cookie.c

This is BSDfortunes2cookie.c in view mode; [Download] [Up]

#include <stdio.h>

/* Format expected is cookie separated by %% alone on a line; lots of limericks, so returns are meaningful */
void main(int argc, char * argv[])
{
	int c, flag, eol;
	char *title;
	
	if (argc < 2)
		title = "BSD";
	else
		title = argv[1];
		
	flag = 0;
	eol = 0;
	c = getchar();
	while (c != EOF) {
		printf("#%s%%", title);	/* cookie title */
		while (c != EOF) {
			if ((c == '%') && (flag)) {
				c = getchar();	/* skip % */
				c = getchar();	/* skip return */
				flag = 0;
				break;
			} else if (c == '%') {
				flag = 1;
				eol = 0;
			} else {
				if (eol) {
					eol = 0;
					putchar(' ');
				}
 				/* write cookie */
				putchar(c);
				if (c == '\n')
					eol = 1;
			}
			c = getchar();
		}
		/* putchar('\n'); */
	}
	
	printf("##\n");		/* end */
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.