1 # AWK file for validating uci specification files
3 # Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 function is_int
(value
) {
21 if (value !~
/^
[0-9]*$
/) { valid =
0 }
25 function is_netmask
(value
) {
29 function is_ip
(value
) {
31 if ((value
!= "") && (value !~
/^
[0-9][0-9]*\.
[0-9][0-9]*\.
[0-9][0-9]*\.
[0-9][0-9]*$
/)) valid =
0
33 split(value
, ipaddr
, "\\.")
34 for (i =
1; i
<=
4; i
++) {
35 if ((ipaddr
[i
] < 0) || (ipaddr
[i
] > 255)) valid =
0
41 function is_wep
(value
) {
43 if (value !~
/^
[0-9A
-Fa
-f
]*$
/) {
45 } else if ((length(value
) != 0) && (length(value
) != 10) && (length(value
) != 26)) {
47 } else if (value ~
/0$
/) {
53 function is_hostname
(value
) {
55 if (value !~
/^
[0-9a
-zA
-z\.\
-]*$
/) {
61 function is_string
(value
) {
65 function is_mac
(value
) {
67 if ((value
!= "") && (value !~
/^
[0-9a
-fA
-F
][0-9a
-fA
-F
]:[0-9a
-fA
-F
][0-9a
-fA
-F
]:[0-9a
-fA
-F
][0-9a
-fA
-F
]:[0-9a
-fA
-F
][0-9a
-fA
-F
]:[0-9a
-fA
-F
][0-9a
-fA
-F
]:[0-9a
-fA
-F
][0-9a
-fA
-F
]$
/)) {
73 function is_port
(value
) {
75 if (value !~
/^
[0-9]*$
/) {
81 function is_ports
(value
) {
83 n =
split(value
",", ports
, ",")
84 for (i =
1; i
<= n
; i
++) {
85 if ((ports
[i
] !~
/^
[0-9]*$
/) && (ports
[i
] !~
/^
[0-9][0-9]*-[0-9][0-9]*$
/)) {
92 function is_wpapsk
(value
) {
94 if (length(value
) > 64) {
97 if ((length(value
) != 0) && (length(value
) < 8)) {
100 if ((length(value
) ==
64) && (value ~
/[^
0-9a
-fA
-F
]/)) {
This page took 0.05088 seconds and 5 git commands to generate.