]> source.dussan.org Git - tigervnc.git/commitdiff
Use nullptr in all C++ code
authorPierre Ossman <ossman@cendio.se>
Tue, 2 Apr 2024 14:13:23 +0000 (16:13 +0200)
committerPierre Ossman <ossman@cendio.se>
Mon, 24 Jun 2024 11:42:54 +0000 (13:42 +0200)
It's more readable than 0, and a bit safer than NULL, so let's try to
follow modern norms.

185 files changed:
common/network/Socket.cxx
common/network/TcpSocket.cxx
common/os/Mutex.cxx
common/os/Thread.cxx
common/os/os.cxx
common/rdr/BufferedInStream.cxx
common/rdr/BufferedOutStream.cxx
common/rdr/Exception.cxx
common/rdr/Exception.h
common/rdr/FdInStream.cxx
common/rdr/FdOutStream.cxx
common/rdr/FileInStream.cxx
common/rdr/InStream.h
common/rdr/OutStream.h
common/rdr/RandomStream.cxx
common/rdr/TLSInStream.cxx
common/rdr/TLSOutStream.cxx
common/rdr/ZlibInStream.cxx
common/rdr/ZlibOutStream.cxx
common/rdr/ZlibOutStream.h
common/rfb/Blacklist.cxx
common/rfb/CConnection.cxx
common/rfb/CMsgReader.cxx
common/rfb/CMsgWriter.cxx
common/rfb/CSecurityRSAAES.cxx
common/rfb/CSecurityStack.h
common/rfb/CSecurityTLS.cxx
common/rfb/CSecurityVeNCrypt.cxx
common/rfb/CSecurityVncAuth.cxx
common/rfb/ClientParams.cxx
common/rfb/Configuration.cxx
common/rfb/Configuration.h
common/rfb/Congestion.cxx
common/rfb/DecodeManager.cxx
common/rfb/Decoder.cxx
common/rfb/EncodeManager.cxx
common/rfb/H264Decoder.cxx
common/rfb/H264LibavDecoderContext.cxx
common/rfb/H264WinDecoderContext.cxx
common/rfb/H264WinDecoderContext.h
common/rfb/HextileEncoder.cxx
common/rfb/Hostname.h
common/rfb/JpegCompressor.cxx
common/rfb/JpegDecompressor.cxx
common/rfb/LogWriter.cxx
common/rfb/Logger.cxx
common/rfb/Logger_file.cxx
common/rfb/Logger_syslog.cxx
common/rfb/Palette.h
common/rfb/PixelBuffer.cxx
common/rfb/SConnection.cxx
common/rfb/SConnection.h
common/rfb/SDesktop.h
common/rfb/SMsgReader.cxx
common/rfb/SMsgWriter.cxx
common/rfb/SSecurityNone.h
common/rfb/SSecurityPlain.cxx
common/rfb/SSecurityRSAAES.cxx
common/rfb/SSecurityStack.cxx
common/rfb/SSecurityStack.h
common/rfb/SSecurityTLS.cxx
common/rfb/SSecurityTLS.h
common/rfb/SSecurityVeNCrypt.cxx
common/rfb/SSecurityVncAuth.cxx
common/rfb/SSecurityVncAuth.h
common/rfb/SecurityClient.cxx
common/rfb/ServerParams.cxx
common/rfb/TightDecoder.cxx
common/rfb/TightEncoder.cxx
common/rfb/Timer.cxx
common/rfb/UpdateTracker.h
common/rfb/VNCSConnectionST.cxx
common/rfb/VNCServer.h
common/rfb/VNCServerST.cxx
common/rfb/VNCServerST.h
common/rfb/ZRLEDecoder.cxx
common/rfb/ZRLEEncoder.cxx
common/rfb/obfuscate.cxx
common/rfb/util.cxx
tests/perf/decperf.cxx
tests/perf/encperf.cxx
tests/perf/fbperf.cxx
tests/perf/util.cxx
tests/unit/unicode.cxx
unix/tx/TXButton.h
unix/tx/TXCheckbox.h
unix/tx/TXDialog.h
unix/tx/TXLabel.h
unix/tx/TXWindow.cxx
unix/tx/TXWindow.h
unix/vncconfig/vncconfig.cxx
unix/vncpasswd/vncpasswd.cxx
unix/x0vncserver/Geometry.cxx
unix/x0vncserver/Image.cxx
unix/x0vncserver/Image.h
unix/x0vncserver/XDesktop.cxx
unix/x0vncserver/XPixelBuffer.cxx
unix/x0vncserver/x0vncserver.cxx
unix/xserver/hw/vnc/RFBGlue.cc
unix/xserver/hw/vnc/XserverDesktop.cc
unix/xserver/hw/vnc/vncExtInit.cc
vncviewer/BaseTouchHandler.cxx
vncviewer/CConn.cxx
vncviewer/DesktopWindow.cxx
vncviewer/GestureHandler.cxx
vncviewer/MonitorIndicesParameter.cxx
vncviewer/OptionsDialog.cxx
vncviewer/OptionsDialog.h
vncviewer/PlatformPixelBuffer.cxx
vncviewer/ServerDialog.cxx
vncviewer/Surface_OSX.cxx
vncviewer/Surface_Win32.cxx
vncviewer/Surface_X11.cxx
vncviewer/UserDialog.cxx
vncviewer/Viewport.cxx
vncviewer/Win32TouchHandler.cxx
vncviewer/XInputTouchHandler.cxx
vncviewer/cocoa.mm
vncviewer/fltk/Fl_Monitor_Arrangement.cxx
vncviewer/fltk/Fl_Navigation.cxx
vncviewer/fltk/theme.cxx
vncviewer/fltk/util.h
vncviewer/gettext.h
vncviewer/parameters.cxx
vncviewer/parameters.h
vncviewer/touch.cxx
vncviewer/vncviewer.cxx
win/rfb_win32/AboutDialog.cxx
win/rfb_win32/CleanDesktop.cxx
win/rfb_win32/Clipboard.cxx
win/rfb_win32/DIBSectionBuffer.cxx
win/rfb_win32/DeviceContext.cxx
win/rfb_win32/DeviceContext.h
win/rfb_win32/DeviceFrameBuffer.cxx
win/rfb_win32/Dialog.cxx
win/rfb_win32/Dialog.h
win/rfb_win32/Handle.h
win/rfb_win32/IntervalTimer.h
win/rfb_win32/LaunchProcess.cxx
win/rfb_win32/LocalMem.h
win/rfb_win32/ModuleFileName.h
win/rfb_win32/MonitorInfo.cxx
win/rfb_win32/MsgBox.h
win/rfb_win32/MsgWindow.cxx
win/rfb_win32/RegConfig.cxx
win/rfb_win32/Registry.cxx
win/rfb_win32/Registry.h
win/rfb_win32/SDisplay.cxx
win/rfb_win32/Security.cxx
win/rfb_win32/Security.h
win/rfb_win32/SecurityPage.cxx
win/rfb_win32/Service.cxx
win/rfb_win32/SocketManager.cxx
win/rfb_win32/SocketManager.h
win/rfb_win32/TrayIcon.h
win/rfb_win32/WMCursor.cxx
win/rfb_win32/WMCursor.h
win/rfb_win32/WMHooks.cxx
win/rfb_win32/WMNotifier.cxx
win/rfb_win32/WMPoller.h
win/rfb_win32/WMWindowCopyRect.cxx
win/rfb_win32/Win32Util.cxx
win/rfb_win32/Win32Util.h
win/vncconfig/Authentication.h
win/vncconfig/Connections.h
win/vncconfig/Desktop.h
win/vncconfig/Hooking.h
win/vncconfig/Inputs.h
win/vncconfig/Legacy.cxx
win/vncconfig/Legacy.h
win/vncconfig/PasswordDialog.cxx
win/vncconfig/PasswordDialog.h
win/vncconfig/Sharing.h
win/vncconfig/vncconfig.cxx
win/winvnc/AddNewClientDialog.h
win/winvnc/ControlPanel.cxx
win/winvnc/ControlPanel.h
win/winvnc/ManagedListener.cxx
win/winvnc/QueryConnectDialog.cxx
win/winvnc/STrayIcon.cxx
win/winvnc/VNCServerService.cxx
win/winvnc/VNCServerWin32.cxx
win/winvnc/VNCServerWin32.h
win/winvnc/winvnc.cxx
win/wm_hooks/wm_hooks.cxx

index 78484f51cec645b27c7e7582202c0d5ce47d2eac..971a7170fb960716c67935b7220f94c97ab23a54 100644 (file)
@@ -71,7 +71,7 @@ bool network::isSocketListening(int sock)
 }
 
 Socket::Socket(int fd)
-  : instream(0), outstream(0),
+  : instream(nullptr), outstream(nullptr),
     isShutdown_(false), queryConnection(false)
 {
   initSockets();
@@ -79,7 +79,7 @@ Socket::Socket(int fd)
 }
 
 Socket::Socket()
-  : instream(0), outstream(0),
+  : instream(nullptr), outstream(nullptr),
     isShutdown_(false), queryConnection(false)
 {
   initSockets();
@@ -129,13 +129,13 @@ void Socket::setFd(int fd)
 }
 
 SocketListener::SocketListener(int fd)
-  : fd(fd), filter(0)
+  : fd(fd), filter(nullptr)
 {
   initSockets();
 }
 
 SocketListener::SocketListener()
-  : fd(-1), filter(0)
+  : fd(-1), filter(nullptr)
 {
   initSockets();
 }
@@ -160,14 +160,14 @@ Socket* SocketListener::accept() {
   int new_sock = -1;
 
   // Accept an incoming connection
-  if ((new_sock = ::accept(fd, 0, 0)) < 0)
+  if ((new_sock = ::accept(fd, nullptr, nullptr)) < 0)
     throw SocketException("unable to accept new connection", errorNumber);
 
   // Create the socket object & check connection is allowed
   Socket* s = createSocket(new_sock);
   if (filter && !filter->verifyConnection(s)) {
     delete s;
-    return NULL;
+    return nullptr;
   }
 
   return s;
index 15730cfdce463b43058d135c0f51692df4080bfa..d9b376c9a4f604b9461b9408211cd0cc1ae7fe94 100644 (file)
@@ -129,17 +129,17 @@ TcpSocket::TcpSocket(const char *host, int port)
   memset(&hints, 0, sizeof(struct addrinfo));
   hints.ai_family = AF_UNSPEC;
   hints.ai_socktype = SOCK_STREAM;
-  hints.ai_canonname = NULL;
-  hints.ai_addr = NULL;
-  hints.ai_next = NULL;
+  hints.ai_canonname = nullptr;
+  hints.ai_addr = nullptr;
+  hints.ai_next = nullptr;
 
-  if ((result = getaddrinfo(host, NULL, &hints, &ai)) != 0) {
+  if ((result = getaddrinfo(host, nullptr, &hints, &ai)) != 0) {
     throw GAIException("unable to resolve host by name", result);
   }
 
   sock = -1;
   err = 0;
-  for (current = ai; current != NULL; current = current->ai_next) {
+  for (current = ai; current != nullptr; current = current->ai_next) {
     int family;
     vnc_sockaddr_t sa;
     socklen_t salen;
@@ -168,7 +168,7 @@ TcpSocket::TcpSocket(const char *host, int port)
     else
       sa.u.sin6.sin6_port = htons(port);
 
-    getnameinfo(&sa.u.sa, salen, ntop, sizeof(ntop), NULL, 0, NI_NUMERICHOST);
+    getnameinfo(&sa.u.sa, salen, ntop, sizeof(ntop), nullptr, 0, NI_NUMERICHOST);
     vlog.debug("Connecting to %s [%s] port %d", host, ntop, port);
 
     sock = socket (family, SOCK_STREAM, 0);
@@ -228,7 +228,7 @@ const char* TcpSocket::getPeerAddress() {
     buffer[0] = '[';
 
     ret = getnameinfo(&sa.u.sa, sizeof(sa.u.sin6),
-                      buffer + 1, sizeof(buffer) - 2, NULL, 0,
+                      buffer + 1, sizeof(buffer) - 2, nullptr, 0,
                       NI_NUMERICHOST);
     if (ret != 0) {
       vlog.error("unable to convert peer name to a string");
@@ -244,7 +244,7 @@ const char* TcpSocket::getPeerAddress() {
     char *name;
 
     name = inet_ntoa(sa.u.sin.sin_addr);
-    if (name == NULL) {
+    if (name == nullptr) {
       vlog.error("unable to convert peer name to a string");
       return "(N/A)";
     }
@@ -352,15 +352,15 @@ std::list<std::string> TcpListener::getMyAddresses() {
   hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV;
   hints.ai_family = AF_UNSPEC;
   hints.ai_socktype = SOCK_STREAM;
-  hints.ai_canonname = NULL;
-  hints.ai_addr = NULL;
-  hints.ai_next = NULL;
+  hints.ai_canonname = nullptr;
+  hints.ai_addr = nullptr;
+  hints.ai_next = nullptr;
 
   // Windows doesn't like NULL for service, so specify something
-  if ((getaddrinfo(NULL, "1", &hints, &ai)) != 0)
+  if ((getaddrinfo(nullptr, "1", &hints, &ai)) != 0)
     return result;
 
-  for (current= ai; current != NULL; current = current->ai_next) {
+  for (current= ai; current != nullptr; current = current->ai_next) {
     char addr[INET6_ADDRSTRLEN];
 
     switch (current->ai_family) {
@@ -377,7 +377,7 @@ std::list<std::string> TcpListener::getMyAddresses() {
     }
 
     getnameinfo(current->ai_addr, current->ai_addrlen, addr, INET6_ADDRSTRLEN,
-                NULL, 0, NI_NUMERICHOST);
+                nullptr, 0, NI_NUMERICHOST);
 
     result.push_back(addr);
   }
@@ -417,7 +417,7 @@ void network::createLocalTcpListeners(std::list<SocketListener*> *listeners,
   ai[1].ai_family = sa[1].u.sin6.sin6_family;
   ai[1].ai_addr = &sa[1].u.sa;
   ai[1].ai_addrlen = sizeof(sa[1].u.sin6);
-  ai[1].ai_next = NULL;
+  ai[1].ai_next = nullptr;
 
   createTcpListeners(listeners, ai);
 }
@@ -436,9 +436,9 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
   hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV;
   hints.ai_family = AF_UNSPEC;
   hints.ai_socktype = SOCK_STREAM;
-  hints.ai_canonname = NULL;
-  hints.ai_addr = NULL;
-  hints.ai_next = NULL;
+  hints.ai_canonname = nullptr;
+  hints.ai_addr = nullptr;
+  hints.ai_next = nullptr;
 
   snprintf (service, sizeof (service) - 1, "%d", port);
   service[sizeof (service) - 1] = '\0';
@@ -463,7 +463,7 @@ void network::createTcpListeners(std::list<SocketListener*> *listeners,
 
   initSockets();
 
-  for (current = ai; current != NULL; current = current->ai_next) {
+  for (current = ai; current != nullptr; current = current->ai_next) {
     switch (current->ai_family) {
     case AF_INET:
       if (!UseIPv4)
@@ -629,7 +629,7 @@ TcpFilter::Pattern TcpFilter::parsePattern(const char* p) {
         parts[0].erase(parts.size()-1, 1);
     }
 
-    if ((result = getaddrinfo (parts[0].c_str(), NULL, &hints, &ai)) != 0) {
+    if ((result = getaddrinfo (parts[0].c_str(), nullptr, &hints, &ai)) != 0) {
       throw GAIException("unable to resolve host by name", result);
     }
 
@@ -711,11 +711,11 @@ std::string TcpFilter::patternToStr(const TcpFilter::Pattern& p) {
 
   if (p.address.u.sa.sa_family == AF_INET) {
     getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin),
-                addr, sizeof(addr), NULL, 0, NI_NUMERICHOST);
+                addr, sizeof(addr), nullptr, 0, NI_NUMERICHOST);
   } else if (p.address.u.sa.sa_family == AF_INET6) {
     addr[0] = '[';
     getnameinfo(&p.address.u.sa, sizeof(p.address.u.sin6),
-                addr + 1, sizeof(addr) - 2, NULL, 0, NI_NUMERICHOST);
+                addr + 1, sizeof(addr) - 2, nullptr, 0, NI_NUMERICHOST);
     strcat(addr, "]");
   } else
     addr[0] = '\0';
index e6532a7de7d6ce094568b9bdfc1f5702822ff5fa..5e245a6d7649efb5c52dee6d5833f165e6a5e29b 100644 (file)
@@ -41,7 +41,7 @@ Mutex::Mutex()
   int ret;
 
   systemMutex = new pthread_mutex_t;
-  ret = pthread_mutex_init((pthread_mutex_t*)systemMutex, NULL);
+  ret = pthread_mutex_init((pthread_mutex_t*)systemMutex, nullptr);
   if (ret != 0)
     throw rdr::SystemException("Failed to create mutex", ret);
 #endif
@@ -95,7 +95,7 @@ Condition::Condition(Mutex* mutex)
   int ret;
 
   systemCondition = new pthread_cond_t;
-  ret = pthread_cond_init((pthread_cond_t*)systemCondition, NULL);
+  ret = pthread_cond_init((pthread_cond_t*)systemCondition, nullptr);
   if (ret != 0)
     throw rdr::SystemException("Failed to create condition variable", ret);
 #endif
index 92cc68d5388105b3cfd8a6b3ee84b2b6b0136c13..91f7fd077ea9a186bc9b8f08e269d5f1b007710e 100644 (file)
@@ -35,7 +35,7 @@
 
 using namespace os;
 
-Thread::Thread() : running(false), threadId(NULL)
+Thread::Thread() : running(false), threadId(nullptr)
 {
   mutex = new Mutex;
 
@@ -64,8 +64,8 @@ void Thread::start()
   AutoMutex a(mutex);
 
 #ifdef WIN32
-  *(HANDLE*)threadId = CreateThread(NULL, 0, startRoutine, this, 0, NULL);
-  if (*(HANDLE*)threadId == NULL)
+  *(HANDLE*)threadId = CreateThread(nullptr, 0, startRoutine, this, 0, nullptr);
+  if (*(HANDLE*)threadId == nullptr)
     throw rdr::SystemException("Failed to create thread", GetLastError());
 #else
   int ret;
@@ -78,9 +78,9 @@ void Thread::start()
   if (ret != 0)
     throw rdr::SystemException("Failed to mask signals", ret);
 
-  ret = pthread_create((pthread_t*)threadId, NULL, startRoutine, this);
+  ret = pthread_create((pthread_t*)threadId, nullptr, startRoutine, this);
 
-  pthread_sigmask(SIG_SETMASK, &old, NULL);
+  pthread_sigmask(SIG_SETMASK, &old, nullptr);
 
   if (ret != 0)
     throw rdr::SystemException("Failed to create thread", ret);
@@ -103,7 +103,7 @@ void Thread::wait()
 #else
   int ret;
 
-  ret = pthread_join(*(pthread_t*)threadId, NULL);
+  ret = pthread_join(*(pthread_t*)threadId, nullptr);
   if (ret != 0)
     throw rdr::SystemException("Failed to join thread", ret);
 #endif
@@ -165,5 +165,9 @@ void* Thread::startRoutine(void* data)
   self->running = false;
   self->mutex->unlock();
 
+#ifdef WIN32
   return 0;
+#else
+  return nullptr;
+#endif
 }
index 83995d0d3147d3400aba0fb4ebd8a819d1445c97..2ac70550eee688f62f22d60586726f8836c17ccd 100644 (file)
@@ -58,12 +58,12 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
 
 #ifndef WIN32
   homedir = getenv("HOME");
-  if (homedir == NULL) {
+  if (homedir == nullptr) {
     uid = getuid();
     passwd = getpwuid(uid);
-    if (passwd == NULL) {
+    if (passwd == nullptr) {
       /* Do we want emit error msg here? */
-      return NULL;
+      return nullptr;
     }
     homedir = passwd->pw_dir;
   }
@@ -72,7 +72,7 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
     return homedir;
 
   xdgdir = getenv(xdg_env);
-  if (xdgdir != NULL && xdgdir[0] == '/')
+  if (xdgdir != nullptr && xdgdir[0] == '/')
     snprintf(dir, sizeof(dir), "%s/tigervnc", xdgdir);
   else
     snprintf(dir, sizeof(dir), "%s/%s/tigervnc", homedir, xdg_def);
@@ -83,25 +83,25 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
   (void) xdg_env;
 
   if (userDir)
-    ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_PROFILE, FALSE);
+    ret = SHGetSpecialFolderPath(nullptr, dir, CSIDL_PROFILE, FALSE);
   else
-    ret = SHGetSpecialFolderPath(NULL, dir, CSIDL_APPDATA, FALSE);
+    ret = SHGetSpecialFolderPath(nullptr, dir, CSIDL_APPDATA, FALSE);
 
   if (ret == FALSE)
-    return NULL;
+    return nullptr;
 
   if (userDir)
     return dir;
 
-  ret = SHGetSpecialFolderPath(NULL, legacy, CSIDL_APPDATA, FALSE);
+  ret = SHGetSpecialFolderPath(nullptr, legacy, CSIDL_APPDATA, FALSE);
 
   if (ret == FALSE)
-    return NULL;
+    return nullptr;
 
   if (strlen(dir) + strlen("\\TigerVNC") >= sizeof(dir))
-    return NULL;
+    return nullptr;
   if (strlen(legacy) + strlen("\\vnc") >= sizeof(legacy))
-    return NULL;
+    return nullptr;
 
   strcat(dir, "\\TigerVNC");
   strcat(legacy, "\\vnc");
@@ -111,7 +111,7 @@ static const char* getvncdir(bool userDir, const char *xdg_env, const char *xdg_
 
 const char* os::getuserhomedir()
 {
-  return getvncdir(true, NULL, NULL);
+  return getvncdir(true, nullptr, nullptr);
 }
 
 const char* os::getvncconfigdir()
index 5978a8c94c33529618b9e83b8a2830b0de7aefb1..3c04bafc34ca9c3fbd6bfbe6fa06166e6f3b1b06 100644 (file)
@@ -35,7 +35,7 @@ BufferedInStream::BufferedInStream()
   : bufSize(DEFAULT_BUF_SIZE), offset(0)
 {
   ptr = end = start = new uint8_t[bufSize];
-  gettimeofday(&lastSizeCheck, NULL);
+  gettimeofday(&lastSizeCheck, nullptr);
   peakUsage = 0;
 }
 
@@ -80,7 +80,7 @@ void BufferedInStream::ensureSpace(size_t needed)
     end = newBuffer + (end - ptr);
     ptr = start = newBuffer;
 
-    gettimeofday(&lastSizeCheck, NULL);
+    gettimeofday(&lastSizeCheck, nullptr);
     peakUsage = needed;
   }
 
@@ -88,7 +88,7 @@ void BufferedInStream::ensureSpace(size_t needed)
     peakUsage = needed;
 
   // Time to shrink an excessive buffer?
-  gettimeofday(&now, NULL);
+  gettimeofday(&now, nullptr);
   if ((avail() == 0) && (bufSize > DEFAULT_BUF_SIZE) &&
       ((now.tv_sec < lastSizeCheck.tv_sec) ||
        (now.tv_sec > (lastSizeCheck.tv_sec + 5)))) {
@@ -105,7 +105,7 @@ void BufferedInStream::ensureSpace(size_t needed)
       bufSize = newSize;
     }
 
-    gettimeofday(&lastSizeCheck, NULL);
+    gettimeofday(&lastSizeCheck, nullptr);
     peakUsage = needed;
   }
 
index 640f6007635b8574e4222dcd398ffd697df55a84..0ee3d644536b25fee79a2e94e858f1b5d5758be0 100644 (file)
@@ -36,7 +36,7 @@ BufferedOutStream::BufferedOutStream(bool emulateCork)
 {
   ptr = start = sentUpTo = new uint8_t[bufSize];
   end = start + bufSize;
-  gettimeofday(&lastSizeCheck, NULL);
+  gettimeofday(&lastSizeCheck, nullptr);
   peakUsage = 0;
 }
 
@@ -75,7 +75,7 @@ void BufferedOutStream::flush()
     ptr = sentUpTo = start;
 
   // Time to shrink an excessive buffer?
-  gettimeofday(&now, NULL);
+  gettimeofday(&now, nullptr);
   if ((sentUpTo == ptr) && (bufSize > DEFAULT_BUF_SIZE) &&
       ((now.tv_sec < lastSizeCheck.tv_sec) ||
        (now.tv_sec > (lastSizeCheck.tv_sec + 5)))) {
@@ -93,7 +93,7 @@ void BufferedOutStream::flush()
       bufSize = newSize;
     }
 
-    gettimeofday(&lastSizeCheck, NULL);
+    gettimeofday(&lastSizeCheck, nullptr);
     peakUsage = 0;
   }
 }
@@ -156,7 +156,7 @@ void BufferedOutStream::overrun(size_t needed)
   sentUpTo = start = newBuffer;
   end = newBuffer + newSize;
 
-  gettimeofday(&lastSizeCheck, NULL);
+  gettimeofday(&lastSizeCheck, nullptr);
   peakUsage = totalNeeded;
 
   return;
index b1e0a841c1a80836feb1fc37d50a126575921fa7..f5ad1819717146ef272ab81074fee8ac059e9e74 100644 (file)
@@ -59,7 +59,7 @@ GAIException::GAIException(const char* s, int err)
   wchar_t *currStr = new wchar_t[len-strlen(str_)];
   wcsncpy(currStr, gai_strerrorW(err), len-1-strlen(str_));
   WideCharToMultiByte(CP_UTF8, 0, currStr, -1, str_+strlen(str_),
-                      len-1-strlen(str_), 0, 0);
+                      len-1-strlen(str_), nullptr, nullptr);
   delete [] currStr;
 #else
   strncat(str_, gai_strerror(err), len-1-strlen(str_));
@@ -83,9 +83,9 @@ SystemException::SystemException(const char* s, int err_)
 #ifdef _WIN32
   wchar_t *currStr = new wchar_t[len-strlen(str_)];
   FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
-                 0, err, 0, currStr, len-1-strlen(str_), 0);
+                 nullptr, err, 0, currStr, len-1-strlen(str_), nullptr);
   WideCharToMultiByte(CP_UTF8, 0, currStr, -1, str_+strlen(str_),
-                      len-1-strlen(str_), 0, 0);
+                      len-1-strlen(str_), nullptr, nullptr);
   delete [] currStr;
 
   int l = strlen(str_);
index 2c66ffcab4950b7b5e46be5133bc8a90276f7a39..f1a167e5c64ab65d6245944b88b45b788dc8f6b1 100644 (file)
@@ -26,7 +26,7 @@ namespace rdr {
   struct Exception {
     enum { len = 256 };
     char str_[len];
-    Exception(const char *format = 0, ...)
+    Exception(const char *format=nullptr, ...)
       __attribute__((__format__ (__printf__, 2, 3)));
     virtual ~Exception() {}
     virtual const char* str() const { return str_; }
index 8e12f3a4b1644125a1db3d17c48475d3294d229f..491dc008ae31a8f9d89d3aab25f410b779947dfc 100644 (file)
@@ -88,7 +88,7 @@ size_t FdInStream::readFd(uint8_t* buf, size_t len)
 
     FD_ZERO(&fds);
     FD_SET(fd, &fds);
-    n = select(fd+1, &fds, 0, 0, &tv);
+    n = select(fd+1, &fds, nullptr, nullptr, &tv);
   } while (n < 0 && errorNumber == EINTR);
 
   if (n < 0)
index 6827655f081f39033ca6c7a7e8df7623e59999f7..1f60d45b4a6e2bee8b0bc63a0ff7a80ee89c769f 100644 (file)
@@ -59,7 +59,7 @@ FdOutStream::FdOutStream(int fd_)
 #endif
   fd(fd_)
 {
-  gettimeofday(&lastWrite, NULL);
+  gettimeofday(&lastWrite, nullptr);
 }
 
 FdOutStream::~FdOutStream()
@@ -113,7 +113,7 @@ size_t FdOutStream::writeFd(const uint8_t* data, size_t length)
 
     FD_ZERO(&fds);
     FD_SET(fd, &fds);
-    n = select(fd+1, 0, &fds, 0, &tv);
+    n = select(fd+1, nullptr, &fds, nullptr, &tv);
   } while (n < 0 && errorNumber == EINTR);
 
   if (n < 0)
@@ -136,7 +136,7 @@ size_t FdOutStream::writeFd(const uint8_t* data, size_t length)
   if (n < 0)
     throw SystemException("write", errorNumber);
 
-  gettimeofday(&lastWrite, NULL);
+  gettimeofday(&lastWrite, nullptr);
 
   return n;
 }
index 6de1a5b29b0e554a0a00c28271ee35c477abf884..4239a2386831c24c3c46406c21debe4624384b9b 100644 (file)
@@ -39,7 +39,7 @@ FileInStream::FileInStream(const char *fileName)
 FileInStream::~FileInStream(void) {
   if (file) {
     fclose(file);
-    file = NULL;
+    file = nullptr;
   }
 }
 
index 019ca5a725be617ce4523c5f3b0490bfcf650be0..939439e1ba03d24483894578f28ad80821e36191 100644 (file)
@@ -64,7 +64,7 @@ namespace rdr {
 #endif
 
       if (length > (size_t)(end - ptr)) {
-        if (restorePoint != NULL) {
+        if (restorePoint != nullptr) {
           bool ret;
           size_t restoreDiff;
 
@@ -100,21 +100,21 @@ namespace rdr {
 
     inline void setRestorePoint() {
 #ifdef RFB_INSTREAM_CHECK
-      if (restorePoint != NULL)
+      if (restorePoint != nullptr)
         throw Exception("Nested use of input stream restore point");
 #endif
       restorePoint = ptr;
     }
     inline void clearRestorePoint() {
 #ifdef RFB_INSTREAM_CHECK
-      if (restorePoint == NULL)
+      if (restorePoint == nullptr)
         throw Exception("Incorrect clearing of input stream restore point");
 #endif
-      restorePoint = NULL;
+      restorePoint = nullptr;
     }
     inline void gotoRestorePoint() {
 #ifdef RFB_INSTREAM_CHECK
-      if (restorePoint == NULL)
+      if (restorePoint == nullptr)
         throw Exception("Incorrect activation of input stream restore point");
 #endif
       ptr = restorePoint;
@@ -204,7 +204,7 @@ namespace rdr {
 
   protected:
 
-    InStream() : restorePoint(NULL)
+    InStream() : restorePoint(nullptr)
 #ifdef RFB_INSTREAM_CHECK
       ,checkedBytes(0)
 #endif
index 8450efd09171a8f2db6e5ab9a9f835e1f7e796c5..2921b2326558e0dc47458d48f61baa7a3a58ba31 100644 (file)
@@ -36,7 +36,7 @@ namespace rdr {
 
   protected:
 
-    OutStream() : ptr(NULL), end(NULL), corked(false) {}
+    OutStream() : ptr(nullptr), end(nullptr), corked(false) {}
 
   public:
 
index 79a1a0f773f24c3bbc310b19a43c6f6aab0f082f..9813abdd132017102dbd103433a6c1948ea6e1c5 100644 (file)
@@ -45,9 +45,11 @@ RandomStream::RandomStream()
 {
 #ifdef RFB_HAVE_WINCRYPT
   provider = 0;
-  if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, 0)) {
+  if (!CryptAcquireContext(&provider, nullptr, nullptr,
+                           PROV_RSA_FULL, 0)) {
     if (GetLastError() == (DWORD)NTE_BAD_KEYSET) {
-      if (!CryptAcquireContext(&provider, 0, 0, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
+      if (!CryptAcquireContext(&provider, nullptr, nullptr,
+                               PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
         vlog.error("unable to create keyset");
         provider = 0;
       }
@@ -68,7 +70,7 @@ RandomStream::RandomStream()
 #endif
 #endif
     vlog.error("no OS supplied random source - using rand()");
-    seed += (unsigned int) time(0) + getpid() + getpid() * 987654 + rand();
+    seed += (unsigned int) time(nullptr) + getpid() + getpid() * 987654 + rand();
     srand(seed);
   }
 }
index 7ba98155fdd4b20c484288d373f00341be83768b..d13cee1fba47cd3ebe680742a8527c4041139f2e 100644 (file)
@@ -41,7 +41,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
 
   self->streamEmpty = false;
   delete self->saved_exception;
-  self->saved_exception = NULL;
+  self->saved_exception = nullptr;
 
   try {
     if (!in->hasData(1)) {
@@ -72,7 +72,7 @@ ssize_t TLSInStream::pull(gnutls_transport_ptr_t str, void* data, size_t size)
 }
 
 TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
-  : session(_session), in(_in), saved_exception(NULL)
+  : session(_session), in(_in), saved_exception(nullptr)
 {
   gnutls_transport_ptr_t recv, send;
 
@@ -83,7 +83,7 @@ TLSInStream::TLSInStream(InStream* _in, gnutls_session_t _session)
 
 TLSInStream::~TLSInStream()
 {
-  gnutls_transport_set_pull_function(session, NULL);
+  gnutls_transport_set_pull_function(session, nullptr);
 
   delete saved_exception;
 }
index a06dd285fc29b5f828619fcedaef144215919c10..c2f693102079e844d6d23f1414e2e36c93545e46 100644 (file)
@@ -41,7 +41,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data,
   OutStream *out = self->out;
 
   delete self->saved_exception;
-  self->saved_exception = NULL;
+  self->saved_exception = nullptr;
 
   try {
     out->writeBytes((const uint8_t*)data, size);
@@ -62,7 +62,7 @@ ssize_t TLSOutStream::push(gnutls_transport_ptr_t str, const void* data,
 }
 
 TLSOutStream::TLSOutStream(OutStream* _out, gnutls_session_t _session)
-  : session(_session), out(_out), saved_exception(NULL)
+  : session(_session), out(_out), saved_exception(nullptr)
 {
   gnutls_transport_ptr_t recv, send;
 
@@ -79,7 +79,7 @@ TLSOutStream::~TLSOutStream()
   } catch (Exception&) {
   }
 #endif
-  gnutls_transport_set_push_function(session, NULL);
+  gnutls_transport_set_push_function(session, nullptr);
 
   delete saved_exception;
 }
index 6441f0a1de42cbe7b53767a5a685042ef61e6237..a90d50f7540b85d086ec397dc5f9df83f4dfe139 100644 (file)
@@ -29,7 +29,7 @@
 using namespace rdr;
 
 ZlibInStream::ZlibInStream()
-  : underlying(0), zs(NULL), bytesIn(0)
+  : underlying(nullptr), zs(nullptr), bytesIn(0)
 {
   init();
 }
@@ -54,7 +54,7 @@ void ZlibInStream::flushUnderlying()
     skip(avail());
   }
 
-  setUnderlying(NULL, 0);
+  setUnderlying(nullptr, 0);
 }
 
 void ZlibInStream::reset()
@@ -65,28 +65,28 @@ void ZlibInStream::reset()
 
 void ZlibInStream::init()
 {
-  assert(zs == NULL);
+  assert(zs == nullptr);
 
   zs = new z_stream;
-  zs->zalloc    = Z_NULL;
-  zs->zfree     = Z_NULL;
-  zs->opaque    = Z_NULL;
-  zs->next_in   = Z_NULL;
+  zs->zalloc    = nullptr;
+  zs->zfree     = nullptr;
+  zs->opaque    = nullptr;
+  zs->next_in   = nullptr;
   zs->avail_in  = 0;
   if (inflateInit(zs) != Z_OK) {
     delete zs;
-    zs = NULL;
+    zs = nullptr;
     throw Exception("ZlibInStream: inflateInit failed");
   }
 }
 
 void ZlibInStream::deinit()
 {
-  assert(zs != NULL);
-  setUnderlying(NULL, 0);
+  assert(zs != nullptr);
+  setUnderlying(nullptr, 0);
   inflateEnd(zs);
   delete zs;
-  zs = NULL;
+  zs = nullptr;
 }
 
 bool ZlibInStream::fillBuffer()
index 63820b8ecba629d9e929ab2240617207516fd454..0b167711ea478bb11b815da648801ed1b17899fe 100644 (file)
@@ -39,10 +39,10 @@ ZlibOutStream::ZlibOutStream(OutStream* os, int compressLevel)
   : underlying(os), compressionLevel(compressLevel), newLevel(compressLevel)
 {
   zs = new z_stream;
-  zs->zalloc    = Z_NULL;
-  zs->zfree     = Z_NULL;
-  zs->opaque    = Z_NULL;
-  zs->next_in   = Z_NULL;
+  zs->zalloc    = nullptr;
+  zs->zfree     = nullptr;
+  zs->opaque    = nullptr;
+  zs->next_in   = nullptr;
   zs->avail_in  = 0;
   if (deflateInit(zs, compressLevel) != Z_OK) {
     delete zs;
@@ -78,14 +78,14 @@ void ZlibOutStream::setCompressionLevel(int level)
 void ZlibOutStream::flush()
 {
   BufferedOutStream::flush();
-  if (underlying != NULL)
+  if (underlying != nullptr)
     underlying->flush();
 }
 
 void ZlibOutStream::cork(bool enable)
 {
   BufferedOutStream::cork(enable);
-  if (underlying != NULL)
+  if (underlying != nullptr)
     underlying->cork(enable);
 }
 
index 8061a58c697a4431cd354ab746b8ed9979fbcf4d..f6c868959d253d869e6af389b39d9985b7545b32 100644 (file)
@@ -35,7 +35,7 @@ namespace rdr {
 
   public:
 
-    ZlibOutStream(OutStream* os=0, int compressionLevel=-1);
+    ZlibOutStream(OutStream* os=nullptr, int compressionLevel=-1);
     virtual ~ZlibOutStream();
 
     void setUnderlying(OutStream* os);
index 12a54c451c8edd95dc9bf8e23564794aa243f443..68420ae2f3f5273b8c070f38b7ede235cedcc818 100644 (file)
@@ -67,7 +67,7 @@ bool Blacklist::isBlackmarked(const char* name) {
   // Entry exists - has it reached the threshold yet?
   if ((*i).second.marks >= threshold) {
     // Yes - entry is blocked - has the timeout expired?        
-    time_t now = time(0);
+    time_t now = time(nullptr);
     if (now >= (*i).second.blockUntil) {
       // Timeout has expired.  Reset timeout and allow
       // a re-try.
index 0f4fc4f887f11a062cab929f56eca79b92c2e74d..2d1c20b61db27f39cef73bf4951ba187cd43f848 100644 (file)
@@ -48,10 +48,10 @@ using namespace rfb;
 static LogWriter vlog("CConnection");
 
 CConnection::CConnection()
-  : csecurity(0),
+  : csecurity(nullptr),
     supportsLocalCursor(false), supportsCursorPosition(false),
     supportsDesktopResize(false), supportsLEDState(false),
-    is(0), os(0), reader_(0), writer_(0),
+    is(nullptr), os(nullptr), reader_(nullptr), writer_(nullptr),
     shared(false),
     state_(RFBSTATE_UNINITIALISED),
     pendingPFChange(false), preferredEncoding(encodingTight),
@@ -59,7 +59,7 @@ CConnection::CConnection()
     formatChange(false), encodingChange(false),
     firstUpdate(true), pendingUpdate(false), continuousUpdates(false),
     forceNonincremental(true),
-    framebuffer(NULL), decoder(this),
+    framebuffer(nullptr), decoder(this),
     hasRemoteClipboard(false), hasLocalClipboard(false)
 {
 }
@@ -71,7 +71,7 @@ CConnection::~CConnection()
 
 void CConnection::setServerName(const char* name_)
 {
-  if (name_ == NULL)
+  if (name_ == nullptr)
     name_ = "";
   serverName = name_;
 }
@@ -91,7 +91,7 @@ void CConnection::setFramebuffer(ModifiablePixelBuffer* fb)
     assert(fb->height() == server.height());
   }
 
-  if ((framebuffer != NULL) && (fb != NULL)) {
+  if ((framebuffer != nullptr) && (fb != nullptr)) {
     Rect rect;
 
     const uint8_t* data;
@@ -399,13 +399,13 @@ void CConnection::close()
     vlog.error("%s", e.str());
   }
 
-  setFramebuffer(NULL);
+  setFramebuffer(nullptr);
   delete csecurity;
-  csecurity = NULL;
+  csecurity = nullptr;
   delete reader_;
-  reader_ = NULL;
+  reader_ = nullptr;
   delete writer_;
-  writer_ = NULL;
+  writer_ = nullptr;
 }
 
 void CConnection::setDesktopSize(int w, int h)
@@ -420,7 +420,7 @@ void CConnection::setDesktopSize(int w, int h)
                                            server.height());
 
   resizeFramebuffer();
-  assert(framebuffer != NULL);
+  assert(framebuffer != nullptr);
   assert(framebuffer->width() == server.width());
   assert(framebuffer->height() == server.height());
 }
@@ -440,7 +440,7 @@ void CConnection::setExtendedDesktopSize(unsigned reason,
                                            server.height());
 
   resizeFramebuffer();
-  assert(framebuffer != NULL);
+  assert(framebuffer != nullptr);
   assert(framebuffer->width() == server.width());
   assert(framebuffer->height() == server.height());
 }
@@ -471,7 +471,7 @@ void CConnection::serverInit(int width, int height,
   vlog.debug("initialisation done");
 
   initDone();
-  assert(framebuffer != NULL);
+  assert(framebuffer != nullptr);
   assert(framebuffer->width() == server.width());
   assert(framebuffer->height() == server.height());
 
@@ -501,7 +501,7 @@ void CConnection::framebufferUpdateStart()
 {
   CMsgHandler::framebufferUpdateStart();
 
-  assert(framebuffer != NULL);
+  assert(framebuffer != nullptr);
 
   // Note: This might not be true if continuous updates are supported
   pendingUpdate = false;
index 006645df42c51857708833a61a20d49d3c74b906..c10b7033aa79a17a98186021f5f765613c592c58 100644 (file)
@@ -385,7 +385,7 @@ bool CMsgReader::readExtendedClipboard(int32_t len)
     }
 
     zis.flushUnderlying();
-    zis.setUnderlying(NULL, 0);
+    zis.setUnderlying(nullptr, 0);
 
     handler->handleClipboardProvide(flags, lengths, buffers);
 
index e941aaa7eb1cb912cf1926b9d59130aeba24a84d..8e3f1c27e1f56414e0aabb0cd74f98e69aac48b2 100644 (file)
@@ -192,7 +192,7 @@ void CMsgWriter::writePointerEvent(const Point& pos, int buttonMask)
 
 void CMsgWriter::writeClientCutText(const char* str)
 {
-  if (strchr(str, '\r') != NULL)
+  if (strchr(str, '\r') != nullptr)
     throw Exception("Invalid carriage return in clipboard data");
 
   std::string latin1(utf8ToLatin1(str));
index 5a4bc9c9b1419368816e5c9ffd0cf390482657a6..832574a0bddcb3a5a893754669c393c64adc200e 100644 (file)
@@ -61,9 +61,9 @@ CSecurityRSAAES::CSecurityRSAAES(CConnection* cc, uint32_t _secType,
   : CSecurity(cc), state(ReadPublicKey),
     keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType),
     clientKey(), clientPublicKey(), serverKey(),
-    serverKeyN(NULL), serverKeyE(NULL),
-    clientKeyN(NULL), clientKeyE(NULL),
-    rais(NULL), raos(NULL), rawis(NULL), rawos(NULL)
+    serverKeyN(nullptr), serverKeyE(nullptr),
+    clientKeyN(nullptr), clientKeyE(nullptr),
+    rais(nullptr), raos(nullptr), rawis(nullptr), rawos(nullptr)
 {
   assert(keySize == 128 || keySize == 256);
 }
@@ -154,7 +154,8 @@ void CSecurityRSAAES::writePublicKey()
   // set e = 65537
   mpz_set_ui(clientPublicKey.e, 65537);
   if (!rsa_generate_keypair(&clientPublicKey, &clientKey,
-                            &rs, random_func, NULL, NULL, clientKeyLength, 0))
+                            &rs, random_func, nullptr, nullptr,
+                            clientKeyLength, 0))
     throw AuthFailureException("failed to generate key");
   clientKeyN = new uint8_t[rsaKeySize];
   clientKeyE = new uint8_t[rsaKeySize];
@@ -413,10 +414,10 @@ void CSecurityRSAAES::clearSecrets()
   delete[] serverKeyE;
   delete[] clientKeyN;
   delete[] clientKeyE;
-  serverKeyN = NULL;
-  serverKeyE = NULL;
-  clientKeyN = NULL;
-  clientKeyE = NULL;
+  serverKeyN = nullptr;
+  serverKeyE = nullptr;
+  clientKeyN = nullptr;
+  clientKeyE = nullptr;
   memset(serverRandom, 0, sizeof(serverRandom));
   memset(clientRandom, 0, sizeof(clientRandom));
 }
@@ -439,7 +440,7 @@ void CSecurityRSAAES::writeCredentials()
   if (subtype == secTypeRA2UserPass)
     (CSecurity::upg)->getUserPasswd(isSecure(), &username, &password);
   else
-    (CSecurity::upg)->getUserPasswd(isSecure(), NULL, &password);
+    (CSecurity::upg)->getUserPasswd(isSecure(), nullptr, &password);
 
   if (subtype == secTypeRA2UserPass) {
     if (username.size() > 255)
index 56ac3fea6f8c3fc94a9b14dd772e58d352cc0210..8eadc1518a5c9e275b8cab57f9bfbf5fe53e57f9 100644 (file)
@@ -28,7 +28,7 @@ namespace rfb {
   class CSecurityStack : public CSecurity {
   public:
     CSecurityStack(CConnection* cc, int Type,
-                   CSecurity* s0 = NULL, CSecurity* s1 = NULL);
+                   CSecurity* s0 = nullptr, CSecurity* s1 = nullptr);
     ~CSecurityStack();
     virtual bool processMsg();
     virtual int getType() const {return type;};
index 11e6dfe3b4fc161806ded664324f14987f15862c..0633dbce86485431c63b82e78939c2c38e2cc902 100644 (file)
@@ -75,7 +75,7 @@ static const char* configdirfn(const char* fn)
   const char* configdir;
 
   configdir = os::getvncconfigdir();
-  if (configdir == NULL)
+  if (configdir == nullptr)
     return "";
 
   snprintf(full_path, sizeof(full_path), "%s/%s", configdir, fn);
@@ -83,8 +83,10 @@ static const char* configdirfn(const char* fn)
 }
 
 CSecurityTLS::CSecurityTLS(CConnection* cc, bool _anon)
-  : CSecurity(cc), session(NULL), anon_cred(NULL), cert_cred(NULL),
-    anon(_anon), tlsis(NULL), tlsos(NULL), rawis(NULL), rawos(NULL)
+  : CSecurity(cc), session(nullptr),
+    anon_cred(nullptr), cert_cred(nullptr),
+    anon(_anon), tlsis(nullptr), tlsos(nullptr),
+    rawis(nullptr), rawos(nullptr)
 {
   if (gnutls_global_init() != GNUTLS_E_SUCCESS)
     throw AuthFailureException("gnutls_global_init failed");
@@ -103,32 +105,32 @@ void CSecurityTLS::shutdown()
 
   if (anon_cred) {
     gnutls_anon_free_client_credentials(anon_cred);
-    anon_cred = 0;
+    anon_cred = nullptr;
   }
 
   if (cert_cred) {
     gnutls_certificate_free_credentials(cert_cred);
-    cert_cred = 0;
+    cert_cred = nullptr;
   }
 
   if (rawis && rawos) {
     cc->setStreams(rawis, rawos);
-    rawis = NULL;
-    rawos = NULL;
+    rawis = nullptr;
+    rawos = nullptr;
   }
 
   if (tlsis) {
     delete tlsis;
-    tlsis = NULL;
+    tlsis = nullptr;
   }
   if (tlsos) {
     delete tlsos;
-    tlsos = NULL;
+    tlsos = nullptr;
   }
 
   if (session) {
     gnutls_deinit(session);
-    session = 0;
+    session = nullptr;
   }
 }
 
@@ -206,7 +208,7 @@ void CSecurityTLS::setParam()
 
     prio = (char*)malloc(strlen(Security::GnuTLSPriority) +
                          strlen(kx_anon_priority) + 1);
-    if (prio == NULL)
+    if (prio == nullptr)
       throw AuthFailureException("Not enough memory for GnuTLS priority string");
 
     strcpy(prio, Security::GnuTLSPriority);
@@ -242,7 +244,7 @@ void CSecurityTLS::setParam()
 
     prio = (char*)malloc(strlen(gnutls_default_priority) +
                          strlen(kx_anon_priority) + 1);
-    if (prio == NULL)
+    if (prio == nullptr)
       throw AuthFailureException("Not enough memory for GnuTLS priority string");
 
     strcpy(prio, gnutls_default_priority);
@@ -385,7 +387,7 @@ void CSecurityTLS::checkSession()
   /* Certificate has some user overridable problems, so TOFU time */
 
   hostsDir = os::getvncstatedir();
-  if (hostsDir == NULL) {
+  if (hostsDir == nullptr) {
     throw AuthFailureException("Could not obtain VNC state directory "
                                "path for known hosts storage");
   }
@@ -393,8 +395,8 @@ void CSecurityTLS::checkSession()
   std::string dbPath;
   dbPath = (std::string)hostsDir + "/x509_known_hosts";
 
-  err = gnutls_verify_stored_pubkey(dbPath.c_str(), NULL,
-                                    client->getServerName(), NULL,
+  err = gnutls_verify_stored_pubkey(dbPath.c_str(), nullptr,
+                                    client->getServerName(), nullptr,
                                     GNUTLS_CRT_X509, &cert_list[0], 0);
 
   /* Previously known? */
@@ -648,8 +650,9 @@ void CSecurityTLS::checkSession()
     }
   }
 
-  if (gnutls_store_pubkey(dbPath.c_str(), NULL, client->getServerName(),
-                          NULL, GNUTLS_CRT_X509, &cert_list[0], 0, 0))
+  if (gnutls_store_pubkey(dbPath.c_str(), nullptr,
+                          client->getServerName(), nullptr,
+                          GNUTLS_CRT_X509, &cert_list[0], 0, 0))
     vlog.error("Failed to store server certificate to known hosts database");
 
   vlog.info("Exception added for server host");
index 3c8e91ba4dbc4a6606fcf47af75b48a5a04f9cb8..ef149c4399b7bc8aecd308cdf8a0a493c6697bff 100644 (file)
@@ -41,7 +41,7 @@ using namespace std;
 static LogWriter vlog("CVeNCrypt");
 
 CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec)
-  : CSecurity(cc), csecurity(NULL), security(sec)
+  : CSecurity(cc), csecurity(nullptr), security(sec)
 {
   haveRecvdMajorVersion = false;
   haveRecvdMinorVersion = false;
@@ -54,7 +54,7 @@ CSecurityVeNCrypt::CSecurityVeNCrypt(CConnection* cc, SecurityClient* sec)
   minorVersion = 0;
   chosenType = secTypeVeNCrypt;
   nAvailableTypes = 0;
-  availableTypes = NULL;
+  availableTypes = nullptr;
 }
 
 CSecurityVeNCrypt::~CSecurityVeNCrypt()
index f6a5e07a656ffb3927db2c0f05a6b195bee4e9a7..e5f842baacd34e5e3b67450b6ab6177b8fb8f4d1 100644 (file)
@@ -54,7 +54,7 @@ bool CSecurityVncAuth::processMsg()
   uint8_t challenge[vncAuthChallengeSize];
   is->readBytes(challenge, vncAuthChallengeSize);
   std::string passwd;
-  (CSecurity::upg)->getUserPasswd(cc->isSecure(), 0, &passwd);
+  (CSecurity::upg)->getUserPasswd(cc->isSecure(), nullptr, &passwd);
 
   // Calculate the correct response
   uint8_t key[8];
index ade990181c509f3260d11f8d7e0829d71fd879d6..bc20c3d7261a965eb7a1e4521349aec0732cd0fe 100644 (file)
@@ -39,7 +39,7 @@ ClientParams::ClientParams()
 {
   setName("");
 
-  cursor_ = new Cursor(0, 0, Point(), NULL);
+  cursor_ = new Cursor(0, 0, Point(), nullptr);
 
   clipFlags = clipboardUTF8 | clipboardRTF | clipboardHTML |
               clipboardRequest | clipboardNotify | clipboardProvide;
index 1c215c7f14f4e551818491fb90c871c9d7a80c8c..a423770d770aa1b4bed905500144876a45fa9b9f 100644 (file)
@@ -48,9 +48,9 @@ static LogWriter vlog("Config");
 
 
 // -=- The Global/server/viewer Configuration objects
-Configuration* Configuration::global_ = 0;
-Configuration* Configuration::server_ = 0;
-Configuration* Configuration::viewer_ = 0;
+Configuration* Configuration::global_ = nullptr;
+Configuration* Configuration::server_ = nullptr;
+Configuration* Configuration::viewer_ = nullptr;
 
 Configuration* Configuration::global() {
   if (!global_)
@@ -127,7 +127,7 @@ VoidParameter* Configuration::get(const char* param)
       return current;
     current = current->_next;
   }
-  return _next ? _next->get(param) : 0;
+  return _next ? _next->get(param) : nullptr;
 }
 
 void Configuration::list(int width, int nameWidth) {
@@ -195,7 +195,7 @@ VoidParameter::VoidParameter(const char* name_, const char* desc_,
                             ConfigurationObject co)
   : immutable(false), name(name_), description(desc_)
 {
-  Configuration *conf = NULL;
+  Configuration *conf = nullptr;
 
   switch (co) {
   case ConfGlobal: conf = Configuration::global();
@@ -339,7 +339,7 @@ IntParameter::IntParameter(const char* name_, const char* desc_, int v,
 bool
 IntParameter::setParam(const char* v) {
   if (immutable) return true;
-  return setParam(strtol(v, NULL, 0));
+  return setParam(strtol(v, nullptr, 0));
 }
 
 bool
@@ -410,7 +410,8 @@ StringParameter::operator const char *() const {
 
 BinaryParameter::BinaryParameter(const char* name_, const char* desc_,
                                 const uint8_t* v, size_t l, ConfigurationObject co)
-: VoidParameter(name_, desc_, co), value(0), length(0), def_value(0), def_length(0) {
+: VoidParameter(name_, desc_, co),
+  value(nullptr), length(0), def_value(nullptr), def_length(0) {
   if (l) {
     assert(v);
     value = new uint8_t[l];
@@ -440,7 +441,7 @@ void BinaryParameter::setParam(const uint8_t* v, size_t len) {
   if (immutable) return; 
   vlog.debug("set %s(Binary)", getName());
   delete [] value;
-  value = NULL;
+  value = nullptr;
   length = 0;
   if (len) {
     assert(v);
index d73d8005277d18ae16273f2ee1b4f04cb8d2752a..0c572cfa5eaee861cdd15d1f652332ae8e962381 100644 (file)
@@ -64,7 +64,8 @@ namespace rfb {
   class Configuration {
   public:
     // - Create a new Configuration object
-    Configuration(const char* name_) : name(name_), head(0), _next(0) {}
+    Configuration(const char* name_)
+      : name(name_), head(nullptr), _next(nullptr) {}
 
     // - Return the buffer containing the Configuration's name
     const char* getName() const { return name.c_str(); }
index 1e252165e74f664571c6cf6f2ea4fcfec9f8c539..94f07055dec6fad42e2ebc508929fdc24e76dff8 100644 (file)
@@ -85,11 +85,11 @@ Congestion::Congestion() :
     baseRTT(-1), congWindow(INITIAL_WINDOW), inSlowStart(true),
     safeBaseRTT(-1), measurements(0), minRTT(-1), minCongestedRTT(-1)
 {
-  gettimeofday(&lastUpdate, NULL);
-  gettimeofday(&lastSent, NULL);
+  gettimeofday(&lastUpdate, nullptr);
+  gettimeofday(&lastSent, nullptr);
   memset(&lastPong, 0, sizeof(lastPong));
-  gettimeofday(&lastPongArrival, NULL);
-  gettimeofday(&lastAdjustment, NULL);
+  gettimeofday(&lastPongArrival, nullptr);
+  gettimeofday(&lastAdjustment, nullptr);
 }
 
 Congestion::~Congestion()
@@ -101,7 +101,7 @@ void Congestion::updatePosition(unsigned pos)
   struct timeval now;
   unsigned delta, consumed;
 
-  gettimeofday(&now, NULL);
+  gettimeofday(&now, nullptr);
 
   delta = pos - lastPosition;
   if ((delta > 0) || (extraBuffer > 0))
@@ -121,7 +121,7 @@ void Congestion::updatePosition(unsigned pos)
     congWindow = __rfbmin(INITIAL_WINDOW, congWindow);
     baseRTT = -1;
     measurements = 0;
-    gettimeofday(&lastAdjustment, NULL);
+    gettimeofday(&lastAdjustment, nullptr);
     minRTT = minCongestedRTT = -1;
     inSlowStart = true;
   }
@@ -149,7 +149,7 @@ void Congestion::sentPing()
 
   memset(&rttInfo, 0, sizeof(struct RTTInfo));
 
-  gettimeofday(&rttInfo.tv, NULL);
+  gettimeofday(&rttInfo.tv, nullptr);
   rttInfo.pos = lastPosition;
   rttInfo.extra = getExtraBuffer();
   rttInfo.congested = isCongested();
@@ -166,7 +166,7 @@ void Congestion::gotPong()
   if (pings.empty())
     return;
 
-  gettimeofday(&now, NULL);
+  gettimeofday(&now, nullptr);
 
   rttInfo = pings.front();
   pings.pop_front();
@@ -320,7 +320,7 @@ void Congestion::debugTrace(const char* filename, int fd)
 #ifdef __linux__
   FILE *f;
   f = fopen(filename, "ab");
-  if (f != NULL) {
+  if (f != nullptr) {
     struct tcp_info info;
     int buffered;
     socklen_t len;
@@ -329,7 +329,7 @@ void Congestion::debugTrace(const char* filename, int fd)
                     TCP_INFO, &info, &len) == 0) &&
         (ioctl(fd, SIOCOUTQ, &buffered) == 0)) {
       struct timeval now;
-      gettimeofday(&now, NULL);
+      gettimeofday(&now, nullptr);
       fprintf(f, "%u.%06u,%u,%u,%u,%u\n",
               (unsigned)now.tv_sec, (unsigned)now.tv_usec,
               congWindow, info.tcpi_snd_cwnd * info.tcpi_snd_mss,
@@ -494,7 +494,7 @@ void Congestion::updateCongestion()
 #endif
 
   measurements = 0;
-  gettimeofday(&lastAdjustment, NULL);
+  gettimeofday(&lastAdjustment, nullptr);
   minRTT = minCongestedRTT = -1;
 }
 
index e39a39433177d148440d705df96cc05500171af6..1e71b8b9837ff0b394a26007a5ab52142bc31a32 100644 (file)
@@ -41,7 +41,7 @@ using namespace rfb;
 static LogWriter vlog("DecodeManager");
 
 DecodeManager::DecodeManager(CConnection *conn) :
-  conn(conn), threadException(NULL)
+  conn(conn), threadException(nullptr)
 {
   size_t cpuCount;
 
@@ -110,7 +110,7 @@ bool DecodeManager::decodeRect(const Rect& r, int encoding,
 
   QueueEntry *entry;
 
-  assert(pb != NULL);
+  assert(pb != nullptr);
 
   if (!Decoder::supported(encoding)) {
     vlog.error("Unknown encoding %d", encoding);
@@ -247,7 +247,7 @@ void DecodeManager::setThreadException(const rdr::Exception& e)
 {
   os::AutoMutex a(queueMutex);
 
-  if (threadException != NULL)
+  if (threadException != nullptr)
     return;
 
   threadException = new rdr::Exception("Exception on worker thread: %s", e.str());
@@ -257,13 +257,13 @@ void DecodeManager::throwThreadException()
 {
   os::AutoMutex a(queueMutex);
 
-  if (threadException == NULL)
+  if (threadException == nullptr)
     return;
 
   rdr::Exception e(*threadException);
 
   delete threadException;
-  threadException = NULL;
+  threadException = nullptr;
 
   throw e;
 }
@@ -305,7 +305,7 @@ void DecodeManager::DecodeThread::worker()
 
     // Look for an available entry in the work queue
     entry = findEntry();
-    if (entry == NULL) {
+    if (entry == nullptr) {
       // Wait and try again
       manager->consumerCond->wait();
       continue;
@@ -351,7 +351,7 @@ DecodeManager::QueueEntry* DecodeManager::DecodeThread::findEntry()
   Region lockedRegion;
 
   if (manager->workQueue.empty())
-    return NULL;
+    return nullptr;
 
   if (!manager->workQueue.front()->active)
     return manager->workQueue.front();
@@ -405,5 +405,5 @@ next:
     lockedRegion.assign_union(entry->affectedRegion);
   }
 
-  return NULL;
+  return nullptr;
 }
index 78c54ec3cf954ea091c8bf318c17d11241572730..a6d9b17c6749096c8e73ae1a6df16f2d24e06163 100644 (file)
@@ -103,6 +103,6 @@ Decoder* Decoder::createDecoder(int encoding)
     return new H264Decoder();
 #endif
   default:
-    return NULL;
+    return nullptr;
   }
 }
index c2658a70a31098bbc60d8e6fee21a74fceaa2793..7a15e0c2442d4133d71c0da411751eb603856b5c 100644 (file)
@@ -138,7 +138,7 @@ EncodeManager::EncodeManager(SConnection* conn_)
 {
   StatsVector::iterator iter;
 
-  encoders.resize(encoderClassMax, NULL);
+  encoders.resize(encoderClassMax, nullptr);
   activeEncoders.resize(encoderTypeMax, encoderRaw);
 
   encoders[encoderRaw] = new RawEncoder(conn);
@@ -332,7 +332,7 @@ void EncodeManager::doUpdate(bool allowLossy, const Region& changed_,
      * We need to render the cursor seperately as it has its own
      * magical pixel buffer, so split it out from the changed region.
      */
-    if (renderedCursor != NULL) {
+    if (renderedCursor != nullptr) {
       cursorRegion = changed.intersect(renderedCursor->getEffectiveRect());
       changed.assign_subtract(renderedCursor->getEffectiveRect());
     }
index f18554ef3e5661e657f6470da4be1c89c6bc56e1..1f79c4ff96f958f1e343be0e0ef947a8dc3b82d9 100644 (file)
@@ -62,7 +62,7 @@ H264DecoderContext* H264Decoder::findContext(const Rect& r)
   for (std::deque<H264DecoderContext*>::iterator it = contexts.begin(); it != contexts.end(); it++)
     if ((*it)->isEqualRect(r))
       return *it;
-  return NULL;
+  return nullptr;
 }
 
 bool H264Decoder::readRect(const Rect& /*r*/,
@@ -102,7 +102,7 @@ void H264Decoder::decodeRect(const Rect& r, const uint8_t* buffer,
   uint32_t len = is.readU32();
   uint32_t flags = is.readU32();
 
-  H264DecoderContext* ctx = NULL;
+  H264DecoderContext* ctx = nullptr;
   if (flags & resetAllContexts)
   {
     resetContexts();
index 8697a5a57528ab29652871bf4157fedb043feca6..5bd1dbbf4d4dc12f64e1f1a6eb7ad499307f7ed5 100644 (file)
@@ -42,9 +42,9 @@ static LogWriter vlog("H264LibavDecoderContext");
 bool H264LibavDecoderContext::initCodec() {
   os::AutoMutex lock(&mutex);
 
-  sws = NULL;
-  swsBuffer = NULL;
-  h264WorkBuffer = NULL;
+  sws = nullptr;
+  swsBuffer = nullptr;
+  h264WorkBuffer = nullptr;
   h264WorkBufferLength = 0;
 
   const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_H264);
@@ -78,7 +78,7 @@ bool H264LibavDecoderContext::initCodec() {
     return false;
   }
 
-  if (avcodec_open2(avctx, codec, NULL) < 0)
+  if (avcodec_open2(avctx, codec, nullptr) < 0)
   {
     av_parser_close(parser);
     avcodec_free_context(&avctx);
@@ -117,7 +117,7 @@ uint8_t* H264LibavDecoderContext::makeH264WorkBuffer(const uint8_t* buffer, uint
   if (!h264WorkBuffer || reserve_len > h264WorkBufferLength)
   {
     h264WorkBuffer = (uint8_t*)realloc(h264WorkBuffer, reserve_len);
-    if (h264WorkBuffer == NULL) {
+    if (h264WorkBuffer == nullptr) {
       throw Exception("H264LibavDecoderContext: Unable to allocate memory");
     }
     h264WorkBufferLength = reserve_len;
@@ -204,7 +204,7 @@ void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer,
 
 #ifdef FFMPEG_INIT_PACKET_DEPRECATED
   packet->size = 0;
-  packet->data = NULL;
+  packet->data = nullptr;
   av_packet_free(&packet);
 #else
   delete packet;
@@ -218,7 +218,7 @@ void H264LibavDecoderContext::decode(const uint8_t* h264_in_buffer,
 
   sws = sws_getCachedContext(sws, frame->width, frame->height, avctx->pix_fmt,
                              frame->width, frame->height, AV_PIX_FMT_RGB32,
-                             0, NULL, NULL, NULL);
+                             0, nullptr, nullptr, nullptr);
 
   int stride;
   pb->getBuffer(rect, &stride);
index bb29edb603d2242895034a9755426e8b02e000f5..e21965200b2e46d6b30d8e7f191c81a7085015c8 100644 (file)
@@ -21,7 +21,7 @@
 #include <mfapi.h>
 #include <mferror.h>
 #include <wmcodecdsp.h>
-#define SAFE_RELEASE(obj) if (obj) { obj->Release(); obj = NULL; }
+#define SAFE_RELEASE(obj) if (obj) { obj->Release(); obj = nullptr; }
 
 #include <os/Mutex.h>
 #include <rfb/LogWriter.h>
@@ -41,17 +41,17 @@ bool H264WinDecoderContext::initCodec() {
     return false;
   }
 
-  if (FAILED(CoCreateInstance(CLSID_CMSH264DecoderMFT, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&decoder)))
+  if (FAILED(CoCreateInstance(CLSID_CMSH264DecoderMFT, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&decoder)))
   {
     vlog.error("MediaFoundation H264 codec not found");
     return false;
   }
 
   GUID CLSID_VideoProcessorMFT = { 0x88753b26, 0x5b24, 0x49bd, { 0xb2, 0xe7, 0xc, 0x44, 0x5c, 0x78, 0xc9, 0x82 } };
-  if (FAILED(CoCreateInstance(CLSID_VideoProcessorMFT, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
+  if (FAILED(CoCreateInstance(CLSID_VideoProcessorMFT, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
   {
     vlog.error("Cannot create MediaFoundation Video Processor (available only on Windows 8+). Trying ColorConvert DMO.");
-    if (FAILED(CoCreateInstance(CLSID_CColorConvertDMO, NULL, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
+    if (FAILED(CoCreateInstance(CLSID_CColorConvertDMO, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (LPVOID*)&converter)))
     {
       decoder->Release();
       vlog.error("ColorConvert DMO not found");
@@ -87,7 +87,7 @@ bool H264WinDecoderContext::initCodec() {
 
   // set decoder output type (NV12)
   DWORD output_index = 0;
-  IMFMediaType* output_type = NULL;
+  IMFMediaType* output_type = nullptr;
   while (SUCCEEDED(decoder->GetOutputAvailableType(0, output_index++, &output_type)))
   {
     GUID subtype;
@@ -175,7 +175,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
   }
 
   BYTE* locked;
-  input_buffer->Lock(&locked, NULL, NULL);
+  input_buffer->Lock(&locked, nullptr, nullptr);
   memcpy(locked, h264_buffer, len);
   input_buffer->Unlock();
 
@@ -203,7 +203,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
     decoded_data.dwStreamID = 0;
     decoded_data.pSample = decoded_sample;
     decoded_data.dwStatus = 0;
-    decoded_data.pEvents = NULL;
+    decoded_data.pEvents = nullptr;
 
     DWORD status;
     HRESULT hr = decoder->ProcessOutput(0, 1, &decoded_data, &status);
@@ -232,7 +232,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
       // need to setup output type and try decoding again
 
       DWORD output_index = 0;
-      IMFMediaType* output_type = NULL;
+      IMFMediaType* output_type = nullptr;
       while (SUCCEEDED(decoder->GetOutputAvailableType(0, output_index++, &output_type)))
       {
         GUID subtype;
@@ -242,7 +242,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
           break;
         }
         output_type->Release();
-        output_type = NULL;
+        output_type = nullptr;
       }
 
       // reinitialize output type (NV12) that now has correct properties (width/height/framerate)
@@ -327,7 +327,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
     converted_data.dwStreamID = 0;
     converted_data.pSample = converted_sample;
     converted_data.dwStatus = 0;
-    converted_data.pEvents = NULL;
+    converted_data.pEvents = nullptr;
 
     DWORD status;
     HRESULT hr = converter->ProcessOutput(0, 1, &converted_data, &status);
@@ -343,7 +343,7 @@ void H264WinDecoderContext::decode(const uint8_t* h264_buffer,
 
       BYTE* out;
       DWORD len;
-      converted_buffer->Lock(&out, NULL, &len);
+      converted_buffer->Lock(&out, nullptr, &len);
       pb->imageRect(rect, out + offset_y * stride + offset_x * 4, (int)stride / 4);
       converted_buffer->Unlock();
     }
index de51576ce2510a6508dcbe2fd816ef44b6f3c3ec..702d8dd6871da7b38c082aab0383efaec798fdf3 100644 (file)
@@ -48,14 +48,14 @@ namespace rfb {
       uint32_t crop_height = 0;
       uint32_t offset_x = 0;
       uint32_t offset_y = 0;
-      IMFTransform *decoder = NULL;
-      IMFTransform *converter = NULL;
-      IMFSample *input_sample = NULL;
-      IMFSample *decoded_sample = NULL;
-      IMFSample *converted_sample = NULL;
-      IMFMediaBuffer *input_buffer = NULL;
-      IMFMediaBuffer *decoded_buffer = NULL;
-      IMFMediaBuffer *converted_buffer = NULL;
+      IMFTransform *decoder = nullptr;
+      IMFTransform *converter = nullptr;
+      IMFSample *input_sample = nullptr;
+      IMFSample *decoded_sample = nullptr;
+      IMFSample *converted_sample = nullptr;
+      IMFMediaBuffer *input_buffer = nullptr;
+      IMFMediaBuffer *decoded_buffer = nullptr;
+      IMFMediaBuffer *converted_buffer = nullptr;
 
       void ParseSPS(const uint8_t* buffer, int length);
   };
index a63cf1fb1ff2cd448d997243358e07c5de529f58..729043f018432fe8ad20b18de7ee42b920fb2c78 100644 (file)
@@ -365,7 +365,7 @@ class HextileTile {
 
 template<class T>
 HextileTile<T>::HextileTile()
-  : m_tile(NULL), m_width(0), m_height(0),
+  : m_tile(nullptr), m_width(0), m_height(0),
     m_size(0), m_flags(0), m_background(0), m_foreground(0),
     m_numSubrects(0)
 {
index 1971e343177c46e2ee4b72f068eba2a7a04c8023..a09cca3f5f765142584f5a18e7c631e0fe428fca 100644 (file)
@@ -29,7 +29,7 @@
 namespace rfb {
 
   static bool isAllSpace(const char *string) {
-    if (string == NULL)
+    if (string == nullptr)
       return false;
     while(*string != '\0') {
       if (! isspace(*string))
@@ -46,7 +46,7 @@ namespace rfb {
     const char* hostEnd;
     const char* portStart;
 
-    if (hi == NULL)
+    if (hi == nullptr)
       throw rdr::Exception("NULL host specified");
 
     // Trim leading whitespace
@@ -59,19 +59,19 @@ namespace rfb {
     if (hi[0] == '[') {
       hostStart = &hi[1];
       hostEnd = strchr(hostStart, ']');
-      if (hostEnd == NULL)
+      if (hostEnd == nullptr)
         throw rdr::Exception("unmatched [ in host");
 
       portStart = hostEnd + 1;
       if (isAllSpace(portStart))
-        portStart = NULL;
+        portStart = nullptr;
     } else {
       hostStart = &hi[0];
       hostEnd = strrchr(hostStart, ':');
 
-      if (hostEnd == NULL) {
+      if (hostEnd == nullptr) {
         hostEnd = hostStart + strlen(hostStart);
-        portStart = NULL;
+        portStart = nullptr;
       } else {
         if ((hostEnd > hostStart) && (hostEnd[-1] == ':'))
           hostEnd--;
@@ -79,7 +79,7 @@ namespace rfb {
         if (portStart != hostEnd) {
           // We found more : in the host. This is probably an IPv6 address
           hostEnd = hostStart + strlen(hostStart);
-          portStart = NULL;
+          portStart = nullptr;
         }
       }
     }
@@ -93,7 +93,7 @@ namespace rfb {
     else
       *host = std::string(hostStart, hostEnd - hostStart);
 
-    if (portStart == NULL)
+    if (portStart == nullptr)
       *port = basePort;
     else {
       char* end;
index a4dd5f3937c907f80aa3e00015e1798ba81e8a5b..42d5c475bf16c5612acd28ab1505a76d4d87c076 100644 (file)
@@ -162,9 +162,9 @@ void JpegCompressor::compress(const uint8_t *buf, volatile int stride,
   int w = r.width();
   int h = r.height();
   int pixelsize;
-  uint8_t * volatile srcBuf = NULL;
+  uint8_t * volatile srcBuf = nullptr;
   volatile bool srcBufIsTemp = false;
-  JSAMPROW * volatile rowPointer = NULL;
+  JSAMPROW * volatile rowPointer = nullptr;
 
   if(setjmp(err->jmpBuffer)) {
     // this will execute if libjpeg has an error
index 44c54fb23e3b083c4a9d27aa59e4fdade383d5fc..92ef014faf69138fd0b1c524b0a34640951a0df9 100644 (file)
@@ -159,9 +159,9 @@ void JpegDecompressor::decompress(const uint8_t *jpegBuf,
   int h = r.height();
   int pixelsize;
   int dstBufStride;
-  uint8_t * volatile dstBuf = NULL;
+  uint8_t * volatile dstBuf = nullptr;
   volatile bool dstBufIsTemp = false;
-  JSAMPROW * volatile rowPointer = NULL;
+  JSAMPROW * volatile rowPointer = nullptr;
 
   if(setjmp(err->jmpBuffer)) {
     // this will execute if libjpeg has an error
index dc9db9d1aa19b2147f0e103eeadb906e6fdc2466..b222d268ac562e65fe7affc8a56bc6cd57f7fcd5 100644 (file)
@@ -34,7 +34,8 @@ rfb::LogParameter rfb::logParams;
 using namespace rfb;
 
 
-LogWriter::LogWriter(const char* name) : m_name(name), m_level(0), m_log(0), m_next(log_writers) {
+LogWriter::LogWriter(const char* name)
+  : m_name(name), m_level(0), m_log(nullptr), m_next(log_writers) {
   log_writers = this;
 }
 
@@ -72,7 +73,7 @@ LogWriter::getLogWriter(const char* name) {
     if (strcasecmp(name, current->m_name) == 0) return current;
       current = current->m_next;
     }
-  return 0;
+  return nullptr;
 }
 
 bool LogWriter::setLogParams(const char* params) {
@@ -83,7 +84,7 @@ bool LogWriter::setLogParams(const char* params) {
     return false;
   }
   int level = atoi(parts[2].c_str());
-  Logger* logger = 0;
+  Logger* logger = nullptr;
   if (!parts[1].empty()) {
     logger = Logger::getLogger(parts[1].c_str());
     if (!logger)
index 7e0895e440c98598e453db321bc0a8be7361d6ac..25f7ccb7c7875a563bfe1f1ac1d5d5edc0ee1614 100644 (file)
 
 using namespace rfb;
 
-Logger* Logger::loggers = 0;
+Logger* Logger::loggers = nullptr;
 
-Logger::Logger(const char* name) : registered(false), m_name(name), m_next(0) {
+Logger::Logger(const char* name)
+  : registered(false), m_name(name), m_next(nullptr)
+{
 }
 
 Logger::~Logger() {
@@ -78,7 +80,7 @@ Logger::getLogger(const char* name) {
     if (strcasecmp(name, current->m_name) == 0) return current;
     current = current->m_next;
   }
-  return 0;
+  return nullptr;
 }
 
 void
index 099a35011772dff2d3164e3ed01cbbcc148254c9..eabe420a44d8e079d6bd2d0e11f80b0991d5425e 100644 (file)
@@ -33,7 +33,7 @@
 using namespace rfb;
 
 Logger_File::Logger_File(const char* loggerName)
-  : Logger(loggerName), indent(13), width(79), m_file(0),
+  : Logger(loggerName), indent(13), width(79), m_file(nullptr),
     m_lastLogTime(0)
 {
   m_filename[0] = '\0';
@@ -65,7 +65,7 @@ void Logger_File::write(int /*level*/, const char *logname, const char *message)
     if (!m_file) return;
   }
 
-  time_t current = time(0);
+  time_t current = time(nullptr);
   if (current != m_lastLogTime) {
     m_lastLogTime = current;
     fprintf(m_file, "\n%s", ctime(&m_lastLogTime));
@@ -115,7 +115,7 @@ void Logger_File::closeFile()
 {
   if (m_file) {
     fclose(m_file);
-    m_file = 0;
+    m_file = nullptr;
   }
 }
 
index 320ab4b0e9b268083fa094129d1cbf7cf35378e5..de9e425e2c567a8c85ca760962f6a87be508046e 100644 (file)
@@ -35,7 +35,7 @@ using namespace rfb;
 Logger_Syslog::Logger_Syslog(const char* loggerName)
   : Logger(loggerName)
 {
-  openlog(0, LOG_CONS | LOG_PID, LOG_USER);
+  openlog(nullptr, LOG_CONS | LOG_PID, LOG_USER);
 }
 
 Logger_Syslog::~Logger_Syslog()
index 6b8cc57e558c2faf2a7651328f69ee70da45c39b..d22af0dcce0b90ffce98c8dc229bf11cfe86750f 100644 (file)
@@ -75,10 +75,10 @@ inline bool rfb::Palette::insert(uint32_t colour, int numPixels)
   hash_key = genHash(colour);
 
   pnode = hash[hash_key];
-  prev_pnode = NULL;
+  prev_pnode = nullptr;
 
   // Do we already have an entry for this colour?
-  while (pnode != NULL) {
+  while (pnode != nullptr) {
     if (pnode->colour == colour) {
       // Yup
 
@@ -114,12 +114,12 @@ inline bool rfb::Palette::insert(uint32_t colour, int numPixels)
 
   // Create a new colour entry
   pnode = &list[numColours];
-  pnode->next = NULL;
+  pnode->next = nullptr;
   pnode->idx = 0;
   pnode->colour = colour;
 
   // Add it to the hash table
-  if (prev_pnode != NULL)
+  if (prev_pnode != nullptr)
     prev_pnode->next = pnode;
   else
     hash[hash_key] = pnode;
@@ -152,7 +152,7 @@ inline unsigned char rfb::Palette::lookup(uint32_t colour) const
   hash_key = genHash(colour);
   pnode = hash[hash_key];
 
-  while (pnode != NULL) {
+  while (pnode != nullptr) {
     if (pnode->colour == colour)
       return pnode->idx;
     pnode = pnode->next;
index c8b5f3d7cdcb56dc74456e7e4807fbdca90ec2c9..f1354a437c1b02627ae0914b28910008015cc2ee 100644 (file)
@@ -326,7 +326,7 @@ FullFramePixelBuffer::FullFramePixelBuffer(const PixelFormat& pf, int w, int h,
 {
 }
 
-FullFramePixelBuffer::FullFramePixelBuffer() : data(0) {}
+FullFramePixelBuffer::FullFramePixelBuffer() : data(nullptr) {}
 
 FullFramePixelBuffer::~FullFramePixelBuffer() {}
 
@@ -365,7 +365,7 @@ void FullFramePixelBuffer::setBuffer(int width, int height,
     throw rfb::Exception("Invalid PixelBuffer height of %d pixels requested", height);
   if ((stride_ < 0) || (stride_ > maxPixelBufferStride) || (stride_ < width))
     throw rfb::Exception("Invalid PixelBuffer stride of %d pixels requested", stride_);
-  if ((width != 0) && (height != 0) && (data_ == NULL))
+  if ((width != 0) && (height != 0) && (data_ == nullptr))
     throw rfb::Exception("PixelBuffer requested without a valid memory area");
 
   ModifiablePixelBuffer::setSize(width, height);
@@ -383,12 +383,12 @@ void FullFramePixelBuffer::setSize(int /*w*/, int /*h*/)
 // Automatically allocates enough space for the specified format & area
 
 ManagedPixelBuffer::ManagedPixelBuffer()
-  : data_(NULL), datasize(0)
+  : data_(nullptr), datasize(0)
 {
 }
 
 ManagedPixelBuffer::ManagedPixelBuffer(const PixelFormat& pf, int w, int h)
-  : FullFramePixelBuffer(pf, 0, 0, NULL, 0), data_(NULL), datasize(0)
+  : FullFramePixelBuffer(pf, 0, 0, nullptr, 0), data_(nullptr), datasize(0)
 {
   setSize(w, h);
 }
@@ -413,7 +413,7 @@ void ManagedPixelBuffer::setSize(int w, int h)
   if (datasize < new_datasize) {
     if (data_) {
       delete [] data_;
-      data_ = NULL;
+      data_ = nullptr;
       datasize = 0;
     }
     if (new_datasize) {
index 12ba0f1ab86f55b341677095812a7be5a870e0f8..8f109a0642d23db503372725d3f62d4d8a9895dd 100644 (file)
@@ -44,8 +44,8 @@ using namespace rfb;
 static LogWriter vlog("SConnection");
 
 SConnection::SConnection(AccessRights accessRights)
-  : readyForSetColourMapEntries(false),
-    is(0), os(0), reader_(0), writer_(0), ssecurity(0),
+  : readyForSetColourMapEntries(false), is(nullptr), os(nullptr),
+    reader_(nullptr), writer_(nullptr), ssecurity(nullptr),
     authFailureTimer(this, &SConnection::handleAuthFailureTimeout),
     state_(RFBSTATE_UNINITIALISED), preferredEncoding(encodingRaw),
     accessRights(accessRights), hasRemoteClipboard(false),
@@ -607,11 +607,11 @@ void SConnection::sendClipboardData(const char* data)
 void SConnection::cleanup()
 {
   delete ssecurity;
-  ssecurity = NULL;
+  ssecurity = nullptr;
   delete reader_;
-  reader_ = NULL;
+  reader_ = nullptr;
   delete writer_;
-  writer_ = NULL;
+  writer_ = nullptr;
 }
 
 void SConnection::writeFakeColourMap(void)
index 5bc616776fbc95bae8b6fad206c5aae9e8151209..fb3ae15ad1ac9bb6e454298f634ce7569509c003 100644 (file)
@@ -71,7 +71,7 @@ namespace rfb {
     // later, after queryConnection() has returned.  It can only be called when
     // in state RFBSTATE_QUERYING.  On rejection, an AuthFailureException is
     // thrown, so this must be handled appropriately by the caller.
-    void approveConnection(bool accept, const char* reason=0);
+    void approveConnection(bool accept, const char* reason=nullptr);
 
 
     // Methods to terminate the connection
index 94e4b0286c441a44f2ee7bc8b87bc2fd4fe9e7f9..b660f496b9ecaad3ea25d66c20d526636ac443f7 100644 (file)
@@ -124,14 +124,18 @@ namespace rfb {
   //     a plain black desktop of the specified format.
   class SStaticDesktop : public SDesktop {
   public:
-    SStaticDesktop(const Point& size) : server(0), buffer(0) {
+    SStaticDesktop(const Point& size)
+      : server(nullptr), buffer(nullptr)
+    {
       PixelFormat pf;
       const uint8_t black[4] = { 0, 0, 0, 0 };
       buffer = new ManagedPixelBuffer(pf, size.x, size.y);
       if (buffer)
         buffer->fillRect(buffer->getRect(), black);
     }
-    SStaticDesktop(const Point& size, const PixelFormat& pf) : buffer(0) {
+    SStaticDesktop(const Point& size, const PixelFormat& pf)
+      : buffer(nullptr)
+    {
       const uint8_t black[4] = { 0, 0, 0, 0 };
       buffer = new ManagedPixelBuffer(pf, size.x, size.y);
       if (buffer)
@@ -147,7 +151,7 @@ namespace rfb {
     }
     virtual void queryConnection(network::Socket* sock,
                                  const char* /*userName*/) {
-      server->approveConnection(sock, true, NULL);
+      server->approveConnection(sock, true, nullptr);
     }
 
   protected:
index 0792639a2e0c0e09d46ca8e59738233e2176fa25..9ddea53df6bf83f213feaf1cf89ac102f1277e1a 100644 (file)
@@ -418,7 +418,7 @@ bool SMsgReader::readExtendedClipboard(int32_t len)
     }
 
     zis.flushUnderlying();
-    zis.setUnderlying(NULL, 0);
+    zis.setUnderlying(nullptr, 0);
 
     handler->handleClipboardProvide(flags, lengths, buffers);
 
index 8592e6f4b833ce015ad92ee3b50ac6a832c7f136..43d978533b210bccebdbfe130dd96e4b7d5492f2 100644 (file)
@@ -93,7 +93,7 @@ void SMsgWriter::writeBell()
 
 void SMsgWriter::writeServerCutText(const char* str)
 {
-  if (strchr(str, '\r') != NULL)
+  if (strchr(str, '\r') != nullptr)
     throw Exception("Invalid carriage return in clipboard data");
 
   std::string latin1(utf8ToLatin1(str));
index f14d83a4b851f51fbae4c43117c5d3051a3023bb..019fc13319f6255b077dc802ffef100ba6aa7651 100644 (file)
@@ -31,7 +31,7 @@ namespace rfb {
     SSecurityNone(SConnection* sc) : SSecurity(sc) {}
     virtual bool processMsg() { return true; }
     virtual int getType() const {return secTypeNone;}
-    virtual const char* getUserName() const {return 0;}
+    virtual const char* getUserName() const {return nullptr;}
   };
 }
 #endif
index a100a7570b5d2b6923ebb38f4bc9b4c2877522c0..9bc07cb1810fc7008888ff664aee97bbef7e7a09 100644 (file)
@@ -75,7 +75,7 @@ SSecurityPlain::SSecurityPlain(SConnection* sc) : SSecurity(sc)
 #elif !defined(__APPLE__)
   valid = new UnixPasswordValidator();
 #else
-  valid = NULL;
+  valid = nullptr;
 #endif
 
   state = 0;
index cea62644119e3439c8783fec04f4647106177a48..64a8b5231b54c32a63347fc4fd5de90f2f22798a 100644 (file)
@@ -75,9 +75,10 @@ SSecurityRSAAES::SSecurityRSAAES(SConnection* sc, uint32_t _secType,
   : SSecurity(sc), state(SendPublicKey),
     keySize(_keySize), isAllEncrypted(_isAllEncrypted), secType(_secType),
     serverKey(), clientKey(),
-    serverKeyN(NULL), serverKeyE(NULL), clientKeyN(NULL), clientKeyE(NULL),
+    serverKeyN(nullptr), serverKeyE(nullptr),
+    clientKeyN(nullptr), clientKeyE(nullptr),
     accessRights(AccessDefault),
-    rais(NULL), raos(NULL), rawis(NULL), rawos(NULL)
+    rais(nullptr), raos(nullptr), rawis(nullptr), rawos(nullptr)
 {
   assert(keySize == 128 || keySize == 256);
 }
@@ -514,10 +515,10 @@ void SSecurityRSAAES::clearSecrets()
   delete[] serverKeyE;
   delete[] clientKeyN;
   delete[] clientKeyE;
-  serverKeyN = NULL;
-  serverKeyE = NULL;
-  clientKeyN = NULL;
-  clientKeyE = NULL;
+  serverKeyN = nullptr;
+  serverKeyE = nullptr;
+  clientKeyN = nullptr;
+  clientKeyE = nullptr;
   memset(serverRandom, 0, sizeof(serverRandom));
   memset(clientRandom, 0, sizeof(clientRandom));
 }
index 9c0321d421d8e2ac8e414e473ac8a1404774a3e7..b306cd6a885b0f223104c15920eda6502692586b 100644 (file)
@@ -61,7 +61,7 @@ bool SSecurityStack::processMsg()
 
 const char* SSecurityStack::getUserName() const
 {
-  const char* c = 0;
+  const char* c = nullptr;
 
   if (state1 && !c)
     c = state1->getUserName();
index cf7b10d0e1d5357470800d044770f306a8886548..90a6e7c0a221b6e670856aeee20451326adeb84b 100644 (file)
@@ -27,7 +27,7 @@ namespace rfb {
   class SSecurityStack : public SSecurity {
   public:
     SSecurityStack(SConnection* sc, int Type,
-                   SSecurity* s0 = NULL, SSecurity* s1 = NULL);
+                   SSecurity* s0 = nullptr, SSecurity* s1 = nullptr);
     ~SSecurityStack();
     virtual bool processMsg();
     virtual int getType() const { return type; };
index 1abfd774bd970e62a1e7311cde34cac0e067d060..0b8f0ff233f52f1b2f72a0ef878e8b61348a0969 100644 (file)
@@ -67,12 +67,12 @@ StringParameter SSecurityTLS::X509_KeyFile
 static LogWriter vlog("TLS");
 
 SSecurityTLS::SSecurityTLS(SConnection* sc, bool _anon)
-  : SSecurity(sc), session(NULL), anon_cred(NULL),
-    cert_cred(NULL), anon(_anon), tlsis(NULL), tlsos(NULL),
-    rawis(NULL), rawos(NULL)
+  : SSecurity(sc), session(nullptr), anon_cred(nullptr),
+    cert_cred(nullptr), anon(_anon), tlsis(nullptr), tlsos(nullptr),
+    rawis(nullptr), rawos(nullptr)
 {
 #if defined (SSECURITYTLS__USE_DEPRECATED_DH)
-  dh_params = NULL;
+  dh_params = nullptr;
 #endif
 
   if (gnutls_global_init() != GNUTLS_E_SUCCESS)
@@ -99,32 +99,32 @@ void SSecurityTLS::shutdown()
 
   if (anon_cred) {
     gnutls_anon_free_server_credentials(anon_cred);
-    anon_cred = 0;
+    anon_cred = nullptr;
   }
 
   if (cert_cred) {
     gnutls_certificate_free_credentials(cert_cred);
-    cert_cred = 0;
+    cert_cred = nullptr;
   }
 
   if (rawis && rawos) {
     sc->setStreams(rawis, rawos);
-    rawis = NULL;
-    rawos = NULL;
+    rawis = nullptr;
+    rawos = nullptr;
   }
 
   if (tlsis) {
     delete tlsis;
-    tlsis = NULL;
+    tlsis = nullptr;
   }
   if (tlsos) {
     delete tlsos;
-    tlsos = NULL;
+    tlsos = nullptr;
   }
 
   if (session) {
     gnutls_deinit(session);
-    session = 0;
+    session = nullptr;
   }
 }
 
@@ -203,7 +203,7 @@ void SSecurityTLS::setParams(gnutls_session_t session)
 
     prio = (char*)malloc(strlen(Security::GnuTLSPriority) +
                          strlen(kx_anon_priority) + 1);
-    if (prio == NULL)
+    if (prio == nullptr)
       throw AuthFailureException("Not enough memory for GnuTLS priority string");
 
     strcpy(prio, Security::GnuTLSPriority);
@@ -239,7 +239,7 @@ void SSecurityTLS::setParams(gnutls_session_t session)
 
     prio = (char*)malloc(strlen(gnutls_default_priority) +
                          strlen(kx_anon_priority) + 1);
-    if (prio == NULL)
+    if (prio == nullptr)
       throw AuthFailureException("Not enough memory for GnuTLS priority string");
 
     strcpy(prio, gnutls_default_priority);
index d0f735fe46d5d1b3b4f6491726c245ded1292138..a68fd0f2f2279c31aae2ecda9fa92597d84e522a 100644 (file)
@@ -46,7 +46,7 @@ namespace rfb {
     SSecurityTLS(SConnection* sc, bool _anon);
     virtual ~SSecurityTLS();
     virtual bool processMsg();
-    virtual const char* getUserName() const {return 0;}
+    virtual const char* getUserName() const {return nullptr;}
     virtual int getType() const { return anon ? secTypeTLSNone : secTypeX509None;}
 
     static StringParameter X509_CertFile;
index 2813f299710bc04ea9f614b18c3301a13e7bcbed..a6dc327ef4ae0c17de6b1fe61e0e80ed3851569f 100644 (file)
@@ -41,7 +41,7 @@ static LogWriter vlog("SVeNCrypt");
 SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc, SecurityServer *sec)
   : SSecurity(sc), security(sec)
 {
-  ssecurity = NULL;
+  ssecurity = nullptr;
   haveSentVersion = false;
   haveRecvdMajorVersion = false;
   haveRecvdMinorVersion = false;
@@ -51,7 +51,7 @@ SSecurityVeNCrypt::SSecurityVeNCrypt(SConnection* sc, SecurityServer *sec)
   haveChosenType = false;
   chosenType = secTypeVeNCrypt;
   numTypes = 0;
-  subTypes = NULL;
+  subTypes = nullptr;
 }
 
 SSecurityVeNCrypt::~SSecurityVeNCrypt()
@@ -175,14 +175,14 @@ bool SSecurityVeNCrypt::processMsg()
 
 const char* SSecurityVeNCrypt::getUserName() const
 {
-  if (ssecurity == NULL)
-    return NULL;
+  if (ssecurity == nullptr)
+    return nullptr;
   return ssecurity->getUserName();
 }
 
 AccessRights SSecurityVeNCrypt::getAccessRights() const
 {
-  if (ssecurity == NULL)
+  if (ssecurity == nullptr)
     return SSecurity::getAccessRights();
   return ssecurity->getAccessRights();
 }
index c1ef1f1c0420959a3037a7663302e9ffc7280b7e..7d5b2664f459873b1c744a02e68eb22b6a47137b 100644 (file)
@@ -119,7 +119,9 @@ bool SSecurityVncAuth::processMsg()
 VncAuthPasswdParameter::VncAuthPasswdParameter(const char* name,
                                                const char* desc,
                                                StringParameter* passwdFile_)
-: BinaryParameter(name, desc, 0, 0, ConfServer), passwdFile(passwdFile_) {
+: BinaryParameter(name, desc, nullptr, 0, ConfServer),
+  passwdFile(passwdFile_)
+{
 }
 
 void VncAuthPasswdParameter::getVncAuthPasswd(std::string *password, std::string *readOnlyPassword) {
@@ -151,8 +153,8 @@ void VncAuthPasswdParameter::getVncAuthPasswd(std::string *password, std::string
     }
   }
 
-  assert(password != NULL);
-  assert(readOnlyPassword != NULL);
+  assert(password != nullptr);
+  assert(readOnlyPassword != nullptr);
 
   try {
     *password = deobfuscate(obfuscated.data(), obfuscated.size());
index 7f27b02bfadc53934d57cf18a6d83f98e4fdd4c5..9c00aa52fa688de4f7a66ca16af06e9132ef136b 100644 (file)
@@ -54,7 +54,7 @@ namespace rfb {
     SSecurityVncAuth(SConnection* sc);
     virtual bool processMsg();
     virtual int getType() const {return secTypeVncAuth;}
-    virtual const char* getUserName() const {return 0;}
+    virtual const char* getUserName() const {return nullptr;}
     virtual AccessRights getAccessRights() const { return accessRights; }
     static StringParameter vncAuthPasswdFile;
     static VncAuthPasswdParameter vncAuthPasswd;
index 1350640d079b74d2a56f0bbc0393e3ac0afd713f..12860662f2e9715c337943380dec9852c1e7bca5 100644 (file)
@@ -41,9 +41,9 @@
 using namespace rdr;
 using namespace rfb;
 
-UserPasswdGetter *CSecurity::upg = NULL;
+UserPasswdGetter *CSecurity::upg = nullptr;
 #if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE)
-UserMsgBox *CSecurity::msg = NULL;
+UserMsgBox *CSecurity::msg = nullptr;
 #endif
 
 StringParameter SecurityClient::secTypes
@@ -67,9 +67,9 @@ ConfViewer);
 
 CSecurity* SecurityClient::GetCSecurity(CConnection* cc, uint32_t secType)
 {
-  assert (CSecurity::upg != NULL); /* (upg == NULL) means bug in the viewer */
+  assert (CSecurity::upg != nullptr); /* (upg == nullptr) means bug in the viewer */
 #if defined(HAVE_GNUTLS) || defined(HAVE_NETTLE)
-  assert (CSecurity::msg != NULL);
+  assert (CSecurity::msg != nullptr);
 #endif
 
   if (!IsSupported(secType))
index 6af446c2124b5387fd3a1b2b178e52263a2af1d4..9f6f530764a5950bb11172d7ba4808c98faec86f 100644 (file)
@@ -38,7 +38,7 @@ ServerParams::ServerParams()
 {
   setName("");
 
-  cursor_ = new Cursor(0, 0, Point(), NULL);
+  cursor_ = new Cursor(0, 0, Point(), nullptr);
 
   clipFlags = 0;
   memset(clipSizes, 0, sizeof(clipSizes));
index 54b620ea88017f8aba665eb90e82cba61af4e251..807f71a5d87cb5fb2891705dccc0417706be5109 100644 (file)
@@ -345,7 +345,7 @@ void TightDecoder::decodeRect(const Rect& r, const uint8_t* buffer,
   size_t rowSize, dataSize;
   uint8_t* netbuf;
 
-  netbuf = NULL;
+  netbuf = nullptr;
 
   if (palSize != 0) {
     if (palSize <= 2)
@@ -387,7 +387,7 @@ void TightDecoder::decodeRect(const Rect& r, const uint8_t* buffer,
     zis[streamId].readBytes(netbuf, dataSize);
 
     zis[streamId].flushUnderlying();
-    zis[streamId].setUnderlying(NULL, 0);
+    zis[streamId].setUnderlying(nullptr, 0);
     delete ms;
 
     bufptr = netbuf;
index 1a169a3db5bb93ef2ee21a12d6bc462ec3be1174..213f872ca775a1558db5bf8d7b1162b228b09720 100644 (file)
@@ -260,12 +260,12 @@ void TightEncoder::flushZlibOutStream(rdr::OutStream* os_)
   rdr::ZlibOutStream* zos;
 
   zos = dynamic_cast<rdr::ZlibOutStream*>(os_);
-  if (zos == NULL)
+  if (zos == nullptr)
     return;
 
   zos->cork(false);
   zos->flush();
-  zos->setUnderlying(NULL);
+  zos->setUnderlying(nullptr);
 
   os = conn->getOutStream();
 
index e9ae52276d0b89b365d87615f03d13b67497ae25..b695df867d4a7f3bb9e33f31e4fb86deba3f01d3 100644 (file)
@@ -63,7 +63,7 @@ int Timer::checkTimeouts() {
   if (pending.empty())
     return -1;
 
-  gettimeofday(&start, 0);
+  gettimeofday(&start, nullptr);
   while (pending.front()->isBefore(start)) {
     Timer* timer;
 
@@ -81,7 +81,7 @@ int Timer::checkTimeouts() {
 
 int Timer::getNextTimeout() {
   timeval now;
-  gettimeofday(&now, 0);
+  gettimeofday(&now, nullptr);
 
   if (pending.empty())
     return -1;
@@ -115,7 +115,7 @@ void Timer::insertTimer(Timer* t) {
 
 void Timer::start(int timeoutMs_) {
   timeval now;
-  gettimeofday(&now, 0);
+  gettimeofday(&now, nullptr);
   stop();
   timeoutMs = timeoutMs_;
   dueTime = addMillis(now, timeoutMs);
@@ -125,7 +125,7 @@ void Timer::start(int timeoutMs_) {
 void Timer::repeat(int timeoutMs_) {
   timeval now;
 
-  gettimeofday(&now, 0);
+  gettimeofday(&now, nullptr);
 
   if (isStarted()) {
     vlog.error("Incorrectly repeating already running timer");
@@ -167,7 +167,7 @@ int Timer::getTimeoutMs() {
 
 int Timer::getRemainingMs() {
   timeval now;
-  gettimeofday(&now, 0);
+  gettimeofday(&now, nullptr);
   return __rfbmax(0, diffTimeMillis(dueTime, now));
 }
 
index 8983b378ae3a3042f55eab8d69ec8029be43e4c4..1c31a168fd575959711cfd51e1e9839b37de8db4 100644 (file)
@@ -53,7 +53,7 @@ namespace rfb {
 
   class ClippingUpdateTracker : public UpdateTracker {
   public:
-    ClippingUpdateTracker() : ut(0) {}
+    ClippingUpdateTracker() : ut(nullptr) {}
     ClippingUpdateTracker(UpdateTracker* ut_, const Rect& r=Rect()) : ut(ut_), clipRect(r) {}
     
     void setUpdateTracker(UpdateTracker* ut_) {ut = ut_;}
index 306bba1dc402dfc0dbc7264e7d8df1cb7632922e..a40a1a30e2157750b3f327c96206e2aa6dd8a450 100644 (file)
@@ -48,7 +48,7 @@ using namespace rfb;
 
 static LogWriter vlog("VNCSConnST");
 
-static Cursor emptyCursor(0, 0, Point(0, 0), NULL);
+static Cursor emptyCursor(0, 0, Point(0, 0), nullptr);
 
 VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
                                    bool reverse, AccessRights ar)
@@ -56,7 +56,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
     sock(s), reverseConnection(reverse),
     inProcessMessages(false),
     pendingSyncFence(false), syncFence(false), fenceFlags(0),
-    fenceDataLen(0), fenceData(NULL), congestionTimer(this),
+    fenceDataLen(0), fenceData(nullptr), congestionTimer(this),
     losslessTimer(this), server(server_),
     updateRenderedCursor(false), removeRenderedCursor(false),
     continuousUpdates(false), encodeManager(this), idleTimer(this),
@@ -409,7 +409,7 @@ bool VNCSConnectionST::needRenderedCursor()
   if (!client.supportsLocalCursor())
     return true;
   if ((server->getCursorPos() != pointerEventPos) &&
-      (time(0) - pointerEventTime) > 0)
+      (time(nullptr) - pointerEventTime) > 0)
     return true;
 
   return false;
@@ -481,7 +481,7 @@ void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask)
 {
   if (rfb::Server::idleTimeout)
     idleTimer.start(secsToMillis(rfb::Server::idleTimeout));
-  pointerEventTime = time(0);
+  pointerEventTime = time(nullptr);
   if (!accessCheck(AccessPtrEvents)) return;
   if (!rfb::Server::acceptPointerEvents) return;
   pointerEventPos = pos;
@@ -690,7 +690,7 @@ void VNCSConnectionST::fence(uint32_t flags, unsigned len, const uint8_t data[])
       fenceFlags = flags & (fenceFlagBlockBefore | fenceFlagBlockAfter | fenceFlagSyncNext);
       fenceDataLen = len;
       delete [] fenceData;
-      fenceData = NULL;
+      fenceData = nullptr;
       if (len > 0) {
         fenceData = new uint8_t[len];
         memcpy(fenceData, data, len);
@@ -1001,7 +1001,7 @@ void VNCSConnectionST::writeDataUpdate()
 
   // Does the client need a server-side rendered cursor?
 
-  cursor = NULL;
+  cursor = nullptr;
   if (needRenderedCursor()) {
     Rect renderedCursorRect;
 
@@ -1083,7 +1083,7 @@ void VNCSConnectionST::writeLosslessRefresh()
 
   // Prepare the cursor in case it overlaps with a region getting
   // refreshed
-  cursor = NULL;
+  cursor = nullptr;
   if (needRenderedCursor())
     cursor = server->getRenderedCursor();
 
index 3ac9fb946674e8dd5c104c77a0d3722daf01e0b4..4e3a5b23d1da238236e1d7a47aee38225c8ff484 100644 (file)
@@ -115,7 +115,7 @@ namespace rfb {
     // acceptance, or false for rejection, in which case a string
     // reason may also be given.
     virtual void approveConnection(network::Socket* sock, bool accept,
-                                   const char* reason = NULL) = 0;
+                                   const char* reason = nullptr) = 0;
 
     // - Close all currently-connected clients, by calling
     //   their close() method with the supplied reason.
index b9579f12aaaa3fddf9853d51e57314663710d9e4..8db5d0fb7a53e3802f1ed4c67bcabc87ba9fa648 100644 (file)
@@ -83,10 +83,10 @@ static LogWriter connectionsLog("Connections");
 
 VNCServerST::VNCServerST(const char* name_, SDesktop* desktop_)
   : blHosts(&blacklist), desktop(desktop_), desktopStarted(false),
-    blockCounter(0), pb(0), ledState(ledUnknown),
-    name(name_), pointerClient(0), clipboardClient(0),
+    blockCounter(0), pb(nullptr), ledState(ledUnknown),
+    name(name_), pointerClient(nullptr), clipboardClient(nullptr),
     pointerClientTime(0),
-    comparer(0), cursor(new Cursor(0, 0, Point(), NULL)),
+    comparer(nullptr), cursor(new Cursor(0, 0, Point(), nullptr)),
     renderedCursorInvalid(false),
     keyRemapper(&KeyRemapper::defInstance),
     idleTimer(this), disconnectTimer(this), connectTimer(this),
@@ -177,7 +177,7 @@ void VNCServerST::removeSocket(network::Socket* sock) {
     if ((*ci)->getSock() == sock) {
       // - Remove any references to it
       if (pointerClient == *ci)
-        pointerClient = NULL;
+        pointerClient = nullptr;
       if (clipboardClient == *ci)
         handleClipboardAnnounce(*ci, false);
       clipboardRequestors.remove(*ci);
@@ -275,7 +275,7 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_, const ScreenSet& layout)
 
   pb = pb_;
   delete comparer;
-  comparer = 0;
+  comparer = nullptr;
 
   if (!pb) {
     screenLayout = ScreenSet();
@@ -355,7 +355,7 @@ void VNCServerST::setScreenLayout(const ScreenSet& layout)
 
 void VNCServerST::requestClipboard()
 {
-  if (clipboardClient == NULL) {
+  if (clipboardClient == nullptr) {
     slog.debug("Got request for client clipboard but no client currently owns the clipboard");
     return;
   }
@@ -379,7 +379,7 @@ void VNCServerST::sendClipboardData(const char* data)
 {
   std::list<VNCSConnectionST*>::iterator ci, ci_next;
 
-  if (strchr(data, '\r') != NULL)
+  if (strchr(data, '\r') != nullptr)
     throw Exception("Invalid carriage return in clipboard data");
 
   for (ci = clipboardRequestors.begin();
@@ -412,7 +412,7 @@ void VNCServerST::setName(const char* name_)
 
 void VNCServerST::add_changed(const Region& region)
 {
-  if (comparer == NULL)
+  if (comparer == nullptr)
     return;
 
   comparer->add_changed(region);
@@ -421,7 +421,7 @@ void VNCServerST::add_changed(const Region& region)
 
 void VNCServerST::add_copied(const Region& dest, const Point& delta)
 {
-  if (comparer == NULL)
+  if (comparer == nullptr)
     return;
 
   comparer->add_copied(dest, delta);
@@ -498,14 +498,14 @@ void VNCServerST::keyEvent(uint32_t keysym, uint32_t keycode, bool down)
 void VNCServerST::pointerEvent(VNCSConnectionST* client,
                                const Point& pos, int buttonMask)
 {
-  time_t now = time(0);
+  time_t now = time(nullptr);
   if (rfb::Server::maxIdleTime)
     idleTimer.start(secsToMillis(rfb::Server::maxIdleTime));
 
   // Let one client own the cursor whilst buttons are pressed in order
   // to provide a bit more sane user experience. But limit the time to
   // prevent locking out all others when e.g. the network is down.
-  if ((pointerClient != NULL) && (pointerClient != client) &&
+  if ((pointerClient != nullptr) && (pointerClient != client) &&
       ((now - pointerClientTime) < 10))
     return;
 
@@ -513,7 +513,7 @@ void VNCServerST::pointerEvent(VNCSConnectionST* client,
   if (buttonMask)
     pointerClient = client;
   else
-    pointerClient = NULL;
+    pointerClient = nullptr;
 
   desktop->pointerEvent(pos, buttonMask);
 }
@@ -533,7 +533,7 @@ void VNCServerST::handleClipboardAnnounce(VNCSConnectionST* client,
   else {
     if (client != clipboardClient)
       return;
-    clipboardClient = NULL;
+    clipboardClient = nullptr;
   }
   desktop->handleClipboardAnnounce(available);
 }
@@ -633,7 +633,7 @@ SConnection* VNCServerST::getConnection(network::Socket* sock) {
     if ((*ci)->getSock() == sock)
       return (SConnection*)*ci;
   }
-  return 0;
+  return nullptr;
 }
 
 void VNCServerST::handleTimeout(Timer* t)
@@ -697,14 +697,14 @@ void VNCServerST::queryConnection(VNCSConnectionST* client,
   // - Are we configured to do queries?
   if (!rfb::Server::queryConnect &&
       !client->getSock()->requiresQuery()) {
-    approveConnection(client->getSock(), true, NULL);
+    approveConnection(client->getSock(), true, nullptr);
     return;
   }
 
   // - Does the client have the right to bypass the query?
   if (client->accessCheck(AccessNoQuery))
   {
-    approveConnection(client->getSock(), true, NULL);
+    approveConnection(client->getSock(), true, nullptr);
     return;
   }
 
index 90c8d7539525b2c68d3eae3924b02f8b1a046a4f..8fbbf971f997a032caef7914de2f0c78122c0659 100644 (file)
@@ -92,7 +92,7 @@ namespace rfb {
 
     virtual void approveConnection(network::Socket* sock, bool accept,
                                    const char* reason);
-    virtual void closeClients(const char* reason) {closeClients(reason, 0);}
+    virtual void closeClients(const char* reason) {closeClients(reason, nullptr);}
     virtual SConnection* getConnection(network::Socket* sock);
 
     virtual void add_changed(const Region &region);
index 4b768afcb301ce995c8a20ba045f1d047af3bc9c..de919dc55a7f771eff15e2a0048287fd6d90f80a 100644 (file)
@@ -286,5 +286,5 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStream* is,
   }
 
   zis->flushUnderlying();
-  zis->setUnderlying(NULL, 0);
+  zis->setUnderlying(nullptr, 0);
 }
index ad3aec1a8e6c53068c3af676ce449700d3003d6c..c967733791708fce874ad0d250795acc5e754126 100644 (file)
@@ -38,7 +38,7 @@ IntParameter zlibLevel("ZlibLevel","[DEPRECATED] Zlib compression level",-1);
 
 ZRLEEncoder::ZRLEEncoder(SConnection* conn)
   : Encoder(conn, encodingZRLE, EncoderPlain, 127),
-  zos(0, 2), mos(129*1024)
+  zos(nullptr, 2), mos(129*1024)
 {
   if (zlibLevel != -1) {
     vlog.info("Warning: The ZlibLevel option is deprecated and is "
@@ -50,7 +50,7 @@ ZRLEEncoder::ZRLEEncoder(SConnection* conn)
 
 ZRLEEncoder::~ZRLEEncoder()
 {
-  zos.setUnderlying(NULL);
+  zos.setUnderlying(nullptr);
 }
 
 bool ZRLEEncoder::isSupported()
index d40e25c3ea15ac2f29787f2d56b6106311982b5d..2afc151233d2b085174570593775cb0450860180 100644 (file)
@@ -41,7 +41,7 @@ std::vector<uint8_t> rfb::obfuscate(const char *str)
 {
   std::vector<uint8_t> buf(8);
 
-  assert(str != NULL);
+  assert(str != nullptr);
 
   size_t l = strlen(str), i;
   for (i=0; i<8; i++)
@@ -59,7 +59,7 @@ std::string rfb::deobfuscate(const uint8_t *data, size_t len)
   if (len != 8)
     throw rdr::Exception("bad obfuscated password length");
 
-  assert(data != NULL);
+  assert(data != nullptr);
 
   deskey(d3desObfuscationKey, DE1);
   des((uint8_t*)data, (uint8_t*)buf);
index 48f59846ddb3ee4477df43aaac5b570b53ee891b..3c62b1dfb97aede447fbbb26af5bae8074c26497 100644 (file)
@@ -40,7 +40,7 @@ namespace rfb {
     std::string out;
 
     va_start(ap, fmt);
-    len = vsnprintf(NULL, 0, fmt, ap);
+    len = vsnprintf(nullptr, 0, fmt, ap);
     va_end(ap);
 
     if (len < 0)
@@ -68,13 +68,13 @@ namespace rfb {
     start = src;
     do {
       stop = strchr(start, delimiter);
-      if (stop == NULL) {
+      if (stop == nullptr) {
         out.push_back(start);
       } else {
         out.push_back(std::string(start, stop-start));
         start = stop + 1;
       }
-    } while (stop != NULL);
+    } while (stop != nullptr);
 
     return out;
   }
@@ -621,7 +621,7 @@ namespace rfb {
   {
     struct timeval now;
 
-    gettimeofday(&now, NULL);
+    gettimeofday(&now, nullptr);
 
     return msBetween(then, &now);
   }
index c72ec1d7c7d88c8d728a3f6c55bcf4dbd37a3b9f..87370a4c1e87a278d0dd75cc57baa048a5668881 100644 (file)
@@ -193,7 +193,7 @@ static struct stats runTest(const char *fn)
   struct timeval start, stop;
   struct stats s;
 
-  gettimeofday(&start, NULL);
+  gettimeofday(&start, nullptr);
 
   try {
     cc = new CConn(fn);
@@ -211,7 +211,7 @@ static struct stats runTest(const char *fn)
     exit(1);
   }
 
-  gettimeofday(&stop, NULL);
+  gettimeofday(&stop, nullptr);
 
   s.decodeTime = cc->cpuTime;
   s.realTime = (double)stop.tv_sec - start.tv_sec;
index 388dcc95595b99ba567eda5c7479dd34c86411ba..7cc51f29bfa7f9705d4ae1cd6ffc3d8b62369366 100644 (file)
@@ -308,7 +308,7 @@ SConn::SConn()
 : SConnection(rfb::AccessDefault)
 {
   out = new DummyOutStream;
-  setStreams(NULL, out);
+  setStreams(nullptr, out);
 
   setWriter(new rfb::SMsgWriter(&client, out));
 
@@ -323,7 +323,7 @@ SConn::~SConn()
 
 void SConn::writeUpdate(const rfb::UpdateInfo& ui, const rfb::PixelBuffer* pb)
 {
-  manager->writeUpdate(ui, pb, NULL);
+  manager->writeUpdate(ui, pb, nullptr);
 }
 
 void SConn::getStats(double& ratio, unsigned long long& bytes,
@@ -357,7 +357,7 @@ static struct stats runTest(const char *fn)
   struct stats s;
   struct timeval start, stop;
 
-  gettimeofday(&start, NULL);
+  gettimeofday(&start, nullptr);
 
   try {
     cc = new CConn(fn);
@@ -375,7 +375,7 @@ static struct stats runTest(const char *fn)
     exit(1);
   }
 
-  gettimeofday(&stop, NULL);
+  gettimeofday(&stop, nullptr);
 
   s.decodeTime = cc->decodeTime;
   s.encodeTime = cc->encodeTime;
@@ -420,7 +420,7 @@ int main(int argc, char **argv)
 
   const char *fn;
 
-  fn = NULL;
+  fn = nullptr;
   for (i = 1; i < argc; i++) {
     if (rfb::Configuration::setParam(argv[i]))
       continue;
@@ -435,7 +435,7 @@ int main(int argc, char **argv)
       usage(argv[0]);
     }
 
-    if (fn != NULL)
+    if (fn != nullptr)
       usage(argv[0]);
 
     fn = argv[i];
@@ -447,7 +447,7 @@ int main(int argc, char **argv)
   double *dev = new double[runCount];
   double median, meddev;
 
-  if (fn == NULL) {
+  if (fn == nullptr) {
     fprintf(stderr, "No file specified!\n\n");
     usage(argv[0]);
   }
index dddf19fb4cf8eca2cd6448154910aa871e8812f6..ba1633b9fa604f4a828e2217208cb0570038121f 100644 (file)
@@ -82,7 +82,7 @@ protected:
 
 TestWindow::TestWindow() :
   Fl_Window(0, 0, "Framebuffer Performance Test"),
-  fb(NULL)
+  fb(nullptr)
 {
 }
 
@@ -116,7 +116,7 @@ void TestWindow::stop()
   hide();
 
   delete fb;
-  fb = NULL;
+  fb = nullptr;
 
   Fl::remove_idle(timer, this);
 }
@@ -208,7 +208,7 @@ void PartialTestWindow::changefb()
 }
 
 OverlayTestWindow::OverlayTestWindow() :
-  overlay(NULL), offscreen(NULL)
+  overlay(nullptr), offscreen(nullptr)
 {
 }
 
@@ -224,7 +224,7 @@ void OverlayTestWindow::start(int width, int height)
 #if !defined(__APPLE__)
   offscreen = new Surface(w(), h());
 #else
-  offscreen = NULL;
+  offscreen = nullptr;
 #endif
 }
 
@@ -233,9 +233,9 @@ void OverlayTestWindow::stop()
   PartialTestWindow::stop();
 
   delete offscreen;
-  offscreen = NULL;
+  offscreen = nullptr;
   delete overlay;
-  overlay = NULL;
+  overlay = nullptr;
 }
 
 void OverlayTestWindow::draw()
@@ -299,7 +299,7 @@ static void dosubtest(TestWindow* win, int width, int height,
 
   win->start(width, height);
 
-  gettimeofday(&start, NULL);
+  gettimeofday(&start, nullptr);
   while (rfb::msSince(&start) < 3000)
     Fl::wait();
 
index 98b2568e87301886745a2e114a8d4e6ed15ff9a0..2720c237cfbe438ede63a1b67b26f890268aa515 100644 (file)
@@ -65,8 +65,8 @@ cpucounter_t newCpuCounter(void)
   syscounter_t *c;
 
   c = (syscounter_t*)malloc(sizeof(syscounter_t) * 2);
-  if (c == NULL)
-    return NULL;
+  if (c == nullptr)
+    return nullptr;
 
   memset(c, 0, sizeof(syscounter_t) * 2);
 
@@ -149,7 +149,7 @@ void startTimeCounter(void)
 #ifdef WIN32
   QueryPerformanceCounter(&timeStart);
 #else
-  gettimeofday(&timeStart, NULL);
+  gettimeofday(&timeStart, nullptr);
 #endif
 }
 
@@ -158,7 +158,7 @@ void endTimeCounter(void)
 #ifdef WIN32
   QueryPerformanceCounter(&timeEnd);
 #else
-  gettimeofday(&timeEnd, NULL);
+  gettimeofday(&timeEnd, nullptr);
 #endif
 }
 
index cb15e7e1df6633c2319de39ed96f68618f86646a..7181504214d0c528d061d2de5114a3b343b72e8b 100644 (file)
@@ -180,7 +180,7 @@ int main(int /*argc*/, char** /*argv*/)
 
     for (i = 0;i < ARRAY_SIZE(latin1utf8);i++) {
         /* Expected failure? */
-        if (strchr(latin1utf8[i].latin1, '?') != NULL)
+        if (strchr(latin1utf8[i].latin1, '?') != nullptr)
             continue;
 
         out = rfb::latin1ToUTF8(latin1utf8[i].latin1);
@@ -212,7 +212,7 @@ int main(int /*argc*/, char** /*argv*/)
 
     for (i = 0;i < ARRAY_SIZE(utf8utf16);i++) {
         /* Expected failure? */
-        if (strstr(utf8utf16[i].utf8, "\xef\xbf\xbd") != NULL)
+        if (strstr(utf8utf16[i].utf8, "\xef\xbf\xbd") != nullptr)
             continue;
 
         wout = rfb::utf8ToUTF16(utf8utf16[i].utf8);
index a51f2ecd285794d9fb2cb05064e7b377720eb112..e6be3d6880ee52ad099780fab337e40110c1026f 100644 (file)
@@ -41,14 +41,15 @@ public:
 class TXButton : public TXWindow, public TXEventHandler {
 public:
 
-  TXButton(Display* dpy_, const char* text_, TXButtonCallback* cb_=0,
-           TXWindow* parent_=0, int w=1, int h=1)
+  TXButton(Display* dpy_, const char* text_,
+           TXButtonCallback* cb_=nullptr,
+           TXWindow* parent_=nullptr, int w=1, int h=1)
     : TXWindow(dpy_, w, h, parent_), cb(cb_), down(false),
       disabled_(false)
   {
     setEventHandler(this);
     setText(text_);
-    gc = XCreateGC(dpy, win(), 0, 0);
+    gc = XCreateGC(dpy, win(), 0, nullptr);
     XSetFont(dpy, gc, defaultFont);
     addEventMask(ExposureMask | ButtonPressMask | ButtonReleaseMask);
   }
index 76cdc95085432c3ae01de8c4f9766c2365f488d9..c69455c69bbc55b811ef3ae054fd4e759212f288 100644 (file)
@@ -48,14 +48,15 @@ public:
 class TXCheckbox : public TXWindow, public TXEventHandler {
 public:
   TXCheckbox(Display* dpy_, const char* text_, TXCheckboxCallback* cb_,
-             bool radio_=false, TXWindow* parent_=0, int w=1, int h=1)
-    : TXWindow(dpy_, w, h, parent_), cb(cb_), text(0),
+             bool radio_=false, TXWindow* parent_=nullptr,
+             int w=1, int h=1)
+    : TXWindow(dpy_, w, h, parent_), cb(cb_), text(nullptr),
       boxSize(radio_ ? 12 : 13), boxPad(4),
       checked_(false), disabled_(false), radio(radio_)
   {
     setEventHandler(this);
     setText(text_);
-    gc = XCreateGC(dpy, win(), 0, 0);
+    gc = XCreateGC(dpy, win(), 0, nullptr);
     XSetFont(dpy, gc, defaultFont);
     addEventMask(ExposureMask| ButtonPressMask | ButtonReleaseMask);
   }
index 861a20bec5d232c43ad3b81c1af11d6ff50d2e11..3187247d0dd3164cafa035720a73761d13ba95cf 100644 (file)
@@ -62,7 +62,7 @@ public:
         fd_set rfds;
         FD_ZERO(&rfds);
         FD_SET(ConnectionNumber(dpy), &rfds);
-        int n = select(FD_SETSIZE, &rfds, 0, 0, 0);
+        int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
         if (n < 0) throw rdr::SystemException("select",errno);
       }
     }
index 24b8cbb3846a830d0d49b2b31ff9ea0e4a71774b..5af1667954e20bc0b37ff2deb056907f63064760 100644 (file)
@@ -35,7 +35,7 @@ public:
   enum HAlign { left, centre, right };
   enum VAlign { top, middle, bottom };
 
-  TXLabel(Display* dpy_, const char* text_, TXWindow* parent_=0,
+  TXLabel(Display* dpy_, const char* text_, TXWindow* parent_=nullptr,
           int w=1, int h=1, HAlign ha=centre, VAlign va=middle)
     : TXWindow(dpy_, w, h, parent_), lineSpacing(2), lines(0),
       halign(ha), valign(va)
index ee097e45e3472b40562b8ceff9b3cf340cdd5078..343b9c28c0bd9a5cd76517e3914c0e5981a38c74 100644 (file)
@@ -44,15 +44,15 @@ unsigned long TXWindow::disabledFg, TXWindow::disabledBg;
 unsigned long TXWindow::enabledBg;
 unsigned long TXWindow::scrollbarBg;
 Colormap TXWindow::cmap = 0;
-GC TXWindow::defaultGC = 0;
+GC TXWindow::defaultGC = nullptr;
 Font TXWindow::defaultFont = 0;
-XFontStruct* TXWindow::defaultFS = 0;
+XFontStruct* TXWindow::defaultFS = nullptr;
 Time TXWindow::cutBufferTime = 0;
 Pixmap TXWindow::dot = 0, TXWindow::tick = 0;
 const int TXWindow::dotSize = 4, TXWindow::tickSize = 8;
 char* TXWindow::defaultWindowClass;
 
-TXGlobalEventHandler* TXWindow::globalEventHandler = NULL;
+TXGlobalEventHandler* TXWindow::globalEventHandler = nullptr;
 
 void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
 {
@@ -79,7 +79,7 @@ void TXWindow::init(Display* dpy, const char* defaultWindowClass_)
   darkBg = disabledFg = cols[3].pixel;
   scrollbarBg = cols[4].pixel;
   white = enabledBg = cols[5].pixel;
-  defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, 0);
+  defaultGC = XCreateGC(dpy, DefaultRootWindow(dpy), 0, nullptr);
   defaultFS
     = XLoadQueryFont(dpy, "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*");
   if (!defaultFS) {
@@ -258,7 +258,8 @@ Window TXWindow::windowWithName(Display* dpy, Window top, const char* name)
 TXWindow::TXWindow(Display* dpy_, int w, int h, TXWindow* parent_,
                    int borderWidth)
   : dpy(dpy_), xPad(3), yPad(3), bevel(2), parent(parent_), width_(w),
-    height_(h), eventHandler(0), dwc(0), eventMask(0), toplevel_(false)
+    height_(h), eventHandler(nullptr), dwc(nullptr), eventMask(0),
+    toplevel_(false)
 {
   sizeHints.flags = 0;
   XSetWindowAttributes attr;
@@ -266,7 +267,8 @@ TXWindow::TXWindow(Display* dpy_, int w, int h, TXWindow* parent_,
   attr.border_pixel = 0;
   Window par = parent ? parent->win() : DefaultRootWindow(dpy);
   win_ = XCreateWindow(dpy, par, 0, 0, width_, height_, borderWidth,
-                      CopyFromParent, CopyFromParent, CopyFromParent,
+                      CopyFromParent, CopyFromParent,
+                      (Visual*)CopyFromParent,
                       CWBackPixel | CWBorderPixel, &attr);
   if (parent) map();
 
@@ -292,7 +294,7 @@ void TXWindow::toplevel(const char* name, TXDeleteWindowCallback* dwc_,
   if (!windowClass) windowClass = defaultWindowClass;
   classHint.res_name = (char*)name;
   classHint.res_class = (char*)windowClass;
-  XSetWMProperties(dpy, win(), 0, 0, argv, argc,
+  XSetWMProperties(dpy, win(), nullptr, nullptr, argv, argc,
                    &sizeHints, &wmHints, &classHint);
   XStoreName(dpy, win(), name);
   XSetIconName(dpy, win(), name);
@@ -443,7 +445,7 @@ void TXWindow::handleXEvent(XEvent* ev)
         break;
       }
     }
-    selectionNotify(&ev->xselection, 0, 0, 0, 0);
+    selectionNotify(&ev->xselection, 0, 0, 0, nullptr);
     break;
 
   case SelectionRequest:
index 223c07a840a003b534aad17af8c9d1144d063b74..9f2a30cb25aaa94df297caab4727139860de3fce 100644 (file)
@@ -65,7 +65,8 @@ public:
   // background (currently grey).  It is mapped by default if it has a parent.
   // If no parent is specified its parent is the root window and it will remain
   // unmapped.
-  TXWindow(Display* dpy_, int width=1, int height=1, TXWindow* parent_=0,
+  TXWindow(Display* dpy_, int width=1, int height=1,
+           TXWindow* parent_=nullptr,
            int borderWidth=0);
   virtual ~TXWindow();
 
@@ -73,8 +74,9 @@ public:
   // window-manager-related properties are set on the window.  The given
   // TXDeleteWindowCallback is notified when the window is "deleted" (cloesd)
   // by the user.
-  void toplevel(const char* name, TXDeleteWindowCallback* dwc=0,
-                int argc=0, char** argv=0, const char* windowClass=0,
+  void toplevel(const char* name, TXDeleteWindowCallback* dwc=nullptr,
+                int argc=0, char** argv=nullptr,
+                const char* windowClass=nullptr,
                 bool iconic=false);
 
   // setMaxSize() tells the window manager the maximum size to allow a
@@ -181,7 +183,7 @@ public:
 
   // strEmptyToNull() returns the string it's given but turns an empty string
   // into null, which can be useful for passing rfb parameters to Xlib calls.
-  static char* strEmptyToNull(char* s) { return s && s[0] ? s : 0; }
+  static char* strEmptyToNull(char* s) { return s && s[0] ? s : nullptr; }
 
   // The following are default values for various things.
   static unsigned long black, white;
index 30d04ca6c873d291848fa965ab0b8bcda3c7be91..cd4b2ee43ce279ca352aa4582ef068703764aee9 100644 (file)
@@ -62,7 +62,7 @@ BoolParameter iconic("iconic", "Start with window iconified", 0);
 #define SET_PRIMARY "SetPrimary"
 #define SEND_PRIMARY "SendPrimary"
 
-char* programName = 0;
+char* programName = nullptr;
 Display* dpy;
 int vncExtEventBase, vncExtErrorBase;
 
@@ -86,7 +86,7 @@ public:
       setPrimaryCB(dpy, "Also set primary selection", this, false, this),
       sendClipboard(dpy, "Send clipboard to viewers", this, false, this),
       sendPrimaryCB(dpy, "Send primary selection to viewers", this,false,this),
-      queryConnectDialog(0)
+      queryConnectDialog(nullptr)
   {
     int y = yPad;
     acceptClipboard.move(xPad, y);
@@ -104,7 +104,7 @@ public:
     sendPrimaryCB.disabled(!sendClipboard.checked());
     y += sendPrimaryCB.height();
     setEventHandler(this);
-    toplevel("VNC config", this, 0, 0, 0, iconic);
+    toplevel("VNC config", this, 0, nullptr, nullptr, iconic);
     XVncExtSelectInput(dpy, win(), VncExtQueryConnectMask);
   }
 
@@ -115,7 +115,7 @@ public:
        vlog.debug("query connection event");
        if (queryConnectDialog)
          delete queryConnectDialog;
-       queryConnectDialog = 0;
+       queryConnectDialog = nullptr;
        char* qcAddress;
        char* qcUser;
        int qcTimeout;
@@ -306,7 +306,7 @@ int main(int argc, char** argv)
 
     while (true) {
       struct timeval tv;
-      struct timeval* tvp = 0;
+      struct timeval* tvp = nullptr;
 
       // Process any incoming X events
       TXWindow::handleXEvents(dpy);
@@ -329,7 +329,7 @@ int main(int argc, char** argv)
       fd_set rfds;
       FD_ZERO(&rfds);
       FD_SET(ConnectionNumber(dpy), &rfds);
-      int n = select(FD_SETSIZE, &rfds, 0, 0, tvp);
+      int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, tvp);
       if (n < 0) throw rdr::SystemException("select",errno);
     }
 
index 30091a3db6078aec71d688fbb6efee7a7db8c005..877ebcbd4c84fef907fe3c9bca7e06d458fd22fa 100644 (file)
@@ -72,7 +72,7 @@ static const char* getpassword(const char* prompt) {
       result[strlen(result)-1] = 0;
     return buf;
   }
-  return 0;
+  return nullptr;
 }
 
 // Reads passwords from stdin and prints encrypted passwords to stdout.
@@ -81,7 +81,7 @@ static int encrypt_pipe() {
 
   // We support a maximum of two passwords right now
   for (i = 0;i < 2;i++) {
-    const char *result = getpassword(NULL);
+    const char *result = getpassword(nullptr);
     if (!result)
       break;
 
@@ -102,7 +102,7 @@ static int encrypt_pipe() {
 static std::vector<uint8_t> readpassword() {
   while (true) {
     const char *passwd = getpassword("Password:");
-    if (passwd == NULL) {
+    if (passwd == nullptr) {
       perror("getpassword error");
       exit(1);
     }
@@ -117,7 +117,7 @@ static std::vector<uint8_t> readpassword() {
     }
 
     passwd = getpassword("Verify:");
-    if (passwd == NULL) {
+    if (passwd == nullptr) {
       perror("getpass error");
       exit(1);
     }
@@ -158,7 +158,7 @@ int main(int argc, char** argv)
 
   if (fname[0] == '\0') {
     const char *configDir = os::getvncconfigdir();
-    if (configDir == NULL) {
+    if (configDir == nullptr) {
       fprintf(stderr, "Can't obtain VNC config directory\n");
       exit(1);
     }
@@ -175,7 +175,7 @@ int main(int argc, char** argv)
 
     fprintf(stderr, "Would you like to enter a view-only password (y/n)? ");
     char yesno[3];
-    if (fgets(yesno, 3, stdin) != NULL && (yesno[0] == 'y' || yesno[0] == 'Y')) {
+    if (fgets(yesno, 3, stdin) != nullptr && (yesno[0] == 'y' || yesno[0] == 'Y')) {
       obfuscatedReadOnly = readpassword();
     } else {
       fprintf(stderr, "A view-only password is not used\n");
index 3f7f28630e6ac10e2c8edc81d4870f2be05b7bcf..28e71be41241fdec483c5c8d90eca711d5149fe3 100644 (file)
@@ -71,7 +71,7 @@ Rect Geometry::parseString(const char *arg) const
 {
   Rect result;                  // empty by default
 
-  if (arg != NULL && strlen(arg) > 0) {
+  if (arg != nullptr && strlen(arg) > 0) {
     int w, h;
     int x = 0, y = 0;
     char sign_x[2] = "+";
index 755da787a13b4ba2a12c1b059fc498a3cbed78df..c202613472c1842dea0709531b8d90ee14d510b7 100644 (file)
@@ -63,13 +63,13 @@ ImageCleanup imageCleanup;
 static rfb::LogWriter vlog("Image");
 
 Image::Image(Display *d)
-  : xim(NULL), dpy(d)
+  : xim(nullptr), dpy(d)
 {
   imageCleanup.images.push_back(this);
 }
 
 Image::Image(Display *d, int width, int height)
-  : xim(NULL), dpy(d)
+  : xim(nullptr), dpy(d)
 {
   imageCleanup.images.push_back(this);
   Init(width, height);
@@ -85,10 +85,11 @@ void Image::Init(int width, int height)
   }
 
   xim = XCreateImage(dpy, vis, DefaultDepth(dpy, DefaultScreen(dpy)),
-                     ZPixmap, 0, 0, width, height, BitmapPad(dpy), 0);
+                     ZPixmap, 0, nullptr, width, height,
+                     BitmapPad(dpy), 0);
 
   xim->data = (char *)malloc(xim->bytes_per_line * xim->height);
-  if (xim->data == NULL) {
+  if (xim->data == nullptr) {
     vlog.error("malloc() failed");
     exit(1);
   }
@@ -99,7 +100,7 @@ Image::~Image()
   imageCleanup.images.remove(this);
 
   // XDestroyImage will free xim->data if necessary
-  if (xim != NULL)
+  if (xim != nullptr)
     XDestroyImage(xim);
 }
 
@@ -217,12 +218,12 @@ static int ShmCreationXErrorHandler(Display* /*dpy*/,
 }
 
 ShmImage::ShmImage(Display *d)
-  : Image(d), shminfo(NULL)
+  : Image(d), shminfo(nullptr)
 {
 }
 
 ShmImage::ShmImage(Display *d, int width, int height)
-  : Image(d), shminfo(NULL)
+  : Image(d), shminfo(nullptr)
 {
   Init(width, height);
 }
@@ -241,7 +242,7 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
   Visual *visual;
   int depth;
 
-  if (vinfo == NULL) {
+  if (vinfo == nullptr) {
     visual = DefaultVisual(dpy, DefaultScreen(dpy));
     depth = DefaultDepth(dpy, DefaultScreen(dpy));
   } else {
@@ -256,12 +257,12 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
 
   shminfo = new XShmSegmentInfo;
 
-  xim = XShmCreateImage(dpy, visual, depth, ZPixmap, 0, shminfo,
+  xim = XShmCreateImage(dpy, visual, depth, ZPixmap, nullptr, shminfo,
                        width, height);
-  if (xim == NULL) {
+  if (xim == nullptr) {
     vlog.error("XShmCreateImage() failed");
     delete shminfo;
-    shminfo = NULL;
+    shminfo = nullptr;
     return;
   }
 
@@ -273,22 +274,22 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
     vlog.error("shmget() failed (%d bytes requested)",
                int(xim->bytes_per_line * xim->height));
     XDestroyImage(xim);
-    xim = NULL;
+    xim = nullptr;
     delete shminfo;
-    shminfo = NULL;
+    shminfo = nullptr;
     return;
   }
 
-  shminfo->shmaddr = xim->data = (char *)shmat(shminfo->shmid, 0, 0);
+  shminfo->shmaddr = xim->data = (char *)shmat(shminfo->shmid, nullptr, 0);
   if (shminfo->shmaddr == (char *)-1) {
     perror("shmat");
     vlog.error("shmat() failed (%d bytes requested)",
                int(xim->bytes_per_line * xim->height));
-    shmctl(shminfo->shmid, IPC_RMID, 0);
+    shmctl(shminfo->shmid, IPC_RMID, nullptr);
     XDestroyImage(xim);
-    xim = NULL;
+    xim = nullptr;
     delete shminfo;
-    shminfo = NULL;
+    shminfo = nullptr;
     return;
   }
 
@@ -301,21 +302,21 @@ void ShmImage::Init(int width, int height, const XVisualInfo *vinfo)
   if (caughtShmError) {
     vlog.error("XShmAttach() failed");
     shmdt(shminfo->shmaddr);
-    shmctl(shminfo->shmid, IPC_RMID, 0);
+    shmctl(shminfo->shmid, IPC_RMID, nullptr);
     XDestroyImage(xim);
-    xim = NULL;
+    xim = nullptr;
     delete shminfo;
-    shminfo = NULL;
+    shminfo = nullptr;
     return;
   }
 }
 
 ShmImage::~ShmImage()
 {
-  if (shminfo != NULL) {
+  if (shminfo != nullptr) {
     XShmDetach(dpy, shminfo);
     shmdt(shminfo->shmaddr);
-    shmctl(shminfo->shmid, IPC_RMID, 0);
+    shmctl(shminfo->shmid, IPC_RMID, nullptr);
     delete shminfo;
   }
 }
@@ -354,13 +355,13 @@ ImageFactory::~ImageFactory()
 
 Image *ImageFactory::newImage(Display *d, int width, int height)
 {
-  Image *image = NULL;
+  Image *image = nullptr;
 
   // Now, try to use shared memory image.
 
   if (mayUseShm) {
     image = new ShmImage(d, width, height);
-    if (image->xim != NULL) {
+    if (image->xim != nullptr) {
       return image;
     }
 
index bf62e7d0b775307d32bb43c5931b299bec2dc126..9fc03d9ad0456a75b23e9ab7a82d15f0f2b832d6 100644 (file)
@@ -111,7 +111,7 @@ public:
 
 protected:
 
-  void Init(int width, int height, const XVisualInfo *vinfo = NULL);
+  void Init(int width, int height, const XVisualInfo *vinfo = nullptr);
 
   XShmSegmentInfo *shminfo;
 
index 55ea9667e31c1cea0fdb89935f0a24c565897dc1..98126ded7ed10fe4c37cfa4d314afb40f7dec01c 100644 (file)
@@ -80,11 +80,11 @@ static const char * ledNames[XDESKTOP_N_LEDS] = {
 };
 
 XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
-  : dpy(dpy_), geometry(geometry_), pb(0), server(0),
-    queryConnectDialog(0), queryConnectSock(0),
+  : dpy(dpy_), geometry(geometry_), pb(nullptr), server(nullptr),
+    queryConnectDialog(nullptr), queryConnectSock(nullptr),
     oldButtonMask(0), haveXtest(false), haveDamage(false),
     maxButtons(0), running(false), ledMasks(), ledState(0),
-    codeMap(0), codeMapLen(0)
+    codeMap(nullptr), codeMapLen(0)
 {
   int major, minor;
 
@@ -108,7 +108,7 @@ XDesktop::XDesktop(Display* dpy_, Geometry *geometry_)
     Bool on;
 
     a = XInternAtom(dpy, ledNames[i], True);
-    if (!a || !XkbGetNamedIndicator(dpy, a, &shift, &on, NULL, NULL))
+    if (!a || !XkbGetNamedIndicator(dpy, a, &shift, &on, nullptr, nullptr))
       continue;
 
     ledMasks[i] = 1u << shift;
@@ -292,12 +292,12 @@ void XDesktop::stop() {
 #endif
 
   delete queryConnectDialog;
-  queryConnectDialog = 0;
+  queryConnectDialog = nullptr;
 
-  server->setPixelBuffer(0);
+  server->setPixelBuffer(nullptr);
 
   delete pb;
-  pb = 0;
+  pb = nullptr;
 }
 
 void XDesktop::terminate() {
@@ -479,7 +479,7 @@ void XDesktop::deleteAddedKeysyms(Display* dpy) {
       if (XkbKeysymToKeycode(dpy, it->first) != it->second)
         continue;
 
-      XkbChangeTypesOfKey(xkb, it->second, 0, XkbGroup1Mask, NULL, &changes);
+      XkbChangeTypesOfKey(xkb, it->second, 0, XkbGroup1Mask, nullptr, &changes);
 
       if (it->second < lowestKeyCode)
         lowestKeyCode = it->second;
@@ -931,7 +931,7 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
     if (cev->window == cev->root)
       return false;
 
-    server->setCursor(0, 0, Point(), NULL);
+    server->setCursor(0, 0, Point(), nullptr);
     return true;
 #endif
   }
@@ -942,8 +942,8 @@ bool XDesktop::handleGlobalEvent(XEvent* ev) {
 void XDesktop::queryApproved()
 {
   assert(isRunning());
-  server->approveConnection(queryConnectSock, true, 0);
-  queryConnectSock = 0;
+  server->approveConnection(queryConnectSock, true, nullptr);
+  queryConnectSock = nullptr;
 }
 
 void XDesktop::queryRejected()
@@ -951,7 +951,7 @@ void XDesktop::queryRejected()
   assert(isRunning());
   server->approveConnection(queryConnectSock, false,
                             "Connection rejected by local user");
-  queryConnectSock = 0;
+  queryConnectSock = nullptr;
 }
 
 #ifdef HAVE_XFIXES
@@ -960,7 +960,7 @@ bool XDesktop::setCursor()
   XFixesCursorImage *cim;
 
   cim = XFixesGetCursorImage(dpy);
-  if (cim == NULL)
+  if (cim == nullptr)
     return false;
 
   // Copied from XserverDesktop::setCursor() in
index b75065135a3921df2beaea747204ce585c9f4a9a..0e24cc513ff098b4719e48bb953dcf61f27042a8 100644 (file)
@@ -35,7 +35,7 @@ using namespace rfb;
 XPixelBuffer::XPixelBuffer(Display *dpy, ImageFactory &factory,
                            const Rect &rect)
   : FullFramePixelBuffer(),
-    m_poller(0),
+    m_poller(nullptr),
     m_dpy(dpy),
     m_image(factory.newImage(dpy, rect.width(), rect.height())),
     m_offsetLeft(rect.tl.x),
index ffaf57889b84b5b7c6530827a096ed490dccc2b7..88c67b0ba345e41327b6f3fd741ccc3a06c741ab 100644 (file)
@@ -90,10 +90,10 @@ static const char* defaultDesktopName()
     return "";
 
   struct passwd* pwent = getpwuid(getuid());
-  if (pwent == NULL)
+  if (pwent == nullptr)
     return "";
 
-  int len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data());
+  int len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data());
   if (len < 0)
     return "";
 
@@ -154,15 +154,15 @@ class FileTcpFilter : public TcpFilter
 public:
 
   FileTcpFilter(const char *fname)
-    : TcpFilter("-"), fileName(NULL), lastModTime(0)
+    : TcpFilter("-"), fileName(nullptr), lastModTime(0)
   {
-    if (fname != NULL)
+    if (fname != nullptr)
       fileName = strdup((char *)fname);
   }
 
   virtual ~FileTcpFilter()
   {
-    if (fileName != NULL)
+    if (fileName != nullptr)
       free(fileName);
   }
 
@@ -182,7 +182,7 @@ protected:
 
   bool reloadRules()
   {
-    if (fileName == NULL)
+    if (fileName == nullptr)
       return true;
 
     struct stat st;
@@ -192,7 +192,7 @@ protected:
     if (st.st_mtime != lastModTime) {
       // Actually reload only if the file was modified
       FILE *fp = fopen(fileName, "r");
-      if (fp == NULL)
+      if (fp == nullptr)
         return false;
 
       // Remove all the rules from the parent class
@@ -225,14 +225,14 @@ private:
 
   bool readLine(char *buf, int bufSize, FILE *fp)
   {
-    if (fp == NULL || buf == NULL || bufSize == 0)
+    if (fp == nullptr || buf == nullptr || bufSize == 0)
       return false;
 
-    if (fgets(buf, bufSize, fp) == NULL)
+    if (fgets(buf, bufSize, fp) == nullptr)
       return false;
 
     char *ptr = strchr(buf, '\n');
-    if (ptr != NULL) {
+    if (ptr != nullptr) {
       *ptr = '\0';              // remove newline at the end
     } else {
       if (!feof(fp)) {
@@ -353,7 +353,7 @@ int main(int argc, char** argv)
       const char *addr = interface;
 
       if (strcasecmp(addr, "all") == 0)
-        addr = 0;
+        addr = nullptr;
       if (localhostOnly)
         createLocalTcpListeners(&tcp_listeners, (int)rfbport);
       else
@@ -436,8 +436,8 @@ int main(int argc, char** argv)
 
       // Do the wait...
       sched.sleepStarted();
-      int n = select(FD_SETSIZE, &rfds, &wfds, 0,
-                     wait_ms ? &tv : NULL);
+      int n = select(FD_SETSIZE, &rfds, &wfds, nullptr,
+                     wait_ms ? &tv : nullptr);
       sched.sleepFinished();
 
       if (n < 0) {
index 25431b6555f350b4cf05d4dc98d61db3d68b604c..2cbee35c51d6e03eddc2590fac688f3e4c05485d 100644 (file)
@@ -51,7 +51,7 @@ void vncLogError(const char *name, const char *format, ...)
   LogWriter *vlog;
   va_list ap;
   vlog = LogWriter::getLogWriter(name);
-  if (vlog == NULL)
+  if (vlog == nullptr)
     return;
   va_start(ap, format);
   vlog->verror(format, ap);
@@ -63,7 +63,7 @@ void vncLogStatus(const char *name, const char *format, ...)
   LogWriter *vlog;
   va_list ap;
   vlog = LogWriter::getLogWriter(name);
-  if (vlog == NULL)
+  if (vlog == nullptr)
     return;
   va_start(ap, format);
   vlog->vstatus(format, ap);
@@ -75,7 +75,7 @@ void vncLogInfo(const char *name, const char *format, ...)
   LogWriter *vlog;
   va_list ap;
   vlog = LogWriter::getLogWriter(name);
-  if (vlog == NULL)
+  if (vlog == nullptr)
     return;
   va_start(ap, format);
   vlog->vinfo(format, ap);
@@ -87,7 +87,7 @@ void vncLogDebug(const char *name, const char *format, ...)
   LogWriter *vlog;
   va_list ap;
   vlog = LogWriter::getLogWriter(name);
-  if (vlog == NULL)
+  if (vlog == nullptr)
     return;
   va_start(ap, format);
   vlog->vdebug(format, ap);
@@ -96,12 +96,12 @@ void vncLogDebug(const char *name, const char *format, ...)
 
 int vncSetParam(const char *name, const char *value)
 {
-  if (value != NULL)
+  if (value != nullptr)
     return rfb::Configuration::setParam(name, value);
   else {
     VoidParameter *param;
     param = rfb::Configuration::getParam(name);
-    if (param == NULL)
+    if (param == nullptr)
       return false;
     return param->setParam();
   }
@@ -118,11 +118,11 @@ char* vncGetParam(const char *name)
 
   // Hack to avoid exposing password!
   if (strcasecmp(name, "Password") == 0)
-    return NULL;
+    return nullptr;
 
   param = rfb::Configuration::getParam(name);
-  if (param == NULL)
-    return NULL;
+  if (param == nullptr)
+    return nullptr;
 
   return strdup(param->getValueStr().c_str());
 }
@@ -132,8 +132,8 @@ const char* vncGetParamDesc(const char *name)
   rfb::VoidParameter *param;
 
   param = rfb::Configuration::getParam(name);
-  if (param == NULL)
-    return NULL;
+  if (param == nullptr)
+    return nullptr;
 
   return param->getDescription();
 }
@@ -144,11 +144,11 @@ int vncIsParamBool(const char *name)
   BoolParameter *bparam;
 
   param = rfb::Configuration::getParam(name);
-  if (param == NULL)
+  if (param == nullptr)
     return false;
 
   bparam = dynamic_cast<BoolParameter*>(param);
-  if (bparam == NULL)
+  if (bparam == nullptr)
     return false;
 
   return true;
@@ -179,8 +179,8 @@ char *vncGetParamList(void)
   }
 
   data = (char*)malloc(len + 1);
-  if (data == NULL)
-    return NULL;
+  if (data == nullptr)
+    return nullptr;
 
   ptr = data;
   for (ParameterIterator i; i.param; i.next()) {
@@ -227,7 +227,7 @@ char* vncConvertLF(const char* src, size_t bytes)
   try {
     return strdup(convertLF(src, bytes).c_str());
   } catch (...) {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -236,7 +236,7 @@ char* vncLatin1ToUTF8(const char* src, size_t bytes)
   try {
     return strdup(latin1ToUTF8(src, bytes).c_str());
   } catch (...) {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -245,7 +245,7 @@ char* vncUTF8ToLatin1(const char* src, size_t bytes)
   try {
     return strdup(utf8ToLatin1(src, bytes).c_str());
   } catch (...) {
-    return NULL;
+    return nullptr;
   }
 }
 
index d4ee16b83e1dff719978da359a87ab285a1b55f4..a38087b415ad319051f772c9ca9d931ebe9f99ce 100644 (file)
@@ -80,7 +80,7 @@ XserverDesktop::XserverDesktop(int screenIndex_,
                                void* fbptr, int stride_)
   : screenIndex(screenIndex_),
     server(0), listeners(listeners_),
-    shadowFramebuffer(NULL),
+    shadowFramebuffer(nullptr),
     queryConnectId(0), queryConnectTimer(this)
 {
   format = pf;
@@ -123,7 +123,7 @@ void XserverDesktop::setFramebuffer(int w, int h, void* fbptr, int stride_)
 
   if (shadowFramebuffer) {
     delete [] shadowFramebuffer;
-    shadowFramebuffer = NULL;
+    shadowFramebuffer = nullptr;
   }
 
   if (!fbptr) {
@@ -521,7 +521,7 @@ void XserverDesktop::handleClipboardData(const char* data_)
 
 void XserverDesktop::grabRegion(const rfb::Region& region)
 {
-  if (shadowFramebuffer == NULL)
+  if (shadowFramebuffer == nullptr)
     return;
 
   std::vector<rfb::Rect> rects;
index 4003e768b328d2b0895df21170f0d75169e6e50c..073b07e2967a630d38fb293a82b0ce65b51fb970 100644 (file)
@@ -114,10 +114,10 @@ static const char* defaultDesktopName()
     return "";
 
   struct passwd* pwent = getpwuid(getuid());
-  if (pwent == NULL)
+  if (pwent == nullptr)
     return "";
 
-  size_t len = snprintf(NULL, 0, "%s@%s", pwent->pw_name, hostname.data());
+  size_t len = snprintf(nullptr, 0, "%s@%s", pwent->pw_name, hostname.data());
   if (len < 0)
     return "";
 
@@ -286,7 +286,7 @@ void vncExtensionClose(void)
   try {
     for (int scr = 0; scr < vncGetScreenCount(); scr++) {
       delete desktop[scr];
-      desktop[scr] = NULL;
+      desktop[scr] = nullptr;
     }
   } catch (rdr::Exception& e) {
     vncFatalError("vncExtInit: %s\n",e.str());
index 1bcf66c9456273988b7f372df2b6bba6ffd33f6d..6552634b4ffe1551b2c4b53c47912bf995fb7e93 100644 (file)
@@ -40,7 +40,7 @@ static const unsigned DOUBLE_TAP_THRESHOLD = 50;
 
 BaseTouchHandler::BaseTouchHandler()
 {
-  gettimeofday(&lastTapTime, NULL);
+  gettimeofday(&lastTapTime, nullptr);
 }
 
 BaseTouchHandler::~BaseTouchHandler()
@@ -188,7 +188,7 @@ void BaseTouchHandler::handleTapEvent(const GestureEvent& ev,
   } else {
     firstDoubleTapEvent = ev;
   }
-  gettimeofday(&lastTapTime, NULL);
+  gettimeofday(&lastTapTime, nullptr);
 
   fakeMotionEvent(newEv);
   fakeButtonEvent(true, buttonEvent, newEv);
index 82c4af410ef7622b687b8f21952020f359715acf..31f5b74dd8a6b4fc32db2d7a4281bdd73e88b8ae 100644 (file)
@@ -72,8 +72,8 @@ static const PixelFormat mediumColourPF(8, 8, false, true,
 // Time new bandwidth estimates are weighted against (in ms)
 static const unsigned bpsEstimateWindow = 1000;
 
-CConn::CConn(const char* vncServerName, network::Socket* socket=NULL)
-  : serverPort(0), desktop(NULL), updateCount(0), pixelCount(0),
+CConn::CConn(const char* vncServerName, network::Socket* socket=nullptr)
+  : serverPort(0), desktop(nullptr), updateCount(0), pixelCount(0),
     lastServerEncoding((unsigned int)-1), bpsEstimate(20000000)
 {
   setShared(::shared);
@@ -90,10 +90,10 @@ CConn::CConn(const char* vncServerName, network::Socket* socket=NULL)
   if (!noJpeg)
     setQualityLevel(::qualityLevel);
 
-  if(sock == NULL) {
+  if(sock == nullptr) {
     try {
 #ifndef WIN32
-      if (strchr(vncServerName, '/') != NULL) {
+      if (strchr(vncServerName, '/') != nullptr) {
         sock = new network::UnixSocket(vncServerName);
         serverHost = sock->getPeerAddress();
         vlog.info(_("Connected to socket %s"), serverHost.c_str());
@@ -346,7 +346,7 @@ void CConn::framebufferUpdateStart()
   CConnection::framebufferUpdateStart();
 
   // For bandwidth estimate
-  gettimeofday(&updateStartTime, NULL);
+  gettimeofday(&updateStartTime, nullptr);
   updateStartPos = sock->inStream().pos();
 
   // Update the screen prematurely for very slow updates
@@ -367,7 +367,7 @@ void CConn::framebufferUpdateEnd()
   updateCount++;
 
   // Calculate bandwidth everything managed to maintain during this update
-  gettimeofday(&now, NULL);
+  gettimeofday(&now, nullptr);
   elapsed = (now.tv_sec - updateStartTime.tv_sec) * 1000000;
   elapsed += now.tv_usec - updateStartTime.tv_usec;
   if (elapsed == 0)
index 7d7ae7c3f482634f0c24ecc66ba1b55fd2008801..b949b0d7f2434357f4d783148f1671f133cea2e4 100644 (file)
@@ -81,18 +81,18 @@ static std::set<DesktopWindow *> instances;
 DesktopWindow::DesktopWindow(int w, int h, const char *name,
                              const rfb::PixelFormat& serverPF,
                              CConn* cc_)
-  : Fl_Window(w, h), cc(cc_), offscreen(NULL), overlay(NULL),
+  : Fl_Window(w, h), cc(cc_), offscreen(nullptr), overlay(nullptr),
     firstUpdate(true),
     delayedFullscreen(false), delayedDesktopSize(false),
     keyboardGrabbed(false), mouseGrabbed(false),
     statsLastUpdates(0), statsLastPixels(0), statsLastPosition(0),
-    statsGraph(NULL)
+    statsGraph(nullptr)
 {
   Fl_Group* group;
 
   // Dummy group to prevent FLTK from moving our widgets around
   group = new Fl_Group(0, 0, w, h);
-  group->resizable(NULL);
+  group->resizable(nullptr);
   resizable(group);
 
   viewport = new Viewport(w, h, serverPF, cc);
@@ -438,7 +438,7 @@ void DesktopWindow::draw()
 #if !defined(__APPLE__)
 
   // Adjust offscreen surface dimensions
-  if ((offscreen == NULL) ||
+  if ((offscreen == nullptr) ||
       (offscreen->width() != w()) || (offscreen->height() != h())) {
     delete offscreen;
     offscreen = new Surface(w(), h());
@@ -786,7 +786,7 @@ void DesktopWindow::setOverlay(const char* text, ...)
 
   overlay = new Surface(image);
   overlayAlpha = 0;
-  gettimeofday(&overlayStart, NULL);
+  gettimeofday(&overlayStart, nullptr);
 
   delete image;
   delete [] buffer;
@@ -814,7 +814,7 @@ void DesktopWindow::updateOverlay(void *data)
     Fl::add_timeout(1.0/60, updateOverlay, self);
   } else {
     delete self->overlay;
-    self->overlay = NULL;
+    self->overlay = nullptr;
   }
 
   self->damage(FL_DAMAGE_USER1);
@@ -891,7 +891,7 @@ int DesktopWindow::fltkDispatch(int event, Fl_Window *win)
   // FLTK keeps spamming bogus FL_MOVE events if _any_ X event is
   // received with the mouse pointer outside our windows
   // https://github.com/fltk/fltk/issues/76
-  if ((event == FL_MOVE) && (win == NULL))
+  if ((event == FL_MOVE) && (win == nullptr))
     return 0;
 
   ret = Fl::handle_(event, win);
@@ -1658,7 +1658,7 @@ void DesktopWindow::handleStatsTimeout(void *data)
   self->stats[statsCount-1].pps = (pixels - self->statsLastPixels) * 1000 / elapsed;
   self->stats[statsCount-1].bps = (pos - self->statsLastPosition) * 1000 / elapsed;
 
-  gettimeofday(&self->statsLastTime, NULL);
+  gettimeofday(&self->statsLastTime, nullptr);
   self->statsLastUpdates = updates;
   self->statsLastPixels = pixels;
   self->statsLastPosition = pos;
index ed99555e79591742214142fbb2b593fa74c11e41..121ceecf22391d2efafe9a442c6d7f232255ab1d 100644 (file)
@@ -95,7 +95,7 @@ void GestureHandler::handleTouchBegin(int id, double x, double y)
     return;
   }
 
-  gettimeofday(&ght.started, NULL);
+  gettimeofday(&ght.started, nullptr);
   ght.active = true;
   ght.lastX = ght.firstX = x;
   ght.lastY = ght.firstY = y;
@@ -238,7 +238,7 @@ void GestureHandler::handleTouchEnd(int id)
     longpressTimer.stop();
 
     if (!waitingRelease) {
-      gettimeofday(&releaseStart, NULL);
+      gettimeofday(&releaseStart, nullptr);
       waitingRelease = true;
 
       // Can't be a tap that requires more touches than we current have
@@ -375,19 +375,19 @@ void GestureHandler::pushEvent(GestureEventType t)
 
   // For most gesture events the current (average) position is the
   // most useful
-  getPosition(NULL, NULL, &avgX, &avgY);
+  getPosition(nullptr, nullptr, &avgX, &avgY);
 
   // However we have a slight distance to detect gestures, so for the
   // first gesture event we want to use the first positions we saw
   if (t == GestureBegin)
-    getPosition(&avgX, &avgY, NULL, NULL);
+    getPosition(&avgX, &avgY, nullptr, nullptr);
 
   // For these gestures, we always want the event coordinates
   // to be where the gesture began, not the current touch location.
   switch (state) {
     case GH_TWODRAG:
     case GH_PINCH:
-      getPosition(&avgX, &avgY, NULL, NULL);
+      getPosition(&avgX, &avgY, nullptr, nullptr);
       break;
   }
 
@@ -398,9 +398,9 @@ void GestureHandler::pushEvent(GestureEventType t)
   if (state == GH_PINCH) {
     if (t == GestureBegin)
       getAverageDistance(&gev.magnitudeX, &gev.magnitudeY,
-                         NULL, NULL);
+                         nullptr, nullptr);
     else
-      getAverageDistance(NULL, NULL,
+      getAverageDistance(nullptr, nullptr,
                          &gev.magnitudeX, &gev.magnitudeY);
   } else if (state == GH_TWODRAG) {
     if (t == GestureBegin)
index dcc762a34e496347d4a1c4c16c0ba38a4c7bce7a..d215d4c2fe95e06e6a982cef396fd34521731cd3 100644 (file)
@@ -134,7 +134,7 @@ static bool parseNumber(std::string number, std::set<int> *indices)
     if (number.size() <= 0)
         return false;
 
-    int v = strtol(number.c_str(), NULL, 0);
+    int v = strtol(number.c_str(), nullptr, 0);
 
     if (v <= 0)
         return false;
index 3c293face488bd302d50c3048884058d6f5e6b77..56bce3d9cfb85c139e9a50bc246b4f4bff30d474 100644 (file)
@@ -123,7 +123,7 @@ OptionsDialog::~OptionsDialog()
 
 void OptionsDialog::showDialog(void)
 {
-  static OptionsDialog *dialog = NULL;
+  static OptionsDialog *dialog = nullptr;
 
   if (!dialog)
     dialog = new OptionsDialog();
@@ -577,7 +577,7 @@ void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
 
   encodingGroup->end();
   /* Needed for resize to work sanely */
-  encodingGroup->resizable(NULL);
+  encodingGroup->resizable(nullptr);
   encodingGroup->size(encodingGroup->w(), ty - encodingGroup->y());
   col1_ty = ty;
 
@@ -629,7 +629,7 @@ void OptionsDialog::createCompressionPage(int tx, int ty, int tw, int th)
 
   colorlevelGroup->end();
   /* Needed for resize to work sanely */
-  colorlevelGroup->resizable(NULL);
+  colorlevelGroup->resizable(nullptr);
   colorlevelGroup->size(colorlevelGroup->w(),
                         ty - colorlevelGroup->y());
   col2_ty = ty;
@@ -745,7 +745,7 @@ void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
 
   encryptionGroup->end();
   /* Needed for resize to work sanely */
-  encryptionGroup->resizable(NULL);
+  encryptionGroup->resizable(nullptr);
   encryptionGroup->size(encryptionGroup->w(),
                         ty - encryptionGroup->y());
 
@@ -787,7 +787,7 @@ void OptionsDialog::createSecurityPage(int tx, int ty, int tw, int th)
 
   authenticationGroup->end();
   /* Needed for resize to work sanely */
-  authenticationGroup->resizable(NULL);
+  authenticationGroup->resizable(nullptr);
   authenticationGroup->size(authenticationGroup->w(),
                             ty - authenticationGroup->y());
 
@@ -847,7 +847,7 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
 
   mouseGroup->end();
   /* Needed for resize to work sanely */
-  mouseGroup->resizable(NULL);
+  mouseGroup->resizable(nullptr);
   mouseGroup->size(mouseGroup->w(), ty - mouseGroup->y());
 
   /* Back to normal */
@@ -873,9 +873,9 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
 
     menuKeyChoice = new Fl_Choice(LBLLEFT(tx, ty, 150, CHOICE_HEIGHT, _("Menu key")));
 
-    fltk_menu_add(menuKeyChoice, _("None"), 0, NULL, (void*)0, FL_MENU_DIVIDER);
+    fltk_menu_add(menuKeyChoice, _("None"), 0, nullptr, nullptr, FL_MENU_DIVIDER);
     for (int i = 0; i < getMenuKeySymbolCount(); i++)
-      fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, NULL, 0, 0);
+      fltk_menu_add(menuKeyChoice, getMenuKeySymbols()[i].name, 0, nullptr, nullptr, 0);
 
     ty += CHOICE_HEIGHT + TIGHT_MARGIN;
   }
@@ -883,7 +883,7 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
 
   keyboardGroup->end();
   /* Needed for resize to work sanely */
-  keyboardGroup->resizable(NULL);
+  keyboardGroup->resizable(nullptr);
   keyboardGroup->size(keyboardGroup->w(), ty - keyboardGroup->y());
 
   /* Back to normal */
@@ -935,7 +935,7 @@ void OptionsDialog::createInputPage(int tx, int ty, int tw, int th)
 
   clipboardGroup->end();
   /* Needed for resize to work sanely */
-  clipboardGroup->resizable(NULL);
+  clipboardGroup->resizable(nullptr);
   clipboardGroup->size(clipboardGroup->w(), ty - clipboardGroup->y());
 
   /* Back to normal */
@@ -1013,7 +1013,7 @@ void OptionsDialog::createDisplayPage(int tx, int ty, int tw, int th)
 
   displayModeGroup->end();
   /* Needed for resize to work sanely */
-  displayModeGroup->resizable(NULL);
+  displayModeGroup->resizable(nullptr);
   displayModeGroup->size(displayModeGroup->w(),
                          ty - displayModeGroup->y());
 
index be08620dcc8b10dc331b41e99483b865219f7820..0129037d18adbf8bce58c2a153392b64259c9cf8 100644 (file)
@@ -42,7 +42,7 @@ protected:
 public:
   static void showDialog(void);
 
-  static void addCallback(OptionsCallback *cb, void *data = NULL);
+  static void addCallback(OptionsCallback *cb, void *data = nullptr);
   static void removeCallback(OptionsCallback *cb);
 
   void show(void);
index 2c91c704568004cb0b0135f7cbadec8ce9c379fb..bcb4cb231e342e02a95c1c200e9f157dcee11138 100644 (file)
@@ -41,16 +41,16 @@ static rfb::LogWriter vlog("PlatformPixelBuffer");
 PlatformPixelBuffer::PlatformPixelBuffer(int width, int height) :
   FullFramePixelBuffer(rfb::PixelFormat(32, 24, false, true,
                                         255, 255, 255, 16, 8, 0),
-                       0, 0, NULL, 0),
+                       0, 0, nullptr, 0),
   Surface(width, height)
 #if !defined(WIN32) && !defined(__APPLE__)
-  , shminfo(NULL), xim(NULL)
+  , shminfo(nullptr), xim(nullptr)
 #endif
 {
 #if !defined(WIN32) && !defined(__APPLE__)
   if (!setupShm(width, height)) {
-    xim = XCreateImage(fl_display, CopyFromParent, 32,
-                       ZPixmap, 0, 0, width, height, 32, 0);
+    xim = XCreateImage(fl_display, (Visual*)CopyFromParent, 32,
+                       ZPixmap, 0, nullptr, width, height, 32, 0);
     if (!xim)
       throw rdr::Exception("XCreateImage");
 
@@ -78,15 +78,15 @@ PlatformPixelBuffer::~PlatformPixelBuffer()
     vlog.debug("Freeing shared memory XImage");
     XShmDetach(fl_display, shminfo);
     shmdt(shminfo->shmaddr);
-    shmctl(shminfo->shmid, IPC_RMID, 0);
+    shmctl(shminfo->shmid, IPC_RMID, nullptr);
     delete shminfo;
-    shminfo = NULL;
+    shminfo = nullptr;
   }
 
   // XDestroyImage() will free(xim->data) if appropriate
   if (xim)
     XDestroyImage(xim);
-  xim = NULL;
+  xim = nullptr;
 #endif
 }
 
@@ -113,7 +113,7 @@ rfb::Rect PlatformPixelBuffer::getDamage(void)
 
   GC gc;
 
-  gc = XCreateGC(fl_display, pixmap, 0, NULL);
+  gc = XCreateGC(fl_display, pixmap, 0, nullptr);
   if (shminfo) {
     XShmPutImage(fl_display, pixmap, gc, xim,
                  r.tl.x, r.tl.y, r.tl.x, r.tl.y,
@@ -147,7 +147,7 @@ bool PlatformPixelBuffer::setupShm(int width, int height)
   int major, minor;
   Bool pixmaps;
   XErrorHandler old_handler;
-  const char *display_name = XDisplayName (NULL);
+  const char *display_name = XDisplayName(nullptr);
 
   /* Don't use MIT-SHM on remote displays */
   if (*display_name && *display_name != ':')
@@ -158,8 +158,8 @@ bool PlatformPixelBuffer::setupShm(int width, int height)
 
   shminfo = new XShmSegmentInfo;
 
-  xim = XShmCreateImage(fl_display, CopyFromParent, 32,
-                        ZPixmap, 0, shminfo, width, height);
+  xim = XShmCreateImage(fl_display, (Visual*)CopyFromParent, 32,
+                        ZPixmap, nullptr, shminfo, width, height);
   if (!xim)
     goto free_shminfo;
 
@@ -169,8 +169,8 @@ bool PlatformPixelBuffer::setupShm(int width, int height)
   if (shminfo->shmid == -1)
     goto free_xim;
 
-  shminfo->shmaddr = xim->data = (char*)shmat(shminfo->shmid, 0, 0);
-  shmctl(shminfo->shmid, IPC_RMID, 0); // to avoid memory leakage
+  shminfo->shmaddr = xim->data = (char*)shmat(shminfo->shmid, nullptr, 0);
+  shmctl(shminfo->shmid, IPC_RMID, nullptr); // to avoid memory leakage
   if (shminfo->shmaddr == (char *)-1)
     goto free_xim;
 
@@ -202,11 +202,11 @@ free_shmaddr:
 
 free_xim:
   XDestroyImage(xim);
-  xim = NULL;
+  xim = nullptr;
 
 free_shminfo:
   delete shminfo;
-  shminfo = NULL;
+  shminfo = nullptr;
 
   return 0;
 }
index 4d57b5fbb9ab1b98258ac4f50491349b61a47023..4827c0fbf32ed195609f338215d52ce1f8c734d0 100644 (file)
@@ -110,7 +110,7 @@ ServerDialog::ServerDialog()
   y += BUTTON_HEIGHT + INNER_MARGIN;
 
   /* Needed for resize to work sanely */
-  resizable(NULL);
+  resizable(nullptr);
   h(y-INNER_MARGIN+OUTER_MARGIN);
 
   callback(this->handleCancel, this);
@@ -146,7 +146,7 @@ void ServerDialog::run(const char* servername, char *newservername)
 
   while (dialog.shown()) Fl::wait();
 
-  if (dialog.serverName->value() == NULL) {
+  if (dialog.serverName->value() == nullptr) {
     newservername[0] = '\0';
     return;
   }
@@ -180,7 +180,7 @@ void ServerDialog::handleLoad(Fl_Widget* /*widget*/, void* data)
     Fl::wait();
   
   // Did the user hit cancel?
-  if (file_chooser->value() == NULL) {
+  if (file_chooser->value() == nullptr) {
     delete(file_chooser);
     return;
   }
@@ -223,7 +223,7 @@ void ServerDialog::handleSaveAs(Fl_Widget* /*widget*/, void* data)
       Fl::wait();
     
     // Did the user hit cancel?
-    if (file_chooser->value() == NULL) {
+    if (file_chooser->value() == nullptr) {
       delete(file_chooser);
       return;
     }
@@ -237,7 +237,7 @@ void ServerDialog::handleSaveAs(Fl_Widget* /*widget*/, void* data)
       // The file already exists.
       fclose(f);
       int overwrite_choice = fl_choice(_("%s already exists. Do you want to overwrite?"), 
-                                       _("Overwrite"), _("No"), NULL, filename);
+                                       _("Overwrite"), _("No"), nullptr, filename);
       if (overwrite_choice == 1) {
 
         // If the user doesn't want to overwrite:
@@ -284,7 +284,7 @@ void ServerDialog::handleConnect(Fl_Widget* /*widget*/, void *data)
   dialog->hide();
 
   try {
-    saveViewerParameters(NULL, servername);
+    saveViewerParameters(nullptr, servername);
   } catch (Exception& e) {
     vlog.error("%s", e.str());
     fl_alert(_("Unable to save the default configuration:\n\n%s"),
@@ -316,7 +316,7 @@ void ServerDialog::loadServerHistory()
 #endif
 
   const char* stateDir = os::getvncstatedir();
-  if (stateDir == NULL)
+  if (stateDir == nullptr)
     throw Exception(_("Could not obtain the state directory path"));
 
   char filepath[PATH_MAX];
@@ -382,7 +382,7 @@ void ServerDialog::saveServerHistory()
 #endif
 
   const char* stateDir = os::getvncstatedir();
-  if (stateDir == NULL)
+  if (stateDir == nullptr)
     throw Exception(_("Could not obtain the state directory path"));
 
   char filepath[PATH_MAX];
index 445c9e6cb8b54d641775a127e4339723f6f74282..864e3b51ab3f8a302c30f8e65f5305e3b68003a5 100644 (file)
@@ -44,8 +44,8 @@ static CGImageRef create_image(CGColorSpaceRef lut,
 
   CGImageRef image;
 
-  provider = CGDataProviderCreateWithData(NULL, data,
-                                          w * h * 4, NULL);
+  provider = CGDataProviderCreateWithData(nullptr, data,
+                                          w * h * 4, nullptr);
   if (!provider)
     throw rdr::Exception("CGDataProviderCreateWithData");
 
@@ -58,7 +58,8 @@ static CGImageRef create_image(CGColorSpaceRef lut,
 
   image = CGImageCreate(w, h, 8, 32, w * 4, lut,
                         alpha | kCGBitmapByteOrder32Little,
-                        provider, NULL, false, kCGRenderingIntentDefault);
+                        provider, nullptr, false,
+                        kCGRenderingIntentDefault);
   CGDataProviderRelease(provider);
   if (!image)
     throw rdr::Exception("CGImageCreate");
index d438fa12aa1f2184cb711351d4bacc5061864c6d..1db5f7185b0ddd1d32957c02d42a688838908e26 100644 (file)
@@ -78,7 +78,7 @@ void Surface::draw(Surface* dst, int src_x, int src_y, int x, int y, int w, int
 {
   HDC origdc, dstdc;
 
-  dstdc = CreateCompatibleDC(NULL);
+  dstdc = CreateCompatibleDC(nullptr);
   if (!dstdc)
     throw rdr::SystemException("CreateCompatibleDC", GetLastError());
 
@@ -106,10 +106,10 @@ void Surface::blend(Surface* dst, int src_x, int src_y, int x, int y, int w, int
   HDC dstdc, srcdc;
   BLENDFUNCTION blend;
 
-  dstdc = CreateCompatibleDC(NULL);
+  dstdc = CreateCompatibleDC(nullptr);
   if (!dstdc)
     throw rdr::SystemException("CreateCompatibleDC", GetLastError());
-  srcdc = CreateCompatibleDC(NULL);
+  srcdc = CreateCompatibleDC(nullptr);
   if (!srcdc)
     throw rdr::SystemException("CreateCompatibleDC", GetLastError());
 
@@ -152,8 +152,8 @@ void Surface::alloc()
   bih.biHeight       = -height(); // Negative to get top-down
   bih.biCompression  = BI_RGB;
 
-  bitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bih,
-                            DIB_RGB_COLORS, (void**)&data, NULL, 0);
+  bitmap = CreateDIBSection(nullptr, (BITMAPINFO*)&bih,
+                            DIB_RGB_COLORS, (void**)&data, nullptr, 0);
   if (!bitmap)
     throw rdr::SystemException("CreateDIBSection", GetLastError());
 }
index 7725cb5b8e683a8c95531132cd27e997fdc245bf..d4d92cf32d5c87e28914afa3698c3a620c5b5530 100644 (file)
@@ -47,7 +47,7 @@ void Surface::draw(int src_x, int src_y, int x, int y, int w, int h)
 {
   Picture winPict;
 
-  winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, NULL);
+  winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, nullptr);
   XRenderComposite(fl_display, PictOpSrc, picture, None, winPict,
                    src_x, src_y, 0, 0, x, y, w, h);
   XRenderFreePicture(fl_display, winPict);
@@ -90,7 +90,7 @@ void Surface::blend(int src_x, int src_y, int x, int y, int w, int h, int a)
 {
   Picture winPict, alpha;
 
-  winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, NULL);
+  winPict = XRenderCreatePicture(fl_display, fl_window, visFormat, 0, nullptr);
   alpha = alpha_mask(a);
   XRenderComposite(fl_display, PictOpOver, picture, alpha, winPict,
                    src_x, src_y, 0, 0, x, y, w, h);
@@ -154,7 +154,7 @@ void Surface::alloc()
   if (!format)
     throw rdr::Exception("XRenderFindFormat");
 
-  picture = XRenderCreatePicture(fl_display, pixmap, format, 0, NULL);
+  picture = XRenderCreatePicture(fl_display, pixmap, format, 0, nullptr);
 
   visFormat = XRenderFindVisualFormat(fl_display, fl_visual->visual);
 }
@@ -177,8 +177,8 @@ void Surface::update(const Fl_RGB_Image* image)
   assert(image->w() == width());
   assert(image->h() == height());
 
-  img = XCreateImage(fl_display, CopyFromParent, 32,
-                     ZPixmap, 0, NULL, width(), height(),
+  img = XCreateImage(fl_display, (Visual*)CopyFromParent, 32,
+                     ZPixmap, 0, nullptr, width(), height(),
                      32, 0);
   if (!img)
     throw rdr::Exception("XCreateImage");
@@ -224,7 +224,7 @@ void Surface::update(const Fl_RGB_Image* image)
       in += image->ld() - image->w() * image->d();
   }
 
-  gc = XCreateGC(fl_display, pixmap, 0, NULL);
+  gc = XCreateGC(fl_display, pixmap, 0, nullptr);
   XPutImage(fl_display, pixmap, gc, img,
             0, 0, 0, 0, img->width, img->height);
   XFreeGC(fl_display, gc);
index 7f8b3c8e6aa3b2fb2e7f1ba7270a8e0b458e3708..41df5bb4be9db4774ead6735a1e8480b635ef112 100644 (file)
@@ -55,10 +55,10 @@ using namespace rfb;
 static Fl_Pixmap secure_icon(secure);
 static Fl_Pixmap insecure_icon(insecure);
 
-static int ret_val = 0;
+static long ret_val = 0;
 
-static void button_cb(Fl_Widget *widget, void *val) {
-  ret_val = (fl_intptr_t)val;
+static void button_cb(Fl_Widget *widget, long val) {
+  ret_val = val;
   widget->window()->hide();
 }
 
@@ -116,7 +116,7 @@ void UserDialog::getUserPasswd(bool secure, std::string* user,
   int x, y;
 
   win = new Fl_Window(410, 0, _("VNC authentication"));
-  win->callback(button_cb,(void *)0);
+  win->callback(button_cb, 0);
 
   banner = new Fl_Box(0, 0, win->w(), 20);
   banner->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_IMAGE_NEXT_TO_TEXT);
@@ -156,7 +156,7 @@ void UserDialog::getUserPasswd(bool secure, std::string* user,
      * Compiler is not bright enough to understand that
      * username won't be used further down...
      */
-    username = NULL;
+    username = nullptr;
   }
 
   y += INPUT_LABEL_OFFSET;
@@ -171,12 +171,12 @@ void UserDialog::getUserPasswd(bool secure, std::string* user,
   x -= BUTTON_WIDTH;
   button = new Fl_Return_Button(x, y, BUTTON_WIDTH,
                                 BUTTON_HEIGHT, fl_ok);
-  button->callback(button_cb, (void*)0);
+  button->callback(button_cb, 0);
   x -= INNER_MARGIN;
 
   x -= BUTTON_WIDTH;
   button = new Fl_Button(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, fl_cancel);
-  button->callback(button_cb, (void*)1);
+  button->callback(button_cb, 1);
   button->shortcut(FL_Escape);
   x -= INNER_MARGIN;
 
@@ -221,9 +221,9 @@ bool UserDialog::showMsgBox(int flags, const char* title, const char* text)
 
   switch (flags & 0xf) {
   case M_OKCANCEL:
-    return fl_choice("%s", NULL, fl_ok, fl_cancel, buffer) == 1;
+    return fl_choice("%s", nullptr, fl_ok, fl_cancel, buffer) == 1;
   case M_YESNO:
-    return fl_choice("%s", NULL, fl_yes, fl_no, buffer) == 1;
+    return fl_choice("%s", nullptr, fl_yes, fl_no, buffer) == 1;
   case M_OK:
   default:
     if (((flags & 0xf0) == M_ICONERROR) ||
index 5dd5f7efc56f99dd00af2a3e2c0665e20e42f64d..bbccc2f925167e1e00765fd674174091da47c0b7 100644 (file)
@@ -116,13 +116,13 @@ static const WORD SCAN_FAKE = 0xaa;
 #endif
 
 Viewport::Viewport(int w, int h, const rfb::PixelFormat& /*serverPF*/, CConn* cc_)
-  : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(NULL),
+  : Fl_Widget(0, 0, w, h), cc(cc_), frameBuffer(nullptr),
     lastPointerPos(0, 0), lastButtonMask(0),
 #ifdef WIN32
     altGrArmed(false),
 #endif
     firstLEDState(true), pendingClientClipboard(false),
-    menuCtrlKey(false), menuAltKey(false), cursor(NULL)
+    menuCtrlKey(false), menuAltKey(false), cursor(nullptr)
 {
 #if !defined(WIN32) && !defined(__APPLE__)
   XkbDescPtr xkb;
@@ -188,7 +188,7 @@ Viewport::Viewport(int w, int h, const rfb::PixelFormat& /*serverPF*/, CConn* cc
   OptionsDialog::addCallback(handleOptions, this);
 
   // Make sure we have an initial blank cursor set
-  setCursor(0, 0, rfb::Point(0, 0), NULL);
+  setCursor(0, 0, rfb::Point(0, 0), nullptr);
 }
 
 
@@ -702,7 +702,7 @@ unsigned int Viewport::getModifierMask(unsigned int keysym)
   mask = 0;
 
   xkb = XkbGetMap(fl_display, XkbAllComponentsMask, XkbUseCoreKbd);
-  if (xkb == NULL)
+  if (xkb == nullptr)
     return 0;
 
   for (keycode = xkb->min_key_code; keycode <= xkb->max_key_code; keycode++) {
@@ -722,7 +722,7 @@ unsigned int Viewport::getModifierMask(unsigned int keysym)
     goto out;
 
   act = XkbKeyAction(xkb, keycode, 0);
-  if (act == NULL)
+  if (act == nullptr)
     goto out;
   if (act->type != XkbSA_LockMods)
     goto out;
@@ -1164,7 +1164,7 @@ int Viewport::handleSystemEvent(void *event, void *data)
     if (keycode == 0)
         keycode = 0x100 | xevent->xkey.keycode;
 
-    XLookupString(&xevent->xkey, &str, 1, &keysym, NULL);
+    XLookupString(&xevent->xkey, &str, 1, &keysym, nullptr);
     if (keysym == NoSymbol) {
       vlog.error(_("No symbol for key code %d (in the current state)"),
                  (int)xevent->xkey.keycode);
@@ -1227,45 +1227,46 @@ void Viewport::initContextMenu()
   contextMenu->clear();
 
   fltk_menu_add(contextMenu, p_("ContextMenu|", "Disconn&ect"),
-                0, NULL, (void*)ID_DISCONNECT, FL_MENU_DIVIDER);
+                0, nullptr, (void*)ID_DISCONNECT, FL_MENU_DIVIDER);
 
   fltk_menu_add(contextMenu, p_("ContextMenu|", "&Full screen"),
-                0, NULL, (void*)ID_FULLSCREEN,
+                0, nullptr, (void*)ID_FULLSCREEN,
                 FL_MENU_TOGGLE | (window()->fullscreen_active()?FL_MENU_VALUE:0));
   fltk_menu_add(contextMenu, p_("ContextMenu|", "Minimi&ze"),
-                0, NULL, (void*)ID_MINIMIZE, 0);
+                0, nullptr, (void*)ID_MINIMIZE, 0);
   fltk_menu_add(contextMenu, p_("ContextMenu|", "Resize &window to session"),
-                0, NULL, (void*)ID_RESIZE,
+                0, nullptr, (void*)ID_RESIZE,
                 (window()->fullscreen_active()?FL_MENU_INACTIVE:0) |
                 FL_MENU_DIVIDER);
 
   fltk_menu_add(contextMenu, p_("ContextMenu|", "&Ctrl"),
-                0, NULL, (void*)ID_CTRL,
+                0, nullptr, (void*)ID_CTRL,
                 FL_MENU_TOGGLE | (menuCtrlKey?FL_MENU_VALUE:0));
   fltk_menu_add(contextMenu, p_("ContextMenu|", "&Alt"),
-                0, NULL, (void*)ID_ALT,
+                0, nullptr, (void*)ID_ALT,
                 FL_MENU_TOGGLE | (menuAltKey?FL_MENU_VALUE:0));
 
   if (menuKeySym) {
     char sendMenuKey[64];
     snprintf(sendMenuKey, 64, p_("ContextMenu|", "Send %s"), (const char *)menuKey);
-    fltk_menu_add(contextMenu, sendMenuKey, 0, NULL, (void*)ID_MENUKEY, 0);
-    fltk_menu_add(contextMenu, "Secret shortcut menu key", menuKeyFLTK, NULL,
+    fltk_menu_add(contextMenu, sendMenuKey, 0, nullptr, (void*)ID_MENUKEY, 0);
+    fltk_menu_add(contextMenu, "Secret shortcut menu key",
+                  menuKeyFLTK, nullptr,
                   (void*)ID_MENUKEY, FL_MENU_INVISIBLE);
   }
 
   fltk_menu_add(contextMenu, p_("ContextMenu|", "Send Ctrl-Alt-&Del"),
-                0, NULL, (void*)ID_CTRLALTDEL, FL_MENU_DIVIDER);
+                0, nullptr, (void*)ID_CTRLALTDEL, FL_MENU_DIVIDER);
 
   fltk_menu_add(contextMenu, p_("ContextMenu|", "&Refresh screen"),
-                0, NULL, (void*)ID_REFRESH, FL_MENU_DIVIDER);
+                0, nullptr, (void*)ID_REFRESH, FL_MENU_DIVIDER);
 
   fltk_menu_add(contextMenu, p_("ContextMenu|", "&Options..."),
-                0, NULL, (void*)ID_OPTIONS, 0);
+                0, nullptr, (void*)ID_OPTIONS, 0);
   fltk_menu_add(contextMenu, p_("ContextMenu|", "Connection &info..."),
-                0, NULL, (void*)ID_INFO, 0);
+                0, nullptr, (void*)ID_INFO, 0);
   fltk_menu_add(contextMenu, p_("ContextMenu|", "About &TigerVNC viewer..."),
-                0, NULL, (void*)ID_ABOUT, 0);
+                0, nullptr, (void*)ID_ABOUT, 0);
 }
 
 
@@ -1297,7 +1298,7 @@ void Viewport::popupContextMenu()
   if (Fl::belowmouse())
     window()->cursor(cursor, cursorHotspot.x, cursorHotspot.y);
 
-  if (m == NULL)
+  if (m == nullptr)
     return;
 
   switch (m->argument()) {
index d6dc7aa4282cc2ca0c2596e215cc571d78c380be..5353127d06a4cd96d09040d0cd95845f3fed6c8a 100644 (file)
@@ -43,7 +43,7 @@ Win32TouchHandler::Win32TouchHandler(HWND hWnd) :
 {
   // If window is registered as touch we can not receive gestures,
   // this should not happen
-  if (IsTouchWindow(hWnd, NULL))
+  if (IsTouchWindow(hWnd, nullptr))
     throw rfb::Exception(_("Window is registered for touch instead of gestures"));
 
   // We will not receive any touch/gesture events if this service
index 6203bda584d731c371596dd4948eb88d4eb52ca6..8fdb46a3e99a5c0740260ab93b382362243832bd 100644 (file)
@@ -97,7 +97,7 @@ bool XInputTouchHandler::grabPointer()
 
   // We grab for the same events as the window is currently interested in
   curmasks = XIGetSelectedEvents(fl_display, wnd, &num_masks);
-  if (curmasks == NULL) {
+  if (curmasks == nullptr) {
     if (num_masks == -1)
       vlog.error(_("Unable to get X Input 2 event mask for window 0x%08lx"), wnd);
     else
index d801a106e33981ff2f9d0ce12ab9ec5573df8031..a355b484369df243fa628444ba3b6a798d9d68e5 100644 (file)
@@ -301,7 +301,7 @@ static NSString *key_translate(UInt16 keyCode, UInt32 modifierFlags)
   const UCKeyboardLayout *layout;
   OSStatus err;
 
-  layout = NULL;
+  layout = nullptr;
 
   TISInputSourceRef keyboard;
   CFDataRef uchr;
@@ -309,11 +309,11 @@ static NSString *key_translate(UInt16 keyCode, UInt32 modifierFlags)
   keyboard = TISCopyCurrentKeyboardLayoutInputSource();
   uchr = (CFDataRef)TISGetInputSourceProperty(keyboard,
                                               kTISPropertyUnicodeKeyLayoutData);
-  if (uchr == NULL)
+  if (uchr == nullptr)
     return nil;
 
   layout = (const UCKeyboardLayout*)CFDataGetBytePtr(uchr);
-  if (layout == NULL)
+  if (layout == nullptr)
     return nil;
 
   UInt32 dead_state;
index 7c72ff68f2df2a7821f54c0266d6c602bcfbd702..02011e1fc0d1eeabdd74dcaeb77563276b2706ca 100644 (file)
@@ -379,7 +379,7 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
 
   Fl::screen_xywh(x, y, w, h, m);
 
-  EnumDisplayMonitors(NULL, NULL, EnumDisplayMonitorsCallback,
+  EnumDisplayMonitors(nullptr, nullptr, EnumDisplayMonitorsCallback,
                       (LPARAM)&sys_monitors);
 
   for (iter = sys_monitors.begin(); iter != sys_monitors.end(); ++iter) {
@@ -441,11 +441,11 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
 
   info = IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID),
                                        kIODisplayOnlyPreferredName);
-  if (info == NULL)
+  if (info == nullptr)
     return "";
 
   dict = (CFDictionaryRef) CFDictionaryGetValue(info, CFSTR(kDisplayProductName));
-  if (dict == NULL) {
+  if (dict == nullptr) {
     CFRelease(info);
     return "";
   }
@@ -454,7 +454,7 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
 
   if (dict_len > 0) {
     CFTypeRef * names = new CFTypeRef[dict_len];
-    CFDictionaryGetKeysAndValues(dict, NULL, (const void **) names);
+    CFDictionaryGetKeysAndValues(dict, nullptr, (const void **) names);
 
     if (names[0]) {
 
@@ -496,7 +496,7 @@ std::string Fl_Monitor_Arrangement::get_monitor_name(int m)
   std::string name;
 
   fl_open_display();
-  assert(fl_display != NULL);
+  assert(fl_display != nullptr);
   Fl::screen_xywh(x, y, w, h, m);
 
   if (!XQueryExtension(fl_display, "RANDR", &xi_major, &ev, &err))
index 603c69ce85cfbde5ace40b19f80b1785db8950aa..d3117aae32c89a3e9e9772d8ffa946e5e199ae2a 100644 (file)
@@ -72,7 +72,7 @@ Fl_Widget *Fl_Navigation::value()
       return pages->child(i);
   }
 
-  return NULL;
+  return nullptr;
 }
 
 int Fl_Navigation::value(Fl_Widget *newpage)
@@ -145,7 +145,7 @@ void Fl_Navigation::update_labels()
   int i, offset;
 
   labels->clear();
-  labels->resizable(NULL);
+  labels->resizable(nullptr);
 
   if (!pages->children())
     return;
index 22e04dc66f2fb25960d9f97d587f70838f841172..2b37fb6ef7bda8124d48a38d41c7cd78823a1c67 100644 (file)
@@ -313,10 +313,10 @@ void init_theme()
   CTFontRef font;
   CFStringRef name;
 
-  font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, NULL);
-  if (font != NULL) {
+  font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, nullptr);
+  if (font != nullptr) {
     name = CTFontCopyFullName(font);
-    if (name != NULL) {
+    if (name != nullptr) {
       CFStringGetCString(name, font_name, sizeof(font_name),
                          kCFStringEncodingUTF8);
 
index 877653964c930a46ef54890cb330bb3b4f7be904..9ce3c7aa4b80282e3fc998f3180c3189b9726703 100644 (file)
@@ -97,7 +97,7 @@ static inline size_t fltk_menu_escape(const char *in, char *out, size_t maxlen)
 /* Helper to add menu entries safely */
 static inline void fltk_menu_add(Fl_Menu_ *menu, const char *text,
                                  int shortcut, Fl_Callback *cb,
-                                 void *data = 0, int flags = 0)
+                                 void *data=nullptr, int flags=0)
 {
     char buffer[1024];
 
index 768a699527f4e0d4542ebc6e5e7041aa4464092d..09473d976232b35a6bcd9a601abc7c10e88d9f36 100644 (file)
    pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
 #else
 # define pgettext(Msgctxt, Msgid) \
-   pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+   pgettext_aux (nullptr, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
 #endif
 #define dpgettext(Domainname, Msgctxt, Msgid) \
   pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
    npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
 #else
 # define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
-   npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+   npgettext_aux (nullptr, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
 #endif
 #define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
   npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
@@ -197,7 +197,7 @@ npgettext_aux (const char *domain,
 #endif
 
 #define pgettext_expr(Msgctxt, Msgid) \
-  dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+  dcpgettext_expr (nullptr, Msgctxt, Msgid, LC_MESSAGES)
 #define dpgettext_expr(Domainname, Msgctxt, Msgid) \
   dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
 
@@ -224,7 +224,7 @@ dcpgettext_expr (const char *domain,
     (msgctxt_len + msgid_len <= sizeof (buf)
      ? buf
      : (char *) malloc (msgctxt_len + msgid_len));
-  if (msg_ctxt_id != NULL)
+  if (msg_ctxt_id != nullptr)
 #endif
     {
       int found_translation;
@@ -244,7 +244,7 @@ dcpgettext_expr (const char *domain,
 }
 
 #define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
-  dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+  dcnpgettext_expr (nullptr, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
 #define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
   dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
 
@@ -272,7 +272,7 @@ dcnpgettext_expr (const char *domain,
     (msgctxt_len + msgid_len <= sizeof (buf)
      ? buf
      : (char *) malloc (msgctxt_len + msgid_len));
-  if (msg_ctxt_id != NULL)
+  if (msg_ctxt_id != nullptr)
 #endif
     {
       int found_translation;
index 15ea4ee80ce74f30e1db89651caff836880155b7..518d3a257c8c93ee076ef95977a1886df71be523 100644 (file)
@@ -350,7 +350,7 @@ static bool getKeyString(const char* _name, char* dest, size_t destSize, HKEY* h
 
   value = new WCHAR[destSize];
   valuesize = destSize;
-  LONG res = RegQueryValueExW(*hKey, name, 0, NULL, (LPBYTE)value, &valuesize);
+  LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)value, &valuesize);
   if (res != ERROR_SUCCESS){
     delete [] value;
     if (res != ERROR_FILE_NOT_FOUND)
@@ -388,7 +388,7 @@ static bool getKeyInt(const char* _name, int* dest, HKEY* hKey) {
   if (size >= buffersize)
     throw Exception(_("The name of the parameter is too large"));
 
-  LONG res = RegQueryValueExW(*hKey, name, 0, NULL, (LPBYTE)&value, &dwordsize);
+  LONG res = RegQueryValueExW(*hKey, name, nullptr, nullptr, (LPBYTE)&value, &dwordsize);
   if (res != ERROR_SUCCESS){
     if (res != ERROR_FILE_NOT_FOUND)
       throw rdr::SystemException("RegQueryValueExW", res);
@@ -420,9 +420,9 @@ static void removeValue(const char* _name, HKEY* hKey) {
 void saveHistoryToRegKey(const vector<string>& serverHistory) {
   HKEY hKey;
   LONG res = RegCreateKeyExW(HKEY_CURRENT_USER,
-                             L"Software\\TigerVNC\\vncviewer\\history", 0, NULL,
-                             REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
-                             &hKey, NULL);
+                             L"Software\\TigerVNC\\vncviewer\\history", 0, nullptr,
+                             REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
+                             &hKey, nullptr);
 
   if (res != ERROR_SUCCESS)
     throw rdr::SystemException(_("Failed to create registry key"), res);
@@ -452,9 +452,9 @@ static void saveToReg(const char* servername) {
   HKEY hKey;
     
   LONG res = RegCreateKeyExW(HKEY_CURRENT_USER,
-                             L"Software\\TigerVNC\\vncviewer", 0, NULL,
-                             REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
-                             &hKey, NULL);
+                             L"Software\\TigerVNC\\vncviewer", 0, nullptr,
+                             REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr,
+                             &hKey, nullptr);
   if (res != ERROR_SUCCESS)
     throw rdr::SystemException(_("Failed to create registry key"), res);
 
@@ -468,11 +468,11 @@ static void saveToReg(const char* servername) {
 
   for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
     try {
-      if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
+      if (dynamic_cast<StringParameter*>(parameterArray[i]) != nullptr) {
         setKeyString(parameterArray[i]->getName(), *(StringParameter*)parameterArray[i], &hKey);
-      } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != NULL) {
+      } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != nullptr) {
         setKeyInt(parameterArray[i]->getName(), (int)*(IntParameter*)parameterArray[i], &hKey);
-      } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
+      } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != nullptr) {
         setKeyInt(parameterArray[i]->getName(), (int)*(BoolParameter*)parameterArray[i], &hKey);
       } else {
         throw Exception(_("Unknown parameter type"));
@@ -553,13 +553,13 @@ static void getParametersFromReg(VoidParameter* parameters[],
 
   for (size_t i = 0; i < parameters_len/sizeof(VoidParameter*); i++) {
     try {
-      if (dynamic_cast<StringParameter*>(parameters[i]) != NULL) {
+      if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) {
         if (getKeyString(parameters[i]->getName(), stringValue, buffersize, hKey))
           parameters[i]->setParam(stringValue);
-      } else if (dynamic_cast<IntParameter*>(parameters[i]) != NULL) {
+      } else if (dynamic_cast<IntParameter*>(parameters[i]) != nullptr) {
         if (getKeyInt(parameters[i]->getName(), &intValue, hKey))
           ((IntParameter*)parameters[i])->setParam(intValue);
-      } else if (dynamic_cast<BoolParameter*>(parameters[i]) != NULL) {
+      } else if (dynamic_cast<BoolParameter*>(parameters[i]) != nullptr) {
         if (getKeyInt(parameters[i]->getName(), &intValue, hKey))
           ((BoolParameter*)parameters[i])->setParam(intValue);
       } else {
@@ -583,7 +583,7 @@ static char* loadFromReg() {
   if (res != ERROR_SUCCESS) {
     if (res == ERROR_FILE_NOT_FOUND) {
       // The key does not exist, defaults will be used.
-      return NULL;
+      return nullptr;
     }
 
     throw rdr::SystemException(_("Failed to open registry key"), res);
@@ -622,7 +622,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
   char encodingBuffer[buffersize];
 
   // Write to the registry or a predefined file if no filename was specified.
-  if(filename == NULL) {
+  if(filename == nullptr) {
 
 #ifdef _WIN32
     saveToReg(servername);
@@ -630,7 +630,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
 #endif
     
     const char* configDir = os::getvncconfigdir();
-    if (configDir == NULL)
+    if (configDir == nullptr)
       throw Exception(_("Could not obtain the config directory path"));
 
     snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
@@ -655,7 +655,7 @@ void saveViewerParameters(const char *filename, const char *servername) {
   fprintf(f, "ServerName=%s\n", encodingBuffer);
 
   for (size_t i = 0; i < sizeof(parameterArray)/sizeof(VoidParameter*); i++) {
-    if (dynamic_cast<StringParameter*>(parameterArray[i]) != NULL) {
+    if (dynamic_cast<StringParameter*>(parameterArray[i]) != nullptr) {
       if (!encodeValue(*(StringParameter*)parameterArray[i],
           encodingBuffer, buffersize)) {
         fclose(f);
@@ -664,9 +664,9 @@ void saveViewerParameters(const char *filename, const char *servername) {
                         _("Could not encode parameter"));
       }
       fprintf(f, "%s=%s\n", ((StringParameter*)parameterArray[i])->getName(), encodingBuffer);
-    } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != NULL) {
+    } else if (dynamic_cast<IntParameter*>(parameterArray[i]) != nullptr) {
       fprintf(f, "%s=%d\n", ((IntParameter*)parameterArray[i])->getName(), (int)*(IntParameter*)parameterArray[i]);
-    } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != NULL) {
+    } else if (dynamic_cast<BoolParameter*>(parameterArray[i]) != nullptr) {
       fprintf(f, "%s=%d\n", ((BoolParameter*)parameterArray[i])->getName(), (int)*(BoolParameter*)parameterArray[i]);
     } else {      
       fclose(f);
@@ -688,7 +688,7 @@ static bool findAndSetViewerParameterFromValue(
   // Find and set the correct parameter
   for (size_t i = 0; i < parameters_len/sizeof(VoidParameter*); i++) {
 
-    if (dynamic_cast<StringParameter*>(parameters[i]) != NULL) {
+    if (dynamic_cast<StringParameter*>(parameters[i]) != nullptr) {
       if (strcasecmp(line, ((StringParameter*)parameters[i])->getName()) == 0) {
         if(!decodeValue(value, decodingBuffer, sizeof(decodingBuffer)))
           throw Exception(_("Invalid format or too large value"));
@@ -696,13 +696,13 @@ static bool findAndSetViewerParameterFromValue(
         return false;
       }
 
-    } else if (dynamic_cast<IntParameter*>(parameters[i]) != NULL) {
+    } else if (dynamic_cast<IntParameter*>(parameters[i]) != nullptr) {
       if (strcasecmp(line, ((IntParameter*)parameters[i])->getName()) == 0) {
         ((IntParameter*)parameters[i])->setParam(atoi(value));
         return false;
       }
 
-    } else if (dynamic_cast<BoolParameter*>(parameters[i]) != NULL) {
+    } else if (dynamic_cast<BoolParameter*>(parameters[i]) != nullptr) {
       if (strcasecmp(line, ((BoolParameter*)parameters[i])->getName()) == 0) {
         ((BoolParameter*)parameters[i])->setParam(atoi(value));
         return false;
@@ -727,14 +727,14 @@ char* loadViewerParameters(const char *filename) {
   memset(servername, '\0', sizeof(servername));
 
   // Load from the registry or a predefined file if no filename was specified.
-  if(filename == NULL) {
+  if(filename == nullptr) {
 
 #ifdef _WIN32
     return loadFromReg();
 #endif
 
     const char* configDir = os::getvncconfigdir();
-    if (configDir == NULL)
+    if (configDir == nullptr)
       throw Exception(_("Could not obtain the config directory path"));
 
     snprintf(filepath, sizeof(filepath), "%s/default.tigervnc", configDir);
@@ -746,7 +746,7 @@ char* loadViewerParameters(const char *filename) {
   FILE* f = fopen(filepath, "r");
   if (!f) {
     if (!filename)
-      return NULL; // Use defaults.
+      return nullptr; // Use defaults.
     throw Exception(_("Could not open \"%s\": %s"),
                     filepath, strerror(errno));
   }
@@ -797,7 +797,7 @@ char* loadViewerParameters(const char *filename) {
 
     // Find the parameter value
     char *value = strchr(line, '=');
-    if (value == NULL) {
+    if (value == nullptr) {
       vlog.error(_("Failed to read line %d in file %s: %s"),
                  lineNr, filepath, _("Invalid format"));
       continue;
@@ -836,7 +836,8 @@ char* loadViewerParameters(const char *filename) {
       vlog.error(_("Failed to read line %d in file %s: %s"),
                  lineNr, filepath, _("Unknown parameter"));
   }
-  fclose(f); f=0;
-  
+  fclose(f);
+  f = nullptr;
+
   return servername;
 }
index 1dd9aca2e3b687ffcd0da4f6692ecbe82d049dc9..df7bc420590665276c24c2e41b549649c6da2d8d 100644 (file)
@@ -80,7 +80,7 @@ extern rfb::BoolParameter reconnectOnError;
 extern rfb::StringParameter via;
 #endif
 
-void saveViewerParameters(const char *filename, const char *servername=NULL);
+void saveViewerParameters(const char *filename, const char *servername=nullptr);
 char* loadViewerParameters(const char *filename);
 
 #ifdef _WIN32
index d4f4098af61c34dc0c7b971aa848514156ec4199..1efd3e460dc2997bf3eb4e8c4566347073145028 100644 (file)
@@ -103,7 +103,7 @@ static void x11_change_touch_ownership(bool enable)
 
   for (iter = handlers.begin(); iter != handlers.end(); ++iter) {
     curmasks = XIGetSelectedEvents(fl_display, iter->first, &num_masks);
-    if (curmasks == NULL) {
+    if (curmasks == nullptr) {
       if (num_masks == -1)
         vlog.error(_("Unable to get X Input 2 event mask for window 0x%08lx"), iter->first);
       continue;
@@ -267,7 +267,7 @@ void enable_touch()
     vlog.error(_("X Input 2.2 (or newer) is not available. Touch gestures will not be supported."));
 #endif
 
-  Fl::add_system_handler(handleTouchEvent, NULL);
+  Fl::add_system_handler(handleTouchEvent, nullptr);
 }
 
 void disable_touch()
index 366327faf8a48530f7b08487f81f7798d396a6ae..6a0093f7c91f47f8f3d1088c5c10cb5153a22866 100644 (file)
@@ -86,11 +86,11 @@ using namespace rfb;
 
 char vncServerName[VNCSERVERNAMELEN] = { '\0' };
 
-static const char *argv0 = NULL;
+static const char *argv0 = nullptr;
 
 static bool inMainloop = false;
 static bool exitMainloop = false;
-static char *exitError = NULL;
+static char *exitError = nullptr;
 static bool fatalError = false;
 
 static const char *about_text()
@@ -117,7 +117,7 @@ void abort_vncviewer(const char *error, ...)
 
   // Prioritise the first error we get as that is probably the most
   // relevant one.
-  if (exitError == NULL) {
+  if (exitError == nullptr) {
     va_list ap;
 
     va_start(ap, error);
@@ -130,7 +130,7 @@ void abort_vncviewer(const char *error, ...)
     exitMainloop = true;
   else {
     // We're early in the startup. Assume we can just exit().
-    if (alertOnFatalError && (exitError != NULL))
+    if (alertOnFatalError && (exitError != nullptr))
       fl_alert("%s", exitError);
     exit(EXIT_FAILURE);
   }
@@ -142,7 +142,7 @@ void abort_connection(const char *error, ...)
 
   // Prioritise the first error we get as that is probably the most
   // relevant one.
-  if (exitError == NULL) {
+  if (exitError == nullptr) {
     va_list ap;
 
     va_start(ap, error);
@@ -200,22 +200,22 @@ static void mainloop(const char* vncserver, network::Socket* sock)
     delete cc;
 
     if (fatalError) {
-      assert(exitError != NULL);
+      assert(exitError != nullptr);
       if (alertOnFatalError)
         fl_alert("%s", exitError);
       break;
     }
 
-    if (exitError == NULL)
+    if (exitError == nullptr)
       break;
 
-    if(reconnectOnError && (sock == NULL)) {
+    if(reconnectOnError && (sock == nullptr)) {
       int ret;
       ret = fl_choice(_("%s\n\n"
                         "Attempt to reconnect?"),
-                      NULL, fl_yes, fl_no, exitError);
+                      nullptr, fl_yes, fl_no, exitError);
       free(exitError);
-      exitError = NULL;
+      exitError = nullptr;
       if (ret == 1)
         continue;
       else
@@ -250,7 +250,7 @@ static void new_connection_cb(Fl_Widget* /*widget*/, void* /*data*/)
     return;
 
   argv[0] = argv0;
-  argv[1] = NULL;
+  argv[1] = nullptr;
 
   execvp(argv[0], (char * const *)argv);
 
@@ -273,16 +273,16 @@ static const char* getlocaledir()
   static char localebuf[PATH_MAX];
   char *slash;
 
-  GetModuleFileName(NULL, localebuf, sizeof(localebuf));
+  GetModuleFileName(nullptr, localebuf, sizeof(localebuf));
 
   slash = strrchr(localebuf, '\\');
-  if (slash == NULL)
-    return NULL;
+  if (slash == nullptr)
+    return nullptr;
 
   *slash = '\0';
 
   if ((strlen(localebuf) + strlen("\\locale")) >= sizeof(localebuf))
-    return NULL;
+    return nullptr;
 
   strcat(localebuf, "\\locale");
 
@@ -296,13 +296,13 @@ static const char* getlocaledir()
   static char localebuf[PATH_MAX];
 
   bundle = CFBundleGetMainBundle();
-  if (bundle == NULL)
-    return NULL;
+  if (bundle == nullptr)
+    return nullptr;
 
   localeurl = CFBundleCopyResourceURL(bundle, CFSTR("locale"),
-                                      NULL, NULL);
-  if (localeurl == NULL)
-    return NULL;
+                                      nullptr, nullptr);
+  if (localeurl == nullptr)
+    return nullptr;
 
   localestr = CFURLCopyFileSystemPath(localeurl, kCFURLPOSIXPathStyle);
 
@@ -311,7 +311,7 @@ static const char* getlocaledir()
   ret = CFStringGetCString(localestr, localebuf, sizeof(localebuf),
                            kCFStringEncodingUTF8);
   if (!ret)
-    return NULL;
+    return nullptr;
 
   return localebuf;
 #else
@@ -331,11 +331,13 @@ static void init_fltk()
 #ifdef WIN32
   HICON lg, sm;
 
-  lg = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
+  lg = (HICON)LoadImage(GetModuleHandle(nullptr),
+                        MAKEINTRESOURCE(IDI_ICON),
                         IMAGE_ICON, GetSystemMetrics(SM_CXICON),
                         GetSystemMetrics(SM_CYICON),
                         LR_DEFAULTCOLOR | LR_SHARED);
-  sm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON),
+  sm = (HICON)LoadImage(GetModuleHandle(nullptr),
+                        MAKEINTRESOURCE(IDI_ICON),
                         IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
                         GetSystemMetrics(SM_CYSMICON),
                         LR_DEFAULTCOLOR | LR_SHARED);
@@ -412,7 +414,7 @@ static void init_fltk()
   Fl_Mac_App_Menu::hide_others = _("Hide Others");
   Fl_Mac_App_Menu::show = _("Show All");
 
-  fl_mac_set_about(about_callback, NULL);
+  fl_mac_set_about(about_callback, nullptr);
 
   Fl_Sys_Menu_Bar *menubar;
   char buffer[1024];
@@ -421,7 +423,7 @@ static void init_fltk()
   // which means we cannot use our generic Fl_Menu_ helpers.
   if (fltk_menu_escape(p_("SysMenu|", "&File"),
                        buffer, sizeof(buffer)) < sizeof(buffer))
-      menubar->add(buffer, 0, 0, 0, FL_SUBMENU);
+      menubar->add(buffer, 0, nullptr, nullptr, FL_SUBMENU);
   if (fltk_menu_escape(p_("SysMenu|File|", "&New Connection"),
                        buffer, sizeof(buffer)) < sizeof(buffer))
       menubar->insert(1, buffer, FL_COMMAND | 'n', new_connection_cb);
@@ -432,7 +434,7 @@ static void usage(const char *programName)
 {
 #ifdef WIN32
   // If we don't have a console then we need to create one for output
-  if (GetConsoleWindow() == NULL) {
+  if (GetConsoleWindow() == nullptr) {
     HANDLE handle;
     int fd;
 
@@ -487,8 +489,8 @@ static void usage(const char *programName)
 static void
 potentiallyLoadConfigurationFile(char *vncServerName)
 {
-  const bool hasPathSeparator = (strchr(vncServerName, '/') != NULL ||
-                                 (strchr(vncServerName, '\\')) != NULL);
+  const bool hasPathSeparator = (strchr(vncServerName, '/') != nullptr ||
+                                 (strchr(vncServerName, '\\')) != nullptr);
 
   if (hasPathSeparator) {
 #ifndef WIN32
@@ -534,7 +536,7 @@ interpretViaParam(char *remoteHost, int *remotePort, int localPort)
 {
   const int SERVER_PORT_OFFSET = 5900;
   char *pos = strchr(vncServerName, ':');
-  if (pos == NULL)
+  if (pos == nullptr)
     *remotePort = SERVER_PORT_OFFSET;
   else {
     int portOffset = SERVER_PORT_OFFSET;
@@ -580,7 +582,7 @@ createTunnel(const char *gatewayHost, const char *remoteHost,
     cmd = "/usr/bin/ssh -f -L \"$L\":\"$H\":\"$R\" \"$G\" sleep 20";
   /* Compatibility with TigerVNC's method. */
   cmd2 = strdup(cmd);
-  while ((percent = strchr(cmd2, '%')) != NULL)
+  while ((percent = strchr(cmd2, '%')) != nullptr)
     *percent = '$';
   system(cmd2);
   free(cmd2);
@@ -612,7 +614,7 @@ int main(int argc, char** argv)
   setlocale(LC_ALL, "");
 
   localedir = getlocaledir();
-  if (localedir == NULL)
+  if (localedir == nullptr)
     fprintf(stderr, "Failed to determine locale directory\n");
   else
     bindtextdomain(PACKAGE_NAME, localedir);
@@ -647,8 +649,8 @@ int main(int argc, char** argv)
   char defaultServerName[VNCSERVERNAMELEN] = "";
   try {
     const char* configServerName;
-    configServerName = loadViewerParameters(NULL);
-    if (configServerName != NULL) {
+    configServerName = loadViewerParameters(nullptr);
+    if (configServerName != nullptr) {
       strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN-1);
       defaultServerName[VNCSERVERNAMELEN-1] = '\0';
     }
@@ -662,8 +664,8 @@ int main(int argc, char** argv)
         VoidParameter *param;
 
         param = Configuration::getParam(&argv[i][1]);
-        if ((param != NULL) &&
-            (dynamic_cast<BoolParameter*>(param) != NULL)) {
+        if ((param != nullptr) &&
+            (dynamic_cast<BoolParameter*>(param) != nullptr)) {
           if ((strcasecmp(argv[i+1], "0") == 0) ||
               (strcasecmp(argv[i+1], "1") == 0) ||
               (strcasecmp(argv[i+1], "true") == 0) ||
@@ -703,7 +705,7 @@ int main(int argc, char** argv)
     Fl::display(display);
   }
   fl_open_display();
-  XkbSetDetectableAutoRepeat(fl_display, True, NULL);
+  XkbSetDetectableAutoRepeat(fl_display, True, nullptr);
 #endif
 
   init_fltk();
@@ -717,11 +719,11 @@ int main(int argc, char** argv)
   char *confdir = strdup(os::getvncconfigdir());
 #ifndef WIN32
   char *dotdir = strrchr(confdir, '.');
-  if (dotdir != NULL && strcmp(dotdir, ".vnc") == 0)
+  if (dotdir != nullptr && strcmp(dotdir, ".vnc") == 0)
     vlog.info(_("~/.vnc is deprecated, please consult 'man vncviewer' for paths to migrate to."));
 #else
   char *vncdir = strrchr(confdir, '\\');
-  if (vncdir != NULL && strcmp(vncdir, "vnc") == 0)
+  if (vncdir != nullptr && strcmp(vncdir, "vnc") == 0)
     vlog.info(_("%%APPDATA%%\\vnc is deprecated, please switch to the %%APPDATA%%\\TigerVNC location."));
 #endif
 
@@ -745,7 +747,7 @@ int main(int argc, char** argv)
   CSecurity::msg = &dlg;
 #endif
 
-  Socket *sock = NULL;
+  Socket *sock = nullptr;
 
 #ifndef WIN32
   /* Specifying -via and -listen together is nonsense */
@@ -765,14 +767,14 @@ int main(int argc, char** argv)
       if (isdigit(vncServerName[0]))
         port = atoi(vncServerName);
 
-      createTcpListeners(&listeners, 0, port);
+      createTcpListeners(&listeners, nullptr, port);
       if (listeners.empty())
         throw Exception(_("Unable to listen for incoming connections"));
 
       vlog.info(_("Listening on port %d"), port);
 
       /* Wait for a connection */
-      while (sock == NULL) {
+      while (sock == nullptr) {
         fd_set rfds;
         FD_ZERO(&rfds);
         for (std::list<SocketListener*>::iterator i = listeners.begin();
@@ -780,7 +782,7 @@ int main(int argc, char** argv)
              i++)
           FD_SET((*i)->getFd(), &rfds);
 
-        int n = select(FD_SETSIZE, &rfds, 0, 0, 0);
+        int n = select(FD_SETSIZE, &rfds, nullptr, nullptr, nullptr);
         if (n < 0) {
           if (errno == EINTR) {
             vlog.debug("Interrupted select() system call");
index a48a1ea7a0a4a6c8dff96ca9c3e136f02d1399fb..a41ceefd75c0394006dc7fb7ce55f495563ddffe 100644 (file)
@@ -32,7 +32,7 @@ static LogWriter vlog("AboutDialog");
 AboutDialog AboutDialog::instance;
 
 
-AboutDialog::AboutDialog() : Dialog(GetModuleHandle(0)) {
+AboutDialog::AboutDialog() : Dialog(GetModuleHandle(nullptr)) {
 }
 
 bool AboutDialog::showDialog() {
index e69acd7f4750f51cb4a5ef64fd90d4d5e12ee69a..d2d6d2d1cce4dd183b341af984d9e105489c7149 100644 (file)
@@ -40,9 +40,9 @@ static LogWriter vlog("CleanDesktop");
 
 
 struct ActiveDesktop {
-  ActiveDesktop() : handle(0) {
+  ActiveDesktop() : handle(nullptr) {
     // - Contact Active Desktop
-    HRESULT result = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
+    HRESULT result = CoCreateInstance(CLSID_ActiveDesktop, nullptr, CLSCTX_INPROC_SERVER,
                                       IID_IActiveDesktop, (PVOID*)&handle);
     if (result != S_OK)
       throw rdr::SystemException("failed to contact Active Desktop", result);
@@ -153,7 +153,7 @@ DWORD SysParamsInfo(UINT action, UINT param, PVOID ptr, UINT ini) {
 CleanDesktop::CleanDesktop() : restoreActiveDesktop(false),
                                restoreWallpaper(false),
                                restoreEffects(false) {
-  CoInitialize(0);
+  CoInitialize(nullptr);
 }
 
 CleanDesktop::~CleanDesktop() {
@@ -207,7 +207,7 @@ void CleanDesktop::enableWallpaper() {
       vlog.debug("restore desktop wallpaper");
 
       // -=- Then restore the standard wallpaper if required
-           SysParamsInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
+           SysParamsInfo(SPI_SETDESKWALLPAPER, 0, nullptr, SPIF_SENDCHANGE);
       restoreWallpaper = false;
     }
 
@@ -223,20 +223,20 @@ void CleanDesktop::disableEffects() {
 
     vlog.debug("disable desktop effects");
 
-    SysParamsInfo(SPI_SETFONTSMOOTHING, FALSE, 0, SPIF_SENDCHANGE);
+    SysParamsInfo(SPI_SETFONTSMOOTHING, FALSE, nullptr, SPIF_SENDCHANGE);
     if (SysParamsInfo(SPI_GETUIEFFECTS, 0, &uiEffects, 0) == ERROR_CALL_NOT_IMPLEMENTED) {
       SysParamsInfo(SPI_GETCOMBOBOXANIMATION, 0, &comboBoxAnim, 0);
       SysParamsInfo(SPI_GETGRADIENTCAPTIONS, 0, &gradientCaptions, 0);
       SysParamsInfo(SPI_GETHOTTRACKING, 0, &hotTracking, 0);
       SysParamsInfo(SPI_GETLISTBOXSMOOTHSCROLLING, 0, &listBoxSmoothScroll, 0);
       SysParamsInfo(SPI_GETMENUANIMATION, 0, &menuAnim, 0);
-      SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, FALSE, SPIF_SENDCHANGE);
-      SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, FALSE, SPIF_SENDCHANGE);
-      SysParamsInfo(SPI_SETHOTTRACKING, 0, FALSE, SPIF_SENDCHANGE);
-      SysParamsInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, FALSE, SPIF_SENDCHANGE);
-      SysParamsInfo(SPI_SETMENUANIMATION, 0, FALSE, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETHOTTRACKING, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETLISTBOXSMOOTHSCROLLING, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETMENUANIMATION, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
     } else {
-      SysParamsInfo(SPI_SETUIEFFECTS, 0, FALSE, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETUIEFFECTS, 0, (PVOID)FALSE, SPIF_SENDCHANGE);
 
       // We *always* restore UI effects overall, since there is no Windows GUI to do it
       uiEffects = TRUE;
@@ -257,7 +257,7 @@ void CleanDesktop::enableEffects() {
 
       RegKey desktopCfg;
       desktopCfg.openKey(HKEY_CURRENT_USER, "Control Panel\\Desktop");
-      SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt("FontSmoothing", 0) != 0, 0, SPIF_SENDCHANGE);
+      SysParamsInfo(SPI_SETFONTSMOOTHING, desktopCfg.getInt("FontSmoothing", 0) != 0, nullptr, SPIF_SENDCHANGE);
       if (SysParamsInfo(SPI_SETUIEFFECTS, 0, (void*)(intptr_t)uiEffects, SPIF_SENDCHANGE) == ERROR_CALL_NOT_IMPLEMENTED) {
         SysParamsInfo(SPI_SETCOMBOBOXANIMATION, 0, (void*)(intptr_t)comboBoxAnim, SPIF_SENDCHANGE);
         SysParamsInfo(SPI_SETGRADIENTCAPTIONS, 0, (void*)(intptr_t)gradientCaptions, SPIF_SENDCHANGE);
index d90d0b7a3ca0010d53bf7fbd46a94514cfc13ede..79115893db6692dbf0347b606d91a288fcee5ca8 100644 (file)
@@ -39,7 +39,7 @@ static LogWriter vlog("Clipboard");
 //
 
 Clipboard::Clipboard()
-  : MsgWindow("Clipboard"), notifier(0), next_window(0) {
+  : MsgWindow("Clipboard"), notifier(nullptr), next_window(nullptr) {
   next_window = SetClipboardViewer(getHandle());
   vlog.debug("registered clipboard handler");
 }
@@ -58,7 +58,7 @@ Clipboard::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
                (long long)wParam, (long long)lParam);
     if ((HWND) wParam == next_window)
       next_window = (HWND) lParam;
-    else if (next_window != 0)
+    else if (next_window != nullptr)
       SendMessage(next_window, msg, wParam, lParam);
     else
       vlog.error("bad clipboard chain change!");
@@ -72,7 +72,7 @@ Clipboard::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
       } else {
         vlog.debug("local clipboard changed by %p", owner);
 
-        if (notifier == NULL)
+        if (notifier == nullptr)
           vlog.debug("no clipboard notifier registered");
         else
           notifier->notifyClipboardChanged(IsClipboardFormatAvailable(CF_UNICODETEXT));
@@ -94,19 +94,19 @@ Clipboard::getClipText() {
 
   // Open the clipboard
   if (!OpenClipboard(getHandle()))
-    return NULL;
+    return nullptr;
 
   // Get the clipboard data
   cliphandle = GetClipboardData(CF_UNICODETEXT);
   if (!cliphandle) {
     CloseClipboard();
-    return NULL;
+    return nullptr;
   }
 
   clipdata = (wchar_t*) GlobalLock(cliphandle);
   if (!clipdata) {
     CloseClipboard();
-    return NULL;
+    return nullptr;
   }
 
   // Convert it to UTF-8
@@ -121,7 +121,7 @@ Clipboard::getClipText() {
 
 void
 Clipboard::setClipText(const char* text) {
-  HANDLE clip_handle = 0;
+  HANDLE clip_handle = nullptr;
 
   try {
 
@@ -147,7 +147,7 @@ Clipboard::setClipText(const char* text) {
     // - Set the new clipboard data
     if (!SetClipboardData(CF_UNICODETEXT, clip_handle))
       throw rdr::SystemException("unable to set Win32 clipboard", GetLastError());
-    clip_handle = 0;
+    clip_handle = nullptr;
 
     vlog.debug("set clipboard");
   } catch (rdr::Exception& e) {
index 632c0a4c246eef2716337e98a237fe103dc566d1..aa03315cc7f26df2267c0e8fe2486e37187e5c3f 100644 (file)
@@ -33,11 +33,11 @@ static LogWriter vlog("DIBSectionBuffer");
 
 
 DIBSectionBuffer::DIBSectionBuffer(HWND window_)
-  : bitmap(0), window(window_), device(0) {
+  : bitmap(nullptr), window(window_), device(nullptr) {
 }
 
 DIBSectionBuffer::DIBSectionBuffer(HDC device_)
-  : bitmap(0), window(0), device(device_) {
+  : bitmap(nullptr), window(nullptr), device(device_) {
 }
 
 DIBSectionBuffer::~DIBSectionBuffer() {
@@ -52,8 +52,8 @@ inline void initMaxAndShift(DWORD mask, int* max, int* shift) {
 }
 
 void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
-  HBITMAP new_bitmap = 0;
-  uint8_t* new_data = 0;
+  HBITMAP new_bitmap = nullptr;
+  uint8_t* new_data = nullptr;
 
   if (!pf.trueColour)
     throw rfb::Exception("palette format not supported");
@@ -78,10 +78,10 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
     // Create a DIBSection to draw into
     if (device)
       new_bitmap = ::CreateDIBSection(device, (BITMAPINFO*)&bi.bmiHeader, iUsage,
-                                      (void**)&new_data, NULL, 0);
+                                      (void**)&new_data, nullptr, 0);
     else
       new_bitmap = ::CreateDIBSection(WindowDC(window), (BITMAPINFO*)&bi.bmiHeader, iUsage,
-                                      (void**)&new_data, NULL, 0);
+                                      (void**)&new_data, nullptr, 0);
 
     if (!new_bitmap) {
       int err = GetLastError();
@@ -112,8 +112,8 @@ void DIBSectionBuffer::initBuffer(const PixelFormat& pf, int w, int h) {
   if (bitmap) {
     // Delete the old bitmap
     DeleteObject(bitmap);
-    bitmap = 0;
-    setBuffer(0, 0, NULL, 0);
+    bitmap = nullptr;
+    setBuffer(0, 0, nullptr, 0);
   }
 
   if (new_bitmap) {
index e59672f5eee21ae0f0f176a5815a2b776c7fa4cd..1efc3a599be5ee189d04088664f535a264e0bae0 100644 (file)
@@ -50,10 +50,10 @@ PixelFormat DeviceContext::getPF(HDC dc) {
   memset(&bi, 0, sizeof(bi));
   bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
   bi.bmiHeader.biBitCount = 0;
-  if (!::GetDIBits(dc, bitmap, 0, 1, NULL, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
+  if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
     throw rdr::SystemException("unable to determine device pixel format", GetLastError());
   }
-  if (!::GetDIBits(dc, bitmap, 0, 1, NULL, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
+  if (!::GetDIBits(dc, bitmap, 0, 1, nullptr, (BITMAPINFO*)&bi, DIB_RGB_COLORS)) {
     throw rdr::SystemException("unable to determine pixel shifts/palette", GetLastError());
   }
 
@@ -157,7 +157,7 @@ Rect DeviceContext::getClipBox(HDC dc) {
 
 
 DeviceDC::DeviceDC(const char* deviceName) {
-  dc = ::CreateDC("DISPLAY", deviceName, NULL, NULL);
+  dc = ::CreateDC("DISPLAY", deviceName, nullptr, nullptr);
   if (!dc)
     throw rdr::SystemException("failed to create DeviceDC", GetLastError());
 }
index 0664684bf69a94ca0a058f0d60a27bbc186959f9..7e89723c7e5bf5c985e3465c1f4d55db88934db6 100644 (file)
@@ -35,7 +35,7 @@ namespace rfb {
     // and the pixel format, and access to the HDC itself.
     class DeviceContext {
     public:
-      DeviceContext() : dc(0) {}
+      DeviceContext() : dc(nullptr) {}
       virtual ~DeviceContext() {}
       operator HDC() const {return dc;}
       PixelFormat getPF() const;
index 5d866de810c004e5f5aeacbb4197c2341ee57e4b..090846f241d5acb495bb448ce62f81586ea380d4 100644 (file)
@@ -122,8 +122,8 @@ void DeviceFrameBuffer::setCursor(HCURSOR hCursor, VNCServer* server)
 {
   // - If hCursor is null then there is no cursor - clear the old one
 
-  if (hCursor == 0) {
-    server->setCursor(0, 0, Point(), NULL);
+  if (hCursor == nullptr) {
+    server->setCursor(0, 0, Point(), nullptr);
     return;
   }
 
index 8e2c1ee861c2529d9fa1fe287ed2e300174a0907..7c1574e9a38b190e6458002c3bb599f5e46fb22b 100644 (file)
@@ -48,7 +48,7 @@ static LogWriter plog("PropSheet");
 
 
 Dialog::Dialog(HINSTANCE inst_)
-: inst(inst_), handle(0), alreadyShowing(false)
+: inst(inst_), handle(nullptr), alreadyShowing(false)
 {
 }
 
@@ -60,7 +60,7 @@ Dialog::~Dialog()
 bool Dialog::showDialog(const char* resource, HWND owner)
 {
   if (alreadyShowing) return false;
-  handle = 0;
+  handle = nullptr;
   alreadyShowing = true;
   INT_PTR result = DialogBoxParam(inst, resource, owner,
                                   staticDialogProc, (LPARAM)this);
@@ -151,14 +151,14 @@ BOOL Dialog::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 }
 
 
-PropSheetPage::PropSheetPage(HINSTANCE inst, const char* id) : Dialog(inst), propSheet(0) {
+PropSheetPage::PropSheetPage(HINSTANCE inst, const char* id) : Dialog(inst), propSheet(nullptr) {
   page.dwSize = sizeof(page);
   page.dwFlags = 0; // PSP_USECALLBACK;
   page.hInstance = inst;
   page.pszTemplate = id;
   page.pfnDlgProc = staticPageProc;
   page.lParam = (LPARAM)this;
-  page.pfnCallback = 0; // staticPageProc;
+  page.pfnCallback = nullptr; // staticPageProc;
 }
 
 PropSheetPage::~PropSheetPage() {
@@ -207,7 +207,7 @@ BOOL PropSheetPage::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
 
 
 PropSheet::PropSheet(HINSTANCE inst_, const char* title_, std::list<PropSheetPage*> pages_, HICON icon_)
-: icon(icon_), pages(pages_), inst(inst_), title(title_), handle(0), alreadyShowing(0) {
+: icon(icon_), pages(pages_), inst(inst_), title(title_), handle(nullptr), alreadyShowing(0) {
 }
 
 PropSheet::~PropSheet() {
@@ -274,7 +274,7 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
     }
 
     handle = (HWND)PropertySheet(&header);
-    if ((handle == 0) || (handle == (HWND)-1))
+    if ((handle == nullptr) || (handle == (HWND)-1))
       throw rdr::SystemException("PropertySheet failed", GetLastError());
     centerWindow(handle, owner);
     plog.info("created %p", handle);
@@ -318,7 +318,7 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
           EnableWindow(owner, FALSE);
         // Run the PropertySheet
         MSG msg;
-        while (GetMessage(&msg, 0, 0, 0)) {
+        while (GetMessage(&msg, nullptr, 0, 0)) {
           if (!PropSheet_IsDialogMessage(handle, &msg))
             DispatchMessage(&msg);
           if (!PropSheet_GetCurrentPageHwnd(handle))
@@ -338,13 +338,13 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
     plog.info("finished %p", handle);
 
     DestroyWindow(handle);
-    handle = 0;
+    handle = nullptr;
     alreadyShowing = false;
 
     // Clear up the pages' GDI objects
     for (pspi=pages.begin(); pspi!=pages.end(); pspi++)
-      (*pspi)->setPropSheet(0);
-    delete [] hpages; hpages = 0;
+      (*pspi)->setPropSheet(nullptr);
+    delete [] hpages; hpages = nullptr;
 
     return true;
   } catch (rdr::Exception&) {
@@ -352,8 +352,8 @@ bool PropSheet::showPropSheet(HWND owner, bool showApply, bool showCtxtHelp, boo
 
     std::list<PropSheetPage*>::iterator pspi;
     for (pspi=pages.begin(); pspi!=pages.end(); pspi++)
-      (*pspi)->setPropSheet(0);
-    delete [] hpages; hpages = 0;
+      (*pspi)->setPropSheet(nullptr);
+    delete [] hpages; hpages = nullptr;
 
     throw;
   }
index d1a8e8312cd25d59d1e2fd9149b59a75deff9bc6..4661dd31dc04ff0c745f768932d73c339497026f 100644 (file)
@@ -52,7 +52,7 @@ namespace rfb {
       // expansion), and owner is an optional window handle - the corresponding
       // window is disabled while the dialog box is displayed.
 
-      bool showDialog(const char* resource, HWND owner=0);
+      bool showDialog(const char* resource, HWND owner=nullptr);
 
       // initDialog() is called upon receipt of the WM_INITDIALOG message.
 
@@ -106,7 +106,7 @@ namespace rfb {
 
     class PropSheet {
     public:
-      PropSheet(HINSTANCE inst, const char* title, std::list<PropSheetPage*> pages, HICON icon=0);
+      PropSheet(HINSTANCE inst, const char* title, std::list<PropSheetPage*> pages, HICON icon=nullptr);
       virtual ~PropSheet();
 
       // Display the PropertySheet
index d3baa5804e6a1712b7c319632cefcbd9bcf3a27d..6b88a8f101badf46811117d99adf8d8dbe581a1a 100644 (file)
@@ -29,7 +29,7 @@ namespace rfb {
 
     class Handle {
     public:
-      Handle(HANDLE h_=0) : h(h_) {}
+      Handle(HANDLE h_=nullptr) : h(h_) {}
       ~Handle() {
         if (h) CloseHandle(h);
       }
index deb2abc63b575060b601711081d72ee780d3cdcb..89cd931228ca3fde6c77cca144bebfaeaf59a685 100644 (file)
@@ -31,7 +31,7 @@ namespace rfb {
       IntervalTimer(HWND hwnd_, int id_)
         : hwnd(hwnd_), id(id_), active(false) {
       }
-      IntervalTimer() : hwnd(0), id(0), active(false) {
+      IntervalTimer() : hwnd(nullptr), id(0), active(false) {
       }
       ~IntervalTimer() {
         stop();
@@ -40,7 +40,7 @@ namespace rfb {
       void start(int interval_) {
         if (!active || interval_ != interval) {
           interval = interval_;
-          if (!SetTimer(hwnd, id, interval, 0))
+          if (!SetTimer(hwnd, id, interval, nullptr))
             throw rdr::SystemException("SetTimer", GetLastError());
           active = true;
         }
index 5e702a0098c4b02630daeb3bf09c414171bd3f02..92a6827373e48f7cdc1f04b07d6b008948f057bf 100644 (file)
@@ -85,11 +85,15 @@ void LaunchProcess::start(HANDLE userToken, bool createConsole) {
   BOOL success;
   if (userToken != INVALID_HANDLE_VALUE)
     success = CreateProcessAsUser(userToken, exePath.c_str(),
-                                  (char*)cmdLine.c_str(), 0, 0, FALSE,
-                                  flags, 0, 0, &sinfo, &procInfo);
+                                  (char*)cmdLine.c_str(),
+                                  nullptr, nullptr, FALSE,
+                                  flags, nullptr, nullptr,
+                                  &sinfo, &procInfo);
   else
-    success = CreateProcess(exePath.c_str(), (char*)cmdLine.c_str(), 0,
-                            0, FALSE, flags, 0, 0, &sinfo, &procInfo);
+    success = CreateProcess(exePath.c_str(), (char*)cmdLine.c_str(),
+                            nullptr, nullptr, FALSE,
+                            flags, nullptr, nullptr,
+                            &sinfo, &procInfo);
   if (!success)
     throw rdr::SystemException("unable to launch process", GetLastError());
 
index a99d32410ad396eedd83d0d217a9338885378e01..239e8c1f529c0213d60f0a8d684551699255c838 100644 (file)
@@ -34,7 +34,7 @@ namespace rfb {
       ~LocalMem() {LocalFree(ptr);}
       operator void*() {return ptr;}
       void* takePtr() {
-        void* t = ptr; ptr = 0; return t;
+        void* t = ptr; ptr = nullptr; return t;
       }
       void* ptr;
     };
index 9a06f50dae84188a25a074b79cebec1f08e51ed2..c95ad1f1a461fa84cf6036bd68575c33b9f3c44d 100644 (file)
@@ -25,9 +25,9 @@ namespace rfb {
   namespace win32 {
 
     struct ModuleFileName {
-      ModuleFileName(HMODULE module=0) {
+      ModuleFileName(HMODULE module=nullptr) {
         if (!module)
-          module = GetModuleHandle(0);
+          module = GetModuleHandle(nullptr);
         if (!GetModuleFileName(module, buf, MAX_PATH))
           buf[0] = 0;
       }
index c7217c19c2e1e7299e9ca45a1a8b79651e030f5b..fb4fb3a9b6de652a461035157e35b2f4ca1ed2b8 100644 (file)
@@ -96,7 +96,7 @@ MonitorInfo::MonitorInfo(const char* devName) {
   monitorByNameData data;
   data.info = this;
   data.monitorName = devName;
-  EnumDisplayMonitors(0, 0, &monitorByNameEnumProc, (LPARAM)&data);
+  EnumDisplayMonitors(nullptr, nullptr, &monitorByNameEnumProc, (LPARAM)&data);
 }
 
 void MonitorInfo::moveTo(HWND handle) {
@@ -134,7 +134,7 @@ void MonitorInfo::clipTo(HWND handle) {
   RECT r;
   GetWindowRect(handle, &r);
   clipTo(&r);
-  SetWindowPos(handle, 0, r.left, r.top, r.right-r.left, r.bottom-r.top,
+  SetWindowPos(handle, nullptr, r.left, r.top, r.right-r.left, r.bottom-r.top,
                SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
 }
 
index 25d36383af677d22a0b2e341894f2bff28acdad7..e831d745fc8cf234b0af93971847c504aaec8905 100644 (file)
@@ -36,7 +36,7 @@ namespace rfb {
 
     // Wrapper around Win32 MessageBox()
     static int MsgBox(HWND parent, const char* msg, UINT flags) {
-      const char* msgType = 0;
+      const char* msgType = nullptr;
       UINT tflags = flags & 0x70;
       if (tflags == MB_ICONHAND)
         msgType = "Error";
index 251b2762fdf435a1c48580fe897a2af59094cb0a..30c9373e95c9a87feff3344f0032891fb280f8af 100644 (file)
@@ -74,11 +74,11 @@ MsgWindowClass::MsgWindowClass() : classAtom(0) {
   wndClass.lpfnWndProc = MsgWindowProc;
   wndClass.cbClsExtra = 0;
   wndClass.cbWndExtra = 0;
-  wndClass.hInstance = instance = GetModuleHandle(0);
-  wndClass.hIcon = 0;
-  wndClass.hCursor = 0;
-  wndClass.hbrBackground = 0;
-  wndClass.lpszMenuName = 0;
+  wndClass.hInstance = instance = GetModuleHandle(nullptr);
+  wndClass.hIcon = nullptr;
+  wndClass.hCursor = nullptr;
+  wndClass.hbrBackground = nullptr;
+  wndClass.lpszMenuName = nullptr;
   wndClass.lpszClassName = "rfb::win32::MsgWindowClass";
   classAtom = RegisterClass(&wndClass);
   if (!classAtom) {
@@ -98,11 +98,11 @@ static MsgWindowClass baseClass;
 // -=- MsgWindow
 //
 
-MsgWindow::MsgWindow(const char* name_) : name(name_), handle(0) {
+MsgWindow::MsgWindow(const char* name_) : name(name_), handle(nullptr) {
   vlog.debug("creating window \"%s\"", name.c_str());
   handle = CreateWindow((const char*)(intptr_t)baseClass.classAtom,
-                        name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10, 0, 0,
-                        baseClass.instance, this);
+                        name.c_str(), WS_OVERLAPPED, 0, 0, 10, 10,
+                        nullptr, nullptr, baseClass.instance, this);
   if (!handle) {
     throw rdr::SystemException("unable to create WMNotifier window instance", GetLastError());
   }
index 38ca52f965d2bb9e94fb00e925ec33cbbad2ae4f..770330ce0da7698404db39d152722ef902867fb6 100644 (file)
@@ -35,7 +35,10 @@ using namespace rfb::win32;
 static LogWriter vlog("RegConfig");
 
 
-RegConfig::RegConfig(EventManager* em) : eventMgr(em), event(CreateEvent(0, TRUE, FALSE, 0)), callback(0) {
+RegConfig::RegConfig(EventManager* em)
+  : eventMgr(em), event(CreateEvent(nullptr, TRUE, FALSE, nullptr)),
+    callback(nullptr)
+{
   if (em->addEvent(event, this))
     eventMgr = em;
 }
@@ -110,7 +113,7 @@ void RegConfigThread::worker() {
   BOOL result = 0;
   MSG msg;
   thread_id = GetCurrentThreadId();
-  while ((result = eventMgr.getMessage(&msg, 0, 0, 0)) > 0) {}
+  while ((result = eventMgr.getMessage(&msg, nullptr, 0, 0)) > 0) {}
   if (result < 0)
     throw rdr::SystemException("RegConfigThread failed", GetLastError());
 }
index d0db60e296bd250d46f2c2ca32471523a3635461..3b12dab9e96ce55e5d6eefcde3fc39f3f5389a27 100644 (file)
@@ -49,18 +49,18 @@ using namespace rfb::win32;
 static LogWriter vlog("Registry");
 
 
-RegKey::RegKey() : key(0), freeKey(false), valueName(NULL), valueNameBufLen(0) {}
+RegKey::RegKey() : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {}
 
-RegKey::RegKey(const HKEY k) : key(0), freeKey(false), valueName(NULL), valueNameBufLen(0) {
-  LONG result = RegOpenKeyEx(k, 0, 0, KEY_ALL_ACCESS, &key);
+RegKey::RegKey(const HKEY k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
+  LONG result = RegOpenKeyEx(k, nullptr, 0, KEY_ALL_ACCESS, &key);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegOpenKeyEx(HKEY)", result);
   vlog.debug("duplicated %p to %p", k, key);
   freeKey = true;
 }
 
-RegKey::RegKey(const RegKey& k) : key(0), freeKey(false), valueName(NULL), valueNameBufLen(0) {
-  LONG result = RegOpenKeyEx(k.key, 0, 0, KEY_ALL_ACCESS, &key);
+RegKey::RegKey(const RegKey& k) : key(nullptr), freeKey(false), valueName(nullptr), valueNameBufLen(0) {
+  LONG result = RegOpenKeyEx(k.key, nullptr, 0, KEY_ALL_ACCESS, &key);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegOpenKeyEx(RegKey&)", result);
   vlog.debug("duplicated %p to %p", k.key, key);
@@ -108,7 +108,7 @@ void RegKey::setDACL(const PACL acl, bool inherit) {
   if ((result = SetSecurityInfo(key, SE_REGISTRY_KEY,
     DACL_SECURITY_INFORMATION |
     (inherit ? UNPROTECTED_DACL_SECURITY_INFORMATION : PROTECTED_DACL_SECURITY_INFORMATION),
-    0, 0, acl, 0)) != ERROR_SUCCESS)
+    nullptr, nullptr, acl, nullptr)) != ERROR_SUCCESS)
     throw rdr::SystemException("RegKey::setDACL failed", result);
 }
 
@@ -116,7 +116,7 @@ void RegKey::close() {
   if (freeKey) {
     vlog.debug("RegCloseKey(%p)", key);
     RegCloseKey(key);
-    key = 0;
+    key = nullptr;
   }
 }
 
@@ -133,7 +133,7 @@ void RegKey::deleteValue(const char* name) const {
 }
 
 void RegKey::awaitChange(bool watchSubTree, DWORD filter, HANDLE event) const {
-  LONG result = RegNotifyChangeKeyValue(key, watchSubTree, filter, event, event != 0);
+  LONG result = RegNotifyChangeKeyValue(key, watchSubTree, filter, event, event != nullptr);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegNotifyChangeKeyValue", result);
 }
@@ -212,11 +212,11 @@ bool RegKey::getBool(const char* valname, bool def) const {
 
 std::string RegKey::getRepresentation(const char* valname) const {
   DWORD type, length;
-  LONG result = RegQueryValueEx(key, valname, 0, &type, 0, &length);
+  LONG result = RegQueryValueEx(key, valname, nullptr, &type, nullptr, &length);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("get registry value length", result);
   std::vector<uint8_t> data(length);
-  result = RegQueryValueEx(key, valname, 0, &type, (BYTE*)data.data(), &length);
+  result = RegQueryValueEx(key, valname, nullptr, &type, (BYTE*)data.data(), &length);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("get registry value", result);
 
@@ -241,7 +241,7 @@ std::string RegKey::getRepresentation(const char* valname) const {
     {
     if (length) {
       std::string str((char*)data.data(), length);
-      DWORD required = ExpandEnvironmentStrings(str.c_str(), 0, 0);
+      DWORD required = ExpandEnvironmentStrings(str.c_str(), nullptr, 0);
       if (required==0)
         throw rdr::SystemException("ExpandEnvironmentStrings", GetLastError());
       std::vector<char> result(required);
@@ -269,7 +269,7 @@ bool RegKey::isValue(const char* valname) const {
 
 const char* RegKey::getValueName(int i) {
   DWORD maxValueNameLen;
-  LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0);
+  LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegQueryInfoKey", result);
   if (valueNameBufLen < maxValueNameLen + 1) {
@@ -278,8 +278,8 @@ const char* RegKey::getValueName(int i) {
     valueName = new char[valueNameBufLen];
   }
   DWORD length = valueNameBufLen;
-  result = RegEnumValue(key, i, valueName, &length, NULL, 0, 0, 0);
-  if (result == ERROR_NO_MORE_ITEMS) return 0;
+  result = RegEnumValue(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
+  if (result == ERROR_NO_MORE_ITEMS) return nullptr;
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegEnumValue", result);
   return valueName;
@@ -287,7 +287,7 @@ const char* RegKey::getValueName(int i) {
 
 const char* RegKey::getKeyName(int i) {
   DWORD maxValueNameLen;
-  LONG result = RegQueryInfoKey(key, 0, 0, 0, 0, &maxValueNameLen, 0, 0, 0, 0, 0, 0);
+  LONG result = RegQueryInfoKey(key, nullptr, nullptr, nullptr, nullptr, &maxValueNameLen, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegQueryInfoKey", result);
   if (valueNameBufLen < maxValueNameLen + 1) {
@@ -296,8 +296,8 @@ const char* RegKey::getKeyName(int i) {
     valueName = new char[valueNameBufLen];
   }
   DWORD length = valueNameBufLen;
-  result = RegEnumKeyEx(key, i, valueName, &length, NULL, 0, 0, 0);
-  if (result == ERROR_NO_MORE_ITEMS) return 0;
+  result = RegEnumKeyEx(key, i, valueName, &length, nullptr, nullptr, nullptr, nullptr);
+  if (result == ERROR_NO_MORE_ITEMS) return nullptr;
   if (result != ERROR_SUCCESS)
     throw rdr::SystemException("RegEnumKey", result);
   return valueName;
index b99c95bcd57860877fd5c20bd01f4b3de0b5fd1f..10c9e099bcc437c02432a87c0946d22d150acf0b 100644 (file)
@@ -68,7 +68,7 @@ namespace rfb {
 
       // Block waiting for a registry change, OR return immediately and notify the
       // event when there is a change, if specified
-      void awaitChange(bool watchSubTree, DWORD filter, HANDLE event=0) const;
+      void awaitChange(bool watchSubTree, DWORD filter, HANDLE event=nullptr) const;
 
       void setExpandString(const char* valname, const char* s) const;
       void setString(const char* valname, const char* s) const;
index dd1ac7da21ad721d4032f63500954e11975abfbe..b1abf849f2267086231e4debde614d9ffd8c080a 100644 (file)
@@ -70,13 +70,13 @@ BoolParameter rfb::win32::SDisplay::disableEffects("DisableEffects",
 // -=- Constructor/Destructor
 
 SDisplay::SDisplay()
-  : server(0), pb(0), device(0),
-    core(0), ptr(0), kbd(0), clipboard(0),
-    inputs(0), monitor(0), cleanDesktop(0), cursor(0),
-    statusLocation(0), queryConnectionHandler(0), ledState(0)
+  : server(nullptr), pb(nullptr), device(nullptr),
+    core(nullptr), ptr(nullptr), kbd(nullptr), clipboard(nullptr),
+    inputs(nullptr), monitor(nullptr), cleanDesktop(nullptr), cursor(nullptr),
+    statusLocation(nullptr), queryConnectionHandler(nullptr), ledState(0)
 {
-  updateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
-  terminateEvent.h = CreateEvent(0, TRUE, FALSE, 0);
+  updateEvent.h = CreateEvent(nullptr, TRUE, FALSE, nullptr);
+  terminateEvent.h = CreateEvent(nullptr, TRUE, FALSE, nullptr);
 }
 
 SDisplay::~SDisplay()
@@ -89,7 +89,7 @@ SDisplay::~SDisplay()
   // the VNCServer ought not to exist and therefore we shouldn't invoke any
   // methods on it.  Setting server to zero here ensures that stop() doesn't
   // call setPixelBuffer(0) on the server.
-  server = 0;
+  server = nullptr;
   if (core) stop();
 }
 
@@ -139,7 +139,7 @@ void SDisplay::stop()
   }
 
   // Stop the SDisplayCore
-  server->setPixelBuffer(0);
+  server->setPixelBuffer(nullptr);
   stopCore();
 
   vlog.debug("stopped");
@@ -156,7 +156,7 @@ void SDisplay::terminate()
 void SDisplay::queryConnection(network::Socket* sock,
                                const char* userName)
 {
-  assert(server != NULL);
+  assert(server != nullptr);
 
   if (queryConnectionHandler) {
     queryConnectionHandler->queryConnection(sock, userName);
@@ -198,7 +198,7 @@ void SDisplay::startCore() {
         core = new SDisplayCorePolling(this, &updates);
       core->setScreenRect(screenRect);
     } catch (rdr::Exception& e) {
-      delete core; core = 0;
+      delete core; core = nullptr;
       if (tryMethod == 0)
         throw rdr::Exception("unable to access desktop");
       tryMethod--;
@@ -234,16 +234,16 @@ void SDisplay::startCore() {
 void SDisplay::stopCore() {
   if (core)
     vlog.info("Stopping %s", core->methodName());
-  delete core; core = 0;
-  delete pb; pb = 0;
-  delete device; device = 0;
-  delete monitor; monitor = 0;
-  delete clipboard; clipboard = 0;
-  delete inputs; inputs = 0;
-  delete ptr; ptr = 0;
-  delete kbd; kbd = 0;
-  delete cleanDesktop; cleanDesktop = 0;
-  delete cursor; cursor = 0;
+  delete core; core = nullptr;
+  delete pb; pb = nullptr;
+  delete device; device = nullptr;
+  delete monitor; monitor = nullptr;
+  delete clipboard; clipboard = nullptr;
+  delete inputs; inputs = nullptr;
+  delete ptr; ptr = nullptr;
+  delete kbd; kbd = nullptr;
+  delete cleanDesktop; cleanDesktop = nullptr;
+  delete cursor; cursor = nullptr;
   ResetEvent(updateEvent);
 }
 
@@ -416,7 +416,7 @@ SDisplay::processEvent(HANDLE event) {
 
         // Update the cursor shape
         if (set_cursor)
-          pb->setCursor(info.visible ? info.cursor : 0, server);
+          pb->setCursor(info.visible ? info.cursor : nullptr, server);
 
         // Update the cursor position
         // NB: First translate from Screen coordinates to Desktop
@@ -447,14 +447,14 @@ SDisplay::recreatePixelBuffer(bool force) {
   //   If no device is specified, open entire screen using GetDC().
   //   Opening the whole display with CreateDC doesn't work on multi-monitor
   //   systems for some reason.
-  DeviceContext* new_device = 0;
+  DeviceContext* new_device = nullptr;
   if (strlen(displayDevice) > 0) {
     vlog.info("Attaching to device %s", (const char*)displayDevice);
     new_device = new DeviceDC(displayDevice);
   }
   if (!new_device) {
     vlog.info("Attaching to virtual desktop");
-    new_device = new WindowDC(0);
+    new_device = new WindowDC(nullptr);
   }
 
   // Get the coordinates of the specified dispay device
index 8dfc5b8d26833faf33345a2385fa28b3d686602f..e706ddb4e999c868f9c4ccad8e43477153fd908b 100644 (file)
@@ -38,7 +38,7 @@ static LogWriter vlog("SecurityWin32");
 Trustee::Trustee(const char* name,
                  TRUSTEE_FORM form,
                  TRUSTEE_TYPE type) {
-  pMultipleTrustee = 0;
+  pMultipleTrustee = nullptr;
   MultipleTrusteeOperation = NO_MULTIPLE_TRUSTEE;
   TrusteeForm = form;
   TrusteeType = type;
@@ -58,7 +58,7 @@ ExplicitAccess::ExplicitAccess(const char* name,
 }
 
 
-AccessEntries::AccessEntries() : entries(0), entry_count(0) {}
+AccessEntries::AccessEntries() : entries(nullptr), entry_count(0) {}
 
 AccessEntries::~AccessEntries() {
   delete [] entries;
@@ -115,19 +115,19 @@ void Sid::getUserNameAndDomain(char** name, char** domain) {
   DWORD nameLen = 0;
   DWORD domainLen = 0;
   SID_NAME_USE use;
-  LookupAccountSid(0, (PSID)*this, 0, &nameLen, 0, &domainLen, &use);
+  LookupAccountSid(nullptr, (PSID)*this, nullptr, &nameLen, nullptr, &domainLen, &use);
   if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
     throw rdr::SystemException("Unable to determine SID name lengths", GetLastError());
   vlog.info("nameLen=%lu, domainLen=%lu, use=%d", nameLen, domainLen, use);
   *name = new char[nameLen];
   *domain = new char[domainLen];
-  if (!LookupAccountSid(0, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use))
+  if (!LookupAccountSid(nullptr, (PSID)*this, *name, &nameLen, *domain, &domainLen, &use))
     throw rdr::SystemException("Unable to lookup account SID", GetLastError());
 }
 
 
 Sid::Administrators::Administrators() {
-  PSID sid = 0;
+  PSID sid = nullptr;
   SID_IDENTIFIER_AUTHORITY ntAuth = { SECURITY_NT_AUTHORITY };
   if (!AllocateAndInitializeSid(&ntAuth, 2,
                                 SECURITY_BUILTIN_DOMAIN_RID,
@@ -139,7 +139,7 @@ Sid::Administrators::Administrators() {
 }
 
 Sid::SYSTEM::SYSTEM() {
-  PSID sid = 0;
+  PSID sid = nullptr;
   SID_IDENTIFIER_AUTHORITY ntAuth = { SECURITY_NT_AUTHORITY };
   if (!AllocateAndInitializeSid(&ntAuth, 1,
                                 SECURITY_LOCAL_SYSTEM_RID,
@@ -151,7 +151,7 @@ Sid::SYSTEM::SYSTEM() {
 
 Sid::FromToken::FromToken(HANDLE h) {
   DWORD required = 0;
-  GetTokenInformation(h, TokenUser, 0, 0, &required);
+  GetTokenInformation(h, TokenUser, nullptr, 0, &required);
   std::vector<uint8_t> tmp(required);
   if (!GetTokenInformation(h, TokenUser, tmp.data(), tmp.size(), &required))
     throw rdr::SystemException("GetTokenInformation", GetLastError());
index a24c359f63628aa96bb1fe3bccca0ed609137b14..a4471f977b570a070aacc6e72f032a9d904dc186 100644 (file)
@@ -96,17 +96,17 @@ namespace rfb {
     // Helper class for handling & freeing ACLs
     struct AccessControlList : public LocalMem {
       AccessControlList(int size) : LocalMem(size) {}
-      AccessControlList(PACL acl_=0) : LocalMem(acl_) {}
+      AccessControlList(PACL acl_=nullptr) : LocalMem(acl_) {}
       operator PACL() {return (PACL)ptr;}
     };
 
     // Create a new ACL based on supplied entries and, if supplied, existing ACL 
-    PACL CreateACL(const AccessEntries& ae, PACL existing_acl=0);
+    PACL CreateACL(const AccessEntries& ae, PACL existing_acl=nullptr);
 
     // Helper class for memory-management of self-relative SecurityDescriptors
     struct SecurityDescriptorPtr : LocalMem {
       SecurityDescriptorPtr(int size) : LocalMem(size) {}
-      SecurityDescriptorPtr(PSECURITY_DESCRIPTOR sd_=0) : LocalMem(sd_) {}
+      SecurityDescriptorPtr(PSECURITY_DESCRIPTOR sd_=nullptr) : LocalMem(sd_) {}
       PSECURITY_DESCRIPTOR takeSD() {return (PSECURITY_DESCRIPTOR)takePtr();}
     };
 
index 600a8a34bf12dbb3f8e9ffa3a657b917c3576567..2571a4d62356d3f41d3bb0404b11ccff5b91dd40 100644 (file)
@@ -40,7 +40,7 @@ static LogWriter vlog("AuthDialog");
 
 /* XXX: This class contains bunch of similar code to unix/vncviewer/CConn.cxx */
 SecurityPage::SecurityPage(Security *security_)
-  : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SECURITY)),
+  : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_SECURITY)),
     security(security_) {
 }
 
index 62230b0739075c22fe3a24c1a6a7857c3f2db7cb..a27cfa67134ac16ebaae6ab0bf11a81eac01e70d 100644 (file)
@@ -42,7 +42,7 @@ static LogWriter vlog("Service");
 
 // - Internal service implementation functions
 
-Service* service = 0;
+Service* service = nullptr;
 bool runAsService = false;
 
 VOID WINAPI serviceHandler(DWORD control) {
@@ -93,7 +93,7 @@ VOID WINAPI serviceProc(DWORD dwArgc, LPTSTR* lpszArgv) {
 
 Service::Service(const char* name_) : name(name_) {
   vlog.debug("Service");
-  status_handle = 0;
+  status_handle = nullptr;
   status.dwControlsAccepted = SERVICE_CONTROL_INTERROGATE | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_STOP;
   status.dwServiceType = SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS;
   status.dwWin32ExitCode = NO_ERROR;
@@ -108,8 +108,8 @@ Service::start() {
   SERVICE_TABLE_ENTRY entry[2];
   entry[0].lpServiceName = (char*)name;
   entry[0].lpServiceProc = serviceProc;
-  entry[1].lpServiceName = NULL;
-  entry[1].lpServiceProc = NULL;
+  entry[1].lpServiceName = nullptr;
+  entry[1].lpServiceProc = nullptr;
   vlog.debug("entering dispatcher");
   if (!SetProcessShutdownParameters(0x100, 0))
     vlog.error("unable to set shutdown parameters: %lu", GetLastError());
@@ -125,7 +125,7 @@ Service::setStatus() {
 
 void
 Service::setStatus(DWORD state) {
-  if (status_handle == 0) {
+  if (status_handle == nullptr) {
     vlog.debug("warning - cannot setStatus");
     return;
   }
@@ -141,7 +141,7 @@ Service::setStatus(DWORD state) {
 
 Service::~Service() {
   vlog.debug("~Service");
-  service = 0;
+  service = nullptr;
 }
 
 
@@ -254,7 +254,7 @@ rfb::win32::changeDesktop() {
 bool
 rfb::win32::emulateCtrlAltDel() {
   rfb::win32::Handle sessionEventCad = 
-    CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNCCad");
+    CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNCCad");
   SetEvent(sessionEventCad);
   return true;
 }
@@ -265,7 +265,7 @@ rfb::win32::emulateCtrlAltDel() {
 class Logger_EventLog : public Logger {
 public:
   Logger_EventLog(const char* srcname) : Logger("EventLog") {
-    eventlog = RegisterEventSource(NULL, srcname);
+    eventlog = RegisterEventSource(nullptr, srcname);
     if (!eventlog)
       printf("Unable to open event log:%ld\n", GetLastError());
   }
@@ -279,7 +279,7 @@ public:
     const char* strings[] = {logname, message};
     WORD type = EVENTLOG_INFORMATION_TYPE;
     if (level == 0) type = EVENTLOG_ERROR_TYPE;
-    if (!ReportEvent(eventlog, type, 0, VNC4LogMessage, NULL, 2, 0, strings, NULL)) {
+    if (!ReportEvent(eventlog, type, 0, VNC4LogMessage, nullptr, 2, 0, strings, nullptr)) {
       // *** It's not at all clear what is the correct behaviour if this fails...
       printf("ReportEvent failed:%ld\n", GetLastError());
     }
@@ -289,7 +289,7 @@ protected:
   HANDLE eventlog;
 };
 
-static Logger_EventLog* logger = 0;
+static Logger_EventLog* logger = nullptr;
 
 bool rfb::win32::initEventLogLogger(const char* srcname) {
   if (logger)
@@ -333,7 +333,7 @@ bool rfb::win32::registerService(const char* name,
   // - Register the service
 
   // - Open the SCM
-  ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
+  ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
   if (!scm)
     throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
 
@@ -342,7 +342,7 @@ bool rfb::win32::registerService(const char* name,
     name, display, SC_MANAGER_ALL_ACCESS,
     SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS,
     SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
-    cmdline.c_str(), NULL, NULL, NULL, NULL, NULL);
+    cmdline.c_str(), nullptr, nullptr, nullptr, nullptr, nullptr);
   if (!service)
     throw rdr::SystemException("unable to create service", GetLastError());
 
@@ -378,7 +378,7 @@ bool rfb::win32::registerService(const char* name,
 
 bool rfb::win32::unregisterService(const char* name) {
   // - Open the SCM
-  ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
+  ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CREATE_SERVICE);
   if (!scm)
     throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
 
@@ -405,7 +405,7 @@ bool rfb::win32::unregisterService(const char* name) {
 bool rfb::win32::startService(const char* name) {
 
   // - Open the SCM
-  ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+  ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
   if (!scm)
     throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
 
@@ -415,7 +415,7 @@ bool rfb::win32::startService(const char* name) {
     throw rdr::SystemException("unable to open the service", GetLastError());
 
   // - Start the service
-  if (!StartService(service, 0, NULL))
+  if (!StartService(service, 0, nullptr))
     throw rdr::SystemException("unable to start the service", GetLastError());
 
   Sleep(500);
@@ -425,7 +425,7 @@ bool rfb::win32::startService(const char* name) {
 
 bool rfb::win32::stopService(const char* name) {
   // - Open the SCM
-  ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+  ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
   if (!scm)
     throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
 
@@ -446,7 +446,7 @@ bool rfb::win32::stopService(const char* name) {
 
 DWORD rfb::win32::getServiceState(const char* name) {
   // - Open the SCM
-  ServiceHandle scm = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);
+  ServiceHandle scm = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
   if (!scm)
     throw rdr::SystemException("unable to open Service Control Manager", GetLastError());
 
index 015ba549f6035152a4714a074f6171337c20d1c4..7d6038cbc2471509efb70b14484db9b6de34f743 100644 (file)
@@ -50,7 +50,7 @@ SocketManager::~SocketManager() {
 
 static void requestAddressChangeEvents(network::SocketListener* sock_) {
   DWORD dummy = 0;
-  if (WSAIoctl(sock_->getFd(), SIO_ADDRESS_LIST_CHANGE, 0, 0, 0, 0, &dummy, 0, 0) == SOCKET_ERROR) {
+  if (WSAIoctl(sock_->getFd(), SIO_ADDRESS_LIST_CHANGE, nullptr, 0, nullptr, 0, &dummy, nullptr, nullptr) == SOCKET_ERROR) {
     DWORD err = WSAGetLastError();
     if (err != WSAEWOULDBLOCK)
       vlog.error("Unable to track address changes: 0x%08x", (unsigned)err);
@@ -210,7 +210,7 @@ void SocketManager::processEvent(HANDLE event) {
       network::Socket* new_sock = li.sock->accept();
       if (new_sock && li.disable) {
         delete new_sock;
-        new_sock = 0;
+        new_sock = nullptr;
       }
       if (new_sock)
         addSocket(new_sock, li.server, false);
index 809c470efab279af384c581c9cca2747b13c7c20..b3df2f4bea3b826790de4c36e02b381b70438e92 100644 (file)
@@ -61,7 +61,7 @@ namespace rfb {
       // VNCServer.
       void addListener(network::SocketListener* sock_,
                        VNCServer* srvr,
-                       AddressChangeNotifier* acn = 0);
+                       AddressChangeNotifier* acn = nullptr);
 
       // Remove and delete a listening socket.
       void remListener(network::SocketListener* sock);
index c99203d157d54e4f6f28087587d3eca79f60317a..61d2c9aca12d33c57f1f2a3acb40f2df1b1672e0 100644 (file)
@@ -43,7 +43,7 @@ namespace rfb {
 
         nid.hWnd = getHandle();
         nid.uID = 0;
-        nid.hIcon = 0;
+        nid.hIcon = nullptr;
         nid.uFlags = NIF_ICON | NIF_MESSAGE;
         nid.uCallbackMessage = WM_USER;
       }
@@ -54,13 +54,13 @@ namespace rfb {
         if (icon == 0) {
           return remove();
         } else {
-          nid.hIcon = (HICON)LoadImage(GetModuleHandle(0), MAKEINTRESOURCE(icon),
+          nid.hIcon = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(icon),
             IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
           return refresh();
         }
       }
       bool setToolTip(const char* text) {
-        if (text == 0) {
+        if (text == nullptr) {
           nid.uFlags &= ~NIF_TIP;
         } else {
           const int tipLen = sizeof(nid.szTip)/sizeof(char);
index 32a8993027eb81a7c40976bd043abb99f0e0b16e..54e31cdc01a92c201142a23583567dbd130113c8 100644 (file)
@@ -32,8 +32,8 @@ using namespace rfb::win32;
 
 static LogWriter vlog("WMCursor");
 
-WMCursor::WMCursor() : cursor(0) {
-  cursor = (HCURSOR)LoadImage(0, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+WMCursor::WMCursor() : cursor(nullptr) {
+  cursor = (HCURSOR)LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
 }
 
 WMCursor::~WMCursor() {
index f4366583de025ebfddb9f105e4d600513f7121df..465331dec3c45ccf58e46cc977f40279c95ad1f6 100644 (file)
@@ -40,7 +40,7 @@ namespace rfb {
         HCURSOR cursor;
         Point position;
         bool visible;
-        Info() : cursor(0), visible(false) {}
+        Info() : cursor(nullptr), visible(false) {}
         bool operator!=(const Info& info) {
           return ((cursor != info.cursor) ||
             (position != info.position) ||
index 017972ba2bd7e271fd939ed2b3d39f661683115f..62fc49f6bd24f9e83467beb2f383e4369f258b50 100644 (file)
@@ -65,52 +65,52 @@ static WM_Hooks_EnableRealInputs_proto WM_Hooks_EnableRealInputs;
 
 static void LoadHooks()
 {
-  if (hooksLibrary != NULL)
+  if (hooksLibrary != nullptr)
     return;
 
   hooksLibrary = LoadLibrary("wm_hooks.dll");
-  if (hooksLibrary == NULL)
+  if (hooksLibrary == nullptr)
     return;
 
   WM_Hooks_WindowChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_WindowChanged");
-  if (WM_Hooks_WindowChanged == NULL)
+  if (WM_Hooks_WindowChanged == nullptr)
     goto error;
   WM_Hooks_WindowBorderChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_WindowBorderChanged");
-  if (WM_Hooks_WindowBorderChanged == NULL)
+  if (WM_Hooks_WindowBorderChanged == nullptr)
     goto error;
   WM_Hooks_WindowClientAreaChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_WindowClientAreaChanged");
-  if (WM_Hooks_WindowClientAreaChanged == NULL)
+  if (WM_Hooks_WindowClientAreaChanged == nullptr)
     goto error;
   WM_Hooks_RectangleChanged = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_RectangleChanged");
-  if (WM_Hooks_RectangleChanged == NULL)
+  if (WM_Hooks_RectangleChanged == nullptr)
     goto error;
 #ifdef _DEBUG
   WM_Hooks_Diagnostic = (WM_Hooks_WMVAL_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_Diagnostic");
-  if (WM_Hooks_Diagnostic == NULL)
+  if (WM_Hooks_Diagnostic == nullptr)
     goto error;
 #endif
 
   WM_Hooks_Install = (WM_Hooks_Install_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_Install");
-  if (WM_Hooks_Install == NULL)
+  if (WM_Hooks_Install == nullptr)
     goto error;
   WM_Hooks_Remove = (WM_Hooks_Remove_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_Remove");
-  if (WM_Hooks_Remove == NULL)
+  if (WM_Hooks_Remove == nullptr)
     goto error;
 #ifdef _DEBUG
   WM_Hooks_SetDiagnosticRange = (WM_Hooks_SetDiagnosticRange_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_SetDiagnosticRange");
-  if (WM_Hooks_SetDiagnosticRange == NULL)
+  if (WM_Hooks_SetDiagnosticRange == nullptr)
     goto error;
 #endif
 
   WM_Hooks_EnableRealInputs = (WM_Hooks_EnableRealInputs_proto)(void*)GetProcAddress(hooksLibrary, "WM_Hooks_EnableRealInputs");
-  if (WM_Hooks_EnableRealInputs == NULL)
+  if (WM_Hooks_EnableRealInputs == nullptr)
     goto error;
 
   return;
 
 error:
   FreeLibrary(hooksLibrary);
-  hooksLibrary = NULL;
+  hooksLibrary = nullptr;
 }
 
 
@@ -126,7 +126,7 @@ protected:
   DWORD thread_id;
 };
 
-static WMHooksThread* hook_mgr = 0;
+static WMHooksThread* hook_mgr = nullptr;
 static std::list<WMHooks*> hooks;
 static os::Mutex hook_mgr_lock;
 
@@ -134,7 +134,7 @@ static os::Mutex hook_mgr_lock;
 static bool StartHookThread() {
   if (hook_mgr)
     return true;
-  if (hooksLibrary == NULL)
+  if (hooksLibrary == nullptr)
     return false;
   vlog.debug("creating thread");
   hook_mgr = new WMHooksThread();
@@ -146,7 +146,7 @@ static bool StartHookThread() {
     vlog.error("failed to initialise hooks");
     hook_mgr->stop();
     delete hook_mgr;
-    hook_mgr = 0;
+    hook_mgr = nullptr;
     return false;
   }
   return true;
@@ -160,7 +160,7 @@ static void StopHookThread() {
   vlog.debug("closing thread");
   hook_mgr->stop();
   delete hook_mgr;
-  hook_mgr = 0;
+  hook_mgr = nullptr;
 }
 
 
@@ -220,7 +220,7 @@ WMHooksThread::worker() {
 
   thread_id = GetCurrentThreadId();
 
-  while (active && GetMessage(&msg, NULL, 0, 0)) {
+  while (active && GetMessage(&msg, nullptr, 0, 0)) {
     count++;
 
     if (msg.message == WM_TIMER) {
@@ -306,7 +306,7 @@ WMHooksThread::stop() {
 
 // -=- WMHooks class
 
-rfb::win32::WMHooks::WMHooks() : updateEvent(0) {
+rfb::win32::WMHooks::WMHooks() : updateEvent(nullptr) {
   LoadHooks();
 }
 
@@ -358,7 +358,7 @@ rfb::win32::WMBlockInput::~WMBlockInput() {
 static bool blocking = false;
 static bool blockRealInputs(bool block_) {
   // NB: Requires blockMutex to be held!
-  if (hooksLibrary == NULL)
+  if (hooksLibrary == nullptr)
     return false;
   if (block_) {
     if (blocking)
index 81b4fa51fc055798380a4b0b824d373d22bbc836..894add1c6ba8e9466107be998c298c45b4d11fd8 100644 (file)
@@ -34,7 +34,7 @@ using namespace rfb::win32;
 static LogWriter vlog("WMMonitor");
 
 
-WMMonitor::WMMonitor() : MsgWindow("WMMonitor"), notifier(0) {
+WMMonitor::WMMonitor() : MsgWindow("WMMonitor"), notifier(nullptr) {
 }
 
 WMMonitor::~WMMonitor() {
index 851b69f43099ed06b6507f9c28771c8e6d135af4..0783e4ff50d9920832fc512754d678192fef19c3 100644 (file)
@@ -38,7 +38,7 @@ namespace rfb {
 
     class WMPoller {
     public:
-      WMPoller() : ut(0) {}
+      WMPoller() : ut(nullptr) {}
 
       bool processEvent();
       bool setUpdateTracker(UpdateTracker* ut);
index 4d69d54bc41ac9473c072f0b5f5f4b80df5f4468..ec6e1fdcb5fcff211424de81a493f88e2d5c80ec 100644 (file)
@@ -33,7 +33,7 @@ static LogWriter vlog("WMCopyRect");
 
 // -=- WMHooks class
 
-rfb::win32::WMCopyRect::WMCopyRect() : ut(0), fg_window(0) {
+rfb::win32::WMCopyRect::WMCopyRect() : ut(nullptr), fg_window(nullptr) {
 }
 
 bool
@@ -56,10 +56,10 @@ rfb::win32::WMCopyRect::processEvent() {
       fg_window = window;
       fg_window_rect = winrect;
     } else {
-      fg_window = 0;
+      fg_window = nullptr;
     }
   } else {
-    fg_window = 0;
+    fg_window = nullptr;
   }
   return false;
 }
index ed6b70cbebb770254d92d6200d720c68cec8f811..c3b7ad1967792a64684e1edecc6ab46dc39fdcb7 100644 (file)
@@ -44,7 +44,7 @@ FileVersionInfo::FileVersionInfo(const char* filename) {
   // Attempt to open the file, to cause Access Denied, etc, errors
   // to be correctly reported, since the GetFileVersionInfoXXX calls lie...
   {
-    Handle file(CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0));
+    Handle file(CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
          if (file.h == INVALID_HANDLE_VALUE)
       throw rdr::SystemException("Failed to open file", GetLastError());
   }
@@ -77,7 +77,7 @@ const char* FileVersionInfo::getVerString(const char* name, DWORD langId) {
   infoName = format("\\StringFileInfo\\%s\\%s", langIdStr.c_str(), name);
 
   // Locate the required version string within the version info
-  char* buffer = 0;
+  char* buffer = nullptr;
   UINT length = 0;
   if (!VerQueryValue(buf, infoName.c_str(), (void**)&buffer, &length)) {
     printf("unable to find %s version string", infoName.c_str());
@@ -104,13 +104,13 @@ void centerWindow(HWND handle, const RECT& r) {
   int x = (r.left + r.right - w)/2;
   int y = (r.top + r.bottom - h)/2;
   UINT flags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOSIZE;
-  SetWindowPos(handle, 0, x, y, 0, 0, flags);
+  SetWindowPos(handle, nullptr, x, y, 0, 0, flags);
 }
 
 void resizeWindow(HWND handle, int width, int height) {
   RECT r;
   GetWindowRect(handle, &r);
-  SetWindowPos(handle, 0, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
+  SetWindowPos(handle, nullptr, 0, 0, width, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
   centerWindow(handle, r);
 }
 
index 24d5905d7c79bebdb2b9dce985fc6c5f64b6e836..927ca1e2bcd8adbf7da91fcb441031bc4b6fbc1d 100644 (file)
@@ -30,7 +30,7 @@ namespace rfb {
   namespace win32 {
 
     struct FileVersionInfo {
-      FileVersionInfo(const char* filename=0);
+      FileVersionInfo(const char* filename=nullptr);
       ~FileVersionInfo();
       const char* getVerString(const char* name, DWORD langId = 0x080904b0);
     private:
index a69f75925a9634d94c43809c50aa76cadb08870d..79d5dfa4187935b87d24995255d497cdda37dde2 100644 (file)
@@ -43,7 +43,7 @@ namespace rfb {
     class SecPage : public SecurityPage {
     public:
       SecPage(const RegKey& rk)
-        : SecurityPage(NULL), regKey(rk) {
+        : SecurityPage(nullptr), regKey(rk) {
         security = new SecurityServer();
       }
 
@@ -84,10 +84,10 @@ namespace rfb {
         if (isItemChecked(IDC_AUTH_VNC))
           verifyVncPassword(regKey);
         else if (haveVncPassword() && 
-            MsgBox(0, "The VNC authentication method is disabled, but a password is still stored for it.\n"
+            MsgBox(nullptr, "The VNC authentication method is disabled, but a password is still stored for it.\n"
                       "Do you want to remove the VNC authentication password from the registry?",
                       MB_ICONWARNING | MB_YESNO) == IDYES) {
-          regKey.setBinary("Password", 0, 0);
+          regKey.setBinary("Password", nullptr, 0);
         }
 
 #ifdef HAVE_GNUTLS
@@ -119,7 +119,7 @@ namespace rfb {
 
       static void verifyVncPassword(const RegKey& regKey) {
         if (!haveVncPassword()) {
-          MsgBox(0, "The VNC authentication method is enabled, but no password is specified.\n"
+          MsgBox(nullptr, "The VNC authentication method is enabled, but no password is specified.\n"
                     "The password dialog will now be shown.", MB_ICONINFORMATION | MB_OK);
           PasswordDialog passwd(regKey, registryInsecure);
           passwd.showDialog();
@@ -165,10 +165,10 @@ namespace rfb {
         ofn.nMaxFile = sizeof(filename);
         ofn.lpstrFilter = (char*)filter;
         ofn.nFilterIndex = 1;
-        ofn.lpstrFileTitle = NULL;
+        ofn.lpstrFileTitle = nullptr;
         ofn.nMaxFileTitle = 0;
         ofn.lpstrTitle = (char*)title;
-        ofn.lpstrInitialDir = NULL;
+        ofn.lpstrInitialDir = nullptr;
         ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
 
         if (GetOpenFileName(&ofn)==TRUE) {
index fcaae2034b9da662674e533940abd45a11575488..9ff6f6a4f89e7a0e144cb465302533c5049fbb01 100644 (file)
@@ -41,7 +41,7 @@ namespace rfb {
 
     class ConnHostDialog : public Dialog {
     public:
-      ConnHostDialog() : Dialog(GetModuleHandle(0)) {}
+      ConnHostDialog() : Dialog(GetModuleHandle(nullptr)) {}
       bool showDialog(const char* pat) {
         pattern = pat;
         return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONN_HOST));
@@ -74,7 +74,7 @@ namespace rfb {
           network::TcpFilter::Pattern pat(network::TcpFilter::parsePattern(newPat.c_str()));
           pattern = network::TcpFilter::patternToStr(pat);
         } catch(rdr::Exception& e) {
-          MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK);
+          MsgBox(nullptr, e.str(), MB_ICONEXCLAMATION | MB_OK);
           return false;
         }
         return true;
@@ -87,7 +87,7 @@ namespace rfb {
     class ConnectionsPage : public PropSheetPage {
     public:
       ConnectionsPage(const RegKey& rk)
-        : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_CONNECTIONS)), regKey(rk) {}
+        : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_CONNECTIONS)), regKey(rk) {}
       void initDialog() {
         vlog.debug("set IDC_PORT %d", (int)port_number);
         setItemInt(IDC_PORT, port_number ? port_number : 5900);
index d7ed0bc8b94fa80ee9064f1641eaf97f76d76d79..c927d5ac7a62313dba78b9ab7285dd19e56464a4 100644 (file)
@@ -29,7 +29,7 @@ namespace rfb {
     class DesktopPage : public PropSheetPage {
     public:
       DesktopPage(const RegKey& rk)
-        : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_DESKTOP)), regKey(rk) {}
+        : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_DESKTOP)), regKey(rk) {}
       void initDialog() {
         const char *action(rfb::win32::SDisplay::disconnectAction);
         bool disconnectLock = stricmp(action, "Lock") == 0;
index e775f2902c9ffdd079407d75e1de106c3a27fd17..d3cf8620d554b8fcc92b7f3d25eb613001a03ff7 100644 (file)
@@ -31,7 +31,7 @@ namespace rfb {
     class HookingPage : public PropSheetPage {
     public:
       HookingPage(const RegKey& rk)
-        : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_HOOKING)), regKey(rk) {}
+        : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_HOOKING)), regKey(rk) {}
       void initDialog() {
         setItemChecked(IDC_USEPOLLING, rfb::win32::SDisplay::updateMethod == 0);
         setItemChecked(IDC_USEHOOKS, (rfb::win32::SDisplay::updateMethod == 1));
index a2ac5a46d61b8ca9b7dfde66f834565fa1352bf6..671520ba826d1555a5c3203dac20f715444e8bc6 100644 (file)
@@ -33,7 +33,7 @@ namespace rfb {
     class InputsPage : public PropSheetPage {
     public:
       InputsPage(const RegKey& rk)
-        : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_INPUTS)),
+        : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_INPUTS)),
           regKey(rk), enableAffectSSaver(true) {}
       void initDialog() {
         setItemChecked(IDC_ACCEPT_KEYS, rfb::Server::acceptKeyEvents);
@@ -70,7 +70,7 @@ namespace rfb {
         regKey.setBool("DisableLocalInputs", isItemChecked(IDC_DISABLE_LOCAL_INPUTS));
         if (enableAffectSSaver) {
           BOOL blocked = !isItemChecked(IDC_AFFECT_SCREENSAVER);
-          SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
+          SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, nullptr, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
         }
         return true;
       }
index 3a22bb5275686b9fe315d169748c39be7a6a4975..1ea867fb9c58bab78183876717edb4399c6f0c13 100644 (file)
@@ -53,7 +53,7 @@ void LegacyPage::LoadPrefs()
         try {
           winvnc3.openKey(HKEY_LOCAL_MACHINE, "Software\\ORL\\WinVNC3");
           int debugMode = winvnc3.getInt("DebugMode", 0);
-          const char* debugTarget = 0; 
+          const char* debugTarget = nullptr;
           if (debugMode & 2) debugTarget = "file";
           if (debugMode & 4) debugTarget = "stderr";
           if (debugTarget) {
@@ -115,7 +115,7 @@ void LegacyPage::LoadPrefs()
               // Finally, save the Hosts value
               regKey.setString("Hosts", newHosts.c_str());
             } catch (rdr::Exception&) {
-              MsgBox(0, "Unable to convert AuthHosts setting to Hosts format.",
+              MsgBox(nullptr, "Unable to convert AuthHosts setting to Hosts format.",
                      MB_ICONWARNING | MB_OK);
             }
           } else {
@@ -181,7 +181,7 @@ void LegacyPage::LoadPrefs()
       {
         regKey.setInt("PortNumber", key.getBool("SocketConnect") ? key.getInt("PortNumber", 5900) : 0);
         if (key.getBool("AutoPortSelect", false)) {
-          MsgBox(0, "The AutoPortSelect setting is not supported by this release."
+          MsgBox(nullptr, "The AutoPortSelect setting is not supported by this release."
                     "The port number will default to 5900.",
                     MB_ICONWARNING | MB_OK);
           regKey.setInt("PortNumber", 5900);
@@ -193,7 +193,7 @@ void LegacyPage::LoadPrefs()
 
         if (key.getInt("QuerySetting", 2) != 2) {
           regKey.setBool("QueryConnect", key.getInt("QuerySetting") > 2);
-          MsgBox(0, "The QuerySetting option has been replaced by QueryConnect."
+          MsgBox(nullptr, "The QuerySetting option has been replaced by QueryConnect."
                  "Please see the documentation for details of the QueryConnect option.",
                  MB_ICONWARNING | MB_OK);
         }
@@ -222,9 +222,9 @@ void LegacyPage::LoadPrefs()
         regKey.setBool("UseHooks", !key.getBool("PollFullScreen", false));
 
         if (key.isValue("AllowShutdown"))
-          MsgBox(0, "The AllowShutdown option is not supported by this release.", MB_ICONWARNING | MB_OK);
+          MsgBox(nullptr, "The AllowShutdown option is not supported by this release.", MB_ICONWARNING | MB_OK);
         if (key.isValue("AllowEditClients"))
-          MsgBox(0, "The AllowEditClients option is not supported by this release.", MB_ICONWARNING | MB_OK);
+          MsgBox(nullptr, "The AllowEditClients option is not supported by this release.", MB_ICONWARNING | MB_OK);
 
         allowProperties = key.getBool("AllowProperties", allowProperties);
       }
index 884a151a8c8c6f1c2ef85090e5395dff246a1125..9232a24d557f705ff4131ebec4a77d85f70cc7a1 100644 (file)
@@ -35,7 +35,7 @@ namespace rfb {
     class LegacyPage : public PropSheetPage {
     public:
       LegacyPage(const RegKey& rk, bool userSettings_)
-        : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_LEGACY)), regKey(rk), userSettings(userSettings_) {}
+        : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_LEGACY)), regKey(rk), userSettings(userSettings_) {}
       void initDialog() {
         setItemChecked(IDC_PROTOCOL_3_3, rfb::Server::protocol3_3);
       }
@@ -43,13 +43,13 @@ namespace rfb {
         switch (id) {
         case IDC_LEGACY_IMPORT:
           {
-            DWORD result = MsgBox(0,
+            DWORD result = MsgBox(nullptr,
               "Importing your legacy VNC 3.3 settings will overwrite your existing settings.\n"
               "Are you sure you wish to continue?",
               MB_ICONWARNING | MB_YESNO);
             if (result == IDYES) {
               LoadPrefs();
-              MsgBox(0, "Imported VNC 3.3 settings successfully.",
+              MsgBox(nullptr, "Imported VNC 3.3 settings successfully.",
                      MB_ICONINFORMATION | MB_OK);
 
               // Sleep to allow RegConfig thread to reload settings
index f35aeb54d82a7297c014a5fe9bd729b070df1f72..8a7103ca7f3c3e6ee9f0ac3436ac5dca8acf0d89 100644 (file)
@@ -25,7 +25,7 @@ using namespace rfb;
 using namespace win32;
 
 PasswordDialog::PasswordDialog(const RegKey& rk, bool registryInsecure_)
-  : Dialog(GetModuleHandle(0)), regKey(rk), registryInsecure(registryInsecure_) {
+  : Dialog(GetModuleHandle(nullptr)), regKey(rk), registryInsecure(registryInsecure_) {
 }
 
 bool PasswordDialog::showDialog(HWND owner) {
@@ -36,12 +36,12 @@ bool PasswordDialog::onOk() {
   std::string password1(getItemString(IDC_PASSWORD1));
   std::string password2(getItemString(IDC_PASSWORD2));
   if (password1 != password2) {
-    MsgBox(0, "The supplied passwords do not match",
+    MsgBox(nullptr, "The supplied passwords do not match",
            MB_ICONEXCLAMATION | MB_OK);
     return false;
   }
   if (registryInsecure &&
-      (MsgBox(0, "Please note that your password cannot be stored securely on this system.  "
+      (MsgBox(nullptr, "Please note that your password cannot be stored securely on this system.  "
                  "Are you sure you wish to continue?",
               MB_YESNO | MB_ICONWARNING) == IDNO))
     return false;
index dd23f8e301ff0ff7104a653c405ad5cbfa0adaf9..5b9d3fb3100b871a032cb60cc99728117fc189df 100644 (file)
@@ -27,7 +27,7 @@ namespace rfb {
     class PasswordDialog : public Dialog {
     public:
       PasswordDialog(const RegKey& rk, bool registryInsecure_);
-      bool showDialog(HWND owner=0);
+      bool showDialog(HWND owner=nullptr);
       bool onOk();
     protected:
       const RegKey& regKey;
index 0a2bbe40d64e71214dede2bccf491aa2e800e718..73966c9d3905bf768f2b47fd5d12c4427a32636c 100644 (file)
@@ -29,7 +29,7 @@ namespace rfb {
     class SharingPage : public PropSheetPage {
     public:
       SharingPage(const RegKey& rk)
-        : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_SHARING)), regKey(rk) {}
+        : PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_SHARING)), regKey(rk) {}
       void initDialog() {
         setItemChecked(IDC_DISCONNECT_CLIENTS, rfb::Server::disconnectClients);
         setItemChecked(IDC_SHARE_NEVER, rfb::Server::neverShared);
index 2b7eaa1e93659f986efb2463fb4f8f83600fb44a..b32f7607562fb40946980c274f9e9d266a3467d1 100644 (file)
@@ -84,7 +84,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
   freopen("CONIN$","rb",stdin);
   freopen("CONOUT$","wb",stdout);
   freopen("CONOUT$","wb",stderr);
-  setbuf(stderr, 0);
+  setbuf(stderr, nullptr);
   initStdIOLoggers();
   LogWriter vlog("main");
   logParams.setParam("*:stderr:100");
@@ -130,7 +130,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
         // Something weird happens on NT 4.0 SP5 but I can't reproduce it on other
         // NT 4.0 service pack revisions.
         if (e.err == ERROR_INVALID_PARAMETER) {
-          MsgBox(0, "Windows reported an error trying to secure the VNC Server settings for this user.  "
+          MsgBox(nullptr, "Windows reported an error trying to secure the VNC Server settings for this user.  "
                     "Your settings may not be secure!", MB_ICONWARNING | MB_OK);
         } else if (e.err != ERROR_CALL_NOT_IMPLEMENTED &&
                    e.err != ERROR_NOT_LOGGED_ON) {
@@ -166,14 +166,14 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
 
 #ifdef _DEBUG
       vlog.debug("capture dialogs=%s", captureDialogs ? "true" : "false");
-      sheet.showPropSheet(0, true, false, captureDialogs);
+      sheet.showPropSheet(nullptr, true, false, captureDialogs);
 #else
-      sheet.showPropSheet(0, true, false);
+      sheet.showPropSheet(nullptr, true, false);
 #endif
     } catch (rdr::SystemException& e) {
       switch (e.err) {
       case ERROR_ACCESS_DENIED:
-        MsgBox(0, "You do not have sufficient access rights to run the VNC Configuration applet",
+        MsgBox(nullptr, "You do not have sufficient access rights to run the VNC Configuration applet",
                MB_ICONSTOP | MB_OK);
         return 1;
       };
@@ -181,7 +181,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE /*prev*/, char* /*cmdLine*/, int /*
     }
 
   } catch (rdr::Exception& e) {
-    MsgBox(NULL, e.str(), MB_ICONEXCLAMATION | MB_OK);
+    MsgBox(nullptr, e.str(), MB_ICONEXCLAMATION | MB_OK);
     return 1;
   }
 
index 44e15e7084d0304c6f17e81baa92af768ed80263..1c24d23b562e21252bc19238f64c123ad723e96a 100644 (file)
@@ -28,7 +28,7 @@ namespace winvnc {
 
   class AddNewClientDialog : public rfb::win32::Dialog {
   public:
-    AddNewClientDialog() : Dialog(GetModuleHandle(0)) {}
+    AddNewClientDialog() : Dialog(GetModuleHandle(nullptr)) {}
     // - Show the dialog and return true if OK was clicked,
     //   false in case of error or Cancel
     virtual bool showDialog() {
index 1b3c40eb97e343956625ee8cdc133dda8ecc6e71..6c593c45d52bf6b5588e610895da2407a7cfe1df 100644 (file)
@@ -16,7 +16,7 @@ using namespace winvnc;
 
 bool ControlPanel::showDialog()
 {
-  return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONTROL_PANEL), NULL);
+  return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONTROL_PANEL), nullptr);
 }
 
 void ControlPanel::initDialog()
@@ -118,7 +118,7 @@ BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM /*lPara
   case WM_COMMAND:
     switch (LOWORD(wParam)) {
     case IDCANCEL:
-      handle = NULL;
+      handle = nullptr;
       EndDialog(hwnd, 0);
       return TRUE;
     default:
@@ -145,7 +145,7 @@ void ControlPanel::SendCommand(DWORD command, int data)
   COPYDATASTRUCT copyData;
   copyData.dwData = command;
   copyData.cbData = 0;
-  copyData.lpData = 0;
+  copyData.lpData = nullptr;
   getSelConnInfo();
   if (data != -1) {
     ListConnStatus.Copy(&ListSelConn);
index f64a60813966c15a885b128ca0fa6d014b8dd660..5d0c50692c62262b6b9648d311d442804fdc27e6 100644 (file)
@@ -20,7 +20,7 @@ namespace winvnc {
   
   class ControlPanel : rfb::win32::Dialog, rfb::win32::ListViewControl {
   public:
-    ControlPanel(HWND hSTIcon) : Dialog(GetModuleHandle(0)), ListViewControl(){
+    ControlPanel(HWND hSTIcon) : Dialog(GetModuleHandle(nullptr)), ListViewControl(){
       m_hSTIcon = hSTIcon;
       stop_updating = false;
     };
index 1a278678b30db17498b8f4ac4f2b98bd9ec7aba1..adc074cf5fe8e372398c1b10352ce445cd92051d 100644 (file)
@@ -31,7 +31,7 @@ static LogWriter vlog("ManagedListener");
 
 
 ManagedListener::ManagedListener(SocketManager* mgr)
-: filter(0), manager(mgr), addrChangeNotifier(0), server(0), port(0), localOnly(false) {
+: filter(nullptr), manager(mgr), addrChangeNotifier(nullptr), server(nullptr), port(0), localOnly(false) {
 }
 
 ManagedListener::~ManagedListener() {
@@ -98,7 +98,7 @@ void ManagedListener::refresh() {
       if (localOnly)
         network::createLocalTcpListeners(&sockets, port);
       else
-        network::createTcpListeners(&sockets, NULL, port);
+        network::createTcpListeners(&sockets, nullptr, port);
     }
   } catch (rdr::Exception& e) {
     vlog.error("%s", e.str());
index 26bd93310c58445fc72edfdacb05e5b4e7484ad9..bedfe5a92e643fec670617a179c2cb2481e9e23a 100644 (file)
@@ -44,7 +44,7 @@ static IntParameter timeout("QueryConnectTimeout",
 QueryConnectDialog::QueryConnectDialog(network::Socket* sock_,
                                        const char* userName_,
                                        VNCServerWin32* s)
-: Dialog(GetModuleHandle(0)),
+: Dialog(GetModuleHandle(nullptr)),
   sock(sock_), peerIp(sock->getPeerAddress()), userName(userName_),
   approve(false), server(s) {
 }
@@ -73,7 +73,7 @@ void QueryConnectDialog::worker() {
 // - Dialog overrides
 
 void QueryConnectDialog::initDialog() {
-  if (!SetTimer(handle, 1, 1000, 0))
+  if (!SetTimer(handle, 1, 1000, nullptr))
     throw rdr::SystemException("SetTimer", GetLastError());
   setItemString(IDC_QUERY_HOST, peerIp.c_str());
   if (userName.empty())
index e70329980908f20dd89d4353a1a798bfd5039573..e23ca77273f2752c12b31fde49426b96ddbbe183 100644 (file)
@@ -80,7 +80,7 @@ public:
     SetWindowText(getHandle(), "winvnc::IPC_Interface");
     // ***
 
-    SetTimer(getHandle(), 1, 3000, 0);
+    SetTimer(getHandle(), 1, 3000, nullptr);
     PostMessage(getHandle(), WM_TIMER, 1, 0);
     PostMessage(getHandle(), WM_SET_TOOLTIP, 0, 0);
     CPanel = new ControlPanel(getHandle());
@@ -100,7 +100,7 @@ public:
           SendMessage(getHandle(), WM_COMMAND, ID_CONTR0L_PANEL, 0);
           break;
         case WM_RBUTTONUP:
-          HMENU menu = LoadMenu(GetModuleHandle(0), MAKEINTRESOURCE(thread.menu));
+          HMENU menu = LoadMenu(GetModuleHandle(nullptr), MAKEINTRESOURCE(thread.menu));
           HMENU trayMenu = GetSubMenu(menu, 0);
 
 
@@ -123,7 +123,7 @@ public:
           // Display the menu
           POINT pos;
           GetCursorPos(&pos);
-          TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, getHandle(), 0);
+          TrackPopupMenu(trayMenu, 0, pos.x, pos.y, 0, getHandle(), nullptr);
 
           break;
                } 
@@ -154,13 +154,13 @@ public:
         thread.server.disconnectClients("tray menu disconnect");
         break;
       case ID_CLOSE:
-        if (MsgBox(0, "Are you sure you want to close the server?",
+        if (MsgBox(nullptr, "Are you sure you want to close the server?",
                    MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
           if (isServiceProcess()) {
             try {
               rfb::win32::stopService(VNCServerService::Name);
             } catch (rdr::Exception& e) {
-              MsgBox(0, e.str(), MB_ICONERROR | MB_OK);
+              MsgBox(nullptr, e.str(), MB_ICONERROR | MB_OK);
             }
           } else {
             thread.server.stop();
@@ -239,7 +239,7 @@ protected:
 
 STrayIconThread::STrayIconThread(VNCServerWin32& sm, UINT inactiveIcon_, UINT activeIcon_, 
                                  UINT dis_inactiveIcon_, UINT dis_activeIcon_, UINT menu_)
-: thread_id(-1), windowHandle(0), server(sm),
+: thread_id(-1), windowHandle(nullptr), server(sm),
   inactiveIcon(inactiveIcon_), activeIcon(activeIcon_),
   dis_inactiveIcon(dis_inactiveIcon_), dis_activeIcon(dis_activeIcon_),
   menu(menu_), runTrayIcon(true) {
@@ -266,12 +266,12 @@ void STrayIconThread::worker() {
     windowHandle = icon.getHandle();
 
     MSG msg;
-    while (runTrayIcon && ::GetMessage(&msg, 0, 0, 0) > 0) {
+    while (runTrayIcon && ::GetMessage(&msg, nullptr, 0, 0) > 0) {
       TranslateMessage(&msg);
       DispatchMessage(&msg);
     }
 
-    windowHandle = 0;
+    windowHandle = nullptr;
   }
 }
 
index 09a0707b06e4cb3cae7d3ffdc6522b9cb27d4d2a..8ae4b747af0b4004dca6d9e828b577a3f1fc811b 100644 (file)
@@ -38,18 +38,18 @@ using namespace win32;
 const char* winvnc::VNCServerService::Name = "TigerVNC";
 
 // SendSAS is not available until Windows 7, and missing from MinGW
-static HMODULE sasLibrary = NULL;
+static HMODULE sasLibrary = nullptr;
 typedef void WINAPI (*SendSAS_proto)(BOOL AsUser);
-static SendSAS_proto _SendSAS = NULL;
+static SendSAS_proto _SendSAS = nullptr;
 
 VNCServerService::VNCServerService()
   : Service(Name)
-  , stopServiceEvent(CreateEvent(0, FALSE, FALSE, 0))
-  , sessionEvent(CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC"))
-  , sessionEventCad(CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNCCad")) {
-  if (sasLibrary == NULL) {
+  , stopServiceEvent(CreateEvent(nullptr, FALSE, FALSE, nullptr))
+  , sessionEvent(CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNC"))
+  , sessionEventCad(CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNCCad")) {
+  if (sasLibrary == nullptr) {
     sasLibrary = LoadLibrary("sas.dll");
-    if (sasLibrary != NULL)
+    if (sasLibrary != nullptr)
       _SendSAS = (SendSAS_proto)(void*)GetProcAddress(sasLibrary, "SendSAS");
   }
   // - Set the service-mode logging defaults
@@ -104,8 +104,8 @@ BOOL GetSessionUserTokenWin(OUT LPHANDLE lphUserToken)
 // START the app as system 
 HANDLE LaunchProcessWin(DWORD /*dwSessionId*/)
 {
-    HANDLE hProcess = NULL;
-    HANDLE hToken = NULL;
+    HANDLE hProcess = nullptr;
+    HANDLE hToken = nullptr;
     if (GetSessionUserTokenWin(&hToken))
     {
         ModuleFileName filename;
@@ -116,9 +116,9 @@ HANDLE LaunchProcessWin(DWORD /*dwSessionId*/)
         si.cb = sizeof si;
         si.dwFlags = STARTF_USESHOWWINDOW;
         PROCESS_INFORMATION    pi;
-        if (CreateProcessAsUser(hToken, NULL, (char*)cmdLine.c_str(),
-                                NULL, NULL, FALSE, DETACHED_PROCESS,
-                                NULL, NULL, &si, &pi))
+        if (CreateProcessAsUser(hToken, nullptr, (char*)cmdLine.c_str(),
+                                nullptr, nullptr, FALSE, DETACHED_PROCESS,
+                                nullptr, nullptr, &si, &pi))
         {
             CloseHandle(pi.hThread);
             hProcess = pi.hProcess;
@@ -132,7 +132,7 @@ DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
 {
     ConsoleSessionId OlddwSessionId;
 
-    HANDLE hProcess = NULL;
+    HANDLE hProcess = nullptr;
     //We use this event to notify the program that the session has changed
     //The program need to end so the service can restart the program in the correct session
     //wait_for_existing_process();
@@ -150,7 +150,7 @@ DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
 
         //cad request
         case WAIT_OBJECT_0 + 1:
-            if (_SendSAS != NULL)
+            if (_SendSAS != nullptr)
                 _SendSAS(FALSE);
             break; 
 
@@ -163,7 +163,7 @@ DWORD VNCServerService::serviceMain(int /*argc*/, char* /*argv*/ [])
                     SetEvent(sessionEvent);
                 }
                 DWORD dwExitCode = 0;
-                if (hProcess == NULL ||
+                if (hProcess == nullptr ||
                     (GetExitCodeProcess(hProcess, &dwExitCode) &&
                     dwExitCode != STILL_ACTIVE &&
                     CloseHandle(hProcess)))
index 38b2ef16ede1a46654c449e85e9fbc6e15ddc25f..0a7128f182548bcb11f7bcc2cbd12afa9a16f1e1 100644 (file)
@@ -61,13 +61,13 @@ static BoolParameter showTrayIcon("ShowTrayIcon",
 
 VNCServerWin32::VNCServerWin32()
   : command(NoCommand),
-    commandEvent(CreateEvent(0, TRUE, FALSE, 0)),
+    commandEvent(CreateEvent(nullptr, TRUE, FALSE, nullptr)),
     sessionEvent(isServiceProcess() ?
-      CreateEvent(0, FALSE, FALSE, "Global\\SessionEventTigerVNC") : 0),
+      CreateEvent(nullptr, FALSE, FALSE, "Global\\SessionEventTigerVNC") : nullptr),
     vncServer(ComputerName().buf, &desktop),
     thread_id(-1), runServer(false), isDesktopStarted(false),
-    config(&sockMgr), rfbSock(&sockMgr), trayIcon(0),
-    queryConnectDialog(0)
+    config(&sockMgr), rfbSock(&sockMgr), trayIcon(nullptr),
+    queryConnectDialog(nullptr)
 {
   commandLock = new os::Mutex;
   commandSig = new os::Condition(commandLock);
@@ -92,7 +92,7 @@ VNCServerWin32::~VNCServerWin32() {
   delete trayIcon;
 
   // Stop the SDisplay from updating our state
-  desktop.setStatusLocation(0);
+  desktop.setStatusLocation(nullptr);
 
   // Join the Accept/Reject dialog thread
   if (queryConnectDialog) {
@@ -187,7 +187,7 @@ int VNCServerWin32::run() {
     MSG msg;
     int result = 0;
     while (runServer) {
-      result = sockMgr.getMessage(&msg, NULL, 0, 0);
+      result = sockMgr.getMessage(&msg, nullptr, 0, 0);
       if (result < 0)
         throw rdr::SystemException("getMessage", GetLastError());
       if (!isServiceProcess() && (result == 0))
@@ -226,7 +226,7 @@ bool VNCServerWin32::disconnectClients(const char* reason) {
 }
 
 bool VNCServerWin32::addNewClient(const char* client) {
-  TcpSocket* sock = 0;
+  TcpSocket* sock = nullptr;
   try {
     std::string hostname;
     int port;
@@ -254,7 +254,7 @@ void VNCServerWin32::queryConnection(network::Socket* sock,
                                      const char* userName)
 {
   if (queryOnlyIfLoggedOn && CurrentUserToken().noUserLoggedOn()) {
-    vncServer.approveConnection(sock, true, NULL);
+    vncServer.approveConnection(sock, true, nullptr);
     return;
   }
   if (queryConnectDialog) {
@@ -266,7 +266,7 @@ void VNCServerWin32::queryConnection(network::Socket* sock,
 }
 
 void VNCServerWin32::queryConnectionComplete() {
-  queueCommand(QueryConnectionComplete, 0, 0, false);
+  queueCommand(QueryConnectionComplete, nullptr, 0, false);
 }
 
 
@@ -324,7 +324,7 @@ void VNCServerWin32::processEvent(HANDLE event_) {
                                   "Connection rejected by user");
       queryConnectDialog->wait();
       delete queryConnectDialog;
-      queryConnectDialog = 0;
+      queryConnectDialog = nullptr;
       break;
 
     default:
@@ -396,7 +396,7 @@ void VNCServerWin32::setConnStatus(ListConnInfo* listConn)
 
     status = listConn->iGetStatus();
     if (status == 3) {
-      conn->close(0);
+      conn->close(nullptr);
     } else {
       rfb::AccessRights ar;
 
index 0a2c330c722d58d013a2aacab6db867445e81619..0fff0963baa63778e8fc4d210d5aaac57e7cfbbe 100644 (file)
@@ -64,7 +64,7 @@ namespace winvnc {
 
     // Disconnect all connected clients
     // THREAD-SAFE
-    bool disconnectClients(const char* reason=0);
+    bool disconnectClients(const char* reason=nullptr);
 
     // Call used to notify VNCServerST of user accept/reject query completion
     // CALLED FROM AcceptConnectDialog THREAD
index 512464070745cb454bd21223cf2d37a80046206e..d612a43e085d5330e01ac76771408db0da1130b6 100644 (file)
@@ -88,7 +88,7 @@ static void programUsage() {
 
 static void MsgBoxOrLog(const char* msg, bool isError=false) {
   if (close_console) {
-    MsgBox(0, msg, (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK);
+    MsgBox(nullptr, msg, (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK);
   } else {
     if (isError) {
       try {
@@ -116,8 +116,8 @@ static void processParams(int argc, char** argv) {
           if (ancd.showDialog())
             host = ancd.getHostName();
         }
-        if (host != NULL) {
-          HWND hwnd = FindWindow(0, "winvnc::IPC_Interface");
+        if (host != nullptr) {
+          HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
           if (!hwnd)
             throw rdr::Exception("Unable to locate existing VNC Server.");
           COPYDATASTRUCT copyData;
@@ -130,12 +130,12 @@ static void processParams(int argc, char** argv) {
         }
       } else if (strcasecmp(argv[i], "-disconnect") == 0) {
         runServer = false;
-        HWND hwnd = FindWindow(0, "winvnc::IPC_Interface");
+        HWND hwnd = FindWindow(nullptr, "winvnc::IPC_Interface");
         if (!hwnd)
           throw rdr::Exception("Unable to locate existing VNC Server.");
         COPYDATASTRUCT copyData;
         copyData.dwData = 2; // *** DisconnectClients
-        copyData.lpData = 0;
+        copyData.lpData = nullptr;
         copyData.cbData = 0;
         printf("Sending disconnect request to VNC Server...\n");
         if (!SendMessage(hwnd, WM_COPYDATA, 0, (LPARAM)&copyData))
@@ -250,7 +250,7 @@ int WINAPI WinMain(HINSTANCE /*inst*/, HINSTANCE /*prevInst*/, char* /*cmdLine*/
        freopen("CONIN$", "rb", stdin);
        freopen("CONOUT$", "wb", stdout);
        freopen("CONOUT$", "wb", stderr);
-    setbuf(stderr, 0);
+    setbuf(stderr, nullptr);
        initStdIOLoggers();
        initFileLogger("C:\\temp\\WinVNC4.log");
        logParams.setParam("*:stderr:100");
index c864171b28db8d5e38aa9f36e23955f45c8140e8..ecff85cbe84b9065fe7f10ee48e76b6042438957 100644 (file)
@@ -69,7 +69,7 @@ ATOM ATOM_Popup_Selection = GlobalAddAtom("RFB.WM_Hooks.PopupSelectionAtom");
 // -=- DLL entry point
 //
 
-HINSTANCE dll_instance = 0;
+HINSTANCE dll_instance = nullptr;
 
 BOOL WINAPI DllMain(HANDLE instance, ULONG reason, LPVOID /*reserved*/) {
   switch (reason) {
@@ -92,12 +92,12 @@ BOOL WINAPI DllMain(HANDLE instance, ULONG reason, LPVOID /*reserved*/) {
 
 DWORD hook_owner SHARED = 0;
 DWORD hook_target SHARED = 0;
-HHOOK hook_CallWndProc SHARED = 0;
-HHOOK hook_CallWndProcRet SHARED = 0;
-HHOOK hook_GetMessage SHARED = 0;
-HHOOK hook_DialogMessage SHARED = 0;
+HHOOK hook_CallWndProc SHARED = nullptr;
+HHOOK hook_CallWndProcRet SHARED = nullptr;
+HHOOK hook_GetMessage SHARED = nullptr;
+HHOOK hook_DialogMessage SHARED = nullptr;
 BOOL enable_cursor_shape SHARED = FALSE;
-HCURSOR cursor SHARED = 0;
+HCURSOR cursor SHARED = nullptr;
 #ifdef _DEBUG
 UINT diagnostic_min SHARED =1;
 UINT diagnostic_max SHARED =0;
@@ -252,7 +252,7 @@ void ProcessWindowMessage(UINT msg, HWND wnd, WPARAM wParam, LPARAM /*lParam*/)
                                if (buffsize != 0)
                                {
                                        buff = (RGNDATA *) new BYTE [buffsize];
-                                       if (buff == NULL)
+                                       if (buff == nullptr)
                                                break;
 
                                        // Now get the region data
@@ -277,7 +277,7 @@ void ProcessWindowMessage(UINT msg, HWND wnd, WPARAM wParam, LPARAM /*lParam*/)
                        }
 
                        // Now free the region
-                       if (region != NULL)
+                       if (region != nullptr)
                                DeleteObject(region);
                }
     */
@@ -353,19 +353,19 @@ BOOL WM_Hooks_Remove(DWORD owner) {
   if (owner != hook_owner) return FALSE;
   if (hook_CallWndProc) {
     UnhookWindowsHookEx(hook_CallWndProc);
-    hook_CallWndProc = 0;
+    hook_CallWndProc = nullptr;
   }
   if (hook_CallWndProcRet) {
     UnhookWindowsHookEx(hook_CallWndProcRet);
-    hook_CallWndProcRet = 0;
+    hook_CallWndProcRet = nullptr;
   }
   if (hook_GetMessage) {
     UnhookWindowsHookEx(hook_GetMessage);
-    hook_GetMessage = 0;
+    hook_GetMessage = nullptr;
   }
   if (hook_DialogMessage) {
     UnhookWindowsHookEx(hook_DialogMessage);
-    hook_DialogMessage = 0;
+    hook_DialogMessage = nullptr;
   }
   hook_owner = 0;
   hook_target = 0;
@@ -376,8 +376,8 @@ BOOL WM_Hooks_Remove(DWORD owner) {
 // -=- User input hooks
 //
 
-HHOOK hook_keyboard SHARED = 0;
-HHOOK hook_pointer SHARED = 0;
+HHOOK hook_keyboard SHARED = nullptr;
+HHOOK hook_pointer SHARED = nullptr;
 bool enable_real_ptr SHARED = true;
 bool enable_synth_ptr SHARED = true;
 bool enable_real_kbd SHARED = true;
@@ -414,11 +414,11 @@ bool RefreshInputHooks() {
   bool set_kbd_hook = !enable_real_kbd || !enable_synth_kbd;
   if (hook_keyboard && !set_kbd_hook) {
     UnhookWindowsHookEx(hook_keyboard);
-    hook_keyboard = 0;
+    hook_keyboard = nullptr;
   }
   if (hook_pointer && !set_ptr_hook) {
     UnhookWindowsHookEx(hook_pointer);
-    hook_pointer = 0;
+    hook_pointer = nullptr;
   }
   if (!hook_keyboard && set_kbd_hook) {
     hook_keyboard = SetWindowsHookEx(WH_KEYBOARD_LL, HookKeyboardHook, dll_instance, 0);