From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- utils/tfstats/html.cpp | 131 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 utils/tfstats/html.cpp (limited to 'utils/tfstats/html.cpp') diff --git a/utils/tfstats/html.cpp b/utils/tfstats/html.cpp new file mode 100644 index 0000000..ca533c9 --- /dev/null +++ b/utils/tfstats/html.cpp @@ -0,0 +1,131 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Implementation of CHTMLFile. see HTML.h for details +// +// $Workfile: $ +// $Date: $ +// +//------------------------------------------------------------------------------------------------------ +// $Log: $ +// +// $NoKeywords: $ +//=============================================================================// +#pragma warning (disable:4786) +#include +#include +#include +#include +#include "TFStatsApplication.h" +#include "util.h" +#include "html.h" + +//readability aids used when calling constructor +const bool CHTMLFile::printBody=true; +const bool CHTMLFile::dontPrintBody=false; +const bool CHTMLFile::linkStyle=true; +const bool CHTMLFile::dontLinkStyle=false; + +using namespace std; +//------------------------------------------------------------------------------------------------------ +// Function: CHTMLFile::CHTMLFile +// Purpose: +// Input: filename - name of the html file that will be written +// title - title of the html document +// fPrintBody - true if the tag is to be written. +// bgimage - name of a background image, if desired +// leftmarg - pixels on the left margin (if desired) +// topmarg - pixels on the top margin (if desired) +//------------------------------------------------------------------------------------------------------ +CHTMLFile::CHTMLFile(const char* filenm,const char* title,bool fPrintBody,const char* bgimage,int leftmarg, int topmarg) +{ + strcpy(filename,filenm); + open(filename); + + + write("\n"); + write(" %s \n",title); + string csshttppath(g_pApp->supportHTTPPath); + csshttppath+="/style.css"; + + write("\n",csshttppath.c_str()); + write("\n"); + + fBody=fPrintBody; + if (fBody) + { + write("\n"); + } + +} + + + +//------------------------------------------------------------------------------------------------------ +// Function: CHTMLFile::open +// Purpose: opens the html file, and writes +// Input: filename - the name of the file to open +//------------------------------------------------------------------------------------------------------ +void CHTMLFile::open(const char* filename) +{ + out=fopen(filename,"wt"); + if (!out) + g_pApp->fatalError("Can't open output file \"%s\"!\nPlease make sure that the file does not exist OR\nif the file does exit, make sure it is not read-only",filename); + + write("\n"); +} + +//------------------------------------------------------------------------------------------------------ +// Function: CHTMLFile::write +// Purpose: writes a string to the html file +// Input: fmt - format string, like printf suite of functions +// ... - list of arguments +//------------------------------------------------------------------------------------------------------ +void CHTMLFile::write(const char* fmt,...) +{ + va_list va; + va_start(va,fmt); + vfprintf(out,fmt,va); +} + + + +//------------------------------------------------------------------------------------------------------ +// Function: CHTMLFile::close +// Purpose: closes the html file, closing and tags if needed +//------------------------------------------------------------------------------------------------------ +void CHTMLFile::close() +{ + if (!out) + return; + if (fBody) + write("\n"); + + write("\n\n"); +#ifndef WIN32 + chmod(filename,PERMIT); +#endif + fclose(out); + out=NULL; +} + +//------------------------------------------------------------------------------------------------------ +// Function: CHTMLFile::~CHTMLFile +// Purpose: Destructor. closes the file +//------------------------------------------------------------------------------------------------------ +CHTMLFile::~CHTMLFile() +{ + close(); +} + + + + +void CHTMLFile::hr(int len,bool alignleft) +{ + write("
\n",alignleft?"align=left":"",len); +} \ No newline at end of file -- cgit v1.2.3