1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <time.h>
5
6 #include "general.h"
7 #include "fileoutput.h"
8
9 /*
10
11 Ringtonetools - Copyright 2001-2005 Michael Kohn (mike@mikekohn.net)
12 This falls under the Kohnian license. Please read
13 it at http://ringtonetools.mikekohn.net/
14
15 This program is NOT opensourced. You may not use any part
16 of this program for your own software.
17
18 */
19
20 /* Siemans supporting SEO (bmp and midi) */
21
write_seo(FILE * in,FILE * out,int in_type,struct note_t * note)22 int write_seo(FILE *in, FILE *out, int in_type, struct note_t *note)
23 {
24 FILE *fp;
25 int file_size;
26 int packets=0,n=0,ptr=0,datasize,headsize,num=1;
27 int max,i;
28 char filename[1024];
29 char objectname[1024];
30 unsigned int referenceid;
31
32 fseek(in,0,SEEK_END);
33 file_size=ftell(in);
34 rewind(in);
35
36 referenceid=time(NULL);
37
38 if (file_size==0) return 0;
39
40 /* n=strlen(note->outname); */
41 n=strlen(note->filename);
42 while(n>=0 && (note->filename[n]!='/' && note->filename[n]!='\\')) n--;
43 if (n<0) n=0;
44 strcpy(objectname,¬e->filename[n]);
45
46 datasize=full_sms_size-24-strlen(objectname)-1;
47 packets=file_size/datasize;
48 if (file_size%datasize!=0) packets++;
49
50 headsize=full_sms_size-datasize;
51
52 n=strlen(note->outname);
53 while(n>0 && note->outname[n]!='.') n--;
54 note->outname[n]=0;
55 max=0;
56
57 ptr=0;
58 while(ptr<file_size)
59 {
60 sprintf(filename,"%s%d.seo",note->outname,num);
61 fprintf(out,"%s\n",filename);
62 fp=fopen(filename,"wb");
63
64 if (datasize+ptr>file_size) datasize=file_size-ptr;
65
66 fprintf(fp,"//SEO%c",1);
67 if (max==0)
68 { write_word(fp,datasize); }
69 else
70 { write_word(fp,max); }
71 write_long(fp,referenceid);
72 write_word(fp,num);
73 write_word(fp,packets);
74 write_long(fp,file_size);
75 if (in_type==3)
76 { fprintf(fp,"%cbmp",3); }
77 else
78 if (in_type==5)
79 { fprintf(fp,"%cmid",3); }
80 putc(strlen(objectname),fp);
81 fprintf(fp,"%s",objectname);
82
83 for (n=0; n<datasize; n++)
84 {
85 putc(getc(in),fp);
86 }
87
88 if (max==0) max=datasize;
89 else
90 {
91 for (i=n; n<max; n++) putc(0,fp);
92 }
93
94 fclose(fp);
95 ptr=ptr+datasize;
96 num++;
97 }
98
99 return 0;
100 }
101
102
103