1*0a6a1f1dSLionel Sambuc /* $NetBSD: hash_driver.c,v 1.3 2014/02/06 14:57:16 joerg Exp $ */
211be35a1SLionel Sambuc /*-
311be35a1SLionel Sambuc * Copyright (c) 2012 The NetBSD Foundation, Inc.
411be35a1SLionel Sambuc * All rights reserved.
511be35a1SLionel Sambuc *
611be35a1SLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation
711be35a1SLionel Sambuc * by Joerg Sonnenberger.
811be35a1SLionel Sambuc *
911be35a1SLionel Sambuc * Redistribution and use in source and binary forms, with or without
1011be35a1SLionel Sambuc * modification, are permitted provided that the following conditions
1111be35a1SLionel Sambuc * are met:
1211be35a1SLionel Sambuc *
1311be35a1SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1411be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer.
1511be35a1SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1611be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer in
1711be35a1SLionel Sambuc * the documentation and/or other materials provided with the
1811be35a1SLionel Sambuc * distribution.
1911be35a1SLionel Sambuc *
2011be35a1SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2111be35a1SLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2211be35a1SLionel Sambuc * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
2311be35a1SLionel Sambuc * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
2411be35a1SLionel Sambuc * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2511be35a1SLionel Sambuc * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
2611be35a1SLionel Sambuc * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
2711be35a1SLionel Sambuc * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2811be35a1SLionel Sambuc * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2911be35a1SLionel Sambuc * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3011be35a1SLionel Sambuc * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3111be35a1SLionel Sambuc * SUCH DAMAGE.
3211be35a1SLionel Sambuc */
3311be35a1SLionel Sambuc
3411be35a1SLionel Sambuc #include <stdio.h>
3511be35a1SLionel Sambuc #include <inttypes.h>
3611be35a1SLionel Sambuc
3711be35a1SLionel Sambuc #include "hash.c"
3811be35a1SLionel Sambuc
3911be35a1SLionel Sambuc int
main(void)4011be35a1SLionel Sambuc main(void)
4111be35a1SLionel Sambuc {
4211be35a1SLionel Sambuc char *line = NULL;
4311be35a1SLionel Sambuc size_t buflen;
4411be35a1SLionel Sambuc ssize_t len;
4511be35a1SLionel Sambuc
46*0a6a1f1dSLionel Sambuc while ((len = getline(&line, &buflen, stdin)) > 0) {
4711be35a1SLionel Sambuc if (len && line[len - 1] == '\n')
4811be35a1SLionel Sambuc --len;
4911be35a1SLionel Sambuc printf("%" PRId32 "\n", hash(line, len));
5011be35a1SLionel Sambuc }
5111be35a1SLionel Sambuc free(line);
5211be35a1SLionel Sambuc return 0;
5311be35a1SLionel Sambuc }
54