- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- File Pointers
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 01:54 AM
тАО07-27-2005 01:54 AM
1) I declare 2 file pointers -
FILE *fp1, *fp2;
2) Using 'fp1' I open a file for reading in binary mode -
fp1=fopen("test","rb");
3) I use 'fp2' to point to same memory what fp1 is pointing to -
fp2=fp1;
4) Using 'fp2' I read a record from the file 'test' using a structure -
fread(&rec,sizeof(struct st),1,fp2);
Question -
What is the impact on pointer 'fp1' after step #4 is executed? Where will 'fp1' point to?
My Observation -
After step #4 is executed, 'fp2' should be at the end of 1st record that is read. and since 'fp1' is never used it should still be pointing to the beginning of the file. but it does not work that way. what i find is though 'fp1' is not used, it too is at the end of the 1st record along with 'fp2'.
i want 'fp1' to remain at the beginning of the file untill i position it. is this something that i could achieve? pl help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 02:07 AM
тАО07-27-2005 02:07 AM
Re: File Pointers
Since something of the type FILE * is a pointer to something (in this case an object of the opaque type FILE), it is only natural that if an operation changes something in that object, both pointers to the same object reflect those changes.
You might want to read on the functions fseek() and ftell(); these can be used to (re)position the read/write marker in a file.
Regards,
Kris (aka Qkcl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 02:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 10:01 AM
тАО07-27-2005 10:01 AM
Re: File Pointers
Opening the file twice will do what you want. HOWEVER, you need to open the file with shared access. The two opens from the same process are seen in the same way as opens from multiple processes - hence shared access is required.
If you used RMS I/O you could OPEN the file once and CONNECT multiple streams. This would allow you to maintain multiple pointers into the file, but with exclusive access. Native C I/O doesn't have a way to access multiple RMS streams (BASIC and COBOL do).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 05:11 PM
тАО07-27-2005 05:11 PM
Re: File Pointers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 05:40 PM
тАО07-27-2005 05:40 PM
Re: File Pointers
There are a number of examples in SYS$EXAMPLES showing various
features of RMS.
The documentation can be found by following the link at the
bottom of the main page for this forum.
http://h71000.www7.hp.com/doc/index.html
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 05:44 PM
тАО07-27-2005 05:44 PM
Re: File Pointers
The RMS reference manual is at
http://h71000.www7.hp.com/doc/731FINAL/4523/4523PRO.HTML
which covers all the services and has various
examples, some in C.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 06:47 PM
тАО07-27-2005 06:47 PM
Re: File Pointers
RMS programming is not simple and (in this case) can't help.
Neither fopen(), neither fread() of standard c-runtime doesn't lock record.
Using of RMS is useful to manage indexed files, not binary/stream flushes.
Full working example is attached.
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:05 PM
тАО07-27-2005 07:05 PM
Re: File Pointers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:09 PM
тАО07-27-2005 07:09 PM
Re: File Pointers
will list all the C programs.
$ type/page sys$examples:alpha_logger.c
will list alpha_logger.c
You may find it easier to look at the examples
in the documentation.
Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:09 PM
тАО07-27-2005 07:09 PM
Re: File Pointers
SYS$EXAMPLES is a logical name; you can think to this like a mapped disk of windows. You can simply type
DIR SYS$EXAMPLES:*.C
However, I don't think you can solve your dubt.
Would you see some RMS source code?
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:11 PM
тАО07-27-2005 07:11 PM
Re: File Pointers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:23 PM
тАО07-27-2005 07:23 PM
Re: File Pointers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:41 PM
тАО07-27-2005 07:41 PM
Re: File Pointers
are there any special considerations while using those functions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:48 PM
тАО07-27-2005 07:48 PM
Re: File Pointers
attached file is source for RMS files manager I use for some years.
Sorry, remarks are in Italian language, because I use it for personal purpose.
Function are like stdio file function. For example, file pointer is declared by
XFILE *fp;
---------------------------------
Function are:
fp = xopen(filename, mode);
open a RMS file; mode may be r,w,b,a that means Read only, Write only, Both (read & write), Append.
File pointer is null RMS file can't be opened.
xclose(fp);
close a RMS file.
buf_prt = xread (buf_ptr, key_str_ptr, index, max_bytes, fp);
read a record from file opened by xopen with exact key. Main index is 0. If function can't read, returns null.
buf_prt = xseek (buf_ptr, key_str_ptr, index, max_bytes, fp);
read a record from file opened by xopen with key greater of equal. Main index is 0. If function can't read, returns null.
buf_prt = xnext (buf_ptr, fp);
read a next record after xread o xseek.If function can't read, returns null.
bytes = xwrite (buf_ptr, max_bytes, fp);
write a new record into file opened by xopen.
bytes = xrewrite (buf_ptr, max_bytes, fp);
rewrite a record after xread.
BOOL = xdelete (fp);
delete current record after xread.
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 07:52 PM
тАО07-27-2005 07:52 PM
Re: File Pointers
here there is xfile.h to compile previous file.
I forgot some other functions:
settmo (fp, timeout);
set time-out when read locked record.
setlmode (fp, mode);
set lock mode; mode may be r for Read (record is not locked by xread o xseek) or w for Write (record is locked).
errc = xerror (fp);
return last error code.
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 08:24 PM
тАО07-27-2005 08:24 PM
Re: File Pointers
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 08:58 PM
тАО07-27-2005 08:58 PM
Re: File Pointers
how can I made it?
Have I translate remarks?
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 09:08 PM
тАО07-27-2005 09:08 PM
Re: File Pointers
Thanks for the source. I need to look at those files at leisure as they seem to be complex :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 09:54 PM
тАО07-27-2005 09:54 PM
Re: File Pointers
http://www.process.com/openvms/index.html
for more info on fileserv. email Hunter Goatley (address on that web page) as he is very helpful and will explain packaging requirements.
For VMS freeware go to
http://h71000.www7.hp.com/openvms/freeware/cd_guide.html
Purely Personal Opinion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2005 08:07 AM
тАО07-28-2005 08:07 AM
Re: File Pointers
>> pxRcb->rab$l_rop = (RAB$M_NLK|RAB$M_RRL); /* Leggi anche locked */
Be sure to read up on th new ( 5 years ? :-) RMS RAB$M_NQL option. This will truly not do any record lock activity as you probably intent. The NLK+RRL will not keep a lock, and read regardless of any existing record lock, but it will take out and release a record lock. This overhead should often be avoided.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 02:37 AM
тАО07-29-2005 02:37 AM
Re: File Pointers
happy to answer you.
The statement you posted can read a RMS record regardless of lock.
It the same of DCL read after open/share=write.
When I want to be sure record is free, I use
xsetlmode(fp,"r") function in the same library I attached.
Antonio Vigliotti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-29-2005 11:38 PM
тАО07-29-2005 11:38 PM
Re: File Pointers
>> The statement you posted can read a RMS record regardless of lock.
Of course.
In my earlier reply I just wanted to point out that, contrary to popular belief, this line will actually cause a VMS lock to be taken and released.
If you use that procedure to read a file with millions of records from begin to end then this will be a significant system overhead.
You can avoid this 'overhead' by also using the newish NQL option.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-31-2005 06:45 PM
тАО07-31-2005 06:45 PM
Re: File Pointers
I also have to say
"sorry for hijacking your thread"
Hein,
interesting,
today I try then I report you the result.
Thank you.
Antonio Vigliotti