DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T c

⟦99ecfc593⟧ TextFile

    Length: 875 (0x36b)
    Types: TextFile
    Names: »cookhash.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Cookie/cookhash.c« 

TextFile

/* cookhash - read a sayings file and generate an index file */
/*  %M%  %I%  %H%  */

#include <stdio.h>

#define YES 1
#define NO 0
#define METACHAR '%'

main(argc,argv)
int argc;
char *argv[];
{
	int c, sawmeta;
	long charpos = 0;

	if (argc != 1)
	{
		fprintf(stderr,"usage: cookhash <cookiefile >hashfile\n");
		exit(1);
	}

	/* write out the "address" of the first cookie */
	puts("000000");

	/* read the cookie until the end,
	 *   whenever the end-of-cookie ("%%") sequence is found,
	 *   the "address" (file position) of the first byte following
	 *   it (start of next cookie) is written to the index (hash) file
	 */
	while ((c = getchar()) != EOF)
	{
		if (c == METACHAR)
		{
			if (sawmeta)
			{
				printf("%06lx\n",charpos+2);
				sawmeta = NO;
			}
			else
				sawmeta = YES;
		}
		else
			sawmeta = NO;
		charpos++;
	}
	exit(0);
}

/* end of cookhash.c */