From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 22-SEP-1990 10:09:27.46
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: Cracking filenames

Received:  by crdgw1.ge.com (5.57/GE 1.73)
	 id AA24797; Sat, 22 Sep 90 09:50:26 EDT
Received: From DANPOST.UNI-C.DK by CRVAX.SRI.COM with TCP; Sat, 22 SEP 90 06:15:11 PDT
Received: from vms2.uni-c.dk by danpost.uni-c.dk (5.61/4.7)
	id AA27462; Sat, 22 Sep 90 13:09:17 GMT
Date: Sat, 22 Sep 90 15:11 +0200
From: ISIS08@ecostat.aau.dk
Subject: Re: Cracking filenames
To: INFO-VAX@SRI.COM, RICKS@BERKELEY.EDU
Message-Id: <2E5A4F485E1F008103@vms2.uni-c.dk>
X-Envelope-To: RICKS@BERKELEY.EDU, INFO-VAX@SRI.COM
X-Vms-To: IN::"INFO-VAX@SRI.COM",IN::"RICKS@BERKELEY.EDU"

> I would like to crack a VMS file specification into it's
> constituent parts (node, device, etc).  I have just found
> out about sys$filescan, but am not familiar with using
> non-C library functions (i.e. how do I set up the arguments).
> Does anybody have a section of C code that uses sys$filescan.

The following piece of C-code is not elegant, but it works !

                                                     Arne

Arne Vajhxj                             Internet: ISIS08@ECOSTAT.AAU.DK
Institute of Economics and Statistics   PSI:      DATAPAX.23830211371400::ISIS08
Aarhus University
Denmark

------------------------------------------------------------------------------

#include <stdio.h>
#include <fscndef.h>
#include <ssdef.h>
#include <descrip.h>
#include <string.h>

int sys$filescan();

main()
{
   $DESCRIPTOR(testfile,"MYNODE::MYDISK:[MYDIR]TEST.DAT");
   char nodestr[7],devicestr[13],directorystr[256],namestr[32],typestr[32];
   struct item {short length; short code; long address;};
   struct item result[] = {
                          {0, FSCN$_NODE, 0},
                          {0, FSCN$_DEVICE, 0},
                          {0, FSCN$_DIRECTORY, 0},
                          {0, FSCN$_NAME, 0},
                          {0, FSCN$_TYPE, 0},
                          {0, 0, 0},
                          };
   sys$filescan(&testfile,&result,0);
   strncpy(&nodestr,(char *)result[0].address,result[0].length);
   strncpy(&devicestr,(char *)result[1].address,result[1].length);
   strncpy(&directorystr,(char *)result[2].address,result[2].length);
   strncpy(&namestr,(char *)result[3].address,result[3].length);
   strncpy(&typestr,(char *)result[4].address,result[4].length);
   nodestr[result[0].length]='\0';
   devicestr[result[1].length]='\0';
   directorystr[result[2].length]='\0';
   namestr[result[3].length]='\0';
   typestr[result[4].length]='\0';
   printf("node=%s\n",nodestr);
   printf("device=%s\n",devicestr);
   printf("directory=%s\n",directorystr);
   printf("name=%s\n",namestr);
   printf("type=%s\n",typestr);
   return SS$_NORMAL;
};


