00001 // -*- C++ -*- 00002 // cfg_getcap.h - This file defines a subclass of ConfigDB that uses 00003 // cgetcap() and friends to read configuration values out of a termcap- 00004 // style database. 00005 // 00006 // ***** BEGIN LICENSE BLOCK ***** 00007 // Version: MPL 1.1/GPL 2.0/LGPL 2.1 00008 // 00009 // The contents of this file are subject to the Mozilla Public License 00010 // Version 1.1 (the "License"); you may not use this file except in 00011 // compliance with the License. You may obtain a copy of the License at 00012 // http://www.mozilla.org/MPL/ 00013 // 00014 // Software distributed under the License is distributed on an "AS IS" 00015 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00016 // the License for the specific language governing rights and limitations 00017 // under the License. 00018 // 00019 // The Original Code is the consmgr network/serial-line monitoring package. 00020 // 00021 // The Initial Developer of the Original Code is Chris P. Ross. 00022 // Portions created by the Initial Developer are Copyright (C) 2000-2008 00023 // the Initial Developer. All Rights Reserved. 00024 // 00025 // Contributor(s): 00026 // 00027 // Alternatively, the contents of this file may be used under the terms of 00028 // either the GNU General Public License Version 2 or later (the "GPL"), or 00029 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00030 // in which case the provisions of the GPL or the LGPL are applicable instead 00031 // of those above. If you wish to allow use of your version of this file only 00032 // under the terms of either the GPL or the LGPL, and not to allow others to 00033 // use your version of this file under the terms of the MPL, indicate your 00034 // decision by deleting the provisions above and replace them with the notice 00035 // and other provisions required by the GPL or the LGPL. If you do not delete 00036 // the provisions above, a recipient may use your version of this file under 00037 // the terms of any one of the MPL, the GPL or the LGPL. 00038 // 00039 // ***** END LICENSE BLOCK ***** 00040 00041 #ifndef __CFG_GETCAP_H 00042 #define __CFG_GETCAP_H 00043 00044 extern "C" { 00045 #include <stdlib.h> 00046 #include <pthread.h> 00047 }; 00048 00049 #include <string> 00050 #include <fstream> 00051 #include <vector> 00052 00053 #include "cmconfig.h" 00054 00055 #ifdef HAVE_GETCAP 00056 00064 class Getcap : public Config { 00065 public: 00066 Getcap(const string &s); 00067 ~Getcap(void); 00068 00070 void load_entry(const string&); 00071 00072 private: 00073 std::string ent_name; 00074 char *capent; 00075 pthread_mutex_t capent_mtx; 00076 00077 // Routines to load and convert entries from the cached capent 00078 00080 int32_t num(const string&); 00082 std::string str(const string&); 00083 }; 00084 #endif /* HAVE_GETCAP */ 00085 00086 #endif /* __CFG_GETCAP_H */