PageRenderTime 80ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/code_comm/error.c

http://research-code-base-animesh.googlecode.com/
C | 77 lines | 38 code | 10 blank | 29 comment | 6 complexity | 8b79e9416107acdb8935a69628e3450c MD5 | raw file
  1. /*
  2. **
  3. ** error.c
  4. **
  5. ** Copyright (C) 1995, 1996, 1997 Johannes Plass
  6. **
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. **
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. **
  21. ** Author: Johannes Plass (plass@thep.physik.uni-mainz.de)
  22. ** Department of Physics
  23. ** Johannes Gutenberg-University
  24. ** Mainz, Germany
  25. **
  26. */
  27. /*
  28. #define MESSAGES
  29. */
  30. #include "message.h"
  31. #include "config.h"
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include "paths.h"
  35. #include INC_X11(Xos.h)
  36. #include INC_X11(Intrinsic.h)
  37. #include "types.h"
  38. #include "error.h"
  39. #include "main_resources.h"
  40. #include "main_globals.h"
  41. #include "d_memdebug.h"
  42. char*
  43. open_fail_error(errornumber,error_str,file_name,show)
  44. int errornumber;
  45. char *error_str;
  46. char *file_name;
  47. int show;
  48. {
  49. char *m;
  50. BEGINMESSAGE(open_fail_error_message)
  51. #if defined (__DECC) && defined (VMS)
  52. if (errornumber < __ERRNO_MAX) m=strerror(errornumber);
  53. else m = "Unknown error";
  54. #else
  55. if (!(m = strerror(errornumber))) m = "Unknown error";
  56. #endif
  57. if (show) {
  58. fprintf(stderr,"%s: %s %s (%s)\n",gv_name,error_str,file_name,m);
  59. m = NULL;
  60. } else {
  61. char buf[1024];
  62. sprintf(buf,"%s %s: %s",error_str,file_name,m);
  63. m = GV_XtNewString(buf);
  64. }
  65. ENDMESSAGE(open_fail_error_message)
  66. return(m);
  67. }