Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

C Code Returning Unreadable File ID String

 
SOLVED
Go to solution
Highlighted
Robert Atkinson
Respected Contributor

C Code Returning Unreadable File ID String

The C code below (from ExecSymb) returns this string as the File ID, which is unusable :-

FILE_IDENTIFICATION
␊_$1$DGA151␤␤␤␤␤ú#M␤␤d-␤␤


Anybody know the code to return it in the (n,n,n) format?

Rob.


C
C Look at the identification of the file being processed. Strip off the
C device name, and get the fileid and directory id values.
C
STREAM(NSTREAM).ENTRY=LONG(MESSAGE(IP:IP+3))
IP=STREAM(NSTREAM).POS(SMBMSG$K_FILE_IDENTIFICATION)
STREAM(NSTREAM).DEVICE_NAME_LEN=BYTE(MESSAGE(IP:IP))
STREAM(NSTREAM).DEVICE_NAME=MESSAGE(IP+1:IP+15)
STREAM(NSTREAM).FID(1)=WORD(MESSAGE(IP+16:IP+17))
STREAM(NSTREAM).FID(2)=WORD(MESSAGE(IP+18:IP+19))
STREAM(NSTREAM).FID(3)=WORD(MESSAGE(IP+20:IP+21))
DID(1)=WORD(MESSAGE(IP+22:IP+23))
DID(2)=WORD(MESSAGE(IP+24:IP+25))
DID(3)=WORD(MESSAGE(IP+26:IP+27))
C
13 REPLIES 13
Hein van den Heuvel
Honored Contributor

Re: C Code Returning Unreadable File ID String

File ID's are often treated as 3 consecutive 16-bit words, even though that wrong. The code sample shown appears to attempt this. To print that data you want to do something similar to:

printf ("%s(%d,%d,%%)\n", device, did[1], did[2], did[2])


To do this properlyy you need to add the 1st 16 bits to 65536*times 8 bits from the 3rd word and display that as file ID.

See layout in the RMS NAMDEF.
Uage example for that:

i = atoi (argv[1]);
nam.nam$w_fid_num = (short) i;
nam.nam$b_fid_nmx = (unsigned char) (i >> 16);
nam.nam$w_fid_seq = (short) atoi ( argv[2] );
nam.nam$w_fid_rvn = (short) atoi ( argv[3] );


Enjoy,
Hein.

GuentherF
Trusted Contributor

Re: C Code Returning Unreadable File ID String

Rob,

I don't see how the listed code lines can return this:

FILE_IDENTIFICATION
â _$1$DGA151⠤⠤⠤⠤⠤ú#M⠤⠤d-⠤⠤

Do you?

Hint...show us the code that produced the lines above.

/Guenther
Steven Schweda
Honored Contributor

Re: C Code Returning Unreadable File ID String

> The C code below [...]

Uh, comments which have a "C" in column one
are not usually described as "C code".
John Gillings
Honored Contributor
Solution

Re: C Code Returning Unreadable File ID String

This looks more like FORTRAN then C to me.

Maybe you could post an example with your formatting code? Put hardcoded values into the FID fields for illustration.

Here's an example in MACRO32 showing how to format a FID from a NAM block.

.TITLE FormatFid
.PSECT data,RD,WRT,NOEXE
$NAMDEF
MyNAM: $NAM

BinFid: .WORD 14426 ; FID (79962,17,0)
.WORD 17
.BYTE 0
.BYTE 1

outstr: .ASCID /12345678901234567890/
fmtstr: .ASCID /(!UL,!UW,!UB)/
.PSECT code,RD,NOWRT,EXE
.ENTRY start,^M

; first set up the NAM block with our canned FID
MOVC3 #NAM$S_FID,BinFid,MyNAM+NAM$R_FID_FIELDS

; Calculate NUM from FID_NUM and FID_NMX
MOVZBL MyNAM+NAM$B_FID_NMX,R2
ASHL #16,R2,R2
MOVW MyNAM+NAM$W_FID_NUM,R2

$FAO_S ctrstr=fmtstr outlen=outstr outbuf=outstr -
p1=R2 p2=MyNAM+NAM$W_FID_SEQ p3=MyNAM+NAM$B_FID_RVN

; display result
PUSHAB outstr
CALLS #1,G^LIB$PUT_OUTPUT
RET
.END start
A crucible of informative mistakes
Steven Schweda
Honored Contributor

Re: C Code Returning Unreadable File ID String

> This looks more like FORTRAN then C to me.

But look at all those C's!

(You're no fun.)
labadie_1
Honored Contributor

Re: C Code Returning Unreadable File ID String

Steven

Thanks for the good laugh !
Robert Atkinson
Respected Contributor

Re: C Code Returning Unreadable File ID String

Sorry Guys - I'd got a mental block and purely assumed it was written in 'C'.

I've attached the original code, taken from http://vms.process.com/scripts/fileserv/fileserv.com?EXECSYMB

There's actually a section in the code which says :-

C
C Item conversion information
C
C Each item has an item name, the length of the name, and an item
C conversion type, used for converting the item value to ASCII for
C streams requiring ASCII-format item values. The following table
C lists the possible item types:
C type meaning
C ---- -------
C 1 No translation (already ASCII, or item not easily
C translated to ASCII, so left in original form)
C 2 Binary longword, converted to hexadecimal in the
C format "%Xnnnnnnnn"
C 3 Date and time, converted to dd-mmm-yyyy hh:mm:ss.cc
C format (with one space between date and time)
C 4 UIC, converted to [gggggg,mmmmmm] format with octal
C group and member numbers containing leading zeroes.
C 5 Bitstring, converted to a list of which bits are
C set. Up to 16 bytes of data can be included in the
C item (since the CHARACTERISTICS item is 16 bytes long.)
C The list is a series of decimal numbers separated by
C commas (e.g. hex 641 becomes "0,6,9,10")
C


Perhaps it's simply a case of defining FILEID as a type '5'? :-

DATA SMBITEM(SMBMSG$K_FILE_IDENTIFICATION) /'FILE_IDENTIFICATION'/
DATA SMBITEMLEN(SMBMSG$K_FILE_IDENTIFICATION) /19/
DATA SMBITEMTYPE(SMBMSG$K_FILE_IDENTIFICATION) /1/


Rob.
Volker Halle
Honored Contributor

Re: C Code Returning Unreadable File ID String

Rob,

the item type of the file specification is probably defaulted to '1', because that binary data can not easily be converted to an ASCII string.

There is a LIB$FID_TO_NAME RTL routine, which could help in this regard. There is a C example of using this routine on the V8 freeware CD.

Volker.
Volker Halle
Honored Contributor

Re: C Code Returning Unreadable File ID String

Rob,

you would need to improve the ITEMEDIT subroutine to accept a new item type (e.g. 6), which would represent the FILE_IDENTIFICATION binary string and then enhance that routine to convert this type of item to a readable ASCII string.

Volker.