extra.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*====================================================================*
  2. *
  3. * signed extra (signed status, errno_t number, int argc, char const * arg []);
  4. *
  5. * error.h
  6. *
  7. * print error message plus excess argments on stdout;
  8. *
  9. * Motley Tools by Charles Maier;
  10. * Copyright (c) 2001-2006 by Charles Maier Associates;
  11. * Licensed under the Internet Software Consortium License;
  12. *
  13. *--------------------------------------------------------------------*/
  14. #ifndef EXTRA_SOURCE
  15. #define EXTRA_SOURCE
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <stdarg.h>
  19. #include <string.h>
  20. #include "../tools/types.h"
  21. #include "../tools/error.h"
  22. signed extra (signed status, errno_t number, int argc, char const * argv [])
  23. {
  24. extern char const *program_name;
  25. if ((program_name) && (*program_name))
  26. {
  27. fprintf (stderr, "%s: ", program_name);
  28. }
  29. if (number)
  30. {
  31. fprintf (stderr, "%s: ", strerror (number));
  32. }
  33. fprintf (stderr, "Excess data: ");
  34. while ((argc) && (* argv))
  35. {
  36. fprintf (stderr, "%s ", * argv);
  37. argv++;
  38. argc--;
  39. }
  40. fprintf (stderr, "\n");
  41. fflush (stderr);
  42. if (status)
  43. {
  44. exit (status);
  45. }
  46. return (-1);
  47. }
  48. #endif