Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

FBwSvc.h

Go to the documentation of this file.
00001 
00007 //---------------------------------------------------------------------------
00008 
00009 #ifndef FBwSvcH
00010 #define FBwSvcH
00011 //---------------------------------------------------------------------------
00012 namespace fbwrap
00013 {
00014 
00015 // What are we using from standard libraries
00016 using std::string;
00017 
00019 
00024 class FBwSvcRequest : public FBwSPB
00025 {
00026 public:
00027     FBwSvcRequest(char ptype)
00028     {
00029         Add(ptype);
00030     }
00031 };
00032 
00034 
00038 class FBwAttachDPB : public FBwSPB
00039 {
00040 public:
00041     FBwAttachDPB(string UserName, string Password);
00042 };
00043 //
00044 //
00045 //---------------------------------------------------------------------------
00047 
00054 class FBwService
00055 {
00056     ISC_STATUS status[20];
00057     isc_svc_handle svchandle;
00058 protected:
00059     FBwServerDsc alias;
00060 public:
00061     FBwService()
00062     {
00063         svchandle=0;
00064     }
00065     FBwService(string pServ, string pUser, string pPass) : alias(pServ,pUser,pPass)
00066     {
00067         svchandle=0;
00068         Attach();
00069     }
00070     FBwService(const FBwServerDsc &ad) : alias(ad)
00071     {
00072         svchandle=0;
00073         Attach();
00074     }
00075     bool IsAttached() const
00076     {
00077         return svchandle != 0;
00078     }
00079     // Parameters Seting
00080     // don't like this it strengthens binding between
00081     // this class an FBwServerDsc
00082     void SetUser(string user)
00083     {
00084         alias.UserName = user;
00085     }
00086     void SetPass(string pass)
00087     {
00088         alias.Password = pass;
00089     }
00090     void SetServer(string serv)
00091     {
00092         alias.Server = serv;
00093     }
00095     void Attach();
00097     void Attach(const FBwServerDsc &ad)
00098     {
00099         alias = ad;
00100         Attach();
00101     }
00103     bool SvcRequest(FBwSvcRequest *rq);
00105     void Dettach();
00107     void GetLastError(BasicFBwErrorMgr *err) const;
00108     ~FBwService();
00109     isc_svc_handle *GetHandle()
00110     {
00111         return &svchandle;
00112     }
00113     ISC_STATUS *GetStatus()
00114     {
00115         return status;
00116     }
00117     void ShowMessage();
00118 };
00119 
00120 
00122 struct FBwUserSec
00123 {
00124     string UserName;
00125     string Password;
00126     string RoleName;
00127     string FirstName;
00128     string MiddleName;
00129     string LastName;
00130     int  uid;
00131     int  gid;
00132     FBwUserSec()
00133     {
00134         uid=gid=-1;
00135     }
00136     void Clear();
00137 };
00138 
00140 
00146 class FBwAddUser : public FBwSvcRequest
00147 {
00148 public:
00149     FBwAddUser(const FBwUserSec &usec,char pType = isc_action_svc_add_user)
00150         : FBwSvcRequest(pType)
00151     {
00152         AddParam(isc_spb_sec_username,usec.UserName);
00153         AddParam(isc_spb_sec_password,usec.Password);
00154         AddParam(isc_spb_sql_role_name,usec.RoleName);
00155         AddParam(isc_spb_sec_firstname,usec.FirstName);
00156         AddParam(isc_spb_sec_middlename,usec.MiddleName);
00157         AddParam(isc_spb_sec_lastname,usec.LastName);
00158         AddParam(isc_spb_sec_userid,usec.uid);
00159         AddParam(isc_spb_sec_groupid,usec.gid);
00160     }
00161 };
00163 
00169 class FBwModUser : public FBwAddUser
00170 {
00171 public:
00172     FBwModUser(const FBwUserSec &msec):
00173         FBwAddUser(msec,isc_action_svc_modify_user)
00174     {
00175     }
00176 };
00177 
00178 class FBwQueryTimeout : public FBwSPB
00179 {
00180 public:
00181     FBwQueryTimeout(int timeout=60)
00182     {
00183         AddParam(isc_info_svc_timeout,timeout);
00184     }
00185 };
00186 
00188 
00193 class FBwSvcCluster
00194 {
00195     const char *reqbuf;
00196     unsigned short reqlen;
00197     int bufCap;
00198     FBwService *svc;
00199     void GrowBuf();
00200     int timeout;
00201     char *infoBuf;
00202 protected:
00203     virtual void ParseBuf(const char *p)=0;
00204     void SetReqBuf(const char *preqbuf, unsigned short preqlen)
00205     {
00206         reqbuf=preqbuf;
00207         reqlen=preqlen;
00208     }
00209     void SetTimeOut(int pTimeout)
00210     {
00211         timeout=pTimeout;
00212     }
00213     // status fields
00214     bool error;
00215     bool truncated;
00216 public:
00217     FBwSvcCluster(FBwService *psvc, int bufLen=1024, int ptimeout=70);
00218     bool GetInfo(); 
00219     bool Error()
00220     {
00221         return error;
00222     }
00223     void ReadInteger(const char **p, unsigned long &v);
00224     void ReadShort(const char **p, unsigned short &v);
00225     void ReadString(const char **p, string &s);
00226     virtual ~FBwSvcCluster()
00227     {
00228         if( infoBuf )
00229             delete[] infoBuf;
00230     }
00231 };
00232 
00233 // Diferent info query objects
00234 
00235 class SrvInfoGenConfig: public FBwSvcCluster
00236 {
00237     virtual void ParseBuf(const char *p);
00238 public:
00239     SrvInfoGenConfig(FBwService *psvc, int bufLen=1024, int ptimeout=70);
00240     // Data obtained
00241     unsigned long ServiceMgrVersion;
00242     string ServerVersion;
00243     string ServerImplementation;
00244     string ServerEnvironment;
00245     string LockFile;
00246     string MessageFile;
00247     string UserDbPath;
00248 };
00249 
00250 class InfoServerConfig: public FBwSvcCluster
00251 {
00252     virtual void ParseBuf(const char *p);
00253 public:
00254     InfoServerConfig(FBwService *psvc, int bufLen=256, int ptimeout=70);
00255     unsigned long ConfValues[22];
00256     string ConfNames(int idx);
00257 };
00258 
00259 class InfoUserSec: public FBwSvcCluster
00260 {
00261     virtual void ParseBuf(const char *p);
00262     int numUsers;
00263     int ReadUser(const char *p);
00264     FBwUserSec usec;
00265     const char *ustart;
00266 public:
00267     InfoUserSec(FBwService *psvc, int bufLen=1024, int ptimeout=70);
00268     bool FindUser(int idx);
00269     const FBwUserSec *GetUser()
00270     {
00271         return &usec;
00272     }
00273     int GetNumUsers()
00274     {
00275         return numUsers;
00276     }
00277     virtual ~InfoUserSec()
00278     {}
00279 };
00280 class FBwSvcQuery
00281 {
00282     FBwService *svc;
00283     char *lineBuf;
00284     unsigned short bufLen;
00285     bool error;
00286     bool eof;
00287 public:
00288     FBwSvcQuery(FBwService *psvc, unsigned short pbufLen=128);
00289     bool RequestInfo();
00290     char *GetNextLine();
00291     bool Eof()
00292     {
00293         return eof;
00294     }
00295     bool Error()
00296     {
00297         return error;
00298     }
00299 };
00300 // namespace fbwrap end
00301 };
00302 #endif

Generated on Fri Jan 31 08:30:02 2003 for fbwrap by doxygen1.2.17