source: vendor/grep/2.5.1a/src/vms_fab.c

Last change on this file was 2557, checked in by bird, 19 years ago

grep 2.5.1a

File size: 1.9 KB
Line 
1 /*
2 <vms_fab>
3
4 This macro sets up the file access block and name block for VMS.
5 It also does the initial parsing of the input string (resolving
6 wildcards,
7 if any) and finds all files matching the input pattern.
8 The address of the first matching pattern is returned.
9
10 Written by Phillip C. Brisco 8/98.
11 */
12#include "vms_fab.h"
13
14void
15vms_fab (int * argp, char **argvp[])
16{
17 extern int optind;
18 int optout;
19
20 fab = cc$rms_fab;
21 nam = cc$rms_nam;
22
23 optout = 0;
24 strcpy (fna_buffer, *argvp[optind]);
25 length_of_fna_buffer = NAM$C_MAXRSS;
26
27 fab.fab$b_bid = FAB$C_BID;
28 fab.fab$b_bln = FAB$C_BLN;
29 fab.fab$l_fop = FAB$M_NAM;
30 fab.fab$l_nam = &nam;
31 fab.fab$l_fna = (char *)&fna_buffer;
32 fab.fab$b_fns = length_of_fna_buffer;
33
34 nam.nam$b_bid = NAM$C_BID;
35 nam.nam$b_bln = NAM$C_BLN;
36 nam.nam$l_esa = (char *)&expanded_name;
37 nam.nam$b_ess = NAM$C_MAXRSS;
38 nam.nam$l_rsa = (char *)&result_name;
39 nam.nam$b_rss = NAM$C_MAXRSS;
40
41 fab_stat = sys$parse (&fab);
42 fab_stat = sys$search (&fab);
43
44 if (fab_stat != 65537)
45 {
46 fprintf (stderr, "No Matches found.\n");
47 exit (0);
48 }
49
50 /*
51 While we find matching patterns, continue searching for more.
52 */
53 while (fab_stat == 65537)
54 {
55 /*
56 Allocate memory for the filename
57 */
58 arr_ptr[optout] = alloca (max_file_path_size + 1);
59
60 strcpy (arr_ptr[optout], result_name);
61
62 /*
63 If we don't tack on a null character at the end of the
64 filename,
65 we can get partial data which is still there from the last
66 sys$search command.
67 */
68 arr_ptr[optout][nam.nam$b_dev +
69 nam.nam$b_dir +
70 nam.nam$b_name +
71 nam.nam$b_type +
72 nam.nam$b_ver] = '\0';
73
74 fab_stat = sys$search (&fab);
75 optout++;
76 }
77
78 optout--;
79
80 /* Return a pointer to the beginning of memory that has the expanded
81 filenames.
82 */
83 *argp = optout;
84 *argvp = arr_ptr;
85
86}
Note: See TracBrowser for help on using the repository browser.