[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

Decoding image headers?

» close window

The Question is:

 
I'm trying to access the image IDENTIFICATION field in the image header at
run-time. Is there a routine I can call
from DEC C++ to get this or any other way of retrieving this string ?
 
Many thanks,
 
Martin Game.
 
 


The Answer is :

 
  There is no documented nor supported mechanism for retrieving and
  processing the image header at run-time.
 
  The following (old! unsupported! undocumented!) OpenVMS VAX code
  might be of interest -- the OpenVMS Alpha symbols will tend to use
  EIHD$, EIHI$, etc. symbols where the following OpenVMS VAX code uses
  the IHD$, IHI$, etc. symbols...  The code will otherwise be fairly
  similar on both platforms.  You will need to look at and acquire a
  basic understanding of the IHD and the associated data structures,
  as well as becoming familiar with the relevent portions of the
  OpenVMS Internals and Data Structures Manual, and with the OpenVMS
  source listings, in order to make best use of this code.
 
  This C code is old, has not been updated for DEC C, has not been
  debugged, and is dependent on OpenVMS routines that are undocumented
  and subject to change without notice.
 
  You will need to create the necessary include files ihddef.h, ihidef.h,
  eihddef.h, eihidef.h, etc., from the contents of the associated system
  Macro32 library SYS$LIBRARY:LIB.MLB modules $ihddef, $ihidef, $eihddef,
  $eihidef, etc.  To get this code to link,  you will need to link against
  the system symbol table (OpenVMS VAX) or the base image (OpenVMS Alpha)
  to resolve the external reference to img$decode_ihd().  Note that
  linking against the system symbol table (OpenVMS VAX) or the base image
  (OpenVMS Alpha) will leave you with an OpenVMS version-dependent image.
  For information on this linking process, see the device driver manuals.
 
  The Wizard would strongly encourage you to find another solution to
  the problem at hand, rather than trying to decode the image header.
  Please do not contact Compaq, nor the OpenVMS Wizard, if you cannot
  get this code to work.
 
 
 
xxx$$decode_ihd( char *img_fn, *img_dn )
    {
    unsigned long int retstat;
    unsigned long int offset = 12;
    unsigned long int vbn = 1;
    struct FAB fab = cc$rms_fab;
    struct NAM nam = cc$rms_nam;
    char blk0[ 512 ];
    char ihd[ 1024 ];
    char *ihi;
    unsigned long int hdrvers = 2;
    unsigned long int last_word = 3;
    struct dsc$descriptor_s asctimbuf;
 
    asctimbuf.dsc$w_length = 23;
    asctimbuf.dsc$b_dtype = DSC$K_DTYPE_T;
    asctimbuf.dsc$b_class = DSC$K_CLASS_S;
    asctimbuf.dsc$a_pointer = calloc( 24, 1 );
 
    fab.fab$l_nam = &nam;
    nam.nam$l_rsa = calloc( nam.nam$b_rss = NAM$C_MAXRSS, 1 );
    fab.fab$b_fac = FAB$M_GET;
    fab.fab$l_fop = FAB$M_UFO | FAB$M_NAM;
    fab.fab$b_fns = strlen( img_fn );
    fab.fab$l_fna = img_fn;
    fab.fab$b_dns = strlen( img_dn );
    fab.fab$l_dna = img_dn;
 
    retstat = sys$open( &fab );
    if (!$VMS_STATUS_SUCCESS( retstat )) return retstat;
 
    retstat = img$decode_ihd(
        fab.fab$l_stv, blk0, ihd, &vbn, &offset, &hdrvers, &last_word );
    if (!$VMS_STATUS_SUCCESS( retstat )) return retstat;
 
    retstat = sys$close( &fab );
    if (!$VMS_STATUS_SUCCESS( retstat )) return retstat;
 
    if ( last_word != (unsigned short int) IHD$C_NATIVE )
        printf( "File: %*s is not a native-mode image.\n",
            nam.nam$b_rsl, nam.nam$l_rsa );
 
    printf( "File: %*s ",
            nam.nam$b_rsl, nam.nam$l_rsa );
 
    ihi = ihd + *(short *)((char *)ihd + IHD$W_IMGIDOFF);
    printf( " ident: %*s\n",
            (char) ihi[IHI$T_IMGID], &ihi[IHI$T_IMGID+1] );
 
    retstat = sys$asctim( 0, &asctimbuf, &ihi[IHI$Q_LINKTIME], 0 );
    if (!$VMS_STATUS_SUCCESS( retstat )) return retstat;
    asctimbuf.dsc$a_pointer[23] = 0;
    printf( " linktime: %23s\n", asctimbuf.dsc$a_pointer );
 
    free( asctimbuf.dsc$a_pointer );
    free( nam.nam$l_rsa );
 
    return SS$_NORMAL;
 
    }
 
 

answer written or last revised on ( 21-OCT-1998 )

» close window