summaryrefslogtreecommitdiff
path: root/gammu/gammu.c
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2011-06-07 15:38:35 +0200
committerMichal Čihař <michal@cihar.com>2011-06-07 15:38:35 +0200
commit5a2b6d8ab9b24e84a056ba753f18cb17b8380ce9 (patch)
treebf5609e5fac5fc66f62c9c3d744c1fddae05c2d8 /gammu/gammu.c
parent477cceca6e30f94c6fe4673266a56804378ff935 (diff)
Imported Upstream version 1.29.93
Diffstat (limited to 'gammu/gammu.c')
-rw-r--r--gammu/gammu.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/gammu/gammu.c b/gammu/gammu.c
index a571c0d..bd6dfd5 100644
--- a/gammu/gammu.c
+++ b/gammu/gammu.c
@@ -60,24 +60,18 @@
static void ListNetworks(int argc, char *argv[])
{
int i = 0;
- char country[4] = "";
+ const char *country_code = NULL;
if (argc > 2) {
- while (GSM_Countries[i * 2] != NULL) {
- if (strncmp
- (GSM_Countries[i * 2 + 1], argv[2],
- strlen(argv[2])) == 0
- || strncmp(GSM_Countries[i * 2], argv[2],
- strlen(argv[2])) == 0) {
- strcpy(country, GSM_Countries[i * 2]);
- printf(_("Networks for %s:"),
- GSM_Countries[i * 2 + 1]);
+ for (i = 0; GSM_Countries[i].Code[0] != 0; i++) {
+ if (strcmp(GSM_Countries[i].Name, argv[2]) == 0 || strcasecmp(GSM_Countries[i].Code, argv[2]) == 0) {
+ country_code = GSM_Countries[i].Code;
+ printf(_("Networks for %s:"), GSM_Countries[i].Name);
printf("\n\n");
break;
}
- i++;
}
- if (strlen(country) == 0) {
+ if (country_code == NULL) {
printf(_("Unknown country name: %s."), argv[2]);
printf("\n");
Terminate(2);
@@ -85,18 +79,10 @@ static void ListNetworks(int argc, char *argv[])
}
printf("%-10s %s\n", _("Network"), _("Name"));
i = 0;
- while (GSM_Networks[i * 2] != NULL) {
- if (argc > 2) {
- if (!strncmp
- (GSM_Networks[i * 2], country, strlen(country))) {
- printf("%-10s %s\n", GSM_Networks[i * 2],
- GSM_Networks[i * 2 + 1]);
- }
- } else {
- printf("%-10s %s\n", GSM_Networks[i * 2],
- GSM_Networks[i * 2 + 1]);
+ for (i = 0; GSM_Networks[i].Code[0] != 0; i++) {
+ if (country_code == NULL || strncmp(GSM_Networks[i].Code, country_code, 3) == 0) {
+ printf("%-10s %s\n", GSM_Networks[i].Code, GSM_Networks[i].Name);
}
- i++;
}
}