home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / Perl5 / macish.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-27  |  1.2 KB  |  76 lines  |  [TEXT/MPS ]

  1. #include "EXTERN.h"
  2. #include "perl.h"
  3.  
  4. int link()
  5. {
  6.     if (dowarn)
  7.         warn("MacPerl: link always fails");
  8.         
  9.     return -1;
  10. }
  11.  
  12. unsigned short umask(unsigned short arg)
  13. {
  14.     if (dowarn && arg)
  15.         warn("MacPerl: nonzero argument to umask() ignored");
  16.     
  17.     return 0;
  18. }
  19.  
  20. static void
  21. setup_argstr(SV *really, SV **mark, SV **sp, char **argstr)
  22. {
  23.   char *tmps, *junk;
  24.   register size_t cmdlen = 0;
  25.   size_t rlen;
  26.   register SV **idx;
  27.  
  28.   idx = mark;
  29.   if (really && *(tmps = SvPV(really,rlen))) {
  30.     cmdlen += rlen + 1;
  31.     idx++;
  32.   }
  33.   
  34.   for (idx++; idx <= sp; idx++) {
  35.     if (*idx) {
  36.       junk = SvPVx(*idx,rlen);
  37.       cmdlen += rlen ? rlen + 1 : 0;
  38.     }
  39.   }
  40.   New(401,*argstr,cmdlen, char);
  41.  
  42.   if (*tmps) {
  43.     strcpy(*argstr,tmps);
  44.     mark++;
  45.   }
  46.   else **argstr = '\0';
  47.   while (++mark <= sp) {
  48.     if (*mark) {
  49.       strcat(*argstr," ");
  50.       strcat(*argstr,SvPVx(*mark,na));
  51.     }
  52.   }
  53.  
  54. }  /* end of setup_argstr() */
  55.  
  56. int do_spawn(char * command)
  57. {
  58.     int         ch;
  59.     FILE *    temp = my_popen(command, "r");
  60.     
  61.     while ((ch = getc(temp)) != EOF)
  62.         putc(ch, stdout);
  63.     
  64.     my_pclose(temp);
  65. }
  66.  
  67. int do_aspawn(SV *really,SV **mark,SV **sp)
  68. {
  69.   if (sp > mark) {
  70.     setup_argstr(really,mark,sp,&Cmd);
  71.     return do_spawn(Cmd);
  72.   }
  73.  
  74.   return -1;
  75. }  /* end of do_aspawn() */
  76.