xref: /openbsd/sys/dev/microcode/udl/build.c (revision 277843a5)
1 /*	$OpenBSD: build.c,v 1.1 2009/08/25 19:04:49 mglocker 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 <unistd.h>
24 
25 #include "udl_huffman.h"
26 
27 #define FILENAME "udl_huffman"
28 
29 int
30 main(void)
31 {
32 	int fd, i;
33 
34 	fd = open(FILENAME, O_WRONLY | O_CREAT | O_TRUNC, 0644);
35 	if (fd == -1)
36 		err(1, "%s", FILENAME);
37 
38 	for (i = 0; i < UDL_HUFFMAN_RECORDS; i++) {
39 		udl_huffman[i].value = htobe32(udl_huffman[i].value);
40 		write(fd, &udl_huffman[i], 5);
41 	}
42 
43 	close(fd);
44 
45 	return (0);
46 }
47