home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / lib / dlibssrc / spawne.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-10-08  |  719 b   |  30 lines

  1. #include <osbind.h>
  2. #include <stdio.h>
  3.  
  4. int spawne(program, cmdline, envp)
  5. char *program;
  6. char *cmdline;
  7. char *envp;
  8. /*
  9.  *    Calls the OS "Pexec" trap with the parameters specified.  Since
  10.  *    the OS uses a Pascal-like string for the command line, the
  11.  *    <cmdline> parameter, which is a normal C-string, is used to
  12.  *    create the actual command line which is passed to the OS trap.
  13.  */
  14. {
  15.     char execbuf[128];        /* buffer for exec command line */
  16.     register int n;
  17.  
  18.     if(cmdline) {
  19.         if((n = strlen(cmdline)) > 126)
  20.             n = 126;
  21.         execbuf[0] = n;
  22.         strncpy(execbuf+1, cmdline, n);
  23.         execbuf[n+2] = '\0';
  24.     }
  25.     else
  26.         execbuf[0] = execbuf[1] = '\0';
  27.     n = Pexec(0, program, execbuf, envp);
  28.     return(n);
  29. }
  30.