1    | /***************************************
2    |   $Revision: 1.7 $
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   | /* config.h - comes from configure. */
42   | #ifdef HAVE_CONFIG_H
43   | #include "config.h"
44   | #endif
45   | 
46   | /* this is to allow user stubs in the code */
47   | /* it will trigger an error when NOSTUBS is set */
48   | 
49   | #ifndef NOSTUBS
50   | #define STUB(a) do{a;}while(0)
51   | #else
52   | #define STUB(a) hey_here_is_a_stub_left=%^&*&@@@;
53   | #endif
54   | 
55   | /* now these are predefined ones... */
56   | 
57   | #ifndef NOSTUBS
58   | 
59   | /* for memcmp and strcmp */
60   | #define CMP_EQUAL 0
61   | 
62   | /* stub for those compilers (wrrrrrrr....) that can't do (struct != struct) */
63   | #define STRUCT_EQUAL(a,b) (memcmp(&a, &b, sizeof(a)) == CMP_EQUAL)
64   | 
65   | /* this prints the filename and line number where it was placed,
66   |    and then commits suicide (read: segfault) by writing to address NULL.
67   |    This in normal conditions generates a coredump for later analysis.
68   |    
69   |    isdigit() is used to avoid warnings from lint. 
70   |    do..while is to allow treating this macro as a single instruction 
71   |    (eg in an if).
72   | */
73   | 
74   | #define die   do{ \
75   | 	fprintf(stderr,"died: +%d %s\n",__LINE__, __FILE__);\
76   | 	*((int*)NULL)=0; \
77   | 	} while(isdigit('a'))		
78   | 
79   | #define dieif(a) if(a) { \
80   |         fprintf(stderr,"died on "#a" in: +%d %s\n",__LINE__, __FILE__);\
81   | 	*((int*)NULL)=0; \
82   | 	}
83   | 
84   | 
85   | #define SQL_TBLNAM_MAX 32 
86   | 
87   | 
88   | /* struct to hold the table name. 
89   |    Wrapped in a struct to make it behave like a normal object (ref by
90   | value)
91   | 
92   |    in fact, this type should be made engine-dependent.
93   | */
94   | 
95   | typedef struct {              
96   |   char val[SQL_TBLNAM_MAX];
97   | } sql_tblnam_t;
98   | 
99   | /* who knows what key type we will really have in other engines */
100  | typedef long sql_key_t;
101  | 
102  | #define SQ_NOKEY 0L
103  | 
104  | 
105  | #ifdef HAVE_STRSEP
106  | /* good */
107  | #else 
108  | #  if defined(HAVE_STRTOK_R) && !defined(HAVE_STRSEP)
109  | /* emulate strsep with strtok_r 
110  |    by making first arg to strtok_r point to the last 
111  | 
112  | char *
113  | strsep(char **stringp, const char *delim)
114  | {
115  |   return strtok_r( *stringp, delim, stringp);
116  | }
117  | */
118  | #define strsep(a,b) strtok_r( *(a), (b), (a) )
119  | 
120  | #  else
121  | #  error "must have strsep or strtok_r"
122  | #  endif
123  | #endif
124  | 
125  | 
126  | #endif /* NOSTUBS */
127  | #endif /* _STUBS_H */