T.R | Title | User | Personal Name | Date | Lines |
---|
2202.1 | Options... | XDELTA::HOFFMAN | Steve, OpenVMS Engineering | Wed May 28 1997 16:04 | 28 |
| :...
: The question is can the version number of the open file be
: determined using DEC C run time library calls? I know how to
: obtain the information using SYS$PARSE but it is desirable to
: use DEC C RTL calls where possible in the application I am
: writing.
Not in a portable program -- the run-time library provides a portable
interface, and version numbers are a feature specific to the file
structures used by OpenVMS and a few other operating systems.
Most (all?) UNIX file systems lack a version number construct.
There are non-portable ways, however... One can use the "acc"
keyword on the open() call to gain access to the FAB and RAB,
and from there one can gain access to all manner of information
on the file.
There are also ways to open an existing file, or -- if a file
is not found -- create a new version, if that is the goal...
: Can the DEC C RTL system function be used in an exit handler
: which has been established with the DEC C RTL atexit function
: call?
I would see no reason not -- I assume there is a question or a
problem seen here, as it would take ten minutes to create a test
program to verify this...
|
2202.2 | getname(file_descr) or getname(fileno(file_pointer)) | TLE::BORIS | Boris Gubenko, DEC C RTL | Wed May 28 1997 17:59 | 48 |
| >
> The question is can the version number of the open file be
> determined using DEC C run time library calls? I know how to
> obtain the information using SYS$PARSE but it is desirable to
> use DEC C RTL calls where possible in the application I am
> writing.
getname() function is, probably, what you're looking for:
CC
Run-time_functions
getname
Returns the file specification associated with a file descriptor.
Syntax:
#include <unixio.h>
char *getname(int file_descriptor, char *buffer,...);
where the ... is an optional argument that can be either 1 or 0.
If you specify 1, getname returns the directory specification in
OpenVMS format. If you specify 0, getname returns the directory
specification (path name) in UNIX style format. If you do not
specify this argument, getname returns the file name according to
your current command-language interpreter.
>
> Can the DEC C RTL system function be used in an exit handler
> which has been established with the DEC C RTL atexit function
> call?
>
As Steve mentioned in .1, there is no obvious reason not. The system()
routine is based on LIB$SPAWN(WAIT) call and utilities structures
maintained by the CRTL to describe processes created by vfork(), exec*()
and system() routines.
The exit handler established by CRTL itself analyzes these structures
and kills all child processes found. Because this handler will be invoked
*after* the handler established by the atexit() function, there shouldn't
be any problem.
Boris
|
2202.3 | also strchr(), sorry | TLE::BORIS | Boris Gubenko, DEC C RTL | Wed May 28 1997 18:19 | 26 |
| I forgot to mention in my previous reply, that you need to locate a ';'
character in the string returned by getname() if you're interested only
in file's version. Try example below.
Boris
x.c
===
#include <stdio.h>
#include <string.h>
#include <unixio.h>
main()
{
char s[256], *p;
FILE *fp = fopen( __FILE__ , "r");
if ( fp ) {
if ( getname(fileno(fp), s, 1) ) {
puts(s);
if ( (p = strchr(s,';')) )
puts(++p);
}
}
}
|
2202.4 | Beware Of Home-Grown File Parsing... | XDELTA::HOFFMAN | Steve, OpenVMS Engineering | Thu May 29 1997 10:47 | 14 |
|
: I forgot to mention in my previous reply, that you need to locate a ';'
: character in the string returned by getname() if you're interested only
: in file's version. Try example below.
I would recommend using the FAB and RAB mechanism and sys$parse.
(We (OpenVMS) really need to implement this in an RTL somewhere.)
I would tend to avoid parsing the file specification when possible,
and would prefer to pass it to RMS for parsing.
(Among other reasons: we are extending the character set permitted
in certain file naming sitations. We already allow the use of "."
as a version seperator -- though getname() might prefer to return
";" over "." as the seperator.)
|
2202.5 | thanks! | CSC32::I_WALDO | | Thu May 29 1997 13:01 | 1 |
| Thanks for the answers! I learn stuff everyday.
|