©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

c9/jmp.c

Go to the documentation of this file.
00001 /*
00002     longjmp example
00003     AUP2, Sec. 9.06
00004 
00005     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00006     May be copied only for purposes and under conditions described
00007     on the Web page www.basepath.com/aup/copyright.htm.
00008 
00009     The Example Files are provided "as is," without any warranty;
00010     without even the implied warranty of merchantability or fitness
00011     for a particular purpose. The author and his publisher are not
00012     responsible for any damages, direct or incidental, resulting
00013     from the use or non-use of these Example Files.
00014 
00015     The Example Files may contain defects, and some contain deliberate
00016     coding mistakes that were included for educational reasons.
00017     You are responsible for determining if and how the Example Files
00018     are to be used.
00019 
00020 */
00021 #include "defs.h"
00022 #include <setjmp.h>
00023 /*[pgm]*/
00024 static jmp_buf loc_info;
00025 
00026 static void fcn2(void)
00027 {
00028     printf("In fcn2\n");
00029     longjmp(loc_info, 1234);
00030     printf("Leaving fcn2\n");
00031 }
00032 
00033 static void fcn1(void)
00034 {
00035     printf("In fcn1\n");
00036     fcn2();
00037     printf("Leaving fcn1\n");
00038 }
00039 
00040 int main(void)
00041 {
00042     int rtn;
00043 
00044     rtn = setjmp(loc_info);
00045     printf("setjmp returned %d\n", rtn);
00046     if (rtn == 0)
00047         fcn1();
00048     printf("Exiting\n");
00049     exit(EXIT_SUCCESS);
00050 }
00051 /*[]*/

Generated on Fri Apr 23 10:57:03 2004 for AUP2 Example Source by doxygen 1.3.1