http://marcin-wiacek.fkn.pl/english/zips/mygnokii.tar.gz
[gnokii.git] / common / data / datapump.c
index 969091a..4eede53 100644 (file)
@@ -6,28 +6,12 @@
 
   A Linux/Unix toolset and driver for Nokia mobile phones.
 
 
   A Linux/Unix toolset and driver for Nokia mobile phones.
 
-  Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml.
-
   Released under the terms of the GNU GPL, see file COPYING for more details.
 
   This file provides routines to handle processing of data when connected in
   fax or data mode. Converts data from/to GSM phone to virtual modem
   interface.
 
   Released under the terms of the GNU GPL, see file COPYING for more details.
 
   This file provides routines to handle processing of data when connected in
   fax or data mode. Converts data from/to GSM phone to virtual modem
   interface.
 
-  $Log$
-  Revision 1.1.1.1  2001/11/25 21:59:07  short
-  :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001
-
-  Revision 1.4  2001/11/17 16:41:35  pkot
-  Cleanup
-
-  Revision 1.3  2001/02/21 19:57:00  chris
-  More fiddling with the directory layout
-
-  Revision 1.2  2001/02/17 22:40:51  chris
-  ATA support
-
-
 */
 
 #define                __data_datapump_c
 */
 
 #define                __data_datapump_c
@@ -69,12 +53,12 @@ bool DP_Initialise(int read_fd, int write_fd)
 {
        PtyRDFD = read_fd;
        PtyWRFD = write_fd;
 {
        PtyRDFD = read_fd;
        PtyWRFD = write_fd;
-       ufds.fd = PtyRDFD;
-       ufds.events = POLLIN;
+       ufds.fd=PtyRDFD;
+       ufds.events=POLLIN;
        RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
        RLP_Initialise(GSM->SendRLPFrame, DP_CallBack);
-       RLP_SetUserRequest(Attach_Req, true);
-       pluscount = 0;
-       connected = false;
+       RLP_SetUserRequest(Attach_Req,true);
+       pluscount=0;
+       connected=false;
        return true;
 }
 
        return true;
 }
 
@@ -85,76 +69,78 @@ int DP_CallBack(RLP_UserInds ind, u8 *buffer, int length)
 
        switch(ind) {
        case Data:
 
        switch(ind) {
        case Data:
-               if (CommandMode == false) write(PtyWRFD, buffer, length);
+               if (CommandMode==false) write(PtyWRFD, buffer, length);
                break;
        case Conn_Ind:
                break;
        case Conn_Ind:
-               if (CommandMode == false) ATEM_ModemResult(MR_CARRIER);
-               RLP_SetUserRequest(Conn_Req, true);
+               if (CommandMode==false) ATEM_ModemResult(MR_CARRIER);
+               RLP_SetUserRequest(Conn_Req,true);
                break;
        case StatusChange:
                break;
        case StatusChange:
-               if (buffer[0] == 0) {
-                       connected = true;
-                       if (CommandMode == false) ATEM_ModemResult(MR_CONNECT);
+               if (buffer[0]==0) {
+                       connected=true;
+                       if (CommandMode==false) ATEM_ModemResult(MR_CONNECT);
                }
                break;
        case Disc_Ind:
                }
                break;
        case Disc_Ind:
-               if (CommandMode == false) ATEM_ModemResult(MR_NOCARRIER);
-               connected = false;
+               if (CommandMode==false) ATEM_ModemResult(MR_NOCARRIER);
+               connected=false;
                /* Set the call passup back to the at emulator */
                /* Set the call passup back to the at emulator */
-               GSM->DialData(NULL, -1, &ATEM_CallPassup);
-               CommandMode = true;
+               GSM->DialData(NULL,-1,&ATEM_CallPassup);
+               CommandMode=true;
                break;
        case Reset_Ind:
                break;
        case Reset_Ind:
-               RLP_SetUserRequest(Reset_Resp, true);
+               RLP_SetUserRequest(Reset_Resp,true);
                break;
        case GetData:
                break;
        case GetData:
-               if (poll(&ufds, 1, 0)) {
+               if (poll(&ufds,1,0)) {
 
                        /* Check if the program has closed */
                        /* Return to command mode */
                        /* Note that the call will still be in progress, */
                        /* as with a normal modem (I think) */
 
 
                        /* Check if the program has closed */
                        /* Return to command mode */
                        /* Note that the call will still be in progress, */
                        /* as with a normal modem (I think) */
 
-                       if (ufds.revents != POLLIN) { 
-                               CommandMode = true;
+                       if (ufds.revents!=POLLIN) { 
+                               CommandMode=true;
                                /* Set the call passup back to the at emulator */
                                /* Set the call passup back to the at emulator */
-                               GSM->DialData(NULL, -1, &ATEM_CallPassup);
+                               GSM->DialData(NULL,-1,&ATEM_CallPassup);
                                return 0;
                        }
 
                        temp = read(PtyRDFD, buffer, length);
 
                                return 0;
                        }
 
                        temp = read(PtyRDFD, buffer, length);
 
-                       if (temp < 0) return 0; /* FIXME - what do we do now? */
+                       if (temp<0) return 0; /* FIXME - what do we do now? */
 
                        /* This will only check +++ and the beginning of a read */
                        /* But there should be a pause before it anyway */
       
 
                        /* This will only check +++ and the beginning of a read */
                        /* But there should be a pause before it anyway */
       
-                       if (buffer[0] == '+') {
+                       if (buffer[0]=='+') {
                                pluscount++;
                                pluscount++;
-                               if (temp > 1) {
-                                       if (buffer[1] == '+') pluscount++;
-                                       else pluscount = 0;
-                                       if (temp > 2) {
-                                               if (buffer[2] == '+') pluscount++;
-                                               else pluscount = 0;
-                                               if (temp > 3) pluscount = 0;
+                               if (temp>1) {
+                                       if (buffer[1]=='+') pluscount++;
+                                       else pluscount=0;
+                                       if (temp>2) {
+                                               if (buffer[2]=='+') pluscount++;
+                                               else pluscount=0;
+                                               if (temp>3) pluscount=0;
                                        }
                                }
                                        }
                                }
-                       } else pluscount = 0;
+                       } else pluscount=0;
       
       
-                       if (pluscount == 3) {
-                               CommandMode = true;
+                       if (pluscount==3) {
+                               CommandMode=true;
                                /* Set the call passup back to the at emulator */
                                /* Set the call passup back to the at emulator */
-                               GSM->DialData(NULL, -1, &ATEM_CallPassup);
+                               GSM->DialData(NULL,-1,&ATEM_CallPassup);
                                ATEM_ModemResult(MR_OK);
                                break;
                        }
       
                        return temp;
                }
                                ATEM_ModemResult(MR_OK);
                                break;
                        }
       
                        return temp;
                }
+               return 0;
                break;
                break;
+
        default:
        default:
-               break;
+
        }
        return 0;
 }
        }
        return 0;
 }
@@ -163,17 +149,17 @@ void DP_CallPassup(char c)
 {
        switch (c) {
        case 'D':
 {
        switch (c) {
        case 'D':
-               if (CommandMode == false) ATEM_ModemResult(MR_CARRIER);
-               RLP_SetUserRequest(Conn_Req, true);
-               connected = true;
+               if (CommandMode==false) ATEM_ModemResult(MR_CARRIER);
+               RLP_SetUserRequest(Conn_Req,true);
+               connected=true;
                break;
        case ' ':
                break;
        case ' ':
-               CommandMode = true;
+               CommandMode=true;
                /* Set the call passup back to the at emulator */
                /* Set the call passup back to the at emulator */
-               GSM->DialData(NULL, -1, &ATEM_CallPassup);
+               GSM->DialData(NULL,-1,&ATEM_CallPassup);
                ATEM_ModemResult(MR_NOCARRIER);
                RLP_SetUserRequest(Disc_Req, true);
                ATEM_ModemResult(MR_NOCARRIER);
                RLP_SetUserRequest(Disc_Req, true);
-               connected = false;
+               connected=false;
                break;
        default:
                break;
                break;
        default:
                break;