From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 23-FEB-1992 13:52:48.28
To:	ARISIA::EVERHART
CC:	
Subj:	Re: VAX C and $FILESCAN

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

Received:  by crdgw1.ge.com (5.57/GE 1.123)
	 id AA27071; Sun, 23 Feb 92 13:26:15 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Sun, 23 FEB 92 10:15:35 PST
Received: by ucbvax.Berkeley.EDU (5.63/1.43)
	id AA09624; Sun, 23 Feb 92 09:58:04 -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: 22 Feb 92 14:38:55 GMT
From: psinntp!npri6!murphy@uunet.uu.net  (David P. Murphy)
Organization: NPRI, Alexandria VA
Subject: Re: VAX C and $FILESCAN
Message-Id: <4918@npri6.npri.com>
References: <1992Feb21.200252.18221@ncsu.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


>Does anyone have an example in C of setting up the structure for $FILESCAN,
>loading the necessary data into it, and then actually calling the service?
>Thanks in advance.
>
>seward@CCVAX1.NCSU.EDU (Bill Seward)

#include "strdesc.h"

#define FSCN$M_NODE        1
#define FSCN$M_DEVICE      2
#define FSCN$M_ROOT        4
#define FSCN$M_DIRECTORY   8
#define FSCN$M_NAME       16
#define FSCN$M_TYPE       32
#define FSCN$M_VERSION    64

#define FSCN$S_FLDFLAGS    1

#define FSCN$V_NODE        0
#define FSCN$V_DEVICE      1
#define FSCN$V_ROOT        2
#define FSCN$V_DIRECTORY   3
#define FSCN$V_NAME        4
#define FSCN$V_TYPE        5
#define FSCN$V_VERSION     6

#define FSCN$_FILESPEC     1
#define FSCN$_NODE         2
#define FSCN$_DEVICE       3
#define FSCN$_ROOT         4
#define FSCN$_DIRECTORY    5
#define FSCN$_NAME         6
#define FSCN$_TYPE         7
#define FSCN$_VERSION      8

#define FSCN$S_ITEM_LEN    8
#define FSCN$S_FSCNDEF     8

#define FSCN$W_LENGTH      0
#define FSCN$W_ITEM_CODE   2
#define FSCN$L_ADDR        4

typedef struct FILESCANITEM {
	variant_union {
		variant_struct {
			short len;
			short code;
		} first2;
		long end;
	} lencode_or_end;
	char *addr;
} FileScanItem;

typedef struct FILESCANFOUND {
	variant_union {
		unsigned long foundMask;
		variant_struct {
			unsigned foundNode :  1;
			unsigned foundDev  :  1;
			unsigned foundRoot :  1;
			unsigned foundDir  :  1;
			unsigned foundName :  1;
			unsigned foundType :  1;
			unsigned foundVer  :  1;
			unsigned           : 25;
		} bits;
	} bitmask;
} FileScanFound;

typedef struct FILESPEC_PTRS {
	Text *fullspecptr;
	Text *nodeptr;
	Text *devptr;
	Text *dirptr;
	Text *nameptr;
	Text *typeptr;
	Text *verptr;
} FileSpecPtrs;

#ifndef FNSIZE
#define FNSIZE  44
#endif

typedef struct FILESPEC {
	Text fullspec[FILENAMESIZE];
	Text node[NODESIZE];
	Text dev[DEVSIZE];
	Text dir[UICSIZE];
	Text name[FNSIZE];
	Text type[FNSIZE];
	Text ver[VERSIZE];
} FileSpec;

typedef STATUS unsigned long;

void scpyn(int s, char *src, char *dst)

{
	move s bytes from src to dst;  /* i forget the call for this */
	dst[s] = EOS;

	return;
}

STATUS ScanFileSpec(fs, deffs, info)

char *fs, *deffs;
FileSpec *info;
{
	int strlen(), sprintf();
	void scpyn();
	STATUS sys$filescan();

	STATUS stat;
	FileScanItem item[8];
	FileScanFound found, deffound;
	struct STRDESC specsd;

	info->node[0] = EOS;
	info->dev[0]  = EOS;
	info->dir[0]  = EOS;
	info->name[0] = EOS;
	info->type[0] = EOS;
	info->ver[0]  = EOS;

	item[0].code = FSCN$_FILESPEC;  item[0].len = 0; item[0].addr = NULL;
	item[1].code = FSCN$_NODE;      item[1].len = 0; item[1].addr = NULL;
	item[2].code = FSCN$_DEVICE;    item[2].len = 0; item[2].addr = NULL;
	item[3].code = FSCN$_DIRECTORY; item[3].len = 0; item[3].addr = NULL;
	item[4].code = FSCN$_NAME;      item[4].len = 0; item[4].addr = NULL;
	item[5].code = FSCN$_TYPE;      item[5].len = 0; item[5].addr = NULL;
	item[6].code = FSCN$_VERSION;   item[6].len = 0; item[6].addr = NULL;

	item[7].end  = 0;

	specsd.ptr  = fs;
	specsd.len  = strlen(fs);
	specsd.type = specsd.class = 0;

	stat = sys$filescan(&specsd, &item[0], &found);
	if (stat != SS$_NORMAL) return(stat);

	   /* always */      scpyn(item[0].len, item[0].addr, info->fullspec);
	if (found.foundNode) scpyn(item[1].len, item[1].addr, info->node);
	if (found.foundDev)  scpyn(item[2].len, item[2].addr, info->dev);
	if (found.foundDir)  scpyn(item[3].len, item[3].addr, info->dir);
	if (found.foundName) scpyn(item[4].len, item[4].addr, info->name);
	if (found.foundType) scpyn(item[5].len, item[5].addr, info->type);
	if (found.foundVer)  scpyn(item[6].len, item[6].addr, info->ver);

	if (deffs == NULL) return(SS$_NORMAL);

	item[0].code = FSCN$_FILESPEC;  item[0].len = 0; item[0].addr = NULL;
	item[1].code = FSCN$_NODE;      item[1].len = 0; item[1].addr = NULL;
	item[2].code = FSCN$_DEVICE;    item[2].len = 0; item[2].addr = NULL;
	item[3].code = FSCN$_DIRECTORY; item[3].len = 0; item[3].addr = NULL;
	item[4].code = FSCN$_NAME;      item[4].len = 0; item[4].addr = NULL;
	item[5].code = FSCN$_TYPE;      item[5].len = 0; item[5].addr = NULL;
	item[6].code = FSCN$_VERSION;   item[6].len = 0; item[6].addr = NULL;

	item[7].end  = 0;

	specsd.ptr = deffs;
	specsd.len = strlen(deffs);

	stat = sys$filescan(&specsd, &item[0], &deffound);
	if (stat != SS$_NORMAL) return(stat);

	if (deffound.foundNode && found.foundNode == NO) {
		scpyn(item[1].len, item[1].addr, info->node);
	}
	if (deffound.foundDev  && found.foundDev  == NO) {
		scpyn(item[2].len, item[2].addr, info->dev);
	}
	if (deffound.foundDir  && found.foundDir  == NO) {
		scpyn(item[3].len, item[3].addr, info->dir);
	}
	if (deffound.foundName && found.foundName == NO) {
		scpyn(item[4].len, item[4].addr, info->name);
	}
	if (deffound.foundType && found.foundType == NO) {
		scpyn(item[5].len, item[5].addr, info->type);
	}
	if (deffound.foundVer  && found.foundVer  == NO) {
		scpyn(item[6].len, item[6].addr, info->ver);
	}

	sprintf(info->fullspec, "%s%s%s%s%s%s", info->node, info->dev,
		info->dir, info->name, info->type, info->ver);

	return(SS$_NORMAL);
}

ok
dpm
-- 
murphy@npri6.npri.com
602 Cameron St.
Alexandria, VA  22314                 The First Amendment:
(703) 683-9090                        it's not just a good idea, it's the law.

