home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0638.ZIP / CCE_0638 / GNULIB / LIBSRC93.ZOO / catch.c next >
C/C++ Source or Header  |  1991-04-12  |  371b  |  19 lines

  1. #include <setjmp.h>
  2.  
  3. static    int    _catchval;        /* catch/throw return value */
  4.  
  5. int catch(id, fn)            /* execute fn() within a catch frame */
  6.     register jmp_buf id;
  7.     register int (*fn)(void);
  8.     {
  9.     return(setjmp(id) ? _catchval : ((*fn)()));
  10.     }
  11.  
  12. void throw(id, rv)                /* return rv to the id catch */
  13.     register jmp_buf id;
  14.     register int rv;
  15.     {
  16.     _catchval = rv;
  17.     longjmp(id, 1);
  18.     }
  19.