2 * SMS backup testing program.
9 #include "../helper/message-display.h"
13 int main(int argc UNUSED
, char **argv UNUSED
)
15 GSM_Debug_Info
*debug_info
;
17 GSM_SMS_Backup Backup
;
18 GSM_MultiSMSMessage
**SortedSMS
, **InputSMS
;
21 /* Check parameters */
23 printf("Not enough parameters!\nUsage: smsbackup file.smsbackup\n");
27 debug_info
= GSM_GetGlobalDebug();
28 GSM_SetDebugFileDescriptor(stderr
, FALSE
, debug_info
);
29 GSM_SetDebugLevel("textall", debug_info
);
32 error
= GSM_ReadSMSBackupFile(argv
[1], &Backup
);
33 gammu_test_result(error
, "GSM_ReadSMSBackupFile");
35 /* Calculate number of messages */
37 while (Backup
.SMS
[count
] != NULL
) {
41 /* Allocate memory for sorted ones */
42 SortedSMS
= (GSM_MultiSMSMessage
**) malloc((count
+ 1) * sizeof(GSM_MultiSMSMessage
*));
43 InputSMS
= (GSM_MultiSMSMessage
**) malloc((count
+ 1) * sizeof(GSM_MultiSMSMessage
*));
45 /* Copy messages to multi message buffers */
46 for (i
= 0; i
< count
; i
++) {
47 InputSMS
[i
] = (GSM_MultiSMSMessage
*) malloc(sizeof(GSM_MultiSMSMessage
));
48 InputSMS
[i
]->Number
= 1;
49 InputSMS
[i
]->SMS
[0] = *Backup
.SMS
[i
];
53 /* Sort linked messages */
54 error
= GSM_LinkSMS(debug_info
, InputSMS
, SortedSMS
, TRUE
);
55 gammu_test_result(error
, "GSM_LinkSMS");
58 for (i
= 0; i
< count
; i
++) {
62 /* Display messages */
63 for (i
= 0; SortedSMS
[i
] != NULL
; i
++) {
64 DisplayMultiSMSInfo(SortedSMS
[i
], TRUE
, TRUE
, NULL
, NULL
);
68 /* We don't need this anymore */
69 GSM_FreeSMSBackup(&Backup
);
76 /* Editor configuration
77 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: