From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,8eb380beafc3eb3a,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1992-08-20 02:29:04 PST Path: sparky!uunet!mcsun!sun4nl!nikhefh!t68 From: t68@nikhefh.nikhef.nl (Jos Vermaseren) Newsgroups: comp.sys.dec Subject: question about files and C in VMS Message-ID: <1833@nikhefh.nikhef.nl> Date: 20 Aug 92 15:55:57 GMT Organization: Nikhef-H, Amsterdam (the Netherlands). HELP!!!!! I have a problem with C under VMS that has bothered me and many others for a while. It has to do with filepositioning from C programs. I have to port a C program to VMS and the program will read part of a text file into a buffer. Then it may go to another part of the file (or it may not) and at a later stage I want to reposition the file and read the next so many bytes. Originally I got into problems because the read command refused to read more than one line at a time. According to the manual fread, fwrite, fseek and ftell emulate the regular C file operations, so I started using those. Problem: fseek refuses to position in the middle of a line. Solution: read (for instance) 1024 bytes, skip back to the last linefeed, recompute the position and do an fseek to this position. Suddenly this does not work anymore. It appears that the file that is to be used as input came by ftp and is not in the form of lines, but in blocks of 80 characters, no matter what characters they are. Example: fseek(handle,0,SEEK_CUR); /* first time might be superfluous of course */ ftell(handle); --> 0 fread(...,1024,...); fseek(handle,1023,SEEK_SET); /* we have to skip one back */ ftell(handle); --> 1120 ????? fseek(handle,1120,SEEK_SET); fread(...,1024,...); This time it looses the line with 1024 in it. and after the next seek and tell it positions the file at a value which is something like 29000 Other attempt: fseek(handle,0,SEEK_CUR); /* first time might be superfluous of course */ ftell(handle); --> 0 fread(...,1024,...); fseek(handle,0,SEEK_SET); fseek(handle,1023,SEEK_CUR); /* rebuild it from the start */ ftell(handle); --> 14 ????? Now what? Whenever I go to someone who is a local VMS guru I get this look and finally the remark: YESSSSS. This is a famous problem. If you ever find this out, please let me know. So I get the feeling that a: most of these library functions do not do what the manual says they should do. b: nobody ever uses them anyway. Is there a global guru who can help me position my files in a filetype independent way? This would make me very happy. Thanks in advance Jos Vermaseren