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

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

#include <stdio.h>

/* format expected is a single cookie per line, filled out by spaces (!!) to wrap around meaningfully on a dumb terminal */
void main(int argc, char * argv[])
{
	int i, c;
	char line[80];
	char *title;
	
	if (argc < 2)
		title = "";
	else
		title = argv[1];
			
	i = 0;
	c = getchar();
	while (c != EOF) {
		printf("#%s%%", title);			/* cookie title */
		while ((c != EOF) && (c != '\n')) {
			line[i++] = c;
			if (i >= 80) {
				/* write cookie */
				line[i] = '\000';	/* terminate string */
				i--;
				while (line[i] == ' ') {
					line[i--] = '\000';
				}
				printf(" %s\n", line);
				i = 0;
			}
			c = getchar();
		}
		if (i != 0) {
			line[i] = '\000';	/* terminate string */
			printf(" %s\n", line);
			i = 0;
		}
		c = getchar();
	}
	
	printf("##\n");		/* end */
}

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