import source from 1.3.40
[external/swig.git] / Tools / WAD / Wad / return.c
1 /* ----------------------------------------------------------------------------- 
2  * return.c
3  *
4  *     This file manages the set of return-points for the WAD signal handler.
5  * 
6  * Author(s) : David Beazley (beazley@cs.uchicago.edu)
7  *
8  * Copyright (C) 2000.  The University of Chicago. 
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  * 
24  * See the file COPYING for a complete copy of the LGPL.
25  * ----------------------------------------------------------------------------- */
26
27 #include "wad.h"
28
29 static char cvs[] = "$Id: return.c 10001 2007-10-17 21:33:57Z wsfulton $";
30
31 /* Maximum number of return points */
32 #define WAD_NUMBER_RETURN  128
33
34 static WadReturnFunc return_points[WAD_NUMBER_RETURN];
35 static int           num_return = 0;
36
37 void wad_set_return(const char *name, long value) {
38   WadReturnFunc *rp;
39   rp = &return_points[num_return];
40   wad_strcpy(rp->name,name);
41   rp->value = value;
42   num_return++;
43   if (wad_debug_mode & DEBUG_RETURN) {
44     printf("wad: Setting return ('%s', %d)\n", name,value);
45   }
46 }
47
48 void wad_set_returns(WadReturnFunc *rf) {
49   int i = 0;
50   while (strlen(rf[i].name)) {
51     wad_set_return(rf[i].name, rf[i].value);
52     i++;
53   }
54 }
55
56 WadReturnFunc *wad_check_return(const char *name) {
57   int i;
58   if (!name) return 0;
59   for (i = 0; i < num_return; i++) {
60     if (strcmp(name,return_points[i].name) == 0) {
61       if (wad_debug_mode & DEBUG_RETURN) {
62         printf("wad: Found return ('%s', %d)\n", return_points[i].name, return_points[i].value);
63       }
64       return &return_points[i];
65     }
66   }
67   return 0;
68 }
69