annotate src/os_vms.c @ 4994:879ebefc462c

Added tag v7-3-1241 for changeset c87476046967
author Bram Moolenaar <bram@vim.org>
date Mon, 24 Jun 2013 22:23:55 +0200
parents 0b3be97064e5
children 2f99966971b0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * VMS port by Henk Elbers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * VMS deport by Zoltan Arpadffy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 char class;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 char type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 short width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 union
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 char _basic[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 char length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 } y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 int basic;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 } x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 int extended;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 } TT_MODE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 short buflen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 short itemcode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 char *bufadrs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 int *retlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 } ITEM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 ITEM equ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 int nul;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 } ITMLST1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 ITEM index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 ITEM string;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 int nul;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 } ITMLST2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 static TT_MODE orgmode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 static short iochan; /* TTY I/O channel */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 static short iosb[4]; /* IO status block */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 static int vms_match_num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 static int vms_match_free = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 static char_u **vms_fmatch = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 static char *Fspec_Rms; /* rms file spec, passed implicitly between routines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 static TT_MODE get_tty __ARGS((void));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 static void set_tty __ARGS((int row, int col));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #define EXPL_ALLOC_INC 64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #define EQN(S1,S2,LN) (strncmp(S1,S2,LN) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 #define SKIP_FOLLOWING_SLASHES(Str) while (Str[1] == '/') ++Str
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 * vul_desc vult een descriptor met een string en de lengte
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 * hier van.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 vul_desc(DESC *des, char *str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 des->dsc$b_dtype = DSC$K_DTYPE_T;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 des->dsc$b_class = DSC$K_CLASS_S;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 des->dsc$a_pointer = str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 des->dsc$w_length = str ? strlen(str) : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 * vul_item vult een item met een aantal waarden
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 vul_item(ITEM *itm, short len, short cod, char *adr, int *ret)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 itm->buflen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 itm->itemcode = cod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 itm->bufadrs = adr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 itm->retlen = ret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 mch_settmode(int tmode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 int status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 if ( tmode == TMODE_RAW )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 set_tty(0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 else{
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 switch (orgmode.width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 default: break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 status = sys$qiow(0, iochan, IO$_SETMODE, iosb, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 &orgmode, sizeof(TT_MODE), 0,0,0,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 (void)sys$dassgn(iochan);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 iochan = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 set_tty(int row, int col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 int status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 TT_MODE newmode; /* New TTY mode bits */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 static short first_time = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 if (first_time)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 orgmode = get_tty();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 first_time = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 newmode = get_tty();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 if (col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 newmode.width = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 if (row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 newmode.x.y.length = row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 newmode.x.basic |= (TT$M_NOECHO | TT$M_HOSTSYNC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 newmode.x.basic &= ~TT$M_TTSYNC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 newmode.extended |= TT2$M_PASTHRU;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 status = sys$qiow(0, iochan, IO$_SETMODE, iosb, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 &newmode, sizeof(newmode), 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 static TT_MODE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 get_tty(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 static $DESCRIPTOR(odsc,"SYS$OUTPUT"); /* output descriptor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 int status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 TT_MODE tt_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 if (!iochan)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 status = sys$assign(&odsc,&iochan,0,0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 status = sys$qiow(0, iochan, IO$_SENSEMODE, iosb, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 &tt_mode, sizeof(tt_mode), 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 tt_mode.width = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 tt_mode.type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 tt_mode.class = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 tt_mode.x.basic = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 tt_mode.x.y.length = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 tt_mode.extended = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 return(tt_mode);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 * Get the current window size in Rows and Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 mch_get_shellsize(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 TT_MODE tmode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 tmode = get_tty(); /* get size from VMS */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 Columns = tmode.width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 Rows = tmode.x.y.length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 * Try to set the window size to Rows and new_Columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 mch_set_shellsize(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 set_tty(Rows, Columns);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 switch (Columns)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 case 132: OUT_STR_NF((char_u *)"\033[?3h\033>"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 case 80: OUT_STR_NF((char_u *)"\033[?3l\033>"); break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 default: break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 screen_start();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 mch_getenv(char_u *lognam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 DESC d_file_dev, d_lognam ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 static char buffer[LNM$C_NAMLENGTH+1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 char_u *cp = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 unsigned long attrib;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 int lengte = 0, dum = 0, idx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 ITMLST2 itmlst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 char *sbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 vul_desc(&d_lognam, (char *)lognam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216 vul_desc(&d_file_dev, "LNM$FILE_DEV");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 attrib = LNM$M_CASE_BLIND;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 vul_item(&itmlst.index, sizeof(int), LNM$_INDEX, (char *)&idx, &dum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 vul_item(&itmlst.string, LNM$C_NAMLENGTH, LNM$_STRING, buffer, &lengte);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 itmlst.nul = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 if (sys$trnlnm(&attrib, &d_file_dev, &d_lognam, NULL,&itmlst) == SS$_NORMAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 buffer[lengte] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 if (cp = (char_u *)alloc((unsigned)(lengte+1)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 strcpy((char *)cp, buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 return(cp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 else if ((sbuf = getenv((char *)lognam)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 lengte = strlen(sbuf) + 1;
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 1698
diff changeset
231 cp = (char_u *)alloc((size_t)lengte);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 if (cp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 strcpy((char *)cp, sbuf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 return cp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 return(NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 * mch_setenv VMS version of setenv()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 mch_setenv(char *var, char *value, int x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 int res, dum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 long attrib = 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 char acmode = PSL$C_SUPER; /* needs SYSNAM privilege */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 DESC tabnam, lognam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 ITMLST1 itmlst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 vul_desc(&tabnam, "LNM$JOB");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 vul_desc(&lognam, var);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 vul_item(&itmlst.equ, value ? strlen(value) : 0, value ? LNM$_STRING : 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 value, &dum);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 itmlst.nul = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 res = sys$crelnm(&attrib, &tabnam, &lognam, &acmode, &itmlst);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 return((res == 1) ? 0 : -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 vms_sys(char *cmd, char *out, char *inp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 DESC cdsc, odsc, idsc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 long status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 if (cmd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 vul_desc(&cdsc, cmd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 if (out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 vul_desc(&odsc, out);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 if (inp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 vul_desc(&idsc, inp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 lib$spawn(cmd ? &cdsc : NULL, /* command string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 inp ? &idsc : NULL, /* input file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 out ? &odsc : NULL, /* output file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 0, 0, 0, &status, 0, 0, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 return status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 * Convert VMS system() or lib$spawn() return code to Unix-like exit value.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 vms_sys_status(int status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 if (status != SS$_NORMAL && (status & STS$M_SUCCESS) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 return status; /* Command failed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 * vms_read()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 * function for low level char input
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 * Returns: input length
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 vms_read(char *inbuf, size_t nbytes)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 {
775
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
301 int status, function, len;
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
302 TT_MODE tt_mode;
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
303 ITEM itmlst[2]; /* terminates on everything */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 /* whatever happened earlier we need an iochan here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 if (!iochan)
775
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
308 tt_mode = get_tty();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
310 /* important: clean the inbuf */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 memset(inbuf, 0, nbytes);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
313 /* set up the itemlist for the first read */
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
314 vul_item(&itmlst[0], 0, TRM$_MODIFIERS,
775
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
315 (char *)( TRM$M_TM_NOECHO | TRM$M_TM_NOEDIT |
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
316 TRM$M_TM_NOFILTR | TRM$M_TM_TRMNOECHO |
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
317 TRM$M_TM_NORECALL) , 0);
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
318 vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask, 0);
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
319
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
320 /* wait forever for a char */
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
321 function = (IO$_READLBLK | IO$M_EXTEND);
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
322 status = sys$qiow(0, iochan, function, &iosb, 0, 0,
775
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
323 inbuf, nbytes-1, 0, 0, &itmlst, sizeof(itmlst));
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
324 len = strlen(inbuf); /* how many chars we got? */
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
325
1197
b7ad1c609161 updated for version 7.1b
vimboss
parents: 1121
diff changeset
326 /* read immediately the rest in the IO queue */
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
327 function = (IO$_READLBLK | IO$M_TIMED | IO$M_ESCAPE | IO$M_NOECHO | IO$M_NOFILTR);
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
328 status = sys$qiow(0, iochan, function, &iosb, 0, 0,
775
f04f56979d84 updated for version 7.0227
vimboss
parents: 715
diff changeset
329 inbuf+len, nbytes-1-len, 0, 0, 0, 0);
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
330
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
331 len = strlen(inbuf); /* return the total length */
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
332
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 return len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 * vms_wproc() is called for each matching filename by decc$to_vms().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 * We want to save each match for later retrieval.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 * Returns: 1 - continue finding matches
1197
b7ad1c609161 updated for version 7.1b
vimboss
parents: 1121
diff changeset
341 * 0 - stop trying to find any further matches
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 vms_wproc(char *name, int val)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 int nlen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 static int vms_match_alloced = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
1197
b7ad1c609161 updated for version 7.1b
vimboss
parents: 1121
diff changeset
350 if (val != DECC$K_FILE) /* Directories and foreign non VMS files are not
b7ad1c609161 updated for version 7.1b
vimboss
parents: 1121
diff changeset
351 counting */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 if (vms_match_num == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 /* first time through, setup some things */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 if (NULL == vms_fmatch) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 vms_fmatch = (char_u **)alloc(EXPL_ALLOC_INC * sizeof(char *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 if (!vms_fmatch)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 vms_match_alloced = EXPL_ALLOC_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 vms_match_free = EXPL_ALLOC_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 /* re-use existing space */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 vms_match_free = vms_match_alloced;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 vms_remove_version(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 /* convert filename to lowercase */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 nlen = strlen(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 for (i = 0; i < nlen; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 name[i] = TOLOWER_ASC(name[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 /* if name already exists, don't add it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 for (i = 0; i<vms_match_num; i++) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 if (0 == STRCMP((char_u *)name,vms_fmatch[i]))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 if (--vms_match_free == 0) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 /* add more space to store matches */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 vms_match_alloced += EXPL_ALLOC_INC;
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 1698
diff changeset
384 vms_fmatch = (char_u **)vim_realloc(vms_fmatch,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 sizeof(char **) * vms_match_alloced);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 if (!vms_fmatch)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 vms_match_free = EXPL_ALLOC_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 vms_fmatch[vms_match_num] = vim_strsave((char_u *)name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 ++vms_match_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 * mch_expand_wildcards this code does wild-card pattern
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 * matching NOT using the shell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 *
1698
f4f8014d516e updated for version 7.2c-000
vimboss
parents: 1197
diff changeset
400 * return OK for success, FAIL for error (you may lose some
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 * memory) and put an error message in *file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 * num_pat number of input patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 * pat array of pointers to input patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 * num_file pointer to number of matched file names
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 * file pointer to array of pointers to matched file names
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u ***file, int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 {
2278
0b3be97064e5 Various small fixes from Dominique Pelle.
Bram Moolenaar <bram@vim.org>
parents: 1738
diff changeset
412 int i, cnt = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 char_u buf[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 int dir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415 int files_alloced, files_free;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 *num_file = 0; /* default: no files found */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 files_alloced = EXPL_ALLOC_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 files_free = EXPL_ALLOC_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 *file = (char_u **) alloc(sizeof(char_u **) * files_alloced);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 if (*file == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 *num_file = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 for (i = 0; i < num_pat; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 /* expand environment var or home dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 if (vim_strchr(pat[i],'$') || vim_strchr(pat[i],'~'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 expand_env(pat[i],buf,MAXPATHL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 STRCPY(buf,pat[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 vms_match_num = 0; /* reset collection counter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 cnt = decc$to_vms(decc$translate_vms(vms_fixfilename(buf)), vms_wproc, 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 /* allow wild, no dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 if (cnt > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 cnt = vms_match_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 if (cnt < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 for (i = 0; i < cnt; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 /* files should exist if expanding interactively */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 if (!(flags & EW_NOTFOUND) && mch_getperm(vms_fmatch[i]) < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 continue;
715
b526e10493b1 updated for version 7.0217
vimboss
parents: 694
diff changeset
448
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 /* do not include directories */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 dir = (mch_isdir(vms_fmatch[i]));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 if (( dir && !(flags & EW_DIR)) || (!dir && !(flags & EW_FILE)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 continue;
715
b526e10493b1 updated for version 7.0217
vimboss
parents: 694
diff changeset
453
b526e10493b1 updated for version 7.0217
vimboss
parents: 694
diff changeset
454 /* Skip files that are not executable if we check for that. */
b526e10493b1 updated for version 7.0217
vimboss
parents: 694
diff changeset
455 if (!dir && (flags & EW_EXEC) && !mch_can_exe(vms_fmatch[i]))
b526e10493b1 updated for version 7.0217
vimboss
parents: 694
diff changeset
456 continue;
b526e10493b1 updated for version 7.0217
vimboss
parents: 694
diff changeset
457
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 /* allocate memory for pointers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 if (--files_free < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 files_alloced += EXPL_ALLOC_INC;
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 1698
diff changeset
462 *file = (char_u **)vim_realloc(*file,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 sizeof(char_u **) * files_alloced);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 if (*file == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466 *file = (char_u **)"";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 *num_file = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 return(FAIL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 files_free = EXPL_ALLOC_INC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 (*file)[*num_file++] = vms_fmatch[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 mch_expandpath(garray_T *gap, char_u *path, int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 int i,cnt = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 vms_match_num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 cnt = decc$to_vms(decc$translate_vms(vms_fixfilename(path)), vms_wproc, 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 /* allow wild, no dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 if (cnt > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 cnt = vms_match_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 for (i = 0; i < cnt; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 if (mch_getperm(vms_fmatch[i]) >= 0) /* add existing file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 addfile(gap, vms_fmatch[i], flags);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 return cnt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 * attempt to translate a mixed unix-vms file specification to pure vms
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 vms_unix_mixed_filespec(char *in, char *out)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 char *lastcolon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 char *end_of_dir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 char ch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 /* copy vms filename portion up to last colon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 * (node and/or disk)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 lastcolon = strrchr(in, ':'); /* find last colon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 if (lastcolon != NULL) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513 len = lastcolon - in + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 strncpy(out, in, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 out += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 in += len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 end_of_dir = NULL; /* default: no directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 /* start of directory portion */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 ch = *in;
694
07d199fe02ed updated for version 7.0209
vimboss
parents: 406
diff changeset
523 if ((ch == '[') || (ch == '/') || (ch == '<')) { /* start of directory(s) ? */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 ch = '[';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 SKIP_FOLLOWING_SLASHES(in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 } else if (EQN(in, "../", 3)) { /* Unix parent directory? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 *out++ = '[';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 *out++ = '-';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 end_of_dir = out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 ch = '.';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 in += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532 SKIP_FOLLOWING_SLASHES(in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 } else { /* not a special character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 while (EQN(in, "./", 2)) { /* Ignore Unix "current dir" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 in += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 SKIP_FOLLOWING_SLASHES(in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 if (strchr(in, '/') == NULL) { /* any more Unix directories ? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 strcpy(out, in); /* No - get rest of the spec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 } else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 *out++ = '['; /* Yes, denote a Vms subdirectory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 ch = '.';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 --in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 /* if we get here, there is a directory part of the filename */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 /* initialize output file spec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 *out++ = ch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 ++in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554 while (*in != '\0') {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555 ch = *in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 if ((ch == ']') || (ch == '/') || (ch == '>') ) { /* end of (sub)directory ? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 end_of_dir = out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 ch = '.';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 SKIP_FOLLOWING_SLASHES(in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 else if (EQN(in, "../", 3)) { /* Unix parent directory? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 *out++ = '-';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 end_of_dir = out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 ch = '.';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 in += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 SKIP_FOLLOWING_SLASHES(in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 else {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 while (EQN(in, "./", 2)) { /* Ignore Unix "current dir" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 end_of_dir = out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 in += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 SKIP_FOLLOWING_SLASHES(in);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 ch = *in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 /* Place next character into output file spec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 *out++ = ch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 ++in;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 *out = '\0'; /* Terminate output file spec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 if (end_of_dir != NULL) /* Terminate directory portion */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 *end_of_dir = ']';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 * for decc$to_vms in vms_fixfilename
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 vms_fspec_proc(char *fil, int val)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 strcpy(Fspec_Rms,fil);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 return(1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 * change unix and mixed filenames to VMS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 void *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 vms_fixfilename(void *instring)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 static char *buf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 static size_t buflen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 size_t len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 /* get a big-enough buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 len = strlen(instring) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 if (len > buflen)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 buflen = len + 128;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 if (buf)
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 1698
diff changeset
615 buf = (char *)vim_realloc(buf, buflen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 else
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 1698
diff changeset
617 buf = (char *)alloc(buflen * sizeof(char));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 #ifdef DEBUG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 char *tmpbuf = NULL;
1738
1ddec6983d9e updated for version 7.2-036
vimboss
parents: 1698
diff changeset
622 tmpbuf = (char *)alloc(buflen * sizeof(char));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 strcpy(tmpbuf, instring);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 Fspec_Rms = buf; /* for decc$to_vms */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 775
diff changeset
628 if (strchr(instring,'/') == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 /* It is already a VMS file spec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 strcpy(buf, instring);
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 775
diff changeset
631 else if (strchr(instring,'"') == NULL) /* password in the path? */
e63691e7c504 updated for version 7.1a
vimboss
parents: 775
diff changeset
632 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 /* Seems it is a regular file, let guess that it is pure Unix fspec */
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 775
diff changeset
634 if (decc$to_vms(instring, vms_fspec_proc, 0, 0) <= 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 /* No... it must be mixed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 vms_unix_mixed_filespec(instring, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 /* we have a password in the path */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 /* decc$ functions can not handle */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 /* this is our only hope to resolv */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 vms_unix_mixed_filespec(instring, buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 return buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 }
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 775
diff changeset
646
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * Remove version number from file name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 * we need it in some special cases as:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 * creating swap file name and writing new file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 vms_remove_version(void * fname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 char_u *cp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 char_u *fp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 if ((cp = vim_strchr( fname, ';')) != NULL) /* remove version */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 *cp = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 else if ((cp = vim_strrchr( fname, '.')) != NULL )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 if ((fp = vim_strrchr( fname, ']')) != NULL ) {;}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 else if ((fp = vim_strrchr( fname, '>')) != NULL ) {;}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 else fp = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 while ( *fp != '\0' && fp < cp )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 if ( *fp++ == '.' )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 *cp = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 return ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 }