File: ip-to-int

package info (click to toggle)
epic4 1%3A3.0-2.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,756 kB
  • sloc: ansic: 56,285; makefile: 631; sh: 161; perl: 30
file content (22 lines) | stat: -rw-r--r-- 479 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
: {
	This converts an ip address (which you provide)
	into a 32 bit internet address, ala what DCC uses.
	One small problem -- epic does math with 'long's and
	not 'unsigned long's and so ip addresses above 128.*
	result in negative values.  How to fix this is left
	as an exercise for the reader.

	Written in November, 2000
}

alias ip_to_int (ip, void)
{
	@ :ip_list = split(. $ip)
	@ :ip32 = 0
	for xx in ($ip_list) {
		@ ip32 = (ip32 << 8) + xx
	}
	return $ip32
}

#hop'y2k