#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (int argc, char* argv[])
{
	char s[255];
	FILE *packetfile, *outfile;
	if (argc != 4) {
        printf("syntax: %s <Packet File> <Output File> <Host>\n", argv[0]);
		return 0;
	}
	strcat(argv[3], "\r\n");
	packetfile = fopen(argv[1], "r");
	outfile = fopen(argv[2], "w");
	if (packetfile != NULL && outfile != NULL)
	{
		while ((fgets (s, 7, packetfile)) != NULL)
		{
			fputs(s, outfile);
			if (strcmp(s, "Host: ") == 0)
			{
				fputs(argv[3], outfile);
				fgets (s, 254, packetfile);
			}
		}
	}
	fclose(packetfile);
	packetfile = fopen(argv[1], "w");
	fclose(packetfile);
	return 0;
}


