summaryrefslogtreecommitdiff
path: root/gammu
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2009-12-03 16:34:32 +0100
committerMichal Čihař <michal@cihar.com>2009-12-03 16:34:32 +0100
commit77e826963edb39dcf28c34dbc962fc529642af21 (patch)
tree450186883426eda52cbaafe691b780ebd1e1d692 /gammu
parent4118922083129abc7a205f389e78e623d6d383b3 (diff)
Imported Upstream version 1.26.92
Diffstat (limited to 'gammu')
-rw-r--r--gammu/backup.c94
-rw-r--r--gammu/backupsms.c2
-rw-r--r--gammu/common.c8
-rw-r--r--gammu/depend/nokia/dct3.c8
-rw-r--r--gammu/depend/nokia/dct4.c17
-rw-r--r--gammu/files.c8
-rw-r--r--gammu/gammu.c12
-rw-r--r--gammu/message.c116
-rw-r--r--gammu/misc.c66
-rw-r--r--gammu/nokia.c14
-rw-r--r--gammu/sniff.c31
11 files changed, 219 insertions, 157 deletions
diff --git a/gammu/backup.c b/gammu/backup.c
index 4c04e94..8dbcaab 100644
--- a/gammu/backup.c
+++ b/gammu/backup.c
@@ -29,7 +29,7 @@ void SaveFile(int argc, char *argv[])
if (strcasecmp(argv[2],"CALENDAR") == 0) {
if (argc<5) {
printf("%s\n", _("Where is backup filename and location?"));
- Terminate(3);
+ Terminate(2);
}
error=GSM_ReadBackupFile(argv[4],&Backup,GSM_GuessBackupFormat(argv[4], FALSE));
if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
@@ -41,7 +41,7 @@ void SaveFile(int argc, char *argv[])
if (i != atoi(argv[5])-1 || Backup.Calendar[i] == NULL) {
printf("%s\n", _("Calendar note not found in file"));
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
j = 0;
error = GSM_EncodeVCALENDAR(Buffer, sizeof(Buffer), &j, Backup.Calendar[i],TRUE,Nokia_VCalendar);
@@ -50,7 +50,7 @@ void SaveFile(int argc, char *argv[])
} else if (strcasecmp(argv[2],"BOOKMARK") == 0) {
if (argc<5) {
printf("%s\n", _("Where is backup filename and location?"));
- Terminate(3);
+ Terminate(2);
}
error=GSM_ReadBackupFile(argv[4],&Backup,GSM_GuessBackupFormat(argv[4], FALSE));
if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
@@ -62,7 +62,7 @@ void SaveFile(int argc, char *argv[])
if (i != atoi(argv[5])-1 || Backup.WAPBookmark[i] == NULL) {
printf("%s\n", _("WAP bookmark not found in file"));
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
j = 0;
error = GSM_EncodeURLFile(Buffer, &j, Backup.WAPBookmark[i]);
@@ -71,7 +71,7 @@ void SaveFile(int argc, char *argv[])
} else if (strcasecmp(argv[2],"NOTE") == 0) {
if (argc<5) {
printf("%s\n", _("Where is backup filename and location?"));
- Terminate(3);
+ Terminate(2);
}
error=GSM_ReadBackupFile(argv[4],&Backup,GSM_GuessBackupFormat(argv[4], FALSE));
if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
@@ -83,7 +83,7 @@ void SaveFile(int argc, char *argv[])
if (i != atoi(argv[5])-1 || Backup.Note[i] == NULL) {
printf("%s\n", _("Note not found in file"));
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
j = 0;
error = GSM_EncodeVNTFile(Buffer, sizeof(Buffer), &j, Backup.Note[i]);
@@ -92,7 +92,7 @@ void SaveFile(int argc, char *argv[])
} else if (strcasecmp(argv[2],"TODO") == 0) {
if (argc<5) {
printf("%s\n", _("Where is backup filename and location?"));
- Terminate(3);
+ Terminate(2);
}
error=GSM_ReadBackupFile(argv[4],&Backup,GSM_GuessBackupFormat(argv[4], FALSE));
if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
@@ -104,7 +104,7 @@ void SaveFile(int argc, char *argv[])
if (i != atoi(argv[5])-1 || Backup.ToDo[i] == NULL) {
printf("%s\n", _("Todo note not found in file"));
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
j = 0;
error = GSM_EncodeVTODO(Buffer, sizeof(Buffer), &j, Backup.ToDo[i], TRUE, Nokia_VToDo);
@@ -113,7 +113,7 @@ void SaveFile(int argc, char *argv[])
} else if (strcasecmp(argv[2],"VCARD10") == 0 || strcasecmp(argv[2],"VCARD21") == 0) {
if (argc<6) {
printf("%s\n", _("Where is backup filename and location and memory type?"));
- Terminate(3);
+ Terminate(2);
}
error=GSM_ReadBackupFile(argv[4],&Backup,GSM_GuessBackupFormat(argv[4], FALSE));
if (error!=ERR_NOTIMPLEMENTED) Print_Error(error);
@@ -126,7 +126,7 @@ void SaveFile(int argc, char *argv[])
if (i != atoi(argv[6])-1 || Backup.SIMPhonebook[i] == NULL) {
printf("%s\n", _("Phonebook entry not found in file"));
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
pbk = Backup.SIMPhonebook[i];
} else if (strcasecmp(argv[5],"ME") == 0) {
@@ -137,13 +137,13 @@ void SaveFile(int argc, char *argv[])
if (i != atoi(argv[6])-1 || Backup.PhonePhonebook[i] == NULL) {
printf("%s\n", _("Phonebook entry not found in file"));
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
pbk = Backup.PhonePhonebook[i];
} else {
printf(_("Unknown memory type: \"%s\"\n"),argv[5]);
GSM_FreeBackup(&Backup);
- Terminate(3);
+ Terminate(2);
}
j = 0;
if (strcasecmp(argv[2],"VCARD10") == 0) {
@@ -157,7 +157,7 @@ void SaveFile(int argc, char *argv[])
}
} else {
printf(_("Unknown backup format: \"%s\"\n"), argv[2]);
- Terminate(3);
+ Terminate(2);
}
file = fopen(argv[3],"wb");
@@ -296,7 +296,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -330,7 +330,7 @@ void DoBackup(int argc, char *argv[])
i++;
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -374,7 +374,7 @@ void DoBackup(int argc, char *argv[])
i++;
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -408,7 +408,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -446,7 +446,7 @@ void DoBackup(int argc, char *argv[])
used * 100 / ToDoStatus.Used);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -480,7 +480,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -518,7 +518,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -619,7 +619,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -656,7 +656,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -693,7 +693,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -730,7 +730,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -766,7 +766,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -809,7 +809,7 @@ void DoBackup(int argc, char *argv[])
fprintf(stderr, "*");
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -995,7 +995,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1063,7 +1063,7 @@ void Restore(int argc, char *argv[])
);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1115,7 +1115,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / (MemStatus.MemoryUsed + MemStatus.MemoryFree));
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1173,7 +1173,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1222,7 +1222,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1250,7 +1250,7 @@ void Restore(int argc, char *argv[])
used * 100 / ToDoStatus.Used);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1266,7 +1266,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1305,7 +1305,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1323,7 +1323,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1372,7 +1372,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1397,7 +1397,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1422,7 +1422,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1458,7 +1458,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1481,7 +1481,7 @@ void Restore(int argc, char *argv[])
Print_Error(error);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1511,7 +1511,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1536,7 +1536,7 @@ void Restore(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1616,7 +1616,7 @@ void AddNew(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1644,7 +1644,7 @@ void AddNew(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1677,7 +1677,7 @@ void AddNew(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1701,7 +1701,7 @@ void AddNew(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1726,7 +1726,7 @@ void AddNew(int argc, char *argv[])
(i + 1) * 100 / max);
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
diff --git a/gammu/backupsms.c b/gammu/backupsms.c
index 297878a..bf7dff8 100644
--- a/gammu/backupsms.c
+++ b/gammu/backupsms.c
@@ -82,7 +82,7 @@ void BackupSMS(int argc UNUSED, char *argv[])
} else {
printf(_(" Increase %s\n") , "GSM_BACKUP_MAX_SMS");
GSM_Terminate();
- Terminate(3);
+ Terminate(1);
}
*Backup.SMS[smsnum] = sms.SMS[j];
smsnum++;
diff --git a/gammu/common.c b/gammu/common.c
index 129def8..04fa783 100644
--- a/gammu/common.c
+++ b/gammu/common.c
@@ -193,7 +193,7 @@ void Print_Error(GSM_Error error)
PrintSecurityStatus();
}
- Terminate(3);
+ Terminate(100 + error);
}
}
@@ -295,13 +295,13 @@ void GetStartStop(int *start, int *stop, int num, int argc, char *argv[])
if (argc <= num) {
printf_err("%s\n", _("More parameters required!"));
- Terminate(3);
+ Terminate(2);
}
*start = atoi(argv[num]);
if (*start == 0) {
printf_err("%s\n", _("Please enumerate locations from 1"));
- Terminate(3);
+ Terminate(2);
}
if (stop != NULL) {
@@ -311,7 +311,7 @@ void GetStartStop(int *start, int *stop, int num, int argc, char *argv[])
if (*stop == 0) {
printf_err("%s\n",
_("Please enumerate locations from 1"));
- Terminate(3);
+ Terminate(2);
}
if (*stop < *start) {
printf_warn("%s\n",
diff --git a/gammu/depend/nokia/dct3.c b/gammu/depend/nokia/dct3.c
index c82953d..640d477 100644
--- a/gammu/depend/nokia/dct3.c
+++ b/gammu/depend/nokia/dct3.c
@@ -53,8 +53,8 @@ void CheckDCT3(void)
switch (error) {
case ERR_OTHERCONNECTIONREQUIRED:
printf("Can't do it with current phone protocol\n");
- GSM_Terminate();
- Terminate(3);
+ Print_Error(error);
+ break;
case ERR_NONE:
break;
default:
@@ -71,7 +71,9 @@ static gboolean answer_yes3(const char *text)
while (1) {
printf("%s (yes/no) ? ",text);
len=GetLine(stdin, ans, 99);
- if (len==-1) Terminate(3);
+ if (len==-1) {
+ Terminate(2);
+ }
if (strcasecmp(ans, "yes") == 0) return TRUE;
if (strcasecmp(ans, "no" ) == 0) return FALSE;
}
diff --git a/gammu/depend/nokia/dct4.c b/gammu/depend/nokia/dct4.c
index 8ccb1a4..f80bbed 100644
--- a/gammu/depend/nokia/dct4.c
+++ b/gammu/depend/nokia/dct4.c
@@ -63,8 +63,8 @@ void CheckDCT4(void)
break;
case ERR_OTHERCONNECTIONREQUIRED:
printf("%s\n", _("Can't do it with current phone protocol"));
- GSM_Terminate();
- Terminate(3);
+ Print_Error(ERR_NOTSUPPORTED);
+ break;
default:
break;
}
@@ -78,7 +78,9 @@ static gboolean answer_yes2(const char *text)
while (1) {
printf(_("%s (yes/no) ? "),text);
len=GetLine(stdin, ans, 99);
- if (len==-1) Terminate(3);
+ if (len==-1) {
+ Terminate(2);
+ }
if (strcasecmp(ans, _("yes")) == 0) return TRUE;
if (strcasecmp(ans, _("no")) == 0) return FALSE;
}
@@ -956,14 +958,14 @@ void DCT4SetLight(int argc, char *argv[])
} else if (strcasecmp(argv[2],"torch") == 0) { type = N6510_LIGHT_TORCH;
} else {
printf(_("What lights should I enable (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
if (strcasecmp(argv[3],"on") == 0) { enable = TRUE;
} else if (strcasecmp(argv[3],"off") == 0) { enable = FALSE;
} else {
printf(_("What should I do (\"%s\") ?\n"),argv[3]);
- Terminate(3);
+ Terminate(2);
}
for (i=0;i<gsm->ConfigNum;i++) {
@@ -1345,8 +1347,9 @@ void DCT4GetScreenDump(int argc, char *argv[])
error=GSM_WaitFor (gsm, req, 6, 0x0E, 4, ID_User3);
Print_Error(error);
len = 2000;
- while (len >= 200) GSM_ReadDevice(gsm,TRUE);
-
+ while (len >= 200) {
+ GSM_ReadDevice(gsm,TRUE);
+ }
GSM_Terminate();
}
diff --git a/gammu/files.c b/gammu/files.c
index bdd91ca..568ecfa 100644
--- a/gammu/files.c
+++ b/gammu/files.c
@@ -377,7 +377,7 @@ void GetOneFile(GSM_File * File, gboolean newtime, int i)
GSM_Terminate();
printf("%s\n",
_ ("Is a folder. Please give only file names."));
- Terminate(3);
+ Terminate(2);
}
if (Size == 0) {
fprintf(stderr, "*");
@@ -691,7 +691,7 @@ void AddSendFile(int argc, char *argv[])
}
printf(_("Parameter \"%s\" unknown\n"),
argv[i]);
- Terminate(3);
+ Terminate(2);
case 1:
if (strcasecmp(argv[i], "JAR") == 0) {
File.Type = GSM_File_Java_JAR;
@@ -726,7 +726,7 @@ void AddSendFile(int argc, char *argv[])
printf(_
("What file type (\"%s\") ?\n"),
argv[i]);
- Terminate(3);
+ Terminate(2);
}
nextlong = 0;
break;
@@ -734,7 +734,7 @@ void AddSendFile(int argc, char *argv[])
}
if (nextlong != 0) {
printf_err("%s\n", _("Parameter missing!"));
- Terminate(3);
+ Terminate(2);
}
}
diff --git a/gammu/gammu.c b/gammu/gammu.c
index 9fa7c2e..952dd1f 100644
--- a/gammu/gammu.c
+++ b/gammu/gammu.c
@@ -110,7 +110,7 @@ static void ListNetworks(int argc, char *argv[])
if (!*country) {
printf(_("Unknown country name: %s."), argv[2]);
printf("\n");
- Terminate(3);
+ Terminate(2);
}
}
printf("%-10s %s\n", _("Network"), _("Name"));
@@ -488,14 +488,14 @@ NORETURN
void SendSMSDSMSObsolete(int argc, char *argv[])
{
printf_err("%s\n", _("SMS daemon is now in separate binary, please use gammu-smsd-inject instead of gammu sendsmsdsms!"));
- Terminate(100);
+ Terminate(99);
}
NORETURN
void SMSDaemonObsolete(int argc, char *argv[])
{
printf_err("%s\n", _("SMS daemon is now in separate binary, please use gammu-smsd instead of gammu smsd!"));
- Terminate(100);
+ Terminate(99);
}
void Help(int argc, char *argv[]);
@@ -1042,7 +1042,7 @@ int ProcessParameters(int start, int argc, char *argv[])
printf("%s\n", _("Bad option!"));
return 2;
}
- return 1;
+ return 2;
}
return 0;
}
@@ -1174,7 +1174,7 @@ int main(int argc, char *argv[])
if (argc <= start + 1) {
HelpGeneral();
printf("%s\n", _("Too few parameters!"));
- Terminate(3);
+ Terminate(2);
}
smcfg0 = GSM_GetConfig(gsm, 0);
@@ -1244,7 +1244,7 @@ int main(int argc, char *argv[])
if (!strcasecmp(GetGammuVersion(), VERSION) == 0) {
printf_err(_("Version of installed libGammu.so (%s) is different to version of Gammu (%s)\n"),
GetGammuVersion(), VERSION);
- Terminate(4);
+ Terminate(98);
}
ret = ProcessParameters(start, argc, argv);
diff --git a/gammu/message.c b/gammu/message.c
index 1269e19..6826f74 100644
--- a/gammu/message.c
+++ b/gammu/message.c
@@ -32,8 +32,11 @@ GSM_MultiSMSMessage IncomingSMSData;
void IncomingSMS(GSM_StateMachine *sm UNUSED, GSM_SMSMessage sms, void *user_data)
{
printf("%s\n", _("SMS message received"));
+ fflush(stdout);
+
if (wasincomingsms) {
printf("%s\n", _("We already have one pending, ignoring this one!"));
+ fflush(stdout);
return;
}
wasincomingsms = TRUE;
@@ -51,10 +54,12 @@ void DisplayIncomingSMS(void)
Print_Error(error);
error=GSM_GetSMS(gsm, &IncomingSMSData);
+
switch (error) {
case ERR_EMPTY:
printf(_("Location %i\n"),IncomingSMSData.SMS[0].Location);
printf("%s\n", _("Empty"));
+ fflush(stdout);
break;
default:
Print_Error(error);
@@ -69,12 +74,14 @@ void IncomingCB(GSM_StateMachine *sm UNUSED, GSM_CBMessage CB, void *user_data)
{
printf("%s\n", _("CB message received"));
printf(_("Channel %i, text \"%s\"\n"),CB.Channel,DecodeUnicodeConsole(CB.Text));
+ fflush(stdout);
}
void IncomingUSSD(GSM_StateMachine *sm UNUSED, GSM_USSDMessage ussd, void *user_data)
{
printf("%s\n", _("USSD received"));
printf(LISTFORMAT, _("Status"));
+
switch(ussd.Status) {
case USSD_NoActionNeeded:
printf("%s\n", _("No action needed"));
@@ -102,6 +109,7 @@ void IncomingUSSD(GSM_StateMachine *sm UNUSED, GSM_USSDMessage ussd, void *user_
break;
}
printf(LISTFORMAT "\"%s\"\n", _("Service reply"), DecodeUnicodeConsole(ussd.Text));
+ fflush(stdout);
}
void IncomingUSSD2(GSM_StateMachine *sm, GSM_USSDMessage ussd, void * user_data)
@@ -118,6 +126,7 @@ void GetUSSD(int argc UNUSED, char *argv[])
signal(SIGINT, interrupt);
fprintf(stderr, "%s\n", _("Press Ctrl+C to break..."));
+ fflush(stderr);
GSM_SetIncomingUSSDCallback(gsm, IncomingUSSD2, NULL);
@@ -164,9 +173,9 @@ void SetSMSC(int argc, char *argv[])
void GetSMSC(int argc, char *argv[])
{
- GSM_SMSC smsc;
+ GSM_SMSC smsc;
GSM_Error error;
- int start, stop, i;
+ int start=0, stop=0, i=0;
if (argc == 2) {
start = 1;
@@ -184,6 +193,7 @@ void GetSMSC(int argc, char *argv[])
Print_Error(error);
printf(LISTFORMAT "%d\n", _("Location"), smsc.Location);
+
if (UnicodeLength(smsc.Name) != 0) {
printf(LISTFORMAT "\"%s\"\n", _("Name"),DecodeUnicodeConsole(smsc.Name));
}
@@ -234,18 +244,17 @@ void GetSMSC(int argc, char *argv[])
}
}
printf("\n");
+ fflush(stdout);
}
-
GSM_Terminate();
}
void GetSMS(int argc, char *argv[])
{
GSM_Error error;
- GSM_MultiSMSMessage sms;
- GSM_SMSFolders folders;
- int start, stop;
- int j;
+ GSM_MultiSMSMessage sms;
+ GSM_SMSFolders folders;
+ int start=0, stop=0, j=0;
GetStartStop(&start, &stop, 3, argc, argv);
@@ -270,15 +279,15 @@ void GetSMS(int argc, char *argv[])
DisplayMultiSMSInfo(&sms,FALSE,FALSE,NULL, gsm);
}
}
-
+ fflush(stdout);
GSM_Terminate();
}
void DeleteSMS(int argc, char *argv[])
{
GSM_Error error;
- GSM_SMSMessage sms;
- int start, stop, i;
+ GSM_SMSMessage sms;
+ int start=0, stop=0, i=0;
sms.Folder=atoi(argv[2]);
@@ -302,14 +311,14 @@ void GetAllSMS(int argc, char *argv[])
GSM_Error error;
GSM_MultiSMSMessage sms;
GSM_SMSFolders folders;
- gboolean start = TRUE;
+ gboolean start = TRUE;
int smsnum=0,smspos=0;
GSM_Backup *BackupPtr = NULL;
#ifdef GSM_ENABLE_BACKUP
- int used,i;
GSM_MemoryStatus MemStatus;
GSM_MemoryEntry Pbk;
GSM_Backup Backup;
+ int used=0,i=0;
GSM_ClearBackup(&Backup);
BackupPtr = &Backup;
@@ -324,15 +333,19 @@ void GetAllSMS(int argc, char *argv[])
if (argc == 3 && strcasecmp(argv[2],"-pbk") == 0) {
MemStatus.MemoryType = MEM_ME;
error=GSM_GetMemoryStatus(gsm, &MemStatus);
+
if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
Pbk.MemoryType = MEM_ME;
i = 1;
used = 0;
+
while (used != MemStatus.MemoryUsed) {
Pbk.Location = i;
error=GSM_GetMemory(gsm, &Pbk);
+
if (error != ERR_EMPTY) {
Print_Error(error);
+
if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) {
Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
@@ -341,22 +354,23 @@ void GetAllSMS(int argc, char *argv[])
printf("\n ");
printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_PHONEPHONEBOOK");
printf("\n");
+ fflush(stdout);
break;
}
*Backup.PhonePhonebook[used]=Pbk;
used++;
}
- fprintf(stderr, "\r");
- fprintf(stderr, "%s ", _("Reading phone phonebook:"));
- fprintf(stderr, _("%i percent"),
- used * 100 / MemStatus.MemoryUsed);
+ fprintf(stderr, "\r%s ", _("Reading phone phonebook:"));
+ fprintf(stderr, _("%i percent"),used * 100 / MemStatus.MemoryUsed);
i++;
+
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
+ fflush(stderr);
}
}
#endif
@@ -367,11 +381,13 @@ void GetAllSMS(int argc, char *argv[])
while (error == ERR_NONE) {
sms.SMS[0].Folder=0x00;
error=GSM_GetNextSMS(gsm, &sms, start);
+
switch (error) {
case ERR_EMPTY:
break;
case ERR_CORRUPTED:
fprintf(stderr, "\n%s\n", _("Corrupted message, skipping"));
+ fflush(stderr);
error = ERR_NONE;
continue;
default:
@@ -386,6 +402,7 @@ void GetAllSMS(int argc, char *argv[])
printf("\n\n");
printf(_("%i SMS parts in %i SMS sequences"),smsnum,smspos);
printf("\n");
+ fflush(stdout);
#ifdef GSM_ENABLE_BEEP
GSM_PhoneBeep();
@@ -397,16 +414,15 @@ void GetEachSMS(int argc, char *argv[])
{
GSM_Error error;
GSM_MultiSMSMessage *GetSMSData[GSM_PHONE_MAXSMSINFOLDER],*SortedSMS[GSM_PHONE_MAXSMSINFOLDER],sms;
- int GetSMSNumber = 0,i,j;
- int smsnum=0,smspos=0;
GSM_SMSFolders folders;
- gboolean start = TRUE, ems = TRUE;
GSM_Backup *BackupPtr = NULL;
+ gboolean start=TRUE, ems=TRUE;
+ int GetSMSNumber=0,i=0,j=0,smsnum=0,smspos=0;
#ifdef GSM_ENABLE_BACKUP
GSM_MemoryStatus MemStatus;
GSM_MemoryEntry Pbk;
- int used;
GSM_Backup Backup;
+ int used=0;
GSM_ClearBackup(&Backup);
BackupPtr = &Backup;
@@ -423,39 +439,46 @@ void GetEachSMS(int argc, char *argv[])
if (argc == 3 && strcasecmp(argv[2],"-pbk") == 0) {
MemStatus.MemoryType = MEM_ME;
error=GSM_GetMemoryStatus(gsm, &MemStatus);
+
if (error==ERR_NONE && MemStatus.MemoryUsed != 0) {
Pbk.MemoryType = MEM_ME;
i = 1;
used = 0;
+
while (used != MemStatus.MemoryUsed) {
Pbk.Location = i;
error=GSM_GetMemory(gsm, &Pbk);
+
if (error != ERR_EMPTY) {
Print_Error(error);
+
if (used < GSM_BACKUP_MAX_PHONEPHONEBOOK) {
Backup.PhonePhonebook[used] = malloc(sizeof(GSM_MemoryEntry));
+
if (Backup.PhonePhonebook[used] == NULL) Print_Error(ERR_MOREMEMORY);
Backup.PhonePhonebook[used+1] = NULL;
} else {
printf("\n ");
printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_PHONEPHONEBOOK");
printf("\n");
+ fflush(stdout);
break;
}
*Backup.PhonePhonebook[used]=Pbk;
used++;
}
- fprintf(stderr, "\r");
- fprintf(stderr, "%s ", _("Reading phone phonebook:"));
- fprintf(stderr, _("%i percent"),
- used * 100 / MemStatus.MemoryUsed);
+ fprintf(stderr, "\r%s ", _("Reading phone phonebook:"));
+ fprintf(stderr, _("%i percent"),used * 100 / MemStatus.MemoryUsed);
+ fflush(stderr);
i++;
+
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
+ fflush(stderr);
}
}
#endif
@@ -464,6 +487,7 @@ void GetEachSMS(int argc, char *argv[])
Print_Error(error);
fprintf(stderr, LISTFORMAT, _("Reading"));
+
while (error == ERR_NONE) {
if (GetSMSNumber==GSM_PHONE_MAXSMSINFOLDER-1) {
fprintf(stderr, "\n%s\n", _("SMS counter overflow"));
@@ -471,6 +495,7 @@ void GetEachSMS(int argc, char *argv[])
}
sms.SMS[0].Folder=0x00;
error=GSM_GetNextSMS(gsm, &sms, start);
+
switch (error) {
case ERR_EMPTY:
break;
@@ -481,6 +506,7 @@ void GetEachSMS(int argc, char *argv[])
default:
Print_Error(error);
GetSMSData[GetSMSNumber] = malloc(sizeof(GSM_MultiSMSMessage));
+
if (GetSMSData[GetSMSNumber] == NULL) Print_Error(ERR_MOREMEMORY);
GetSMSData[GetSMSNumber+1] = NULL;
memcpy(GetSMSData[GetSMSNumber],&sms,sizeof(GSM_MultiSMSMessage));
@@ -501,6 +527,7 @@ void GetEachSMS(int argc, char *argv[])
Print_Error(error);
i=0;
+
while(GetSMSData[i] != NULL) {
free(GetSMSData[i]);
GetSMSData[i] = NULL;
@@ -508,10 +535,13 @@ void GetEachSMS(int argc, char *argv[])
}
i=0;
+
while(SortedSMS[i] != NULL) {
smspos++;
+
for (j=0;j<SortedSMS[i]->Number;j++) {
smsnum++;
+
if ((j==0) || (j!=0 && SortedSMS[i]->SMS[j].Location != SortedSMS[i]->SMS[j-1].Location)) {
PrintSMSLocation(&SortedSMS[i]->SMS[j], &folders);
}
@@ -526,7 +556,7 @@ void GetEachSMS(int argc, char *argv[])
printf("\n");
printf(_("%i SMS parts in %i SMS sequences"),smsnum,smspos);
printf("\n");
-
+ fflush(stdout);
GSM_Terminate();
}
@@ -534,7 +564,7 @@ void GetSMSFolders(int argc UNUSED, char *argv[] UNUSED)
{
GSM_Error error;
GSM_SMSFolders folders;
- int i;
+ int i=0;
GSM_Init(TRUE);
@@ -543,6 +573,7 @@ void GetSMSFolders(int argc UNUSED, char *argv[] UNUSED)
for (i=0;i<folders.Number;i++) {
printf("%i. \"%30s\"",i+1,DecodeUnicodeConsole(folders.Folder[i].Name));
+
switch(folders.Folder[i].Memory) {
case MEM_SM: printf(_(", SIM memory")); break;
case MEM_ME: printf(_(", phone memory")); break;
@@ -553,7 +584,7 @@ void GetSMSFolders(int argc UNUSED, char *argv[] UNUSED)
if (folders.Folder[i].OutboxFolder) printf(_(", Outbox folder"));
printf("\n");
}
-
+ fflush(stdout);
GSM_Terminate();
}
@@ -564,6 +595,7 @@ GSM_Error SMSStatus;
void SendSMSStatus (GSM_StateMachine *sm, int status, int MessageReference, void *user_data)
{
smprintf(gsm, "Sent SMS on device: \"%s\"\n", GSM_GetConfig(sm, -1)->Device);
+
if (status==0) {
printf(_("..OK"));
SMSStatus = ERR_NONE;
@@ -571,7 +603,9 @@ void SendSMSStatus (GSM_StateMachine *sm, int status, int MessageReference, void
printf(_("..error %i"),status);
SMSStatus = ERR_UNKNOWN;
}
- printf(_(", message reference=%d\n"),MessageReference);
+ printf(_(", message reference=%d"),MessageReference);
+ printf("\n");
+ fflush(stdout);
}
void SendSaveDisplaySMS(int argc, char *argv[])
@@ -580,7 +614,7 @@ void SendSaveDisplaySMS(int argc, char *argv[])
GSM_MultiSMSMessage sms;
GSM_Message_Type type;
GSM_SMSFolders folders;
- int i;
+ int i=0;
if (strcasestr(argv[1], "savesms") != NULL) {
type = SMS_Save;
@@ -618,6 +652,7 @@ void SendSaveDisplaySMS(int argc, char *argv[])
signal(SIGINT, interrupt);
fprintf(stderr, "%s\n", _("If you want break, press Ctrl+C..."));
+ fflush(stderr);
}
for (i=0;i<sms.Number;i++) {
@@ -637,15 +672,17 @@ void SendSaveDisplaySMS(int argc, char *argv[])
if (type == SMS_SendSaved) {
printf(_("Sending sms from folder \"%s\", location %i\n"),
DecodeUnicodeString(folders.Folder[sms.SMS[i].Folder-1].Name),sms.SMS[i].Location);
+ fflush(stdout);
SMSStatus = ERR_TIMEOUT;
error = GSM_SendSavedSMS(gsm, 0, sms.SMS[i].Location);
Print_Error(error);
printf(_("....waiting for network answer"));
+ fflush(stdout);
+
while (!gshutdown) {
GSM_ReadDevice(gsm,TRUE);
if (SMSStatus == ERR_UNKNOWN) {
- GSM_Terminate();
- Terminate(3);
+ Print_Error(SMSStatus);
}
if (SMSStatus == ERR_NONE) break;
}
@@ -655,6 +692,7 @@ void SendSaveDisplaySMS(int argc, char *argv[])
case SMS_Send:
signal(SIGINT, interrupt);
fprintf(stderr, "%s\n", _("If you want break, press Ctrl+C..."));
+ fflush(stderr);
GSM_SetSendSMSStatusCallback(gsm, SendSMSStatus, NULL);
@@ -666,11 +704,12 @@ void SendSaveDisplaySMS(int argc, char *argv[])
Print_Error(error);
printf(_("....waiting for network answer"));
fflush(stdout);
+
while (!gshutdown) {
GSM_ReadDevice(gsm,TRUE);
+
if (SMSStatus == ERR_UNKNOWN) {
- GSM_Terminate();
- Terminate(3);
+ Print_Error(SMSStatus);
}
if (SMSStatus == ERR_NONE) break;
}
@@ -711,17 +750,21 @@ void DeleteAllSMS(int argc, char *argv[])
Print_Error(error);
GetStartStop(&foldernum, NULL, 2, argc, argv);
+
if (foldernum > folders.Number) {
printf(_("Too high folder number (max. %i)\n"),folders.Number);
+ fflush(stdout);
GSM_Terminate();
- Terminate(3);
+ Terminate(2);
}
printf(_("Deleting SMS from \"%s\" folder: "),DecodeUnicodeConsole(folders.Folder[foldernum-1].Name));
+ fflush(stdout);
while (error == ERR_NONE) {
sms.SMS[0].Folder=0x00;
error=GSM_GetNextSMS(gsm, &sms, start);
+
switch (error) {
case ERR_EMPTY:
break;
@@ -750,4 +793,3 @@ void DeleteAllSMS(int argc, char *argv[])
/* How should editor hadle tabs in this file? Add editor commands here.
* vim: noexpandtab sw=8 ts=8 sts=8:
*/
-
diff --git a/gammu/misc.c b/gammu/misc.c
index fa9ac53..ce67388 100644
--- a/gammu/misc.c
+++ b/gammu/misc.c
@@ -57,6 +57,18 @@ void PrintNetworkInfo(GSM_NetworkInfo NetInfo)
DecodeUnicodeConsole(NetInfo.NetworkName));
}
}
+ if (NetInfo.GPRS != 0) {
+ printf(LISTFORMAT, _("GPRS"));
+ switch (NetInfo.GPRS) {
+ case GSM_GPRS_Attached:
+ printf("%s", _("attached"));
+ break;
+ case GSM_GPRS_Detached:
+ printf("%s", _("detached"));
+ break;
+ }
+ printf("\n");
+ }
}
GSM_Error GSM_PlayRingtone(GSM_Ringtone ringtone)
@@ -586,7 +598,7 @@ void DialVoice(int argc, char *argv[])
} else if (strcasecmp(argv[3],"hide") == 0) { ShowNumber = GSM_CALL_HideNumber;
} else {
printf(_("Unknown parameter (\"%s\")\n"),argv[3]);
- Terminate(3);
+ Terminate(2);
}
}
@@ -615,7 +627,7 @@ void MakeTerminatedCall(int argc, char *argv[])
} else if (strcasecmp(argv[4],"hide") == 0) { ShowNumber = GSM_CALL_HideNumber;
} else {
printf(_("Unknown parameter (\"%s\")\n"),argv[4]);
- Terminate(3);
+ Terminate(2);
}
}
@@ -755,7 +767,7 @@ void Reset(int argc UNUSED, char *argv[])
} else if (strcasecmp(argv[2],"HARD") == 0) { hard=TRUE;
} else {
printf(_("What type of reset do you want (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
GSM_Init(TRUE);
@@ -866,7 +878,7 @@ void GetBitmap(int argc, char *argv[])
MultiBitmap.Bitmap[0].Type=GSM_OperatorLogo;
} else {
printf(_("What type of logo do you want to get (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
MultiBitmap.Bitmap[0].Location=location;
@@ -976,7 +988,7 @@ void SetBitmap(int argc, char *argv[])
if (strcasecmp(argv[2],"STARTUP") == 0) {
if (argc<4) {
printf("%s\n", _("More parameters required!"));
- Terminate(3);
+ Terminate(2);
}
MultiBitmap.Bitmap[0].Type=GSM_StartupLogo;
MultiBitmap.Bitmap[0].Location=1;
@@ -991,26 +1003,26 @@ void SetBitmap(int argc, char *argv[])
} else if (strcasecmp(argv[2],"TEXT") == 0) {
if (argc<4) {
printf("%s\n", _("More parameters required!"));
- Terminate(3);
+ Terminate(2);
}
Bitmap.Type=GSM_WelcomeNote_Text;
EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
} else if (strcasecmp(argv[2],"DEALER") == 0) {
if (argc<4) {
printf("%s\n", _("More parameters required!"));
- Terminate(3);
+ Terminate(2);
}
Bitmap.Type=GSM_DealerNote_Text;
EncodeUnicode(Bitmap.Text,argv[3],strlen(argv[3]));
} else if (strcasecmp(argv[2],"CALLER") == 0) {
if (argc<4) {
printf("%s\n", _("More parameters required!"));
- Terminate(3);
+ Terminate(2);
}
GetStartStop(&i, NULL, 3, argc, argv);
if (i>5 && i!=255) {
printf("%s\n", _("Maximal location for caller logo can be 5"));
- Terminate(2);
+ Terminate(1);
}
MultiBitmap.Bitmap[0].Type = GSM_CallerGroupLogo;
MultiBitmap.Bitmap[0].Location = i;
@@ -1035,7 +1047,7 @@ void SetBitmap(int argc, char *argv[])
} else if (strcasecmp(argv[2],"PICTURE") == 0) {
if (argc<5) {
printf("%s\n", _("More parameters required!"));
- Terminate(3);
+ Terminate(2);
}
MultiBitmap.Bitmap[0].Type = GSM_PictureImage;
MultiBitmap.Bitmap[0].Location = atoi(argv[4]);
@@ -1093,7 +1105,7 @@ void SetBitmap(int argc, char *argv[])
memcpy(&Bitmap,&MultiBitmap.Bitmap[0],sizeof(GSM_Bitmap));
} else {
printf(_("What type of logo do you want to set (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
if (init) GSM_Init(TRUE);
@@ -1134,7 +1146,7 @@ void SetRingtone(int argc, char *argv[])
break;
}
printf(_("Unknown parameter (\"%s\")"),argv[i]);
- Terminate(3);
+ Terminate(2);
case 1:
ringtone.Location=atoi(argv[i]);
nextlong = 0;
@@ -1147,11 +1159,11 @@ void SetRingtone(int argc, char *argv[])
}
if (nextlong!=0) {
printf_err("%s\n", _("Parameter missing!"));
- Terminate(3);
+ Terminate(2);
}
if (ringtone.Location==0) {
printf_err("%s\n", _("Please enumerate locations from 1"));
- Terminate(2);
+ Terminate(1);
}
GSM_Init(TRUE);
@@ -1192,7 +1204,7 @@ void ClearMemory(GSM_MemoryType type, const char *question)
(i + 1) * 100 / (MemStatus.MemoryUsed + MemStatus.MemoryFree));
if (gshutdown) {
GSM_Terminate();
- Terminate(0);
+ Terminate(4);
}
}
fprintf(stderr, "\n");
@@ -1591,7 +1603,7 @@ void CopyBitmap(int argc, char *argv[])
Bitmap.Bitmap[i].Type = GSM_OperatorLogo;
} else {
printf(_("What format of output file logo (\"%s\") ?\n"),argv[4]);
- Terminate(3);
+ Terminate(2);
}
}
}
@@ -1616,7 +1628,7 @@ void CopyRingtone(int argc, char *argv[])
} else if (strcasecmp(argv[4],"BINARY") == 0) { Format = RING_NOKIABINARY;
} else {
printf(_("What format of output ringtone file (\"%s\") ?\n"),argv[4]);
- Terminate(3);
+ Terminate(2);
}
}
@@ -1636,7 +1648,7 @@ void PressKeySequence(int argc UNUSED, char *argv[])
error = MakeKeySequence(argv[2], KeyCode, &Length);
if (error == ERR_NOTSUPPORTED) {
printf(_("Unknown key/function name: \"%c\"\n"),argv[2][Length]);
- Terminate(3);
+ Terminate(2);
}
GSM_Init(TRUE);
@@ -1666,7 +1678,7 @@ void GetAllCategories(int argc UNUSED, char *argv[])
Status.Type = Category_Phonebook;
} else {
printf(_("What type of categories do you want to get (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
GSM_Init(TRUE);
@@ -1704,7 +1716,7 @@ void GetCategory(int argc, char *argv[])
Category.Type = Category_Phonebook;
} else {
printf(_("What type of categories do you want to get (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
GetStartStop(&start, &stop, 2, argc - 1, argv + 1);
@@ -1742,7 +1754,7 @@ void AddCategory(int argc UNUSED, char *argv[])
Category.Type = Category_Phonebook;
} else {
printf(_("What type of category do you want to add (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
GSM_Init(TRUE);
@@ -1789,7 +1801,7 @@ void EnterSecurityCode(int argc UNUSED, char *argv[])
} else if (strcasecmp(argv[2],"NETWORK") == 0) { Code.Type = SEC_Network;
} else {
printf_err("%s: %s\n", _("Invalid security code type"), argv[2]);
- Terminate(3);
+ Terminate(2);
}
if (strcmp(argv[3], "-") == 0) {
@@ -1806,7 +1818,7 @@ void EnterSecurityCode(int argc UNUSED, char *argv[])
#endif
if (fscanf(stdin, "%15s", Code.Code) != 1) {
printf_err("%s\n", _("No PIN code entered!"));
- Terminate(3);
+ Terminate(2);
}
#endif
} else {
@@ -2009,7 +2021,7 @@ void ResetPhoneSettings(int argc UNUSED, char *argv[])
} else if (strcasecmp(argv[2],"FACTORY") == 0) { Type = GSM_RESET_FULLFACTORY;
} else {
printf(_("What type of reset phone settings (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
GSM_Init(TRUE);
@@ -2109,7 +2121,7 @@ void CallDivert(int argc, char *argv[])
else if (strcasecmp("set", argv[2]) == 0) {}
else {
printf(_("Unknown divert action (\"%s\")\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
if (strcasecmp("all" , argv[3]) == 0) {cd.Request.DivertType = GSM_DIVERT_AllTypes ;}
@@ -2118,7 +2130,7 @@ void CallDivert(int argc, char *argv[])
else if (strcasecmp("outofreach", argv[3]) == 0) {cd.Request.DivertType = GSM_DIVERT_OutOfReach;}
else {
printf(_("Unknown divert type (\"%s\")\n"),argv[3]);
- Terminate(3);
+ Terminate(2);
}
if (strcasecmp("all" , argv[4]) == 0) {cd.Request.CallType = GSM_DIVERT_AllCalls ;}
@@ -2127,7 +2139,7 @@ void CallDivert(int argc, char *argv[])
else if (strcasecmp("data" , argv[4]) == 0) {cd.Request.CallType = GSM_DIVERT_DataCalls ;}
else {
printf(_("Unknown call type (\"%s\")\n"),argv[4]);
- Terminate(3);
+ Terminate(2);
}
GSM_Init(TRUE);
diff --git a/gammu/nokia.c b/gammu/nokia.c
index 591d0ae..a13bcca 100644
--- a/gammu/nokia.c
+++ b/gammu/nokia.c
@@ -41,7 +41,7 @@ void NokiaComposer(int argc UNUSED, char *argv[])
if (ringtone.Format != RING_NOTETONE) {
printf("%s\n", _("It can be RTTL ringtone only used with this option"));
- Terminate(3);
+ Terminate(2);
}
started = FALSE;
@@ -437,7 +437,7 @@ void NokiaAddPlayLists(int argc UNUSED, char *argv[] UNUSED)
if (error == ERR_FILENOTEXIST) {
printf("%s\n", _("Your phone model is not supported. Please report it to authors (see <http://wammu.eu/support/bugs/>). Thank you."));
GSM_Terminate();
- Terminate(3);
+ Terminate(2);
} else if (error != ERR_EMPTY) {
Print_Error(error);
}
@@ -546,7 +546,7 @@ void NokiaAddFile(int argc, char *argv[])
}
if (!Found) {
printf(_("What folder type (\"%s\") ?\n"),argv[2]);
- Terminate(3);
+ Terminate(2);
}
if (strcasecmp(argv[2],"Application") == 0 || strcasecmp(argv[2],"Game") == 0) {
@@ -581,7 +581,7 @@ void NokiaAddFile(int argc, char *argv[])
if (!Found) {
printf("%s\n", _("Folder not found. Probably function not supported!"));
GSM_Terminate();
- Terminate(3);
+ Terminate(2);
}
} else if (GSM_IsPhoneFeatureAvailable(GSM_GetModelInfo(gsm), F_FILES2)) {
i = 0;
@@ -655,7 +655,7 @@ void NokiaAddFile(int argc, char *argv[])
if (!Found) {
printf("%s\n", _("Folder not found. Probably function not supported!"));
GSM_Terminate();
- Terminate(3);
+ Terminate(2);
}
File.Buffer = NULL;
File.Protected = FALSE;
@@ -935,7 +935,7 @@ void NokiaAddFile(int argc, char *argv[])
continue;
}
printf(_("Parameter \"%s\" unknown\n"),argv[j]);
- Terminate(3);
+ Terminate(2);
case 1:
strcpy(buffer,argv[j]);
nextlong = 0;
@@ -944,7 +944,7 @@ void NokiaAddFile(int argc, char *argv[])
}
if (nextlong!=0) {
printf_err("%s\n", _("Parameter missing!"));
- Terminate(3);
+ Terminate(2);
}
}
}
diff --git a/gammu/sniff.c b/gammu/sniff.c
index eaada7d..a17b03b 100644
--- a/gammu/sniff.c
+++ b/gammu/sniff.c
@@ -249,10 +249,9 @@ static void prepareStateMachine(void)
void decodesniff(int argc, char *argv[])
{
GSM_ConnectionType Protocol = GCT_MBUS2;
- unsigned char Buffer[50000];
- unsigned char Buffer2[50000];
+ unsigned char Buffer[65536]={'\0'},Buffer2[65536]={'\0'};
FILE *file;
- int len, len2, pos, state, i;
+ int len=0, len2=0, pos=0, state=0, i=0;
unsigned char mybyte1 = 0,mybyte2;
GSM_Error error;
@@ -262,12 +261,12 @@ void decodesniff(int argc, char *argv[])
Protocol = GCT_IRDAPHONET;
} else {
printf("What protocol (\"%s\") ?\n",argv[2]);
- Terminate(3);
+ Terminate(2);
}
file = fopen(argv[3], "rb");
if (file == NULL) {
printf("Can not open file \"%s\"\n",argv[3]);
- Terminate(3);
+ Terminate(2);
}
prepareStateMachine();
if (argc > 4) {
@@ -291,10 +290,12 @@ void decodesniff(int argc, char *argv[])
MBUS2Data.MsgRXState=RX_Sync;
len2=30000;
state=0;
+
while (len2==30000) {
len2=fread(Buffer, 1, 30000, file);
pos=0;
len=0;
+
while (pos!=len2) {
switch (state) {
case 0:
@@ -346,31 +347,34 @@ void decodesniff(int argc, char *argv[])
void decodebinarydump(int argc, char *argv[])
{
- unsigned char Buffer[50000];
FILE *file;
- int len, len2, i;
- unsigned char type;
- gboolean sent;
GSM_Protocol_Message msg;
GSM_Debug_Info ldi = {DL_TEXTALL, stdout, FALSE, NULL, TRUE, FALSE, NULL, NULL};
- GSM_Error error;
+ GSM_Error error;
+ unsigned char Buffer[65536]={'\0'},type=0;
+ int len=0, len2=0, i=0;
+ gboolean sent=FALSE;
prepareStateMachine();
+
if (argc > 3) {
strcpy(gsm->CurrentConfig->Model,argv[3]);
error = GSM_RegisterAllPhoneModules(gsm);
if (error!=ERR_NONE) Print_Error(error);
}
file = fopen(argv[2], "rb");
+
if (file == NULL) {
printf("Can not open file \"%s\"\n",argv[2]);
Terminate(3);
}
len2=30000;
msg.Buffer = NULL;
+
while (len2==30000) {
len2=fread(Buffer, 1, 30000, file);
i=0;
+
while (i!=len2) {
if (Buffer[i++]==0x01) {
smprintf(gsm, "Sending frame ");
@@ -384,12 +388,12 @@ void decodebinarydump(int argc, char *argv[])
len = len + Buffer[i++];
smprintf(gsm, "0x%02x / 0x%04x", type, len);
DumpMessage(&ldi, Buffer+i, len);
- fflush(stdout);
+
if (gsm->Phone.Functions != NULL && !sent) {
msg.Buffer = (unsigned char *)realloc(msg.Buffer,len);
memcpy(msg.Buffer,Buffer+i,len);
- msg.Type = type;
- msg.Length = len;
+ msg.Type = type;
+ msg.Length = len;
gsm->Phone.Data.RequestMsg = &msg;
gsm->Phone.Functions->DispatchMessage(gsm);
}
@@ -397,7 +401,6 @@ void decodebinarydump(int argc, char *argv[])
}
}
fclose(file);
-
}
#endif