7 extern unsigned char *com_substr() ; /* ;AN000; DBCS enabled */
10 union REGS inregs, outregs; /* ;AN000; Regs for Int21 */
11 struct SREGS segregs; /* ;AN000; Segment regs for Int21 */
13 #define GET_DBCS_VEC 0x6300 /* ;AN000; Int21 Get DBCS Vector */
14 #define DBLNULL "00" /* ;AN000; */
15 #define NULL 0 /* ;AN000; */
19 /* return FALSE if drive is valid AND the path is not a prefix of a non-root
36 if (curdir(buf, d) == -1) /* drive is invalid => error */
39 if (strlen(buf) == 3) /* current directory is root => OK */
46 if(testkanj(*p1 & 0xFF))
49 if((*p1++ == '\\') && (*p1 == NULL))
53 if (p[strlen(p)-1] == '\\') /* prefix matched, prefix had...*/
54 return(TRUE) ; /* ...trailing / => valid ... */
55 /* ...prefix => ERROR */
58 if (d == 0 || d == '\\') /* prefix matched,... */
59 return(TRUE) ; /* ...prefix had no trailing /, */
60 /* ...next char was / => ... */
61 /* ...valid prefix => ERROR */
64 return(FALSE) ; /* drive letter good and not valid prefix => OK */
72 return(!strncmp(pre, tot, strlen(pre)));
87 ffirst(pb, attr, pfbuf)
90 struct findType *pfbuf ;
94 /* set DMA to point to buffer */
97 regs.x.dx = (unsigned) pfbuf ;
98 intdos (®s, ®s) ;
100 /* perform system call */
104 regs.x.dx = (unsigned) pb ;
105 intdos (®s, ®s) ;
107 return (regs.x.cflag ? -1 : 0) ;
111 struct findType *pfbuf;
115 /* set DMA to point to buffer */
117 regs.x.dx = (unsigned) pfbuf;
118 intdos (®s, ®s);
119 /* perform system call */
121 intdos (®s, ®s);
122 return (regs.x.cflag ? -1 : 0) ;
126 char *strbscan(str, class)
132 p = com_substr(str, class) ; /* :AN000; DBCS function */
133 return((p == NULL) ? (str + strlen(str)) : p) ;
140 /* curdir.c - return text of current directory for a particular drive */
152 regs.x.si = (unsigned) dst ;
153 intdos (®s, ®s) ;
154 return(regs.x.cflag ? -1 : 0) ;
164 /*** rootpath -- convert a pathname argument to root based cannonical form
166 * rootpath determines the current directory, appends the path argument (which
167 * may affect which disk the current directory is relative to), and qualifies
168 * "." and ".." references. The result is a complete, simple, path name with
171 * If the relative path the user specifies does not include a drive spec., the
172 * default drive will be used as the base. (The default drive will never be
175 * entry: relpath -- pointer to the pathname to be expanded
176 * fullpath -- must point to a working buffer, see warning
177 * exit: fullpath -- the full path which results
178 * return: true if an error occurs, false otherwise
180 * calls: curdir, getdrv
182 * warning: fullpath must point to a working buffer large enough to hold the
183 * longest possible relative path argument plus the longest possible
184 * current directory path.
187 int rootpath(relpath, fullpath)
193 register char *lead, *follow ;
197 /* extract drive spec */
198 drivenum = getdrv() ;
199 if ((*relpath != NULL) && (relpath[1] == COLON)) {
200 drivenum = relpath[0] - 'A' ;
203 fullpath[0] = (char) ('A' + drivenum) ;
204 fullpath[1] = COLON ;
206 /* append relpath to fullpath/base */
207 if (*relpath == PathChr) {
208 /* relpath starts at base */
209 strcpy(fullpath+2, relpath) ;
212 /* must get base path first */
213 if (curdir(fullpath+2, drivenum+1))
214 return(TRUE) ; /* terrible error */
215 if ((*relpath != ASCNULL) && (strlen(fullpath) > 3))
216 strcat(fullpath, "\\") ;
217 strcat(fullpath, relpath) ;
221 /* convert path to cannonical form */
223 while(*lead != ASCNULL) {
224 /* mark next path segment */
226 lead = (char *) com_substr(follow+1, "\\") ; /* ;AC000; */
228 lead = fullpath + strlen(fullpath) ;
230 if (tempchar == PathChr)
231 tempchar = BACKSLASH ; /* make breaks uniform */
235 if (strcmp(follow+1, ".") == 0) {
237 strcpy(follow, lead) ; /* remove "." segment */
242 else if (strcmp(follow+1, "..") == 0) {
247 while(*(p2=strbscan(p1=p2+1,"\\")) != NULL) ;
248 /* p1 now points to the start of the previous element */
251 return(TRUE) ; /* tried to .. the root */
252 follow = p1 - 1 ; /* follow points to path sep */
253 strcpy(follow, lead) ; /* remove ".." segment */
261 if (strlen(fullpath) == 2) /* 'D:' or some such */
262 strcat(fullpath, "\\") ;
268 /* getdrv - return current drive as a character */
275 regs.h.ah = CURDISK ; /* Function 0x19 */
276 intdos (®s, ®s) ;
283 char fix_es_reg[1]; /* ;AN000; Fixes es reg after "far" */
284 char far * fptr; /* ;AN000; Pts to DBCS vector */
285 unsigned * ptr; /* ;AN000; Input to fptr */
286 unsigned int got_dbcs; /* ;AN000; Flag */
288 inregs.x.ax = GET_DBCS_VEC; /* ;AN000; 0x6300 */
289 intdosx(&inregs,&outregs,&segregs); /* ;AN000; Int21 */
291 got_dbcs = FALSE; /* ;AN000; Initialize */
293 ptr = (unsigned *)&fptr; /* ;AN000; Int21 returns DS:SI */
294 *ptr = outregs.x.si; /* ;AN000; as ptr to DBCS */
295 ptr++; /* ;AN000; vector, now fill */
296 *ptr = segregs.ds; /* ;AN000; in our pointer */
298 for (fptr; *(unsigned far *)fptr != (unsigned)DBLNULL; fptr += 2) /* ;AN000; */
300 if ( (c >= (char)*fptr) && (c <= (char)*(fptr+1)) ) /* ;AN000; Is char */
301 { /* ;AN000; within the range? */
302 got_dbcs = TRUE; /* ;AN000; Char is DBCS */
307 strcpy(fix_es_reg,NULL); /* ;AN000; Repair ES reg */
308 return(got_dbcs); /* ;AN000; */