summaryrefslogtreecommitdiff
path: root/utils/tfstats/html.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/tfstats/html.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/tfstats/html.cpp')
-rw-r--r--utils/tfstats/html.cpp131
1 files changed, 131 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string>
+#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 <body> 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("<HEAD>\n");
+ write("<TITLE> %s </TITLE>\n",title);
+ string csshttppath(g_pApp->supportHTTPPath);
+ csshttppath+="/style.css";
+
+ write("<link rel=\"stylesheet\" href=\"%s\" type=\"text/css\">\n",csshttppath.c_str());
+ write("</HEAD>\n");
+
+ fBody=fPrintBody;
+ if (fBody)
+ {
+ write("<BODY leftmargin=%li topmargin=%li ",leftmarg,topmarg);
+ if (bgimage)
+ write("background=%s",bgimage);
+ else
+ write("bgcolor = black");
+ write(">\n");
+ }
+
+}
+
+
+
+//------------------------------------------------------------------------------------------------------
+// Function: CHTMLFile::open
+// Purpose: opens the html file, and writes <html>
+// 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("<HTML>\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 <body> and <html> tags if needed
+//------------------------------------------------------------------------------------------------------
+void CHTMLFile::close()
+{
+ if (!out)
+ return;
+ if (fBody)
+ write("</BODY>\n");
+
+ write("</HTML>\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("<hr %s width=%li>\n",alignleft?"align=left":"",len);
+} \ No newline at end of file