1 /* temp.c - Temporary file registry */
3 Copyright 1992-1998 Werner Almesberger.
4 Copyright 1999-2006 John Coffman.
7 Licensed under the terms contained in the file 'COPYING' in the
26 typedef struct _temp {
32 static TEMP *list = NULL;
35 void temp_register(char *name)
40 new->name = stralloc(name);
46 void temp_unregister(char *name)
50 for (walk = &list; *walk; walk = &(*walk)->next)
51 if (!strcmp(name,(*walk)->name)) {
58 die("Internal error: temp_unregister %s",name);
62 void temp_remove(void)
68 if (remove(list->name) < 0)
69 warn("(temp) %s: %s",list->name,strerror(errno));
70 else if (verbose>=2) printf("Removed temporary file %s\n",list->name);
79 #include <sys/types.h>
85 void process(char *file, char *name)
91 unsigned char data[NBUF];
93 if ((fd = open(file, O_RDONLY)) < 0) exit(1);
94 if (fstat(fd, &buf)) exit(1);
97 printf("struct { int size; unsigned char data[%d]; } %s = { %d, {",
100 nrd = (nchar>NBUF ? NBUF : nchar);
101 if (read(fd, data, nrd) != nrd) exit(1);
102 for (i=0; i<nrd; i++) {
103 printf("%c%3d", i?',':'\n', (int)data[i]);
106 if (nchar>0) printf(",");
116 printf("/* begin loader ***/\n");
118 process("first.b", "First");
119 process("second.b", "Second");
120 process("third.b", "Third");
121 process("bitmap.b", "Bitmap");
122 process("mbr.b", "Mbr");
123 process("mbr2.b", "Mbr2");
124 process("chain.b", "Chain");
125 #ifndef LCF_SOLO_CHAIN
126 process("os2_d.b", "Os2_d");
129 printf("/*** end loader ***/\n");