Expand PMF_FN_* macros.
[netbsd-mini2440.git] / usr.sbin / sup / source / cvt.c
blobfcd2fe4f2c79d90a516cac56fba48c6ef23a2f42
1 /* $NetBSD: cvt.c,v 1.2 1997/06/17 18:56:10 christos Exp $ */
3 /*
4 * Quick hack to convert old binary sup when.collection files into
5 * the new ascii format.
6 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <fcntl.h>
12 int
13 main(int argc, char **argv)
15 long b;
16 FILE *fp;
17 int fd;
19 if (argc != 2) {
20 (void) fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
21 return 1;
24 if ((fd = open(argv[1], O_RDWR)) == -1) {
25 perror("open");
26 return 1;
29 if (read(fd, &b, sizeof(b)) != sizeof(b)) {
30 perror("read");
31 return 1;
34 if (lseek(fd, 0, SEEK_SET) == -1) {
35 perror("lseek");
36 return 1;
39 (void) close(fd);
41 if ((fp = fopen(argv[1], "w")) == NULL) {
42 perror("fopen");
43 return 1;
46 if (fprintf(fp, "%ld\n", b) < 0) {
47 perror("fprintf");
48 return 1;
50 if (fclose(fp) != 0) {
51 perror("fclose");
52 return 1;
55 return 0;