GNOKII_API char *gn_network2country(char *network_code) { char ccode[4]; snprintf(ccode, sizeof(ccode), "%s", network_code); return gn_country_name_get(ccode); }
void list_gsm_networks(void) { gn_network network; int i = 0; printf(_("Network Name\n")); printf(_("-----------------------------------------\n")); while (gn_network_get(&network, i++)) printf(_("%-7s %s (%s)\n"), network.code, network.name, gn_country_name_get(network.code)); }
gn_error getnetworkinfo(gn_data *data, struct gn_statemachine *state) { gn_network_info networkinfo; gn_error error; int lac, cid; char country[4] = {0, 0, 0, 0}; gn_data_clear(data); memset(&networkinfo, 0, sizeof(networkinfo)); data->network_info = &networkinfo; state->callbacks.reg_notification = NULL; data->callback_data = NULL; if ((error = gn_sm_functions(GN_OP_GetNetworkInfo, data, state)) != GN_ERR_NONE) { fprintf(stderr, _("Error: %s\n"), gn_error_print(error)); return error; } /* Ugly, ugly, ... */ if (networkinfo.cell_id[2] == 0 && networkinfo.cell_id[3] == 0) cid = (networkinfo.cell_id[0] << 8) + networkinfo.cell_id[1]; else cid = (networkinfo.cell_id[0] << 24) + (networkinfo.cell_id[1] << 16) + (networkinfo.cell_id[2] << 8) + networkinfo.cell_id[3]; lac = (networkinfo.LAC[0] << 8) + networkinfo.LAC[1]; memcpy(country, networkinfo.network_code, 3); fprintf(stdout, _("Network : %s (%s)\n"), gn_network_name_get((char *)networkinfo.network_code), gn_country_name_get((char *)country)); fprintf(stdout, _("Network code : %s\n"), (*networkinfo.network_code ? networkinfo.network_code : _("undefined"))); fprintf(stdout, _("LAC : %04x (%d)\n"), lac, lac); fprintf(stdout, _("Cell id : %08x (%d)\n"), cid, cid); return GN_ERR_NONE; }