Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.6 KiB

  1. /* Copyright (C) Boris Nikolaus, Germany, 1996-1997. All rights reserved. */
  2. /* Copyright (C) Microsoft Corporation, 1997-1998. All rights reserved. */
  3. #include "precomp.h"
  4. #include "error.h"
  5. /* MyAbort by an error message */
  6. void
  7. error(int errornr, LLPOS *pos)
  8. {
  9. char errbuf[256];
  10. switch (errornr) {
  11. case E_systemerror:
  12. strcpy(errbuf, strerror(errno));
  13. break;
  14. case E_COMPONENTS_OF_in_extension:
  15. strcpy(errbuf, "`COMPONENTS OF' may not be used in extensions");
  16. break;
  17. case E_applied_COMPONENTS_OF_to_bad_type:
  18. strcpy(errbuf, "`COMPONENTS OF' must be applied to SEQUENCE/SET/CHOICE type");
  19. break;
  20. case E_COMPONENTS_OF_extended_type:
  21. strcpy(errbuf, "`COMPONENTS OF' can only be applied to unextended types");
  22. break;
  23. case E_bad_component_in_selectiontype:
  24. strcpy(errbuf, "unknown component in selection type");
  25. break;
  26. case E_selection_of_bad_type:
  27. strcpy(errbuf, "selection type can only be applied to SEQUENCE/SET/CHOICE types");
  28. break;
  29. case E_recursive_type_definition:
  30. strcpy(errbuf, "recursive type definition, introduce --<POINTER>-- to break recursion");
  31. break;
  32. case E_undefined_typereference:
  33. strcpy(errbuf, "undefined type reference");
  34. break;
  35. case E_unterminated_string:
  36. strcpy(errbuf, "unterminated string constant");
  37. break;
  38. case E_bad_character:
  39. strcpy(errbuf, "bad character in file");
  40. break;
  41. case E_duplicate_tag:
  42. strcpy(errbuf, "duplicate tag in sequence/set/choice type");
  43. break;
  44. case E_bad_directive:
  45. strcpy(errbuf, "directive does not fit to given type");
  46. break;
  47. case E_constraint_too_complex:
  48. strcpy(errbuf, "constraint is too complex");
  49. break;
  50. default:
  51. sprintf(errbuf, "unknown error 0x%x", errornr);
  52. break;
  53. }
  54. ASSERT(0);
  55. llerror(stderr, pos, "%s", errbuf);
  56. /*NOTREACHED*/
  57. }
  58. /* print an error message: */
  59. /* print the file name, the line number, the line and mark the column where */
  60. /* the error occured and terminate unsuccessful */
  61. void
  62. llverror(FILE *f, LLPOS *pos, char *fmt, va_list args)
  63. {
  64. char *p, *q;
  65. int i;
  66. if (pos) {
  67. p = file;
  68. for (i = 1; i < pos->line; i++) {
  69. p = strchr(p, '\n');
  70. if (!p)
  71. break;
  72. p++;
  73. }
  74. if (pos && pos->file)
  75. fprintf(f, "File %s, line %d:\n", pos->file, pos->line);
  76. if (p && (q = strchr(p, '\n'))) {
  77. if (q[-1] == '\r')
  78. q--;
  79. fprintf(f, "%.*s\n", q - p, p);
  80. for (i = 0; i < pos->column - 1; i++)
  81. putc(p[i] == '\t' ? '\t' : ' ', f);
  82. fprintf(f, "^ ");
  83. }
  84. }
  85. vfprintf(f, fmt, args);
  86. putc('\n', f);
  87. MyExit(1);
  88. }