added some dependency file generation
[comedilib.git] / lib / comedi.c
index 2b7499b99d24e20b7915bac624ec6716128c9dcb..b0c4d0caf6ae6a4cd50a8f09c06c81ba56bf1b36 100644 (file)
@@ -1,24 +1,24 @@
 /*
     lib/comedi.c
-    comedi library routines
+    generic functions
 
-    COMEDI - Linux Control and Measurement Device Interface
-    Copyright (C) 1997-8 David A. Schleef <ds@stm.lbl.gov>
+    COMEDILIB - Linux Control and Measurement Device Interface Library
+    Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org>
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation, version 2.1
+    of the License.
 
-    This program is distributed in the hope that it will be useful,
+    This library is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
 
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+    USA.
 */
 
 #include <stdio.h>
@@ -33,7 +33,7 @@
 #include <comedi.h>
 #include <string.h>
 
-#include <libinternal.h>
+#include "libinternal.h"
 
 INTERNAL int __comedi_init=0;
 
@@ -45,10 +45,11 @@ INTERNAL void initialize(void)
 
        if( (s=getenv("COMEDILIB_LOGLEVEL")) ){
                __comedi_loglevel=strtol(s,NULL,0);
-               DEBUG(3,"setting loglevel to %d\n",__comedi_loglevel);
+               COMEDILIB_DEBUG(3,"setting loglevel to %d\n",__comedi_loglevel);
        }
 }
   
+EXPORT_SYMBOL(comedi_open,0.7.18);
 comedi_t *comedi_open(const char *fn)
 {
        comedi_t *it;
@@ -65,7 +66,7 @@ comedi_t *comedi_open(const char *fn)
                goto cleanup;
        }
 
-       if(ioctl_devinfo(it->fd,&it->devinfo)<0)
+       if(comedi_ioctl(it->fd, COMEDI_DEVINFO, (unsigned long)&it->devinfo)<0)
                goto cleanup;
 
        it->n_subdevices=it->devinfo.n_subdevs;
@@ -82,11 +83,7 @@ cleanup:
        return NULL;
 }
 
-#if 0
-/* this is an example of how we do versioned symbols */
-__asm__(".symver comedi_open_0,comedi_open@");
-#endif
-
+EXPORT_SYMBOL(comedi_close,0.7.18);
 int comedi_close(comedi_t *it)
 {
        subdevice *s;
@@ -122,16 +119,19 @@ int comedi_close(comedi_t *it)
        return 0;
 }
 
+EXPORT_SYMBOL(comedi_cancel,0.7.18);
 int comedi_cancel(comedi_t *it,unsigned int subdevice)
 {
-       return ioctl(it->fd,COMEDI_CANCEL,subdevice);
+       return comedi_ioctl(it->fd,COMEDI_CANCEL,subdevice);
 }
 
+EXPORT_SYMBOL(comedi_poll,0.7.18);
 int comedi_poll(comedi_t *it,unsigned int subdevice)
 {
-       return ioctl(it->fd,COMEDI_POLL,subdevice);
+       return comedi_ioctl(it->fd,COMEDI_POLL,subdevice);
 }
 
+EXPORT_SYMBOL(comedi_fileno,0.7.18);
 int comedi_fileno(comedi_t *it)
 {
        if(!it)
@@ -140,18 +140,20 @@ int comedi_fileno(comedi_t *it)
        return it->fd;
 }
 
+EXPORT_SYMBOL(comedi_trigger,0.7.18);
 int comedi_trigger(comedi_t *it,comedi_trig *t)
 {
        if(!it || !t)
                return -1;
 
-       return ioctl_trigger(it->fd,t);
+       return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)t);
 }
 
+EXPORT_SYMBOL(comedi_command,0.7.18);
 int comedi_command(comedi_t *it,comedi_cmd *t)
 {
        int ret;
-       ret = ioctl(it->fd,COMEDI_CMD,t);
+       ret = comedi_ioctl(it->fd, COMEDI_CMD, (unsigned long)t);
        __comedi_errno = errno;
        switch(__comedi_errno){
        case EIO:
@@ -161,10 +163,11 @@ int comedi_command(comedi_t *it,comedi_cmd *t)
        return ret;
 }
 
+EXPORT_SYMBOL(comedi_command_test,0.7.18);
 int comedi_command_test(comedi_t *it,comedi_cmd *t)
 {
        int ret;
-       ret = ioctl(it->fd,COMEDI_CMDTEST,t);
+       ret = comedi_ioctl(it->fd, COMEDI_CMDTEST, (unsigned long)t);
        __comedi_errno = errno;
        switch(__comedi_errno){
        case EIO:
@@ -174,18 +177,20 @@ int comedi_command_test(comedi_t *it,comedi_cmd *t)
        return ret;
 }
 
+EXPORT_SYMBOL(comedi_do_insnlist,0.7.18);
 int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il)
 {
        int ret;
-       ret = ioctl(it->fd,COMEDI_INSNLIST,il);
+       ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)il);
        __comedi_errno = errno;
        return ret;
 }
 
+EXPORT_SYMBOL(comedi_do_insn,0.7.18);
 int comedi_do_insn(comedi_t *it,comedi_insn *insn)
 {
        if(it->has_insn_ioctl){
-               return ioctl(it->fd,COMEDI_INSN,insn);
+               return comedi_ioctl(it->fd, COMEDI_INSN, (unsigned long)insn);
        }else{
                comedi_insnlist il;
                int ret;
@@ -193,20 +198,22 @@ int comedi_do_insn(comedi_t *it,comedi_insn *insn)
                il.n_insns = 1;
                il.insns = insn;
 
-               ret = ioctl(it->fd,COMEDI_INSNLIST,&il);
+               ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)&il);
 
                if(ret<0)return ret;
                return insn->n;
        }
 }
 
+EXPORT_SYMBOL(comedi_lock,0.7.18);
 int comedi_lock(comedi_t *it,unsigned int subdevice)
 {
-       return ioctl(it->fd,COMEDI_LOCK,subdevice);
+       return comedi_ioctl(it->fd, COMEDI_LOCK, subdevice);
 }
 
+EXPORT_SYMBOL(comedi_unlock,0.7.18);
 int comedi_unlock(comedi_t *it,unsigned int subdevice)
 {
-       return ioctl(it->fd,COMEDI_UNLOCK,subdevice);
+       return comedi_ioctl(it->fd, COMEDI_UNLOCK, subdevice);
 }