(x-invocation-args): Add defvar.
[emacs.git] / lib-src / etags-vmslib.c
blob5d501682055cb778a8459f58585e0fd63037251b
1 /* File name wild card expansion for VMS.
2 This file is part of the etags program.
3 Copyright (C) 1987 Free Software Foundation, Inc. 3 Feb 1987
5 This program is distributed in the hope that it will be useful,
6 but without any warranty. No author or distributor
7 accepts responsibility to anyone for the consequences of using it
8 or for whether it serves any particular purpose or works at all,
9 unless he says so in writing.
11 Permission is granted to anyone to distribute verbatim copies
12 of this program's source code as received, in any medium, provided that
13 the copyright notice, the nonwarraty notice above
14 and this permission notice are preserved,
15 and that the distributor grants the recipient all rights
16 for further redistribution as permitted by this notice,
17 and informs him of these rights.
19 Permission is granted to distribute modified versions of this
20 program's source code, or of portions of it, under the above
21 conditions, plus the conditions that all changed files carry
22 prominent notices stating who last changed them and that the
23 derived material, including anything packaged together with it and
24 conceptually functioning as a modification of it rather than an
25 application of it, is in its entirety subject to a permission
26 notice identical to this one.
28 Permission is granted to distribute this program (verbatim or
29 as modified) in compiled or executable form, provided verbatim
30 redistribution is permitted as stated above for source code, and
31 A. it is accompanied by the corresponding machine-readable
32 source code, under the above conditions, or
33 B. it is accompanied by a written offer, with no time limit,
34 to distribute the corresponding machine-readable source code,
35 under the above conditions, to any one, in return for reimbursement
36 of the cost of distribution. Verbatim redistribution of the
37 written offer must be permitted. Or,
38 C. it is distributed by someone who received only the
39 compiled or executable form, and is accompanied by a copy of the
40 written offer of source code which he received along with it.
42 Permission is granted to distribute this program (verbatim or as modified)
43 in executable form as part of a larger system provided that the source
44 code for this program, including any modifications used,
45 is also distributed or offered as stated in the preceding paragraph.
47 In other words, you are welcome to use, share and improve this program.
48 You are forbidden to forbid anyone else to use, share and improve
49 what you give them. Help stamp out software-hoarding! */
51 #include <stdio.h>
52 typedef char tbool;
54 /* This is a BUG! ANY arbitrary limit is a BUG!
55 Won't someone please fix this? */
56 #define MAX_FILE_SPEC_LEN 255
57 typedef struct {
58 short curlen;
59 char body[MAX_FILE_SPEC_LEN + 1];
60 } vspec;
61 #define EOS '\0'
62 #define NO 0
63 #define YES 1
64 #define NULL 0
66 /* v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
67 name of each file specified by all the remaining args in the command-line
68 expanding wild cards and
69 stepping over arguments when they have been processed completely
71 char*
72 gfnames(pac, pav, p_error)
73 int *pac;
74 char **pav[];
75 tbool *p_error;
77 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
78 short fn_exp();
80 while (1)
81 if (*pac == 0)
83 *p_error = NO;
84 return(NULL);
86 else switch(fn_exp(&filename, **pav))
88 case 1:
89 *p_error = NO;
90 return(filename.body);
91 break;
92 case 0:
93 --*pac;
94 ++*pav;
95 break;
96 default:
97 *p_error = YES;
98 return(filename.body);
99 break;
104 /* v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
105 returning in each successive call the next filename matching the input
106 spec. The function expects that each in_spec passed
107 to it will be processed to completion; in particular, up to and
108 including the call following that in which the last matching name
109 is returned, the function ignores the value of in_spec, and will
110 only start processing a new spec with the following call.
111 If an error occurs, on return out_spec contains the value
112 of in_spec when the error occurred.
114 With each successive filename returned in out_spec, the
115 function's return value is one. When there are no more matching
116 names the function returns zero. If on the first call no file
117 matches in_spec, or there is any other error, -1 is returned.
120 #include <rmsdef.h>
121 #include <descrip.h>
122 #define OUTSIZE MAX_FILE_SPEC_LEN
123 short
124 fn_exp(out, in)
125 vspec *out;
126 char *in;
128 static long context = 0;
129 static struct dsc$descriptor_s o;
130 static struct dsc$descriptor_s i;
131 static tbool pass1 = YES;
132 long status;
133 short retval;
135 if (pass1)
137 pass1 = NO;
138 o.dsc$a_pointer = (char *) out;
139 o.dsc$w_length = (short)OUTSIZE;
140 i.dsc$a_pointer = in;
141 i.dsc$w_length = (short)strlen(in);
142 i.dsc$b_dtype = DSC$K_DTYPE_T;
143 i.dsc$b_class = DSC$K_CLASS_S;
144 o.dsc$b_dtype = DSC$K_DTYPE_VT;
145 o.dsc$b_class = DSC$K_CLASS_VS;
147 if ( (status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
149 out->body[out->curlen] = EOS;
150 return(1);
152 else if (status == RMS$_NMF)
153 retval = 0;
154 else
156 strcpy(out->body, in);
157 retval = -1;
159 lib$find_file_end(&context);
160 pass1 = YES;
161 return(retval);
164 #ifndef OLD /* Newer versions of VMS do provide `system'. */
165 system(cmd)
166 char *cmd;
168 fprintf(stderr, "system() function not implemented under VMS\n");
170 #endif
172 #define VERSION_DELIM ';'
173 char *massage_name(s)
174 char *s;
176 char *start = s;
178 for ( ; *s; s++)
179 if (*s == VERSION_DELIM)
181 *s = EOS;
182 break;
184 else
185 *s = tolower(*s);
186 return(start);