/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved. * Copyright (C) 2004-2005 Cendio AB. 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. */ // -=- Configuration.cxx #include #include #include #include #ifdef WIN32 #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif #include #include #include #include #ifdef WIN32 // Under Win32, we use these routines from several threads, // so we must provide suitable locking. #include static rfb::Mutex configLock; #endif #include #include using namespace rfb; static LogWriter vlog("Config"); // -=- Configuration VoidParameter* Configuration::head = 0; bool Configuration::setParam(const char* n, const char* v, bool immutable) { return setParam(n, strlen(n), v, immutable); } bool Configuration::setParam(const char* name, int len, const char* val, bool immutable) { VoidParameter* current = head; while (current) { if ((int)strlen(current->getName()) == len && strncasecmp(current->getName(), name, len) == 0) { bool b = current->setParam(val); current->setHasBeenSet(); if (b && immutable) current->setImmutable(); return b; } current = current->_next; } return false; } bool Configuration::setParam(const char* config, bool immutable) { bool hyphen = false; if (config[0] == '-') { hyphen = true; config++; if (config[0] == '-') config++; // allow gnu-style --