Commit caf01d55 authored by claes's avatar claes

ExternVolume implemented

parent bc8a5393
! pwrb_c_ExternVolumeConfig.wb_load -- Defines the class ExternVolumeConfig.
!
! PROVIEW/R
! Copyright (C) 1996 by Comator Process AB.
!
! <Description>.
!
SObject pwrb:Class
!/**
! @Group ProjectConfiguration
!*/
Object ExternVolumeConfig $ClassDef 427
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr Flags |= pwr_mClassDef_TopObject
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
Attr StructName = "ExternVolumeConfig"
EndBody
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object DevProvider $Attribute 2
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
Object RtProvider $Attribute 3
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
EndObject
Object NavigatorPosnn $Menu
Object Pointed $Menu
Object OpenDb $MenuButton
Body SysBody
Attr ButtonName = "Open Volume..."
Attr MethodName = "ExternVolumeConfig-OpenDb"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPoson $Menu
Object Pointed $Menu
Object OpenDb $MenuButton
Body SysBody
Attr ButtonName = "Open Volume..."
Attr MethodName = "ExternVolumeConfig-OpenDb"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosos $Menu
Object Pointed $Menu
Object OpenDb $MenuButton
Body SysBody
Attr ButtonName = "Open Volume..."
Attr MethodName = "ExternVolumeConfig-OpenDb"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosms $Menu
Object Pointed $Menu
Object OpenDb $MenuButton
Body SysBody
Attr ButtonName = "Open Volume..."
Attr MethodName = "ExternVolumeConfig-OpenDb"
EndBody
EndObject
EndObject
EndObject
Object NavigatorPosmn $Menu
Object Pointed $Menu
Object OpenDb $MenuButton
Body SysBody
Attr ButtonName = "Open Volume..."
Attr MethodName = "ExternVolumeConfig-OpenDb"
EndBody
EndObject
EndObject
EndObject
EndObject
EndSObject
! pwrs_c_externvolume.wb_load -- Defines the class ExternVolume.
!
! PROVIEW/R
! Copyright (C) 1996 by Comator Process AB.
!
SObject pwrs:Class
!/**
! @Group Volumes
! Volume to store paste buffers in development environment.
!*/
Object $ExternVolume $ClassDef pwr_eCix_ExternVolume
Body SysBody
Attr Flags |= pwr_mClassDef_System
Attr Flags |= pwr_mClassDef_DevOnly
Attr Flags |= pwr_mClassDef_TopObject
EndBody
Object SysBody $ObjBodyDef 1
Body SysBody
Attr StructName = "ExternVolume"
EndBody
Object Description $Attribute 1
Body SysBody
Attr TypeRef = "pwrs:Type-$String80"
EndBody
EndObject
EndObject
EndObject
EndSObject
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "wb_vrepdbs.h" #include "wb_vrepdbs.h"
#include "wb_vrepdb.h" #include "wb_vrepdb.h"
#include "wb_vrepref.h" #include "wb_vrepref.h"
#include "wb_vrepext.h"
#include "wb_cdrep.h" #include "wb_cdrep.h"
#include "wb_orep.h" #include "wb_orep.h"
#include "wb_tdrep.h" #include "wb_tdrep.h"
...@@ -199,6 +200,15 @@ wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid) ...@@ -199,6 +200,15 @@ wb_vrep *wb_erep::nextVolume(pwr_tStatus *sts, pwr_tVid vid)
return it->second; return it->second;
} }
else { else {
// Next volume in extern
for ( it = m_vrepextern.begin();
it != m_vrepextern.end();
it++) {
if ( it->second->cid() == pwr_eClass_ExternVolume) {
*sts = LDH__SUCCESS;
return it->second;
}
}
*sts = LDH__NOSUCHVOL; *sts = LDH__NOSUCHVOL;
return 0; return 0;
} }
...@@ -508,7 +518,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -508,7 +518,7 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
} }
while ( fpm.getline( line, sizeof(line))) { while ( fpm.getline( line, sizeof(line))) {
char vol_array[5][80]; char vol_array[7][80];
int nr; int nr;
if ( line[0] == '#') if ( line[0] == '#')
...@@ -517,13 +527,33 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -517,13 +527,33 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
nr = dcli_parse( line, " ", "", (char *)vol_array, nr = dcli_parse( line, " ", "", (char *)vol_array,
sizeof(vol_array)/sizeof(vol_array[0]), sizeof(vol_array)/sizeof(vol_array[0]),
sizeof(vol_array[0]), 0); sizeof(vol_array[0]), 0);
if ( nr != 4) if ( nr > 6)
cout << "Syntax error in file: " << fname << endl; cout << "Syntax error in file: " << fname << endl;
cdh_StringToVolumeId( vol_array[1], &vid); cdh_StringToVolumeId( vol_array[1], &vid);
if ( (cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0) || if ( cdh_NoCaseStrcmp( vol_array[2], "ExternVolume") == 0) {
if ( nr != 6)
cout << "Syntax error in file: " << fname << endl;
// Load extern volume for this volume
cdh_ToLower( vol_array[0], vol_array[0]);
try {
wb_vrepext *vrepext = new wb_vrepext( this, vid, vol_array[0], vol_array[4]);
addExtern( &sts, vrepext);
MsgWindow::message( 'I', "Volume loaded", vname);
vol_cnt++;
}
catch ( wb_error& e) {
MsgWindow::message( 'E', "Unable to open volume", vname, e.what().c_str());
}
}
else if ( (cdh_NoCaseStrcmp( vol_array[2], "ClassVolume") == 0) ||
(strcmp( vol_array[3], "load") == 0)) { (strcmp( vol_array[3], "load") == 0)) {
if ( nr != 4)
cout << "Syntax error in file: " << fname << endl;
// Load dbs for this volume // Load dbs for this volume
cdh_ToLower( vol_array[0], vol_array[0]); cdh_ToLower( vol_array[0], vol_array[0]);
...@@ -575,6 +605,9 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db) ...@@ -575,6 +605,9 @@ void wb_erep::loadMeta( pwr_tStatus *status, char *db)
// Load db for this volume // Load db for this volume
char uname[80]; char uname[80];
if ( nr != 4)
cout << "Syntax error in file: " << fname << endl;
if ( db) { if ( db) {
// If db is specified, load only specified db, load as dbs instead // If db is specified, load only specified db, load as dbs instead
if ( cdh_NoCaseStrcmp( vol_array[0], db) != 0) { if ( cdh_NoCaseStrcmp( vol_array[0], db) != 0) {
......
...@@ -75,7 +75,8 @@ typedef enum { ...@@ -75,7 +75,8 @@ typedef enum {
ldh_eVolRep_Dbs, ldh_eVolRep_Dbs,
ldh_eVolRep_Wbl, ldh_eVolRep_Wbl,
ldh_eVolRep_Mem, ldh_eVolRep_Mem,
ldh_eVolRep_Ref ldh_eVolRep_Ref,
ldh_eVolRep_Ext
} ldh_eVolRep; } ldh_eVolRep;
typedef enum { typedef enum {
......
#include "wb_orepext.h"
wb_orepext::wb_orepext( wb_vrepext *v, ext_object& n): m_vrep(v), m_extobject(n)
{}
wb_orepext::~wb_orepext()
{
}
//
// Operations declared in wb_Orep
//
pwr_tOid wb_orepext::oid() const
{
return m_extobject.m_oid;
}
pwr_tVid wb_orepext::vid() const
{
return m_extobject.m_oid.vid;
}
pwr_tOix wb_orepext::oix() const
{
return m_extobject.m_oid.oix;
}
pwr_tOix wb_orepext::cid() const
{
return m_extobject.m_cid;
}
pwr_tOid wb_orepext::poid() const
{
return m_extobject.fthoid;
}
pwr_tOid wb_orepext::foid() const
{
return m_extobject.fchoid;
}
pwr_tOid wb_orepext::loid() const
{
return m_extobject.lchoid;
}
pwr_tOid wb_orepext::boid() const
{
return m_extobject.bwsoid;
}
pwr_tOid wb_orepext::aoid() const
{
return m_extobject.fwsoid;
}
const char *wb_orepext::name() const
{
return m_extobject.name();
}
wb_name wb_orepext::longName()
{
return wb_name( m_extobject.longname());
}
pwr_tTime wb_orepext::ohTime() const
{
pwr_tTime t = {0,0};
return t;
}
pwr_mClassDef wb_orepext::flags() const
{
return m_extobject.m_flags;
}
bool wb_orepext::isOffspringOf(const wb_orep *o) const
{
return true;
}
wb_orep *wb_orepext::ancestor(pwr_tStatus *sts)
{
return m_vrep->ancestor(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::parent(pwr_tStatus *sts)
{
return m_vrep->parent(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::after(pwr_tStatus *sts)
{
return m_vrep->after(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::before(pwr_tStatus *sts)
{
return m_vrep->before(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::first(pwr_tStatus *sts)
{
return m_vrep->first(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::child(pwr_tStatus *sts, wb_name &name)
{
return m_vrep->child(sts, (wb_orep *)this, name);
}
wb_orep *wb_orepext::last(pwr_tStatus *sts)
{
return m_vrep->last(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::next(pwr_tStatus *sts)
{
return m_vrep->next(sts, (wb_orep *)this);
}
wb_orep *wb_orepext::previous(pwr_tStatus *sts)
{
return m_vrep->previous(sts, (wb_orep *)this);
}
wb_adrep *wb_orepext::attribute(pwr_tStatus*, const char *aname)
{
return 0;
}
wb_adrep *wb_orepext::attribute(pwr_tStatus*)
{
return 0;
}
#ifndef wb_orepext_h
#define wb_orepext_h
#include "wb_orep.h"
#include "wb_vrepext.h"
#include "pwr.h"
class wb_orepext : public wb_orep
{
wb_vrepext *m_vrep;
unsigned int m_refCount;
ext_object m_extobject;
public:
wb_orepext(int oix);
wb_orepext( wb_vrepext *v, ext_object& n);
~wb_orepext();
// void* operator new(size_t size, wb_vrepext *v);
// void operator delete(void *p, size_t size, wb_vrepext *v);
virtual pwr_tOid oid() const;
virtual pwr_tVid vid() const;
virtual pwr_tOix oix() const;
virtual pwr_tCid cid() const;
virtual pwr_tOid poid() const;
virtual pwr_tOid foid() const;
virtual pwr_tOid loid() const;
virtual pwr_tOid boid() const;
virtual pwr_tOid aoid() const;
virtual const char * name() const;
virtual wb_name longName();
virtual pwr_tTime ohTime() const;
virtual pwr_mClassDef flags() const;
virtual bool isOffspringOf(const wb_orep *o) const;
// Navigational operations
wb_orep *ancestor(pwr_tStatus *sts); //< get object at top of hierarchy
wb_orep *parent(pwr_tStatus *sts);
wb_orep *after(pwr_tStatus *sts); //< get next sibling
wb_orep *before(pwr_tStatus *sts); //< get previous sibling
wb_orep *first(pwr_tStatus *sts); //< get first child
wb_orep *child(pwr_tStatus *sts, wb_name &name); //< get named child
wb_orep *last(pwr_tStatus *sts); //< get last child
wb_orep *next(pwr_tStatus *sts); //< get next in list of objects of same class in one volume
wb_orep *previous(pwr_tStatus *sts); //< get previous in list of objects of same class in one volume
virtual wb_adrep *attribute(pwr_tStatus*, const char *name);
virtual wb_adrep *attribute(pwr_tStatus*);
wb_erep *erep() const { return m_vrep->erep();}
wb_vrep *vrep() const { return m_vrep;}
virtual bool docBlock( char **block, int *size) const { return false;}
virtual bool docBlock( char *block) { return false;}
};
#endif
...@@ -3161,6 +3161,9 @@ pwr_tStatus utl_show_volumes( ...@@ -3161,6 +3161,9 @@ pwr_tStatus utl_show_volumes(
case ldh_eVolRep_Ref: case ldh_eVolRep_Ref:
u_print( utlctx, " Ref"); u_print( utlctx, " Ref");
break; break;
case ldh_eVolRep_Ext:
u_print( utlctx, " Ext");
break;
} }
u_print( utlctx, " %s", class_name); u_print( utlctx, " %s", class_name);
u_posit( utlctx, 2, strlen(class_name) + 2); u_posit( utlctx, 2, strlen(class_name) + 2);
......
#ifndef wb_vext_h
#define wb_vext_h
typedef enum {
vext_eMsgType_Object,
vext_eMsgType_ObjectOid,
vext_eMsgType_ObjectName,
vext_eMsgType_ObjectBody
} vext_eMsgType;
// Question message types
typedef struct {
unsigned long message_type;
vext_eMsgType Type;
} vext_sQMsgAny;
typedef struct {
unsigned long message_type;
vext_eMsgType Type;
pwr_tOix Oix;
} vext_sQMsgOid;
typedef struct {
unsigned long message_type;
vext_eMsgType Type;
char Name[120];
} vext_sQMsgObjectName;
typedef union {
vext_sQMsgAny Any;
vext_sQMsgOid Oid;
vext_sQMsgObjectName ObjectName;
} vext_sQMsg;
// Answer message types
typedef struct {
unsigned long message_type;
vext_eMsgType Type;
pwr_tStatus Status;
} vext_sAMsgAny;
typedef struct {
unsigned long message_type;
vext_eMsgType Type;
pwr_tStatus Status;
pwr_tOix oix;
pwr_tOix fthoix;
pwr_tOix bwsoix;
pwr_tOix fwsoix;
pwr_tOix fchoix;
pwr_tOix lchoix;
pwr_tCid cid;
char name[32];
char longname[120];
} vext_sAMsgObject;
typedef struct {
unsigned long message_type;
vext_eMsgType Type;
pwr_tStatus Status;
pwr_tOix oix;
int size;
char body[500];
} vext_sAMsgObjectBody;
typedef union {
vext_sAMsgAny Any;
vext_sAMsgObject Object;
vext_sAMsgObjectBody ObjectBody;
} vext_sAMsg;
#endif
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <fcntl.h>
#include "wb_vrepext.h"
#include "wb_orepext.h"
#include "wb_vext.h"
#include "wb_ldh_msg.h"
#include "wb_dbs.h"
#include "wb_bdrep.h"
#include "wb_cdrep.h"
#include "wb_attribute.h"
#include "wb_erep.h"
#include "wb_merep.h"
#include "wb_tdrep.h"
#include "wb_ldh_msg.h"
#include "wb_vrepwbl.h"
#include "wb_vrepref.h"
#include "wb_print_wbl.h"
#include "wb_volume.h"
#include "pwr_baseclasses.h"
extern "C" {
#include "co_dcli.h"
}
wb_vrepext::wb_vrepext( wb_erep *erep, pwr_tVid vid) :
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), m_connected(0)
{
strcpy( m_provider, "");
m_vid = vid;
m_cid = pwr_eClass_ExternVolume;
createVolumeObject("");
}
wb_vrepext::wb_vrepext( wb_erep *erep, pwr_tVid vid, char *name, char *provider) :
wb_vrep(vid), m_erep(erep), m_merep(erep->merep()), m_connected(0)
{
strcpy( m_provider, provider);
m_vid = vid;
m_cid = pwr_eClass_ExternVolume;
createVolumeObject( name);
strcpy( m_name, name);
}
wb_vrepext::~wb_vrepext()
{
}
wb_orep *wb_vrepext::object(pwr_tStatus *sts, pwr_tOid oid)
{
if ( oid.vid != m_vid) {
*sts = LDH__BADOBJID;
return 0;
}
if ( oid.oix == 0) {
// Volume object
*sts = LDH__SUCCESS;
return new wb_orepext( this, volume_object);
}
// Look in cache
if ( m_cashe.m_oid.oix == oid.oix) {
wb_orepext *orep = new wb_orepext( this, m_cashe);
return orep;
}
vext_sQMsg qmsg;
vext_sAMsg amsg;
qmsg.Oid.Type = vext_eMsgType_ObjectOid;
qmsg.Oid.Oix = oid.oix;
put( &qmsg, sizeof(qmsg), sts);
if ( EVEN(*sts)) return 0;
receive( &amsg, sizeof(amsg), sts);
if ( EVEN(*sts)) return 0;
if ( ODD( amsg.Object.Status)) {
*sts = LDH__SUCCESS;
ext_object exto( &amsg.Object, m_vid);
m_cashe = exto;
wb_orepext *orep = new wb_orepext( this, exto);
return orep;
}
else {
*sts = amsg.Object.Status;
return 0;
}
}
wb_orep *wb_vrepext::object(pwr_tStatus *sts, pwr_tCid cid)
{
*sts = LDH__NOSUCHOBJ;
return 0;
}
wb_orep *wb_vrepext::object(pwr_tStatus *sts, wb_name &name)
{
if ( name.hasVolume() && !name.hasObject()) {
// Volume object
*sts = LDH__SUCCESS;
return new wb_orepext( this, volume_object);
}
vext_sQMsg qmsg;
vext_sAMsg amsg;
qmsg.ObjectName.Type = vext_eMsgType_ObjectName;
strcpy( qmsg.ObjectName.Name, name.name(cdh_mName_path | cdh_mName_object));
put( &qmsg, sizeof(qmsg), sts);
if ( EVEN(*sts)) return 0;
receive( &amsg, sizeof(amsg), sts);
if ( EVEN(*sts)) return 0;
if ( ODD( amsg.Object.Status)) {
*sts = LDH__SUCCESS;
ext_object exto( &amsg.Object, m_vid);
wb_orepext *orep = new wb_orepext( this, exto);
return orep;
}
else {
*sts = amsg.Object.Status;
return 0;
}
}
wb_vrep *wb_vrepext::next()
{
pwr_tStatus sts;
return m_erep->nextVolume( &sts, vid());
}
void wb_vrepext::info()
{
cout << "Volume : " << volume_name << " " << volume_class << " " << m_vid << endl;
}
void wb_vrepext::unref()
{
if (--m_nRef == 0)
delete this;
}
wb_vrep *wb_vrepext::ref()
{
m_nRef++;
return this;
}
wb_orep *wb_vrepext::object(pwr_tStatus *sts)
{
vext_sQMsg qmsg;
vext_sAMsg amsg;
qmsg.Any.Type = vext_eMsgType_Object;
put( &qmsg, sizeof(qmsg), sts);
if ( EVEN(*sts)) return 0;
receive( &amsg, sizeof(amsg), sts);
if ( EVEN(*sts)) return 0;
if ( ODD( amsg.Object.Status)) {
*sts = LDH__SUCCESS;
ext_object exto( &amsg.Object, m_vid);
wb_orepext *orep = new wb_orepext( this, exto);
return orep;
}
else {
*sts = amsg.Object.Status;
return 0;
}
}
wb_orep *wb_vrepext::ancestor(pwr_tStatus *sts, const wb_orep *o)
{
wb_orepext *orep = 0;
*sts = LDH__NOSUCHOBJ;
return orep;
}
wb_orep *wb_vrepext::parent(pwr_tStatus *sts, const wb_orep *o)
{
if ( o->poid().oix == 0) {
*sts = LDH__NOSUCHOBJ;
return 0;
}
return object( sts, o->poid());
}
wb_orep *wb_vrepext::after(pwr_tStatus *sts, const wb_orep *o)
{
if ( o->aoid().oix == 0) {
*sts = LDH__NO_SIBLING;
return 0;
}
return object( sts, o->aoid());
}
wb_orep *wb_vrepext::before(pwr_tStatus *sts, const wb_orep *o)
{
if ( o->boid().oix == 0) {
*sts = LDH__NO_SIBLING;
return 0;
}
return object( sts, o->boid());
}
wb_orep *wb_vrepext::first(pwr_tStatus *sts, const wb_orep *o)
{
if ( o->foid().oix == 0) {
*sts = LDH__NO_CHILD;
return 0;
}
return object( sts, o->foid());
}
wb_orep *wb_vrepext::child(pwr_tStatus *sts, const wb_orep *o, wb_name &name)
{
wb_orepext *orep = 0;
*sts = LDH__NO_CHILD;
return orep;
}
wb_orep *wb_vrepext::last(pwr_tStatus *sts, const wb_orep *o)
{
if ( o->loid().oix == 0) {
*sts = LDH__NO_CHILD;
return 0;
}
return object( sts, o->loid());
}
wb_orep *wb_vrepext::next(pwr_tStatus *sts, const wb_orep *o)
{
*sts = LDH__NOSUCHOBJ;
return 0;
}
wb_orep *wb_vrepext::previous(pwr_tStatus *sts, const wb_orep *o)
{
return 0;
}
void wb_vrepext::objectName(const wb_orep *o, char *str)
{
*str = 0;
}
bool wb_vrepext::writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p)
{
*sts = LDH__SUCCESS;
return false;
}
void *wb_vrepext::readAttribute(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p)
{
void *body = readBody( sts, o, bix, 0);
if ( EVEN(*sts))
return 0;
if ( p) {
memcpy( p, (char *)body + offset, size);
return p;
}
return (void *)((char *)body + offset);
}
bool wb_vrepext::writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p)
{
*sts = LDH__NOSUCHBODY;
return false;
}
void *wb_vrepext::readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, void *p)
{
vext_sQMsg qmsg;
static vext_sAMsg amsg;
if ( bix != pwr_eBix_rt) {
*sts = LDH__NOSUCHBODY;
return 0;
}
qmsg.Oid.Type = vext_eMsgType_ObjectBody;
qmsg.Oid.Oix = o->oid().oix;
put( &qmsg, sizeof(qmsg), sts);
if ( EVEN(*sts)) return 0;
receive( &amsg, sizeof(amsg), sts);
if ( EVEN(*sts)) return 0;
if ( ODD( amsg.ObjectBody.Status)) {
*sts = LDH__SUCCESS;
if ( p) {
memcpy( p, &amsg.ObjectBody.body, amsg.ObjectBody.size);
return p;
}
return &amsg.ObjectBody.body;
}
*sts = LDH__NOSUCHBODY;
return 0;
}
wb_orep *wb_vrepext::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name)
{
return 0;
}
bool wb_vrepext::createVolumeObject( char *name)
{
pwr_tStatus sts;
wb_cdrep *cdrep = m_merep->cdrep( &sts, m_cid);
wb_cdef cdef = wb_cdef( cdrep);
ext_object exto;
strcpy( exto.m_name, name);
exto.m_oid.vid = m_vid;
exto.m_oid.oix = 0;
exto.m_cid = m_cid;
exto.m_flags = cdef.flags();
exto.rbody_size = cdef.size( pwr_eBix_rt);
if ( exto.rbody_size) {
exto.rbody = malloc( exto.rbody_size);
cdef.templateBody( &sts, pwr_eBix_rt, exto.rbody, exto.m_oid);
if ( EVEN(sts)) return false;
}
exto.dbody_size = cdef.size( pwr_eBix_dev);
if ( exto.dbody_size) {
exto.dbody = malloc( exto.dbody_size);
cdef.templateBody( &sts, pwr_eBix_dev, exto.dbody, exto.m_oid);
if ( EVEN(sts)) return false;
}
volume_object = exto;
strcpy( volume_name, name);
return true;
}
wb_orep *wb_vrepext::copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name)
{
return 0;
}
bool wb_vrepext::moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d)
{
return true;
}
bool wb_vrepext::deleteObject(pwr_tStatus *sts, wb_orep *orep)
{
return true;
}
bool wb_vrepext::deleteFamily(pwr_tStatus *sts, wb_orep *orep)
{
return true;
}
bool wb_vrepext::renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name)
{
*sts = LDH__SUCCESS;
return true;
}
bool wb_vrepext::commit(pwr_tStatus *sts)
{
return true;
}
bool wb_vrepext::abort(pwr_tStatus *sts)
{
return true;
}
void wb_vrepext::put( vext_sQMsg *msg, int size, pwr_tStatus *sts)
{
if ( !m_connected) {
vext_sAMsg amsg;
int fd = -1;
key_t key;
fd = open( m_provider, O_RDWR | O_CREAT, 0777);
if ( fd < 0) {
*sts = LDH__NOPROV;
return;
}
close( fd);
key = ftok( m_provider, 0);
m_msgsndid = msgget( key, 0666 | IPC_CREAT);
if ( m_msgsndid == -1) {
*sts = LDH__MSGGET;
return;
}
m_msgrcvid = msgget( (key_t)(key + 1), 0666 | IPC_CREAT);
if ( m_msgrcvid == -1) {
*sts = LDH__MSGGET;
return;
}
// Clear the receive que
while( msgrcv( m_msgrcvid, (void *) &amsg, sizeof(amsg), 0, IPC_NOWAIT) != -1) ;
m_connected = 1;
}
msg->Any.message_type = 1;
if ( msgsnd( m_msgsndid, (void *)msg, size, 0) == -1) {
*sts = LDH__MSGSND;
return;
}
*sts = LDH__SUCCESS;
}
void wb_vrepext::receive( vext_sAMsg *msg, int size, pwr_tStatus *sts)
{
if ( msgrcv( m_msgrcvid, (void *)msg, size, 0, 0) == -1) {
*sts = LDH__MSGRCV;
return;
}
*sts = LDH__SUCCESS;
}
#ifndef wb_vrepext_h
#define wb_vrepext_h
#include <string>
#include "wb_vrep.h"
#include "wb_erep.h"
#include "wb_attrname.h"
#include "wb_treeimport.h"
#include "co_dbs.h"
#include "wb_import.h"
#include "wb_vext.h"
class wb_vrepext;
class ext_object
{
friend class wb_vrepext;
public:
ext_object() : rbody_size(0), dbody_size(0), rbody(0), dbody(0),
m_cid(0), m_tid(0), fthoid(pwr_cNOid), bwsoid(pwr_cNOid), fwsoid(pwr_cNOid),
fchoid(pwr_cNOid), lchoid(pwr_cNOid)
{
strcpy( m_name, "");
strcpy( m_longname, "");
strcpy( cname, "");
m_flags.m = 0;
m_oid.oix = 0;
m_oid.vid = 0;
}
ext_object( vext_sAMsgObject *msg, pwr_tVid vid) : rbody_size(0), dbody_size(0), rbody(0), dbody(0)
{
strcpy( m_name, msg->name);
strcpy( m_longname, msg->longname);
m_oid.oix = msg->oix;
m_oid.vid = vid;
fthoid.oix = msg->fthoix;
fthoid.vid = vid;
bwsoid.oix = msg->bwsoix;
bwsoid.vid = vid;
fwsoid.oix = msg->fwsoix;
fwsoid.vid = vid;
fchoid.oix = msg->fchoix;
fchoid.vid = vid;
lchoid.oix = msg->lchoix;
lchoid.vid = vid;
m_cid = msg->cid;
}
~ext_object() {
if ( rbody_size) free( rbody);
if ( dbody_size) free( dbody);
}
const char *name() const { return m_name; }
const char *longname() const { return m_longname; }
bool exportHead(wb_import &i) { return false;}
bool exportDbody(wb_import &i) { return false;}
bool exportRbody(wb_import &i) { return false;}
bool exportDocBlock(wb_import &i) { return false;}
bool exportTree( wb_treeimport &i, bool isRoot) { return false;}
bool exportPaste( wb_treeimport &i, pwr_tOid destination, bool isRoot,
ldh_eDest destcode, bool keepoid, pwr_tOid *rootlist) { return false;}
size_t rbody_size;
size_t dbody_size;
void *rbody;
void *dbody;
pwr_tCid m_cid;
pwr_tTid m_tid;
pwr_tOid m_oid;
char cname[32];
char m_name[32];
char m_longname[120];
pwr_mClassDef m_flags;
pwr_tOid fthoid;
pwr_tOid bwsoid;
pwr_tOid fwsoid;
pwr_tOid fchoid;
pwr_tOid lchoid;
pwr_tTime time;
};
class wb_orepext;
class wb_vrepext : public wb_vrep
{
wb_erep *m_erep;
wb_merep *m_merep;
unsigned int m_nRef;
ext_object volume_object;
char m_provider[200];
int m_connected;
int m_msgsndid;
int m_msgrcvid;
ext_object m_cashe;
map<pwr_tOix, ext_object *> m_oix_list;
typedef map<pwr_tOix, ext_object *>::iterator iterator_oix_list;
public:
wb_vrepext( wb_erep *erep) :
m_erep(erep), m_merep(erep->merep()), m_nRef(0) {}
wb_vrepext( wb_erep *erep, pwr_tVid vid);
wb_vrepext( wb_erep *erep, pwr_tVid vid, char *name, char *provider);
~wb_vrepext();
virtual ldh_eVolRep type() const { return ldh_eVolRep_Ext;}
pwr_tVid vid() const { return m_vid;}
pwr_tCid cid() const { return m_cid;}
wb_vrep *next();
virtual bool createSnapshot(const char *fileName) { return false;}
char volume_class[32];
char volume_name[32];
virtual void unref();
virtual wb_vrep *ref();
wb_erep *erep() {return m_erep;}
wb_merep *merep() const { return m_merep;}
int nextOix();
ext_object *findObject( pwr_tOix oix);
ext_object *find( const char *name);
int nameToOid( const char *name, pwr_tOid *oid);
bool registerObject( pwr_tOix oix, ext_object *node);
bool unregisterObject( pwr_tOix oix);
void registerVolume( const char *name, pwr_tCid cid, pwr_tVid vid, ext_object *node);
void info();
bool createVolumeObject( char *name);
virtual pwr_tOid oid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
virtual pwr_tVid vid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNVid;}
virtual pwr_tOix oix(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOix;}
virtual pwr_tCid cid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNCid;}
virtual pwr_tOid poid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
virtual pwr_tOid foid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
virtual pwr_tOid loid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
virtual pwr_tOid boid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
virtual pwr_tOid aoid(pwr_tStatus *sts, const wb_orep *o) { return pwr_cNOid;}
virtual const char * objectName(pwr_tStatus *sts, const wb_orep *o) { return "";}
virtual wb_name longName(pwr_tStatus *sts, const wb_orep *o) { return wb_name();}
virtual pwr_tTime ohTime(pwr_tStatus *sts, const wb_orep *o) { pwr_tTime t = {0, 0}; return t;}
virtual pwr_mClassDef flags(pwr_tStatus *sts, const wb_orep *o) { pwr_mClassDef f; f.m = 0; return f;}
virtual bool isOffspringOf(pwr_tStatus *sts, const wb_orep *child, const wb_orep *parent) { return false;}
wb_orep *object(pwr_tStatus *sts);
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
wb_orep *object(pwr_tStatus *sts, pwr_tCid cid);
wb_orep *object(pwr_tStatus *sts, wb_name &name);
wb_orep *object(pwr_tStatus *sts, const wb_orep *parent, wb_name &name) {return 0;}
wb_orep *createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination &d, wb_name &name);
wb_orep *copyObject(pwr_tStatus *sts, const wb_orep *orep, wb_destination &d, wb_name &name);
bool copyOset(pwr_tStatus *sts, wb_oset *oset, wb_destination &d) {return false;}
bool moveObject(pwr_tStatus *sts, wb_orep *orep, wb_destination &d);
bool deleteObject(pwr_tStatus *sts, wb_orep *orep);
bool deleteFamily(pwr_tStatus *sts, wb_orep *orep);
bool deleteOset(pwr_tStatus *sts, wb_oset *oset) {return false;}
bool renameObject(pwr_tStatus *sts, wb_orep *orep, wb_name &name);
bool commit(pwr_tStatus *sts);
bool abort(pwr_tStatus *sts);
virtual bool writeAttribute(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readAttribute(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, size_t offset, size_t size, void *p);
virtual void *readBody(pwr_tStatus *sts, const wb_orep *o, pwr_eBix bix, void *p);
virtual bool writeBody(pwr_tStatus *sts, wb_orep *o, pwr_eBix bix, void *p);
wb_orep *ancestor(pwr_tStatus *sts, const wb_orep *o);
wb_orep *parent(pwr_tStatus *sts, const wb_orep *o);
wb_orep *after(pwr_tStatus *sts, const wb_orep *o);
wb_orep *before(pwr_tStatus *sts, const wb_orep *o);
wb_orep *first(pwr_tStatus *sts, const wb_orep *o);
wb_orep *child(pwr_tStatus *sts, const wb_orep *o, wb_name &name);
wb_orep *last(pwr_tStatus *sts, const wb_orep *o);
wb_orep *next(pwr_tStatus *sts, const wb_orep *o);
wb_orep *previous(pwr_tStatus *sts, const wb_orep *o);
wb_srep *newSession() {return 0;}
bool isLocal(const wb_orep *o) {return o->oid().vid == vid();}
void objectName(const wb_orep *o, char *str);
virtual bool exportVolume(wb_import &i) { return false;}
virtual bool exportHead(wb_import &i) { return false;}
virtual bool exportRbody(wb_import &i) { return false;}
virtual bool exportDbody(wb_import &i) { return false;}
virtual bool exportDocBlock(wb_import &i) { return false;}
virtual bool exportMeta(wb_import &i) { return false;}
virtual bool exportTree(wb_treeimport &i, pwr_tOid oid) { return false;}
bool exportPaste(wb_treeimport &i, pwr_tOid destination, ldh_eDest destcode, bool keepoid,
pwr_tOid **rootlist) { return false;}
virtual bool importTree(bool keepref) { return false;}
virtual bool importTreeObject(wb_merep *merep, pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody)
{ return false;}
virtual bool importPaste() { return false;}
virtual bool importPasteObject(pwr_tOid destination, ldh_eDest destcode,
bool keepoid, pwr_tOid oid,
pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, const char *name, pwr_mClassDef flags,
size_t rbSize, size_t dbSize, void *rbody, void *dbody,
pwr_tOid *roid)
{ return false;}
virtual void importIgnoreErrors() {}
virtual bool accessSupported( ldh_eAccess access) { return true;}
virtual const char *fileName() { return "";}
virtual bool importVolume(wb_export &e) { return false;}
virtual bool importHead(pwr_tOid oid, pwr_tCid cid, pwr_tOid poid,
pwr_tOid boid, pwr_tOid aoid, pwr_tOid foid, pwr_tOid loid,
const char *name, const char *normname, pwr_mClassDef flags,
pwr_tTime ohTime, pwr_tTime rbTime, pwr_tTime dbTime,
size_t rbSize, size_t dbSize) { return false;}
virtual bool importRbody(pwr_tOid oid, size_t size, void *body) { return false;}
virtual bool importDbody(pwr_tOid oid, size_t size, void *body) { return false;}
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block) { return false;}
virtual bool importMeta(dbs_sMenv *mep) { return true;}
private:
void put( vext_sQMsg *msg, int size, pwr_tStatus *sts);
void receive( vext_sAMsg *msg, int size, pwr_tStatus *sts);
};
#endif
...@@ -575,6 +575,9 @@ pwr_tStatus WVsel::load_volumelist() ...@@ -575,6 +575,9 @@ pwr_tStatus WVsel::load_volumelist()
case ldh_eVolRep_Ref: case ldh_eVolRep_Ref:
strcat( str, "Ref "); strcat( str, "Ref ");
break; break;
case ldh_eVolRep_Ext:
strcat( str, "Ext ");
break;
} }
switch (classid) switch (classid)
...@@ -597,6 +600,9 @@ pwr_tStatus WVsel::load_volumelist() ...@@ -597,6 +600,9 @@ pwr_tStatus WVsel::load_volumelist()
case pwr_eClass_DirectoryVolume: case pwr_eClass_DirectoryVolume:
strcat( str, "DirectoryVolume"); strcat( str, "DirectoryVolume");
break; break;
case pwr_eClass_ExternVolume:
strcat( str, "ExternVolume");
break;
} }
cstr = XmStringCreateSimple( str); cstr = XmStringCreateSimple( str);
XmListAddItemUnselected( widgets.volumelist, cstr, 0); XmListAddItemUnselected( widgets.volumelist, cstr, 0);
......
...@@ -200,6 +200,8 @@ static wbl_sSym classes[] = ...@@ -200,6 +200,8 @@ static wbl_sSym classes[] =
,{ "pwr_eCix_DirectoryVolume", pwr_eCix_DirectoryVolume } ,{ "pwr_eCix_DirectoryVolume", pwr_eCix_DirectoryVolume }
,{ "pwr_eClass_VolatileVolume", pwr_eClass_VolatileVolume } ,{ "pwr_eClass_VolatileVolume", pwr_eClass_VolatileVolume }
,{ "pwr_eCix_VolatileVolume", pwr_eCix_VolatileVolume } ,{ "pwr_eCix_VolatileVolume", pwr_eCix_VolatileVolume }
,{ "pwr_eClass_ExternVolume", pwr_eClass_ExternVolume }
,{ "pwr_eCix_ExternVolume", pwr_eCix_ExternVolume }
,{ "pwr_eClass_CreateVolume", pwr_eClass_CreateVolume } ,{ "pwr_eClass_CreateVolume", pwr_eClass_CreateVolume }
,{ "pwr_eCix_CreateVolume", pwr_eCix_CreateVolume } ,{ "pwr_eCix_CreateVolume", pwr_eCix_CreateVolume }
,{ "pwr_eClass_MountVolume", pwr_eClass_MountVolume } ,{ "pwr_eClass_MountVolume", pwr_eClass_MountVolume }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment