Back to index

im-sdk  12.3.91
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes
IMSvrCfg Class Reference

#include <IMSvrCfg.hh>

Inheritance diagram for IMSvrCfg:
Inheritance graph
[legend]
Collaboration diagram for IMSvrCfg:
Collaboration graph
[legend]

List of all members.

Classes

struct  CfgVal
struct  CfgVal.v

Public Types

enum  IMSvrCfgOpt {
  IMDIR = 0, BASICLOCALE, IFPATHNAME, IFNAME,
  PORT, HOSTNAME, NSMAP_CFG_FILE, CONFIGFILE,
  LECONFFILE, CONVERSIONKEYS, LABEL, SETTRIGGEROFFKEYS,
  IMCONFIG, DIRECT_XSUNIM, LOG_FACILITY, LOG_LEVEL,
  MESSAGE_LOCALE, LOOKUPROW, LOOKUPCOL, NODAEMON,
  DEBUGFLAG, USER, VARDIR, DESKTOP,
  PREFERRED_LOADING, CFGOPT_LAST
}

Public Member Functions

bool get_boolval (enum IMSvrCfgOpt opt) const
int get_numval (enum IMSvrCfgOpt opt) const
const char * get_strval (enum IMSvrCfgOpt opt) const
void showall () const
const char * get_command_name ()
virtual bool configure (IMSvr *pimsvr)=0

Protected Types

enum  CfgType {
  ARG_UNINIT = 0, ARG_INVALID, ARG_BOOL, ARG_NUMBER,
  ARG_STRING
}

Protected Member Functions

enum CfgType get_type (enum IMSvrCfgOpt opt)
const string & get_description (enum IMSvrCfgOpt opt)
void setbool (enum IMSvrCfgOpt opt, bool boolval)
void setnum (enum IMSvrCfgOpt opt, int numval)
void setstr (enum IMSvrCfgOpt opt, const char *strval)
bool get_process_user (string &user)
bool get_home_dir (string &dir)
IMUserMgrget_usermgr (IMSvr *pimsvr)
bool config_lepath (IMSvr *pimsvr, const char *lepath)
bool config_listenaddress (IMSvr *pimsvr, IMSocketAddressVec &addrvec)
bool config_le (IMSvr *pimsvr, const char *lepath, IIIMLEXMLConf &xml, bool preferred_loading)
bool set_nsmap_config (IMSvr *pimsvr, IMNsMapStruct *nsm, int num_entries)
 IMSvrCfg (const IMSvrCfg &base)
 IMSvrCfg (string cmdname)
virtual ~IMSvrCfg ()

Private Member Functions

void initbool (enum IMSvrCfgOpt opt, const char *desc, bool boolval)
void initnum (enum IMSvrCfgOpt opt, const char *desc, int boolval)
void initstr (enum IMSvrCfgOpt opt, const char *desc, const char *strval)
void initialize ()

Private Attributes

const IMSvrCfgpbase
CfgValpopts
string command_name

Detailed Description

Definition at line 10 of file IMSvrCfg.hh.


Class Documentation

struct IMSvrCfg::CfgVal

Definition at line 55 of file IMSvrCfg.hh.

Collaboration diagram for IMSvrCfg::CfgVal:
Class Members
enum IMSvrCfgOpt string
description struct CfgVal
v
struct IMSvrCfg::CfgVal.v

Definition at line 58 of file IMSvrCfg.hh.

Class Members
bool b
int n
string s

Member Enumeration Documentation

enum IMSvrCfg::CfgType [protected]
Enumerator:
ARG_UNINIT 
ARG_INVALID 
ARG_BOOL 
ARG_NUMBER 
ARG_STRING 

Definition at line 46 of file IMSvrCfg.hh.

Enumerator:
IMDIR 
BASICLOCALE 
IFPATHNAME 
IFNAME 
PORT 
HOSTNAME 
NSMAP_CFG_FILE 
CONFIGFILE 
LECONFFILE 
CONVERSIONKEYS 
LABEL 
SETTRIGGEROFFKEYS 
IMCONFIG 
DIRECT_XSUNIM 
LOG_FACILITY 
LOG_LEVEL 
MESSAGE_LOCALE 
LOOKUPROW 
LOOKUPCOL 
NODAEMON 
DEBUGFLAG 
USER 
VARDIR 
DESKTOP 
PREFERRED_LOADING 
CFGOPT_LAST 

Definition at line 13 of file IMSvrCfg.hh.


Constructor & Destructor Documentation

IMSvrCfg::IMSvrCfg ( const IMSvrCfg base) [protected]

Definition at line 289 of file IMSvrCfg.cpp.

{
    command_name = base.command_name;
    popts = base.popts;
    pbase = &base;
}
IMSvrCfg::IMSvrCfg ( string  cmdname) [protected]

Definition at line 298 of file IMSvrCfg.cpp.

{
    command_name = cmdname;
    popts = new CfgVal[CFGOPT_LAST];
    pbase = NULL;
    initialize();
}

Here is the call graph for this function:

IMSvrCfg::~IMSvrCfg ( ) [protected, virtual]

Definition at line 308 of file IMSvrCfg.cpp.

{
    if (!pbase) delete[] popts;
}

Member Function Documentation

bool IMSvrCfg::config_le ( IMSvr pimsvr,
const char *  lepath,
IIIMLEXMLConf &  xml,
bool  preferred_loading 
) [inline, protected]

Definition at line 120 of file IMSvrCfg.hh.

       { return pimsvr->config_le(lepath, xml, preferred_loading); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSvrCfg::config_lepath ( IMSvr pimsvr,
const char *  lepath 
) [inline, protected]

Definition at line 116 of file IMSvrCfg.hh.

    { return pimsvr->config_lepath(lepath); }

Here is the call graph for this function:

Here is the caller graph for this function:

bool IMSvrCfg::config_listenaddress ( IMSvr pimsvr,
IMSocketAddressVec addrvec 
) [inline, protected]

Definition at line 118 of file IMSvrCfg.hh.

    { return pimsvr->config_listenaddress(addrvec); }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool IMSvrCfg::configure ( IMSvr pimsvr) [pure virtual]

Implemented in IMSvrArg, and IMSvrXMLConf.

Here is the caller graph for this function:

bool IMSvrCfg::get_boolval ( enum IMSvrCfgOpt  opt) const

Definition at line 221 of file IMSvrCfg.cpp.

{
    if ((opt >= CFGOPT_LAST)
       || (popts[opt].type != ARG_BOOL)) {
       ERROR_INTERNAL("Invalid argument access.");
    }

    return popts[opt].v.b;
}

Here is the caller graph for this function:

const char* IMSvrCfg::get_command_name ( ) [inline]

Definition at line 138 of file IMSvrCfg.hh.

    { return command_name.c_str(); }

Here is the caller graph for this function:

const string& IMSvrCfg::get_description ( enum IMSvrCfgOpt  opt) [inline, protected]

Definition at line 71 of file IMSvrCfg.hh.

    { return popts[opt].description; }
bool IMSvrCfg::get_home_dir ( string &  dir) [protected]

Definition at line 18 of file IMSvrCfg.cpp.

{

#ifdef HAVE_PWENT
    struct passwd *pass;
#  if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
#ifndef NSS_BUFLEN_PASSWD
#define NSS_BUFLEN_PASSWD 1024
#endif
    struct passwd pass_buf;
    char buf[NSS_BUFLEN_PASSWD];

#    ifdef HAVE_POSIX_GETPWUID_R
    if (getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD, &pass) != 0) {
        return false;
    }
#else
    if ((pass = getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD))
       != NULL) {
        return false;
    }
#endif
#else /* !HAVE_GETPWUID_R || !HAVE_NONPOSIX_GETPWUID_R */
    if ((pass = getpwuid(geteuid())) == NULL) {
        return false;
    } 
#endif
    dir = string(pass->pw_dir);
    return true;
#else
    return false;
#endif
}

Here is the caller graph for this function:

int IMSvrCfg::get_numval ( enum IMSvrCfgOpt  opt) const

Definition at line 235 of file IMSvrCfg.cpp.

{
    if ((opt >= CFGOPT_LAST)
       || (popts[opt].type != ARG_NUMBER)) {
       ERROR_INTERNAL("Invalid argument access.");
    }

    return popts[opt].v.n;
}
bool IMSvrCfg::get_process_user ( string &  user) [protected]

Definition at line 54 of file IMSvrCfg.cpp.

{

#ifdef HAVE_PWENT
    struct passwd *pass;
#  if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
#ifndef NSS_BUFLEN_PASSWD
#define NSS_BUFLEN_PASSWD 1024
#endif
    struct passwd pass_buf;
    char buf[NSS_BUFLEN_PASSWD];

#    ifdef HAVE_POSIX_GETPWUID_R
    if (getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD, &pass) != 0) {
        return false;
    }
#else
    if ((pass = getpwuid_r(geteuid(), &pass_buf, buf, NSS_BUFLEN_PASSWD))
       != NULL) {
        return false;
    }
#endif
#else /* !HAVE_GETPWUID_R || !HAVE_NONPOSIX_GETPWUID_R */
    if ((pass = getpwuid(geteuid())) == NULL) {
        return false;
    } 
#endif
    username = string(pass->pw_name);
    return true;
#else
    return false;
#endif
}

Here is the caller graph for this function:

const char * IMSvrCfg::get_strval ( enum IMSvrCfgOpt  opt) const

Definition at line 249 of file IMSvrCfg.cpp.

{
    if ((opt >= CFGOPT_LAST)
       || (popts[opt].type != ARG_STRING)) {
       ERROR_INTERNAL("Invalid argument access.");
    }

    return popts[opt].v.s.c_str();
}

Here is the caller graph for this function:

enum CfgType IMSvrCfg::get_type ( enum IMSvrCfgOpt  opt) [inline, protected]

Definition at line 69 of file IMSvrCfg.hh.

    { return popts[opt].type; }

Here is the caller graph for this function:

IMUserMgr* IMSvrCfg::get_usermgr ( IMSvr pimsvr) [inline, protected]

Definition at line 114 of file IMSvrCfg.hh.

    { return &pimsvr->usermgr; }

Here is the caller graph for this function:

void IMSvrCfg::initbool ( enum IMSvrCfgOpt  opt,
const char *  desc,
bool  boolval 
) [private]

Definition at line 139 of file IMSvrCfg.cpp.

{
    popts[opt].opt = opt;
    popts[opt].type = ARG_BOOL;
    popts[opt].description = desc;
    popts[opt].v.b = boolval;
}

Here is the caller graph for this function:

void IMSvrCfg::initialize ( ) [private]

Reimplemented in IMSvrArg.

Definition at line 91 of file IMSvrCfg.cpp.

{
    initstr(IMDIR, "IM main directory.", IIIMLIBDIR);
    initstr(BASICLOCALE, "Locale used by default", "C");
#ifdef WIN32
    initstr(IFPATHNAME, "Language Engine module directory",
          "D:\\WINNT\\System32\\iiimf");
#else
    initstr(IFPATHNAME, "Language Engine module directory",
          IIIMLEDIR);
#endif
    initstr(IFNAME, "Language Engine name", "");
    initstr(PORT, "Port or service name", "9010");
    initstr(HOSTNAME, "host name", "localhost");
    initstr(NSMAP_CFG_FILE, "Config file for Namespace Mapping", XMLCONFDIR "/ns_map.cfg");
#ifdef WIN32
    initstr(CONFIGFILE, "Configuration file", "D:\\WINNT\\System32\\iiimd.xml.conf");
#else
    initstr(CONFIGFILE, "Configuration file", XMLCONFDIR "/iiimd.xml.conf");
#endif
#ifdef WIN32
    initstr(LECONFFILE, "LE-specific Configuration file", "D:\\WINNT\\System32\\le.xml.conf");
#else
    initstr(LECONFFILE, "LE-specific Configuration file", XMLCONFDIR "/le.xml.conf");
#endif
    initstr(CONVERSIONKEYS, "Conversion ON keys", "<Ctrl>space");
    initstr(LABEL, "Label type", "numeric");
    initbool(SETTRIGGEROFFKEYS, "set trigger off keys", false);
    // initstr(IMCONFIG, "/usr/lib/iiim/etc/im.config");
    // initbool(DIRECT_XSUNIM, true);
    initstr(LOG_FACILITY, "syslog facility", "USER");
    initstr(LOG_LEVEL, "log level", "NORMAL");
    initstr(MESSAGE_LOCALE, "message locale", "C");
    initnum(LOOKUPROW, "The number of lookup-choice rows.", 4);
    initnum(LOOKUPCOL, "The number of lookup-choice columns.", 4);
    initbool(NODAEMON, "Don't transit to daemon mode", false);
    initbool(USER, "behave as a per-user server", false);
    initbool(DEBUGFLAG, "debug mode", false);
    initstr(VARDIR, "IIIM volatile data directory", "");
#if defined(HAVE_UNIX_SOCKET)
    initstr(UDSFILE, "Use specified unix domain socket", "");
#endif /* HAVE_UNIX_SOCKET */
    initbool(DESKTOP, "exit if no desktop exists", false);
    initbool(PREFERRED_LOADING, "load LEs only you prefer", false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrCfg::initnum ( enum IMSvrCfgOpt  opt,
const char *  desc,
int  boolval 
) [private]

Definition at line 153 of file IMSvrCfg.cpp.

{
    popts[opt].opt = opt;
    popts[opt].type = ARG_NUMBER;
    popts[opt].description = desc;
    popts[opt].v.n = numval;
}

Here is the caller graph for this function:

void IMSvrCfg::initstr ( enum IMSvrCfgOpt  opt,
const char *  desc,
const char *  strval 
) [private]

Definition at line 167 of file IMSvrCfg.cpp.

{
    popts[opt].opt = opt;
    popts[opt].type = ARG_STRING;
    popts[opt].description = desc;
    popts[opt].v.s = strval;
}

Here is the caller graph for this function:

bool IMSvrCfg::set_nsmap_config ( IMSvr pimsvr,
IMNsMapStruct nsm,
int  num_entries 
) [inline, protected]

Definition at line 122 of file IMSvrCfg.hh.

    { return pimsvr->set_nsmap_config(nsm, num_entries); }

Here is the call graph for this function:

Here is the caller graph for this function:

void IMSvrCfg::setbool ( enum IMSvrCfgOpt  opt,
bool  boolval 
) [protected]

Definition at line 181 of file IMSvrCfg.cpp.

{
    if (popts[opt].type != ARG_BOOL) {
       ERROR_INTERNAL("Invalid argument access.");
    }
    popts[opt].v.b = boolval;
}

Here is the caller graph for this function:

void IMSvrCfg::setnum ( enum IMSvrCfgOpt  opt,
int  numval 
) [protected]

Definition at line 194 of file IMSvrCfg.cpp.

{
    if (popts[opt].type != ARG_NUMBER) {
       ERROR_INTERNAL("Invalid argument access.");
    }
    popts[opt].v.n = numval;
}

Here is the caller graph for this function:

void IMSvrCfg::setstr ( enum IMSvrCfgOpt  opt,
const char *  strval 
) [protected]

Definition at line 207 of file IMSvrCfg.cpp.

{
    if (popts[opt].type != ARG_STRING) {
       ERROR_INTERNAL("Invalid argument access.");
    }
    popts[opt].v.s = strval;
}

Here is the caller graph for this function:

void IMSvrCfg::showall ( ) const

Definition at line 262 of file IMSvrCfg.cpp.

{
    int i;
    for (i = 0; i < CFGOPT_LAST; i++) {
       switch(popts[i].type) {
         case ARG_BOOL:
          if (popts[i].v.b) {
              LOG_DEBUG("%s[%d]:true", popts[i].description.c_str(), (int)popts[i].opt);
          } else {
              LOG_DEBUG("%s[%d]:false", popts[i].description.c_str(), (int)popts[i].opt);
          }
          break;
         case ARG_NUMBER:
          LOG_DEBUG("%s[%d]:%d", popts[i].description.c_str(), (int)popts[i].opt, popts[i].v.n);
          break;
         case ARG_STRING:
          LOG_DEBUG("%s[%d]:%s", popts[i].description.c_str(), (int)popts[i].opt, popts[i].v.s.c_str());
          break;
         default:
          ERROR_INTERNAL("Invalid arg type.");
          break;
       }
    }

    return;
}

Member Data Documentation

string IMSvrCfg::command_name [private]

Definition at line 93 of file IMSvrCfg.hh.

const IMSvrCfg* IMSvrCfg::pbase [private]

Definition at line 65 of file IMSvrCfg.hh.

CfgVal* IMSvrCfg::popts [private]

Definition at line 66 of file IMSvrCfg.hh.


The documentation for this class was generated from the following files: