Compare commits
2 Commits
51daae4c1d
...
7da798d8fa
Author | SHA1 | Date |
---|---|---|
Nick Chambers | 7da798d8fa | |
Nick Chambers | 23505bf8a5 |
|
@ -4,7 +4,7 @@
|
||||||
uint32_t numeric_ip4(const char *ip) {
|
uint32_t numeric_ip4(const char *ip) {
|
||||||
uint32_t octets = 0;
|
uint32_t octets = 0;
|
||||||
uint8_t octet = 0;
|
uint8_t octet = 0;
|
||||||
|
|
||||||
for(; *ip; ip += 1) {
|
for(; *ip; ip += 1) {
|
||||||
if(*ip == '.') {
|
if(*ip == '.') {
|
||||||
octets = (octets << 8) | octet;
|
octets = (octets << 8) | octet;
|
||||||
|
@ -13,7 +13,7 @@ uint32_t numeric_ip4(const char *ip) {
|
||||||
octet = (octet * 10) + (*ip - '0');
|
octet = (octet * 10) + (*ip - '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (octets << 8) | octet;
|
return (octets << 8) | octet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
foreach $arg (0..$#ARGV) {
|
||||||
|
my $num = int($ARGV[$arg]);
|
||||||
|
my $fmt = "", $cnt = 0;
|
||||||
|
|
||||||
|
while($num > 0) {
|
||||||
|
$fmt = ($num % 10) . $fmt;
|
||||||
|
|
||||||
|
if(++$cnt % 3 == 0 and $num >= 10) {
|
||||||
|
$fmt = "," . $fmt;
|
||||||
|
}
|
||||||
|
|
||||||
|
use integer;
|
||||||
|
$num /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
print "$fmt\n";
|
||||||
|
}
|
Loading…
Reference in New Issue