summaryrefslogtreecommitdiffstats
path: root/include/plmn_list.sh
diff options
context:
space:
mode:
Diffstat (limited to 'include/plmn_list.sh')
-rwxr-xr-xinclude/plmn_list.sh31
1 files changed, 19 insertions, 12 deletions
diff --git a/include/plmn_list.sh b/include/plmn_list.sh
index 26e9616..0a17068 100755
--- a/include/plmn_list.sh
+++ b/include/plmn_list.sh
@@ -1,22 +1,26 @@
#!/bin/sh
#
-# Copyright 2012 Paul Kocialkowski, GPLv3+
+# Copyright 2012-2014 Paul Kocialkowski, GPLv3+
#
# This script is a dirty hack, keep in mind that is was written in a hurry
-# and doesn't reflect our code cleanness standards.
+# and doesn't reflect our code cleanness standards.
# Any (working) replacement written in a cleaner way, such as a perl script
# would be greatly appreciated.
-echo "/**"
-echo " * This list was generated from http://en.wikipedia.org/wiki/Mobile_Network_Code"
-echo " * "
+echo "/*"
+echo " * This list was generated from:"
+echo " * http://en.wikipedia.org/wiki/Mobile_country_code"
+echo " *"
echo " * Date: "$( date "+%x %X" )
-echo " * Copyright: Wikipedia Contributors, Creative Commons Attribution-ShareAlike License"
+echo " * Copyright: Wikipedia Contributors, Creative Commons"
+echo " * Attribution-ShareAlike License"
echo " */"
echo ""
echo "#ifndef _PLMN_LIST_H_"
echo "#define _PLMN_LIST_H_"
echo ""
+echo "#include <stdlib.h>"
+echo ""
echo "struct plmn_list_entry {"
echo " unsigned int mcc;"
echo " unsigned int mnc;"
@@ -26,7 +30,7 @@ echo "};"
echo ""
echo "struct plmn_list_entry plmn_list[] = {"
-wget "http://en.wikipedia.org/w/index.php?title=Special:Export&pages=Mobile_country_code&action=submit" --quiet -O - | tr -d '\n' | sed -e "s|.*<text[^>]*>\(.*\)</text>.*|\1|g" -e "s/|-/\n|-\n/g" | sed -e "s/\(}===.*\)/\n\1/g" -e "s/===={.*/===={\n/g" -e "s/\&amp;/\&/g" -e "s/\&lt;[^\&]*\&gt;//g" -e "s/&quot;//g" -e "s#\[http[^]]*\]##g" -e "s#\[\[\([^]|]*\)|\([^]]*\)\]\]#\2#g" -e "s#\[\[\([^]]*\)\]\]#\1#g" -e "s#\[\([^] ]*\) \([^]]*\)\]#\2#g" | tail -n +2 | sed "s|.*=== \(.*\) ===.*|// \1|g" | grep -v "|-" | while read line
+wget "http://en.wikipedia.org/w/index.php?title=Special:Export&pages=Mobile_country_code&action=submit" --quiet -O - | tr -d '\n' | sed -e "s|.*<text[^>]*>\(.*\)</text>.*|\1|g" -e "s/|-/\n|-\n/g" | sed -e "s/\(}===.*\)/\n\1/g" -e "s/===={.*/===={\n/g" -e "s/\&amp;/\&/g" -e "s/\&lt;[^\&]*\&gt;//g" -e "s/&quot;//g" -e "s#\[http[^]]*\]##g" -e "s#\[\[\([^]|]*\)|\([^]]*\)\]\]#\2#g" -e "s#\[\[\([^]]*\)\]\]#\1#g" -e "s#\[\([^] ]*\) \([^]]*\)\]#\2#g" -e "s#{{[^}]*}}##g" | tail -n +2 | sed "s|.*==== *\([^=]*\) *====.*|// \1|g" | grep -v "|-" | while read line
do
if [ "$line" = "" ]
then
@@ -37,7 +41,7 @@ do
if [ ! "$test" = "" ]
then
- echo "\n\t$line\n" | sed -e "s#[^|]*|\(.*\)#// \1#g" -e "s/^ //g" -e "s/ $//g"
+ echo "\n\t$line\n" | sed -e "s#[^|]*|\(.*\)#// \1#g" -e "s/^ //g" -e "s/ $//g" -e "s/ / /g"
continue
fi
@@ -48,10 +52,10 @@ do
continue
fi
- mcc=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\1#g" -e "s/^ //g" -e "s/ $//g" -e "s/[^1-9]*\([0-9]*\).*/\1/g")
- mnc=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\2#g" -e "s/^ //g" -e "s/ $//g" -e "s/[^1-9]*\([0-9]*\).*/\1/g")
- brand=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\3#g" -e "s/^ //g" -e "s/ $//g" )
- operator=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\4#g" -e "s/^ //g" -e "s/ $//g" )
+ mcc=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\1#g" -e "s/^[ |\t]*//g" -e "s/ [ |\t]*$//g" -e "s/[^1-9]*\([0-9]*\).*/\1/g")
+ mnc=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\2#g" -e "s/^[ |\t]*//g" -e "s/ [ |\t]*$//g" -e "s/[^1-9]*\([0-9]*\).*/\1/g")
+ brand=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\3#g" -e "s/^[ |\t]*//g" -e "s/ [ |\t]*$//g" )
+ operator=$( echo "$line" | sed -e "s#[^|]*|[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\)[ ]*||[ ]*\([^|]*\).*#\4#g" -e "s/^[ |\t]*//g" -e "s/ [ |\t]*$//g" )
if [ "$mcc" = "" ] || [ "$mcc" = "?" ]
then
@@ -78,4 +82,7 @@ done
echo "};"
echo ""
+echo "unsigned int plmn_list_count = sizeof(plmn_list) /"
+echo "\tsizeof(struct plmn_list_entry);"
+echo ""
echo "#endif"