Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
#include "Logfile.hpp" // Konstruktor // CLogfile::CLogfile () { } // Konstruktor // Destruktor // // Aufgabe: Gibt Ende-Meldung aus und schließt die Logfile // CLogfile::~CLogfile () { // Logfile-Ende schreiben und Datei schließen Textout ("<br><br>End of logfile</font></body></html>"); fclose (m_Logfile); } // Destruktor // CreateLogfile // // Aufgabe: Logfile erstellen und Kopf schreiben // void CLogfile::CreateLogfile(const char *LogName) { // Logfile leeren und Kopf schreiben m_Logfile = fopen (LogName, "w"); Textout ("<html><head><title>Logfile</title></head>"); Textout ("<body><font face='courier new'>"); WriteTopic ("Logfile", 3); // Aktuelle Build-Konfiguration ausgeben #ifdef _DEBUG Textout ("BUILD: DEBUG<br>"); #else Textout ("BUILD: RELEASE<br>"); #endif // Link für E-Mail-Adresse schreiben Textout ("<a href='mailto:black_creeper@web.de?subject=Logfile'>"); Textout ("Send E-Mail to me</a><br><br>"); // Logfile schließen und mit append wieder öffnen fclose (m_Logfile); m_Logfile = fopen (LogName, "a"); } // CreateLogfile // WriteTopic // // Aufgabe: Überschrift erzeugen // void CLogfile::WriteTopic(const char *Topic, int Size) { // Überschrift schreiben und flushen Textout ("<table cellspacing='0' cellpadding='0' width='100%%' "); Textout ("bgcolor='#DFDFE5'>\n<tr>\n<td>\n<font face='arial' "); fTextout ("size ='+&i'>\n", Size); Textout (Topic); Textout ("</font>\n</td>\n</tr>\n</table>\n<br>"); fflush (m_Logfile); } // WriteTopic // Textout // // Aufgabe: Text in Logfile schreiben (schwarz) // void CLogfile::Textout(const char *Text) { // Text schreiben und flushen fprintf (m_Logfile, Text); fflush (m_Logfile); } // Textout (schwarz) // Textout // // Aufgabe: Text in Logfile schreiben (farbig) // void CLogfile::Textout(int Color, const char *Text) { Textout (Color, false, Text); } // Textout (farbig) // Textout // // Aufgabe: Text in Logfile schreiben (farbig, Liste) // void CLogfile::Textout(int Color, bool List, const char *Text) { // Listen-Tag schreiben if (List == true) Textout ("<li>"); // Farbtag schreiben switch (Color) { case BLACK: Textout ("<font color=black>"); break; case RED: Textout ("<font color=red>"); break; case GREEN: Textout ("<font color=green>"); break; case BLUE: Textout ("<font color=blue>"); break; case PURPLE: Textout ("<font color=purple>"); break; }; // Text schreiben Textout (Text); Textout ("</font>"); if ( List == false) Textout ("<br>"); else Textout ("</li>"); } // Textout (farbig, Liste) // fTextout // // Aufgabe: formatierten Text in Logfile schreiben (schwarz) // void CLogfile::fTextout(const char *Text, ...) { TCHAR buffer[MAX_BUFFER]; // char-Buffer va_list pArgList; // Liste der übergebenen Argumente // String aus den Argumenten erstellen va_start (pArgList, Text); vsprintf (buffer, Text, pArgList); va_end (pArgList); // Erzeugten String schreiben Textout (buffer); } // fTextout (schwarz) // fTextout // // Aufgbe: formatierten Text in Logfile schreiben (farbig) // void CLogfile::fTextout(int Color, const char *Text, ...) { TCHAR buffer[MAX_BUFFER]; // char-Buffer va_list pArgList; // Liste der übergebenen Argumente // String aus den Argumenten erstellen va_start (pArgList, Text); vsprintf (buffer, Text, pArgList); va_end (pArgList); // Erzeugten String schreiben Textout (Color, buffer); } // fTextout (farbig) // fTextout // // Aufgabe: formatierten Text in Logfile schreiben (farbig, Liste) // void CLogfile::fTextout(int Color, bool List, const char *Text, ...) { TCHAR buffer[MAX_BUFFER]; // char-Buffer va_list pArgList; // Liste der übergebenen Argumente // String aus den Argumenten erstellen va_start (pArgList, Text); vsprintf (buffer, Text, pArgList); va_end (pArgList); // Erzeugten String schreiben Textout (Color, List, buffer); } // fTextout (farbig, Liste) // FunctionResult // // Aufgabe: OK oder ERROR für Funktionsaufruf ausgeben // void CLogfile::FunctionResult(const char *Name, bool Result) { if (L_OK == Result) { Textout ("<table width='100%%' cellSpacing='1' cellPadding='5'"); Textout (" border='0' bgcolor='#C0C0C0'><tr><td bgcolor="); fTextout ("'#FFFFFF' width='35%%'>%s</TD>", Name); Textout ("<td bgcolor='#FFFFFF' width='30%%'><font color="); Textout ("'green'>OK</FONT></TD><td bgcolor='#FFFFFF' "); Textout ("width='35%%'>-/-</TD></tr></table>"); } else { Textout ("<table width='100%%' cellSpacing='1' cellPadding='5'"); Textout (" border='0' bgcolor='#C0C0C0'><tr><td bgcolor="); fTextout ("'#FFFFFF' width='35%%'>%s</TD>", Name); Textout ("<td bgcolor='#FFFFFF' width='30%%'><font color="); Textout ("'red'>ERROR</FONT></TD><td bgcolor='#FFFFFF' "); Textout ("width='35%%'>-/-</TD></tr></table>"); } } // FunctionResult |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
1>------ Erstellen gestartet: Projekt: Listing8_15B, Konfiguration: Debug Win32 ------ 1>Kompilieren... 1>Logfile.cpp 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(28) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> g:\c++ programming\microsoft visual studio 9.0\vc\include\stdio.h(237): Siehe Deklaration von 'fopen' 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(46) : warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> g:\c++ programming\microsoft visual studio 9.0\vc\include\stdio.h(237): Siehe Deklaration von 'fopen' 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(134) : error C2664: 'vsprintf': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(138) : error C2664: 'void CLogfile::Textout(const char *)': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'const char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(153) : error C2664: 'vsprintf': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(157) : error C2664: 'void CLogfile::Textout(int,const char *)': Konvertierung des Parameters 2 von 'TCHAR [1024]' in 'const char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(173) : error C2664: 'vsprintf': Konvertierung des Parameters 1 von 'TCHAR [1024]' in 'char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>g:\c++ programming\projekte\listing8_15b\listing8_15b\logfile.cpp(177) : error C2664: 'void CLogfile::Textout(int,bool,const char *)': Konvertierung des Parameters 3 von 'TCHAR [1024]' in 'const char *' nicht möglich 1> Die Typen, auf die verwiesen wird, sind nicht verknüpft; die Konvertierung erfordert einen reinterpret_cast-Operator oder eine Typumwandlung im C- oder Funktionsformat. 1>Das Buildprotokoll wurde unter "file://g:\C++ Programming\Projekte\Listing8_15B\Listing8_15B\Debug\BuildLog.htm" gespeichert. 1>Listing8_15B - 6 Fehler, 2 Warnung(en) ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ========== |
Werbeanzeige