This commit was generated by cvs2svn to compensate for changes in r96, which
[gnokii.git] / gnokii / gnokii.c
index 43beca6..106b367 100644 (file)
@@ -867,6 +867,7 @@ int usage(void)
   fprintf(stdout, _(
 "          gnokii --sniff [port]\n"
 "          gnokii --decodefile file\n"
+"          gnokii --getbinringfromfile file name offset file2\n"
   ));
 #endif
 
@@ -1046,6 +1047,7 @@ int main(int argc, char *argv[])
 #ifdef DEBUG
     { "sniff",              optional_argument, NULL, OPT_SNIFFER    },// Will show datas from port
     { "decodefile",         required_argument, NULL, OPT_DECODEFILE },//decode input file
+    { "getbinringfromfile", required_argument, NULL, OPT_GETBINRINGFROMFILE },
 #endif
 
     { 0, 0, 0, 0},
@@ -1067,6 +1069,7 @@ int main(int argc, char *argv[])
 #ifdef DEBUG
     { OPT_SNIFFER,           0, 1, 0 },
     { OPT_DECODEFILE,        1, 1, 0 },
+    { OPT_GETBINRINGFROMFILE,4, 4, 0 },
 #endif
 
     { OPT_SETDATETIME,       0, 5, 0 },
@@ -1215,6 +1218,7 @@ int main(int argc, char *argv[])
 #ifdef DEBUG
     case OPT_SNIFFER:               rc = sniff(nargc, nargv);       break;
     case OPT_DECODEFILE:            rc = decodefile(nargc, nargv);  break;
+    case OPT_GETBINRINGFROMFILE:    rc = getbinringfromfile(nargc, nargv);break;
 #endif                                 
        
     // Now, options with arguments
@@ -1302,7 +1306,141 @@ int main(int argc, char *argv[])
 /* Restores various phone settings from one file */
 int restoresettings(char *argv[])
 {
-  fprintf(stdout,_("Work in progress. Not usefull now. Sorry\n"));
+  GSM_Backup Backup;
+  GSM_PhonebookEntry pbk;
+
+  int confirm;
+  char ans[4];
+
+  int i,pos;
+
+  GSM_MemoryStatus SIMMemoryStatus = {GMT_SM, 0, 0};
+  GSM_MemoryStatus PhoneMemoryStatus = {GMT_ME, 0, 0};
+
+  if (GSM_ReadBackupFile(argv[0], &Backup)!=GE_NONE) return 1;
+
+  fbusinit(NULL);
+
+  if (Backup.SIMPhonebookUsed!=0) {
+    confirm=-1;    
+    while (confirm < 0) {
+      fprintf(stderr, _("Restore SIM phonebook ? "));
+      GetLine(stdin, ans, 99);
+      if (!strcmp(ans, "yes")) confirm = 1;
+      if (!strcmp(ans, "no" )) confirm = 0;
+    }
+    if (confirm==1) {
+      if (GSM->GetMemoryStatus(&SIMMemoryStatus) != GE_NONE) {
+        fprintf(stderr,_("Error getting memory status !\n"));
+        GSM->Terminate();
+      }
+      i=0;pos=1;
+
+      while ((pos-1)!=SIMMemoryStatus.Used+SIMMemoryStatus.Free) {
+        pbk.Location=pos;
+        pbk.MemoryType=GMT_SM;
+        pbk.Name[0]=0;
+        pbk.Number[0]=0;
+        pbk.SubEntriesCount = 0;
+        if (i<Backup.SIMPhonebookUsed) {
+          if (Backup.SIMPhonebook[i].Location==pbk.Location) {
+            pbk=Backup.SIMPhonebook[i];
+            i++;
+//#ifdef DEBUG
+//            fprintf(stdout,_("Copying from backup\n"));
+//#endif
+          }
+        }
+//#ifdef DEBUG
+//        fprintf(stdout,_("Setting location %i\n"),pbk.Location);
+//#endif
+        GSM->WritePhonebookLocation(&pbk);
+       fprintf(stderr,_("."));
+        pos++;
+      }
+      fprintf(stderr,_("\n"));
+    }
+  }
+  if (Backup.PhonePhonebookUsed!=0) {
+    confirm=-1;    
+    while (confirm < 0) {
+      fprintf(stderr, _("Restore phone phonebook ? "));
+      GetLine(stdin, ans, 99);
+      if (!strcmp(ans, "yes")) confirm = 1;
+      if (!strcmp(ans, "no" )) confirm = 0;
+    }
+    if (confirm==1) {
+      if (GSM->GetMemoryStatus(&PhoneMemoryStatus) != GE_NONE) {
+        fprintf(stderr,_("Error getting memory status !\n"));
+        GSM->Terminate();
+      }
+
+      i=0;pos=1;
+
+      while ((pos-1)!=PhoneMemoryStatus.Used+PhoneMemoryStatus.Free) {
+        pbk.Location=pos;
+        pbk.MemoryType=GMT_ME;
+        pbk.Name[0]=0;
+        pbk.Number[0]=0;
+        pbk.SubEntriesCount = 0;
+        if (i<Backup.PhonePhonebookUsed) {
+          if (Backup.PhonePhonebook[i].Location==pbk.Location) {
+            pbk=Backup.PhonePhonebook[i];
+            i++;
+//#ifdef DEBUG
+//            fprintf(stdout,_("Copying from backup\n"));
+//#endif
+          }
+        }
+//#ifdef DEBUG
+//        fprintf(stdout,_("Setting location %i\n"),pbk.Location);
+//#endif
+        GSM->WritePhonebookLocation(&pbk);
+       fprintf(stderr,_("."));
+        pos++;
+      }
+      fprintf(stderr,_("\n"));
+    }
+  }
+  if (Backup.CallerAvailable==true) {
+    confirm=-1;    
+    while (confirm < 0) {
+      fprintf(stderr, _("Restore caller groups ? "));
+      GetLine(stdin, ans, 99);
+      if (!strcmp(ans, "yes")) confirm = 1;
+      if (!strcmp(ans, "no" )) confirm = 0;
+    }
+    if (confirm==1) {
+      for (i=0;i<5;i++) GSM->SetBitmap(&Backup.CallerGroups[i]);
+    }
+  }
+  if (Backup.OperatorLogoAvailable==true) {
+    confirm=-1;    
+    while (confirm < 0) {
+      fprintf(stderr, _("Restore operator logo ? "));
+      GetLine(stdin, ans, 99);
+      if (!strcmp(ans, "yes")) confirm = 1;
+      if (!strcmp(ans, "no" )) confirm = 0;
+    }
+    if (confirm==1) {
+      GSM->SetBitmap(&Backup.OperatorLogo);
+    }
+  }
+  if (Backup.StartupLogoAvailable==true) {
+    confirm=-1;    
+    while (confirm < 0) {
+      fprintf(stderr, _("Restore startup logo ? "));
+      GetLine(stdin, ans, 99);
+      if (!strcmp(ans, "yes")) confirm = 1;
+      if (!strcmp(ans, "no" )) confirm = 0;
+    }
+    if (confirm==1) {
+      GSM->SetBitmap(&Backup.StartupLogo);
+    }
+  }
+
+  GSM->Terminate();
+
   return 0;
 }
 
@@ -1321,7 +1459,7 @@ int backupsettings(char *argv[])
 
   fprintf(stderr,_("Backup phonebook from SIM..."));
   Backup.SIMPhonebookUsed=0;
-  if (GSM->GetMemoryStatus(&SIMMemoryStatus) == GE_NONE) {//FIXME
+  if (GSM->GetMemoryStatus(&SIMMemoryStatus) == GE_NONE) {
     Backup.SIMPhonebookSize=SIMMemoryStatus.Used+SIMMemoryStatus.Free;
 
     PbkEntry.MemoryType=GMT_SM;
@@ -1396,11 +1534,10 @@ int backupsettings(char *argv[])
   Backup.OperatorLogoAvailable=true;
   Backup.OperatorLogo.type=GSM_7110OperatorLogo;
   if (GSM->GetBitmap(&Backup.OperatorLogo)!=GE_NONE) {
-    Backup.OperatorLogoAvailable=true;
     Backup.OperatorLogo.type=GSM_OperatorLogo;
     if (GSM->GetBitmap(&Backup.OperatorLogo)!=GE_NONE) {
       Backup.OperatorLogoAvailable=false;
-      fprintf(stderr,_("Error\n"));
+     fprintf(stderr,_("Error\n"));
     } else fprintf(stderr,_("Done\n"));
   } else fprintf(stderr,_("Done\n"));
 
@@ -1442,9 +1579,6 @@ int presskeysequence(char *argv[])
   
   sleep(1);
 
-  /* We need to make sure that the init is finished to avoid interrupted */
-  /* multiframe packets... */
-
   fbusinit(NULL);
   
   for (i=0;i<strlen(argv[0]);i++)
@@ -1988,11 +2122,8 @@ int getsms(int argc, char *argv[])
      int i;
      
      /* [end] can be only argv[4] */
-     if (argv[4][0] == '-') {
-        end_message = start_message;
-     } else {
-        end_message = atoi(argv[4]);
-     }
+     if (argv[4][0] == '-') { end_message = start_message; }
+                       else { end_message = atoi(argv[4]); }
 
      /* parse all options (beginning with '-' */
      while ((i = getopt(argc, argv, "f:")) != -1) {
@@ -2051,16 +2182,12 @@ int getsms(int argc, char *argv[])
           switch (message.Status)
           {
            case  GSS_SENTREAD:
-                if (message.folder==0) //GST_INBOX
-                 fprintf(stdout, _("(read)\n"));
-                else
-                 fprintf(stdout, _("(sent)\n"));
+                if (message.folder==0) fprintf(stdout, _("(read)\n")); //GST_INBOX
+                                  else fprintf(stdout, _("(sent)\n"));
                break;
            case  GSS_NOTSENTREAD:
-                if (message.folder==0) //GST_INBOX
-                 fprintf(stdout, _("(unread)\n"));
-                else
-                 fprintf(stdout, _("(not sent)\n"));
+                if (message.folder==0) fprintf(stdout, _("(unread)\n")); //GST_INBOX
+                                  else fprintf(stdout, _("(not sent)\n"));
                break;
            case  GSS_UNKNOWN:
                fprintf(stdout, _("(not known :-()\n"));
@@ -2113,16 +2240,12 @@ int getsms(int argc, char *argv[])
          switch (message.Status)
            {
            case  GSS_SENTREAD:
-                if (message.folder==0) //GST_INBOX
-                 fprintf(stdout, _("(read)\n"));
-                else
-                 fprintf(stdout, _("(sent)\n"));
+                if (message.folder==0) fprintf(stdout, _("(read)\n")); //GST_INBOX
+                                  else fprintf(stdout, _("(sent)\n"));
                break;
            case  GSS_NOTSENTREAD:
-                if (message.folder==0) //GST_INBOX
-                 fprintf(stdout, _("(unread)\n"));
-                else
-                 fprintf(stdout, _("(not sent)\n"));
+                if (message.folder==0) fprintf(stdout, _("(unread)\n")); //GST_INBOX
+                                  else fprintf(stdout, _("(not sent)\n"));
                break;
             case  GSS_UNKNOWN:
                 fprintf(stdout, _("(not known :-()\n"));
@@ -3141,7 +3264,7 @@ int setlogo(int argc, char *argv[])
           bitmap.type=GSM_StartupLogo;
           bitmap.width=84;
           bitmap.height=48;
-         bitmap.size=bitmap.width*bitmap.height/8;
+         bitmap.size=GSM_GetBitmapSize(&bitmap);
           num=argv[1][0]-'0';
           if (num>=1 && num<=3) {
            bitmap.number=num;
@@ -3255,7 +3378,7 @@ int setlogo(int argc, char *argv[])
          strncpy(bitmap.netcode,"000 00",7);
          bitmap.width=72;
          bitmap.height=14;
-         bitmap.size=bitmap.width*bitmap.height/8;
+         bitmap.size=GSM_GetBitmapSize(&bitmap);
          GSM_ClearBitmap(&bitmap);
        }
         if (!strcmp(argv[0],"7110op"))
@@ -3264,7 +3387,7 @@ int setlogo(int argc, char *argv[])
          strncpy(bitmap.netcode,"000 00",7);
          bitmap.width=78;
          bitmap.height=21;
-          bitmap.size=(bitmap.width*bitmap.height + 7)/8;
+          bitmap.size=GSM_GetBitmapSize(&bitmap);
          GSM_ClearBitmap(&bitmap);
        }
        /* FIX ME: how to remove startup and group logos ? */
@@ -7416,53 +7539,34 @@ int getringtone(int argc, char *argv[])
   GSM_Error error;
   GSM_Ringtone SMringtone;
 
-  int i;
-  
-  char model[64];
-
-  FILE *file;
-
   ringtone.location=1;
   if (argc>1) ringtone.location=atoi(argv[1]);
 
   /* Initialise the GSM interface. */
   fbusinit(NULL);
 
-  error=GSM->GetBinRingtone(&ringtone);
-
-  while (GSM->GetModel(model)  != GE_NONE)
-    sleep(1);
-
-  GSM->Terminate();
+  error=GSM_GetPhoneRingtone(&ringtone,&SMringtone);
 
   fprintf(stdout, _("Downloaded ringtone, location %i: "),ringtone.location);
   
   switch (error) {
     case GE_NONE:
       fprintf(stdout, _("get succeeded!\n"));
-      fprintf(stdout, _("Name: %s (binary format)\n"),ringtone.name);
+      /* In 33.. we have normal "Smart Messaging" format */
+      if (GetModelFeature (FN_RINGTONES)==F_RING_SM) {
+        fprintf(stdout, _("Name: %s (normal format)\n"),SMringtone.name);
+        GSM_SaveRingtoneFileOnConsole(argv[0], &SMringtone);   
+      } else {
+        fprintf(stdout, _("Name: %s (binary format)\n"),ringtone.name);
+        GSM_SaveBinRingtoneFile(argv[0], &ringtone);
+      }
+      GSM->Terminate();
+      return 0;
       break;
     case GE_INVALIDRINGLOCATION:
       fprintf(stdout, _("invalid location %i!\n"),ringtone.location);
       break;
     case GE_UNKNOWNMODEL:
-    
-      /* In 3310 we have normal "Smart Messaging" format */
-      if (GetModelFeature (FN_RINGTONES)==F_RING_SM) {
-      
-        i=7;
-       if (ringtone.frame[9]==0x4a && ringtone.frame[10]==0x3a) i=8;
-       ringtone.frame[i]=0x02;
-       
-        GSM_UnPackRingtone(&SMringtone, ringtone.frame+i, ringtone.length-i);
-
-        fprintf(stdout, _("Name: %s (normal format)\n"),SMringtone.name);
-
-        GSM_SaveRingtoneFileOnConsole(argv[0], &SMringtone);
-       
-       return 0;
-      }
-
       fprintf(stdout, _("mygnokii doesn't know format for this model!\n"));
       break;
     case GE_NOTIMPLEMENTED:
@@ -7472,21 +7576,10 @@ int getringtone(int argc, char *argv[])
       fprintf(stdout, _("not supported by this model!\n"));
       break;
   }
-  
-  if (error!=GE_NONE)
-    return(-1);
-  
-  file = fopen(argv[0], "wb");
-      
-  if (!file)
-    return(GE_CANTOPENFILE);
 
-  fwrite(ringtone.frame, 1, ringtone.length, file);    
-  
-  fclose(file);
+  GSM->Terminate();
   
-  return 0;
-
+  return(-1);
 }
 
 int binringtoneconvert(int argc, char *argv[])
@@ -7558,32 +7651,32 @@ int binringtoneconvert(int argc, char *argv[])
            w=w*2;
            if (w>z && (w/2)<=z) {
              switch (m) {
-               case 1:fprintf(file,_("16"));break;
-               case 2:fprintf(file,_("8"));break;
-               case 3:fprintf(file,_("4"));break;
-               case 4:fprintf(file,_("2"));break;
-               case 5:fprintf(file,_("1"));break;
+               case 1:fprintf(file,_("16"));break;\r
+               case 2:fprintf(file,_("8"));break;\r
+               case 3:fprintf(file,_("4"));break;\r
+               case 4:fprintf(file,_("2"));break;\r
+               case 5:fprintf(file,_("1"));break;\r
              }
              break;
            }
          }
          if (z>w) fprintf(file,_("1"));
          pause=false;
-          switch (GSM_GetNote(j)) {
-            case Note_C  :fprintf(file,_("c"));break;
-            case Note_Cis:fprintf(file,_("c#"));break;
-            case Note_D  :fprintf(file,_("d"));break;
-            case Note_Dis:fprintf(file,_("d#"));break;
-            case Note_E  :fprintf(file,_("e"));break;
-            case Note_F  :fprintf(file,_("f"));break;
-            case Note_Fis:fprintf(file,_("f#"));break;
-            case Note_G  :fprintf(file,_("g"));break;
-            case Note_Gis:fprintf(file,_("g#"));break;
-            case Note_A  :fprintf(file,_("a"));break;
-            case Note_Ais:fprintf(file,_("a#"));break;
-            case Note_H  :fprintf(file,_("h"));break;
-            default      :pause=true;fprintf(file,_("p"));break; //Pause ?
-          }
+          switch (GSM_GetNote(j)) {\r
+            case Note_C  :fprintf(file,_("c"));break;\r
+            case Note_Cis:fprintf(file,_("c#"));break;\r
+            case Note_D  :fprintf(file,_("d"));break;\r
+            case Note_Dis:fprintf(file,_("d#"));break;\r
+            case Note_E  :fprintf(file,_("e"));break;\r
+            case Note_F  :fprintf(file,_("f"));break;\r
+            case Note_Fis:fprintf(file,_("f#"));break;\r
+            case Note_G  :fprintf(file,_("g"));break;\r
+            case Note_Gis:fprintf(file,_("g#"));break;\r
+            case Note_A  :fprintf(file,_("a"));break;\r
+            case Note_Ais:fprintf(file,_("a#"));break;\r
+            case Note_H  :fprintf(file,_("h"));break;\r
+            default      :pause=true;fprintf(file,_("p"));break; //Pause ?\r
+          }\r
          w=deflen*1.5;
          for (m=0;m<6;m++) {
            w=w*2;
@@ -7722,11 +7815,11 @@ int setsimlock()
     fprintf(stderr,_("Error getting simlock info\n"));GSM->Terminate();return -1;
   }
   /* Opening all locks (we must check, if we can open them) */
-  NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer0);
-  openbuffer[4]=1;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
-  openbuffer[4]=2;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
-  openbuffer[4]=4;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
-  openbuffer[4]=8;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer0);
+  openbuffer[4]=1;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  openbuffer[4]=2;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  openbuffer[4]=4;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  openbuffer[4]=8;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
   if (GSM->SimlockInfo(&siml)!=GE_NONE) {
     fprintf(stderr,_("Error getting simlock info\n"));GSM->Terminate();return -1;
   }
@@ -7775,13 +7868,13 @@ int setsimlock()
   }  
   /* Closing simlock with given values */
   closebuffer[4]=1+2+4+8;
-  NULL_SendMessageSequence(50, &CurrentMagicError, 20, 0x40,closebuffer);  
+  NULL_SendMessageSequence\r(50, &CurrentMagicError, 20, 0x40,closebuffer);  
   /* Opening all locks */
-  NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer0);
-  openbuffer[4]=1;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
-  openbuffer[4]=2;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
-  openbuffer[4]=4;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
-  openbuffer[4]=8;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer0);
+  openbuffer[4]=1;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  openbuffer[4]=2;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  openbuffer[4]=4;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
+  openbuffer[4]=8;NULL_SendMessageSequence\r(50, &CurrentMagicError, 10, 0x40,openbuffer);
   GSM->Reset(0x03);
   GSM->Terminate();
   return 0;
@@ -7881,7 +7974,7 @@ int geteeprom()
     
     if ((i/256)!=((i-1)/256)) fprintf(stderr,_("."));
     
-    if (NULL_SendMessageSequence(50, &CurrentMagicError, 9, 0x40,buffer)!=GE_NONE)       break;
+    if (NULL_SendMessageSequence(50, &CurrentMagicError, 9, 0x40,buffer)!=GE_NONE)\r      break;
 
     i=i+0x10;
   }
@@ -8682,7 +8775,7 @@ int savephonebookentry(int argc, char *argv[])
     case GE_NONE:
 
       /* Put entry into SMS structure */
-      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71) {
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21);
       } else {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10);
@@ -8727,7 +8820,7 @@ int sendphonebookentry(int argc, char *argv[])
     case GE_NONE:
 
       /* Put entry into SMS structure */
-      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71) {
+      if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21);
       } else {
         GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10);
@@ -8746,3 +8839,75 @@ int sendphonebookentry(int argc, char *argv[])
 
   return 0;
 }
+
+#ifdef DEBUG
+int getbinringfromfile(int argc, char *argv[])
+{
+  FILE *file;
+  int i,j;
+  bool found;
+  GSM_BinRingtone binring,ringtone;
+
+  fprintf(stdout,_("Offset %ld\n"),atol(argv[2]));
+
+  file = fopen(argv[0], "rb");
+
+  if (!file) return(GE_CANTOPENFILE);
+
+  fseek(file,atol(argv[2]),0);
+  
+  ringtone.length=fread(ringtone.frame, 1, 900, file);
+
+  fclose(file);
+
+  i=0;found=false;
+  while (true) {
+    if (ringtone.frame[i  ]==0x00 && ringtone.frame[i+1]==0x02 && 
+        ringtone.frame[i+2]==0xFC && ringtone.frame[i+3]==0x09) {
+      found=true;
+      break;
+    }
+    i++;
+    if (i==ringtone.length-3) break;
+  }
+
+  if (!found) {
+    fprintf(stdout,_("Start not found\n"));
+    return (-1);
+  }
+
+  j=0;found=false;
+  while (true) {
+    if (ringtone.frame[j]==0x07 && ringtone.frame[j+1]==0x0B) {
+      found=true;
+      break;
+    }
+    j++;
+    if (j==ringtone.length-2) break;
+  }
+
+  if (!found) {
+    fprintf(stdout,_("End not found\n"));
+    return (-1);
+  }
+
+  binring.length=0;
+  binring.frame[binring.length++]=0x00;
+  binring.frame[binring.length++]=0x00;
+  binring.frame[binring.length++]=0x0C;
+  binring.frame[binring.length++]=0x01;
+  binring.frame[binring.length++]=0x2C;
+  
+  memcpy(binring.frame+binring.length,argv[1],strlen(argv[1]));
+  binring.length=binring.length+strlen(argv[1]);
+
+  binring.frame[binring.length++]=0x00;
+
+  memcpy(binring.frame+binring.length,ringtone.frame+i,j-i+2);
+  binring.length=binring.length+j-i+2;
+
+  GSM_SaveBinRingtoneFile(argv[3], &binring); 
+
+  return GE_NONE;
+}
+#endif