First version, development moved to 5110-connected machine
[gnokii.git] / common / devices / device.c
index 45330c2..eb81b25 100644 (file)
@@ -8,12 +8,11 @@
 
 */
 
+#include "config.h"
+
 #ifndef WIN32
   #include "devices/unixserial.h"
-  #include "devices/unixirda.h"
-  #include "devices/tekram.h"
   #include <sys/ioctl.h>
-  #include <pthread.h>
   #include <termios.h>
   #include <signal.h>
   #include <errno.h>
@@ -32,9 +31,9 @@
   #include "mversion.h"
 #endif
 
-char PortDevice[GSM_MAX_DEVICE_NAME_LENGTH]={0x00};
+static char PortDevice[GSM_MAX_DEVICE_NAME_LENGTH]={0x00};
 
-bool duringwrite;
+static bool duringwrite;
 
 #ifndef WIN32
 
@@ -43,26 +42,22 @@ bool duringwrite;
   pthread_t selThread;
 #endif
 
-int device_portfd = -1;
+static int device_portfd = -1;
 
 /*
  * Structure to store the filedescriptor we use.
  *
  */
-int device_getfd(void)
+#ifdef DEBUG
+static int device_getfd(void)
 {
   return device_portfd;
 }
+#endif /* DEBUG */
 
-int device_open(__const char *__file, int __with_odd_parity) {
+static int device_open(__const char *__file, int __with_odd_parity) {
 
   switch (CurrentConnectionType) {
-    case GCT_Tekram:
-      device_portfd = tekram_open(__file);
-      break;
-    case GCT_Irda:
-      device_portfd = irda_open();
-      break;
     default:
       device_portfd = serial_opendevice(__file, __with_odd_parity, true, false);
       break;
@@ -79,23 +74,26 @@ void device_close(void)
   //pthread_join(Thread, NULL);
 
   switch (CurrentConnectionType) {
-    case GCT_Tekram: tekram_close(device_portfd); break;
-    case GCT_Irda  :   irda_close(device_portfd); break;
     default        : serial_close(device_portfd); break;
   }
 
   PortDevice[0]=0x00;
 }
 
+#ifndef UCLINUX
+
 void device_reset(void) {
 }
 
+#endif /* UCLINUX */
+
+#ifdef DEBUG
+static void device_dumpserial(void);
+#endif /* DEBUG */
+
 void device_setdtrrts(int __dtr, int __rts)
 {
   switch (CurrentConnectionType) {
-    case GCT_Tekram:
-    case GCT_Irda:
-      break;
     default:
       serial_setdtrrts(device_portfd, __dtr, __rts);
 #ifdef DEBUG
@@ -108,11 +106,6 @@ void device_setdtrrts(int __dtr, int __rts)
 void device_changespeed(int __speed)
 {
   switch (CurrentConnectionType) {
-    case GCT_Irda:
-      break;
-    case GCT_Tekram:
-      tekram_changespeed(device_portfd, __speed);
-      break;
     default:
       serial_changespeed(device_portfd, __speed);
 #ifdef DEBUG
@@ -122,11 +115,9 @@ void device_changespeed(int __speed)
   }
 }
 
-size_t device_read(__ptr_t __buf, size_t __nbytes)
+static size_t device_read(__ptr_t __buf, size_t __nbytes)
 {
   switch (CurrentConnectionType) {
-    case GCT_Tekram: return (tekram_read(device_portfd, __buf, __nbytes)); break;
-    case GCT_Irda  : return (  irda_read(device_portfd, __buf, __nbytes)); break;
     default        : return (serial_read(device_portfd, __buf, __nbytes)); break;
   }
 }
@@ -142,8 +133,6 @@ size_t device_write(__const __ptr_t __buf, size_t __n) {
 
   duringwrite=true;
   switch (CurrentConnectionType) {
-    case GCT_Irda  : mysize =   irda_write(device_portfd, __buf, __n); break;
-    case GCT_Tekram: mysize = tekram_write(device_portfd, __buf, __n); break;      
     default        : mysize = serial_write(device_portfd, __buf, __n); break;
   }
   duringwrite=false;
@@ -151,7 +140,7 @@ size_t device_write(__const __ptr_t __buf, size_t __n) {
 }
 
 #ifdef DEBUG
-void device_dumpserial(void)
+static void device_dumpserial(void)
 {
   int PortFD;
   unsigned int Flags=0;
@@ -168,7 +157,7 @@ void device_dumpserial(void)
 }
 #endif /* DEBUG */
 
-void SigHandler(int status)
+static void SigHandler(int status)
 {
 
   unsigned char buffer[2048];
@@ -223,6 +212,7 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
   struct sigaction sig_io;
 #endif
 
+#ifndef UCLINUX
 #ifdef DEBUG
       if ((strstr(GSM_Info->IrdaModels,"decode")!=NULL) &&  (CurrentConnectionType == GCT_Irda))
        {
@@ -230,6 +220,7 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
          return true;
        }
 #endif 
+#endif /* UCLINUX */
 
   if (PortDevice[0]!=0x00) return true;
 
@@ -254,13 +245,12 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
   strcpy(text,"Connection ");
   switch (con) {
     case GCT_FBUS    :strcpy(text+strlen(text),"FBUS");break;
-    case GCT_Infrared:strcpy(text+strlen(text),"infrared");break;
-    case GCT_Irda    :strcpy(text+strlen(text),"irda sockets");break;
+#ifndef UCLINUX
     case GCT_MBUS    :strcpy(text+strlen(text),"MBUS");break;
     case GCT_DLR3    :strcpy(text+strlen(text),"DLR3");break;
-    case GCT_Tekram  :strcpy(text+strlen(text),"Tekram");break;
     case GCT_AT      :strcpy(text+strlen(text),"AT");break;
     default          :strcpy(text+strlen(text),"unknown");break;
+#endif /* UCLINUX */
   }
   strcpy(text+strlen(text),"\n");
   AppendLogText(text,false);
@@ -415,11 +405,8 @@ bool StartConnection (char *port_device, bool with_odd_parity, GSM_ConnectionTyp
   strcpy(text,"Connection ");
   switch (con) {
     case GCT_FBUS    :strcpy(text+strlen(text),"FBUS");break;
-    case GCT_Infrared:strcpy(text+strlen(text),"infrared");break;
-    case GCT_Irda    :strcpy(text+strlen(text),"irda sockets");break;
     case GCT_MBUS    :strcpy(text+strlen(text),"MBUS");break;
     case GCT_DLR3    :strcpy(text+strlen(text),"DLR3");break;
-    case GCT_Tekram  :strcpy(text+strlen(text),"Tekram");break;
     case GCT_AT      :strcpy(text+strlen(text),"AT");break;
     default          :strcpy(text+strlen(text),"unknown");break;
   }