!* !* Record and array formats !* %RECORDFORMAT HF(%INTEGER DATAEND,DATASTART,FILESIZE,FILETYPE,SUM,DATETIME,FORMAT,RECORDS) %RECORDFORMAT PDF(%INTEGER START, %STRING (11) NAME, %INTEGER HOLE,S5,S6,S7) %RECORDFORMAT PDHF(%INTEGER DATAEND,DATASTART,SIZE,FILETYPE,SUM,DATETIME,ADIR,COUNT) %RECORDFORMAT RF(%INTEGER CONAD,FILETYPE,DATASTART,DATAEND) %OWNRECORD (PDF) %ARRAYFORMAT DIRAF(0:4095) %EXTERNALROUTINESPEC EMAS3 INTEGER(%STRINGNAME VECTOR, %INTEGERNAME VALUE) %EXTERNALROUTINESPEC EMAS3 STRING(%STRINGNAME VECTOR,VALUE) %EXTERNALROUTINESPEC SET RETURN CODE %ALIAS "S#SETRETURNCODE"(%INTEGER N) %RECORDFORMAT CHDRFORM(%INTEGER CONAD,FILETYPE,DATASTART,DATAEND) %EXTERNALROUTINESPEC COPY %ALIAS "s#copy"(%STRING (255) F,T, %INTEGERNAME FLAG) %EXTERNALROUTINESPEC DISCONNECT %alias "S#DISCONNECT" (%STRING (255) FILE, %INTEGERNAME FLAG) %RECORDFORMAT OINFF(%STRING (11) NAME, %INTEGER SP12,NKB, %BYTEINTEGER ARCH,CODES,CCT,OWNP, EEP,USE,CODES2,SSBYTE,FLAGS,PHEAD,DAYNO,GROUP) ! { if PHEAD is non zero, this record has been permitted } { to one or more users } { if GROUP is non zero, this record refers to a group } %EXTERNALINTEGERFNSPEC DFILENAMES(%STRINGNAME GROUP, %INTEGERNAME FILENO,MAXREC,NFILES,FSYS, TYPE, %RECORD (OINFF) %ARRAYNAME INF) ! ! This procedure delivers, in the record array INFS (which should be ! declared (0:n)), a sequence of records describing the on-line files ! (for TYPE=0), archived files (for TYPE=1) or backed-up files (for ! TYPE=2) belonging to group GROUP on fsys FSYS (or -1 if not known). ! ! The procedure works differently for on-line files (TYPE=0) and ! off-line files (TYPE>0). ! ! For on-line files, the records returned give the names of files and ! groups belonging to GROUP but not the contents of any of these groups. ! DFILENAMES must be called again with GROUP set to the name of the ! subgroup to determine these. Thus ! ! FLAG = DFILENAMES(ERCC99,... ! ! returns the names of files and groups in ERCC99's main file index. If ! there is a group called PROJ., the contents of it can be found with ! ! FLAG = DFILENAMES(ERCC99:PROJ.,... ! ! The group separator, ., may be omitted if desired. ! ! Note the usage of : and . (USEP and GSEP) in EMAS3. ! The UINF fields USEP, USEPCH etc allow utilities to be written which ! will work for both EMAS2 and EMAS3. ! ! MAXREC is set by the caller to specify the maximum number of records he ! is prepared to accept in the array INFS, and is set by Director to be ! the number of records returned. ! ! NFILES is set by Director to be the number of files actually held on ! on-line storage or on archive storage, depending on the value of TYPE. ! ! FILENO is not normally used. [ If the top bit of MAXREC is set, FILENO ! is used in the same way as for off-line files, described below ] ! ! The format of the records returned in INFS is ! ! %STRING(11)NAME, %INTEGER SPARE1, KBYTES, ! %BYTEINTEGER ARCH, CODES, CCT, OWNP, ! EEP, USE, CODES2, SSBYTE, SPARE2, PHEAD, DAYNO, GROUP ! ! ( 32 bytes ) ! PHEAD is non-zero if the file or group has been permitted itself to a ! user or user group. ! GROUP is non-zero if NAME is the name of a group. ! ! For off-line files, TYPE = 1 or 2, GROUP will normally be be the name ! of a file index eg ERCC99 or ERCC99{UTILS} when all the names in the ! index will be returned. If an actual group name is given eg ! ! ERCC99:PROJ. ! ! then only names of the form ! ! ERCC99:PROJ.name ! ! are returned. MAXREC and NFILES are used in the same way as above. ! ! Filenames are stored in chronological order of archive (or backup) date, ! youngest first. FILENO is set by the caller to specify the "file-number" ! from which names are to be returned, zero representing the most recently ! archived file. Thus the caller can conveniently receive subsets of names ! of a very large number of files. ! ! The format of the records returned in INFS is ! ! %STRING(11)NAME, %INTEGER KBYTES, ! %STRING(8)DATE, %STRING(6)TAPE, ! %HALFINTEGER PREFIX, CHAPTER, ! %BYTEINTEGER EEP, PHEAD, SPARE, COUNT ! ! ( 40 bytes ) ! To allow the full filenames to be reconstructed, the array INFS, in ! general, contains some records which hold group names. Records refering ! to filenames can be distinguished by the fact that KBYTES > 0. If PREFIX ! is > 0, the name is a member of a group whose name is given in the ! record INFS(PREFIX). The chain can be followed back until a record ! with a zero PREFIX field is found. ! ! Note. MAXREC does not give the number of filenames returned but the ! number of records in INFS. ! ! TAPE and CHAPTER are returned null to unprivileged callers. %EXTERNALROUTINESPEC CONNECT %ALIAS "S#CONNECT"(%STRING (255) FILE, %INTEGER MODE,HOLE,PROT, %INTEGERNAME CONAD,TYPE,START,END,FLAG) %EXTERNALROUTINESPEC EMAS3(%STRINGNAME COMMAND,PARAMS, %INTEGERNAME FLAG) %CONSTINTEGER PDTYPE=6,GROUPSEP='.' %CONSTSTRING (11) TEMPNAME="T#PDGT" %EXTERNALROUTINE PDTOGROUP %ALIAS "C#PDTOGROUP" !*********************************************************************** !* transfers a pdfile to a group with filenames the same as * !* the membernames. Any pdfiles members are further expanded * !* by default * !*********************************************************************** %INTEGER I,J,K,CONAD,FLAG,FLAG1,EXP,FILETYPE,NM %RECORD (PDF) %ARRAYNAME DIRA %RECORD (PDF) %NAME DIR %RECORD (PDHF) %NAME HDR,PDHDR %STRING (255) PD,GROUP,PARAM,FROMNAME,TONAME ! EMAS3STRING("pdfile which must exist;file;?;call pamhelp;",PD) EMAS3STRING("group which must not exist;group;?;call pamhelp;",GROUP) EMAS3INTEGER("expand;word,yes,no;yes;call pamhelp",EXP) FLAG=0; FLAG1=0 CONNECT(PD,0,1,0,CONAD,FILETYPE,J,K,FLAG) ->FAIL %UNLESS FLAG=0 %IF FILETYPE#PDTYPE %THEN FLAG=286 %AND ->FAIL HDR==RECORD(CONAD) NM=HDR_COUNT DIRA==ARRAY(CONAD+HDR_ADIR,DIRAF) J=LENGTH(GROUP) %IF CHARNO(GROUP,J)#GROUPSEP %THEN GROUP=GROUP.TOSTRING(GROUPSEP) EMAS3("newgroup",GROUP,FLAG) FLAG=-FLAG %AND ->FAIL %UNLESS FLAG=0 %FOR I=0,1,NM-1 %CYCLE DIR==DIRA(I) FROMNAME=PD."_".DIR_NAME PDHDR==RECORD(CONAD+DIR_START) %IF EXP=0 %AND PDHDR_FILETYPE=PDTYPE %THEN TONAME=TEMPNAME %ELSE TONAME=GROUP.DIR_NAME ! PARAM=FROMNAME.",".TONAME COPY(FROMNAME,TONAME,FLAG) %IF FLAG=x'80000000' %THEN FLAG=0 ->FAIL %UNLESS FLAG=0 %IF TONAME=TEMPNAME %START; ! further expand pd files TONAME=GROUP.DIR_NAME.TOSTRING(GROUPSEP) PARAM=TEMPNAME.",".TONAME EMAS3("pdtogroup",PARAM,FLAG) EMAS3("destroy",TEMPNAME,FLAG1) FLAG=-FLAG %AND ->FAIL %UNLESS FLAG=0 FLAG=FLAG1 ->FAIL %UNLESS FLAG=0 %FINISHELSESTART DISCONNECT(TONAME,FLAG) %FINISH %REPEAT FLAG=0 FAIL: ! %MONITORUNLESS FLAG=0 ! FLAG=-FLAG %UNLESS FLAG=286 SET RETURN CODE(FLAG) %END %EXTERNALROUTINE GROUPTOPD %ALIAS "C#GROUPTOPD" !*********************************************************************** !* transfers a group to a pdfile with membernames the same as * !* the filenames.Subgroups become partitioned members by default * !*********************************************************************** %INTEGER I,J,K,CONAD,FLAG,EXP,FILETYPE,NM,NF %RECORD (OINFF) %ARRAY DIRA(0:255) %RECORD (OINFF) %NAME DIR %STRING (255) PD,GROUP,PARAM,FROMNAME,TONAME,TEMPN %OWNINTEGER DEPTH DEPTH=DEPTH+1 TEMPN=TEMPNAME.TOSTRING(DEPTH+'0') ! EMAS3STRING("group which must exist;group;?;call pamhelp;",GROUP) EMAS3STRING("pdfile which must not exist;file;?;call pamhelp;",PD) EMAS3INTEGER("Compress subgroups?;word,yes,no;yes;call pamhelp",EXP) NM=255 FLAG=DFILENAMES(GROUP,0,NM,NF,-1,0,DIRA) ->FAIL %UNLESS FLAG=0 J=LENGTH(GROUP) %IF CHARNO(GROUP,J)#GROUPSEP %THEN GROUP=GROUP.TOSTRING(GROUPSEP) EMAS3("newpdfile",PD,FLAG) FLAG=-FLAG %AND ->FAIL %UNLESS FLAG=0 %FOR I=0,1,NM-1 %CYCLE DIR==DIRA(I) %if dir_name->("#") %then %continue;! cant deal with these FROMNAME=GROUP.DIR_NAME TONAME=PD."_".DIR_NAME %IF DIR_GROUP#0 %START; ! compress subgroup %IF EXP#0 %THENCONTINUE PARAM=FROMNAME.".,".TEMPN EMAS3("grouptopd",PARAM,FLAG) FLAG=-FLAG %AND ->FAIL %UNLESS FLAG=0 FROMNAME=TEMPN %FINISH ! PARAM=FROMNAME.",".TONAME COPY(FROMNAME,TONAME,FLAG) %IF FLAG=x'80000000' %THEN FLAG=0 ->FAIL %UNLESS FLAG=0 %IF EXP=0 %AND DIR_GROUP#0 %START; ! further expand pd files EMAS3("destroy",TEMPN,FLAG) %FINISH DISCONNECT(FROMNAME,FLAG) %REPEAT FLAG=0 FAIL: ! %MONITORUNLESS FLAG=0 ! FLAG=-FLAG %UNLESS FLAG=286 SET RETURN CODE(FLAG) DEPTH=DEPTH-1 %END %ENDOFFILE