Subversion Repositories SvarDOS

Rev

Rev 577 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 577 Rev 2213
Line 20... Line 20...
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
 * DEALINGS IN THE SOFTWARE.
22
 * DEALINGS IN THE SOFTWARE.
23
 */
23
 */
24
 
24
 
25
#include <string.h> /* memset() */
-
 
26
 
-
 
27
#include "env.h"
25
#include "env.h"
28
#include "helpers.h"
26
#include "helpers.h"
29
#include "rmodinit.h"
27
#include "rmodinit.h"
30
 
28
 
31
#include "redir.h"
29
#include "redir.h"
Line 93... Line 91...
93
 
91
 
94
  /* preset oldstdout to 0xffff in case no redirection is required */
92
  /* preset oldstdout to 0xffff in case no redirection is required */
95
  oldstdout = 0xffff;
93
  oldstdout = 0xffff;
96
 
94
 
97
  /* clear out the redir_data struct */
95
  /* clear out the redir_data struct */
98
  memset(d, 0, sizeof(*d));
96
  sv_bzero(d, sizeof(*d));
99
 
97
 
100
  *awaitingcmd = 0;
98
  *awaitingcmd = 0;
101
 
99
 
102
  /* parse the command line and fill struct with pointers */
100
  /* parse the command line and fill struct with pointers */
103
  for (i = 0;; i++) {
101
  for (i = 0;; i++) {
Line 128... Line 126...
128
 
126
 
129
  /* if pipes present, write them to awaitingcmd (and stdout redirection too) */
127
  /* if pipes present, write them to awaitingcmd (and stdout redirection too) */
130
  if (pipescount != 0) {
128
  if (pipescount != 0) {
131
    static char tmpfile[130];
129
    static char tmpfile[130];
132
    for (i = 0; i < pipescount; i++) {
130
    for (i = 0; i < pipescount; i++) {
133
      if (i != 0) _fstrcat(awaitingcmd, "|");
131
      if (i != 0) sv_strcat_far(awaitingcmd, "|");
134
      _fstrcat(awaitingcmd, d->pipes[i]);
132
      sv_strcat_far(awaitingcmd, d->pipes[i]);
135
    }
133
    }
136
    /* append stdout redirection so I don't forget about it for the last command of the pipe queue */
134
    /* append stdout redirection so I don't forget about it for the last command of the pipe queue */
137
    if (d->stdoutfile != NULL) {
135
    if (d->stdoutfile != NULL) {
138
      if (d->stdout_openflag == 0x11) {
136
      if (d->stdout_openflag == 0x11) {
139
        _fstrcat(awaitingcmd, ">>");
137
        sv_strcat_far(awaitingcmd, ">>");
140
      } else {
138
      } else {
141
        _fstrcat(awaitingcmd, ">");
139
        sv_strcat_far(awaitingcmd, ">");
142
      }
140
      }
143
      d->stdoutfile = NULL;
141
      d->stdoutfile = NULL;
144
    }
142
    }
145
    /* redirect stdin of next command from a temp file (that is used as my output) */
143
    /* redirect stdin of next command from a temp file (that is used as my output) */
146
    _fstrcat(awaitingcmd, "<");
144
    sv_strcat_far(awaitingcmd, "<");
147
    i = gentmpfile(tmpfile, envseg);
145
    i = gentmpfile(tmpfile, envseg);
148
    if (i != 0) return(i);
146
    if (i != 0) return(i);
149
    _fstrcat(awaitingcmd, tmpfile);
147
    sv_strcat_far(awaitingcmd, tmpfile);
150
    /* same file is used as my stdout */
148
    /* same file is used as my stdout */
151
    d->stdoutfile = tmpfile;
149
    d->stdoutfile = tmpfile;
152
    d->stdout_openflag = 0x12;
150
    d->stdout_openflag = 0x12;
153
  }
151
  }
154
  return(0);
152
  return(0);