11.3Sjoerg/*	$NetBSD: hash_driver.c,v 1.3 2014/02/06 14:57:16 joerg Exp $	*/
21.1Sjoerg/*-
31.1Sjoerg * Copyright (c) 2012 The NetBSD Foundation, Inc.
41.1Sjoerg * All rights reserved.
51.1Sjoerg *
61.1Sjoerg * This code is derived from software contributed to The NetBSD Foundation
71.1Sjoerg * by Joerg Sonnenberger.
81.1Sjoerg *
91.1Sjoerg * Redistribution and use in source and binary forms, with or without
101.1Sjoerg * modification, are permitted provided that the following conditions
111.1Sjoerg * are met:
121.1Sjoerg *
131.1Sjoerg * 1. Redistributions of source code must retain the above copyright
141.1Sjoerg *    notice, this list of conditions and the following disclaimer.
151.1Sjoerg * 2. Redistributions in binary form must reproduce the above copyright
161.1Sjoerg *    notice, this list of conditions and the following disclaimer in
171.1Sjoerg *    the documentation and/or other materials provided with the
181.1Sjoerg *    distribution.
191.1Sjoerg *
201.1Sjoerg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
211.1Sjoerg * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
221.1Sjoerg * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
231.1Sjoerg * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
241.1Sjoerg * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
251.1Sjoerg * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
261.1Sjoerg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
271.1Sjoerg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
281.1Sjoerg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
291.1Sjoerg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
301.1Sjoerg * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311.1Sjoerg * SUCH DAMAGE.
321.1Sjoerg */
331.1Sjoerg
341.1Sjoerg#include <stdio.h>
351.1Sjoerg#include <inttypes.h>
361.1Sjoerg
371.1Sjoerg#include "hash.c"
381.1Sjoerg
391.1Sjoergint
401.1Sjoergmain(void)
411.1Sjoerg{
421.1Sjoerg	char *line = NULL;
431.1Sjoerg	size_t buflen;
441.1Sjoerg	ssize_t len;
451.1Sjoerg
461.3Sjoerg	while ((len = getline(&line, &buflen, stdin)) > 0) {
471.1Sjoerg		if (len && line[len - 1] == '\n')
481.1Sjoerg			--len;
491.2Sjoerg		printf("%" PRId32 "\n", hash(line, len));
501.1Sjoerg	}
511.1Sjoerg	free(line);
521.1Sjoerg	return 0;
531.1Sjoerg}
54