Created
October 5, 2014 00:02
-
-
Save elieux/08f95e56f75b78371a73 to your computer and use it in GitHub Desktop.
aria2-segfault
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef D_OUTPUT_FILE_H | |
#define D_OUTPUT_FILE_H | |
#include "common.h" | |
#include <cstdlib> | |
#include <cstdarg> | |
namespace aria2 { | |
class OutputFile { | |
public: | |
virtual ~OutputFile() {} | |
virtual size_t write(const char* str) = 0; | |
virtual int flush() = 0; | |
virtual int vprintf(const char* format, va_list va) = 0; | |
inline int printf(const char *format, ...) { | |
va_list va; | |
va_start(va, format); | |
int rv = vprintf(format, va); | |
va_end(va); | |
return rv; | |
} | |
// Returns true if the output medium supports ANSI color codes. | |
virtual bool supportsColor() = 0; | |
}; | |
} // namespace aria2 | |
#endif // D_OUTPUT_FILE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef D_WIN_CONSOLE_FILE_H | |
#define D_WIN_CONSOLE_FILE_H | |
#include "OutputFile.h" | |
#include <string> | |
namespace aria2 { | |
// This is a wrapper class for WriteConsoleW | |
class WinConsoleFile: public OutputFile | |
{ | |
public: | |
WinConsoleFile(DWORD stdHandle); | |
virtual ~WinConsoleFile() {} | |
virtual size_t write(const char* str) CXX11_OVERRIDE; | |
virtual int vprintf(const char* format, va_list va) CXX11_OVERRIDE; // <-- error here | |
virtual bool supportsColor() CXX11_OVERRIDE; | |
virtual int flush() CXX11_OVERRIDE | |
{ | |
return 0; | |
} | |
private: | |
DWORD stdHandle_; | |
bool bold_; | |
bool underline_; | |
bool reverse_; | |
WORD fg_, deffg_; | |
WORD bg_, defbg_; | |
size_t writeColorful(const std::wstring& str); | |
inline HANDLE handle() const | |
{ | |
return ::GetStdHandle(stdHandle_); | |
} | |
private: | |
// Don't allow copying | |
WinConsoleFile(const WinConsoleFile&) = delete; | |
WinConsoleFile& operator=(const WinConsoleFile&) = delete; | |
}; | |
} // namespace aria2 | |
#endif // D_WIN_CONSOLE_FILE_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment