error.c.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. error.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='EmulateHost.c.html' title=' EmulateHost.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='EthernetHeader.c.html' title=' EthernetHeader.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * signed error (signed status, errno_t number, char const * format, ...);
  24. *
  25. * error.h
  26. *
  27. * custom implementation of GNU error() function for systems
  28. * that do not have it; this version always returns -1;
  29. *
  30. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  31. * Copyright (c) 2001-2006 by Charles Maier Associates;
  32. * Licensed under the Internet Software Consortium License;
  33. *
  34. *--------------------------------------------------------------------*/
  35. #ifndef ERROR_SOURCE
  36. #define ERROR_SOURCE
  37. #include &lt;stdio.h&gt;
  38. #include &lt;stdlib.h&gt;
  39. #include &lt;stdarg.h&gt;
  40. #include &lt;string.h&gt;
  41. #include &quot;../tools/types.h&quot;
  42. #include &quot;../tools/error.h&quot;
  43. #ifdef __GNUC__
  44. __attribute__ ((format (printf, 3, 4)))
  45. #endif
  46. signed error (signed status, errno_t number, char const * format, ...)
  47. {
  48. extern char const *program_name;
  49. if ((program_name) &amp;&amp; (*program_name))
  50. {
  51. fprintf (stderr, &quot;%s: &quot;, program_name);
  52. }
  53. #if 1
  54. if ((format) &amp;&amp; (*format))
  55. {
  56. va_list arglist;
  57. va_start (arglist, format);
  58. vfprintf (stderr, format, arglist);
  59. va_end (arglist);
  60. }
  61. if (number)
  62. {
  63. fprintf (stderr, &quot;: %s&quot;, strerror (number));
  64. }
  65. #else
  66. if (number)
  67. {
  68. fprintf (stderr, &quot;%s: &quot;, strerror (number));
  69. }
  70. if ((format) &amp;&amp; (*format))
  71. {
  72. va_list arglist;
  73. va_start (arglist, format);
  74. vfprintf (stderr, format, arglist);
  75. va_end (arglist);
  76. }
  77. #endif
  78. fprintf (stderr, &quot;\n&quot;);
  79. fflush (stderr);
  80. if (status)
  81. {
  82. exit (status);
  83. }
  84. return (-1);
  85. }
  86. #endif
  87. </pre>
  88. <div class='footerlink'>
  89. [<a href='EmulateHost.c.html' title=' EmulateHost.c '>PREV</a>]
  90. [<a href='toolkit.html' title=' Index '>HOME</a>]
  91. [<a href='EthernetHeader.c.html' title=' EthernetHeader.c '>NEXT</a>]
  92. </div>
  93. </body>
  94. </html>