ckusig.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* C K U S I G . H */
  2. /* Definitions and prototypes for signal handling */
  3. /*
  4. Author: Jeffrey E Altman (jaltman@secure-endpoints.com),
  5. Secure Endpoints Inc., New York City.
  6. Copyright (C) 1985, 2009,
  7. Trustees of Columbia University in the City of New York.
  8. All rights reserved. See the C-Kermit COPYING.TXT file or the
  9. copyright text in the ckcmai.c module for disclaimer and permissions.
  10. */
  11. #ifdef CK_ANSIC
  12. typedef void (*ck_sigfunc)(void *);
  13. typedef void (*ck_sighand)(int);
  14. #else
  15. typedef VOID (*ck_sigfunc)();
  16. typedef VOID (*ck_sighand)();
  17. #endif /* CK_ANSIC */
  18. /* Macros for POSIX vs old-style signal handling. */
  19. #ifdef CK_POSIX_SIG
  20. typedef sigjmp_buf ckjmpbuf;
  21. #else
  22. typedef jmp_buf ckjmpbuf;
  23. #endif /* CK_POSIX_SIG */
  24. /*
  25. Suppose you want to pass the address of a jmp_buf bar to a function foo.
  26. Since jmp_buf is normally defined (typedef'd) as an array, you would do
  27. it like this: foo(bar), where foo = foo(jmp_buf bar). But suppose a
  28. jmp_buf is (say) a struct rather than an array. Then you must do
  29. foo(&bar) where foo is foo(jmp_buf * bar). This is controlled here in
  30. the traditional fashion, by ifdefs. By default, we assume that jmp_buf
  31. is an array. Define the symbol JBNOTARRAY if jmp_buf is not an array.
  32. */
  33. #ifndef JBNOTARRAY
  34. #ifdef NT
  35. #define JBNOTARRAY
  36. #endif /* NT */
  37. #endif /* JBNOTARRAY */
  38. #ifdef JBNOTARRAY
  39. typedef ckjmpbuf * ckjptr;
  40. #define ckjaddr(x) & x
  41. #define ckjdref(x) * x
  42. #ifdef CK_POSIX_SIG
  43. #define cksetjmp(x) sigsetjmp(x,1)
  44. #else
  45. #define cksetjmp(x) setjmp(x,1)
  46. #endif /* CK_POSIX_SIG */
  47. #else /* jmp_buf is an array */
  48. typedef ckjmpbuf ckjptr;
  49. #define ckjaddr(x) x
  50. #define ckjdref(x) x
  51. #ifdef CK_POSIX_SIG
  52. #define cksetjmp sigsetjmp
  53. #else
  54. #define cksetjmp setjmp
  55. #endif /* CK_POSIX_SIG */
  56. #endif /* JBNOTARRAY */
  57. _PROTOTYP( int cc_execute, (ckjptr, ck_sigfunc, ck_sigfunc) );
  58. _PROTOTYP( int alrm_execute,
  59. (ckjptr,
  60. int timo,
  61. ck_sighand handler,
  62. ck_sigfunc, ck_sigfunc) );
  63. _PROTOTYP( int cc_alrm_execute,
  64. (ckjptr,
  65. int timo,
  66. ck_sighand handler,
  67. ck_sigfunc,
  68. ck_sigfunc) );
  69. /* End of ckusig.h */