/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * * This is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ // -=- VNC Server 4.0 for Windows (WinVNC4) #include #include #include #include #include #include #include #include #include #include using namespace winvnc; using namespace rfb; using namespace win32; static LogWriter vlog("main"); TStr rfb::win32::AppName("KasmVNC Server"); extern bool runAsService; static bool runServer = true; static bool close_console = false; // // -=- processParams // Read in the command-line parameters and interpret them. // static void programInfo() { win32::FileVersionInfo inf; _tprintf(_T("%s - %s, Version %s\n"), inf.getVerString(_T("ProductName")), inf.getVerString(_T("FileDescription")), inf.getVerString(_T("FileVersion"))); printf("%s\n", buildTime); _tprintf(_T("%s\n\n"), inf.getVerString(_T("LegalCopyright"))); } static void programUsage() { printf("Command-line options:\n"); printf(" -connect [] - Connect an existing WinVNC server to a listening viewer.\n"); printf(" -disconnect - Disconnect all clients from an existing WinVNC server.\n"); printf(" -register - Register WinVNC server as a system service.\n"); printf(" -unregister - Remove WinVNC server from the list of system services.\n"); printf(" -start - Start the WinVNC server system service.\n"); printf(" -stop - Stop the WinVNC server system service.\n"); printf(" -status - Query the WinVNC service status.\n"); printf(" -help - Provide usage information.\n"); printf(" -noconsole - Run without a console (i.e. no stderr/stdout)\n"); printf(" = - Set the named configuration parameter.\n"); printf(" (Parameter values specified on the command-line override those specified by other configuration methods.)\n"); printf("\nLog names:\n"); LogWriter::listLogWriters(); printf("\nLog destinations:\n"); Logger::listLoggers(); printf("\nAvailable configuration parameters:\n"); Configuration::listParams(79, 14); } static void MsgBoxOrLog(const char* msg, bool isError=false) { if (close_console) { MsgBox(0, TStr(msg), (isError ? MB_ICONERROR : MB_ICONINFORMATION) | MB_OK); } else { if (isError) { try { vlog.error("%s", msg); return; } catch (...) { } } fprintf(stderr, "%s\n", msg); } } static void processParams(int argc, char** argv) { for (int i=1; i=, or - if (Configuration::setParam(argv[i], true)) continue; // Try to process -