diff options
| author | Jim Blandy | 1988-06-14 08:25:54 +0000 |
|---|---|---|
| committer | Jim Blandy | 1988-06-14 08:25:54 +0000 |
| commit | e095fd0c72561ac421cfbbea283520083bad5b4d (patch) | |
| tree | 0e96bd173b15ec7025a88c3cc34ab65319f9f601 /lib-src | |
| parent | 3d72126b31065d2e5fac01c0c260f420e16d4730 (diff) | |
| download | emacs-e095fd0c72561ac421cfbbea283520083bad5b4d.tar.gz emacs-e095fd0c72561ac421cfbbea283520083bad5b4d.zip | |
Initial revision
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags-vmslib.c | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/lib-src/etags-vmslib.c b/lib-src/etags-vmslib.c new file mode 100644 index 00000000000..0aa5bf6cc5d --- /dev/null +++ b/lib-src/etags-vmslib.c | |||
| @@ -0,0 +1,187 @@ | |||
| 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 | ||
| 4 | |||
| 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. | ||
| 10 | |||
| 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. | ||
| 18 | |||
| 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. | ||
| 27 | |||
| 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. | ||
| 41 | |||
| 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. | ||
| 46 | |||
| 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! */ | ||
| 50 | |||
| 51 | #include <stdio.h> | ||
| 52 | typedef char tbool; | ||
| 53 | |||
| 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 | ||
| 65 | |||
| 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 | ||
| 70 | */ | ||
| 71 | char* | ||
| 72 | gfnames(pac, pav, p_error) | ||
| 73 | int *pac; | ||
| 74 | char **pav[]; | ||
| 75 | tbool *p_error; | ||
| 76 | { | ||
| 77 | static vspec filename = {MAX_FILE_SPEC_LEN, "\0"}; | ||
| 78 | short fn_exp(); | ||
| 79 | |||
| 80 | while (1) | ||
| 81 | if (*pac == 0) | ||
| 82 | { | ||
| 83 | *p_error = NO; | ||
| 84 | return(NULL); | ||
| 85 | } | ||
| 86 | else switch(fn_exp(&filename, **pav)) | ||
| 87 | { | ||
| 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; | ||
| 100 | } | ||
| 101 | |||
| 102 | } | ||
| 103 | |||
| 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. | ||
| 113 | |||
| 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. | ||
| 118 | */ | ||
| 119 | |||
| 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; | ||
| 127 | { | ||
| 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; | ||
| 134 | |||
| 135 | if (pass1) | ||
| 136 | { | ||
| 137 | pass1 = NO; | ||
| 138 | o.dsc$a_pointer = 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; | ||
| 146 | } | ||
| 147 | if ( (status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL) | ||
| 148 | { | ||
| 149 | out->body[out->curlen] = EOS; | ||
| 150 | return(1); | ||
| 151 | } | ||
| 152 | else if (status == RMS$_NMF) | ||
| 153 | retval = 0; | ||
| 154 | else | ||
| 155 | { | ||
| 156 | strcpy(out->body, in); | ||
| 157 | retval = -1; | ||
| 158 | } | ||
| 159 | lib$find_file_end(&context); | ||
| 160 | pass1 = YES; | ||
| 161 | return(retval); | ||
| 162 | } | ||
| 163 | |||
| 164 | #ifndef OLD /* Newer versions of VMS do provide `system'. */ | ||
| 165 | system(cmd) | ||
| 166 | char *cmd; | ||
| 167 | { | ||
| 168 | fprintf(stderr, "system() function not implemented under VMS\n"); | ||
| 169 | } | ||
| 170 | #endif | ||
| 171 | |||
| 172 | #define VERSION_DELIM ';' | ||
| 173 | char *massage_name(s) | ||
| 174 | char *s; | ||
| 175 | { | ||
| 176 | char *start = s; | ||
| 177 | |||
| 178 | for ( ; *s; s++) | ||
| 179 | if (*s == VERSION_DELIM) | ||
| 180 | { | ||
| 181 | *s = EOS; | ||
| 182 | break; | ||
| 183 | } | ||
| 184 | else | ||
| 185 | *s = tolower(*s); | ||
| 186 | return(start); | ||
| 187 | } | ||