Back to index

im-sdk  12.3.91
IMSvrCfg.hh
Go to the documentation of this file.
00001 #ifndef IMSVRCFG_HH_
00002 #define IMSVRCFG_HH_
00003 #include <string>
00004 #include "basictype.hh"
00005 #include "IMSvr.hh"
00006 #include "IMUtil.hh"
00007 #include "lexmlconf.h"
00008 #include "SunIM.h"
00009 
00010 class IMSvrCfg
00011 {
00012   public:
00013     enum IMSvrCfgOpt {
00014            IMDIR = 0,
00015            BASICLOCALE,
00016            IFPATHNAME,
00017            IFNAME,
00018            PORT,
00019            HOSTNAME,
00020            NSMAP_CFG_FILE,
00021            CONFIGFILE,
00022            LECONFFILE,
00023            CONVERSIONKEYS,
00024            LABEL,
00025            SETTRIGGEROFFKEYS,
00026            IMCONFIG,
00027            DIRECT_XSUNIM,
00028            LOG_FACILITY,
00029            LOG_LEVEL,
00030            MESSAGE_LOCALE,
00031            LOOKUPROW,
00032            LOOKUPCOL,
00033            NODAEMON,
00034            DEBUGFLAG,
00035            USER,
00036            VARDIR,
00037 #if defined(HAVE_UNIX_SOCKET)
00038            UDSFILE,
00039 #endif /* HAVE_UNIX_SOCKET */
00040            DESKTOP,
00041            PREFERRED_LOADING,
00042            CFGOPT_LAST
00043     };
00044 
00045   protected:
00046     enum CfgType {
00047            ARG_UNINIT = 0,
00048            ARG_INVALID,
00049            ARG_BOOL,
00050            ARG_NUMBER,
00051            ARG_STRING
00052     };
00053 
00054   private:
00055     struct CfgVal {
00056        enum IMSvrCfgOpt opt;
00057        string description;
00058        struct {
00059            bool b;
00060            int n;
00061            string s;
00062        } v;
00063        enum CfgType type;
00064     };
00065     const IMSvrCfg *pbase;
00066     CfgVal *popts;
00067 
00068   protected:
00069     enum CfgType get_type(enum IMSvrCfgOpt opt)
00070     { return popts[opt].type; }
00071     const string& get_description(enum IMSvrCfgOpt opt)
00072     { return popts[opt].description; }
00073     void setbool(
00074        enum IMSvrCfgOpt opt,
00075        bool boolval
00076     );
00077     void setnum(
00078        enum IMSvrCfgOpt opt,
00079        int numval
00080     );
00081     void setstr(
00082        enum IMSvrCfgOpt opt,
00083        const char* strval
00084     );
00085     bool get_process_user(
00086         string &user
00087     );
00088     bool get_home_dir(
00089         string &dir
00090     );
00091 
00092   private:
00093     string command_name;
00094 
00095     void initbool(
00096        enum IMSvrCfgOpt opt,
00097        const char* desc,
00098        bool boolval
00099     );
00100     void initnum(
00101        enum IMSvrCfgOpt opt,
00102        const char* desc,
00103        int boolval
00104     );
00105     void initstr(
00106        enum IMSvrCfgOpt opt,
00107        const char* desc,
00108        const char* strval
00109     );
00110     void initialize();
00111 
00112   protected:
00113     /* methods for manipulating IMSvr. */
00114     IMUserMgr* get_usermgr(IMSvr *pimsvr)
00115     { return &pimsvr->usermgr; }
00116     bool config_lepath(IMSvr *pimsvr, const char* lepath)
00117     { return pimsvr->config_lepath(lepath); }
00118     bool config_listenaddress(IMSvr *pimsvr, IMSocketAddressVec &addrvec)
00119     { return pimsvr->config_listenaddress(addrvec); }
00120     bool config_le(IMSvr *pimsvr, const char* lepath, IIIMLEXMLConf &xml, bool preferred_loading)
00121        { return pimsvr->config_le(lepath, xml, preferred_loading); }
00122     bool set_nsmap_config(IMSvr *pimsvr, IMNsMapStruct *nsm, int num_entries)
00123     { return pimsvr->set_nsmap_config(nsm, num_entries); }
00124 
00125   public:
00126 
00127     bool get_boolval(
00128        enum IMSvrCfgOpt opt
00129     ) const;
00130     int get_numval(
00131        enum IMSvrCfgOpt opt
00132     ) const;
00133     const char* get_strval(
00134        enum IMSvrCfgOpt opt
00135     ) const;
00136     void showall() const;
00137 
00138     const char* get_command_name()
00139     { return command_name.c_str(); }
00140 
00141     virtual bool configure(
00142        IMSvr *pimsvr
00143     ) = 0;
00144 
00145   protected:
00146     IMSvrCfg(
00147        const IMSvrCfg& base
00148     );
00149     IMSvrCfg(
00150        string cmdname
00151     );
00152     virtual ~IMSvrCfg();
00153 };
00154 
00155 #endif /* not IMSVRCFG_HH_ */
00156 
00157 /* Local Variables: */
00158 /* c-file-style: "iiim-project" */
00159 /* End: */