summaryrefslogtreecommitdiff
path: root/systems/msdos/tx/src/txexpand.c
blob: a3deed7423f0f543f5a1a921ed47f89674959a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "tx.h" 
 
int ExpandNames(char *expand,char *notexpand,int limit) 
{ 
  int i ; 
 
  while ( limit && (*expand = *notexpand++) != '\0' ) { 
    if ( *expand != SUBST_SIGN ) { 
      ++expand ; 
      --limit  ; 
    } 
    else if ( !strnicmp(notexpand,WF_PATH,L_WF_PATH) ) { 
      for ( i=0 ; limit && (*expand = Path[i]) ; i++ , limit-- ) {
#ifdef __GO32__
        if ( *expand == SLASH ) 
           *expand = '\\' ; /* dos wants backslashes here */
#endif
	++expand ;
      }
      if (limit && Path[--i] != BACKSLASH ) { 
	*expand++ = '\\' ; 
	--limit ;
      }
      if (!limit) 
	break ; 
      notexpand += L_WF_PATH ; 
    } 
    else if ( !strnicmp(notexpand,WF_SLPATH,L_WF_SLPATH) ) { 
      for ( i=0 ; limit && (*expand=Path[i]) ; i++ , limit-- ) {
#ifndef __GO32__
	if ( *expand == BACKSLASH ) 
	  *expand = SLASH ; 
#endif
	expand++ ; 
      } 
      if (limit && Path[--i] != BACKSLASH ) { 
	*expand++ = SLASH ; 
	--limit ;
      }
      if (!limit) 
	break ; 
      notexpand += L_WF_SLPATH ; 
    } 
    else if ( !strnicmp(notexpand,WF_NAME,L_WF_NAME) ) { 
      for ( i=0 ; limit && FileName[i] ; i++ , limit-- ) 
	*expand++ = FileName[i] ; 
      if (!limit) 
	break ; 
      notexpand += L_WF_NAME ; 
    } 
    else if ( !strnicmp(notexpand,WF_EXT,L_WF_EXT) ) { 
      for ( i=0 ; limit && Extension[i] ; i++ , limit-- ) 
	*expand++ = Extension[i] ; 
      if (!limit) 
	break ; 
      notexpand += L_WF_EXT ; 
    } 
  } 
  
  if ( limit ) 
    return 1 ;        /* return 1 on successful completion */ 
  *(--expand) = '\0' ; /* must back up to put null */ 
  return 0 ;           /* return 0 if limit has been reached */ 
}