  Accessing RMS (compressed) records? 
 The Question is:
 
I have a third party file that has compressed data starting
at byte 114 of a 485 byte record. Byte 1 thru 113 is ascii.
Is there a VMS command to unparse the data and convert/write
it to a sequential file?
 
 
 The Answer is:
 
  Without knowing what sort of data compression scheme is used, this
  question is difficult to answer.
 
  Opening and reading an RMS file is trivial, the code to perform the
  decompression depends on the algorithm used.
 
  Attached is C code that opens an RMS file, and displays the records
  of the file to the terminal.  Several changes -- support for a longer
  record length, and the decompression scheme, obviously -- would need
  to be made to this example for your particular application.
 
 
/*
** COPYRIGHT (c) 1992 BY
** DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS.
** ALL RIGHTS RESERVED.
**
** THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
** ONLY  IN  ACCORDANCE  OF  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
** INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR  ANY  OTHER
** COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
** OTHER PERSON.  NO TITLE TO AND  OWNERSHIP OF THE  SOFTWARE IS  HEREBY
** TRANSFERRED.
**
** THE INFORMATION IN THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT NOTICE
** AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
** CORPORATION.
**
** DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE  OR  RELIABILITY OF ITS
** SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
*/
 
/*
**++
**  Facility:
**
**	Examples
**
**  Version: V1.1
**
**  Abstract:
**
**	Example of working with RMS calls from C
**
**  Author:
**	Steve Hoffman (XDELTA::HOFFMAN)
**
**  Creation Date:  1-Jan-1990
**
**  Modification History:
**	    Hoffman	15-Oct-1994	Updates for DEC C
**--
*/
 
/*
//  RMS_EXAMPLES.C
//
//  Program displays some RMS calls made from the c language.  Types out
//  the calling process's SYS$LOGIN:LOGIN.COM file to SYS$OUTPUT.
//
//  Included is a main and three subroutines.  The subroutines open,
//  read a record, and close the file.  Several hooks, such as the
//  use of the NAM block to obtain the specification of the file that
//  was actually opened, are included but are not currently used.
//
//  To build:
//
//    $ CC [/DECC] [/DEBUG/NOOPTIM] RMS_EXAMPLES
//    $ LINK [/DEBUG] RMS_EXAMPLES
//    $ RUN [/[NO]DEBUG] RMS_EXAMPLES
*/
 
#include &lt;lib$routines.h&gt;
#include &lt;rms.h&gt;
#include &lt;starlet.h&gt;
#include &lt;string.h&gt;
#include &lt;ssdef.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stsdef.h&gt;
 
/*
// RMS_MRS is the maximum record size that can be read (and thus
// displayed) by this program.
*/
#define RMS_MRS	255
 
/*
// The following is the core data structure for the program.
// The various RMS subroutines all communicate via a pointer
// referencing this struct.
*/
struct RmsFileContext
    {
    struct FAB fab;
    struct RAB rab;
    struct NAM nam;
    char rss[NAM$C_MAXRSS];
    short max_rec_siz;
    char *data_buffer;
    };
 
RmsFileOpen( void **CtxArg,
char *FileName, char *DefFileName, int flags, int rss )
    {
    int RetStat;
    struct RmsFileContext *Ctx;
    int howbig = sizeof( struct RmsFileContext );
 
    /*
    // acquire some space for a Context block.
    */
    RetStat = lib$get_vm( &amp;howbig, &amp;Ctx, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    *CtxArg = (void *) Ctx;
 
    /*
    // Fill in the various fields of the Context block.
    // -- Builds the File Access Block (FAB), the Record Access
    // Block (RAB) and the Name (NAM) Block.  Along with some
    // other miscellaneous housekeeping stuff.
    */
    Ctx-&gt;fab = cc$rms_fab;
    Ctx-&gt;rab = cc$rms_rab;
    Ctx-&gt;nam = cc$rms_nam;
 
    Ctx-&gt;fab.fab$l_nam = &amp;Ctx-&gt;nam;
    Ctx-&gt;fab.fab$l_fop = FAB$M_NAM;
    Ctx-&gt;fab.fab$b_fac = FAB$M_GET;
 
    Ctx-&gt;fab.fab$l_fna = FileName;
    Ctx-&gt;fab.fab$b_fns = strlen( FileName );
    Ctx-&gt;fab.fab$l_dna = DefFileName;
    Ctx-&gt;fab.fab$b_dns = strlen( DefFileName );
 
    Ctx-&gt;rab.rab$l_fab = &amp;Ctx-&gt;fab;
 
    Ctx-&gt;nam.nam$b_rss = NAM$C_MAXRSS;
    Ctx-&gt;nam.nam$l_rsa = Ctx-&gt;rss;
 
    Ctx-&gt;rab.rab$b_rac = RAB$C_SEQ;
 
    /*
    // Attempt to open the file...
    */
    RetStat = sys$open( &amp;Ctx-&gt;fab, 0, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    /*
    // Allocate a buffer large enough for the biggest record.
    */
    RetStat = lib$get_vm( &amp;RMS_MRS, &amp;Ctx-&gt;data_buffer, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    /*
    // Attempt to connect the record stream to the file...
    */
    RetStat = sys$connect( &amp;Ctx-&gt;rab, 0, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    return RetStat;
    }
 
RmsFileRead( void **CtxArg, char **BufAdr, int *BufLen )
    {
    int RetStat;
    struct RmsFileContext *Ctx = *CtxArg;
 
    Ctx-&gt;rab.rab$l_ubf = Ctx-&gt;data_buffer;
    Ctx-&gt;rab.rab$w_usz = RMS_MRS;
 
    RetStat = sys$get( &amp;Ctx-&gt;rab, 0, 0 );
 
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	{
        *BufLen = (char) 0;
	*BufAdr = (char) 0;
	return RetStat;
	}
 
    *BufAdr = Ctx-&gt;rab.rab$l_rbf;
    *BufLen = Ctx-&gt;rab.rab$w_rsz;
 
    return RetStat;
    }
 
RmsFileClose( void **CtxArg )
    {
    int RetStat;
    struct RmsFileContext *Ctx = *CtxArg;
 
    /*
    // Free up the record buffer...
    */
    RetStat = lib$free_vm( &amp;RMS_MRS, &amp;Ctx-&gt;data_buffer, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    /*
    // Be nice and clean up the record stream...
    */
    RetStat = sys$disconnect( &amp;Ctx-&gt;rab, 0, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    /*
    // And close the file...
    */
    RetStat = sys$close( &amp;Ctx-&gt;fab, 0, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    /*
    // And free up the allocated memory...
    */
    RetStat = lib$free_vm( &amp;sizeof( struct RmsFileContext ), CtxArg, 0 );
    if ( !$VMS_STATUS_SUCCESS( RetStat ) )
	return RetStat;
 
    return RetStat;
 
    }
main()
    {
    int RetStat;
    void *Context;
    char *BufAdr;
    int BufLen;
 
    /*
    // Open the file.  Minimal checking is performed.  Read access only.
    */
    RetStat = RmsFileOpen( &amp;Context, "LOGIN", "SYS$LOGIN:.COM", 0, 0 );
 
    /*
    // Read the file.  Minimal checking is performed.
    */
    for (;;)
	{
	RetStat = RmsFileRead( &amp;Context, &amp;BufAdr, &amp;BufLen );
	if ( $VMS_STATUS_SUCCESS( RetStat ) )
	    printf("%*.*s\n", BufLen, BufLen, BufAdr );
	else
	    break;
	}
 
    /*
    // Close up shop.
    */
    RetStat = RmsFileClose( &amp;Context );
 
    return RetStat;
    }
 
