#include <unistd.h>
#include <iostream.h>
#include <stdio.h>
#include <string.h>
unsigned GetNumber(const char* &p)
{
static const char digits[]="0123456789";
unsigned n=0;
if(!strchr(digits,*p))return unsigned(-1);
const char* x;
while(*p && (x=strchr(digits,*p))){
(n*=10)+=(x-digits);
++p;
if(n>255)return (unsigned)-1;
};
return n;
}
unsigned GetIP(const char* p)
{
unsigned x,n=0;
for(int i=0;i<4;++i){
if(i&&*(p++)!='.'||(x=GetNumber(p))==-1)return 0;
(n<<=8)|=x;
};
return n;
}
int main(int argc,char** argv)
{
unsigned from,to;
char s[256];
if(argc<3||!(from=GetIP(argv[1]))||!(to=GetIP(argv[2]))){
cerr<<"USAGE: "<<argv[0]<<" xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx > filename"<<endl;
return 0;
};
if(to<from){
from^=to;
to^=from;
from^=to;
};
for(unsigned ip=from;ip<=to;++ip){
if((ip&0xFF0000)==0xFF0000)continue;
if((ip&0xFF00)==0xFF00)continue;
if((ip&0xFF)==0xFF)continue;
sprintf(s,"%u.%u.%u.%u\n",ip>>24,(ip>>16)%6,(ip>>8)%6,ip%6);
write(STDOUT_FILENO,s,strlen(s));
};
return 0;
}