Commit af180afc authored by claes's avatar claes

Classvolumes inserted first in volume_cnf file

parent 0acfe6bf
/* /*
* Proview $Id: wb_lfu.cpp,v 1.3 2006-05-05 11:32:28 claes Exp $ * Proview $Id: wb_lfu.cpp,v 1.4 2006-05-24 06:00:59 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB. * Copyright (C) 2005 SSAB Oxelsund AB.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -695,72 +695,73 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -695,72 +695,73 @@ pwr_tStatus lfu_SaveDirectoryVolume(
} }
/* Check that the configured volumes exist */ /* Check that the configured volumes exist */
sts = ldh_GetRootList( ldhses, &envobjid); for ( int k = 0; k < 2; k++) {
while ( ODD(sts)) // Check class volumes in the first round, and other volumes after
{
sts = ldh_GetObjectClass( ldhses, envobjid, &cid);
if ( EVEN(sts)) return sts;
if ( cid == pwr_cClass_WbEnvironment) for ( sts = ldh_GetRootList( ldhses, &envobjid);
{ ODD(sts);
/* Create directory list file */ sts = ldh_GetNextSibling( ldhses, envobjid, &envobjid)) {
sts = ldh_ObjidToName( ldhses, envobjid, ldh_eName_Object,
name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody", sts = ldh_GetObjectClass( ldhses, envobjid, &cid);
"Path", (char **) &path_ptr, &size);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
dcli_translate_filename( filename, load_cNameFilePath); if ( cid == pwr_cClass_WbEnvironment) {
if ( k != 1)
continue;
fpath = fopen( filename, "w"); /* Create directory list file */
if ( !fpath) { sts = ldh_ObjidToName( ldhses, envobjid, ldh_eName_Object,
printf( "** Unable to open path file %s\n", filename); name, sizeof(name), &size);
syntax_error = 1; if ( EVEN(sts)) return sts;
free( (char *)path_ptr);
return LFU__NOFILE; sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody",
} "Path", (char **) &path_ptr, &size);
if ( EVEN(sts)) return sts;
dcli_translate_filename( filename, load_cNameFilePath);
path_file_created = 1; fpath = fopen( filename, "w");
if ( !fpath) {
printf( "** Unable to open path file %s\n", filename);
syntax_error = 1;
free( (char *)path_ptr);
return LFU__NOFILE;
}
for ( i = 0; i < 20; i++) { path_file_created = 1;
dcli_trim( path, path_ptr[i]);
if ( strcmp( path, "") != 0)
fprintf( fpath, "%s\n", path);
}
fclose( fpath);
free( (char *)path_ptr);
// Get xxxVolumeLoad objects for ( i = 0; i < 20; i++) {
sts = ldh_GetChild( ldhses, envobjid, &volobjid); dcli_trim( path, path_ptr[i]);
while ( ODD(sts)) if ( strcmp( path, "") != 0)
{ fprintf( fpath, "%s\n", path);
sts = ldh_GetObjectClass( ldhses, volobjid, &cid); }
if ( EVEN(sts)) return sts; fclose( fpath);
free( (char *)path_ptr);
if ( cid == pwr_cClass_RootVolumeLoad || // Get xxxVolumeLoad objects
cid == pwr_cClass_SubVolumeLoad || sts = ldh_GetChild( ldhses, envobjid, &volobjid);
cid == pwr_cClass_ClassVolumeLoad || while ( ODD(sts)) {
cid == pwr_cClass_SharedVolumeLoad ) sts = ldh_GetObjectClass( ldhses, volobjid, &cid);
{ if ( EVEN(sts)) return sts;
sts = ldh_ObjidToName( ldhses, volobjid, ldh_eName_Object,
volume_name, sizeof(volume_name), &size);
if ( EVEN(sts)) return sts;
utl_toupper( name, volume_name);
/* Check that the name is in the global volume list */ if ( cid == pwr_cClass_RootVolumeLoad ||
found = 0; cid == pwr_cClass_SubVolumeLoad ||
volumelist_ptr = volumelist; cid == pwr_cClass_ClassVolumeLoad ||
for ( i = 0; i < volumecount; i++) cid == pwr_cClass_SharedVolumeLoad ) {
{ sts = ldh_ObjidToName( ldhses, volobjid, ldh_eName_Object,
utl_toupper( volname, volumelist_ptr->volume_name); volume_name, sizeof(volume_name), &size);
if ( !strcmp( name, volname)) if ( EVEN(sts)) return sts;
{ utl_toupper( name, volume_name);
found = 1;
/* Check that the name is in the global volume list */
found = 0;
volumelist_ptr = volumelist;
for ( i = 0; i < volumecount; i++) {
utl_toupper( volname, volumelist_ptr->volume_name);
if ( !strcmp( name, volname)) {
found = 1;
switch (cid) switch (cid) {
{
case pwr_cClass_RootVolumeLoad : case pwr_cClass_RootVolumeLoad :
strcpy( classname, "RootVolume"); strcpy( classname, "RootVolume");
break; break;
...@@ -773,47 +774,51 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -773,47 +774,51 @@ pwr_tStatus lfu_SaveDirectoryVolume(
case pwr_cClass_SharedVolumeLoad : case pwr_cClass_SharedVolumeLoad :
strcpy( classname, "SharedVolume"); strcpy( classname, "SharedVolume");
break; break;
} }
fprintf( file, "%s %s %s load\n", fprintf( file, "%s %s %s load\n",
volume_name, volume_name,
cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0), cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0),
classname); classname);
break; break;
}
volumelist_ptr++;
} }
volumelist_ptr++; if ( !found) {
} char msg[200];
if ( !found) sprintf( msg, "Error in VolumeConfig object, '%s' is not configured in the global\
{
char msg[200];
sprintf( msg, "Error in VolumeConfig object, '%s' is not configured in the global\
volume list", name); volume list", name);
MsgWindow::message( 'E', msg, msgw_ePop_Default); MsgWindow::message( 'E', msg, msgw_ePop_Default);
syntax_error = 1; syntax_error = 1;
}
} }
} sts = ldh_GetNextSibling( ldhses, volobjid, &volobjid);
sts = ldh_GetNextSibling( ldhses, volobjid, &volobjid); }
} }
} else if ( cid == pwr_cClass_RootVolumeConfig ||
else if ( cid == pwr_cClass_RootVolumeConfig || cid == pwr_cClass_SubVolumeConfig ||
cid == pwr_cClass_SubVolumeConfig || cid == pwr_cClass_ClassVolumeConfig ||
cid == pwr_cClass_ClassVolumeConfig || cid == pwr_cClass_SharedVolumeConfig ||
cid == pwr_cClass_SharedVolumeConfig || cid == pwr_cClass_ExternVolumeConfig ) {
cid == pwr_cClass_ExternVolumeConfig ) { if ( cid != pwr_cClass_ClassVolumeConfig && k == 0)
sts = ldh_ObjidToName( ldhses, envobjid, ldh_eName_Object, continue;
volume_name, sizeof(volume_name), &size); if ( cid == pwr_cClass_ClassVolumeConfig && k == 1)
if ( EVEN(sts)) return sts; continue;
utl_toupper( name, volume_name);
sts = ldh_ObjidToName( ldhses, envobjid, ldh_eName_Object,
volume_name, sizeof(volume_name), &size);
if ( EVEN(sts)) return sts;
utl_toupper( name, volume_name);
/* Check that the name is in the global volume list */ /* Check that the name is in the global volume list */
found = 0; found = 0;
volumelist_ptr = volumelist; volumelist_ptr = volumelist;
for ( i = 0; i < volumecount; i++) { for ( i = 0; i < volumecount; i++) {
utl_toupper( volname, volumelist_ptr->volume_name); utl_toupper( volname, volumelist_ptr->volume_name);
if ( !strcmp( name, volname)) { if ( !strcmp( name, volname)) {
found = 1; found = 1;
switch (cid) { switch (cid) {
case pwr_cClass_RootVolumeConfig : case pwr_cClass_RootVolumeConfig :
strcpy( classname, "RootVolume"); strcpy( classname, "RootVolume");
break; break;
...@@ -829,68 +834,68 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -829,68 +834,68 @@ pwr_tStatus lfu_SaveDirectoryVolume(
case pwr_cClass_ExternVolumeConfig : case pwr_cClass_ExternVolumeConfig :
strcpy( classname, "ExternVolume"); strcpy( classname, "ExternVolume");
break; break;
} }
switch (cid) { switch (cid) {
case pwr_cClass_RootVolumeConfig : case pwr_cClass_RootVolumeConfig :
case pwr_cClass_SubVolumeConfig : case pwr_cClass_SubVolumeConfig :
case pwr_cClass_ClassVolumeConfig : case pwr_cClass_ClassVolumeConfig :
case pwr_cClass_SharedVolumeConfig : case pwr_cClass_SharedVolumeConfig :
fprintf( file, "%s %s %s cnf\n", fprintf( file, "%s %s %s cnf\n",
volume_name, volume_name,
cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0), cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0),
classname); classname);
break; break;
case pwr_cClass_ExternVolumeConfig : { case pwr_cClass_ExternVolumeConfig : {
char *devprovider; char *devprovider;
char *rtprovider; char *rtprovider;
sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody", sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody",
"DevProvider", (char **)&devprovider, &size); "DevProvider", (char **)&devprovider, &size);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody", sts = ldh_GetObjectPar( ldhses, envobjid, "RtBody",
"RtProvider", (char **)&rtprovider, &size); "RtProvider", (char **)&rtprovider, &size);
if ( EVEN(sts)) return sts; if ( EVEN(sts)) return sts;
fprintf( file, "%s %s %s cnf %s %s\n", fprintf( file, "%s %s %s cnf %s %s\n",
volume_name, volume_name,
cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0), cdh_VolumeIdToString( NULL, volumelist_ptr->volume_id, 0, 0),
classname, devprovider, rtprovider); classname, devprovider, rtprovider);
free( devprovider); free( devprovider);
free( rtprovider); free( rtprovider);
break;
}
}
break; break;
} }
} volumelist_ptr++;
break;
} }
volumelist_ptr++;
}
if ( !found) { if ( !found) {
char msg[200]; char msg[200];
sprintf( msg, "Error in VolumeConfig object, '%s' is not configured in the global\ sprintf( msg, "Error in VolumeConfig object, '%s' is not configured in the global\
volume list", name); volume list", name);
MsgWindow::message( 'E', msg, msgw_ePop_Default); MsgWindow::message( 'E', msg, msgw_ePop_Default);
syntax_error = 1; syntax_error = 1;
} }
else { else {
switch (cid) { switch (cid) {
case pwr_cClass_RootVolumeConfig : case pwr_cClass_RootVolumeConfig :
case pwr_cClass_SubVolumeConfig : case pwr_cClass_SubVolumeConfig :
case pwr_cClass_SharedVolumeConfig : { case pwr_cClass_SharedVolumeConfig : {
/* Check if the databas is created */ /* Check if the databas is created */
sprintf( filename, "$pwrp_db/%s.db/info", volume_name); sprintf( filename, "$pwrp_db/%s.db/info", volume_name);
cdh_ToLower( filename, filename); cdh_ToLower( filename, filename);
dcli_translate_filename( filename, filename); dcli_translate_filename( filename, filename);
sts = dcli_search_file( filename, found_file, DCLI_DIR_SEARCH_INIT); sts = dcli_search_file( filename, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( filename, found_file, DCLI_DIR_SEARCH_END); dcli_search_file( filename, found_file, DCLI_DIR_SEARCH_END);
if (EVEN(sts)) { if (EVEN(sts)) {
if ( parent_window) { if ( parent_window) {
lfu_sCreaDb *data; lfu_sCreaDb *data;
data = (lfu_sCreaDb *) calloc( 1, sizeof(*data)); data = (lfu_sCreaDb *) calloc( 1, sizeof(*data));
strcpy( data->name, volumelist_ptr->volume_name); strcpy( data->name, volumelist_ptr->volume_name);
data->vid = volumelist_ptr->volume_id; data->vid = volumelist_ptr->volume_id;
switch ( cid) { switch ( cid) {
case pwr_cClass_RootVolumeConfig: case pwr_cClass_RootVolumeConfig:
data->cid = pwr_eClass_RootVolume; data->cid = pwr_eClass_RootVolume;
break; break;
...@@ -901,54 +906,53 @@ pwr_tStatus lfu_SaveDirectoryVolume( ...@@ -901,54 +906,53 @@ pwr_tStatus lfu_SaveDirectoryVolume(
data->cid = pwr_eClass_SharedVolume; data->cid = pwr_eClass_SharedVolume;
break; break;
default: ; default: ;
} }
data->ldhses = ldhses; data->ldhses = ldhses;
sprintf( text, " Volume '%s' is not yet created.\n \n\ sprintf( text, " Volume '%s' is not yet created.\n \n\
Do you want to create this volume.\n", Do you want to create this volume.\n",
volume_name); volume_name);
wow_DisplayQuestion( NULL, parent_window, wow_DisplayQuestion( NULL, parent_window,
"Create volume", text, "Create volume", text,
lfu_creadb_qb_yes, NULL, (void *)data); lfu_creadb_qb_yes, NULL, (void *)data);
} }
else { else {
char msg[200]; char msg[200];
sprintf( msg, "Error, Volume '%s' is not yet created.", sprintf( msg, "Error, Volume '%s' is not yet created.",
volume_name); volume_name);
MsgWindow::message( 'E', msg, msgw_ePop_Default); MsgWindow::message( 'E', msg, msgw_ePop_Default);
}
} }
break;
} }
break; case pwr_cClass_ClassVolumeConfig : {
} // Check wbload-file...
case pwr_cClass_ClassVolumeConfig : { FILE *wblfile;
// Check wbload-file...
FILE *wblfile; sprintf( fname, "$pwrp_db/%s.wb_load", volume_name);
cdh_ToLower( fname, fname);
sprintf( fname, "$pwrp_db/%s.wb_load", volume_name); dcli_translate_filename( fname, fname);
cdh_ToLower( fname, fname); wblfile = fopen( fname, "r");
dcli_translate_filename( fname, fname);
wblfile = fopen( fname, "r");
if ( wblfile == 0) {
wblfile = fopen( fname, "w");
if ( wblfile == 0) { if ( wblfile == 0) {
char msg[200]; wblfile = fopen( fname, "w");
sprintf( msg, "Error, unable to create file %s, ", fname); if ( wblfile == 0) {
MsgWindow::message( 'E', msg, msgw_ePop_Default); char msg[200];
break; sprintf( msg, "Error, unable to create file %s, ", fname);
} MsgWindow::message( 'E', msg, msgw_ePop_Default);
break;
fprintf( wblfile, "Volume %s pwr_eClass_ClassVolume %s\nEndVolume\n", }
volume_name, cdh_VolumeIdToString( 0, volumelist_ptr->volume_id, 0, 0));
fclose( wblfile); fprintf( wblfile, "Volume %s pwr_eClass_ClassVolume %s\nEndVolume\n",
volume_name, cdh_VolumeIdToString( 0, volumelist_ptr->volume_id, 0, 0));
fclose( wblfile);
}
break;
}
} }
break;
} }
} }
}
} }
sts = ldh_GetNextSibling( ldhses, envobjid, &envobjid);
} }
fclose( file); fclose( file);
#if defined OS_VMS #if defined OS_VMS
system( "purge/nolog " load_cNameVolumeList); system( "purge/nolog " load_cNameVolumeList);
......
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