error.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /*
  15. * standalone mini error interface
  16. */
  17. #include <stdarg.h>
  18. #include <errno.h>
  19. typedef struct Error_info_s {
  20. int errors;
  21. int indent;
  22. int line;
  23. int warnings;
  24. int trace;
  25. char *file;
  26. char *id;
  27. } Error_info_t;
  28. #define ERROR_INFO 0 /* info message -- no err_id */
  29. #define ERROR_WARNING 1 /* warning message */
  30. #define ERROR_ERROR 2 /* error message -- no err_exit */
  31. #define ERROR_FATAL 3 /* error message with err_exit */
  32. #define ERROR_PANIC ERROR_LEVEL /* panic message with err_exit */
  33. #define ERROR_LEVEL 0x00ff /* level portion of status */
  34. #define ERROR_SYSTEM 0x0100 /* report system errno message */
  35. #define ERROR_USAGE 0x0800 /* usage message */
  36. /* support for extra API misuse warnings if available */
  37. #ifdef __GNUC__
  38. #define PRINTF_LIKE(index, first) __attribute__((format(printf, index, first)))
  39. #else
  40. #define PRINTF_LIKE(index, first) /* nothing */
  41. #endif
  42. extern Error_info_t error_info;
  43. extern void setTraceLevel (int);
  44. extern void setErrorLine (int);
  45. extern void setErrorFileLine (char*, int);
  46. extern void setErrorId (char*);
  47. extern void setErrorErrors (int);
  48. extern int getErrorErrors (void);
  49. extern void error(int, const char *, ...) PRINTF_LIKE(2, 3);
  50. extern void errorf(void *, void *, int, const char *, ...) PRINTF_LIKE(4, 5);
  51. extern void errorv(const char *, int, const char *, va_list);
  52. #undef PRINTF_LIKE
  53. #ifdef __cplusplus
  54. }
  55. #endif