It's just confusing that we have our own variety that isn't compatible.
namespace rfb {
- char* strDup(const char* s) {
- if (!s) return 0;
- int l = strlen(s);
- char* r = new char[l+1];
- memcpy(r, s, l+1);
- return r;
- };
-
- void strFree(char* s) {
- delete [] s;
- }
-
std::string strFormat(const char *fmt, ...)
{
va_list ap;
return out;
}
- bool strContains(const char* src, char c) {
- int l=strlen(src);
- for (int i=0; i<l; i++)
- if (src[i] == c) return true;
- return false;
- }
-
- void strCopy(char* dest, const char* src, int destlen) {
- if (src)
- strncpy(dest, src, destlen-1);
- dest[src ? destlen-1 : 0] = 0;
- }
-
static char intToHex(uint8_t i) {
if (i<=9)
return '0'+i;
namespace rfb {
- char* strDup(const char* s);
- void strFree(char* s);
-
// Formats according to printf(), with a dynamic allocation
std::string strFormat(const char *fmt, ...)
__attribute__((__format__ (__printf__, 1, 2)));
std::vector<std::string> strSplit(const char* src,
const char delimiter);
- // Returns true if src contains c
- bool strContains(const char* src, char c);
-
- // Copies src to dest, up to specified length-1, and guarantees termination
- void strCopy(char* dest, const char* src, int destlen);
-
// Conversion to and from a hex string
void binToHex(const uint8_t* in, size_t inlen, char* out, size_t outlen);
#include <X11/Xatom.h>
#include "TXWindow.h"
#include <list>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
-#include <rfb/util.h>
std::list<TXWindow*> windows;
static unsigned char tickBits[] = { 0x80, 0xc0, 0xe2, 0x76, 0x3e, 0x1c, 0x08, 0x00};
tick = XCreateBitmapFromData(dpy, DefaultRootWindow(dpy), (char*)tickBits,
tickSize, tickSize);
- defaultWindowClass = rfb::strDup(defaultWindowClass_);
+ defaultWindowClass = strdup(defaultWindowClass_);
}
void TXWindow::handleXEvents(Display* dpy)
char* vncConvertLF(const char* src, size_t bytes)
{
try {
- return strDup(convertLF(src, bytes).c_str());
+ return strdup(convertLF(src, bytes).c_str());
} catch (...) {
return NULL;
}
char* vncLatin1ToUTF8(const char* src, size_t bytes)
{
try {
- return strDup(latin1ToUTF8(src, bytes).c_str());
+ return strdup(latin1ToUTF8(src, bytes).c_str());
} catch (...) {
return NULL;
}
char* vncUTF8ToLatin1(const char* src, size_t bytes)
{
try {
- return strDup(utf8ToLatin1(src, bytes).c_str());
+ return strdup(utf8ToLatin1(src, bytes).c_str());
} catch (...) {
return NULL;
}
}
-
-void vncStrFree(char* str)
-{
- strFree(str);
-}
char* vncLatin1ToUTF8(const char* src, size_t bytes);
char* vncUTF8ToLatin1(const char* src, size_t bytes);
-void vncStrFree(char* str);
-
#ifdef __cplusplus
}
#endif
XA_STRING, 8, PropModeReplace,
strlen(latin1), latin1, TRUE);
- vncStrFree(latin1);
+ free(latin1);
if (rc != Success)
return rc;
return;
utf8 = vncLatin1ToUTF8(filtered, (size_t)-1);
- vncStrFree(filtered);
+ free(filtered);
if (utf8 == NULL)
return;
vncSendClipboardData(utf8);
- vncStrFree(utf8);
+ free(utf8);
} else if (target == xaUTF8_STRING) {
char *filtered;
vncSendClipboardData(filtered);
- vncStrFree(filtered);
+ free(filtered);
}
}