No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / grep / src / vms_fab.c
blobf44c52c7f5a2cfc1cf8090043731e64690657e3c
1 /* $NetBSD$ */
3 /*
4 <vms_fab>
6 This macro sets up the file access block and name block for VMS.
7 It also does the initial parsing of the input string (resolving
8 wildcards,
9 if any) and finds all files matching the input pattern.
10 The address of the first matching pattern is returned.
12 Written by Phillip C. Brisco 8/98.
14 #include "vms_fab.h"
16 void
17 vms_fab (int * argp, char **argvp[])
19 extern int optind;
20 int optout;
22 fab = cc$rms_fab;
23 nam = cc$rms_nam;
25 optout = 0;
26 strcpy (fna_buffer, *argvp[optind]);
27 length_of_fna_buffer = NAM$C_MAXRSS;
29 fab.fab$b_bid = FAB$C_BID;
30 fab.fab$b_bln = FAB$C_BLN;
31 fab.fab$l_fop = FAB$M_NAM;
32 fab.fab$l_nam = &nam;
33 fab.fab$l_fna = (char *)&fna_buffer;
34 fab.fab$b_fns = length_of_fna_buffer;
36 nam.nam$b_bid = NAM$C_BID;
37 nam.nam$b_bln = NAM$C_BLN;
38 nam.nam$l_esa = (char *)&expanded_name;
39 nam.nam$b_ess = NAM$C_MAXRSS;
40 nam.nam$l_rsa = (char *)&result_name;
41 nam.nam$b_rss = NAM$C_MAXRSS;
43 fab_stat = sys$parse (&fab);
44 fab_stat = sys$search (&fab);
46 if (fab_stat != 65537)
48 fprintf (stderr, "No Matches found.\n");
49 exit (0);
53 While we find matching patterns, continue searching for more.
55 while (fab_stat == 65537)
58 Allocate memory for the filename
60 arr_ptr[optout] = alloca (max_file_path_size + 1);
62 strcpy (arr_ptr[optout], result_name);
65 If we don't tack on a null character at the end of the
66 filename,
67 we can get partial data which is still there from the last
68 sys$search command.
70 arr_ptr[optout][nam.nam$b_dev +
71 nam.nam$b_dir +
72 nam.nam$b_name +
73 nam.nam$b_type +
74 nam.nam$b_ver] = '\0';
76 fab_stat = sys$search (&fab);
77 optout++;
80 optout--;
82 /* Return a pointer to the beginning of memory that has the expanded
83 filenames.
85 *argp = optout;
86 *argvp = arr_ptr;