Пример #1
0
/*******************************************************************
 * WCMD_call - processes a batch call statement
 *
 *	If there is a leading ':', calls within this batch program
 *	otherwise launches another program.
 */
void WCMD_call (WCHAR *command) {

    /* Run other program if no leading ':' */
    if (*command != ':') {
        WCMD_run_program(command, 1);
    } else {

        WCHAR gotoLabel[MAX_PATH];

        strcpyW(gotoLabel, param1);

        if (context) {

            LARGE_INTEGER li;

            /* Save the current file position, call the same file,
               restore position                                    */
            li.QuadPart = 0;
            li.u.LowPart = SetFilePointer(context -> h, li.u.LowPart,
                                          &li.u.HighPart, FILE_CURRENT);

            WCMD_batch (param1, command, 1, gotoLabel, context->h);

            SetFilePointer(context -> h, li.u.LowPart,
                           &li.u.HighPart, FILE_BEGIN);
        } else {
            WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_CALLINSCRIPT));
        }
    }
}
Пример #2
0
/*******************************************************************
 * WCMD_call - processes a batch call statement
 *
 *	If there is a leading ':', calls within this batch program
 *	otherwise launches another program.
 */
void WCMD_call (WCHAR *command) {

  /* Run other program if no leading ':' */
  if (*command != ':') {
    WCMD_run_program(command, TRUE);
    /* If the thing we try to run does not exist, call returns 1 */
    if (errorlevel) errorlevel=1;
  } else {

    WCHAR gotoLabel[MAX_PATH];

    strcpyW(gotoLabel, param1);

    if (context) {

      LARGE_INTEGER li;
      FOR_CONTEXT oldcontext;

      /* Save the for variable context, then start with an empty context
         as for loop variables do not survive a call                    */
      oldcontext = forloopcontext;
      memset(&forloopcontext, 0, sizeof(forloopcontext));

      /* Save the current file position, call the same file,
         restore position                                    */
      li.QuadPart = 0;
      li.u.LowPart = SetFilePointer(context -> h, li.u.LowPart,
                     &li.u.HighPart, FILE_CURRENT);
      WCMD_batch (param1, command, TRUE, gotoLabel, context->h);
      SetFilePointer(context -> h, li.u.LowPart,
                     &li.u.HighPart, FILE_BEGIN);

      /* Restore the for loop context */
      forloopcontext = oldcontext;
    } else {
      WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_CALLINSCRIPT));
    }
  }
}