Exemple #1
0
// Print the variation of a row of nodes over time
void PrintTimeVariation(void)
{
	FILE *OutputFile;
	TimeVariationSet *CurrentTimeVariation;
	char *FilenameBuffer;

	FilenameBuffer = (char*)malloc(100*sizeof(char));

	sprintf_s(FilenameBuffer, 100*sizeof(char), "%s/%s_%s", FolderName, ProjectName, TimeVariationFilename);
	
	if (fopen_s(&OutputFile, FilenameBuffer, "w") != 0) {
		printf("Could not open file '%s'\n", TimeVariationFilename);
	}
	else {
		printf("Printing time variation to output file %s\n", TimeVariationFilename);
		PrintFileHeader(OutputFile);
		CurrentTimeVariation = TimeVariation;
		while (CurrentTimeVariation != NULL) {
			for (int x = 0; x < xSize; x++) {
				fprintf(OutputFile, "%f\t", CurrentTimeVariation->V[x]);
			}
			fprintf(OutputFile, "\n");
			CurrentTimeVariation = CurrentTimeVariation->NextSet;
		}

		if (fclose(OutputFile)) {
			printf("Output file close unsuccessful\n");
		}
	}
	free(FilenameBuffer);
}
Exemple #2
0
// Print the impedances of nodes to a text file
void PrintImpedances(void)
{
	FILE *OutputFile;
	double Impedance;
	char *FilenameBuffer;

	FilenameBuffer = (char*)malloc(100*sizeof(char));

	sprintf_s(FilenameBuffer, 100*sizeof(char), "%s/%s_%s", FolderName, ProjectName, OutputFilename);
	
	if (fopen_s(&OutputFile, FilenameBuffer, "w") != 0) {
		printf("Could not open file '%s'\n", OutputFilename);
	}
	else {
		printf("Printing Impedances to output file '%s'\n", OutputFilename);
		PrintFileHeader(OutputFile);
		for (int y = ySize-1; y>=0; y--) {
			for (int x = 0; x < xSize; x++) {
				Impedance = Grid[x][y][zSize/2].Z;
				if (x == ImpulseSource.X && y == ImpulseSource.Y) {
					fputc('i',OutputFile);
				}
				else if (x==PlaceWithinGridX(RoundToNearest(PathLossParameters.X1/GridSpacing)) && y == PlaceWithinGridY(RoundToNearest(PathLossParameters.Y1/GridSpacing))) {
					fputc('1',OutputFile);
				}
				else if (PathLossParameters.Type != POINT && x==PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing)) && y == PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing))) {
					fputc('2',OutputFile);
				}
				// E = 1
				else if (Impedance == IMPEDANCE_OF_FREE_SPACE) {
					fputc('.',OutputFile);
				}
				// E <= 2
				else if (Impedance >= IMPEDANCE_OF_FREE_SPACE/sqrt(2.0)) {
					fputc('W', OutputFile);
				}
				// E <= 5
				else if (Impedance >= IMPEDANCE_OF_FREE_SPACE/sqrt(5.0)) {
					fputc('#', OutputFile);
				}
				// E >= 5
				else {
					fputc(' ', OutputFile);
				}
			}
			fprintf(OutputFile, "\n");
		}

		if (fclose(OutputFile)) {
			printf("Output file close unsuccessful\n");
		}
	}
	free(FilenameBuffer);
}
BOOL OpenDebugLog()
{
	if( !g_bLogging ) return FALSE;

	
	GetModuleFileName( NULL, g_lpszLogFileName, MAX_PATH * 2UL - 64UL );
	const int len = lstrlen( g_lpszLogFileName );
	for( int i = len - 1; i >= 0; i-- )
	{
		if( g_lpszLogFileName[ i ] == TEXT( '\\' ) )
		{
			g_lpszLogFileName[ i ] = TEXT( '\0' );
			break;
		}
	}

	if( g_lpszLogFileName[ 0 ] == TEXT( '\0' ) )
	{
		GetCurrentDirectory( MAX_PATH * 2 - 64, g_lpszLogFileName );
	}

	TCHAR tmpstr[ 64 ] = TEXT( "" );
	SYSTEMTIME st;
	GetLocalTime( &st );
	wsprintf( tmpstr, TEXT( "\\bes-%04d%02d%02d.log" ), st.wYear, st.wMonth, st.wDay );


	lstrcat( g_lpszLogFileName, tmpstr );

	FILE * fdebug = _tfopen( g_lpszLogFileName, TEXT( "ab" ) );
	if( fdebug == NULL ) return FALSE;

#ifdef _UNICODE
	fputc( 0xFF, fdebug );
	fputc( 0xFE, fdebug );
#endif
	_fputts( TEXT( "-------- START --------\r\n" ), fdebug );

	PrintFileHeader( fdebug );

	fclose( fdebug );
	return TRUE;
}
Exemple #4
0
// Print information on the time taken to execute the program
void PrintTimingInformation(void)
{
	FILE *TimingFile;
	char *FilenameBuffer;

	FilenameBuffer = (char*)malloc(100*sizeof(char));

	sprintf_s(FilenameBuffer, 100*sizeof(char), "%s/%s_%s", FolderName, ProjectName, TimingFilename);
	
	if (fopen_s(&TimingFile, FilenameBuffer, "w") != 0) {
		printf("Could not open file '%s'\n", TimingFilename);
	}
	else {
		printf("Printing timing information to '%s'\n", TimingFilename);
		PrintFileHeader(TimingFile);
		fprintf(TimingFile, "Timing information for scene file '%s'\n", SceneFilename);
		fprintf(TimingFile, "TotalTime = %dms\nScene parsing time = %dms\nAlgorithm time = %dms\n", TimingData.FinishTime - TimingData.StartTime, TimingData.SceneParsingFinishTime - TimingData.SceneParsingStartTime, TimingData.AlgorithmFinishTime - TimingData.AlgorithmStartTime);
	}
	free(FilenameBuffer);
}
Exemple #5
0
// Print statistics to a file
void PrintStatsToFile()
{	
	FILE *StatsFile;
	char *FilenameBuffer;

	if (StatsList != NULL) {

		FilenameBuffer = (char*)malloc(100*sizeof(char));

		sprintf_s(FilenameBuffer, 100*sizeof(char), "%s/%s_%s", FolderName, ProjectName, StatsFilename);

		if (fopen_s(&StatsFile, FilenameBuffer, "w") != 0) {
			printf("Could not open file '%s'\n", StatsFilename);
		}
		else {
			Stats *CurrentStats = StatsList;
			int n = 0;

			printf("Printing statistics to '%s'\n",StatsFilename);
			PrintFileHeader(StatsFile);

			fprintf(StatsFile,"\nIteration\tActive Nodes\tAdded Nodes\tRemoved Both\tRemoved Abs\tRemoved Rel\tTotal Calcs\tBoundary Calcs\tNew Maximums\tIteration Time\n");

			while (CurrentStats != NULL) {
				fprintf(StatsFile, "%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\n", n, CurrentStats->nActiveNodes, CurrentStats->nAddedNodes, CurrentStats->nRemovedBoth, CurrentStats->nRemovedAbsolute, CurrentStats->nRemovedRelative, CurrentStats->nCalcs, CurrentStats->nBoundaryCalcs, CurrentStats->nNewMaximums, CurrentStats->IterationTime);

				CurrentStats = CurrentStats->NextStats;
				n++;
			}
	
			if (fclose(StatsFile)) {
				printf("Path loss file close unsuccessful\n");
			}
		}
		free(FilenameBuffer);	
	}
	else {
		printf("No statistics to print");
	}
}
Exemple #6
0
// Print information required to estimate the path loss error constant kappa to a text file
void PrintKappaData(void) 
{
	FILE *OutputFile;
	char *FilenameBuffer;

	FilenameBuffer = (char*)malloc(100*sizeof(char));

	sprintf_s(FilenameBuffer, 100*sizeof(char), "%s/%s_%s", FolderName, ProjectName, "KappaCalcs.txt");

	int x, y, z;
	double d;
	
	if (fopen_s(&OutputFile, FilenameBuffer, "w") != 0) {
		printf("Could not open file '%s'\n", "KappaCalcs.txt");
	}
	else {
		printf("Printing time variation to output file %s\n", "KappaCalcs.txt");
		PrintFileHeader(OutputFile);
		
		fprintf(OutputFile,"V\tDistance\tTheta\tPhi\n");
		for (int xx = 0; xx < 10; xx++) { 
			for (int yy = 0; yy < 10; yy++) {
				for (int zz = 0; zz < 10; zz++) {
					x = RoundToNearest(ImpulseSource.X + 9*xx*GridSpacing);
					y = RoundToNearest(ImpulseSource.Y + 9*yy*GridSpacing);
					z = RoundToNearest(ImpulseSource.Z + 9*zz*GridSpacing);
					d = 9*sqrt((double)(SQUARE(xx)+SQUARE(yy)+SQUARE(zz)));
					fprintf(OutputFile,"%f\t%f\t%f\t%f\n", Grid[x][y][z].Vmax, d, asin((9.0*zz)/d), atan((double)(yy)/xx));
				}
			}
		}


		if (fclose(OutputFile)) {
			printf("Output file close unsuccessful\n");
		}
	}
	free(FilenameBuffer);
}
Exemple #7
0
// Has nothing to do with the coff loader itself
// it can be used to parse the headers of a dll
// already loaded into memory
int CoffLoader::ParseHeaders(void* hModule)
{
  if (strncmp((char*)hModule, "MZ", 2) != 0)
    return 0;

  int* Offset = (int*)((char*)hModule+0x3c);
  if (*Offset <= 0)
    return 0;

  if (strncmp((char*)hModule+*Offset, "PE\0\0", 4) != 0)
    return 0;

  FileHeaderOffset = *Offset + 4;

  CoffFileHeader = (COFF_FileHeader_t *) ( (char*)hModule + FileHeaderOffset );
  NumOfSections = CoffFileHeader->NumberOfSections;

  OptionHeader = (OptionHeader_t *) ( (char*)CoffFileHeader + sizeof(COFF_FileHeader_t) );
  WindowsHeader = (WindowsHeader_t *) ( (char*)OptionHeader + OPTHDR_SIZE );
  EntryAddress = OptionHeader->Entry;
  NumOfDirectories = WindowsHeader->NumDirectories;

  Directory = (Image_Data_Directory_t *) ( (char*)WindowsHeader + WINHDR_SIZE);
  SectionHeader = (SectionHeader_t *) ( (char*)Directory + sizeof(Image_Data_Directory_t) * NumOfDirectories);

  if (CoffFileHeader->MachineType != IMAGE_FILE_MACHINE_I386)
    return 0;

#ifdef DUMPING_DATA
  PrintFileHeader(CoffFileHeader);
#endif

  if ( CoffFileHeader->SizeOfOptionHeader == 0 ) //not an image file, object file maybe
    return 0;

  // process Option Header
  if (OptionHeader->Magic == OPTMAGIC_PE32P)
  {
    printf("PE32+ not supported\n");
    return 0;
  }
  else if (OptionHeader->Magic == OPTMAGIC_PE32)
  {

#ifdef DUMPING_DATA
    PrintOptionHeader(OptionHeader);
    PrintWindowsHeader(WindowsHeader);
#endif

  }
  else
  {
    //add error message
    return 0;
  }

#ifdef DUMPING_DATA
  for (int DirCount = 0; DirCount < NumOfDirectories; DirCount++)
  {
    printf("Data Directory %02d: %s\n", DirCount + 1, DATA_DIR_NAME[DirCount]);
    printf("                    RVA:  %08X\n", Directory[DirCount].RVA);
    printf("                    Size: %08X\n\n", Directory[DirCount].Size);
  }
#endif

  return 1;

}
Exemple #8
0
int CoffLoader::LoadCoffHModule(FILE *fp)
{
  //test file signatures
  char Sig[4];
  rewind(fp);
  memset(Sig, 0, sizeof(Sig));
  if (!fread(Sig, 1, 2, fp) || strncmp(Sig, "MZ", 2) != 0)
    return 0;

  int Offset = 0;
  fseek(fp, 0x3c, SEEK_SET);
  if (!fread(&Offset, sizeof(int), 1, fp) || (Offset <= 0))
    return 0;

  fseek(fp, Offset, SEEK_SET);
  memset(Sig, 0, sizeof(Sig));
  if (!fread(Sig, 1, 4, fp) || strncmp(Sig, "PE\0\0", 4) != 0)
    return 0;

  Offset += 4;
  FileHeaderOffset = Offset;

  // Load and process Header
  if (fseek(fp, FileHeaderOffset + sizeof(COFF_FileHeader_t) + OPTHDR_SIZE, SEEK_SET)) //skip to winows headers
    return 0;

  WindowsHeader_t tempWindowsHeader;
  size_t readcount = fread(&tempWindowsHeader, 1, WINHDR_SIZE, fp);
  if (readcount != WINHDR_SIZE) //test file size error
    return 0;

  // alloc aligned memory
#ifdef _LINUX
  hModule = malloc(tempWindowsHeader.SizeOfImage);
#else
  hModule = VirtualAllocEx(0, (PVOID)tempWindowsHeader.ImageBase, tempWindowsHeader.SizeOfImage, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
  if (hModule == NULL)
    hModule = VirtualAlloc(0, tempWindowsHeader.SizeOfImage, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
#endif
  if (hModule == NULL)
    return 0;   //memory allocation fails

  rewind(fp);
  readcount = fread(hModule, 1, tempWindowsHeader.SizeOfHeaders, fp);
  if (readcount != tempWindowsHeader.SizeOfHeaders)   //file size error
    return 0;

  CoffFileHeader = (COFF_FileHeader_t *) ( (char*)hModule + FileHeaderOffset );
  NumOfSections = CoffFileHeader->NumberOfSections;

  OptionHeader = (OptionHeader_t *) ( (char*)CoffFileHeader + sizeof(COFF_FileHeader_t) );
  WindowsHeader = (WindowsHeader_t *) ( (char*)OptionHeader + OPTHDR_SIZE );
  EntryAddress = OptionHeader->Entry;
  NumOfDirectories = WindowsHeader->NumDirectories;

  Directory = (Image_Data_Directory_t *) ( (char*)WindowsHeader + WINHDR_SIZE);
  SectionHeader = (SectionHeader_t *) ( (char*)Directory + sizeof(Image_Data_Directory_t) * NumOfDirectories);

  if (CoffFileHeader->MachineType != IMAGE_FILE_MACHINE_I386)
    return 0;

#ifdef DUMPING_DATA
  PrintFileHeader(CoffFileHeader);
#endif

  if ( CoffFileHeader->SizeOfOptionHeader == 0 ) //not an image file, object file maybe
    return 0;

  // process Option Header
  if (OptionHeader->Magic == OPTMAGIC_PE32P)
  {
    printf("PE32+ not supported\n");
    return 0;
  }
  else if (OptionHeader->Magic == OPTMAGIC_PE32)
  {

#ifdef DUMPING_DATA
    PrintOptionHeader(OptionHeader);
    PrintWindowsHeader(WindowsHeader);
#endif

  }
  else
  {
    //add error message
    return 0;
  }

#ifdef DUMPING_DATA
  for (int DirCount = 0; DirCount < NumOfDirectories; DirCount++)
  {
    printf("Data Directory %02d: %s\n", DirCount + 1, DATA_DIR_NAME[DirCount]);
    printf("                    RVA:  %08X\n", Directory[DirCount].RVA);
    printf("                    Size: %08X\n\n", Directory[DirCount].Size);
  }
#endif

  return 1;

}
/*!
* Retrieves the web language output file stream.
* Opens a new stream if it has not been opened already.
*
* \param webType file language type
* \param outputFileNamePrePend name to prepend to the output file
* \param cmd current command line string
* \param csvOutput CSV file stream? (otherwise ASCII text file)
* \param legacyOutput legacy format file stream? (otherwise standard text file)
*
* \return output file stream
*/
ofstream* CWebCounter::GetOutputStream(WebType webType, const string &outputFileNamePrePend, const string &cmd, bool csvOutput, bool legacyOutput)
{
	if (webType == WEB_PHP)
	{
		if (csvOutput)
		{
			if (!php_output_file_csv.is_open())
			{
				string ofname = outputFileNamePrePend + "PHP";
				ofname += OUTPUT_FILE_NAME_CSV;
				php_output_file_csv.open(ofname.c_str(), ofstream::out);

				if (!php_output_file_csv.is_open()) return NULL;
				PrintFileHeader(php_output_file_csv, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(php_output_file_csv, "RESULTS FOR PHP FILES");
				php_output_file_csv << endl << ",,,,HTML,,JS-Clnt,,VBS-Clnt,,PHP,,," << endl;
				php_output_file_csv << "Total,Blank,Comments,,Word,Exec.,Data,Exec.,Data,Exec.,Comp.,Data,Exec.,Logical SLOC,,,,,Physical,File,Module" << endl;
				php_output_file_csv << "Lines,Lines,Whole,Embed,LOC,Instr,Decl,Instr,Decl,Instr,Direct.,Decl,Instr,HTML,JS-Clnt,VBS-Clnt,PHP,Total,SLOC,Type,Name" << endl;
			}
			return &php_output_file_csv;
		}
		else
		{
			if (!php_output_file.is_open())
			{
				string ofname = outputFileNamePrePend + "PHP";
				ofname += OUTPUT_FILE_NAME;
				php_output_file.open(ofname.c_str(), ofstream::out);

				if (!php_output_file.is_open()) return NULL;
				PrintFileHeader(php_output_file, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(php_output_file, "RESULTS FOR PHP FILES");
				php_output_file << endl << "                                    |       HTML      |     JS-Clnt     |    VBS-Clnt     |           PHP           |" << endl;
				if (legacyOutput)
				{
					php_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  | Compiler  Data   Exec.  |                Logical SLOC                | File  Module" << endl;
					php_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. | Direct.   Decl.  Instr. |   Total      HTML JS-Clnt VBS-Clnt     PHP | Type  Name" << endl;
					php_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-------------------------+---------+----------------------------------+---------------------------" << endl;
				}
				else
				{
					php_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  | Compiler  Data   Exec.  |                Logical SLOC                | Physical | File  Module" << endl;
					php_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. | Direct.   Decl.  Instr. |    HTML JS-Clnt VBS-Clnt     PHP     Total |   SLOC   | Type  Name" << endl;
					php_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-------------------------+----------------------------------+---------+----------+---------------------------" << endl;
				}
			}
			return &php_output_file;
		}
	}
	else if (webType == WEB_JSP)
	{
		if (csvOutput)
		{
			if (!jsp_output_file_csv.is_open())
			{
				string ofname = outputFileNamePrePend + "JSP";
				ofname += OUTPUT_FILE_NAME_CSV;
				jsp_output_file_csv.open(ofname.c_str(), ofstream::out);

				if (!jsp_output_file_csv.is_open()) return NULL;

				PrintFileHeader(jsp_output_file_csv, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(jsp_output_file_csv, "RESULTS FOR JSP FILES");
				jsp_output_file_csv << endl << ",,,,HTML,,JS-Clnt,,VBS-Clnt,,Java" << endl;
				jsp_output_file_csv << "Total,Blank,Comments,,Word,Exec.,Data,Exec.,Data,Exec.,Comp.,Data,Exec.,Logical SLOC,,,,,Physical,File,Module" << endl;
				jsp_output_file_csv << "Lines,Lines,Whole,Embed,LOC,Instr,Decl,Instr,Decl,Instr,Direct.,Decl,Instr,HTML,JS-Clnt,VBS-Clnt,Java,Total,SLOC,Type,Name" << endl;
			}
			return &jsp_output_file_csv;
		}
		else
		{
			if (!jsp_output_file.is_open())
			{
				string ofname = outputFileNamePrePend + "JSP";
				ofname += OUTPUT_FILE_NAME;
				jsp_output_file.open(ofname.c_str(), ofstream::out);

				if (!jsp_output_file.is_open()) return NULL;

				PrintFileHeader(jsp_output_file, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(jsp_output_file, "RESULTS FOR JSP FILES");
				jsp_output_file << endl << "                                    |       HTML      |     JS-Clnt     |    VBS-Clnt     |          Java           |" << endl;
				if (legacyOutput)
				{
					jsp_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  | Compiler  Data   Exec.  |                Logical SLOC                | File  Module" << endl;
					jsp_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. | Direct.   Decl.  Instr. |   Total      HTML JS-Clnt VBS-Clnt    Java | Type  Name" << endl;
					jsp_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-------------------------+---------+----------------------------------+---------------------------" << endl;
				}
				else
				{
					jsp_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  | Compiler  Data   Exec.  |                Logical SLOC                | Physical | File  Module" << endl;
					jsp_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. | Direct.   Decl.  Instr. |    HTML JS-Clnt VBS-Clnt    Java     Total |   SLOC   | Type  Name" << endl;
					jsp_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-------------------------+----------------------------------+---------+----------+---------------------------" << endl;
				}
			}
			return &jsp_output_file;
		}
	}
	else if (webType == WEB_ASP)
	{
		if (csvOutput)
		{
			if (!asp_output_file_csv.is_open())
			{
				string ofname = outputFileNamePrePend + "ASP";
				ofname += OUTPUT_FILE_NAME_CSV;
				asp_output_file_csv.open(ofname.c_str(), ofstream::out);

				if (!asp_output_file_csv.is_open()) return NULL;

				PrintFileHeader(asp_output_file_csv, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(asp_output_file_csv, "RESULTS FOR ASP FILES");
				asp_output_file_csv << endl << ",,,,HTML,,JS-Clnt,,VBS-Clnt,,JS-Svr,,VBS-Svr,,C#-Svr" << endl;
				asp_output_file_csv << "Total,Blank,Comments,,Word,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Logical SLOC,,,,,,,Physical,File,Module" << endl;
				asp_output_file_csv << "Lines,Lines,Whole,Embed,LOC,Instr,Decl,Instr,Decl,Instr,Decl,Instr,Decl,Instr,Decl,Instr,HTML,JS-Clnt,VBS-Clnt,JS-Svr,VBS-Svr,C#-Svr,Total,SLOC,Type,Name" << endl;
			}
			return &asp_output_file_csv;
		}
		else
		{
			if (!asp_output_file.is_open())
			{
				string ofname = outputFileNamePrePend + "ASP";
				ofname += OUTPUT_FILE_NAME;
				asp_output_file.open(ofname.c_str(), ofstream::out);

				if (!asp_output_file.is_open()) return NULL;

				PrintFileHeader(asp_output_file, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(asp_output_file, "RESULTS FOR ASP FILES");
				asp_output_file << endl << "                                    |       HTML      |     JS-Clnt     |    VBS-Clnt     |      JS-Svr     |     VBS-Svr     |      C#-Svr     |" << endl;
				if (legacyOutput)
				{
					asp_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                        Logical SLOC                        | File  Module" << endl;
					asp_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Total      HTML JS-Clnt VBS-Clnt  JS-Svr VBS-Svr  C#-Svr | Type  Name" << endl;
					asp_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+---------+--------------------------------------------------+---------------------------" << endl;
				}
				else
				{
					asp_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                        Logical SLOC                        | Physical | File  Module" << endl;
					asp_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |    HTML JS-Clnt VBS-Clnt  JS-Svr VBS-Svr  C#-Svr     Total |   SLOC   | Type  Name" << endl;
					asp_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+--------------------------------------------------+---------+----------+---------------------------" << endl;
				}
			}
			return &asp_output_file;
		}
	}
	else if (webType == WEB_CFM)
	{
		if (csvOutput)
		{
			if (!cfm_output_file_csv.is_open())
			{
				string ofname = outputFileNamePrePend + "ColdFusion";
				ofname += OUTPUT_FILE_NAME_CSV;
				cfm_output_file_csv.open(ofname.c_str(), ofstream::out);

				if (!cfm_output_file_csv.is_open()) return NULL;

				PrintFileHeader(cfm_output_file_csv, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(cfm_output_file_csv, "RESULTS FOR ColdFusion FILES");
				cfm_output_file_csv << endl << ",,,,HTML,,JS-Clnt,,VBS-Clnt,,SQL,,ColdFusion,,CFScript" << endl;
				cfm_output_file_csv << "Total,Blank,Comments,,Word,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Logical SLOC,,,,,,,Physical,File,Module" << endl;
				cfm_output_file_csv << "Lines,Lines,Whole,Embed,LOC,Instr,Decl,Instr,Decl,Instr,Decl,Instr,Decl,Instr,Decl,Instr,HTML,JS-Clnt,VBS-Clnt,SQL,ColdFusion,CFScript,Total,SLOC,Type,Name" << endl;
			}
			return &cfm_output_file_csv;
		}
		else
		{
			if (!cfm_output_file.is_open())
			{
				string ofname = outputFileNamePrePend + "ColdFusion";
				ofname += OUTPUT_FILE_NAME;
				cfm_output_file.open(ofname.c_str(), ofstream::out);

				if (!cfm_output_file.is_open()) return NULL;

				PrintFileHeader(cfm_output_file, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(cfm_output_file, "RESULTS FOR ColdFusion FILES");
				cfm_output_file << endl << "                                    |       HTML      |     JS-Clnt     |    VBS-Clnt     |       SQL       |    ColdFusion   |     CFScript    |" << endl;
				if (legacyOutput)
				{
					cfm_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                          Logical SLOC                          | File  Module" << endl;
					cfm_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Total      HTML JS-Clnt VBS-Clnt     SQL ColdFusion CFScript | Type  Name" << endl;
					cfm_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+---------+------------------------------------------------------+---------------------------" << endl;
				}
				else
				{
					cfm_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                          Logical SLOC                          | Physical | File  Module" << endl;
					cfm_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |    HTML JS-Clnt VBS-Clnt     SQL ColdFusion CFScript     Total |   SLOC   | Type  Name" << endl;
					cfm_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+-----------------+-----------------+------------------------------------------------------+---------+----------+---------------------------" << endl;
				}
			}
			return &cfm_output_file;
		}
	}
	else if (webType == WEB_XML)
	{
		if (csvOutput)
		{
			if (!xml_output_file_csv.is_open())
			{
				string ofname = outputFileNamePrePend + "XML";
				ofname += OUTPUT_FILE_NAME_CSV;
				xml_output_file_csv.open(ofname.c_str(), ofstream::out);

				if (!xml_output_file_csv.is_open()) return NULL;

				PrintFileHeader(xml_output_file_csv, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(xml_output_file_csv, "RESULTS FOR XML FILES");
				xml_output_file_csv << endl << ",,,,XML,,JS-Clnt,,VBS-Clnt,,C#-Clnt" << endl;
				xml_output_file_csv << "Total,Blank,Comments,,Word,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Logical SLOC,,,,,Physical,File,Module" << endl;
				xml_output_file_csv << "Lines,Lines,Whole,Embed,LOC,Instr,Decl,Instr,Decl,Instr,Decl,Instr,XML,JS-Clnt,VBS-Clnt,C#-Clnt,Total,SLOC,Type,Name" << endl;
			}
			return &xml_output_file_csv;
		}
		else
		{
			if (!xml_output_file.is_open())
			{
				string ofname = outputFileNamePrePend + "XML";
				ofname += OUTPUT_FILE_NAME;
				xml_output_file.open(ofname.c_str(), ofstream::out);

				if (!xml_output_file.is_open()) return NULL;

				PrintFileHeader(xml_output_file, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(xml_output_file, "RESULTS FOR XML FILES");
				xml_output_file << endl << "                                    |       XML       |     JS-Clnt     |    VBS-Clnt     |     C#-Clnt     |" << endl;
				if (legacyOutput)
				{
					xml_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                Logical SLOC                | File  Module" << endl;
					xml_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Total       XML JS-Clnt VBS-Clnt C#-Clnt | Type  Name" << endl;
					xml_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+---------+----------------------------------+---------------------------" << endl;
				}
				else
				{
					xml_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                Logical SLOC                | Physical | File  Module" << endl;
					xml_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |     XML JS-Clnt VBS-Clnt C#-Clnt     Total |   SLOC   | Type  Name" << endl;
					xml_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+----------------------------------+---------+----------+---------------------------" << endl;
				}
			}
			return &xml_output_file;
		}
	}
	else // html
	{
		if (csvOutput)
		{
			if (!html_output_file_csv.is_open())
			{
				string ofname = outputFileNamePrePend + "HTML";
				ofname += OUTPUT_FILE_NAME_CSV;
				html_output_file_csv.open(ofname.c_str(), ofstream::out);

				if (!html_output_file_csv.is_open()) return NULL;

				PrintFileHeader(html_output_file_csv, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(html_output_file_csv, "RESULTS FOR HTML FILES");
				html_output_file_csv << endl << ",,,,HTML,,JS-Clnt,,VBS-Clnt,,C#-Clnt" << endl;
				html_output_file_csv << "Total,Blank,Comments,,Word,Exec.,Data,Exec.,Data,Exec.,Data,Exec.,Logical SLOC,,,,,Physical,File,Module" << endl;
				html_output_file_csv << "Lines,Lines,Whole,Embed,LOC,Instr,Decl,Instr,Decl,Instr,Decl,Instr,HTML,JS-Clnt,VBS-Clnt,C#-Clnt,Total,SLOC,Type,Name" << endl;
			}
			return &html_output_file_csv;
		}
		else
		{
			if (!html_output_file.is_open())
			{
				string ofname = outputFileNamePrePend + "HTML";
				ofname += OUTPUT_FILE_NAME;
				html_output_file.open(ofname.c_str(), ofstream::out);

				if (!html_output_file.is_open()) return NULL;

				PrintFileHeader(html_output_file, "SLOC COUNT RESULTS", cmd);

				PrintFileHeaderLine(html_output_file, "RESULTS FOR HTML FILES");
				html_output_file << endl << "                                    |       HTML      |     JS-Clnt     |    VBS-Clnt     |     C#-Clnt     |" << endl;
				if (legacyOutput)
				{
					html_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                Logical SLOC                | File  Module" << endl;
					html_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Total      HTML JS-Clnt VBS-Clnt C#-Clnt | Type  Name" << endl;
					html_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+---------+----------------------------------+---------------------------" << endl;
				}
				else
				{
					html_output_file << "   Total   Blank |      Comments    |    Word  Exec.  |   Data   Exec.  |   Data   Exec.  |   Data   Exec.  |                Logical SLOC                | Physical | File  Module" << endl;
					html_output_file << "   Lines   Lines |   Whole Embedded |     LOC  Instr. |   Decl.  Instr. |   Decl.  Instr. |   Decl.  Instr. |    HTML JS-Clnt VBS-Clnt C#-Clnt     Total |   SLOC   | Type  Name" << endl;
					html_output_file << "-----------------+------------------+-----------------+-----------------+-----------------+-----------------+----------------------------------+---------+----------+---------------------------" << endl;
				}
			}
			return &html_output_file;
		}
	}
}
Exemple #10
0
// Print the estimated path loss to a text file. Either print a point, route (line) or grid of estimates
void PrintPathLossToFile(void)
{	
	FILE *PathLossFile;
	char *FilenameBuffer;

	FilenameBuffer = (char*)malloc(100*sizeof(char));

	sprintf_s(FilenameBuffer, 100*sizeof(char), "%s/%s_%s", FolderName, ProjectName, PathLossFilename);

	if (fopen_s(&PathLossFile, FilenameBuffer, "w") != 0) {
		printf("Could not open file '%s'\n", PathLossFilename);
	}
	else {

		printf("Printing path loss values to '%s'\n",PathLossFilename);
		PrintFileHeader(PathLossFile);

		int x, y, z;
		double PathLoss;
		

		// Z coordinate is constant
		z = PlaceWithinGridZ(RoundToNearest(PathLossParameters.Z1/GridSpacing));
		
		switch (PathLossParameters.Type) {
			// Print the path loss at a single point
			case POINT: {
				// Details of the path loss estimates required and column titles
				fprintf(PathLossFile, "Point Analysis\nHeight = %f\n\nX\t\tY\t\tPL(dB)\n", z*GridSpacing);
				x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X1/GridSpacing));
				y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y1/GridSpacing));
				PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
				fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				break;
			}
			// Print the path loss along a route
			case ROUTE: {
				double length = sqrt(SQUARE(PathLossParameters.X2 - PathLossParameters.X1)+SQUARE(PathLossParameters.Y2 - PathLossParameters.Y1));
				double nSamples = length/PathLossParameters.Spacing;
				double dx = (PathLossParameters.X2 - PathLossParameters.X1)/nSamples;
				double dy = (PathLossParameters.Y2 - PathLossParameters.Y1)/nSamples;

				// Details of the path loss estimates required and column titles
				fprintf(PathLossFile, "Route Analysis - %d samples\nHeight = %f\n\nX\t\tY\t\tPL(dB)\n", (int)nSamples == nSamples ? (int)nSamples+1 : (int)nSamples+2, z*GridSpacing);

				for (int i = 0; i < nSamples; i++) {
					x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
					y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*i)/GridSpacing));
					PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
					fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				}
				x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
				y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
				PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
				fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				break;
			}

			// Print the path loss in a 2d grid
			case GRID: {
				double nSamplesX = (PathLossParameters.X2-PathLossParameters.X1)/PathLossParameters.Spacing;
				double nSamplesY = (PathLossParameters.Y2-PathLossParameters.Y1)/PathLossParameters.SpacingY;
				double dx = (PathLossParameters.X2 - PathLossParameters.X1)/nSamplesX;
				double dy = (PathLossParameters.Y2 - PathLossParameters.Y1)/nSamplesY;

				// Details of the path loss estimates required and column titles
				fprintf(PathLossFile, "Grid Analysis - %d x %d samples\nHeight = %f\n\nX\t\tY\t\tPL(dB)\n", (int)nSamplesX == nSamplesX ? (int)nSamplesX+1 : (int)nSamplesX+2, (int)nSamplesY == nSamplesY ? (int)nSamplesY+1 : (int)nSamplesY+2, z*GridSpacing);
				
				for (int j=0; j < nSamplesY; j++) {
					for (int i=0; i < nSamplesX; i++) {
						x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
						y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*j)/GridSpacing));
						PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
						fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
					}
					x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
					y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*j)/GridSpacing));
					PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
					fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				}
				// Print a path loss estimate of the outer X row nearest X2,Y2 on the grid (may not be a whole sample space apart)
				for (int i=0; i < nSamplesX; i++) {
					x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
					y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
					PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
					fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				}
				x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
				y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
				PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
				fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				break;
			}

			// Print the path loss in a set of 2d grids
			case CUBE: {
				double nSamplesX = (PathLossParameters.X2-PathLossParameters.X1)/PathLossParameters.Spacing;
				double nSamplesY = (PathLossParameters.Y2-PathLossParameters.Y1)/PathLossParameters.SpacingY;
				double nSamplesZ = (PathLossParameters.Z2-PathLossParameters.Z1)/PathLossParameters.SpacingZ;
				double dx = (PathLossParameters.X2 - PathLossParameters.X1)/nSamplesX;
				double dy = (PathLossParameters.Y2 - PathLossParameters.Y1)/nSamplesY;
				double dz = (PathLossParameters.Z2 - PathLossParameters.Z1)/nSamplesZ;

				// Details of the path loss estimates required and column titles
				fprintf(PathLossFile, "Grid Analysis - %d x %d x %d samples\n", (int)nSamplesX == nSamplesX ? (int)nSamplesX+1 : (int)nSamplesX+2, (int)nSamplesY == nSamplesY ? (int)nSamplesY+1 : (int)nSamplesY+2, (int)nSamplesZ == nSamplesZ ? (int)nSamplesZ+1 : (int)nSamplesZ+2);
				
				for (int k=0; k < nSamplesZ; k++) {
					z = PlaceWithinGridZ(RoundToNearest((PathLossParameters.Z1+dz*k)/GridSpacing));
					fprintf(PathLossFile, "\nHeight = %f\n\nX\t\tY\t\tPL(dB)\n", z*GridSpacing);
				
					for (int j=0; j < nSamplesY; j++) {
						for (int i=0; i < nSamplesX; i++) {
							x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
							y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*j)/GridSpacing));
							PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
							fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
						}
						x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
						y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*j)/GridSpacing));
						PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
						fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
					}
					// Print a path loss estimate of the outer X row nearest X2,Y2 on the grid (may not be a whole sample space apart)
					for (int i=0; i < nSamplesX; i++) {
						x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
						y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
						PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
						fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
					}
					x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
					y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
					PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
					fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				}

				z = PlaceWithinGridZ(RoundToNearest((PathLossParameters.Z2)/GridSpacing));
				fprintf(PathLossFile, "\nHeight = %f\n\nX\t\tY\t\tPL(dB)\n", z*GridSpacing);
				
				for (int j=0; j < nSamplesY; j++) {
					for (int i=0; i < nSamplesX; i++) {
						x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
						y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*j)/GridSpacing));
						PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
						fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
					}
					x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
					y = PlaceWithinGridY(RoundToNearest((PathLossParameters.Y1+dy*j)/GridSpacing));
					PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
					fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				}
				// Print a path loss estimate of the outer X row nearest X2,Y2 on the grid (may not be a whole sample space apart)
				for (int i=0; i < nSamplesX; i++) {
					x = PlaceWithinGridX(RoundToNearest((PathLossParameters.X1+dx*i)/GridSpacing));
					y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
					PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
					fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				}
				x = PlaceWithinGridX(RoundToNearest(PathLossParameters.X2/GridSpacing));
				y = PlaceWithinGridY(RoundToNearest(PathLossParameters.Y2/GridSpacing));
				PathLoss = VoltageToDB(SPEED_OF_LIGHT/Frequency * Grid[x][y][z].Vmax * KAPPA/4/M_PI/GridSpacing);
				fprintf(PathLossFile, "%f\t%f\t%f\n", x*GridSpacing, y*GridSpacing, PathLoss);
				break;
			}
		}

		if (fclose(PathLossFile)) {
			printf("Path loss file close unsuccessful\n");
		}
	}
	free(FilenameBuffer);	
}