#include <string.h>
#include <limits.h>
+#include "i18n.h"
+
using namespace rfb;
static LogWriter vlog("Parameters");
strncpy(dest+pos, "\\\\", 2);
pos++;
if (pos >= destSize) {
- vlog.error("Encoding backslash: The size of the buffer dest is to small, "
- "it needs to be more than %d bytes bigger.", (destSize - 1 - i));
+ vlog.error(_("Encoding backslash: The size of the buffer dest "
+ "is to small, it needs to be more than %d bytes bigger."),
+ (destSize - 1 - i));
return false;
}
dest[pos] = '\\';
pos++;
if (pos >= destSize) {
- vlog.error("Encoding escape sequence: The size of the buffer dest is to small, "
- "it needs to be more than %d bytes bigger.", (destSize - 1 - i));
+ vlog.error(_("Encoding escape sequence: The size of the buffer "
+ "dest is to small, it needs to be more than %d bytes "
+ "bigger."), (destSize - 1 - i));
return false;
}
pos++;
if (pos >= destSize) {
- vlog.error("Encoding normal character: The size of the buffer dest is to small, "
- "it needs to be more than %d bytes bigger.", (destSize - 1 - i));
+ vlog.error(_("Encoding normal character: The size of the buffer dest "
+ "is to small, it needs to be more than %d bytes bigger."),
+ (destSize - 1 - i));
return false;
}
dest[pos] = val[i];
i++;
} else {
- vlog.error("Unknown escape sequence at character %d", i);
+ vlog.error(_("Unknown escape sequence at character %d"), i);
return false;
}
}
escapedCharacter = false; // Reset for next loop
pos++;
if (pos >= destSize) {
- vlog.error("Decoding: The size of the buffer dest is to small, "
- "it needs to be 1 byte bigger.");
+ vlog.error(_("Decoding: The size of the buffer dest is to small, "
+ "it needs to be 1 byte bigger."));
return false;
}
}
wchar_t name[buffersize];
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "writing to the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "writing to the Registry, the buffersize is to small."),
+ _name);
return;
}
char encodingBuffer[buffersize];
if (!encodeValue(_value, encodingBuffer, buffersize)) {
- vlog.error("Could not encode the parameter-value %s when "
- "writing to the Registry.", _value);
+ vlog.error(_("Could not encode the parameter-value %s when "
+ "writing to the Registry."), _value);
return;
}
wchar_t value[buffersize];
size = fl_utf8towc(encodingBuffer, strlen(encodingBuffer)+1, value, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-value %s to wchar_t* when "
- "writing to the Registry, the buffersize is to small.", _value);
+ vlog.error(_("Could not convert the parameter-value %s to wchar_t* when "
+ "writing to the Registry, the buffersize is to small."),
+ _value);
return;
}
LONG res = RegSetValueExW(*hKey, name, 0, REG_SZ, (BYTE*)&value, (wcslen(value)+1)*2);
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) writing %s(REG_SZ) to Registry.", res, _value);
+ vlog.error(_("Error(%d) writing %s(REG_SZ) to Registry."), res, _value);
return;
}
}
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "writing to the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "writing to the Registry, the buffersize is to small."),
+ _name);
return;
}
LONG res = RegSetValueExW(*hKey, name, 0, REG_DWORD, (BYTE*)&value, sizeof(DWORD));
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) writing %d(REG_DWORD) to Registry.", res, _value);
+ vlog.error(_("Error(%d) writing %d(REG_DWORD) to Registry."), res, _value);
return;
}
}
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "reading from the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "reading from the Registry, the buffersize is to small."),
+ _name);
return false;
}
if (res == ERROR_FILE_NOT_FOUND) {
// The value does not exist, defaults will be used.
} else {
- vlog.error("Error(%d) reading %s from Registry.", res, _name);
+ vlog.error(_("Error(%d) reading %s from Registry."), res, _name);
}
return false;
}
char utf8val[destSize];
size = fl_utf8fromwc(utf8val, sizeof(utf8val), value, wcslen(value)+1);
if (size >= sizeof(utf8val)) {
- vlog.error("Could not convert the parameter-value for %s to utf8 char* "
- "when reading from the Registry, the buffer dest is to small.",
- _name);
+ vlog.error(_("Could not convert the parameter-value for %s to utf8 "
+ "char* when reading from the Registry, the buffer dest is "
+ "to small."), _name);
return false;
}
const char *ret = utf8val;
unsigned size = fl_utf8towc(_name, strlen(_name)+1, name, buffersize);
if (size >= buffersize) {
- vlog.error("Could not convert the parameter-name %s to wchar_t* when "
- "reading from the Registry, the buffersize is to small.", _name);
+ vlog.error(_("Could not convert the parameter-name %s to wchar_t* when "
+ "reading from the Registry, the buffersize is to small."),
+ _name);
return false;
}
if (res == ERROR_FILE_NOT_FOUND) {
// The value does not exist, defaults will be used.
} else {
- vlog.error("Error(%d) reading %s from Registry.", res, _name);
+ vlog.error(_("Error(%d) reading %s from Registry."), res, _name);
}
return false;
}
LONG res = RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\TigerVNC\\vncviewer", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL);
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) creating key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) creating key: Software\\TigerVNC\\vncviewer"), res);
return;
}
} else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey);
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", i);
+ vlog.info(_("The parameterArray contains a object of a invalid type "
+ "at line %d."), i);
}
}
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS) {
- vlog.error("Error(%d) closing key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) closing key: Software\\TigerVNC\\vncviewer"), res);
}
}
if (res == ERROR_FILE_NOT_FOUND) {
// The key does not exist, defaults will be used.
} else {
- vlog.error("Error(%d) opening key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) opening key: Software\\TigerVNC\\vncviewer"), res);
}
return NULL;
}
if (getKeyInt(parameterArray[i]->getName(), &intValue, &hKey))
((BoolParameter*)parameterArray[i])->setParam(intValue);
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", i);
+ vlog.info(_("The parameterArray contains a object of a invalid type at line %d."), i);
}
}
res = RegCloseKey(hKey);
if (res != ERROR_SUCCESS){
- vlog.error("Error(%d) closing key: Software\\TigerVNC\\vncviewer", res);
+ vlog.error(_("Error(%d) closing key: Software\\TigerVNC\\vncviewer"), res);
}
return servername;
char* homeDir = NULL;
if (getvnchomedir(&homeDir) == -1) {
- vlog.error("Failed to write configuration file, "
- "can't obtain home directory path.");
+ vlog.error(_("Failed to write configuration file, can't obtain home "
+ "directory path."));
return;
}
FILE* f = fopen(filepath, "w+");
if (!f) {
snprintf(write_error, sizeof(write_error),
- "Failed to write configuration file, can't open %s", filepath);
+ _("Failed to write configuration file, can't open %s"), filepath);
throw Exception(write_error);
}
} else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
fprintf(f, "%s=%d\n", ((BoolParameter*)parameterArray[i])->getName(), (int)*(BoolParameter*)parameterArray[i]);
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", i);
+ vlog.info(_("The parameterArray contains a object of a invalid type "
+ "at line %d."), i);
}
}
fclose(f);
char* homeDir = NULL;
if (getvnchomedir(&homeDir) == -1)
- throw Exception("Failed to read configuration file, "
- "can't obtain home directory path.");
+ throw Exception(_("Failed to read configuration file, "
+ "can't obtain home directory path."));
snprintf(filepath, sizeof(filepath), "%sdefault.tigervnc", homeDir);
} else {
if (!f) {
if (!filename)
return NULL; // Use defaults.
- snprintf(readError, sizeof(readError), "Failed to read configuration file, "
- "can't open %s", filepath);
+ snprintf(readError, sizeof(readError),
+ _("Failed to read configuration file, can't open %s"), filepath);
throw Exception(readError);
}
lineNr++;
if (!fgets(line, sizeof(line), f)) {
if (line[sizeof(line) -1] != '\0') {
- vlog.error("Could not read the line(%d) in the configuration file,"
- "the buffersize is to small.", lineNr);
+ vlog.error(_("Could not read the line(%d) in the configuration file,"
+ "the buffersize is to small."), lineNr);
return NULL;
}
if (feof(f))
break;
- snprintf(readError, sizeof(readError), "Failed to read line %d in file %s",
- lineNr, filepath);
+ snprintf(readError, sizeof(readError),
+ _("Failed to read line %d in file %s"), lineNr, filepath);
throw Exception(readError);
}
if(strncmp(line, IDENTIFIER_STRING, strlen(IDENTIFIER_STRING)) == 0) {
continue;
} else {
- snprintf(readError, sizeof(readError), "Line 1 in file %s\n"
- "must contain the TigerVNC configurationfile identifier string:\n"
- "\"%s\"", filepath, IDENTIFIER_STRING);
+ snprintf(readError, sizeof(readError),
+ _("Line 1 in file %s\nmust contain the TigerVNC "
+ "configuration file identifier string:\n"
+ "\"%s\""), filepath, IDENTIFIER_STRING);
throw Exception(readError);
}
}
// Find the parameter value
char *value = strchr(line, '=');
if (value == NULL) {
- vlog.info("Bad Name/Value pair on line: %d in file: %s",
+ vlog.info(_("Bad Name/Value pair on line: %d in file: %s"),
lineNr, filepath);
continue;
}
if (strcasecmp(line, "ServerName") == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer))) {
- vlog.info("The value of the parameter %s on line %d in file %s is invalid.",
- line, lineNr, filepath);
+ vlog.info(_("The value of the parameter %s on line %d in file %s "
+ "is invalid."), line, lineNr, filepath);
continue;
}
snprintf(servername, sizeof(decodingBuffer), "%s", decodingBuffer);
if (strcasecmp(line, ((StringParameter*)parameterArray[i])->getName()) == 0) {
if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer))) {
- vlog.info("The value of the parameter %s on line %d in file %s is invalid.",
- line, lineNr, filepath);
+ vlog.info(_("The value of the parameter %s on line %d in file %s "
+ "is invalid."), line, lineNr, filepath);
continue;
}
((StringParameter*)parameterArray[i])->setParam(decodingBuffer);
}
} else {
- vlog.info("The parameterArray contains a object of a invalid type at line %d.", lineNr);
+ vlog.info(_("The parameterArray contains a object of a invalid type "
+ "at line %d."), lineNr);
}
}
}
if (invalidParameterName)
- vlog.info("Invalid parameter name on line: %d in file: %s",
+ vlog.info(_("Invalid parameter name on line: %d in file: %s"),
lineNr, filepath);
}
fclose(f); f=0;