summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/service/gsmring.c
Unidiff
Diffstat (limited to 'gammu/emb/common/service/gsmring.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/service/gsmring.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/gammu/emb/common/service/gsmring.c b/gammu/emb/common/service/gsmring.c
index 7df46f1..dab028c 100644
--- a/gammu/emb/common/service/gsmring.c
+++ b/gammu/emb/common/service/gsmring.c
@@ -1,4 +1,6 @@
1/* (c) 2001-2004 by Marcin Wiacek */ 1/* (c) 2001-2004 by Marcin Wiacek */
2/* Based on some work from Ralf Thelen (7110 ringtones), 2/* Based on some work from Ralf Thelen (7110 ringtones) and others */
3 * Gnokii (RTTL and SM) and others 3/* Based on some work (RTTL and SM) from Gnokii (www.gnokii.org)
4 * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5 * GNU GPL version 2 or later
4 */ 6 */
@@ -9,2 +11,3 @@
9#include <math.h> 11#include <math.h>
12#include <sys/stat.h>
10#ifdef WIN32 13#ifdef WIN32
@@ -158,2 +161,8 @@ static GSM_Error savepuremidi(FILE *file, GSM_Ringtone *ringtone)
158 161
162static GSM_Error savemmf(FILE *file, GSM_Ringtone *ringtone)
163{
164 fwrite(ringtone->NokiaBinary.Frame,1,ringtone->NokiaBinary.Length,file);
165 return ERR_NONE;
166}
167
159GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone) 168GSM_Error saverttl(FILE *file, GSM_Ringtone *ringtone)
@@ -487,2 +496,5 @@ GSM_Error GSM_SaveRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
487 break; 496 break;
497 case RING_MMF:
498 savemmf(file, ringtone);
499 break;
488 } 500 }
@@ -771,2 +783,22 @@ static GSM_Error loadpuremidi(FILE *file, GSM_Ringtone *ringtone)
771 783
784static GSM_Error loadmmf(FILE *file, GSM_Ringtone *ringtone)
785{
786 struct stat st;
787 char *buffer;
788 int length;
789
790 dbgprintf("loading smaf file\n");
791 fstat(fileno(file), &st);
792 ringtone->BinaryTone.Length = length = st.st_size;
793 ringtone->BinaryTone.Buffer = buffer = malloc(length);
794 if (buffer == NULL)
795 return ERR_MOREMEMORY;
796 fread(buffer, 1, length, file);
797
798 dbgprintf("Length %i name \"%s\"\n", length,
799 DecodeUnicodeString(ringtone->Name));
800
801 return ERR_NONE;
802}
803
772static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone) 804static GSM_Error loadre(FILE *file, GSM_Ringtone *ringtone)
@@ -818,2 +850,6 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
818 } 850 }
851 if (buffer[0]==0x4D && buffer[1]==0x4D &&
852 buffer[2]==0x4D && buffer[3]==0x44) {
853 ringtone->Format = RING_MMF;
854 }
819 } 855 }
@@ -844,2 +880,7 @@ GSM_Error GSM_ReadRingtoneFile(char *FileName, GSM_Ringtone *ringtone)
844 error = loadpuremidi(file,ringtone); 880 error = loadpuremidi(file,ringtone);
881 break;
882 case RING_MMF:
883 EncodeUnicode(ringtone->Name,FileName,strlen(FileName));
884 error = loadmmf(file,ringtone);
885 break;
845 } 886 }