Question: #include #include #include #include #include // Global Vars for fileChNames char InputFile[] = CS222_Inet.txt; char Output_Locality_Rpt[] = 222 Locality Report.txt; char Output_Alias_List[] = 222 Alias

#include #include #include #include #include

// Global Vars for fileChNames char InputFile[] = "CS222_Inet.txt"; char Output_Locality_Rpt[] = "222 Locality Report.txt"; char Output_Alias_List[] = "222 Alias List.txt";

// structure to hold the first 2 parts in an ip address struct locality_t { int IP1; int IP2; struct locality_t *nxt; };

// structure to hold the data file information struct address_t { int IP1; int IP2; int IP3; int IP4; char ChName[10]; };

int Read_Data_File (struct address_t *);

void BubbleSort (int, struct address_t *);

void Generate_Locality_Rpt (int, struct address_t *);

void Generate_Alias_List (int, struct address_t *);

void Insert_locality_t(struct locality_t **, int , int );

int main () { int i,j;

struct address_t Dfile[100];

int num = Read_Data_File(Dfile); Generate_Locality_Rpt(num,Dfile); Generate_Alias_List(num,Dfile);

}

void Insert_locality_t(struct locality_t **dptrtoL, int IP1, int IP2) {

if(dptrtoL==NULL) {

struct locality_t *temp = malloc(sizeof(struct locality_t)); temp->IP1 = IP1; temp->IP2 = IP2; *dptrtoL = temp; } else {

struct locality_t *sptrtoL = NULL; sptrtoL = *dptrtoL;

while(sptrtoL != NULL) {

if(sptrtoL->IP1 == IP1 && sptrtoL->IP2 == IP2) {

return; }

sptrtoL = sptrtoL->nxt; } struct locality_t *temp = malloc(sizeof(struct locality_t));

temp->IP1 = IP1; temp->IP2 = IP2;

temp->nxt = *dptrtoL;

*dptrtoL = temp;

} }

int Read_Data_File (struct address_t *address) { int num = 0; char line[30];

FILE *fh = fopen(InputFile ,"r"); do { fgets(line,sizeof(line), fh); if (strstr(line, "none") == NULL) { sscanf(line, "%d.%d.%d.%d %s", &address[num].IP1, &address[num].IP2, &address[num].IP3, &address[num].IP4, address[num].ChName); num++; } } while (strstr(line, "none") == NULL); fclose(fh); return num;

} void BubbleSort(int num, struct address_t *address) { int i,j;

for ( i=1; i0) { struct address_t temp = address[j]; address[j] = address[j+1]; address[j+1] = temp; } } } }

void Generate_Locality_Rpt(int num,struct address_t * address) { int i;

struct locality_t *head = NULL;

struct locality_t *sptrtoL = NULL;

for(i=0;i

time_t t = time(NULL); struct tm *tm = localtime(&t); char date_str[64];

strftime(date_str, sizeof(date_str), "%B %d, %Y", tm);

fprintf(fh,"RANDOM NAME %s ",date_str); fprintf(fh, "CS222 Network Locality Report " );

while(sptrtoL != NULL) {

fprintf(fh,"%d.%d ",sptrtoL->IP1,sptrtoL->IP2 );

for(i=0;iIP1 == address[i].IP1 && sptrtoL->IP2 == address[i].IP2) { fprintf(fh,"%s ",address[i].ChName ); }

} fprintf(fh, " " ); sptrtoL = sptrtoL->nxt; }

fclose(fh);

}

void Generate_Alias_List(int num,struct address_t * address) {

FILE *fh = fopen(Output_Alias_List ,"w"); int i;

time_t t = time(NULL); struct tm *tm = localtime(&t); char date_str[64];

strftime(date_str, sizeof(date_str), "%B %d, %Y", tm);

fprintf(fh,"Random NAME %s ",date_str); fprintf(fh, "CS222 Network Alias Report " );

BubbleSort(num, address);

for(i=0;i

}

THIS IS MY CODE. COULD YOU PLEASE CHECK IF THE CODE GIVES THE SAME OUT AN MEETS THE BELOW CODNTION. CODE IS IN C LANYGUAGE

 #include #include #include #include #include // Global Vars for fileChNames char

Examples Xamples: Hal Greenwald July 13, 2017 Hal Greenwald July 13, 2017 CS222 Network Alias Listing CS222 Network Locality Report 111.22 platte green 131.250.47.63 111.22.5.66 131.250.95.21 111.22.3.44 172.66.7.88 baker green platte wabash 131.250 baker 172.66 wabash Program structure and design Create a structure type called address_t with components for the four integers of an IPv4 address along with a fifth component in which to store an associated alias of up to 10 characters. Create a two-dimensional array called locality t which will contain each unique locality pair: int locality t[100][2]; In the above example, the locality t would contain the following three unique locality pairs locality tlrowl[O locality trowll1 131 250

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!