From:	SMTP%"bill@office.ab.umd.edu"  7-AUG-1993 11:49:39.22
To:	EVERHART
CC:	
Subj:	Re: Preserving RMS information across Unix ftp...

X-Newsgroups: comp.os.vms
Subject: Re: Preserving RMS information across Unix ftp...
Message-Id: <23p9hr$dec@umd5.umd.edu>
From: bill@office.ab.umd.edu (Bill Bame)
Date: 4 Aug 1993 21:26:19 GMT
Reply-To: bill@office.ab.umd.edu
Sender: bill@bill.ab.umd.edu (Bill Bame)
Distribution: world
Organization: UMMS/Shock Trauma
Nntp-Posting-Host: bill.ab.umd.edu
X-Newsreader: mxrn 6.18-4
Lines: 73
To: Info-VAX@kl.sri.com
X-Gateway-Source-Info: USENET


Rudy,

The accepted method for restoring VMS file attributes after FTP (or KERMIT
or whatever) is via Joe Meadows FILE utility or another of it's ilk.  In
case you don't have that, this snippet of C code will do the trick for VMS
backup savesets.

-Bill

/* FIX_SAVESET.C
 * Author : William P. Bame (September 1990)
 * Purpose: Change the file attributes of a saveset so that VMS BACKUP can
 *          read it again.  Especially useful when transferring save sets via
 *          some non-DEC protocol (ftp, uucp, etc.).
 * Notes  : Tested with VMS 5.1-1 through 5.5-2
 *
 * Disclaimer:  As usual, use at your own risk.
 */
#include <unixio.h>
#include <file.h>
#include <fab.h>
#include <rmedef.h>

main(argc,argv)
int argc;
char **argv;
{
  int fd,buffer[11],status;
  struct FAB myfab = cc$rms_fab;

  if (argc >= 2) {
    if ((fd = open(*++argv,O_RDONLY,0)) <= 0) {
      perror("open");
      exit();
    }
    else {
      if ((read(fd,buffer,44)) < 0) {
        perror("read");
        exit();
      }
    }
    close(fd);
    printf("size = %d\n",buffer[10]);
    myfab.fab$b_fac = FAB$M_PUT;
    myfab.fab$l_fop = FAB$M_ESC;
    myfab.fab$l_ctx = RME$C_SETRFM;
    myfab.fab$l_fna = *argv;
    myfab.fab$b_fns = strlen(*argv);
    if (((status = SYS$OPEN(&myfab, 0, 0)) & 1) != 1)
        exit((printf("Couldn't open %s\n", *argv), status));
    myfab.fab$b_org = FAB$C_SEQ;
    myfab.fab$b_rfm = FAB$C_FIX;
    myfab.fab$w_mrs = buffer[10] & 0x0000FFFF;
    if (((status = SYS$MODIFY(&myfab, 0, 0)) & 1) != 1)
        exit((printf("Couldn't modify %s\n", *argv), status));
    if (((status = SYS$CLOSE(&myfab, 0 , 0)) & 1) != 1)
        exit((printf("Couldn't close %s\n", *argv), status));
  }
  else {
    printf("usage: fix_saveset <filename>\n");
    exit(1);
  }
}

-- 
+--------------------------------------+-------------------------------------+
|   William P. Bame                    | Ground: William P. Bame             |
|   internet: bill@office.ab.umd.edu   |         UMMS/Shock Trauma           |
|             bbame@achi1.ab.umd.edu   |         22 South Greene Street      |
|   AT&T    : [Work] (410) 328-3062    |         Baltimore, MD 21201         |
|   CIS     : 71620,425                |         Room: T1R55                 |
+--------------------------------------+-------------------------------------+

