#include #include #include #include #define FNAME "/usr/share/3gmodem/apn.json" int main( int argc, char **argv ) { int ret=0; int cnt_apn=0; if ( argc != 2 ) { printf(" %s [APN_Provider_5_symbols]\n", argv[0]); printf("%s 12345\n", argv[0]); return -1; } else if ( strlen(argv[1]) != 5 ) { printf("ERR: Only 5 number apn supported\n"); return -1; } char *apnnumber = argv[1]; char mcc[4]; char mnc[3]; memcpy( mcc, apnnumber, 3 ); mcc[3] = 0; memcpy( mnc, apnnumber+3 , 2 ); mnc[2] = 0; int i; struct json_object *jo = json_object_from_file( FNAME ); if ( jo == NULL ) { printf("ERR:Cannot get file\n"); ret = 1; goto free_resources; } struct json_object *jarr = json_object_object_get( jo, "data" ); if ( jarr == NULL ) { printf("ERR:Cannot get data object\n"); ret = 1; goto free_resources; } if ( !json_object_is_type( jarr, json_type_array ) ) { printf("ERR:Object isnot array\n"); ret = 1; goto free_resources; } for (i=0; i