Ejemplo n.º 1
0
int cmd_show_server(VSTRING& param)
{
  int ret = TFS_ERROR;
  ParamInfo ret_param(SERVER_TYPE_SERVER_INFO);
  if ((ret = parse_param(param, SERVER_TYPE, ret_param)) != TFS_ERROR)
  {
    if (!g_need_cmp)
    {
      g_show_info.show_server(ret_param.type_, ret_param.num_, ret_param.server_ip_port_, ret_param.count_, ret_param.interval_, ret_param.filename_);
    }
    else
    {
      g_cmp_info.compare(SERVER_TYPE, ret_param.type_, ret_param.num_);
    }
  }
  return ret;
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: alimy/tfs
int cmd_show_block(VSTRING& param)
{
  int ret = TFS_ERROR;
  int8_t type = CMD_NOP;
  g_need_cmp ? (type = BLOCK_CMP_ALL_INFO) : (type = BLOCK_TYPE_BLOCK_INFO);
  ParamInfo ret_param(type);
  if ((ret = parse_param(param, BLOCK_TYPE, ret_param)) != TFS_ERROR)
  {
    if (!g_need_cmp)
    {
      g_show_info.show_block(ret_param.type_, ret_param.num_, ret_param.block_id_, ret_param.count_, ret_param.interval_, ret_param.filename_);
    }
    else
    {
      g_cmp_info.compare(BLOCK_TYPE, ret_param.type_, ret_param.num_);
    }
  }
  return ret;
}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: alimy/tfs
int main(int argc,char** argv)
{
  //TODO readline
  int32_t i;
  string ns_ip_port_1;
  string ns_ip_port_2;
  bool directly = false;
  while ((i = getopt(argc, argv, "s:m:ihv")) != EOF)
  {
    switch (i)
    {
      case 's':
        ns_ip_port_2 = optarg;
        break;
      case 'm':
        ns_ip_port_1 = optarg;
        g_need_cmp = true;
        break;
      case 'i':
        directly = true;
        break;
      case 'v':
        version(argv[0]);
        break;
      case 'h':
      default:
        usage(argv[0]);
    }
  }

  if (ns_ip_port_2.empty() || (g_need_cmp && ns_ip_port_1.empty()))
  {
    fprintf(stderr, "please input nameserver ip and port.\n");
    usage(argv[0]);
  }

  TBSYS_LOGGER.setLogLevel("error");

  init();

  gstreamer.set_packet_factory(&gfactory);
  NewClientManager::get_instance().initialize(&gfactory, &gstreamer);

  if (!g_need_cmp)
  {
    g_show_info.set_ns_ip(ns_ip_port_2);
  }
  else
  {
    g_cmp_info.set_ns_ip(ns_ip_port_1, ns_ip_port_2);
  }

  signal(SIGINT, sign_handler);
  signal(SIGTERM, sign_handler);
  if (optind >= argc)
  {
    main_loop();
  }
  else
  {
    if (directly) // ssm ... -i "cmd"
    {
      for (i = optind; i < argc; i++)
      {
        do_cmd(argv[i]);
      }
      g_show_info.clean_last_file();
    }
    else// exec filename
    {
      VSTRING param;
      for (i = optind; i < argc; i++)
      {
        param.clear();
        param.push_back(argv[i]);
        cmd_batch(param);
      }
    }
  }
  NewClientManager::get_instance().destroy();
}