Operating System - OpenVMS
1748163 Members
3784 Online
108758 Solutions
New Discussion

Re: How to decide when to use RMS or POSIX stream operation to read file content?

 
Dmitriy_21
Advisor

How to decide when to use RMS or POSIX stream operation to read file content?

Hi

 

I am having issue reading files from C-program using RMS call sys$get when RAB buffer size is 32767 bytes and file information report that max record size is 32767 bytes.

 

For example this file:

 

$ dir /fu SYS$SYSDEVICE:[SYS0.SYSCOMMON.SYSFONT.DECW.100DPI]TERMINAL_BOLD36_100DPI.PCF

Directory SYS$SYSDEVICE:[SYS0.SYSCOMMON.SYSFONT.DECW.100DPI]

TERMINAL_BOLD36_100DPI.PCF;1              File ID:  (594,1,0)             
Size:           91/96         Owner:    [SYSTEM]
Created:    30-AUG-2007 11:35:01.48
Revised:    30-AUG-2007 11:35:01.49 (1)

....
Linkcount:  1
File organization:  Sequential
Shelved state:      Online
Caching attribute:  Writethrough
File attributes:    Allocation: 96, Extend: 0, Global buffer count: 0
                    No version limit
Record format:      Stream_LF, maximum 0 bytes, longest 32767 bytes
Record attributes:  Carriage return carriage control
RMS attributes:     None
Journaling enabled: None
File protection:    System:RWED, Owner:RWED, Group:RE, World:RE
Access Cntrl List:  None
Client attributes:  None

Total of 1 file, 91/96 blocks.

When I am reading this file, i am getting error RMS$_RTB and rab$l_stv shows 41070 bytes.

 

I guess, this and other files with a similar error are just a binary files.

I could try to read them using fopen/fread but I need to know this up-front and before I start reading data; not after sys$get call failed.

 

Is there is a way to tell if file is really a binary file?

 

Thanks

6 REPLIES 6
B Claremont
Frequent Advisor

Re: How to decide when to use RMS or POSIX stream operation to read file content?

Take a look at the arguments for F$FILE_ATTRIBUTES.  RAT, RFM, and ORG come to mind as options that might help narrow down a file type.

 

If by binary file you mean an executable image, the file extension (.exe) is a clue, although not a guaranty.  Some of the ANALYZE file options might also be useful.

www.MigrationSpecialties.com
Dmitriy_21
Advisor

Re: How to decide when to use RMS or POSIX stream operation to read file content?

Thanks for your replay.

I did check all the attributes, but I don't think it will help in all case.
It would be nice if all the files are created with appropriate attributes.

The disturbing thing is, the OS installed files has inconsistent attributes too (SYS$SYSDEVICE:[SYS0.SYSCOMMON.SYSFONT.DECW.100DPI]TERMINAL_BOLD36_100DPI.PCF).

I am wondering if combination of attribute's values can help.

For example, for above file, the LRL (Longest record length) shows 32767, and MRS (Maximum record size) is 0.
While reading, one of the records is 41070 bytes long (much longer than 32767).
abrsvc
Respected Contributor

Re: How to decide when to use RMS or POSIX stream operation to read file content?

One thing I noticed is that the file has records with a CR terminator. What are you using as the record terminator? I would guess that the 41070 byte record contains a CR somewhere before the 32767 point.

Dan
Dmitriy_21
Advisor

Re: How to decide when to use RMS or POSIX stream operation to read file content?

The file in question was created by OS installation and based on file information it should use LF as a field separator.
The file must be created with fixed records attribute in a first place and it is outside by control.
GuentherF
Trusted Contributor

Re: How to decide when to use RMS or POSIX stream operation to read file content?

RMS record I/O using SYS$GET can only handle a maximum record size of 32767 bytes...as you found out.

 

Either use Unix I/O functions i.e. open without parameter "rfm=..." or, open the file with RMS specifying UFO in the FAB and access the file with SYS$QIO[W].

 

Btw, the "Carriage return carriage control" means if RMS ouputs records to a printing device (i.e. terminal) each record should have a CR/LF added. The "Carriage return" is NOT stored in the file.

 

/Guenther

H.Becker
Honored Contributor

Re: How to decide when to use RMS or POSIX stream operation to read file content?

>>>The file in question was created by OS installation and based on file information it should use LF as a field separator.


The file was only copied to your system by the OS installation. The file very likely was created by a C program running on VMS which by default creates a file with stmlf (and LRL=32737 and MRS=0). Whether the C program wrote a record structure at all is questionable. I'm not familiar with these font files, but you may find more info on the format at http://fontforge.org/pcf-format.html.
 
I would set it to (rfm=)udf, because:
 
$ pipe dump TERMINAL_BOLD36_100DPI.PCF/rec |search sys$pipe "Record number "
Record number 1 (00000001), 372 (0174) bytes, RFA(0001,0000,0000)
Record number 2 (00000002), 587 (024B) bytes, RFA(0001,0000,0175)
Record number 3 (00000003), 15 (000F) bytes, RFA(0002,0000,01C1)
Record number 4 (00000004), 11 (000B) bytes, RFA(0002,0000,01D1)
Record number 5 (00000005), 23 (0017) bytes, RFA(0002,0000,01DD)
Record number 6 (00000006), 1076 (0434) bytes, RFA(0002,0000,01F5)
Record number 7 (00000007), 3 (0003) bytes, RFA(0005,0000,002A)
$ set fil/attr=rfm=stmcr TERMINAL_BOLD36_100DPI.PCF
$ pipe dump TERMINAL_BOLD36_100DPI.PCF/rec |search sys$pipe "Record number "
Record number 1 (00000001), 2105 (0839) bytes, RFA(0001,0000,0000)
$ set fil/attr=rfm=stm TERMINAL_BOLD36_100DPI.PCF
$ pipe dump TERMINAL_BOLD36_100DPI.PCF/rec |search sys$pipe "Record number "
Record number 1 (00000001), 373 (0175) bytes, RFA(0001,0000,0000)
Record number 2 (00000002), 585 (0249) bytes, RFA(0001,0000,0175)
Record number 3 (00000003), 7 (0007) bytes, RFA(0002,0000,01C1)
Record number 4 (00000004), 7 (0007) bytes, RFA(0002,0000,01D1)
Record number 5 (00000005), 9 (0009) bytes, RFA(0002,0000,01DD)
Record number 6 (00000006), 7 (0007) bytes, RFA(0002,0000,01ED)
Record number 7 (00000007), 1046 (0416) bytes, RFA(0002,0000,01F5)
Record number 8 (00000008), 2 (0002) bytes, RFA(0005,0000,002A)
Record number 9 (00000009), 2 (0002) bytes, RFA(0005,0000,002E)
Record number 10 (0000000A), 2 (0002) bytes, RFA(0005,0000,0032)
$ set fil/attr=rfm=udf TERMINAL_BOLD36_100DPI.PCF
$ pipe dump TERMINAL_BOLD36_100DPI.PCF/rec |search sys$pipe "Record number "
Record number 1 (00000001), 32767 (7FFF) bytes, RFA(0001,0000,0000)
Record number 2 (00000002), 13461 (3495) bytes, RFA(0040,0000,01FF)
$ 
 
no stream format will enable RMS to read the whole file: with any of the possible stream delimiters there is always one record which is too long. Also, with the possibility that this is a binary file, reading a record will strip the record delimiter. That's very likely not what you want.
 
With udf you should be able to read the file with RMS record and CRTL stream I/O.
 
I don't understand your comment on "fixed records attributes".