Commit ec9c2ef0 authored by Claes Sjofors's avatar Claes Sjofors

Template for upgrade program remade

parent 7229c04b
include $(pwre_dir_symbols)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(hw_name)/$(type_name)_generic.mk
ifeq ($($(type_name)_generic_mk),)
-include $(pwre_kroot)/tools/bld/src/$(os_name)/$(type_name)_generic.mk
endif
ifeq ($($(type_name)_generic_mk),)
include $(pwre_kroot)/tools/bld/src/$(type_name)_generic.mk
endif
ifndef link_rule_mk
link_rule_mk := 1
link = $(ldxx) $(elinkflags) $(domap) -o $(export_exe) \
$(export_obj) $(objects) $(wb_msg_eobjs) $(rt_msg_eobjs) \
$(pwr_eobj)/rt_io_user.o $(pwr_obj)/wb_provider.o \
-L/usr/local/BerkeleyDB.4.0/lib \
-lpwr_wb -lpwr_rt -lpwr_ge -lpwr_flow -lpwr_glow -lpwr_co \
-lpwr_msg_dummy -lantlr \
-lrpcsvc -lpthread -lm -lrt -ldb_cxx -lz $(linkmysql)
endif
...@@ -29,140 +29,102 @@ ...@@ -29,140 +29,102 @@
BaseClasses-Drive */ BaseClasses-Drive */
#include <stdlib.h> #include <stdlib.h>
#include <iostream>
#include "pwr.h" #include "pwr.h"
#include "pwr_class.h" #include "pwr_class.h"
#include "wb_ldh.h" #include "wb_env.h"
#include "wb_foe.h" #include "wb_volume.h"
#include "wb_trv.h" #include "wb_session.h"
#include "wb_foe_macros.h" #include "wb_object.h"
#include "wb_foe_msg.h"
#include "pwr_baseclasses.h" #include "pwr_baseclasses.h"
#define CHECK_STS \ static void usage()
if ( EVEN(sts)) \ {
{ \ printf( "\nUsage: wb_upgrade -v 'volumename'\n\n");
error_msg( sts); \ }
exit(sts); \
}
static int set_object_mask( static void process( wb_session& session, wb_object& o)
pwr_tObjid Objdid,
ldh_tSesContext ldhses,
unsigned long dum0,
unsigned long dum1,
unsigned long dum2,
unsigned long dum3);
static int set_mask(
ldh_tSesContext ldhses,
pwr_tClassId classid);
static int doc_count = 0;
static int set_object_mask(
pwr_tObjid Objdid,
ldh_tSesContext ldhses,
unsigned long dum0,
unsigned long dum1,
unsigned long dum2,
unsigned long dum3)
{ {
pwr_sPlcNode *nodebuffer; pwr_sPlcNode plcnode;
int sts, size;
pwr_eClass class;
sts = ldh_GetObjectBuffer( ldhses, Objdid, "DevBody", if ( o.cid() == pwr_cClass_csub) {
"PlcNode", &class, (char **)&nodebuffer, &size); printf ( "Object: %s\n", o.longName().c_str());
if( EVEN(sts)) return sts;
sts = ldh_SetObjectPar( ldhses, wb_attribute a = session.attribute( o.oid(), "DevBody", "PlcNode");
Objdid, "DevBody", "DocumentOrientation", if ( !a) exit(0);
(char *)&nodebuffer->mask[1], 4);
if( EVEN(sts)) return sts;
sts = ldh_SetObjectPar( ldhses, a.value( &plcnode);
Objdid, "DevBody", "DocumentSize",
(char *)&nodebuffer->mask[0], 4);
if( EVEN(sts)) return sts;
XtFree( (char *)nodebuffer); printf( "subwindow: %d, woid: %u,%u\n", plcnode.subwindow,
plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);
doc_count++; wb_object c = o.first();
return FOE__SUCCESS; if ( c && c.cid() == pwr_cClass_windowplc) {
} plcnode.subwind_oid[0].vid = c.oid().vid;
plcnode.subwind_oid[0].oix = c.oid().oix;
static int set_mask( printf( "subwindow: %d, woid: %u,%u\n", plcnode.subwindow,
ldh_tSesContext ldhses, plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);
pwr_tClassId classid)
{
int sts;
pwr_tClassId class[2] = {0,0};
doc_count = 0;
class[0] = classid;
/* Get all objects */ session.writeAttribute( a, &plcnode, sizeof(plcnode));
sts = trv_get_objects_hier_class_name( ldhses, pwr_cNObjid, class, 0, if ( !a) cout << "** Write error" << endl;
&set_object_mask, ldhses, 0, 0, 0, 0); }
if ( EVEN(sts)) return sts; }
printf( "-- %d Document objects converted\n", doc_count); for ( wb_object c = o.first(); c.oddSts(); c = c.after()) {
return FOE__SUCCESS; process( session, c);
}
} }
int main() int main( int argc, char *argv[])
{ {
ldh_tWBContext wbctx; pwr_tObjName volume;
ldh_tSesContext ldhses;
int sts; for ( int i = 1; i < argc; i++) {
pwr_tVolumeId volid; if ( argv[i][0] == '-') {
ldh_tVolContext volctx; switch ( argv[i][1]) {
char name[80]; case 'h':
pwr_tClassId class; usage();
int size; exit(0);
case 'v':
/* Open session */ if ( i+1 >= argc) {
sts = ldh_OpenWB( &wbctx, 0, 0); usage();
CHECK_STS; exit(0);
}
sts = ldh_GetVolumeList( wbctx, &volid); strncpy( volume, argv[i+1], sizeof(volume));
while ( ODD(sts) ) i++;
{ break;
sts = ldh_GetVolumeClass( wbctx, volid, &class); default:
if (EVEN(sts)) return sts; printf("Unknown argument: %s\n", argv[i]);
usage();
sts = ldh_VolumeIdToName( wbctx, volid, name, sizeof(name), exit(0);
&size); }
CHECK_STS; }
printf("-- Processing volume %s\n", name); }
if ( class == pwr_eClass_RootVolume) wb_env env;
{ env.load( volume);
sts = ldh_AttachVolume( wbctx, volid, &volctx);
CHECK_STS; wb_volume vol;
for ( vol = env.volume(); vol.oddSts(); vol.next()) {
sts = ldh_OpenSession( &ldhses, volctx, if ( vol.cid() == pwr_eClass_RootVolume ||
ldh_eAccess_ReadWrite, ldh_eUtility_Pwr); vol.cid() == pwr_eClass_SubVolume ||
CHECK_STS; vol.cid() == pwr_eClass_SharedVolume) {
break;
sts = set_mask( ldhses, pwr_cClass_Document); }
CHECK_STS; }
sts = set_mask( ldhses, pwr_cClass_DocUser1); if ( vol.evenSts()) exit( vol.sts());
CHECK_STS;
sts = set_mask( ldhses, pwr_cClass_DocUser2); wb_session session(vol);
CHECK_STS; if ( ! session.access( ldh_eAccess_ReadWrite)) {
cout << "** No write access" << endl;
sts = ldh_SaveSession( ldhses); exit(0);
CHECK_STS; }
sts = ldh_CloseSession( ldhses); wb_object o;
CHECK_STS; for ( o = session.object(); o.oddSts(); o = o.after()) {
process( session, o);
sts = ldh_DetachVolume( wbctx, volctx); }
CHECK_STS; session.commit();
}
sts = ldh_GetNextVolume( wbctx, volid, &volid);
}
return 0;
} }
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