home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sherlock.zip / EXCEPT / EXCEPT.ZIP / SOURCE.ZIP / TRAPPER.C < prev    next >
Text File  |  1993-10-19  |  3KB  |  61 lines

  1. /**********************************************************************/
  2. /*                           IBM DAPTOOLS UseOnly                    */
  3. /**********************************************************************/
  4. /*                                                                    */
  5. /*  TRAPPER                                                           */
  6. /*                                                                    */
  7. /* Program demonstration EXCEPT.DLL usage                             */
  8. /* TrapperQ is preferable (TrapperQ uses EXCEPTQ.DLL)                 */
  9. /* Compiled with IBM C/2 see SAMPLE.C for 32 bit C-SET/2 sample       */
  10. /**********************************************************************/
  11. /* Version: 2.2             |   Marc Fiammante                        */
  12. /**********************************************************************/
  13. /*                                                                    */
  14. /**********************************************************************/
  15. /* History:                                                           */
  16. /* --------                                                           */
  17. /*                                                                    */
  18. /* created: Marc Fiammante December 1992                              */
  19. /**********************************************************************/
  20. #include <mt\stdio.h>
  21. #include <mt\conio.h>
  22. #include <mt\process.h>
  23. #define INCL_BASE
  24. #include <os2.h>
  25. USHORT rc;
  26. PCHAR  Test;
  27. struct _EXCEPTIONREGISTRATIONRECORD
  28.    {
  29.       struct _EXCEPTIONREGISTRATIONRECORD * prev_structure;
  30.       PFN Handler;
  31.    };
  32. typedef struct _EXCEPTIONREGISTRATIONRECORD EXCEPTIONREGISTRATIONRECORD;
  33. typedef struct _EXCEPTIONREGISTRATIONRECORD * PEXCEPTIONREGISTRATIONRECORD;
  34. USHORT EXPENTRY SETEXCEPT(PEXCEPTIONREGISTRATIONRECORD);
  35. TID Tid;
  36. #define STACKSIZE 0x2000
  37. SEL   SelStack;
  38. PCHAR StackPtr;
  39. void   Thread(unsigned far *args);         /* Playing   thread function   */
  40. void cdecl main() {
  41.     EXCEPTIONREGISTRATIONRECORD ExceptReg;
  42.     printf("Setting exception handler\n");
  43.     rc=SETEXCEPT(&ExceptReg);
  44.     DosAllocSeg(STACKSIZE,&SelStack,1);
  45.     StackPtr=MAKEP(SelStack,0);
  46.     Tid=_beginthread(
  47.        Thread,
  48.        (VOID FAR *)StackPtr,
  49.        STACKSIZE,
  50.        NULL);
  51.       getch();
  52. }
  53. void   Thread(unsigned far *args) {
  54.     EXCEPTIONREGISTRATIONRECORD ExceptReg;
  55.     printf("Setting exception handler from the thread\n");
  56.     rc=SETEXCEPT(&ExceptReg);
  57.     printf("Generating the TRAP from thread\n");
  58.     Test=NULL;
  59.     *Test=0;
  60. }
  61.