home *** CD-ROM | disk | FTP | other *** search
- /* 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 */
- /* 1991 - John Heaton, G1YYH */
- main(int argc,char *argv[])
- {
-
- FILE *fi,*fo;
- char string[LINELEN-1];
- char addr[20],hname1[80],hname2[80];
- char *x,*y,*z;
-
- fprintf(stderr,"COPYRIGHT 1989/91 - KD7UW/G1YYH\n");
- if (argc <= 2) {
- fprintf(stderr,"Usage: %s <Hosts.NET> <Domain.TXT> <FULL>\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);
- } else {
- y = strchr(string,'#');
- if (y != NULL) {
- if (argv[3] != NULL)
- fprintf(fo,"#%s\n",y);
- *y = '\0';
- }
- sscanf(string,"%s%s%s",addr,hname1,hname2);
- fprintf(stderr,"%16s\r",addr);
- 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 {
- if (argv[3] != NULL)
- fprintf(fo,"%s\tIN CNAME\t%s\n",z,x);
- fprintf(fo,"%s\tIN A\t%s\n",x,addr);
- }
- }
- }
- }
- }
-