fix ruby prefix to work for distcheck
[comedilib.git] / lib / libinternal.h
1 /*
2     lib/libinternal.h
3     internal definitions for comedilib
4
5     COMEDILIB - Linux Control and Measurement Device Interface Library
6     Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org>
7
8     This library is free software; you can redistribute it and/or
9     modify it under the terms of the GNU Lesser General Public
10     License as published by the Free Software Foundation, version 2.1
11     of the License.
12
13     This library is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     Lesser General Public License for more details.
17
18     You should have received a copy of the GNU Lesser General Public
19     License along with this library; if not, write to the Free Software
20     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
21     USA.
22 */
23
24 #ifndef _LIBINTERNAL_H
25 #define _LIBINTERNAL_H
26
27 #define _COMEDILIB_DEPRECATED
28
29 #include "comedilib.h"
30 #include "comedi.h"
31 #include "comedi_errno.h"
32 #include <sys/ioctl.h>
33 #include <fcntl.h>
34 #include <stdio.h>
35 #ifdef I18N
36 #include <libintl.h>
37 #endif
38
39 /* This indicates a symbol that should not be exported as part of
40  * the library.  But I don't know how to make it useful yet. */
41 #define INTERNAL
42
43 /* gettext()ization */
44
45 #ifdef I18N
46 #define GETTEXT(a) gettext((a))
47 #else
48 #define GETTEXT(a) (a)
49 #endif
50 #define _s(a) (a)
51
52
53 #define debug_ptr(a)    if(!(a))fprintf(stderr," ** NULL pointer: " __FILE__ ", line %d\n",__LINE__);
54 #define debug_int(a)    if((a)<0)fprintf(stderr," ** error: " __FILE__ ", line %d\n",__LINE__);
55
56 #define COMEDILIB_DEBUG(level,format,args...) do{if(__comedi_loglevel>=(level))fprintf(stderr,"%s: " format, __FUNCTION__ , ##args);}while(0)
57
58 #define COMEDILIB_MAGIC 0xc001dafe
59
60 /* handle versioning */
61
62 #define EXPORT_SYMBOL(a,b) __asm__(".symver " #a "," #a "@v" #b )
63 #define EXPORT_ALIAS_VER(a,b,c) __asm__(".symver " #a "," #b "@v" #c )
64 #define EXPORT_ALIAS_DEFAULT(a,b,c) __asm__(".symver " #a "," #b "@@v" #c )
65
66
67 extern int __comedi_init;
68 extern int __comedi_loglevel;
69 extern int __comedi_errno;
70
71 #if 0
72
73 #define libc_error()            (__comedi_errno=errno)
74 #define internal_error(a)       (__comedi_errno=(a))
75
76 #else
77
78 void libc_error(void);
79 void internal_error(int error_number);
80
81 #endif
82
83
84 typedef struct subdevice_struct subdevice;
85 typedef struct device_struct device;
86
87 struct comedi_t_struct{
88         int magic;
89
90         int fd;
91         int n_subdevices;
92
93         comedi_devinfo devinfo;
94
95         subdevice *subdevices;
96
97         unsigned int has_insnlist_ioctl;
98         unsigned int has_insn_ioctl;
99 };
100
101 struct subdevice_struct{
102         unsigned int type;
103         unsigned int n_chan;
104         unsigned int subd_flags;
105         unsigned int timer_type;
106         unsigned int len_chanlist;
107         lsampl_t maxdata;
108         unsigned int flags;
109         unsigned int range_type;
110
111         lsampl_t *maxdata_list;
112         unsigned int *range_type_list;
113         unsigned int *flags_list;
114
115         comedi_range *rangeinfo;
116         comedi_range **rangeinfo_list;
117
118         unsigned int has_cmd;
119         unsigned int has_insn_bits;
120
121         int cmd_mask_errno;
122         comedi_cmd *cmd_mask;
123         int cmd_timed_errno;
124         comedi_cmd *cmd_timed;
125 };
126
127 #define comedi_ioctl _comedi_ioctl
128 //#define comedi_ioctl _comedi_ioctl_debug
129
130 int _comedi_ioctl( int fd, int request, unsigned long arg );
131 int _comedi_ioctl_debug(int,int,unsigned long);
132
133 /* filler routines */
134
135 int get_subdevices(comedi_t *it);
136 comedi_range *get_rangeinfo(int fd,unsigned int range_type);
137
138 /* validators */
139
140 int valid_dev(comedi_t *it);
141 int valid_subd(comedi_t *it,unsigned int subdevice);
142 int valid_chan(comedi_t *it,unsigned int subdevice,unsigned int chan);
143
144 enum{
145         COMEDILIB_NOERROR = 0x1000,
146         COMEDILIB_UNKNOWN,
147         COMEDILIB_BADDEV,
148         COMEDILIB_BADSUBD,
149         COMEDILIB_BADCHAN,
150 };
151
152 /* used by range.c, was in comedilib.h but apparently deprecated so I put it here - fmhess */
153 int comedi_get_rangetype(comedi_t *it,unsigned int subdevice,unsigned int chan);
154
155 #define YY_DECL int calib_yylex( YYSTYPE *calib_lvalp, YYLTYPE *calib_llocp )
156 void calib_yyerror( char *s );
157 int calib_yyparse( void *parse_arg );
158 void calib_yyrestart( FILE *input );
159
160 #endif
161