<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Stream_LF file shared access using standard I/O functions in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584044#M6596</link>
    <description>Antonio,&lt;BR /&gt;&lt;BR /&gt;I guess the default is taken from the file and the file is already stream_lf. This would modify it to stream and add terminators cr and ff.&lt;BR /&gt;&lt;BR /&gt;Wim</description>
    <pubDate>Mon, 18 Jul 2005 01:02:56 GMT</pubDate>
    <dc:creator>Wim Van den Wyngaert</dc:creator>
    <dc:date>2005-07-18T01:02:56Z</dc:date>
    <item>
      <title>Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584036#M6588</link>
      <description>Hi,&lt;BR /&gt;I have following problem:&lt;BR /&gt;I have several processes writing to one file. Writes are guarded with exclusive mutex. The program looks like:&lt;BR /&gt;const int MAX_MRS = 10000;&lt;BR /&gt;FILE *fd = fopen(fname, "a+b", "ctx=rec", "shr=get,put");&lt;BR /&gt;...&lt;BR /&gt;for(;;)&lt;BR /&gt;{&lt;BR /&gt;  ....&lt;BR /&gt;  mutex.Enter();&lt;BR /&gt;  fseek(fa, 0, SEEK_END);&lt;BR /&gt;  if(bufsize &amp;gt; MAX_MRS)&lt;BR /&gt;    write by MAX_MRS blocks using fwrite;&lt;BR /&gt;  else&lt;BR /&gt;    fwrite(buffer, bufsize, 1, fd);&lt;BR /&gt;  fsync(fileno(fd));&lt;BR /&gt;  mutex.Leave();&lt;BR /&gt;  ...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Creating file in this way I get with dir/full:&lt;BR /&gt;...&lt;BR /&gt;Linkcount:  1&lt;BR /&gt;File organization:  Sequential&lt;BR /&gt;Shelved state:      Online&lt;BR /&gt;Caching attribute:  Writethrough&lt;BR /&gt;File attributes:    Allocation: 15390, Extend: 0, Global buffer count: 0, No version limit&lt;BR /&gt;Record format:      Stream_LF, maximum 0 bytes, longest 10000 bytes&lt;BR /&gt;Record attributes:  Carriage return carriage control&lt;BR /&gt;RMS attributes:     None&lt;BR /&gt;Journaling enabled: None&lt;BR /&gt;File protection:    System:RWED, Owner:RWE, Group:, World:&lt;BR /&gt;Access Cntrl List:  (IDENTIFIER=JUP_TEST1,ACCESS=READ+WRITE+DELETE+CONTROL)&lt;BR /&gt;                    (IDENTIFIER=JUP_TRAINING,ACCESS=READ+WRITE+DELETE+CONTROL)&lt;BR /&gt;Client attributes:  None&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;After that, when I use this file I expect that all records (saved with fwrite call) must be followed by LF, but it is not true. Some of them (very small amount) not!!&lt;BR /&gt;&lt;BR /&gt;Can somebody explain me what I am doing wrong.&lt;BR /&gt;Thank you&lt;BR /&gt;Sergejus</description>
      <pubDate>Sun, 17 Jul 2005 00:29:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584036#M6588</guid>
      <dc:creator>Sergejus Zabinskis</dc:creator>
      <dc:date>2005-07-17T00:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584037#M6589</link>
      <description>Hi Sergejous,&lt;BR /&gt;before of all, Welcome to VMS forum :-)&lt;BR /&gt; &lt;BR /&gt;A little quote: fseek use fa pointer not fd; I think it's typo. Also fsync().&lt;BR /&gt; &lt;BR /&gt;Now&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;I expect that all records (saved with fwrite call) must be followed by LF&lt;BR /&gt;&lt;/QUOTE&gt;&lt;BR /&gt;Why?&lt;BR /&gt;You open file in append binary mode (a+b). Binary mode tells to runtime "write record as is". And fwrite writes # items of declared len onto output file without formatting. Is there, at end of buffer the LF?&lt;BR /&gt;I'm not sure I get your real intention. Usually LF means end of line. If you want add EOL you have to open file in append standard mode and use fprintf function. In this way runtime add CR+LF at end of line. If you want to add only LF, open file a+b, and use &lt;BR /&gt;fprintf (fd, "%s\x000A",buffer);&lt;BR /&gt;I hope understand what you want to do.&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 17 Jul 2005 01:49:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584037#M6589</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-17T01:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584038#M6590</link>
      <description>Thanks for response, Antonio.&lt;BR /&gt;I agree with you that writing to file in binary mode doesn't append anything. This is binary mode "definition". But I say what I see.&lt;BR /&gt;I calculate file size before writing and after and I notice that file grows additionally with 1 byte for each fwrite call.&lt;BR /&gt;Then I open this file as:&lt;BR /&gt;FILE *fa = fopen(fname, "rb", "shr=get,put");&lt;BR /&gt;and see that this additional byte is LF = 10.&lt;BR /&gt;Sergejus</description>
      <pubDate>Sun, 17 Jul 2005 02:35:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584038#M6590</guid>
      <dc:creator>Sergejus Zabinskis</dc:creator>
      <dc:date>2005-07-17T02:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584039#M6591</link>
      <description>Hi Sergejus,&lt;BR /&gt;I didn't read carefully your question, so I didn't see fopen() function.&lt;BR /&gt;You use DEC CC extention of fopen. However, readind cc help and HP documentation I understand what you want to do.&lt;BR /&gt; &lt;BR /&gt;FILE *fd=fopen(fname, "a+b", "ctx=rec", "shr=get,put");&lt;BR /&gt;where&lt;BR /&gt;ctx=rec means you write per record, overriding binary declaration; see here for detailed information &lt;A href="http://h71000.www7.hp.com/commercial/c/docs/5763pro_024.html#fab_rab_keywords_1" target="_blank"&gt;http://h71000.www7.hp.com/commercial/c/docs/5763pro_024.html#fab_rab_keywords_1&lt;/A&gt;&lt;BR /&gt;I don't know how these option work. I guess you can use ctx=stm instead or you can declare rfm=stm or rfm=stmlf, but I'm not sure about this.&lt;BR /&gt;Don't forget, run time add LF at end of record even when you write splitted record (bufsiz &amp;gt; MAX_RMS).&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jul 2005 00:15:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584039#M6591</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-18T00:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584040#M6592</link>
      <description>RMS want to see records. You gave binary data and at the end RMS want to see a record terminator (LF). You didn't specify it, so RMS added it. Follow the advice of Antonio.&lt;BR /&gt;&lt;BR /&gt;Wim</description>
      <pubDate>Mon, 18 Jul 2005 00:32:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584040#M6592</guid>
      <dc:creator>Wim Van den Wyngaert</dc:creator>
      <dc:date>2005-07-18T00:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584041#M6593</link>
      <description>Hi again Antonio,&lt;BR /&gt;I can't use "ctx=stm" instead of "ctx=rec", because I get wrong behaviour if several processes are writing to the same file.&lt;BR /&gt;&lt;BR /&gt;At the bottom of the page you sent:&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/commercial/c/docs/5763pro_024.html#fab_rab_keywords_1" target="_blank"&gt;http://h71000.www7.hp.com/commercial/c/docs/5763pro_024.html#fab_rab_keywords_1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;is said (exactly about my situation):&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;You cannot share the default HP C for OpenVMS stream file I/O. If you wish to share files, you must specify "ctx=rec" to force record access mode. You must also specify the appropriate "shr" options depending on the type of access you want. &lt;BR /&gt;&lt;/QUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;Anyway, thank you for your attention.&lt;BR /&gt;Sergejus&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jul 2005 00:36:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584041#M6593</guid>
      <dc:creator>Sergejus Zabinskis</dc:creator>
      <dc:date>2005-07-18T00:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584042#M6594</link>
      <description>Isn't a record in your file the whole file if you don't have LF's ?&lt;BR /&gt;&lt;BR /&gt;Wim</description>
      <pubDate>Mon, 18 Jul 2005 00:49:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584042#M6594</guid>
      <dc:creator>Wim Van den Wyngaert</dc:creator>
      <dc:date>2005-07-18T00:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584043#M6595</link>
      <description>Sergejus,&lt;BR /&gt;perhaps this code can work for you&lt;BR /&gt; &lt;BR /&gt;FILE *fd = fopen(fname, "a+b", "ctx=rec", "rfm=stm", "shr=get,put");&lt;BR /&gt; &lt;BR /&gt;ctx is rec ad HP c runtime require;&lt;BR /&gt;rfm declare stream I/O; you can also declare stmlf (stream with LF).&lt;BR /&gt;As I posted, I never used DECC extension, so I have not direct experience about that.&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jul 2005 00:58:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584043#M6595</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-18T00:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584044#M6596</link>
      <description>Antonio,&lt;BR /&gt;&lt;BR /&gt;I guess the default is taken from the file and the file is already stream_lf. This would modify it to stream and add terminators cr and ff.&lt;BR /&gt;&lt;BR /&gt;Wim</description>
      <pubDate>Mon, 18 Jul 2005 01:02:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584044#M6596</guid>
      <dc:creator>Wim Van den Wyngaert</dc:creator>
      <dc:date>2005-07-18T01:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584045#M6597</link>
      <description>Is the data that you write binary, or just ascii. Specifically, can it have LF byte (value 10) perhaps as part of an integer or float? Such embedded terminator will create a fresh record boundary on future reads.&lt;BR /&gt;&lt;BR /&gt;From the RMS documentation for $PUT to stream_lf: 'If the last byte in the buffer is not a terminator, RMS adds the appropriate terminator'.&lt;BR /&gt;So if the last byte happens to have value 10, then this will become a shorter record as no terminator is addedd.&lt;BR /&gt;&lt;BR /&gt;If you really want binary data then you should consider UDF (User Defined) record format where you know how many bytes to read and write, but RMS sees no struture.&lt;BR /&gt;Or... if the objects all have the same size, then you could/should consider a 'Fixed Length Record file (RFM=FIX).&lt;BR /&gt;&lt;BR /&gt;Finally, if this is not part of a portable solution then you have to ask what value the C RTL add and consider calling RMS directly.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jul 2005 03:41:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584045#M6597</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-07-18T03:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584046#M6598</link>
      <description>Hi,&lt;BR /&gt;Antonio in his earlier post and Hein are absolutely right. Appending LF to the end of each record solves all my problems - I made few experiments and it works.&lt;BR /&gt;Before that I had situation that is described in Hein response. RMS added terminating LF, but due to the large amount of data there was situations when chr(10) from data buffer (not terminator) occured at the end of partial record and during future read it disappeared from data - so I got corrupted data.&lt;BR /&gt;No I append LF to the end of each record - and everything seems OK.&lt;BR /&gt;Many thanks for your kind attention to my problem!!!&lt;BR /&gt;Sergejus</description>
      <pubDate>Mon, 18 Jul 2005 03:56:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584046#M6598</guid>
      <dc:creator>Sergejus Zabinskis</dc:creator>
      <dc:date>2005-07-18T03:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584047#M6599</link>
      <description>About "rfm=fix". Unfortunately, data buffer sizes to save are irregular, so it is not acceptable from disk space viewpoint.&lt;BR /&gt;Thanks once more and bye.&lt;BR /&gt;Sergejus</description>
      <pubDate>Mon, 18 Jul 2005 04:05:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584047#M6599</guid>
      <dc:creator>Sergejus Zabinskis</dc:creator>
      <dc:date>2005-07-18T04:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584048#M6600</link>
      <description>Another warning :&lt;BR /&gt;One of the file types defined by RMS is an RMS-11 stream format file, corresponding to a value of FAB$C_STM for the record format. The definition of this format is such that the RMS record operation SYS$GET removes leading null bytes from each record. Because this file type is processed in record mode by the HP C RTL, it is unsuitable as a file format for binary data unless it is explicitly opened with "ctx=stm", in which case the raw bytes of data from the file are returned. &lt;BR /&gt;&lt;BR /&gt;Wim</description>
      <pubDate>Mon, 18 Jul 2005 04:48:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584048#M6600</guid>
      <dc:creator>Wim Van den Wyngaert</dc:creator>
      <dc:date>2005-07-18T04:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584049#M6601</link>
      <description>Sergejus,&lt;BR /&gt;happy you solved!&lt;BR /&gt;I'm waiting here for your next question!&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jul 2005 04:49:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584049#M6601</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-07-18T04:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: Stream_LF file shared access using standard I/O functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584050#M6602</link>
      <description>Sergejus, can you assign points to the responses you have recieved. See&lt;BR /&gt;&lt;A href="http://forums2.itrc.hp.com/service/forums/helptips.do?#33" target="_blank"&gt;http://forums2.itrc.hp.com/service/forums/helptips.do?#33&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;for an explaination.</description>
      <pubDate>Mon, 18 Jul 2005 05:53:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/stream-lf-file-shared-access-using-standard-i-o-functions/m-p/3584050#M6602</guid>
      <dc:creator>Ian Miller.</dc:creator>
      <dc:date>2005-07-18T05:53:54Z</dc:date>
    </item>
  </channel>
</rss>

