From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX"  1-MAR-1991 17:43:00.14
To:	ARISIA::EVERHART
CC:	
Subj:	A Little Gizmo to Fix Savesets

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.88)
	 id AA04958; Fri, 1 Mar 91 17:29:06 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Thu, 28 FEB 91 11:04:18 PST
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA12633; Thu, 28 Feb 91 10:59:55 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 28 Feb 91 17:38:07 GMT
From: bill.ab.umd.edu!bill@umd5.umd.edu  (Bill Bame)
Organization: Maryland Institute for Emergency Medical Services Systems
Subject: A Little Gizmo to Fix Savesets
Message-Id: <1991Feb28.122919@bill.ab.umd.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

We send/receive a lot of VMS BACKUP save sets (through means other than DECnet),
and up until a few months ago I used either MODATT or FILE to "fix" the file
characteristics after the transfer. Unfortunately both of these assume that I
know what the record size should be.  This is not always the case, so I wrote
this short C program to find out (and then fix up the file for me).

To use it, compile/link it, set it up as a foreign command like this:

fix_saveset:==$disk:[dir]fix_saveset

then simply enter "fix_saveset filename.ext" at the DCL prompt.

I would have posted this to vmsnet.sources, but that group is not offerred by
the NNTP news server that I have access to.

--------------------- CUT HERE
--------------------------------------------------
/*
 * 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.4-1A
 *
 * Disclaimer:  As usual, use at your own risk.
 */
#include <unixio.h>
#include <file.h>
#include <fab.h>
#define RME$C_SETRFM 0x00000001

main(argc,argv)
int argc;
char **argv;
{
  int fd,buffer[10],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",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)) & 7) != 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];
    if (((status = SYS$MODIFY(&myfab, 0, 0)) & 7) != 1)
        exit((printf("Couldn't modify %s\n", *argv), status));
    if (((status = SYS$CLOSE(&myfab, 0, 0)) & 7) != 1)
        exit((printf("Couldn't close %s\n", *argv), status));
  }
  else {
    printf("usage: fix_saveset <filename>\n");
    exit(1);
  }
}
--------------------- CUT HERE
--------------------------------------------------

--
------------------------------------------------------------------------
---------
William P. Bame                    | sneakernet: William P. Bame
internet: bill@bill.ab.umd.edu     |             M.I.E.M.S.S.
          bbame@achi1.ab.umd.edu   |             22 South Greene Street
AT&T    : [Work] (301) 328-3062    |             Baltimore, MD 21201
CIS     : 71620,425                |             Room: T1R55
------------------------------------------------------------------------
---------

