]> sjero.net Git - linphone/blobdiff - coreapi/proxy.c
add access to country code from iso name
[linphone] / coreapi / proxy.c
index bb01f14ee1ade10c993646db026160d6ba467da6..47fe08bdda30401886af9412814a843af33c198e 100644 (file)
@@ -375,21 +375,33 @@ bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg
  */
 typedef struct dial_plan{
        const char *country;
+       const char* iso_country_code; /* ISO 3166-1 alpha-2 code, ex: FR for France*/
        char  ccc[8]; /*country calling code*/
        int nnl; /*maximum national number length*/
        const char * icp; /*international call prefix, ex: 00 in europe*/
+       
 }dial_plan_t;
 
 /* TODO: fill with information for all countries over the world*/
 static dial_plan_t const dial_plans[]={
-       {"France"       , "33"  , 9     , "00"  },
-       {"United States", "1"   , 10    , "011" },
-       {"Turkey"       , "90"  , 10    , "00"  },
-       {"Switzerland"  , "41"  , 9     , "00"  },
-       {NULL           , ""    , 0     , NULL  }
+       {"France"                       ,"FR"           , "33"  , 9             , "00"  },
+       {"United States"        ,"US"           , "1"   , 10    , "011" },
+       {"Turkey"                       ,"TR"           , "90"  , 10    , "00"  },
+       {"Switzerland"          ,"XK"           , "41"  , 9             , "00"  },
+       {NULL           ,NULL,""        , 0     , NULL  }
 };
 
-static dial_plan_t most_common_dialplan={ "generic" , "", 10, "00"};
+static dial_plan_t most_common_dialplan={ "generic" ,"", "", 10, "00"};
+
+int linphone_dial_plan_lookup_ccc_from_iso(const char* iso) {
+       dial_plan_t* dial_plan;
+       for (dial_plan=(dial_plan_t*)dial_plans; dial_plan->country!=NULL; dial_plan++) {
+               if (strcmp(iso, dial_plan->iso_country_code)==0) {
+                       return atoi(dial_plan->ccc);
+               }
+       }
+       return -1;
+}
 
 static void lookup_dial_plan(const char *ccc, dial_plan_t *plan){
        int i;