[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | VAX and Alpha VMS |
Notice: | This is a new VMSnotes, please read note 2.1 |
Moderator: | VAXAXP::BERNARDO |
|
Created: | Wed Jan 22 1997 |
Last Modified: | Fri Jun 06 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 703 |
Total number of notes: | 3722 |
121.0. "LIB$FIND_FILE with a default spec returns files more than once" by OPCO::TSG_PLL (Live and Sweaty) Thu Jan 30 1997 22:17
Folks,
I am trying to use LIB$FIND_FILE to expand a wildcard filespec that will be
input by a user. I also want to provide a default spec. If the default spec is
something like SYS$LOGIN:LOGIN.COM then all is fine. If the default spec is
SYS$MANAGER:LOGIN.COM and I supply a wildcard filespec then each file that
satisfies the wildcard spec is returned twice. If the default spec is
SYS$STARTUP:LOGIN.COM then each file is returned four times.
What am I doing wrong? Each filespec returned by the call of LIB$FIND_FILE
is then processed and I really only want to process each file once, so how do I
persuade LIB$FIND_FILE to give me each file spec once?
I have tried the following code on OpenVMS V6.2 Alpha and VAX as well as
OpenVMS V7.1 Alpha. The DECC compiler version is V5.3-006 in all cases. If
have also use C++ V5.5 with the same result.
Thanks in advance
Paul
(14:13) $ set verify
(14:13) $ cc/vers nl:
DEC C V5.3-006 on OpenVMS Alpha V7.1
(14:13) $ cc test
(14:13) $ link test
(14:13) $ run test
LIB$FIND_FILE returns TSG_ROOT:[TSG_PLL]LOGIN.COM;19
LIB$FIND_FILE returns TSG_ROOT:[TSG_PLL]LOGIN.COM;19
(14:13) $ dir sys$login:login*
Directory TSG_ROOT:[TSG_PLL]
LOGIN.COM;19 LOGIN.COM;18 LOGIN.COM;17
Total of 3 files.
(14:13) $ type test.c
// TEST.C
//
#include descrip
#include stdio
#include ints
#include lib$routines
#include rmsdef
#include string
main (int argc, char *argv[])
{
struct dsc$descriptor next_file;
int32 status;
uint32 find_context=0, rms_status, find_flags=2;
$DESCRIPTOR (infile_name,"sys$login:login*");
$DESCRIPTOR (default_spec, "sys$manager:login.com");
char temp[256];
char next_file_buff[256];
next_file.dsc$w_length=255;
next_file.dsc$b_dtype=DSC$K_DTYPE_T;
next_file.dsc$b_class=DSC$K_CLASS_S;
next_file.dsc$a_pointer = next_file_buff;
while (RMS$_NORMAL == lib$find_file(&infile_name,
&next_file,
&find_context,
&default_spec,
0,
&rms_status,
&find_flags)) {
strncpy (temp, next_file.dsc$a_pointer, next_file.dsc$w_length);
temp[next_file.dsc$w_length] = '\0';
printf("LIB$FIND_FILE returns %s\n", temp);
}
lib$find_file_end(&find_context);
}
T.R | Title | User | Personal Name | Date | Lines |
---|
121.1 | search lists | GIDDAY::GILLINGS | a crucible of informative mistakes | Fri Jan 31 1997 01:01 | 11 |
| Paul,
SYS$MANAGER is a search list which leads to 2 directories, SYS$STARTUP
leads to 4. RMS defaulting rules result in the file being found multiple
times. There's a "good" reason why it works like this, but the behavior
can cause problems under some circumstances (such as an apparently infinite
loop when linking).
There's not a lot you can do about it short of avoiding search list
logical names in default filespecs.
John Gillings, Sydney CSC
|
121.2 | | AUSS::GARSON | DECcharity Program Office | Mon Feb 03 1997 16:37 | 5 |
| re .0
Also, forget your code. DIRECTORY does exactly the same thing. It's
expected, if annoying, behaviour and I think the "good" reason for it is
lost in the mists of time.
|