Given a network name and a country name, this prints the corresponding MCC and MNC or "undefined" if the name is not found.
Both network (operator) and country name are case insensitive, but you need to type them exactly as you find them in libgnokii (use gnokii --listnetworks
to see all network names known by libgnokii and please report to the gnokii mailing list if you find errors or omissions).
Examples:
$ network_code vodafone italy 222 10 $ network_code vodafone germany 262 02
Source code:
/* $Id:$ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Copyright (c) 2006 by Daniele Forsi Prints the MCC and the MNC corresponding to the given network (operator) and country names (case insensitive). Prints "undefined" if the name is not found. gcc -Wall network_code.c -o network_code $(pkg-config --libs gnokii) network_code vodafone italy 222 10 network_code vodafone Germany */ #include <stdio.h> #include <gnokii.h&t; int main( int argc, char *argv[] ) { char *country, *code; if ( argc == 3 ) { country = argv[ 2 ]; } else { printf( "Usage: %s network_name country_name\n", argv[0]); return 1; } code = gn_network_code_find(argv[1], country); printf("%s\n", code ); return 0; }