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 @@
BaseClasses-Drive */
#include <stdlib.h>
#include <iostream>
#include "pwr.h"
#include "pwr_class.h"
#include "wb_ldh.h"
#include "wb_foe.h"
#include "wb_trv.h"
#include "wb_foe_macros.h"
#include "wb_foe_msg.h"
#include "wb_env.h"
#include "wb_volume.h"
#include "wb_session.h"
#include "wb_object.h"
#include "pwr_baseclasses.h"
#define CHECK_STS \
if ( EVEN(sts)) \
{ \
error_msg( sts); \
exit(sts); \
}
static void usage()
{
printf( "\nUsage: wb_upgrade -v 'volumename'\n\n");
}
static int set_object_mask(
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)
static void process( wb_session& session, wb_object& o)
{
pwr_sPlcNode *nodebuffer;
int sts, size;
pwr_eClass class;
pwr_sPlcNode plcnode;
sts = ldh_GetObjectBuffer( ldhses, Objdid, "DevBody",
"PlcNode", &class, (char **)&nodebuffer, &size);
if( EVEN(sts)) return sts;
if ( o.cid() == pwr_cClass_csub) {
printf ( "Object: %s\n", o.longName().c_str());
sts = ldh_SetObjectPar( ldhses,
Objdid, "DevBody", "DocumentOrientation",
(char *)&nodebuffer->mask[1], 4);
if( EVEN(sts)) return sts;
wb_attribute a = session.attribute( o.oid(), "DevBody", "PlcNode");
if ( !a) exit(0);
sts = ldh_SetObjectPar( ldhses,
Objdid, "DevBody", "DocumentSize",
(char *)&nodebuffer->mask[0], 4);
if( EVEN(sts)) return sts;
a.value( &plcnode);
XtFree( (char *)nodebuffer);
printf( "subwindow: %d, woid: %u,%u\n", plcnode.subwindow,
plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);
doc_count++;
return FOE__SUCCESS;
}
wb_object c = o.first();
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(
ldh_tSesContext ldhses,
pwr_tClassId classid)
{
int sts;
pwr_tClassId class[2] = {0,0};
doc_count = 0;
class[0] = classid;
printf( "subwindow: %d, woid: %u,%u\n", plcnode.subwindow,
plcnode.subwind_oid[0].vid, plcnode.subwind_oid[0].oix);
/* Get all objects */
sts = trv_get_objects_hier_class_name( ldhses, pwr_cNObjid, class, 0,
&set_object_mask, ldhses, 0, 0, 0, 0);
if ( EVEN(sts)) return sts;
session.writeAttribute( a, &plcnode, sizeof(plcnode));
if ( !a) cout << "** Write error" << endl;
}
}
printf( "-- %d Document objects converted\n", doc_count);
return FOE__SUCCESS;
for ( wb_object c = o.first(); c.oddSts(); c = c.after()) {
process( session, c);
}
}
int main()
int main( int argc, char *argv[])
{
ldh_tWBContext wbctx;
ldh_tSesContext ldhses;
int sts;
pwr_tVolumeId volid;
ldh_tVolContext volctx;
char name[80];
pwr_tClassId class;
int size;
/* Open session */
sts = ldh_OpenWB( &wbctx, 0, 0);
CHECK_STS;
sts = ldh_GetVolumeList( wbctx, &volid);
while ( ODD(sts) )
{
sts = ldh_GetVolumeClass( wbctx, volid, &class);
if (EVEN(sts)) return sts;
sts = ldh_VolumeIdToName( wbctx, volid, name, sizeof(name),
&size);
CHECK_STS;
printf("-- Processing volume %s\n", name);
if ( class == pwr_eClass_RootVolume)
{
sts = ldh_AttachVolume( wbctx, volid, &volctx);
CHECK_STS;
sts = ldh_OpenSession( &ldhses, volctx,
ldh_eAccess_ReadWrite, ldh_eUtility_Pwr);
CHECK_STS;
sts = set_mask( ldhses, pwr_cClass_Document);
CHECK_STS;
sts = set_mask( ldhses, pwr_cClass_DocUser1);
CHECK_STS;
sts = set_mask( ldhses, pwr_cClass_DocUser2);
CHECK_STS;
sts = ldh_SaveSession( ldhses);
CHECK_STS;
sts = ldh_CloseSession( ldhses);
CHECK_STS;
sts = ldh_DetachVolume( wbctx, volctx);
CHECK_STS;
}
sts = ldh_GetNextVolume( wbctx, volid, &volid);
}
return 0;
pwr_tObjName volume;
for ( int i = 1; i < argc; i++) {
if ( argv[i][0] == '-') {
switch ( argv[i][1]) {
case 'h':
usage();
exit(0);
case 'v':
if ( i+1 >= argc) {
usage();
exit(0);
}
strncpy( volume, argv[i+1], sizeof(volume));
i++;
break;
default:
printf("Unknown argument: %s\n", argv[i]);
usage();
exit(0);
}
}
}
wb_env env;
env.load( volume);
wb_volume vol;
for ( vol = env.volume(); vol.oddSts(); vol.next()) {
if ( vol.cid() == pwr_eClass_RootVolume ||
vol.cid() == pwr_eClass_SubVolume ||
vol.cid() == pwr_eClass_SharedVolume) {
break;
}
}
if ( vol.evenSts()) exit( vol.sts());
wb_session session(vol);
if ( ! session.access( ldh_eAccess_ReadWrite)) {
cout << "** No write access" << endl;
exit(0);
}
wb_object o;
for ( o = session.object(); o.oddSts(); o = o.after()) {
process( session, o);
}
session.commit();
}
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