Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!mit-eddie!genrad!decvax!minow From: minow@decvax.UUCP (Martin Minow) Newsgroups: comp.lang.c Subject: Re: C ON VMS (file attributes) Message-ID: <79@decvax.UUCP> Date: Sun, 31-May-87 19:52:42 EDT Article-I.D.: decvax.79 Posted: Sun May 31 19:52:42 1987 Date-Received: Tue, 2-Jun-87 02:53:53 EDT References: <7614@brl-adm.ARPA> Reply-To: minow@decvax.UUCP (Martin Minow) Organization: Digital Eq. Corp. - Merrimack NH. Lines: 106 In article <7614@brl-adm.ARPA> ADLER1%BRANDEIS.BITNET@wiscvm.wisc.EDU describes a problem understanding file attributes on VMS, and how they interact with C programs. I apologize for the length of this response, but hope it proves useful. First, I want to make it clear that the following are my opinions and do not represent the position of Dec. >I am having a problem with C on VAX/VMS which I could perhaps solve if the >DEC documentation were reliable, which it is not. I've found the C documentation to be quite reliable and useful. I hope the poster was able to read the entire manual, and the manual version matches the version of C. (These notes refer to the current "V2" version.) >The problem has to do with using C to handle files. To be concrete, consider >a program which prompts the user for a character, a string, a sourcefile >name and a target file name and then copies the source file one character at >a time to the target file except that it replaces every occurrence of the >given ccharacter by the given string. This is a pretty simple program to >write. I've appended an untested version to this posting. >In VMS, it performs strangely. For example, suppose I run the program so >that it should have no effect, say, change every comma to a comma. The >DIFFERENCES command will indicate that the source file and target file are >identical but the target file will no longer be in standard text file format >even if the source file is. This already shows that stdio is not designed >to take the file formatting into account. The output file knows nothing about the input file. One major goal for Vax C for VMS was to simplify porting programs from the Unix (byte-stream) environment to the VMS (record-oriented) environment. To do this, a new file format, "Stream-LF," was added to the file system (RMS), and optional arguments were added to open() (Vax C version 1) and fopen() (version 2). In VMS as a whole, the "standard text file format" is "variable-length, carriage-control", in which each record has a byte count and the "new-line" is implied. Unfortunately, this is impossible to use with any C program that assumes it can seek() to arbitrary positions in the file. > Now suppose you begin with a >file containing a period and run the program to change to period to 10 >periods, then take the resulting file and run the program, again changing >each period to 10 periods, and so on. Very quickly one gets error messages >when one tries to type the resulting files and in some cases I've gotten >error messages just from running the program. Again it has to do with the >formatting of the file. I don't understand -- perhaps a bug in your program? Every VMS error message is unique, and there is a large manual describing each one. The poster then discusses attributes and their sample programs. As I don't have a manual at home, I'll skip this. If I may venture a guess, I would suspect (s)he is describing direct calls to the VMS system services, which is possible, but fairly difficult (also unnecessary). The XABs describe extended file attributes, such as the creation date, protection, and ISAM key attributes. There are a half-dozen XAB's, chained together. Accessing them is moderatly boring, but not too difficult. I learned to do it by reading the documentation. I've never found an error in a sample program in the C documentation, by the way. If you find one, you should use the "reader's comment form" at the end of the manual to communicate it to Dec. >The material in Ch. 13 of the VAX C manual is based on the RMS of VAX/VMS. >Presumably, one can find what one needs to know by reading the RMS manual. >However, I am advised that the RMS manual is itself unreliable. Yes. Yes. You were advised incorrectly. The poster then describes problems getting help. These are not issues for comp.lang.c Following my signature is an uncompiled, untested sketch of the program requested. It should show how to specify "vanilla RMS file attributes." Martin Minow decvax!minow This posting does not represent the position of Digital Equipment Corporation. #include #define SRC_CHAR (argv[1][0]) #define REP_STRING (argv[2]) #define IN_FILE (argv[3]) #define OUT_FILE (argv[4]) main(argc, argv) int argc; char *argv[]; { register int c; freopen(IN_FILE, "r", stdin); /* * Create output file with "standard attributes" */ freopen(OUT_FILE, "w", stdout, "rat=cr", "rfm=var"); while ((c = getchar()) != EOF) { if (c == SRC_CHAR) fputs(REP_STRING, stdout); else { putchar(c); } l, 1f