当前位置: 首页>>代码示例>>C++>>正文


C++ ShellExecContext类代码示例

本文整理汇总了C++中ShellExecContext的典型用法代码示例。如果您正苦于以下问题:C++ ShellExecContext类的具体用法?C++ ShellExecContext怎么用?C++ ShellExecContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ShellExecContext类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HHVM_FUNCTION

String HHVM_FUNCTION(system,
                     const String& command,
                     VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return empty_string();
  StringBuffer sbuf;
  if (fp) {
    sbuf.read(fp);
  }

  Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
  int ret = ctx.exit();
  if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
  return_var = ret;
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }

  auto& ectx = *g_context;
  for (int i = 0; i < count; i++) {
    ectx.write(lines[i].toString());
    ectx.write("\n");
  }
  if (!count || lines.empty()) {
    return String();
  }

  return HHVM_FN(rtrim)(lines[count - 1].toString());
}
开发者ID:milesj,项目名称:hhvm,代码行数:31,代码来源:ext_process.cpp

示例2: f_system

String f_system(CStrRef command, Variant return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return "";
  StringBuffer sbuf;
  if (fp) {
    sbuf.read(fp);
  }

  Array lines = StringUtil::Explode(sbuf.detach(), "\n");
  return_var = ctx.exit();
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }

  for (int i = 0; i < count; i++) {
    echo(lines[i]);
    echo("\n");
  }
  if (!count || lines.empty()) {
    return String();
  }
  return StringUtil::Trim(lines[count - 1], StringUtil::TrimRight);
}
开发者ID:dipjyotighosh,项目名称:hiphop-php,代码行数:25,代码来源:ext_process.cpp

示例3: f_system

String f_system(const String& command, VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command.c_str());
  if (!fp) return "";
  StringBuffer sbuf;
  if (fp) {
    sbuf.read(fp);
  }

  Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
  int ret = ctx.exit();
  if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
  return_var = ret;
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }

  for (int i = 0; i < count; i++) {
    echo(lines[i].toString());
    echo("\n");
  }
  if (!count || lines.empty()) {
    return String();
  }

  return f_rtrim(lines[count - 1].toString());
}
开发者ID:SeaFlat123,项目名称:hhvm,代码行数:28,代码来源:ext_process.cpp

示例4: f_exec

String f_exec(const String& command, VRefParam output /* = null */,
              VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command.c_str());
  if (!fp) return "";
  StringBuffer sbuf;
  sbuf.read(fp);

  Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
  int ret = ctx.exit();
  if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
  return_var = ret;
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }
  if (!output.is(KindOfArray)) {
    output = Array(ArrayData::Create());
  }

  for (int i = 0; i < count; i++) {
    output.append(lines[i]);
  }

  if (!count || lines.empty()) {
    return String();
  }

  return f_rtrim(lines[count - 1].toString());
}
开发者ID:SeaFlat123,项目名称:hhvm,代码行数:30,代码来源:ext_process.cpp

示例5: f_exec

String f_exec(CStrRef command, Variant output /* = null */,
              Variant return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return "";
  StringBuffer sbuf;
  sbuf.read(fp);

  Array lines = StringUtil::Explode(sbuf.detach(), "\n");
  return_var = ctx.exit();
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }
  if (!output.is(KindOfArray)) {
    output = Array(ArrayData::Create());
  }

  for (int i = 0; i < count; i++) {
    output.append(lines[i]);
  }

  if (!count || lines.empty()) {
    return String();
  }
  return StringUtil::Trim(lines[count - 1], StringUtil::TrimRight);
}
开发者ID:dipjyotighosh,项目名称:hiphop-php,代码行数:27,代码来源:ext_process.cpp

示例6: f_shell_exec

String f_shell_exec(const String& cmd) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(cmd.c_str());
  if (!fp) return "";
  StringBuffer sbuf;
  sbuf.read(fp);
  return sbuf.detach();
}
开发者ID:SeaFlat123,项目名称:hhvm,代码行数:8,代码来源:ext_process.cpp

示例7: f_shell_exec

String f_shell_exec(CStrRef cmd) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(cmd);
  if (!fp) return "";
  StringBuffer sbuf;
  sbuf.read(fp);
  return sbuf.detach();
}
开发者ID:7755373049,项目名称:hiphop-php,代码行数:8,代码来源:ext_process.cpp

示例8: f_passthru

void f_passthru(CStrRef command, Variant return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return;

  char buffer[1024];
  while (true) {
    int len = read(fileno(fp), buffer, sizeof(buffer) - 1);
    if (len == -1 && errno == EINTR) continue;
    if (len <= 0) break; // break on error or EOF
    buffer[len] = '\0';
    echo(String(buffer, len, AttachLiteral));
  }
  return_var = ctx.exit();
}
开发者ID:dipjyotighosh,项目名称:hiphop-php,代码行数:15,代码来源:ext_process.cpp

示例9: f_passthru

void f_passthru(const String& command, VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command.c_str());
  if (!fp) return;

  char buffer[1024];
  while (true) {
    int len = read(fileno(fp), buffer, sizeof(buffer) - 1);
    if (len == -1 && errno == EINTR) continue;
    if (len <= 0) break; // break on error or EOF
    buffer[len] = '\0';
    echo(String(buffer, len, CopyString));
  }
  int ret = ctx.exit();
  if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
  return_var = ret;
}
开发者ID:SeaFlat123,项目名称:hhvm,代码行数:17,代码来源:ext_process.cpp

示例10: HHVM_FUNCTION

void HHVM_FUNCTION(passthru,
                   const String& command,
                   VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return;

  char buffer[1024];
  while (true) {
    int len = read(fileno(fp), buffer, sizeof(buffer) - 1);
    if (len == -1 && errno == EINTR) continue;
    if (len <= 0) break; // break on error or EOF
    buffer[len] = '\0';
    g_context->write(String(buffer, len, CopyString));
  }
  int ret = ctx.exit();
  MAYBE_WIFEXITED(ret);
  return_var.assignIfRef(ret);
}
开发者ID:DerPapst,项目名称:hhvm,代码行数:19,代码来源:ext_std_process.cpp


注:本文中的ShellExecContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。