add experimental sane-backends package, like to get canon scanner working via saned
[openwrt.git] / openwrt / package / base-files / default / etc / functions.sh
1 #!/bin/sh
2 . /etc/nvram.sh
3
4 alias debug=${DEBUG:-:}
5
6 # valid interface?
7 if_valid () (
8 ifconfig "$1" >&- 2>&- ||
9 [ "${1%%[0-9]}" = "br" ] ||
10 { debug "# missing interface '$1' ignored"; false; }
11 )
12
13 hotplug_dev() {
14 env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
15 }
16
17 bitcount () {
18 local c=$1
19 echo $((
20 c=((c>> 1)&0x55555555)+(c&0x55555555),
21 c=((c>> 2)&0x33333333)+(c&0x33333333),
22 c=((c>> 4)&0x0f0f0f0f)+(c&0x0f0f0f0f),
23 c=((c>> 8)&0x00ff00ff)+(c&0x00ff00ff),
24 c=((c>>16)&0x0000ffff)+(c&0x0000ffff)
25 ))
26 }
27
28 valid_netmask () {
29 return $((-($1)&~$1))
30 }
31
32 ip2int () (
33 set $(echo $1 | tr '\.' ' ')
34 echo $(($1<<24|$2<<16|$3<<8|$4))
35 )
36
37 int2ip () {
38 echo $(($1>>24&255)).$(($1>>16&255)).$(($1>>8&255)).$(($1&255))
39 }
This page took 0.063369 seconds and 5 git commands to generate.