aboutsummaryrefslogtreecommitdiffstats
path: root/unix/xserver/hw/vnc/RFBGlue.cc
diff options
context:
space:
mode:
Diffstat (limited to 'unix/xserver/hw/vnc/RFBGlue.cc')
-rw-r--r--unix/xserver/hw/vnc/RFBGlue.cc118
1 files changed, 52 insertions, 66 deletions
diff --git a/unix/xserver/hw/vnc/RFBGlue.cc b/unix/xserver/hw/vnc/RFBGlue.cc
index 2295bee8..f217906a 100644
--- a/unix/xserver/hw/vnc/RFBGlue.cc
+++ b/unix/xserver/hw/vnc/RFBGlue.cc
@@ -22,35 +22,36 @@
#endif
#include <stdlib.h>
+#include <string.h>
+
+#include <core/Configuration.h>
+#include <core/Logger_stdio.h>
+#include <core/Logger_syslog.h>
+#include <core/LogWriter.h>
+#include <core/string.h>
#include <network/TcpSocket.h>
-#include <rfb/Configuration.h>
-#include <rfb/LogWriter.h>
-#include <rfb/Logger_stdio.h>
-#include <rfb/Logger_syslog.h>
-#include <rfb/util.h>
-#include "RFBGlue.h"
+#include <rfb/UnixPasswordValidator.h>
-using namespace rfb;
+#include "RFBGlue.h"
// Loggers used by C code must be created here
-static LogWriter inputLog("Input");
-static LogWriter selectionLog("Selection");
+static core::LogWriter inputLog("Input");
+static core::LogWriter selectionLog("Selection");
void vncInitRFB(void)
{
- rfb::initStdIOLoggers();
- rfb::initSyslogLogger();
- rfb::LogWriter::setLogParams("*:stderr:30");
- rfb::Configuration::enableServerParams();
+ core::initStdIOLoggers();
+ core::initSyslogLogger();
+ core::LogWriter::setLogParams("*:stderr:30");
}
void vncLogError(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -60,9 +61,9 @@ void vncLogError(const char *name, const char *format, ...)
void vncLogStatus(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -72,9 +73,9 @@ void vncLogStatus(const char *name, const char *format, ...)
void vncLogInfo(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -84,9 +85,9 @@ void vncLogInfo(const char *name, const char *format, ...)
void vncLogDebug(const char *name, const char *format, ...)
{
- LogWriter *vlog;
+ core::LogWriter* vlog;
va_list ap;
- vlog = LogWriter::getLogWriter(name);
+ vlog = core::LogWriter::getLogWriter(name);
if (vlog == nullptr)
return;
va_start(ap, format);
@@ -97,30 +98,25 @@ void vncLogDebug(const char *name, const char *format, ...)
int vncSetParam(const char *name, const char *value)
{
if (value != nullptr)
- return rfb::Configuration::setParam(name, value);
+ return core::Configuration::setParam(name, value);
else {
- VoidParameter *param;
- param = rfb::Configuration::getParam(name);
+ core::VoidParameter* param;
+ param = core::Configuration::getParam(name);
if (param == nullptr)
return false;
return param->setParam();
}
}
-int vncSetParamSimple(const char *nameAndValue)
-{
- return rfb::Configuration::setParam(nameAndValue);
-}
-
char* vncGetParam(const char *name)
{
- VoidParameter *param;
+ core::VoidParameter* param;
// Hack to avoid exposing password!
if (strcasecmp(name, "Password") == 0)
return nullptr;
- param = rfb::Configuration::getParam(name);
+ param = core::Configuration::getParam(name);
if (param == nullptr)
return nullptr;
@@ -129,40 +125,18 @@ char* vncGetParam(const char *name)
const char* vncGetParamDesc(const char *name)
{
- rfb::VoidParameter *param;
+ core::VoidParameter* param;
- param = rfb::Configuration::getParam(name);
+ param = core::Configuration::getParam(name);
if (param == nullptr)
return nullptr;
return param->getDescription();
}
-int vncIsParamBool(const char *name)
-{
- VoidParameter *param;
- BoolParameter *bparam;
-
- param = rfb::Configuration::getParam(name);
- if (param == nullptr)
- return false;
-
- bparam = dynamic_cast<BoolParameter*>(param);
- if (bparam == nullptr)
- return false;
-
- return true;
-}
-
int vncGetParamCount(void)
{
- int count;
-
- count = 0;
- for (ParameterIterator i; i.param; i.next())
- count++;
-
- return count;
+ return core::Configuration::global()->size();
}
char *vncGetParamList(void)
@@ -172,8 +146,8 @@ char *vncGetParamList(void)
len = 0;
- for (ParameterIterator i; i.param; i.next()) {
- int l = strlen(i.param->getName());
+ for (core::VoidParameter *param: *core::Configuration::global()) {
+ int l = strlen(param->getName());
if (l <= 255)
len += l + 1;
}
@@ -183,11 +157,11 @@ char *vncGetParamList(void)
return nullptr;
ptr = data;
- for (ParameterIterator i; i.param; i.next()) {
- int l = strlen(i.param->getName());
+ for (core::VoidParameter *param: *core::Configuration::global()) {
+ int l = strlen(param->getName());
if (l <= 255) {
*ptr++ = l;
- memcpy(ptr, i.param->getName(), l);
+ memcpy(ptr, param->getName(), l);
ptr += l;
}
}
@@ -198,7 +172,12 @@ char *vncGetParamList(void)
void vncListParams(int width, int nameWidth)
{
- rfb::Configuration::listParams(width, nameWidth);
+ core::Configuration::listParams(width, nameWidth);
+}
+
+int vncHandleParamArg(int argc, char* argv[], int index)
+{
+ return core::Configuration::handleParamArg(argc, argv, index);
}
int vncGetSocketPort(int fd)
@@ -225,7 +204,7 @@ int vncIsTCPPortUsed(int port)
char* vncConvertLF(const char* src, size_t bytes)
{
try {
- return strdup(convertLF(src, bytes).c_str());
+ return strdup(core::convertLF(src, bytes).c_str());
} catch (...) {
return nullptr;
}
@@ -234,7 +213,7 @@ char* vncConvertLF(const char* src, size_t bytes)
char* vncLatin1ToUTF8(const char* src, size_t bytes)
{
try {
- return strdup(latin1ToUTF8(src, bytes).c_str());
+ return strdup(core::latin1ToUTF8(src, bytes).c_str());
} catch (...) {
return nullptr;
}
@@ -243,7 +222,7 @@ char* vncLatin1ToUTF8(const char* src, size_t bytes)
char* vncUTF8ToLatin1(const char* src, size_t bytes)
{
try {
- return strdup(utf8ToLatin1(src, bytes).c_str());
+ return strdup(core::utf8ToLatin1(src, bytes).c_str());
} catch (...) {
return nullptr;
}
@@ -252,8 +231,15 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes)
int vncIsValidUTF8(const char* str, size_t bytes)
{
try {
- return isValidUTF8(str, bytes);
+ return core::isValidUTF8(str, bytes);
} catch (...) {
return 0;
}
}
+
+void vncSetDisplayName(const char *displayNumStr)
+{
+ std::string displayName(":");
+ displayName += displayNumStr;
+ rfb::UnixPasswordValidator::setDisplayName(displayName);
+}