1 /* $OpenBSD: build.c,v 1.6 2009/11/10 23:55:12 mpf Exp $ */
2
3 /*
4 * Copyright (c) 2009 Marcus Glocker <mglocker@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <sys/types.h>
20
21 #include <err.h>
22 #include <fcntl.h>
23 #include <stdio.h>
24 #include <unistd.h>
25
26 #include "udl_huffman.h"
27
28 #define FILENAME "udl_huffman"
29
30 int
main(void)31 main(void)
32 {
33 int i;
34 FILE *file;
35 uint32_t bit_count;
36 uint32_t bit_pattern;
37
38 if ((file = fopen(FILENAME, "w")) == NULL)
39 err(1, "fopen %s", FILENAME);
40
41 for (i = 0; i < UDL_HUFFMAN_RECORDS; i++) {
42 bit_count = udl_huffman[i].bit_count;
43 bit_pattern = htobe32(udl_huffman[i].bit_pattern);
44 if (fwrite(&bit_count, sizeof(bit_count), 1, file) != 1)
45 err(1, "fwrite");
46 if (fwrite(&bit_pattern, sizeof(bit_pattern), 1, file) != 1)
47 err(1, "fwrite");
48 }
49
50 fclose(file);
51
52 return (0);
53 }
54