home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 3
/
hamradioversion3.0examsandprograms1992.iso
/
packet
/
n17jsrc
/
gendom.c
< prev
next >
Wrap
Text File
|
1990-12-11
|
1KB
|
73 lines
/* Here is a program to convert your hosts.net to domain.txt */
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define LINELEN 256
/* copyright 1989 - John D. Hays, KD7UW */
main(int argc,char *argv[])
{
FILE *fi,*fo;
char string[LINELEN-1];
char addr[20],hname1[80],hname2[80];
char *x,*y,*z;
int cnt;
fprintf(stderr,"COPYRIGHT 1989 - John D. Hays, KD7UW\n");
if (argc != 3)
{
fprintf(stderr,"Usage: %s input-hosts.net output-domain.txt\n\007",
argv[0]);
exit(0);
}
if ((fi=fopen(argv[1],"r")) != NULL)
{
fo = fopen(argv[2],"w");
while (fgets(string,LINELEN,fi) != NULL)
{
y = strchr(string,'\n');
*y = '\0';
addr[0] = '\0';
hname1[0] = '\0';
hname2[0] = '\0';
if ((string[0] == '#') || (strlen(string) < 3))
{
fprintf(fo,"%s\n",string);
goto foo;
}
y = strchr(string,'#');
if (y != NULL)
{
fprintf(fo,"#%s\n",y);
*y = '\0';
}
sscanf(string,"%s%s%s",addr,hname1,hname2);
if (strchr(hname1,'.'))
{
x = hname1;
z = hname2;
}
else
{
x = hname2;
z = hname1;
}
if ((*x == '\0') || (*z == '\0'))
{
fprintf(fo,"%s.\tIN\tA\t%s\n",hname1,addr);
}
else
{
fprintf(fo,"%s.\tIN\tA\t%s\n",x,addr);
fprintf(fo,"%s.\tIN\tCNAME\t%s.\n",z,x);
}
foo: fprintf(stderr,"%s\n",string);
}
}
}