Subversion Repositories SvarDOS

Rev

Rev 575 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 575 Rev 577
Line 32... Line 32...
32
 
32
 
33
static unsigned short oldstdout = 0xffff;
33
static unsigned short oldstdout = 0xffff;
34
 
34
 
35
 
35
 
36
/* compute a filename to be used for pipes */
36
/* compute a filename to be used for pipes */
37
static unsigned short gentmpfile(char *s) {
37
static unsigned short gentmpfile(char *s, unsigned short envseg) {
38
  unsigned short err = 0;
38
  unsigned short err = 0;
39
  /* do I have a %temp% path? */
-
 
40
  /* TODO */
39
  unsigned short i;
41
 
40
 
-
 
41
  /* do I have a %temp% path? */
-
 
42
  i = env_lookup_valcopy(s, 116, envseg, "TEMP");
-
 
43
  if (i > 0) {
-
 
44
    /* make sure it is terminated by a backslash (required by int 0x21, ah=5a) */
-
 
45
    if (s[i - 1] != '\\') {
-
 
46
      s[i++] = '\\';
-
 
47
      s[i] = 0;
-
 
48
    }
-
 
49
  } else {
42
  /* if fails, then use truename(\) */
50
    /* if fails, then use truename(.\) */
43
  if (file_truename(".\\", s) != 0) *s = 0;
51
    if (file_truename(".\\", s) != 0) *s = 0;
-
 
52
  }
44
 
53
 
45
  /* create file */
54
  /* create file */
46
  _asm {
55
  _asm {
47
    mov ah, 0x5a
56
    mov ah, 0x5a
48
    mov dx, s
57
    mov dx, s
Line 64... Line 73...
64
 
73
 
65
/* parse commandline and performs necessary redirections. cmdline is
74
/* parse commandline and performs necessary redirections. cmdline is
66
 * modified so all redirections are cut out.
75
 * modified so all redirections are cut out.
67
 * piped commands are moved to awaitingcmd for later execution
76
 * piped commands are moved to awaitingcmd for later execution
68
 * returns 0 on success, DOS err on failure */
77
 * returns 0 on success, DOS err on failure */
69
unsigned short redir_parsecmd(struct redir_data *d, char *cmdline, char far *awaitingcmd) {
78
unsigned short redir_parsecmd(struct redir_data *d, char *cmdline, char far *awaitingcmd, unsigned short envseg) {
70
  unsigned short i;
79
  unsigned short i;
71
  unsigned short pipescount = 0;
80
  unsigned short pipescount = 0;
72
 
81
 
73
  /* NOTES:
82
  /* NOTES:
74
   *
83
   *
Line 133... Line 142...
133
      }
142
      }
134
      d->stdoutfile = NULL;
143
      d->stdoutfile = NULL;
135
    }
144
    }
136
    /* redirect stdin of next command from a temp file (that is used as my output) */
145
    /* redirect stdin of next command from a temp file (that is used as my output) */
137
    _fstrcat(awaitingcmd, "<");
146
    _fstrcat(awaitingcmd, "<");
138
    i = gentmpfile(tmpfile);
147
    i = gentmpfile(tmpfile, envseg);
139
    if (i != 0) return(i);
148
    if (i != 0) return(i);
140
    _fstrcat(awaitingcmd, tmpfile);
149
    _fstrcat(awaitingcmd, tmpfile);
141
    /* same file is used as my stdout */
150
    /* same file is used as my stdout */
142
    d->stdoutfile = tmpfile;
151
    d->stdoutfile = tmpfile;
143
    d->stdout_openflag = 0x12;
152
    d->stdout_openflag = 0x12;
144
    /* TODO I need to remember that the tmp file must be removed... */
-
 
145
/*    outputnl("awaitingcmd:");
-
 
146
    for (i = 0; awaitingcmd[i] != 0; i++) printf("%c", awaitingcmd[i]);
-
 
147
    printf("\r\n");*/
-
 
148
  }
153
  }
149
  return(0);
154
  return(0);
150
}
155
}
151
 
156
 
152
 
157