assist.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*====================================================================*
  2. *
  3. * void assist (char const * name, char const * type, struct _code_ const list [], size_t size);
  4. *
  5. * symbol.h
  6. *
  7. * print program name followed by an error message containing the
  8. * type of name expected, the incorrect name and a list of correct
  9. * name;
  10. *
  11. * Motley Tools by Charles Maier;
  12. * Copyright (c) 2001-2006 by Charles Maier Associates;
  13. * Licensed under the Internet Software Consortium License;
  14. *
  15. *--------------------------------------------------------------------*/
  16. #ifndef ASSIST_SOURCE
  17. #define ASSIST_SOURCE
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include "../tools/symbol.h"
  22. #include "../tools/error.h"
  23. void assist (char const * name, char const * type, struct _code_ const list [], size_t size)
  24. {
  25. extern char const * program_name;
  26. fprintf (stderr, "%s: ", program_name);
  27. fprintf (stderr, "%s: ", strerror (ENOTSUP));
  28. if (name)
  29. {
  30. #if 0
  31. fprintf (stderr, "Have %s '%s' but expected %s ", type, name, type);
  32. #else
  33. fprintf (stderr, "Have '%s' but want ", name);
  34. #endif
  35. }
  36. else
  37. {
  38. fprintf (stderr, "Want %s ", type);
  39. }
  40. codelist (list, size, ",", "''", stderr);
  41. fprintf (stderr, ".\n");
  42. exit (1);
  43. }
  44. #endif