home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / except2x.zip / sample.c < prev    next >
Text File  |  1995-06-25  |  3KB  |  68 lines

  1. /**********************************************************************/
  2. /*                           IBM Internal Use Only                    */
  3. /**********************************************************************/
  4. /*                                                                    */
  5. /*  SAMPLE                                                            */
  6. /*                                                                    */
  7. /* SAMPLE 32 bit program to access EXCEPTQ.DLL exception handler      */
  8. /* SAMPLE generates a TRAP to demonstrate information gathering       */
  9. /* C-SET/2 compiler complies that code                                */
  10. /**********************************************************************/
  11. /* Version: 2.2             |   Marc Fiammante (FIAMMANT at LGEVM2)   */
  12. /*                          |   La Gaude FRANCE                       */
  13. /**********************************************************************/
  14. /*                                                                    */
  15. /**********************************************************************/
  16. /* History:                                                           */
  17. /* --------                                                           */
  18. /*                                                                    */
  19. /* created: Marc Fiammante December 1992                              */
  20. /**********************************************************************/
  21.  
  22. /* Following line to tell C-Set compiler to install an exception handler */
  23. /* for main                                                              */
  24. #pragma handler(main)
  25. /* Following line to tell C-Set compiler to use MYHANDLER instead of     */
  26. /* default _Exception handler                                            */
  27. #pragma map (_Exception,"MYHANDLER")
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31.  
  32. void TrapFunc(void);
  33.  
  34. typedef unsigned char BYTE;
  35. typedef unsigned short USHORT;
  36.  
  37.  
  38. struct some_struct {
  39.    BYTE   bByte;
  40.    USHORT uUshort;
  41.    char   *pTest;
  42. };
  43.  
  44. void main(void)
  45. {
  46.     struct some_struct TestStruct;
  47.     USHORT test = 4567;
  48.     USHORT *pUshort;
  49.     struct some_struct *pTestStruct;
  50.  
  51.     printf("Exception handler has been set by compiler\n");
  52.     printf("Generating the TRAP from function\n");
  53.  
  54.     TestStruct.bByte = 123;
  55.     TestStruct.uUshort = 1234;
  56.     TestStruct.pTest = (void *)0;
  57.  
  58.     TrapFunc();
  59. }
  60.  
  61. void TrapFunc() {
  62.     BYTE * Test;
  63.     char * Test1 = "1234";
  64.  
  65.     Test=0;
  66.     *Test=0;
  67. }
  68.