Subversion Repositories SvarDOS

Rev

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

Rev 458 Rev 461
Line 344... Line 344...
344
  if (explicitpath) return(-2); /* don't bother trying other paths, the caller had its own path preset anyway */
344
  if (explicitpath) return(-2); /* don't bother trying other paths, the caller had its own path preset anyway */
345
  return(-1);
345
  return(-1);
346
}
346
}
347
 
347
 
348
 
348
 
349
static void run_as_external(char *buff, const char far *cmdline, unsigned short envseg) {
349
static void run_as_external(char *buff, const char far *cmdline, unsigned short envseg, struct rmod_props far *rmod) {
350
  char const **argvlist = (void *)(buff + 512);
350
  char const **argvlist = (void *)(buff + 512);
351
  char *cmdfile = buff + 1024;
351
  char *cmdfile = buff + 1024;
352
  const char far *pathptr;
352
  const char far *pathptr;
353
  int lookup;
353
  int lookup;
354
  unsigned short i;
354
  unsigned short i;
355
  const char *ext;
355
  const char *ext;
-
 
356
  const char far *cmdtail;
-
 
357
  char far *rmod_execprog = MK_FP(rmod->rmodseg, RMOD_OFFSET_EXECPROG);
-
 
358
  char far *rmod_cmdtail = MK_FP(rmod->rmodseg, 0x81);
-
 
359
  _Packed struct {
-
 
360
    unsigned short envseg;
-
 
361
    unsigned long cmdtail;
-
 
362
    unsigned long fcb1;
-
 
363
    unsigned long fcb2;
-
 
364
  } far *ExecParam = MK_FP(rmod->rmodseg, RMOD_OFFSET_EXECPARAM);
356
 
365
 
357
  cmd_explode(buff + 2048, cmdline, argvlist);
366
  cmd_explode(buff + 2048, cmdline, argvlist);
358
 
367
 
359
  /* for (i = 0; argvlist[i] != NULL; i++) printf("arg #%d = '%s'\r\n", i, argvlist[i]); */
368
  /* for (i = 0; argvlist[i] != NULL; i++) printf("arg #%d = '%s'\r\n", i, argvlist[i]); */
360
 
369
 
Line 399... Line 408...
399
    return;
408
    return;
400
  }
409
  }
401
 
410
 
402
  /* printf("Exec: '%s'\r\n", cmdfile); */
411
  /* printf("Exec: '%s'\r\n", cmdfile); */
403
 
412
 
-
 
413
  /* find cmdtail */
-
 
414
  cmdtail = cmdline;
-
 
415
  while (*cmdtail == ' ') cmdtail++;
-
 
416
  while ((*cmdtail != ' ') && (*cmdtail != '/') && (*cmdtail != '+') && (*cmdtail != 0)) {
-
 
417
    cmdtail++;
-
 
418
  }
-
 
419
 
-
 
420
  /* copy full filename to execute */
-
 
421
  for (i = 0; cmdfile[i] != 0; i++) rmod_execprog[i] = cmdfile[i];
-
 
422
  rmod_execprog[i] = 0;
-
 
423
 
404
  /* this call should never return, unless the program failed to be executed */
424
  /* copy cmdtail to rmod's PSP and compute its len */
-
 
425
  for (i = 0; cmdtail[i] != 0; i++) rmod_cmdtail[i] = cmdtail[i];
-
 
426
  rmod_cmdtail[i] = '\r';
405
  execvp(cmdfile, argvlist);
427
  rmod_cmdtail[-1] = i;
-
 
428
 
-
 
429
  printf("Exec: '");
-
 
430
  for (i = 0; rmod_execprog[i] != 0; i++) {
-
 
431
    printf("%c", rmod_execprog[i]);
-
 
432
  }
-
 
433
  printf("'\r\n");
-
 
434
 
-
 
435
  /* set up rmod to execute the command */
-
 
436
 
-
 
437
  ExecParam->envseg = 0; /* 0 = use parent's env segment */
-
 
438
  ExecParam->cmdtail = (unsigned long)MK_FP(rmod->rmodseg, 0x80); /* farptr, must be in PSP format (lenbyte args \r) */
-
 
439
  ExecParam->fcb1 = 0; /* TODO farptr */
-
 
440
  ExecParam->fcb2 = 0; /* TODO farptr */
-
 
441
  exit(0); /* let rmod do the job now */
406
}
442
}
407
 
443
 
408
 
444
 
409
static void set_comspec_to_self(unsigned short envseg) {
445
static void set_comspec_to_self(unsigned short envseg) {
410
  unsigned short *psp_envseg = (void *)(0x2c); /* pointer to my env segment field in the PSP */
446
  unsigned short *psp_envseg = (void *)(0x2c); /* pointer to my env segment field in the PSP */
Line 592... Line 628...
592
      redir_revert(); /* revert stdout (in case it was redirected) */
628
      redir_revert(); /* revert stdout (in case it was redirected) */
593
      continue;
629
      continue;
594
    }
630
    }
595
 
631
 
596
    /* if here, then this was not an internal command */
632
    /* if here, then this was not an internal command */
597
    run_as_external(BUFFER, cmdline, *rmod_envseg);
633
    run_as_external(BUFFER, cmdline, *rmod_envseg, rmod);
598
 
634
 
599
    /* revert stdout (in case it was redirected) */
635
    /* revert stdout (in case it was redirected) */
600
    redir_revert();
636
    redir_revert();
601
 
637
 
602
    /* execvp() replaces the current process by the new one
638
    /* execvp() replaces the current process by the new one