Failure.c 917 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* This Hello World simply print out "Hello World" */
  4. #include "pal.h"
  5. #include "pal_error.h"
  6. #include "pal_debug.h"
  7. int handled = 0;
  8. void FailureHandler (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
  9. {
  10. pal_printf("Failure notified: %s\n",
  11. pal_errstring[(unsigned long) arg]);
  12. handled = 1;
  13. DkExceptionReturn(event);
  14. }
  15. int main (int argc, char ** argv, char ** envp)
  16. {
  17. pal_printf("Enter Main Thread\n");
  18. DkSetExceptionHandler(FailureHandler, PAL_EVENT_FAILURE);
  19. PAL_HANDLE out = DkStreamOpen("foo:unknown", PAL_ACCESS_WRONLY, 0, 0, 0);
  20. if (!out && !handled) {
  21. pal_printf("DkStreamOpen failed\n");
  22. return -1;
  23. }
  24. pal_printf("Leave Main Thread\n");
  25. return 0;
  26. }