1    | /***************************************
2    |   $Revision: 1.6 $
3    | 
4    |   stubs.h - header file with things defined just to provisionally fix the TBDs.
5    | 
6    |   Status: NOT REVUED, TESTED, INCOMPLETE
7    | 
8    |   Design and implementation by: Marek Bukowy
9    | 
10   |   ******************/ /******************
11   |   Copyright (c) 1999                              RIPE NCC
12   |  
13   |   All Rights Reserved
14   |   
15   |   Permission to use, copy, modify, and distribute this software and its
16   |   documentation for any purpose and without fee is hereby granted,
17   |   provided that the above copyright notice appear in all copies and that
18   |   both that copyright notice and this permission notice appear in
19   |   supporting documentation, and that the name of the author not be
20   |   used in advertising or publicity pertaining to distribution of the
21   |   software without specific, written prior permission.
22   |   
23   |   THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
24   |   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
25   |   AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
26   |   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27   |   AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
28   |   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29   |   ***************************************/
30   | 
31   | /* stubs: just defined to let the other thing compile. Use #define
32   | NOSTUBS to disable it. */
33   | 
34   | #ifndef _STUBS_H
35   | #define _STUBS_H
36   | 
37   | #include <stdlib.h>
38   | #include <stdio.h>
39   | #include <ctype.h>
40   | 
41   | /* this is to allow user stubs in the code */
42   | /* it will trigger an error when NOSTUBS is set */
43   | 
44   | #ifndef NOSTUBS
45   | #define STUB(a) do{a;}while(0)
46   | #else
47   | #define STUB(a) hey_here_is_a_stub_left=%^&*&@@@;
48   | #endif
49   | 
50   | /* now these are predefined ones... */
51   | 
52   | #ifndef NOSTUBS
53   | 
54   | /* for memcmp and strcmp */
55   | #define CMP_EQUAL 0
56   | 
57   | /* stub for those compilers (wrrrrrrr....) that can't do (struct != struct) */
58   | #define STRUCT_EQUAL(a,b) (memcmp(&a, &b, sizeof(a)) == CMP_EQUAL)
59   | 
60   | /* this prints the filename and line number where it was placed,
61   |    and then commits suicide (read: segfault) by writing to address NULL.
62   |    This in normal conditions generates a coredump for later analysis.
63   |    
64   |    isdigit() is used to avoid warnings from lint. 
65   |    do..while is to allow treating this macro as a single instruction 
66   |    (eg in an if).
67   | */
68   | 
69   | #define die   do{ \
70   | 	fprintf(stderr,"died: +%d %s\n",__LINE__, __FILE__);\
71   | 	*((int*)NULL)=0; \
72   | 	} while(isdigit('a'))		
73   | 
74   | #define dieif(a) if(a) { \
75   |         fprintf(stderr,"died on "#a" in: +%d %s\n",__LINE__, __FILE__);\
76   | 	*((int*)NULL)=0; \
77   | 	}
78   | 
79   | 
80   | #define SQL_TBLNAM_MAX 32 
81   | 
82   | 
83   | /* struct to hold the table name. 
84   |    Wrapped in a struct to make it behave like a normal object (ref by
85   | value)
86   | 
87   |    in fact, this type should be made engine-dependent.
88   | */
89   | 
90   | typedef struct {              
91   |   char val[SQL_TBLNAM_MAX];
92   | } sql_tblnam_t;
93   | 
94   | /* who knows what key type we will really have in other engines */
95   | typedef long sql_key_t;
96   | 
97   | #define SQ_NOKEY 0L
98   | 
99   | 
100  | #ifdef HAVE_STRSEP
101  | /* good */
102  | #else 
103  | #  if defined(HAVE_STRTOK_R) && !defined(HAVE_STRSEP)
104  | /* emulate strsep with strtok_r 
105  |    by making first arg to strtok_r point to the last 
106  | 
107  | char *
108  | strsep(char **stringp, const char *delim)
109  | {
110  |   return strtok_r( *stringp, delim, stringp);
111  | }
112  | */
113  | #define strsep(a,b) strtok_r( *(a), (b), (a) )
114  | 
115  | #  else
116  | #  error "must have strsep or strtok_r"
117  | #  endif
118  | #endif
119  | 
120  | 
121  | #endif /* NOSTUBS */
122  | #endif /* _STUBS_H */