403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.69.166.65
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/client/base/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/client/base/abstract_options_provider.cc
/*
   Copyright (c) 2001, 2023, Oracle and/or its affiliates.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2.0,
   as published by the Free Software Foundation.

   This program is also distributed with certain software (including
   but not limited to OpenSSL) that is licensed under separate terms,
   as designated in a particular file or component or in included license
   documentation.  The authors of MySQL hereby grant you an additional
   permission to link the program and your derivative works with the
   separately licensed software that they have included with MySQL.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License, version 2.0, for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
   */

#include <vector>
#include <iostream>
#include "my_getopt.h"
#include "abstract_options_provider.h"
#include "i_options_provider.h"

using std::vector;
using std::string;
using std::map;
using namespace Mysql::Tools::Base::Options;
using Mysql::Nullable;


Simple_option* Abstract_options_provider::create_new_option(
  string name, string description)
{
  return this->attach_new_option<Simple_option>(
    new Simple_option(name, description));
}

Disabled_option* Abstract_options_provider::create_new_disabled_option(
  string name, string description)
{
  return this->attach_new_option<Disabled_option>(
    new Disabled_option(name, description));
}

Char_array_option* Abstract_options_provider::create_new_option(
  char** value, string name, string description)
{
  return this->attach_new_option<Char_array_option>(
    new Char_array_option(value, false, name, description));
}

Password_option* Abstract_options_provider::create_new_password_option(
  Nullable<string>* value, string name, string description)
{
  return this->attach_new_option<Password_option>(
    new Password_option(value, name, description));
}

String_option* Abstract_options_provider::create_new_option(
  Nullable<string>* value, string name, string description)
{
  return this->attach_new_option<String_option>(
    new String_option(value, name, description));
}

Number_option<int32>* Abstract_options_provider::create_new_option(
  int32* value, string name, string description)
{
  return this->attach_new_option<Number_option<int32> >(
    new Number_option<int32>(value, name, description));
}

Number_option<uint32>* Abstract_options_provider::create_new_option(
  uint32* value, string name, string description)
{
  return this->attach_new_option<Number_option<uint32> >(
    new Number_option<uint32>(value, name, description));
}

Number_option<int64>* Abstract_options_provider::create_new_option(
  int64* value, string name, string description)
{
  return this->attach_new_option<Number_option<int64> >(
    new Number_option<int64>(value, name, description));
}

Number_option<uint64>* Abstract_options_provider::create_new_option(
  uint64* value, string name, string description)
{
  return this->attach_new_option<Number_option<uint64> >(
    new Number_option<uint64>(value, name, description));
}

Number_option<double>* Abstract_options_provider::create_new_option(
  double* value, string name, string description)
{
  return this->attach_new_option<Number_option<double> >(
    new Number_option<double>(value, name, description));
}

Bool_option* Abstract_options_provider::create_new_option(
  bool* value, string name, string description)
{
  return this->attach_new_option<Bool_option>(
    new Bool_option(value, name, description));
}


vector<my_option> Abstract_options_provider::generate_options()
{
  if (this->m_are_options_created == false)
  {
    this->m_are_options_created= true;
    this->create_options();
  }

  vector<my_option> res;
  for (vector<I_option*>::iterator it= this->m_options_created.begin();
    it != this->m_options_created.end();
    it++)
  {
    res.push_back((*it)->get_my_option());
  }

  return res;
}


void Abstract_options_provider::options_parsed()
{}


Abstract_options_provider::Abstract_options_provider()
  : m_are_options_created(false),
  m_option_changed_listener(NULL)
{}

Abstract_options_provider::~Abstract_options_provider()
{
  for (vector<I_option*>::iterator it= this->m_options_created.begin();
    it != this->m_options_created.end();
    it++)
  {
    delete *it;
  }
}

void Abstract_options_provider::set_option_changed_listener(I_option_changed_listener* listener)
{
  assert(this->m_option_changed_listener == NULL);
  this->m_option_changed_listener= listener;
}


void Abstract_options_provider::notify_option_name_changed(I_option* source,
                                                            string old_name)
{
  // Check if it is modification or new assignment
  if (old_name != "")
  {
    this->m_name_usage.erase(this->m_name_usage.find(old_name));
  }

  string new_name= source->get_my_option().name;

  // Try to find existing option with that name.
  map<string, I_option*>::iterator name_item =
    this->m_name_usage.find(new_name);

  // Report error if already used.
  if (name_item != this->m_name_usage.end())
  {
    std::cerr << "Cannot register new option \"" << new_name
      << "\" as it collides with existing one with following name \""
      << name_item->second->get_my_option().name << "\" and description: "
      << name_item->second->get_my_option().comment << std::endl;
    exit(1);
  }
  // Add name usage.
  this->m_name_usage.insert(std::make_pair(new_name, source));

  // If we have listener we should inform it too.
  if (this->m_option_changed_listener != NULL)
  {
    this->m_option_changed_listener->notify_option_name_changed(source, old_name);
  }
}

void Abstract_options_provider::notify_option_optid_changed(I_option* source,
                                                            uint32 old_optid)
{
  // Check if it is modification or new assignment
  if (old_optid != 0)
  {
    this->m_optid_usage.erase(this->m_optid_usage.find(old_optid));
  }

  uint32 new_optid= source->get_my_option().id;

  // Try to find existing option with that optid.
  map<uint32, I_option*>::iterator optid_item =
    this->m_optid_usage.find(new_optid);

  // Report error if already used.
  if (optid_item != this->m_optid_usage.end())
  {
    string name= source->get_my_option().name;

    std::cerr << "Cannot register new option \"" << name
      << "\" as it collides with existing one with following name \""
      << optid_item->second->get_my_option().name << "\" and description: "
      << optid_item->second->get_my_option().comment << std::endl;
    exit(1);
  }
  // Add optid usage.
  this->m_optid_usage.insert(std::make_pair(new_optid, source));

  // If we have listener we should inform it too.
  if (this->m_option_changed_listener != NULL)
  {
    this->m_option_changed_listener->notify_option_optid_changed(source, old_optid);
  }
}


Youez - 2016 - github.com/yon3zu
LinuXploit