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