[TRANSLATIONS] Update the email address and add a note in the Turkish translation...
[reactos.git] / base / shell / cmd / call.c
1 /*
2 * CALL.C - call internal batch command.
3 *
4 *
5 * History:
6 *
7 * 16 Jul 1998 (Hans B Pufal)
8 * started.
9 *
10 * 16 Jul 1998 (John P Price)
11 * Separated commands into individual files.
12 *
13 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
14 * added config.h include
15 *
16 * 04-Aug-1998 (Hans B Pufal)
17 * added lines to initialize for pointers (HBP004) This fixed the
18 * lock-up that happened sometimes when calling a batch file from
19 * another batch file.
20 *
21 * 07-Jan-1999 (Eric Kohl)
22 * Added help text ("call /?") and cleaned up.
23 *
24 * 20-Jan-1999 (Eric Kohl)
25 * Unicode and redirection safe!
26 *
27 * 02-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
28 * Remove all hardcoded strings in En.rc
29 */
30
31 #include "precomp.h"
32
33 /*
34 * Perform CALL command.
35 */
36
37 INT cmd_call(LPTSTR param)
38 {
39 TCHAR line[CMDLINE_LENGTH + 1];
40 TCHAR *first;
41 BOOL bInQuote = FALSE;
42
43 TRACE ("cmd_call: (\'%s\')\n", debugstr_aw(param));
44 if (!_tcsncmp (param, _T("/?"), 2))
45 {
46 ConOutResPaging(TRUE,STRING_CALL_HELP);
47 return 0;
48 }
49
50 /* Do a second round of %-variable substitutions */
51 if (!SubstituteVars(param, line, _T('%')))
52 return (nErrorLevel = 1);
53
54 /* Find start and end of first word */
55 first = line;
56 while (_istspace(*first))
57 first++;
58
59 for (param = first; *param; param++)
60 {
61 if (!bInQuote && (_istspace(*param) || _tcschr(_T(",;="), *param)))
62 break;
63 bInQuote ^= (*param == _T('"'));
64 }
65
66 /* Separate first word from rest of line */
67 memmove(param + 1, param, (_tcslen(param) + 1) * sizeof(TCHAR));
68 *param++ = _T('\0');
69
70 if (*first == _T(':') && bc)
71 {
72 /* CALL :label - call a subroutine of the current batch file */
73 while (*param == _T(' '))
74 param++;
75 nErrorLevel = Batch(bc->BatchFilePath, first, param, NULL);
76 return nErrorLevel;
77 }
78
79 nErrorLevel = DoCommand(first, param, NULL);
80 return nErrorLevel;
81 }
82
83 /* EOF */