From:	CSBVAX::MRGATE!INFO-VAX-RELAY@KL.SRI.COM@SMTP  8-JUL-1988 20:15
To:	ARISIA::EVERHART
Subj:	unix & vms filename translations


Received: from oly.acs.washington.edu by KL.SRI.COM with TCP; Thu 5 May 88 13:56:08-PDT
Received: from UWAVM.ACS.WASHINGTON.EDU by oly.acs.washington.edu ; Thu, 05 May 88 13:56:51 PDT
Received: from UWAVM.ACS.WASHINGTON.EDU by UWAVM.ACS.WASHINGTON.EDU (Mailer
 X1.25) with BSMTP id 1312; Thu, 05 May 88 13:56:47 PDT
P1-Message-Id: US**EDU;UWAVM.ACS.WASHINGTON.EDU:LLGPMdDP
Date:         Thu, 5 May 88 13:54-0700
X400-Trace:   US**EDU; arrival Thu, 5 May 88 13:54-0700 action Relayed
X400-Trace:   US**EDU; arrival Thu, 5 May 88 13:56-0700 action Relayed
From:         Joe Meadows<JOE%FHCRCVAX.BITNET@oly.acs.washington.edu>
Subject:      unix & vms filename translations
To:           <info-vax@kl.sri.COM>
Message-Id:   <UWAVM.ACS.WASHINGTON.EDU:LLGPMdDP*>
X-VMS-To: IN%"info-vax@kl.sri.com"


        Someone once asked how to use the SHELL$TO_VMS/SHELL$FROM_VMS
routines. Not having ever looked into it I didn't know how to. Until
today. Someone asked me about them today and I just decided to spelunk
through the code (manuals? you mean they're in a manual somewhere? oops..)
and figure out how they were called. The following short example program
should demonstrate their usage. I don't have DECShell, so I can't tell
how they relate to it, although the code does check what CLI it's running
under (the SHELL$ code, not mine)..

  Cheers,
  Joe Meadows Jr.
     bitnet - JOE@FHCRCVAX
     arpa   - JOE%FHCRCVAX.BITNET@OLY.ACS.WASHINGTON.EDU

/* SHELL.C
   This test program either converts a file spec from VMS to UNIX,
   or vice versa, or simply translates a filespec. Invoke by defining
   a foreign command - SHELL := $disk:[dir]SHELL, then say
        shell t filespec [filespec...]
                Calls shell$translate_vms
        shell u filespec [filespec...]
                Calls shell$to_vms
        shell v filespec [filespec...]
                Calls shell$from_vms
        shell w[u|v] filespec [filespec]
                Calls shell$[to|from]_vms with wildcard flag set
*/

int action();

main(argc,argv)
  int argc;
  char *argv[];
{
  int i;
  int x = 0;
  int wild = 0;
  char *y;

  if (*argv[1] == 'w') {
    *argv[1] = *(argv[1]+1);
    wild = 1;
  };

  switch (*argv[1]) {
    case 't':
      for (i=2; i<argc; ++i) {
        printf("converting %s\n",argv[i]);
        y = shell$translate_vms(argv[i]);
        printf("translated %s\n",y?y:"as garbage");
      };
      break;
    case 'u':
      for (i=2; i<argc; ++i) {
        printf("converting %s\n",argv[i]);
        x = shell$to_vms(argv[i],&action,wild);
        printf("%d files found\n",x);
      };
      break;
    case 'v':
      for (i=2; i<argc; ++i) {
        printf("converting %s\n",argv[i]);
        x = shell$from_vms(argv[i],&action,wild);
        printf("%d files found\n",x);
      };
      break;
    default:
      printf("Unknown option \"%s\", must call as :\n",argv[1]);
      printf("\tshell [t|u|v|wu|wv] filespec [filespec]\n");
      printf("\t\t t = translate vms to unix\n");
      printf("\t\t u = convert from unix to vms\n");
      printf("\t\t v = convert from vms to unix\n");
      printf("\t\t wu = wildcarded convert from unix to vms\n");
      printf("\t\t wv = wildcarded convert from vms to unix\n");
      break;
  };
}

action(name)
  char *name;
{
  printf("%s\n",name);
  return(1);
}
-------
