/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. * Copyright 2004-2005 Cendio AB. * Copyright 2017 Peter Astrand for Cendio AB * * 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 #include #include #include #include #include #define LOCK_CONFIG os::AutoMutex a(mutex) #include #include using namespace rfb; 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() { if (!global_) global_ = new Configuration("Global"); return global_; } Configuration* Configuration::server() { if (!server_) server_ = new Configuration("Server"); return server_; } Configuration* Configuration::viewer() { if (!viewer_) viewer_ = new Configuration("Viewer"); return viewer_; } // -=- Configuration implementation bool Configuration::set(const char* n, const char* v, bool immutable) { return set(n, strlen(n), v, immutable); } bool Configuration::set(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); if (b && immutable) current->setImmutable(); return b; } current = current->_next; } return _next ? _next->set(name, len, val, immutable) : false; } bool Configuration::set(const char* config, bool immutable) { bool hyphen = false; if (config[0] == '-') { hyphen = true; config++; if (config[0] == '-') config++; // allow gnu-style --