1 /* common.c - Common functions */
3 /* Written 1993 by Werner Almesberger */
5 /* FAT32, VFAT, Atari format support, and various fixes additions May 1998
6 * by Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> */
18 typedef struct _link
{
24 void die(char *msg
,...)
29 vfprintf(stderr
,msg
,args
);
36 void pdie(char *msg
,...)
41 vfprintf(stderr
,msg
,args
);
43 fprintf(stderr
,":%s\n",strerror(errno
));
52 if ((this = malloc(size
))) return this;
54 return NULL
; /* for GCC */
58 void *qalloc(void **root
,int size
)
62 link
= alloc(sizeof(LINK
));
65 return link
->data
= alloc(size
);
69 void qfree(void **root
)
74 this = (LINK
*) *root
;
91 char get_key(char *valid
,char *prompt
)
96 if (prompt
) printf("%s ",prompt
);
98 while (ch
= getchar(), ch
== ' ' || ch
== '\t');
99 if (ch
== EOF
) exit(1);
100 if (!strchr(valid
,okay
= ch
)) okay
= 0;
101 while (ch
= getchar(), ch
!= '\n' && ch
!= EOF
);
102 if (ch
== EOF
) exit(1);
103 if (okay
) return okay
;
104 printf("Invalid input.\n");
108 /* Local Variables: */