ns-3 Direct Code Execution
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
dce-global-variables.cc
Go to the documentation of this file.
1 #include <stdio.h>
2 #include "dce-global-variables.h"
3 #include "process.h"
4 #include "utils.h"
5 #include "dce-stdio.h"
6 
7 using namespace ns3;
8 
10 {
11  struct Process *process = Current ()->process;
12  if (process->pstdin != 0)
13  {
14  // protect against multiple calls to this function.
15  return;
16  }
17  process->pstdin = variables->pstdin;
18  process->pstdout = variables->pstdout;
19  process->pstderr = variables->pstderr;
20  process->penvp = variables->penvp;
21  // Now, we initialize the process variables
22  *process->pstdin = dce_fdopen (0, "r");
23  *process->pstdout = dce_fdopen (1, "a"); // Append in order to not erase content while doing an exec
24  *process->pstderr = dce_fdopen (2, "a"); // Append in order to not erase content while doing an exec
25  *process->penvp = process->originalEnvp;
26 
27  process->poptarg = variables->poptarg;
28  process->poptind = variables->poptind;
29  process->popterr = variables->popterr;
30  process->poptopt = variables->poptopt;
31 
32  *variables->pprogname = process->originalProgname;
33  *variables->pprogram_invocation_name = process->originalProgname;
34  char *crsr = process->originalProgname;
35  char *slash = crsr;
36  while (*crsr)
37  {
38  if (*crsr == '/')
39  {
40  crsr++;
41  slash = crsr;
42  }
43  else
44  {
45  crsr++;
46  }
47  }
48  *variables->pprogram_invocation_short_name = slash;
49 }