00001 // -*- C++ -*- 00002 // Global header for the consmgr package... 00003 // 00004 // ***** BEGIN LICENSE BLOCK ***** 00005 // Version: MPL 1.1/GPL 2.0/LGPL 2.1 00006 // 00007 // The contents of this file are subject to the Mozilla Public License 00008 // Version 1.1 (the "License"); you may not use this file except in 00009 // compliance with the License. You may obtain a copy of the License at 00010 // http://www.mozilla.org/MPL/ 00011 // 00012 // Software distributed under the License is distributed on an "AS IS" 00013 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00014 // the License for the specific language governing rights and limitations 00015 // under the License. 00016 // 00017 // The Original Code is the consmgr network/serial-line monitoring package. 00018 // 00019 // The Initial Developer of the Original Code is Chris P. Ross. 00020 // Portions created by the Initial Developer are Copyright (C) 2000-2008 00021 // the Initial Developer. All Rights Reserved. 00022 // 00023 // Contributor(s): 00024 // 00025 // Alternatively, the contents of this file may be used under the terms of 00026 // either the GNU General Public License Version 2 or later (the "GPL"), or 00027 // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00028 // in which case the provisions of the GPL or the LGPL are applicable instead 00029 // of those above. If you wish to allow use of your version of this file only 00030 // under the terms of either the GPL or the LGPL, and not to allow others to 00031 // use your version of this file under the terms of the MPL, indicate your 00032 // decision by deleting the provisions above and replace them with the notice 00033 // and other provisions required by the GPL or the LGPL. If you do not delete 00034 // the provisions above, a recipient may use your version of this file under 00035 // the terms of any one of the MPL, the GPL or the LGPL. 00036 // 00037 // ***** END LICENSE BLOCK ***** 00038 00039 00050 #ifndef _CONSMGR_H 00051 #define _CONSMGR_H 00052 00053 #include "archdeps.h" 00054 00055 extern "C" { 00056 /* This is a threaded application, so we'll assume all of it's parts need */ 00057 /* pthread.h... */ 00058 #include <pthread.h> 00059 #include <err.h> 00060 #include <errno.h> 00061 #include <string.h> 00062 } 00063 00064 #include <iostream> 00065 #include <vector> 00066 00067 #include "cmconfig.h" // Only needed for the build_addr() prototype. 00068 #include "exceptions.h" 00069 00070 #if 1 // Only needed because of wait_for_signals(), which should be moved 00071 class Outlet; 00072 #endif 00073 00074 // Prototypes for functions 00075 struct sockaddr *build_addr(Config&); // misc.cc 00076 #ifdef NO_SA_LEN 00077 // Build a length for OSes that don't have _len members of the 00078 // sockaddr structs. Determine the length based on the ss_family 00079 // of the argument. 00080 socklen_t build_addrlen(const struct sockaddr*); 00081 #endif 00082 void mutex_info(std::ostream&,pthread_mutex_t*); 00083 00084 00085 00086 // These items from the std namespace are used in most of the 00087 // common code. Just reference them here... 00088 using std::cerr; 00089 using std::clog; 00090 using std::endl; 00091 00092 // Configuration. This should perhaps be elsewhere..... 00093 00094 // History saved in memory in the daemons. How many lines worth? 00095 #define HISTORY 50 00096 00097 // Debugging crap 00098 //#define EXTRA_MUTEX_STATE_LOGGING 1 00099 00100 00101 #if EXTRA_MUTEX_STATE_LOGGING 00102 # define MUTEX_LOG(foo) clog<<"XX-MT-XX("<<pthread_self()<<"): "<<foo<<endl 00103 # define AMUTEX_LOG(foo) clog<<"XX-A_MT-XX("<<pthread_self()<<"): "<<foo<<endl 00104 # define DMUTEX_LOG(foo) clog<<"XX-D_MT-XX("<<pthread_self()<<"): "<<foo<<endl 00105 #else 00106 # define MUTEX_LOG(foo) 00107 # define AMUTEX_LOG(foo) 00108 # define DMUTEX_LOG(foo) 00109 #endif 00110 00111 00112 #endif /* _CONSMGR_H */