common.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* common.h - Common functions */
  2. /* Written 1993 by Werner Almesberger */
  3. # include <asm/types.h>
  4. # define MSDOS_FAT12 4084 /* maximum number of clusters in a 12 bit FAT */
  5. #ifndef _COMMON_H
  6. #define _COMMON_H
  7. void die(char *msg,...) __attribute((noreturn));
  8. /* Displays a prinf-style message and terminates the program. */
  9. void pdie(char *msg,...) __attribute((noreturn));
  10. /* Like die, but appends an error message according to the state of errno. */
  11. void *alloc(int size);
  12. /* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
  13. if malloc fails. */
  14. void *qalloc(void **root,int size);
  15. /* Like alloc, but registers the data area in a list described by ROOT. */
  16. void qfree(void **root);
  17. /* Deallocates all qalloc'ed data areas described by ROOT. */
  18. int min(int a,int b);
  19. /* Returns the smaller integer value of a and b. */
  20. char get_key(char *valid,char *prompt);
  21. /* Displays PROMPT and waits for user input. Only characters in VALID are
  22. accepted. Terminates the program on EOF. Returns the character. */
  23. #endif