This commit was manufactured by cvs2svn to create tag
[gnokii.git] / common / gsm-sms.c
index cfc0061..9fbb114 100644 (file)
@@ -8,8 +8,6 @@
        
 */
 
-#include "config.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -20,7 +18,7 @@
 #include "gsm-coding.h"
 
 /* User data headers */
-static GSM_UDHHeader UDHHeaders[] = {
+GSM_UDHHeader UDHHeaders[] = {
   { GSM_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00" },
       /* See GSM 03.40 section 9.2.3.24.1 */
   { GSM_DisableVoice,         0x04, "\x01\x02\x00\x00" },
@@ -69,8 +67,7 @@ static GSM_UDHHeader UDHHeaders[] = {
 
 #define ByteMask ((1 << Bits) - 1)
 
-#ifndef UCLINUX
-static int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output)
+int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output)
 {
         unsigned char *OUT = output; /* Current pointer to the output buffer */
         unsigned char *IN  = input;  /* Current pointer to the input buffer */
@@ -262,7 +259,7 @@ GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
 }
 
 /* See GSM 03.40 section 9.2.3.11 */
-static GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
+GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
 {
   DT->Year    = DecodeWithBCDAlphabet(req[0]);
   DT->Month   = DecodeWithBCDAlphabet(req[1]);
@@ -295,7 +292,7 @@ static GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req)
   return GE_NONE;
 }
 
-static int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
+int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
 {
   int off,size=0,size2=0,w,i;
 
@@ -350,7 +347,7 @@ static int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *
       ETSI->TPDCS |= 0x08;
 
 #ifdef DEBUG
-      fprintf(stdout,_("SMS Length is %ld\n"),(long)strlen(SMS->MessageText));
+      fprintf(stdout,_("SMS Length is %i\n"),strlen(SMS->MessageText));
 #endif
 
       EncodeUnicode (ETSI->MessageText+off,SMS->MessageText,strlen(SMS->MessageText));
@@ -494,7 +491,7 @@ GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *E
       fprintf(stdout, "   7 bit SMS, body is (length %i): ",SMS->Length);
 #endif /* DEBUG */
 
-      DecodeDefault (SMS->MessageText, output, tmp);
+      DecodeDefault (SMS->MessageText, output, SMS->Length);
 
 #ifdef DEBUG
       fprintf(stdout, "%s\n",SMS->MessageText);          
@@ -733,6 +730,7 @@ GSM_Error GSM_EncodeETSISMSSubmitValidity(GSM_SMSMessage *SMS,GSM_ETSISMSMessage
 GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length)
 {
   int size=0;
+  GSM_Error error;
 
   ETSI->firstbyte=0;
   ETSI->TPPID=0;
@@ -752,8 +750,10 @@ GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_M
       /* Mask for request for delivery report from SMSC */
       if (SMS->Type == GST_DR) ETSI->firstbyte |= 32;
 
-      GSM_EncodeETSISMSSubmitHeader(SMS, ETSI);
-      GSM_EncodeETSISMSSubmitValidity(SMS, ETSI);
+      error=GSM_EncodeETSISMSSubmitHeader(SMS, ETSI);
+      if (error!=GE_NONE) return error;
+      error=GSM_EncodeETSISMSSubmitValidity(SMS, ETSI);
+      if (error!=GE_NONE) return error;
       size=GSM_EncodeETSISMSSubmitData(SMS, ETSI);
 
       break;
@@ -763,7 +763,8 @@ GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_M
       /* Bits 1 and 0: 00. SMS-Deliver */
       ETSI->firstbyte |= 0x00;
 
-      GSM_EncodeETSISMSSubmitHeader(SMS, ETSI);
+      error=GSM_EncodeETSISMSSubmitHeader(SMS, ETSI);
+      if (error!=GE_NONE) return error;
       GSM_EncodeSMSDateTime(&SMS->Time, ETSI->DeliveryDateTime);
       size=GSM_EncodeETSISMSSubmitData(SMS, ETSI);
 
@@ -824,9 +825,8 @@ GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI)
 
   return GE_NONE;
 }
-#endif /* UCLINUX */
 
-static void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
+void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
 {
   struct tm *now;
   time_t nowh;
@@ -891,9 +891,6 @@ static void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS)
    - GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24
    - Smart Messaging Specification, Revision 1.0.0, September 15, 1997
 */
-#ifdef UCLINUX
-static
-#endif /* UCLINUX */
 GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType)
 {
        int i=0;
@@ -917,7 +914,7 @@ GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType)
        return GE_NONE;
 }
 
-static int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
+int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS,
     unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding){
 
   int j;