annotate lib-src/etags-vmslib.c @ 173:8eaf7971accc r20-3b13

Import from CVS: tag r20-3b13
author cvs
date Mon, 13 Aug 2007 09:49:09 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* File name wild card expansion for VMS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 This file is part of the etags program.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1987 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 along with this program; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 typedef char tbool;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* This is a BUG! ANY arbitrary limit is a BUG!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 Won't someone please fix this? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 #define MAX_FILE_SPEC_LEN 255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 typedef struct {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 short curlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 char body[MAX_FILE_SPEC_LEN + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 } vspec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #define EOS '\0'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #define NO 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #define YES 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #define NULL 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 /* gfnames - return in successive calls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 name of each file specified by all the remaining args in the command-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 expanding wild cards and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 stepping over arguments when they have been processed completely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 char*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 gfnames(pac, pav, p_error)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 int *pac;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 char **pav[];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 tbool *p_error;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 short fn_exp();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 if (*pac == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 *p_error = NO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 return(NULL);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 else switch(fn_exp(&filename, **pav))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 case 1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 *p_error = NO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 return(filename.body);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 --*pac;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ++*pav;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 *p_error = YES;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 return(filename.body);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 /* fn_exp - expand specification of list of file names
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 returning in each successive call the next filename matching the input
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 spec. The function expects that each in_spec passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 to it will be processed to completion; in particular, up to and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 including the call following that in which the last matching name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 is returned, the function ignores the value of in_spec, and will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 only start processing a new spec with the following call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 If an error occurs, on return out_spec contains the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 of in_spec when the error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 With each successive filename returned in out_spec, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 function's return value is one. When there are no more matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 names the function returns zero. If on the first call no file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 matches in_spec, or there is any other error, -1 is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 #include <rmsdef.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 #include <descrip.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 #define OUTSIZE MAX_FILE_SPEC_LEN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 short
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 fn_exp(out, in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 vspec *out;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 char *in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 static long context = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 static struct dsc$descriptor_s o;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 static struct dsc$descriptor_s i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 static tbool pass1 = YES;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 short retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 if (pass1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 pass1 = NO;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 o.dsc$a_pointer = (char *) out;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 o.dsc$w_length = (short)OUTSIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 i.dsc$a_pointer = in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 i.dsc$w_length = (short)strlen(in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 i.dsc$b_dtype = DSC$K_DTYPE_T;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 i.dsc$b_class = DSC$K_CLASS_S;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 o.dsc$b_dtype = DSC$K_DTYPE_VT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 o.dsc$b_class = DSC$K_CLASS_VS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 if ( (status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 out->body[out->curlen] = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 return(1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 else if (status == RMS$_NMF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 strcpy(out->body, in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 retval = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 lib$find_file_end(&context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 pass1 = YES;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 return(retval);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 #ifndef OLD /* Newer versions of VMS do provide `system'. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 system(cmd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 char *cmd;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 fprintf(stderr, "system() function not implemented under VMS\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 #define VERSION_DELIM ';'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 char *massage_name(s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 char *s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 char *start = s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 for ( ; *s; s++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 if (*s == VERSION_DELIM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 *s = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 *s = tolower(*s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 return(start);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 }