备份
This commit is contained in:
89
demo/kugou/include/Common/include/Chat.hpp
Normal file
89
demo/kugou/include/Common/include/Chat.hpp
Normal file
@@ -0,0 +1,89 @@
|
||||
//#include "os.h"
|
||||
//#include "WebClient.h"
|
||||
//
|
||||
//inline void Loop() {
|
||||
// /*Socket s;
|
||||
// s.Bind("0.0.0.0", 80);
|
||||
// bool b = s.Listen();
|
||||
// for (; b;) {
|
||||
// Socket client = s.Accep();
|
||||
// printf("连接进入 %s %d\n", client.Address.c_str(), client.Port);
|
||||
//
|
||||
// std::string resp;
|
||||
// size_t pos = -1;
|
||||
// size_t length = 0;
|
||||
// std::string body;
|
||||
// bool end = false;
|
||||
// for (;;) {
|
||||
// char buf[128]{ 0 };
|
||||
// int len = client.Receive(buf, sizeof(buf));
|
||||
// if (len == -1 || len == 0) {
|
||||
// client.Close();
|
||||
// printf("客户端断开 %s %d\n", client.Address.c_str(), client.Port);
|
||||
// break;
|
||||
// }
|
||||
// if (!end) {
|
||||
// resp.append(buf, len);
|
||||
// }
|
||||
// else {
|
||||
// body.append(buf, len);
|
||||
// }
|
||||
// if (!end && (pos = resp.find("\r\n\r\n")) != -1) {
|
||||
// body.append(resp.c_str() + pos + 4, resp.size() - pos - 4);
|
||||
// end = true;
|
||||
// auto pos2 = resp.find("Content-Length:");
|
||||
// if (pos2 != -1) {
|
||||
// std::string len;
|
||||
// for (size_t i = pos2 + 7; i < resp.size(); i++)
|
||||
// {
|
||||
// if (resp.at(i) >= '0' && resp.at(i) <= '9') {
|
||||
// len += resp.at(i);
|
||||
// }
|
||||
// else {
|
||||
// length = std::atoi(len.c_str());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (end && body.size() >= length) {
|
||||
// client.Close();
|
||||
// printf("服务端断开 %s %d\n", client.Address.c_str(), client.Port);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// printf("%s\n", body.c_str());
|
||||
// }*/
|
||||
//}
|
||||
//
|
||||
//int main(int argc, char* argv[])
|
||||
//{
|
||||
//
|
||||
// StopWatch sw;
|
||||
// for (size_t i = 0; i < 15; i++)
|
||||
// {
|
||||
// WebClient wc;
|
||||
// std::string resp;
|
||||
// std::string key = "var items=";
|
||||
// size_t pos1 = size_t(-1), pos2 = size_t(-1);
|
||||
// wc.CallBack = ([=, &pos1, &pos2](char* contents, size_t size, size_t nmemb, void* respone)->size_t {
|
||||
// size_t count = size * nmemb;
|
||||
// std::string* str = (std::string*)respone;
|
||||
// (*str).append(contents, count);
|
||||
// if (pos1 == size_t(-1)) {
|
||||
// pos1 = str->find(key);
|
||||
// }
|
||||
// if (pos1 != size_t(-1)) {
|
||||
// pos2 = str->find("}];", key.size() + pos1);
|
||||
// if (pos2 != size_t(-1)) {
|
||||
// *str = str->substr(pos1 + key.size(), pos2 - (pos1 + key.size())) + "}]";
|
||||
// return 23;//终止
|
||||
// }
|
||||
// }
|
||||
// return count;
|
||||
// });
|
||||
// wc.HttpGet("http://163.197.44.13/Web/reserve/materialx?languages=1", resp, 999);
|
||||
// }
|
||||
// auto time = sw.ElapsedMilliseconds();
|
||||
// return 0;
|
||||
//}
|
||||
30
demo/kugou/include/Common/include/Common.h
Normal file
30
demo/kugou/include/Common/include/Common.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <map>
|
||||
#include <io.h>
|
||||
#include <Windows.h>
|
||||
#include <winuser.h>
|
||||
#include <assert.h>
|
||||
|
||||
#pragma warning(disable:4018)
|
||||
#pragma warning(disable:4244)
|
||||
#pragma warning(disable:4551)
|
||||
#pragma warning(disable:4293)
|
||||
#pragma warning(disable:4996)
|
||||
#pragma warning(disable:4099)
|
||||
#pragma warning(disable:4800)
|
||||
#pragma warning(disable:4101)
|
||||
#pragma warning(disable:4267)
|
||||
|
||||
|
||||
#include "Text.h"
|
||||
#include "FileSystem.h"
|
||||
#include "Time.hpp"//防止和系统的time.h重命名
|
||||
#include "WinTool.h"
|
||||
38
demo/kugou/include/Common/include/ConfigIni.h
Normal file
38
demo/kugou/include/Common/include/ConfigIni.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include "Text.h"
|
||||
|
||||
class ConfigIni {
|
||||
protected:
|
||||
size_t buffSize;
|
||||
Text::String filename;
|
||||
Text::String section;
|
||||
DWORD GetValue(const Text::String& key, const Text::String& filename, Text::String& outResult);
|
||||
bool SetValue(const Text::String& key, const Text::String& Value, const Text::String& absoluteFilename);
|
||||
private:
|
||||
ConfigIni() = delete;
|
||||
ConfigIni(const ConfigIni&) = delete;
|
||||
public:
|
||||
//FileName //一定要绝对路径
|
||||
ConfigIni(const Text::String& filename, const Text::String& defaultSection = "setting", size_t buffSize = 1024);
|
||||
//设置一个名称
|
||||
void SetSection(const Text::String& sectionName);
|
||||
//读取ini中的字符
|
||||
Text::String ReadString(const Text::String& key, const Text::String& defaultValue = "");
|
||||
//读取ini中的数字
|
||||
float ReadFloat(const Text::String& key, float defaultValue = 0);
|
||||
//读取ini中的int数字
|
||||
int ReadInt(const Text::String& key, int defaultValue = 0);
|
||||
//读取bool类型值
|
||||
bool ReadBool(const Text::String& key, bool defaultValue = false);
|
||||
//写入ini
|
||||
bool WriteString(const Text::String& key, const Text::String& value);
|
||||
bool WriteFloat(const Text::String& key, float value);
|
||||
bool WriteInt(const Text::String& key, int value);
|
||||
bool WriteBool(const Text::String& key, bool defaultValue);
|
||||
|
||||
//获取所有的Section
|
||||
std::vector<Text::String> GetSections();
|
||||
//删除所有的Section
|
||||
void DeleteSection(const Text::String& section);
|
||||
};
|
||||
147
demo/kugou/include/Common/include/FileSystem.h
Normal file
147
demo/kugou/include/Common/include/FileSystem.h
Normal file
@@ -0,0 +1,147 @@
|
||||
#pragma once
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <Windows.h>
|
||||
#include "Text.h"
|
||||
|
||||
namespace FileSystem {
|
||||
class FileInfo;
|
||||
enum FileType :int
|
||||
{
|
||||
File = 2,
|
||||
Directory = 4
|
||||
};
|
||||
//重载枚举的 | 运算符
|
||||
inline FileType operator|(FileType left, FileType right)
|
||||
{
|
||||
return static_cast<FileType>(static_cast<int>(left) | static_cast<int>(right));
|
||||
}
|
||||
};
|
||||
|
||||
namespace File {
|
||||
typedef std::string FileStream;
|
||||
//创建文件
|
||||
extern bool Create(const Text::String& filename);
|
||||
//删除文件
|
||||
extern bool Delete(const Text::String& filename);
|
||||
//判断文件是否存在
|
||||
extern bool Exists(const Text::String& filename);
|
||||
//文件移动或者改名
|
||||
extern bool Move(const Text::String& oldname, const Text::String& newname);
|
||||
//读取文件并out返回
|
||||
extern bool ReadFile(const Text::String& filename, FileStream* fileStream);
|
||||
//写入文件
|
||||
extern bool WriteFile(const FileStream* fileStream, const Text::String& filename);
|
||||
//写入文件
|
||||
extern bool WriteFile(const char* fileStream, size_t count, const Text::String& filename);
|
||||
//拷贝文件
|
||||
extern bool Copy(const Text::String& filename, const Text::String& des_filename, bool overwrite = true);
|
||||
//获取文件字节大小
|
||||
extern ULONGLONG GetFileSize(const Text::String& fileName);
|
||||
};
|
||||
|
||||
namespace Directory {
|
||||
//创建目录
|
||||
extern bool Create(const Text::String& path);
|
||||
//拷贝目录所有文件到目标目录
|
||||
extern bool Copy(const Text::String& srcPath, const Text::String& desPath, bool overwrite = true);
|
||||
//移动目录到新位置
|
||||
extern bool Move(const Text::String& oldname, const Text::String& newname);
|
||||
//删除路径 如果存在子文件夹或者文件 将会递归删除
|
||||
extern bool Delete(const Text::String& directoryName);
|
||||
//通配符查找文件夹/文件
|
||||
extern size_t Find(const Text::String& path, std::vector<FileSystem::FileInfo>& result, const Text::String& pattern = "*.*", bool loopSubDir = false, FileSystem::FileType fileType = FileSystem::FileType::Directory | FileSystem::FileType::File);
|
||||
//检查路径是否存在
|
||||
extern bool Exists(const Text::String& path);
|
||||
};
|
||||
|
||||
namespace Path {
|
||||
//格式化路径为统一反斜杠
|
||||
extern Text::String Format(const Text::String& path);
|
||||
//判断路径是不是相同
|
||||
extern bool Equal(const Text::String& path1, const Text::String& path2);
|
||||
//获取文件名称(文件名称)
|
||||
extern Text::String GetFileNameWithoutExtension(const Text::String& _filename);
|
||||
//获取文件目录名称(所在目录)
|
||||
extern Text::String GetDirectoryName(const Text::String& _filename);
|
||||
//获取文件名称+后缀
|
||||
extern Text::String GetFileName(const Text::String& _filename);
|
||||
//获取用户桌面路径
|
||||
extern Text::String UserDesktop(bool publicUser = true);
|
||||
//获取开始菜单路径
|
||||
extern Text::String StartPrograms(bool publicUser = true);
|
||||
//获取文件后缀名(后缀名)
|
||||
extern Text::String GetExtension(const Text::String& _filename);
|
||||
//获取进程所在绝对路径目录
|
||||
extern Text::String StartPath();
|
||||
//获取进程所在绝对路径包含文件名称
|
||||
extern const Text::String& StartFileName();
|
||||
#undef GetTempPath
|
||||
/// <summary>
|
||||
/// 获取应当前windows用户的临时目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
extern Text::String GetTempPath();
|
||||
/// <summary>
|
||||
/// 获取应用程序的临时目录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
extern Text::String GetAppTempPath(const Text::String& appName = "");
|
||||
/// <summary>
|
||||
/// 获取应用程序数据存储目录 C:/Users/%s/AppData/Local/%s
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
extern Text::String GetAppDataPath(const Text::String& appName = "");
|
||||
};
|
||||
namespace FileSystem {
|
||||
class FileInfo
|
||||
{
|
||||
private:
|
||||
std::ifstream* ifs = NULL;
|
||||
ULONGLONG StreamPos = 0;
|
||||
public:
|
||||
DWORD dwFileAttributes;
|
||||
const Text::String FileName;
|
||||
bool IsFile() const {
|
||||
return !(dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||
}
|
||||
bool IsReadOnly() const {
|
||||
return dwFileAttributes & FILE_ATTRIBUTE_READONLY;
|
||||
}
|
||||
const ULONGLONG FileSize = 0;
|
||||
FileInfo() {}
|
||||
FileInfo(const Text::String& fileName) {
|
||||
if (File::Exists(fileName)) {
|
||||
(Text::String)FileName = fileName;
|
||||
//获取大小
|
||||
ifs = new std::ifstream(fileName.unicode(), std::ios::binary);
|
||||
ifs->seekg(0, std::ios::end);
|
||||
(ULONGLONG&)FileSize = ifs->tellg();
|
||||
}
|
||||
}
|
||||
size_t Read(char* _buf_, size_t _rdCount = 255) {
|
||||
size_t rdbufCount = _rdCount;
|
||||
if (StreamPos + _rdCount >= FileSize) {
|
||||
rdbufCount = FileSize - StreamPos;
|
||||
}
|
||||
if (rdbufCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (ifs == NULL) {
|
||||
ifs = new std::ifstream(FileName.unicode(), std::ios::binary);
|
||||
}
|
||||
ifs->seekg(StreamPos);
|
||||
ifs->read(_buf_, rdbufCount);
|
||||
StreamPos += rdbufCount;
|
||||
return rdbufCount;
|
||||
}
|
||||
void Close() {
|
||||
ifs->close();
|
||||
}
|
||||
~FileInfo() {
|
||||
if (ifs) {
|
||||
delete ifs;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
39
demo/kugou/include/Common/include/JsonValue.h
Normal file
39
demo/kugou/include/Common/include/JsonValue.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
|
||||
#define USEJSONCPP 1 //是否使用JsonCpp库
|
||||
|
||||
#if USEJSONCPP
|
||||
#include <json/json.h>
|
||||
|
||||
#ifdef _WIN64
|
||||
|
||||
#ifdef _DEBUG
|
||||
#pragma comment (lib,"X64/json_libd.lib")
|
||||
#else
|
||||
#pragma comment (lib,"X64/json_lib.lib")
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef _DEBUG
|
||||
#pragma comment (lib,"json_libd.lib")
|
||||
#else
|
||||
#pragma comment (lib,"json_lib.lib")
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct JsonValue :public Json::Value {
|
||||
private:
|
||||
bool b = false;
|
||||
Json::Reader rd;
|
||||
public:
|
||||
bool IsJson();
|
||||
//JObject(const Json::Value& right);
|
||||
JsonValue& operator = (const Json::Value& other);
|
||||
JsonValue(const std::string& jsonStr);
|
||||
};
|
||||
#endif
|
||||
37
demo/kugou/include/Common/include/Log.h
Normal file
37
demo/kugou/include/Common/include/Log.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "Time.hpp"
|
||||
namespace Log {
|
||||
//是否启用日志
|
||||
extern bool Enable;
|
||||
extern bool WriteFile;
|
||||
extern void WriteLog(const Text::String& log);
|
||||
|
||||
template<typename ...T>
|
||||
/// <summary>
|
||||
/// 打印utf8的字符
|
||||
/// </summary>
|
||||
/// <typeparam name="...T"></typeparam>
|
||||
/// <param name="formatStr"></param>
|
||||
/// <param name="...args"></param>
|
||||
inline Text::String Info(const Text::String& formatStr, const T &...args) {
|
||||
if (!Enable)return "";
|
||||
// 计算格式化后的字符串所需的内存大小
|
||||
int bufSize = ::snprintf(nullptr, 0, formatStr.c_str(), args...) + 2; // +1是为了换行符和结束符 \n '\0'
|
||||
char* buf = new char[bufSize];
|
||||
auto count = ::sprintf_s(buf, bufSize, formatStr.c_str(), std::forward<const T&>(args)...);
|
||||
buf[count] = '\n';
|
||||
buf[count + 1] = 0;
|
||||
Text::String info(buf);
|
||||
info = Time::Now().ToString("HH:mm:ss ") + info;
|
||||
delete[] buf;
|
||||
//转为本地可识别的编码
|
||||
auto ansi = info.ansi();
|
||||
std::cout << ansi;
|
||||
OutputDebugStringA(ansi.c_str());
|
||||
WriteLog(info);
|
||||
return info;
|
||||
}
|
||||
};
|
||||
46
demo/kugou/include/Common/include/Map.hpp
Normal file
46
demo/kugou/include/Common/include/Map.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
|
||||
template<class T1, class T2>
|
||||
class Map :protected std::unordered_map<T1, T2> {
|
||||
using __base = std::unordered_map<T1, T2>;
|
||||
T2 defaultValue = T2();//当获取不到value的时候返回的默认值
|
||||
public:
|
||||
typename __base::iterator begin() {
|
||||
return __base::begin();
|
||||
}
|
||||
typename __base::iterator end() {
|
||||
return __base::end();
|
||||
}
|
||||
bool insert(const T1& key, const T2& value) {
|
||||
auto itor = __base::insert(std::pair<T1, T2>(key, value));
|
||||
return itor.second;
|
||||
}
|
||||
bool empty() {
|
||||
return __base::empty();
|
||||
}
|
||||
size_t size() {
|
||||
return __base::size();
|
||||
}
|
||||
const T2& operator[](const T1& key) const {
|
||||
auto itor = __base::find(key);
|
||||
if (itor != __base::end()) {
|
||||
return itor->second;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
typename __base::iterator find(const T1& key) {
|
||||
return __base::find(key);
|
||||
}
|
||||
void erase(const typename __base::iterator& itor) {
|
||||
__base::erase(itor);
|
||||
}
|
||||
bool erase(const T1& key) {
|
||||
auto itor = __base::find(key);
|
||||
if (itor != __base::end()) {
|
||||
__base::erase(itor);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
284
demo/kugou/include/Common/include/MySqlClient.hpp
Normal file
284
demo/kugou/include/Common/include/MySqlClient.hpp
Normal file
@@ -0,0 +1,284 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <winsock.h>
|
||||
#include <mysql/mysql.h>
|
||||
#pragma comment(lib,"libmysql.lib")
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "JsonValue.h"
|
||||
/*
|
||||
mysql的连接类
|
||||
*/
|
||||
class MySqlClient
|
||||
{
|
||||
public:
|
||||
//处理防注入的
|
||||
class PreparedStatement {
|
||||
struct Pair {
|
||||
char type;
|
||||
int value_int;//type 0
|
||||
std::string value_str;//type 1
|
||||
};
|
||||
std::string sql;
|
||||
std::vector<Pair> values;
|
||||
friend MySqlClient;
|
||||
public:
|
||||
PreparedStatement(const std::string& sql) :sql(sql) {
|
||||
}
|
||||
PreparedStatement& Replace(int value) {
|
||||
values.push_back({ 0,value });
|
||||
return *this;
|
||||
}
|
||||
PreparedStatement& Replace(const std::string& value) {
|
||||
values.push_back({ 1,0,value });
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::string host;
|
||||
std::string user;
|
||||
std::string pwd;
|
||||
std::string database;
|
||||
std::string charset;
|
||||
unsigned int port = 3306;
|
||||
private:
|
||||
static size_t get_data(MYSQL_RES* result, std::string& jsonArr) {
|
||||
std::vector<std::string> fields;
|
||||
//获取列名
|
||||
size_t filedCount = mysql_num_fields(result);
|
||||
for (size_t i = 0; i < filedCount; i++)
|
||||
{
|
||||
std::string name = mysql_fetch_field(result)->name;
|
||||
fields.push_back(name);
|
||||
//std::cout << name << std::endl;
|
||||
}
|
||||
jsonArr = "[";
|
||||
//获取每行的数据
|
||||
MYSQL_ROW sql_row;
|
||||
size_t rowCount = 0;
|
||||
while (sql_row = mysql_fetch_row(result))//获取具体的数据
|
||||
{
|
||||
rowCount++;
|
||||
jsonArr.append("{");
|
||||
bool frist_ = true;
|
||||
for (size_t i = 0; i < filedCount; i++)
|
||||
{
|
||||
if (sql_row[i]) {
|
||||
jsonArr.append("\"" + fields[i] + "\":\"" + sql_row[i] + "\"");
|
||||
}
|
||||
else {
|
||||
jsonArr.append("\"" + fields[i] + "\":\"\"");
|
||||
}
|
||||
jsonArr.append(",");
|
||||
}
|
||||
jsonArr.erase(jsonArr.length() - 1, 1);
|
||||
jsonArr.append("},");
|
||||
}
|
||||
jsonArr.erase(jsonArr.length() - 1, 1);
|
||||
jsonArr.append("]");
|
||||
if (rowCount == 0) {
|
||||
jsonArr = "[]";
|
||||
}
|
||||
return rowCount;
|
||||
}
|
||||
public:
|
||||
bool OpenConn(MYSQL& mysql);
|
||||
void CloseConn(MYSQL& mysql);
|
||||
MySqlClient(const std::string& host, unsigned int port, const std::string& user, const std::string& pwd, const std::string& database, const std::string& charset = "utf8mb4");
|
||||
/*执行查询*/
|
||||
bool ExecuteQuery(const std::string& sql, std::string& result);
|
||||
/*执行增删改*/
|
||||
size_t ExecuteNoQuery(const std::string& sql);
|
||||
|
||||
size_t Insert(const std::string& tableName, const Json::Value& jv);
|
||||
size_t Update(const std::string& tableName, const Json::Value& jv, const std::string& whereText);
|
||||
bool ExecuteQuery(const std::string& sql, Json::Value& result);
|
||||
bool ExecuteSTMT(const PreparedStatement& _stmt, std::string& result);
|
||||
virtual ~MySqlClient();
|
||||
};
|
||||
|
||||
inline bool MySqlClient::OpenConn(MYSQL& mysql)
|
||||
{
|
||||
const char* unix_socket = NULL;
|
||||
unsigned long client_flag = 0;
|
||||
mysql_init(&mysql); //初始化
|
||||
if ((mysql_real_connect(&mysql, host.c_str(), user.c_str(), pwd.c_str(), database.c_str(), port, unix_socket, client_flag)) == NULL) //连接MySQL
|
||||
{
|
||||
//数据库打开失败
|
||||
printf("%s\n", mysql_error(&mysql));
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
//数据库打开
|
||||
return true;
|
||||
}
|
||||
}
|
||||
inline void MySqlClient::CloseConn(MYSQL& mysql)
|
||||
{
|
||||
mysql_close(&mysql);
|
||||
}
|
||||
inline MySqlClient::MySqlClient(const std::string& host, unsigned int port, const std::string& user, const std::string& pwd, const std::string& database, const std::string& charset)
|
||||
{
|
||||
this->host = host;
|
||||
this->user = user;
|
||||
this->pwd = pwd;
|
||||
this->database = database;
|
||||
this->charset = charset;
|
||||
this->port = port;
|
||||
}
|
||||
inline bool MySqlClient::ExecuteSTMT(const PreparedStatement& _stmt, std::string& resultJson) {
|
||||
MYSQL mysql;
|
||||
if (!OpenConn(mysql)) {
|
||||
return false;
|
||||
}
|
||||
std::string charset_ = "set names ";
|
||||
charset_.append(charset);
|
||||
mysql_query(&mysql, charset_.c_str());
|
||||
|
||||
MYSQL_BIND* binds = NULL;
|
||||
MYSQL_STMT* stmt = NULL;
|
||||
MYSQL_RES* result = NULL;
|
||||
bool ok = false;
|
||||
do
|
||||
{
|
||||
binds = new MYSQL_BIND[_stmt.values.size()];
|
||||
::memset(binds, 0, sizeof(MYSQL_BIND) * _stmt.values.size());
|
||||
int pos = 0;
|
||||
for (auto& it : _stmt.values) {
|
||||
if (it.type == 0) {
|
||||
binds[pos].buffer_type = MYSQL_TYPE_LONG;
|
||||
binds[pos].buffer = (char*)&it.value_int;
|
||||
binds[pos].is_null = 0;
|
||||
}
|
||||
else if (it.type == 1) {
|
||||
binds[pos].buffer_type = MYSQL_TYPE_STRING;
|
||||
binds[pos].buffer = (char*)it.value_str.c_str();
|
||||
binds[pos].buffer_length = it.value_str.size();
|
||||
binds[pos].is_null = 0;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
stmt = mysql_stmt_init(&mysql);
|
||||
if (mysql_stmt_prepare(stmt, _stmt.sql.c_str(), _stmt.sql.size()) != 0) {
|
||||
std::cerr << "Failed to mysql_stmt_prepare: " << mysql_stmt_error(stmt) << std::endl;
|
||||
break;
|
||||
}
|
||||
if (mysql_stmt_bind_param(stmt, binds) != 0) {
|
||||
std::cerr << "Failed to mysql_stmt_bind_param: " << mysql_stmt_error(stmt) << std::endl;
|
||||
break;
|
||||
}
|
||||
//执行
|
||||
if (mysql_stmt_execute(stmt) != 0) {
|
||||
std::cerr << "Failed to mysql_stmt_execute: " << mysql_stmt_error(stmt) << std::endl;
|
||||
break;
|
||||
}
|
||||
result = mysql_stmt_result_metadata(stmt);
|
||||
ok = true;
|
||||
} while (false);
|
||||
//获取结果
|
||||
if (result == NULL) {
|
||||
resultJson = "[]";
|
||||
}
|
||||
else {
|
||||
get_data(result, resultJson);
|
||||
}
|
||||
//释放
|
||||
CloseConn(mysql);
|
||||
delete[] binds;
|
||||
mysql_stmt_close(stmt);
|
||||
mysql_free_result(result);
|
||||
return ok;
|
||||
}
|
||||
inline bool MySqlClient::ExecuteQuery(const std::string& sql, std::string& resultx)
|
||||
{
|
||||
MYSQL mysql;
|
||||
if (!OpenConn(mysql)) {
|
||||
return false;
|
||||
}
|
||||
std::string charset_ = "set names ";
|
||||
charset_.append(charset);
|
||||
mysql_query(&mysql, charset_.c_str());
|
||||
mysql_query(&mysql, sql.c_str());
|
||||
MYSQL_RES* result = NULL;
|
||||
result = mysql_store_result(&mysql);
|
||||
//查询失败
|
||||
if (!result) {
|
||||
mysql_free_result(result);
|
||||
CloseConn(mysql);
|
||||
resultx = "[]";
|
||||
return false;
|
||||
}
|
||||
get_data(result, resultx);
|
||||
//释放
|
||||
mysql_free_result(result);
|
||||
CloseConn(mysql);
|
||||
return true;
|
||||
}
|
||||
inline size_t MySqlClient::ExecuteNoQuery(const std::string& sql)
|
||||
{
|
||||
MYSQL mysql;
|
||||
if (!OpenConn(mysql)) {
|
||||
return false;
|
||||
}
|
||||
std::string charset_ = "set names ";
|
||||
charset_.append(charset);
|
||||
mysql_query(&mysql, charset_.c_str());
|
||||
mysql_query(&mysql, sql.c_str());
|
||||
size_t affected_row = mysql_affected_rows(&mysql);
|
||||
CloseConn(mysql);
|
||||
return affected_row;
|
||||
}
|
||||
inline size_t MySqlClient::Update(const std::string& tableName, const Json::Value& jv, const std::string& whereText) {
|
||||
std::string sql = "update " + tableName + " set ";
|
||||
for (const auto& key : jv.getMemberNames()) {
|
||||
if (jv[key].isNumeric()) {
|
||||
sql += (key + "=" + jv[key].toString() + "");
|
||||
}
|
||||
else if (jv[key].isString()) {
|
||||
sql += (key + "='" + jv[key].asString() + "'");
|
||||
}
|
||||
else {
|
||||
sql += (key + "='" + jv[key].toString() + "'");
|
||||
}
|
||||
sql += ",";
|
||||
}
|
||||
sql.erase(sql.size() - 1, 1);
|
||||
sql += " " + whereText;
|
||||
return this->ExecuteNoQuery(sql);
|
||||
}
|
||||
inline size_t MySqlClient::Insert(const std::string& tableName, const Json::Value& jv) {
|
||||
std::string keys = "(";
|
||||
std::string values = "(";
|
||||
for (const auto& key : jv.getMemberNames()) {
|
||||
keys += "" + key + ",";
|
||||
if (jv[key].isNumeric()) {
|
||||
values += jv[key].toString() + ",";
|
||||
}
|
||||
else if (jv[key].isString()) {
|
||||
values += "'" + jv[key].asString() + "',";
|
||||
}
|
||||
else {
|
||||
values += "'" + jv[key].asString() + "',";
|
||||
}
|
||||
}
|
||||
keys.erase(keys.size() - 1, 1);
|
||||
values.erase(values.size() - 1, 1);
|
||||
keys += ")";
|
||||
values += ")";
|
||||
std::string sql = "insert into " + tableName + " " + keys + "values" + values;
|
||||
return this->ExecuteNoQuery(sql);
|
||||
}
|
||||
inline bool MySqlClient::ExecuteQuery(const std::string& sql, Json::Value& result)
|
||||
{
|
||||
std::string str;
|
||||
auto ret = this->ExecuteQuery(sql, str);
|
||||
result = JsonValue(str);
|
||||
return ret;
|
||||
}
|
||||
inline MySqlClient::~MySqlClient()
|
||||
{
|
||||
}
|
||||
132
demo/kugou/include/Common/include/OrcaleClient.hpp
Normal file
132
demo/kugou/include/Common/include/OrcaleClient.hpp
Normal file
@@ -0,0 +1,132 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <occi/occi.h>
|
||||
using namespace oracle::occi;
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib,"oraocci12d.lib")
|
||||
#else
|
||||
#pragma comment(lib,"oraocci12.lib")
|
||||
#endif // _DEBUG
|
||||
#include <string>
|
||||
class OrcaleClient
|
||||
{
|
||||
private:
|
||||
std::string host;
|
||||
unsigned int port = 1521;
|
||||
std::string user;
|
||||
std::string pwd;
|
||||
std::string server_name;
|
||||
std::string charset;
|
||||
Environment* outEnv = NULL;
|
||||
std::string dbStr;
|
||||
public:
|
||||
virtual ~OrcaleClient() {
|
||||
if (outEnv) {
|
||||
Environment::terminateEnvironment(outEnv);
|
||||
}
|
||||
}
|
||||
OrcaleClient(const std::string& host, unsigned int port, const std::string& user, const std::string& pwd, const std::string& server_name, const std::string& charset = "UTF8");
|
||||
void CloseConn(Connection* conn);
|
||||
Connection* OpenConn();
|
||||
bool ExecuteQuery(const std::string& sql, std::string& sqlResult);
|
||||
size_t ExecuteNoQuery(const std::string& sql);
|
||||
};
|
||||
|
||||
inline Connection* OrcaleClient::OpenConn() {
|
||||
try
|
||||
{
|
||||
auto conn = outEnv->createConnection(user, pwd, dbStr);
|
||||
return conn;
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
printf("%s\n", ex.what());
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
inline void OrcaleClient::CloseConn(Connection* conn) {
|
||||
outEnv->terminateConnection(conn);
|
||||
}
|
||||
inline OrcaleClient::OrcaleClient(const std::string& host, unsigned int port, const std::string& user, const std::string& pwd, const std::string& server_name, const std::string& charset) {
|
||||
this->host = host;
|
||||
this->port = port;
|
||||
this->user = user;
|
||||
this->pwd = pwd;
|
||||
this->server_name = server_name;
|
||||
this->charset = charset;
|
||||
this->dbStr = host + ":" + std::to_string(port) + "/" + server_name;
|
||||
this->outEnv = Environment::createEnvironment("ZHS16GBK", this->charset);//编码问题
|
||||
}
|
||||
inline size_t OrcaleClient::ExecuteNoQuery(const std::string& sql) {
|
||||
size_t affRow = 0;
|
||||
auto conn = OpenConn();
|
||||
if (conn) {
|
||||
Statement* stmt = NULL;
|
||||
try {
|
||||
stmt = conn->createStatement();
|
||||
affRow = stmt->executeUpdate(sql);
|
||||
}
|
||||
catch (SQLException& ex)
|
||||
{
|
||||
printf("%s\n", ex.what());
|
||||
}
|
||||
if (stmt) {
|
||||
conn->terminateStatement(stmt);
|
||||
}
|
||||
CloseConn(conn);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
inline bool OrcaleClient::ExecuteQuery(const std::string& sql, std::string& sqlResult) {
|
||||
bool ok = false;
|
||||
auto conn = OpenConn();
|
||||
if (conn) {
|
||||
std::vector<std::string> fields;
|
||||
Statement* stmt = NULL;
|
||||
ResultSet* rset = NULL;
|
||||
try {
|
||||
stmt = conn->createStatement();
|
||||
rset = stmt->executeQuery(sql);
|
||||
for (auto item : rset->getColumnListMetaData()) {
|
||||
std::string s = item.getString(MetaData::ATTR_NAME);
|
||||
fields.push_back(s);
|
||||
}
|
||||
sqlResult = "[";
|
||||
//获取每行的数据
|
||||
bool frist = true;
|
||||
size_t rowCount = 0;
|
||||
while (rset->next())//获取具体的数据
|
||||
{
|
||||
rowCount++;
|
||||
sqlResult.append("{");
|
||||
bool frist_ = true;
|
||||
for (size_t i = 0; i < fields.size(); i++)
|
||||
{
|
||||
sqlResult.append("\"" + fields[i] + "\":\"" + rset->getString(i + 1) + "\"");
|
||||
sqlResult.append(",");
|
||||
}
|
||||
sqlResult.erase(sqlResult.length() - 1, 1);
|
||||
sqlResult.append("},");
|
||||
if (frist) {
|
||||
frist = false;
|
||||
}
|
||||
}
|
||||
sqlResult.erase(sqlResult.length() - 1, 1);
|
||||
sqlResult.append("]");
|
||||
if (rowCount == 0) {
|
||||
sqlResult = "[]";
|
||||
}
|
||||
ok = true;
|
||||
}
|
||||
catch (SQLException& ex)
|
||||
{
|
||||
printf("%s\n", ex.what());
|
||||
}
|
||||
if (stmt && rset) {
|
||||
stmt->closeResultSet(rset);
|
||||
conn->terminateStatement(stmt);
|
||||
}
|
||||
CloseConn(conn);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
169
demo/kugou/include/Common/include/QrenCode.hpp
Normal file
169
demo/kugou/include/Common/include/QrenCode.hpp
Normal file
@@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
#include "Common.h"
|
||||
#include "qrcode/qrencode.h"
|
||||
|
||||
#ifdef _WIN64
|
||||
#ifdef _DEBUG
|
||||
#pragma comment (lib,"X64/libqrencode_d.lib")
|
||||
#else
|
||||
#pragma comment (lib,"X64/libqrencode.lib")
|
||||
#endif
|
||||
#else
|
||||
#ifdef _DEBUG
|
||||
#pragma comment(lib,"libqrencode_d.lib")
|
||||
#else
|
||||
#pragma comment(lib,"libqrencode.lib")
|
||||
#endif // !_DEBUG
|
||||
#endif
|
||||
|
||||
namespace QrenCode {
|
||||
//生成二维码 返回位图 用完位图记得释放
|
||||
inline HBITMAP Generate(const std::string& str, QRecLevel level = QRecLevel::QR_ECLEVEL_M) {
|
||||
unsigned int unWidth, x, y, l, n, unWidthAdjusted;
|
||||
byte* pRGBData = NULL, * pSourceData, * pDestData;
|
||||
QRcode* pQRC = NULL;
|
||||
HBITMAP bmp = NULL;
|
||||
do
|
||||
{
|
||||
if (pQRC = QRcode_encodeString(str.c_str(), 0, level, QR_MODE_8, 1))
|
||||
{
|
||||
unWidth = pQRC->width;
|
||||
unWidthAdjusted = unWidth * 8 * 3;
|
||||
if (unWidthAdjusted % 4) {
|
||||
unWidthAdjusted = (unWidthAdjusted / 4 + 1) * 4;
|
||||
}
|
||||
|
||||
BITMAPINFO bmpInfo;
|
||||
memset(&bmpInfo, 0, sizeof(bmpInfo));
|
||||
BITMAPINFOHEADER& kInfoHeader = bmpInfo.bmiHeader;
|
||||
kInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
kInfoHeader.biWidth = unWidth * 8;
|
||||
kInfoHeader.biHeight = -((int)unWidth * 8);
|
||||
kInfoHeader.biPlanes = 1;
|
||||
kInfoHeader.biBitCount = 24;
|
||||
kInfoHeader.biCompression = BI_RGB;
|
||||
kInfoHeader.biSizeImage = 0;
|
||||
kInfoHeader.biXPelsPerMeter = 0;
|
||||
kInfoHeader.biYPelsPerMeter = 0;
|
||||
kInfoHeader.biClrUsed = 0;
|
||||
kInfoHeader.biClrImportant = 0;
|
||||
// Convert QrCode bits to bmp pixels
|
||||
pSourceData = pQRC->data;
|
||||
|
||||
bmp = ::CreateDIBSection(NULL, &bmpInfo, DIB_RGB_COLORS, (void**)&pRGBData, NULL, 0);
|
||||
|
||||
for (y = 0; y < unWidth; y++)
|
||||
{
|
||||
pDestData = pRGBData + unWidthAdjusted * y * 8;
|
||||
for (x = 0; x < unWidth; x++)
|
||||
{
|
||||
if (*pSourceData & 1)
|
||||
{
|
||||
for (l = 0; l < 8; l++)
|
||||
{
|
||||
for (n = 0; n < 8; n++)
|
||||
{
|
||||
//以下三行是设置三基色,三基色都设置为0x00,则生成的二维码图片就是黑色的了,要什么颜色自己调整
|
||||
*(pDestData + n * 3 + unWidthAdjusted * l) = 0x00;
|
||||
*(pDestData + 1 + n * 3 + unWidthAdjusted * l) = 0x00;
|
||||
*(pDestData + 2 + n * 3 + unWidthAdjusted * l) = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
pDestData += 3 * 8;
|
||||
pSourceData++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
if (pQRC) {
|
||||
QRcode_free(pQRC);
|
||||
}
|
||||
return bmp;
|
||||
////绑定dc
|
||||
//HDC dc=::CreateCompatibleDC(NULL);
|
||||
//::SelectObject(dc, bmp);
|
||||
////用完释放
|
||||
//::DeleteDC(dc);
|
||||
//::DeleteObject(bmp);
|
||||
}
|
||||
//生成二维码到内存
|
||||
inline bool Generate(const std::string& str, std::string& outFileData, QRecLevel level = QRecLevel::QR_ECLEVEL_M) {
|
||||
const char* szSourceSring = str.c_str();
|
||||
unsigned int unWidth, x, y, l, n, unWidthAdjusted, unDataBytes;
|
||||
byte* pSourceData, * pDestData;
|
||||
QRcode* pQRC = NULL;
|
||||
do
|
||||
{
|
||||
if (pQRC = QRcode_encodeString(szSourceSring, 0, level, QR_MODE_8, 1))
|
||||
{
|
||||
unWidth = pQRC->width;
|
||||
unWidthAdjusted = unWidth * 8 * 3;
|
||||
if (unWidthAdjusted % 4) {
|
||||
unWidthAdjusted = (unWidthAdjusted / 4 + 1) * 4;
|
||||
}
|
||||
unDataBytes = unWidthAdjusted * unWidth * 8;
|
||||
|
||||
// Prepare bmp headers
|
||||
BITMAPFILEHEADER kFileHeader;
|
||||
kFileHeader.bfType = 0x4d42;
|
||||
kFileHeader.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + unDataBytes;
|
||||
kFileHeader.bfReserved1 = 0;
|
||||
kFileHeader.bfReserved2 = 0;
|
||||
kFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
|
||||
BITMAPINFOHEADER kInfoHeader;
|
||||
kInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
kInfoHeader.biWidth = unWidth * 8;
|
||||
kInfoHeader.biHeight = -((int)unWidth * 8);
|
||||
kInfoHeader.biPlanes = 1;
|
||||
kInfoHeader.biBitCount = 24;
|
||||
kInfoHeader.biCompression = BI_RGB;
|
||||
kInfoHeader.biSizeImage = 0;
|
||||
kInfoHeader.biXPelsPerMeter = 0;
|
||||
kInfoHeader.biYPelsPerMeter = 0;
|
||||
kInfoHeader.biClrUsed = 0;
|
||||
kInfoHeader.biClrImportant = 0;
|
||||
// Convert QrCode bits to bmp pixels
|
||||
pSourceData = pQRC->data;
|
||||
|
||||
//因为是放在内存 所以简化了一些
|
||||
outFileData.resize(sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + unDataBytes);
|
||||
byte* ptr = (byte*)outFileData.c_str();
|
||||
::memcpy(ptr, (char*)&kFileHeader, sizeof(kFileHeader));
|
||||
ptr += sizeof(kFileHeader);
|
||||
::memcpy(ptr, (char*)&kInfoHeader, sizeof(kInfoHeader));
|
||||
ptr += sizeof(kInfoHeader);
|
||||
byte* pRGBData = ptr;
|
||||
// Preset to white
|
||||
::memset(pRGBData, 0xff, unDataBytes);
|
||||
|
||||
for (y = 0; y < unWidth; y++)
|
||||
{
|
||||
pDestData = pRGBData + unWidthAdjusted * y * 8;
|
||||
for (x = 0; x < unWidth; x++)
|
||||
{
|
||||
if (*pSourceData & 1)
|
||||
{
|
||||
for (l = 0; l < 8; l++)
|
||||
{
|
||||
for (n = 0; n < 8; n++)
|
||||
{
|
||||
//以下三行是设置三基色,三基色都设置为0x00,则生成的二维码图片就是黑色的了,要什么颜色自己调整
|
||||
*(pDestData + n * 3 + unWidthAdjusted * l) = 0x00;
|
||||
*(pDestData + 1 + n * 3 + unWidthAdjusted * l) = 0x00;
|
||||
*(pDestData + 2 + n * 3 + unWidthAdjusted * l) = 0x00;
|
||||
}
|
||||
}
|
||||
}
|
||||
pDestData += 3 * 8;
|
||||
pSourceData++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
if (pQRC) {
|
||||
QRcode_free(pQRC);
|
||||
}
|
||||
return !outFileData.empty();
|
||||
}
|
||||
};
|
||||
16
demo/kugou/include/Common/include/Random.hpp
Normal file
16
demo/kugou/include/Common/include/Random.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <random>
|
||||
class Random {
|
||||
std::mt19937 randomer;
|
||||
public:
|
||||
Random() :randomer(std::random_device()()) {
|
||||
}
|
||||
int Next(int lower, int upper) {
|
||||
std::uniform_int_distribution<int> distribution(lower, upper);
|
||||
return distribution(randomer);
|
||||
}
|
||||
float Next(float lower, float upper) {
|
||||
std::uniform_real_distribution<float> distribution(lower, upper);
|
||||
return distribution(randomer);
|
||||
}
|
||||
};
|
||||
168
demo/kugou/include/Common/include/Regedit.hpp
Normal file
168
demo/kugou/include/Common/include/Regedit.hpp
Normal file
@@ -0,0 +1,168 @@
|
||||
//#pragma once
|
||||
//#include <windows.h>
|
||||
//#include <stdio.h>
|
||||
//#include <strsafe.h>
|
||||
//
|
||||
//namespace Regedit {
|
||||
// //删除指定key
|
||||
// BOOL DelKey(HKEY keyRoot, LPTSTR keyPath);
|
||||
// //判断是否存在key
|
||||
// BOOL Exist(HKEY keyRoot, LPTSTR keyPath);
|
||||
//
|
||||
// bool SetValue(HKEY hKey, const TString&key, const TString&value = TEXT(""));
|
||||
// void SetValueEx(HKEY hKey, const TString&key, const TString&value);
|
||||
// HKEY CreateKey(HKEY rootKey, const TString&keyPath, const TString&defaultValue = TEXT(""));
|
||||
//};
|
||||
//
|
||||
//namespace Regedit {
|
||||
// inline bool SetValue(HKEY hKey, const TString&key, const TString&value) {
|
||||
// return !::RegSetValue(hKey, key.c_str(), REG_SZ, value.c_str(), value.size());
|
||||
// }
|
||||
// inline void SetValueEx(HKEY hKey, const TString&key, const TString&value) {
|
||||
// RegSetValueEx(hKey, key.c_str(), NULL, REG_SZ, (BYTE*)value.c_str(), value.size());
|
||||
// }
|
||||
// inline HKEY CreateKey(HKEY rootKey, const TString&keyPath, const TString&defaultValue) {
|
||||
// HKEY hKey;
|
||||
// RegCreateKey(rootKey, keyPath.c_str(), &hKey);
|
||||
// SetValue(hKey, TEXT(""), defaultValue);
|
||||
// return hKey;
|
||||
// }
|
||||
//
|
||||
// inline BOOL DelKey(HKEY hKeyRoot, LPTSTR lpSubKey)
|
||||
// {
|
||||
// LPTSTR lpEnd;
|
||||
// LONG lResult;
|
||||
// DWORD dwSize;
|
||||
// TCHAR szName[MAX_PATH];
|
||||
// HKEY hKey;
|
||||
// FILETIME ftWrite;
|
||||
// // First, see if we can delete the key without having
|
||||
// // to recurse.
|
||||
// lResult = RegDeleteKey(hKeyRoot, lpSubKey);
|
||||
// if (lResult == ERROR_SUCCESS) {
|
||||
// return TRUE;
|
||||
// }
|
||||
// lResult = RegOpenKeyEx(hKeyRoot, lpSubKey, 0, KEY_READ, &hKey);
|
||||
//
|
||||
// if (lResult != ERROR_SUCCESS)
|
||||
// {
|
||||
// if (lResult == ERROR_FILE_NOT_FOUND) {
|
||||
// printf("Key not found.\n");
|
||||
// return TRUE;
|
||||
// }
|
||||
// else {
|
||||
// printf("Error opening key.\n");
|
||||
// return FALSE;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Check for an ending slash and add one if it is missing.
|
||||
//
|
||||
// lpEnd = lpSubKey + lstrlen(lpSubKey);
|
||||
//
|
||||
// if (*(lpEnd - 1) != TEXT('\\'))
|
||||
// {
|
||||
// *lpEnd = TEXT('\\');
|
||||
// lpEnd++;
|
||||
// *lpEnd = TEXT('\0');
|
||||
// }
|
||||
//
|
||||
// // Enumerate the keys
|
||||
//
|
||||
// dwSize = MAX_PATH;
|
||||
// lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
|
||||
// NULL, NULL, &ftWrite);
|
||||
//
|
||||
// if (lResult == ERROR_SUCCESS)
|
||||
// {
|
||||
// do {
|
||||
//
|
||||
// StringCchCopy(lpEnd, MAX_PATH * 2, szName);
|
||||
//
|
||||
// if (!DelKey(hKeyRoot, lpSubKey)) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// dwSize = MAX_PATH;
|
||||
//
|
||||
// lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
|
||||
// NULL, NULL, &ftWrite);
|
||||
//
|
||||
// } while (lResult == ERROR_SUCCESS);
|
||||
// }
|
||||
//
|
||||
// lpEnd--;
|
||||
// *lpEnd = TEXT('\0');
|
||||
//
|
||||
// RegCloseKey(hKey);
|
||||
// // Try again to delete the key.
|
||||
// lResult = RegDeleteKey(hKeyRoot, lpSubKey);
|
||||
//
|
||||
// if (lResult == ERROR_SUCCESS)
|
||||
// return TRUE;
|
||||
//
|
||||
// return FALSE;
|
||||
// }
|
||||
// inline BOOL Exist(HKEY keyRoot, LPTSTR keyPath)
|
||||
// {
|
||||
// HKEY hExtKey;
|
||||
// if (RegOpenKey(keyRoot, keyPath, &hExtKey) == ERROR_SUCCESS)
|
||||
// {
|
||||
// RegCloseKey(hExtKey);
|
||||
// return TRUE;
|
||||
// }
|
||||
// return FALSE;
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//
|
||||
//struct Version {
|
||||
// WORD v1, v2, v3, v4;
|
||||
//};
|
||||
//struct Product {
|
||||
//private:
|
||||
// HKEY hExtKey = NULL;
|
||||
// TString ProductName;
|
||||
// DWORD type = REG_SZ;
|
||||
// DWORD dwLen = MAX_PATH;
|
||||
//public:
|
||||
// Product(const TString&ProductName) {
|
||||
// this->ProductName = ProductName;
|
||||
// if (RegOpenKey(HKEY_CLASSES_ROOT, ProductName.c_str(), &hExtKey) != ERROR_SUCCESS)//如果打不开
|
||||
// {
|
||||
// hExtKey = ::Regedit::CreateKey(HKEY_CLASSES_ROOT, ProductName);//就创建
|
||||
// }
|
||||
// }
|
||||
// void SetValue(const TString&key, const TString&value) {
|
||||
// Regedit::SetValueEx(hExtKey, key, value);
|
||||
// }
|
||||
// TString GetValue(const TString&key, const TString&defaulValue = "") {
|
||||
// TCHAR bufStr[MAX_PATH]{ 0 };
|
||||
// if (::RegQueryValueEx(hExtKey, key.c_str(), 0, &type, (LPBYTE)bufStr, &dwLen) != ERROR_SUCCESS) {
|
||||
// auto code = ::GetLastError();
|
||||
// SetValue(key, defaulValue);
|
||||
// return defaulValue;
|
||||
// }
|
||||
// return bufStr;
|
||||
// }
|
||||
// Version GetVersion() {//从注册表中获取程序版本
|
||||
// TString localVer = GetValue("ver", "0.0.0.0");
|
||||
// Version ver{ 0,0,0,0 };//当前程序版本
|
||||
// auto vers = Text::Split(localVer, ".");
|
||||
// ver.v1 = (WORD)std::stoi(vers.at(0));
|
||||
// ver.v2 = (WORD)std::stoi(vers.at(1));
|
||||
// ver.v3 = (WORD)std::stoi(vers.at(2));
|
||||
// ver.v4 = (WORD)std::stoi(vers.at(3));
|
||||
// return ver;
|
||||
// }
|
||||
// void SetVersion(const Version&ver) {//设置新版本
|
||||
// TCHAR newVer[MAX_PATH] = { 0 };
|
||||
// Text::Format(newVer, MAX_PATH, "%d.%d.%d.%d", ver.v1, ver.v2, ver.v3, ver.v4);
|
||||
// SetValue("ver", newVer);
|
||||
// }
|
||||
// ~Product() {
|
||||
// if (hExtKey) {
|
||||
// ::RegCloseKey(hExtKey);
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
37
demo/kugou/include/Common/include/Socket.h
Normal file
37
demo/kugou/include/Common/include/Socket.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <winsock2.h> // 先包含 winsock2.h,避免冲突
|
||||
#include <windows.h> // 再包含 windows.h
|
||||
#include <ws2tcpip.h> // ws2tcpip.h 依赖 winsock2.h,可以放在后面
|
||||
#pragma comment(lib, "ws2_32.lib")
|
||||
#endif
|
||||
|
||||
class Socket
|
||||
{
|
||||
private:
|
||||
SOCKET socket = NULL;
|
||||
sockaddr_in sockaddr = {};
|
||||
public:
|
||||
static std::vector<std::string> GetIpByName(const std::string& hostname);
|
||||
public:
|
||||
size_t Port = 0;
|
||||
std::string Address;
|
||||
int Receive(char* outBuf, size_t recvLen, int flags = 0) const;
|
||||
bool Connect(const std::string& ip, size_t port);
|
||||
bool Bind(const std::string& ip, size_t port);
|
||||
bool Listen(int backlog = 5);
|
||||
Socket Accep() const;
|
||||
int Write(const char* buff, int size)const;
|
||||
void Close() const;
|
||||
Socket();
|
||||
Socket(SOCKET socket);
|
||||
virtual ~Socket();
|
||||
};
|
||||
|
||||
84
demo/kugou/include/Common/include/Text.h
Normal file
84
demo/kugou/include/Common/include/Text.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
|
||||
#ifdef _WINDLL
|
||||
#define UI_EXPORT __declspec(dllexport)
|
||||
#define UI_VAR_EXPORT UI_EXPORT
|
||||
#else
|
||||
#define UI_EXPORT
|
||||
#define UI_VAR_EXPORT __declspec(dllimport)
|
||||
#endif // _WINDLL
|
||||
|
||||
namespace Text {
|
||||
|
||||
//-----------------------------------------------Copy Start-----------------------------------------------
|
||||
/// <summary>
|
||||
/// utf8字符串
|
||||
/// </summary>
|
||||
class UI_EXPORT String :public std::string {
|
||||
public:
|
||||
String();
|
||||
virtual ~String();
|
||||
String(const String& _right)noexcept;
|
||||
String(String&& _right)noexcept;
|
||||
String& operator=(const String& _right)noexcept;
|
||||
String& operator=(String&& _right)noexcept;
|
||||
String(const std::string& str)noexcept;
|
||||
String(const char* szbuf)noexcept;
|
||||
String(const wchar_t* szbuf)noexcept;
|
||||
String(const std::wstring& wstr)noexcept;
|
||||
//获取utf8字符串的字符串长度
|
||||
virtual size_t length() const final;
|
||||
std::wstring unicode() const;
|
||||
std::string ansi() const;
|
||||
void erase(char _ch);
|
||||
void erase(size_t pos, size_t count);
|
||||
String replace(char oldChar, char newChar)const;
|
||||
String replace(const String& oldText, const String& newText, bool allReplace = true)const;
|
||||
String toLower()const;
|
||||
String toUpper()const;
|
||||
//去除前后空格
|
||||
String trim()const;
|
||||
//find value count
|
||||
size_t count(const String& value);
|
||||
std::vector<String> split(const String& ch)const;
|
||||
bool operator==(const wchar_t* szbuf)const;
|
||||
bool operator==(const std::wstring& wStr)const;
|
||||
|
||||
template<typename ...T>
|
||||
inline String format(const T &...args) {
|
||||
auto bufSize = ::snprintf(nullptr, 0, this->c_str(), std::forward<const T&>(args)...) + 1; // +1是为了'结束符\0'
|
||||
char* buf = new char[bufSize] {0};
|
||||
auto count = ::sprintf_s(buf, bufSize, this->c_str(), std::forward<const T&>(args)...);
|
||||
String ret(buf);
|
||||
delete[] buf;
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
//base convert
|
||||
UI_EXPORT void AnyToUnicode(const std::string& src_str, UINT codePage, std::wstring* out_wstr);
|
||||
UI_EXPORT void UnicodeToAny(const std::wstring& unicode_wstr, UINT codePage, std::string* out_str);
|
||||
//
|
||||
UI_EXPORT void GBKToUTF8(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void UTF8ToGBK(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void ANSIToUniCode(const std::string& str, std::wstring* outStr);
|
||||
UI_EXPORT void ANSIToUTF8(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void UnicodeToANSI(const std::wstring& wstr, std::string* outStr);
|
||||
UI_EXPORT void UnicodeToUTF8(const std::wstring& wstr, std::string* outStr);
|
||||
UI_EXPORT void UTF8ToANSI(const std::string& str, std::string* outStr);
|
||||
UI_EXPORT void UTF8ToUnicode(const std::string& str, std::wstring* outStr);
|
||||
//
|
||||
UI_EXPORT void Tolower(std::string* str_in_out);
|
||||
UI_EXPORT void Toupper(std::string* str_in_out);
|
||||
UI_EXPORT void Erase(std::string* str_in_out, char ch);
|
||||
UI_EXPORT void Replace(std::string* str_in_out, char oldChar, char newChar);
|
||||
UI_EXPORT size_t Replace(std::string* str_in_out, const std::string& oldText, const std::string& newText, bool replaceAll = true);
|
||||
UI_EXPORT void Split(const std::string& str_in, const std::string& ch, std::vector<std::string>* strs_out);
|
||||
//
|
||||
UI_EXPORT String ToString(double number, size_t keepBitSize);
|
||||
//-----------------------------------------------Copy End-----------------------------------------------
|
||||
};
|
||||
using u8String = Text::String;
|
||||
137
demo/kugou/include/Common/include/ThreadPool.hpp
Normal file
137
demo/kugou/include/Common/include/ThreadPool.hpp
Normal file
@@ -0,0 +1,137 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <future>
|
||||
#include <list>
|
||||
|
||||
class Thread {
|
||||
bool _bStop = false;
|
||||
std::thread* _task = NULL;
|
||||
bool _bJoin = false;
|
||||
std::mutex _mtx;
|
||||
std::condition_variable _codv;
|
||||
private:
|
||||
Thread(const Thread&) = delete;
|
||||
public:
|
||||
template<class Func, class... Args>
|
||||
Thread(Func&& f, Args&& ...args) {
|
||||
std::function<void()>* func = new std::function<void()>(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
_task = new std::thread([this, func]() mutable {
|
||||
(*func)();
|
||||
delete func;
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(_mtx);
|
||||
_bStop = true;
|
||||
}
|
||||
_codv.notify_all();
|
||||
});
|
||||
}
|
||||
void Wait() {
|
||||
if (!_bJoin)
|
||||
{
|
||||
_bJoin = true;
|
||||
std::unique_lock<std::mutex> autoLock(_mtx);
|
||||
_codv.wait(autoLock, [this]() ->bool {
|
||||
return _bStop;
|
||||
});
|
||||
_task->join();
|
||||
}
|
||||
}
|
||||
bool IsStopped() {
|
||||
std::unique_lock<std::mutex> autoLock(_mtx);
|
||||
return _bStop;
|
||||
}
|
||||
virtual ~Thread() {
|
||||
Wait();
|
||||
delete _task;
|
||||
}
|
||||
};
|
||||
|
||||
class ThreadPool {
|
||||
bool bStop = false;
|
||||
std::list<Thread*> tasks;
|
||||
std::list<std::function<void()>> funcs;
|
||||
std::mutex mtx;
|
||||
std::condition_variable codv;
|
||||
//用于等待任务清空的锁和条件变量
|
||||
std::mutex mtx2;
|
||||
std::condition_variable codv2;
|
||||
private:
|
||||
ThreadPool(const ThreadPool&) = delete;
|
||||
public:
|
||||
ThreadPool(int maxTaskCount = 50) {
|
||||
for (size_t i = 0; i < maxTaskCount; ++i)
|
||||
{
|
||||
tasks.push_back(new Thread([this]() {
|
||||
while (true)
|
||||
{
|
||||
std::function<void()> task;
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(this->mtx);
|
||||
this->codv.wait(autoLock, [this]()->bool {
|
||||
return this->bStop || !this->funcs.empty();
|
||||
});
|
||||
if (funcs.empty()) {
|
||||
this->codv2.notify_all();
|
||||
}
|
||||
if (this->bStop && funcs.empty()) {
|
||||
break;
|
||||
}
|
||||
task = std::move(*funcs.begin());
|
||||
funcs.pop_front();
|
||||
}
|
||||
task();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
void WaitAll() {
|
||||
codv.notify_all();
|
||||
std::unique_lock<std::mutex> lock2(this->mtx2);
|
||||
this->codv2.wait(lock2, [this]()->bool {
|
||||
return funcs.empty();
|
||||
});
|
||||
}
|
||||
virtual ~ThreadPool() {
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(mtx);
|
||||
bStop = true;
|
||||
}
|
||||
WaitAll();
|
||||
while (!tasks.empty())
|
||||
{
|
||||
for (auto itor = tasks.begin(); itor != tasks.end(); )
|
||||
{
|
||||
if ((*itor)->IsStopped()) {
|
||||
(*itor)->Wait();
|
||||
delete (*itor);
|
||||
itor = tasks.erase(itor);
|
||||
}
|
||||
else {
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//添加到任务队列中的末尾(先后顺序执行)
|
||||
template<class Func, class... Args>
|
||||
void Add(Func&& f, Args&& ...args) {
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(mtx);
|
||||
funcs.emplace_back(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
}
|
||||
codv.notify_one();
|
||||
}
|
||||
//添加至任务队列的第一位(优先执行)
|
||||
template<class Func, class... Args>
|
||||
void AddToFrist(Func&& f, Args&& ...args) {
|
||||
{
|
||||
std::unique_lock<std::mutex> autoLock(mtx);
|
||||
funcs.emplace_front(std::bind(std::forward<Func>(f), std::forward<Args>(args)...));
|
||||
}
|
||||
codv.notify_one();
|
||||
}
|
||||
};
|
||||
83
demo/kugou/include/Common/include/Time.hpp
Normal file
83
demo/kugou/include/Common/include/Time.hpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include <time.h>
|
||||
#include <string>
|
||||
#include "Text.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
class Time {
|
||||
time_t _time;
|
||||
public:
|
||||
static Time Now() {
|
||||
return Time(::time(NULL));
|
||||
}
|
||||
public:
|
||||
Time(time_t second) {
|
||||
_time = second;
|
||||
}
|
||||
Time(const std::string& timeStr, const std::string& format = "yyyy-MM-dd HH:mm:ss") {
|
||||
std::string formatStr = format;
|
||||
Text::Replace(&formatStr, "yyyy", "%Y");
|
||||
Text::Replace(&formatStr, "MM", "%m");
|
||||
Text::Replace(&formatStr, "dd", "%d");
|
||||
Text::Replace(&formatStr, "HH", "%H");
|
||||
Text::Replace(&formatStr, "mm", "%M");
|
||||
Text::Replace(&formatStr, "ss", "%S");
|
||||
|
||||
std::tm tm{};
|
||||
std::istringstream ss(timeStr);
|
||||
ss >> std::get_time(&tm, formatStr.c_str());
|
||||
tm.tm_isdst = -1; // Enable daylight saving time
|
||||
|
||||
std::time_t timeStamp = std::mktime(&tm);
|
||||
if (timeStamp == -1) {
|
||||
throw std::runtime_error("Error converting time string to timestamp.");
|
||||
}
|
||||
this->_time = timeStamp;
|
||||
}
|
||||
std::string ToString(const std::string& format = "yyyy-MM-dd HH:mm:ss") const{
|
||||
std::string formatStr = format;
|
||||
Text::Replace(&formatStr, "yyyy", "%Y");
|
||||
Text::Replace(&formatStr, "MM", "%m");
|
||||
Text::Replace(&formatStr, "dd", "%d");
|
||||
Text::Replace(&formatStr, "HH", "%H");
|
||||
Text::Replace(&formatStr, "mm", "%M");
|
||||
Text::Replace(&formatStr, "ss", "%S");
|
||||
|
||||
char timeStr[128]{ 0 };
|
||||
time_t t = _time;
|
||||
struct tm* ttime = std::localtime(&t);
|
||||
std::strftime(timeStr, sizeof(timeStr), formatStr.c_str(), ttime);
|
||||
return timeStr;
|
||||
}
|
||||
time_t operator - (const Time& right) {
|
||||
return this->_time - right._time;
|
||||
}
|
||||
bool operator == (const Time& right) {
|
||||
return this->_time == right._time;
|
||||
}
|
||||
bool operator != (const Time& right) {
|
||||
return this->_time != right._time;
|
||||
}
|
||||
bool operator > (const Time& right) {
|
||||
return this->_time > right._time;
|
||||
}
|
||||
bool operator < (const Time& right) {
|
||||
return this->_time < right._time;
|
||||
}
|
||||
Time& operator += (time_t right) {
|
||||
this->_time += right;
|
||||
return *this;
|
||||
}
|
||||
Time& operator -= (time_t right) {
|
||||
this->_time -= right;
|
||||
return *this;
|
||||
}
|
||||
Time operator + (time_t right) {
|
||||
return Time(this->_time + right);
|
||||
}
|
||||
Time operator - (time_t right) {
|
||||
return Time(this->_time - right);
|
||||
}
|
||||
};
|
||||
81
demo/kugou/include/Common/include/UnZiper.h
Normal file
81
demo/kugou/include/Common/include/UnZiper.h
Normal file
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
#include "Text.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
DECLARE_HANDLE(HZIP_U);
|
||||
|
||||
struct ZipItem
|
||||
{
|
||||
int index; // index of this file within the zip
|
||||
TCHAR name[MAX_PATH]; // filename within the zip
|
||||
DWORD attr; // attributes, as in GetFileAttributes.
|
||||
FILETIME atime, ctime, mtime;// access, create, modify filetimes
|
||||
long comp_size; // sizes of item, compressed and uncompressed. These
|
||||
long unc_size; // may be -1 if not yet known (e.g. being streamed in)
|
||||
bool isDir()const {
|
||||
if (attr & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 专门负责解压缩的类
|
||||
/// </summary>
|
||||
class UnZiper {
|
||||
HZIP_U ptr = NULL;
|
||||
int itemCount = 0;
|
||||
public:
|
||||
UnZiper(const std::wstring& fileName, const std::string& password = "");
|
||||
UnZiper(const char* fileData, unsigned int size, const std::string& password = "");
|
||||
bool Find(const std::string& itemName, ZipItem* item);
|
||||
bool Find(int index, ZipItem* item);
|
||||
bool UnZipItem(const ZipItem& item, byte** data);
|
||||
int GetCount();
|
||||
virtual ~UnZiper();
|
||||
public:
|
||||
static bool UnZip(UnZiper* zip, const Text::String& outDir, const std::string& password = "", std::function<void(const Text::String&, int total, int index, bool& stop)> callback = NULL) {
|
||||
bool ok = true;
|
||||
for (int i = 0; i < zip->GetCount(); i++)
|
||||
{
|
||||
ZipItem ze;
|
||||
zip->Find(i, &ze);
|
||||
Text::String itemName = outDir + "/" + Text::String(ze.name);
|
||||
if (ze.isDir()) {
|
||||
if (!Directory::Create(itemName)) {
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
File::Delete(itemName);
|
||||
byte* data = NULL;
|
||||
zip->UnZipItem(ze, &data);
|
||||
std::ofstream ofs(itemName.unicode(), std::ios::binary);
|
||||
ofs.write((char*)data, ze.unc_size);
|
||||
ofs.flush();
|
||||
ofs.close();
|
||||
if (!ofs.good()) {
|
||||
ok = false;
|
||||
}
|
||||
if (data) {
|
||||
delete[] data;
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
bool stop = false;
|
||||
callback(itemName, zip->GetCount(), i, stop);
|
||||
if (stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool UnZip(const Text::String& zipFileName, const Text::String& outDir, const std::string& password = "", std::function<void(const Text::String&, int total, int index, bool& stop)> callback = NULL) {
|
||||
Directory::Create(outDir);
|
||||
UnZiper zip(zipFileName.unicode(), password);
|
||||
return UnZip(&zip, outDir, password, callback);
|
||||
}
|
||||
};
|
||||
30
demo/kugou/include/Common/include/Util.h
Normal file
30
demo/kugou/include/Common/include/Util.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <Windows.h>
|
||||
#include <string>
|
||||
|
||||
namespace Util {
|
||||
//文件的md5
|
||||
std::string MD5FromFile(const std::wstring& filename);
|
||||
//字符串的md5
|
||||
std::string MD5FromString(const std::string& string);
|
||||
//base64编码
|
||||
std::string Base64Encode(const char* str, int strLen);
|
||||
//base64编码
|
||||
std::string Base64Encode(const std::string& string);
|
||||
//base64解码
|
||||
std::string Base64Decode(const char* base64Str, int strLen);
|
||||
//base64解码
|
||||
std::string Base64Decode(const std::string& string);
|
||||
//url编码
|
||||
std::string UrlEncode(const std::string& str);
|
||||
//url解码
|
||||
std::string UrlDecode(const std::string& str, bool convert_plus_to_space = false);
|
||||
//少一个GZIP
|
||||
|
||||
namespace XOR {
|
||||
//XOR加密 必须输入密码才能加密
|
||||
std::string EnCode(const std::string& data, const std::string& password);
|
||||
//XOR解密
|
||||
std::string DeCode(const std::string& data, const std::string& password);
|
||||
}
|
||||
};
|
||||
76
demo/kugou/include/Common/include/WebClient.h
Normal file
76
demo/kugou/include/Common/include/WebClient.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include "FileSystem.h"
|
||||
#include "Text.h"
|
||||
|
||||
#define USECURL 1 //是否使用curl 使用curl会导致库变得很大
|
||||
|
||||
#if USECURL
|
||||
namespace PostForm {
|
||||
//字段类型
|
||||
enum FieldType :char
|
||||
{
|
||||
None,
|
||||
Text,
|
||||
File
|
||||
};
|
||||
class Field {
|
||||
public:
|
||||
FieldType FieldType = FieldType::None;
|
||||
std::string FieldName;
|
||||
std::string FieldValue;
|
||||
|
||||
std::string FileName;
|
||||
Field(const std::string& FieldName, const std::string& ValueOrFullFileName, PostForm::FieldType FieldType = PostForm::FieldType::Text) {
|
||||
this->FieldName = FieldName;
|
||||
this->FieldType = FieldType;
|
||||
if (FieldType == PostForm::FieldType::File) {
|
||||
this->FieldValue = Path::GetFileName(ValueOrFullFileName);
|
||||
this->FileName = ValueOrFullFileName;
|
||||
}
|
||||
else {
|
||||
this->FieldValue = ValueOrFullFileName;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class WebClient
|
||||
{
|
||||
public:
|
||||
struct Content
|
||||
{
|
||||
void* tag = NULL;
|
||||
bool cancel = false;
|
||||
int type = 0;//0:正常请求 1:下载文件
|
||||
};
|
||||
private:
|
||||
Content content;
|
||||
public:
|
||||
std::function<size_t(char* contents, size_t size, size_t nmemb, void* respone)> CallBack = NULL;
|
||||
private:
|
||||
void* Init(const std::string& url, std::string* resp, int timeOut);
|
||||
long CleanUp(void* curl, int code);
|
||||
std::map<std::string, std::string> Header;
|
||||
void* curl_header = NULL;//类型参见 curl_slist
|
||||
public:
|
||||
std::string Cookies;
|
||||
std::string Proxy;
|
||||
WebClient();
|
||||
virtual ~WebClient();
|
||||
//取消请求/下载
|
||||
void Cancel();
|
||||
void AddHeader(const std::string& key, const std::string& value);
|
||||
void RemoveHeader(const std::string& key);
|
||||
int HttpGet(const std::string& strUrl, std::string* response = NULL, int nTimeout = 60);
|
||||
int HttpPost(const std::string& strUrl, const std::string& data = "", std::string* response = NULL, int nTimeout = 60);
|
||||
int DownloadFile(const std::string& strUrl, const std::wstring& filename, const std::function<void(long long dltotal, long long dlnow)>& progressCallback = NULL, int nTimeout = 99999);
|
||||
int FtpDownLoad(const std::string& strUrl, const std::string& user, const std::string& pwd, const std::wstring& outFileName, int nTimeout = 99999);
|
||||
int UploadFile(const std::string& strUrl, const std::string& filename, const std::string& field, std::string* response = NULL, const std::function<void(long long dltotal, long long dlnow)>& progressCallback = NULL, int nTimeout = 99999);
|
||||
int SubmitForm(const std::string& strUrl, const std::vector<PostForm::Field>& fieldValues, std::string* response = NULL, int nTimeout = 99999);
|
||||
};
|
||||
#endif
|
||||
172
demo/kugou/include/Common/include/WinTool.h
Normal file
172
demo/kugou/include/Common/include/WinTool.h
Normal file
@@ -0,0 +1,172 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <functional>
|
||||
#include <Windows.h>
|
||||
#include <TlHelp32.h>
|
||||
|
||||
#include "Text.h"
|
||||
|
||||
#ifdef GetUserName
|
||||
#undef GetUserName
|
||||
inline void GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer) {
|
||||
::GetUserNameA(lpBuffer, pcbBuffer);
|
||||
}
|
||||
inline void GetUserName(LPWSTR lpBuffer, LPDWORD pcbBuffer) {
|
||||
::GetUserNameW(lpBuffer, pcbBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GetComputerName
|
||||
#undef GetComputerName
|
||||
inline void GetComputerName(LPSTR lpBuffer, LPDWORD pcbBuffer) {
|
||||
::GetComputerNameA(lpBuffer, pcbBuffer);
|
||||
}
|
||||
inline void GetComputerName(LPWSTR lpBuffer, LPDWORD pcbBuffer) {
|
||||
::GetComputerNameW(lpBuffer, pcbBuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace WinTool {
|
||||
/// <summary>
|
||||
/// 路由信息
|
||||
/// </summary>
|
||||
struct RouterInfo {
|
||||
Text::String IP;
|
||||
Text::String MAC;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
unsigned long processId;
|
||||
HWND best_handle;
|
||||
}handle_data;
|
||||
|
||||
typedef struct _MyAdpterInfo
|
||||
{
|
||||
std::vector<std::string> Ip;
|
||||
std::string MacAddress;
|
||||
std::string Description;
|
||||
std::string Name;
|
||||
UINT Type;
|
||||
}MyAdpterInfo;
|
||||
|
||||
struct AppInfo {
|
||||
/// app名称
|
||||
Text::String DisplayName;
|
||||
/// 版本号
|
||||
Text::String DisplayVersion;
|
||||
//显示图标
|
||||
Text::String DisplayIcon;
|
||||
// 发布者
|
||||
Text::String Publisher;
|
||||
//软件安装路径
|
||||
Text::String InstallLocation;
|
||||
// 主程序启动完整路径 C:\\Program Files\\xxx\xxx.exe
|
||||
Text::String PragmaFile;
|
||||
// 卸载执行的命令行
|
||||
Text::String UninstallString;
|
||||
// 产品帮助链接
|
||||
Text::String HelpLink;
|
||||
//帮助说明[这是一款桌面工具]
|
||||
Text::String Comments;
|
||||
//产品官网
|
||||
Text::String URLInfoAbout;
|
||||
//是否禁用控制面板修改按钮
|
||||
bool NoModify = false;
|
||||
//是否禁用控制面板修复按钮
|
||||
bool NoRepair = false;
|
||||
// 是否创建桌面快捷方式
|
||||
bool DesktopLink = true;
|
||||
// 是否开机启动
|
||||
bool AutoBoot = false;
|
||||
//为所有用户注册
|
||||
bool AllUsers = true;
|
||||
};
|
||||
//给进程提权
|
||||
extern BOOL EnablePrivilege(HANDLE process = NULL);
|
||||
//创捷快捷方式
|
||||
extern bool CreateLink(const Text::String& pragmaFilename, const Text::String& outDir, const Text::String& LnkName = L"", const Text::String& cmdline = L"", const Text::String& iconFilename = L"");
|
||||
//删除快捷方式
|
||||
extern void DeleteLink(const Text::String& linkDir, const Text::String& pragmaFilename, const Text::String& LnkName = "");
|
||||
/// 删除注册表中某个项及其子项和值
|
||||
extern void DeleteKeyRecursively(HKEY hKeyParent, const wchar_t* subKey);
|
||||
//获取软件相关信息
|
||||
extern Text::String GetAppValue(const Text::String& appName_en, const Text::String& key);
|
||||
//根据软件名称修改一些信息
|
||||
extern bool SetAppValue(const Text::String& appName_en, const Text::String& key, const Text::String& value);
|
||||
//注册软件到电脑
|
||||
extern bool RegisterApp(const AppInfo& appInfo);
|
||||
//从电脑上注销软件
|
||||
extern void UnRegisterApp(const Text::String& appName_en);
|
||||
//给软件注册许可
|
||||
extern bool RegisterLicenser(const Text::String& exeFilename, const Text::String& softwareData);
|
||||
//获取软件许可证书
|
||||
extern Text::String FindLicenser(const Text::String& exeFilename);
|
||||
//设置程序自启动 rootKey参数:HKEY_CURRENT_USER(当前用户), HKEY_LOCAL_MACHINE//所有用户(需要管理员)
|
||||
extern bool SetAutoBoot(const Text::String& filename = L"", bool enable = true, HKEY rootKey = HKEY_CURRENT_USER);
|
||||
//获取程序自启动状态 rootKey参数:HKEY_CURRENT_USER(当前用户), HKEY_LOCAL_MACHINE//所有用户(需要管理员)
|
||||
extern bool IsAutoBoot(const Text::String& _keyName, HKEY rootKey = HKEY_CURRENT_USER);
|
||||
//检查计划任务
|
||||
extern bool IsInTask(const Text::String& _taskName);
|
||||
//添加到启动计划任务
|
||||
extern bool AddBootTask(const Text::String& _taskName, const Text::String& _exeFile);
|
||||
//寻找进程中的窗口
|
||||
extern HWND FindMainWindow(DWORD processId);
|
||||
//获取进程信息
|
||||
extern std::vector<PROCESSENTRY32W> FindProcessInfo(const Text::String& _proccname);
|
||||
//根据进程名称打开进程
|
||||
extern HANDLE OpenProcess(const Text::String& _proccname);
|
||||
//获取进程ID集合
|
||||
extern std::vector<DWORD> FindProcessId(const Text::String& proccname);
|
||||
//获取进程文件路径
|
||||
extern Text::String FindProcessFilename(DWORD processId);
|
||||
//关闭所有进程
|
||||
extern int CloseProcess(const std::vector<DWORD>& processIds);
|
||||
//使用进程ID关闭进程
|
||||
extern bool CloseProcess(DWORD processId);
|
||||
//使用句柄关闭进程
|
||||
extern bool CloseProcess(HANDLE hProcess, UINT exitCode = 0);
|
||||
//获取进程是不是64位的
|
||||
extern bool Is64BitPorcess(DWORD processId);
|
||||
//获取进程是不是32位的
|
||||
extern bool Is86BitPorcess(DWORD processId);
|
||||
//获取当前进程ID
|
||||
extern DWORD GetCurrentProcessId();
|
||||
//获取系统位数
|
||||
extern int GetSystemBits();
|
||||
//获取计算机唯一识别码
|
||||
extern Text::String GetComputerID();
|
||||
//用户当前用户名称
|
||||
extern Text::String GetUserName();
|
||||
//获取计算机名称
|
||||
extern Text::String GetComputerName();
|
||||
//获取网卡相关
|
||||
extern int GetAdptersInfo(std::vector<MyAdpterInfo>& adpterInfo);
|
||||
/// 获取磁盘可以用空间单位:GB
|
||||
extern double GetDiskFreeSize(const Text::String& path);
|
||||
/// 直接执行可执行文件并获取返回内容
|
||||
extern Text::String ExecuteCMD(const Text::String& cmdStr, std::function<void(const Text::String&)> callback = NULL, HANDLE* outHandle = NULL);
|
||||
///获取首选网卡的mac地址
|
||||
extern Text::String GetMacAddress();
|
||||
/// 获取操作系统的版本号
|
||||
extern Text::String GetWinVersion();
|
||||
/// 弹出选择文件对话框(filter传入参数的方式存在问题 以后改)
|
||||
extern Text::String ShowFileDialog(HWND ownerWnd = NULL, const Text::String& defaultPath = "", const Text::String& title = "Select a File", const Text::String& filter = "All Files\0*.*\0");
|
||||
/// 弹出选择目录对话框
|
||||
extern Text::String ShowFolderDialog(HWND ownerWnd = NULL, const Text::String& defaultPath = "", const Text::String& title = "Select a directory");
|
||||
/// 获取路由信息
|
||||
extern RouterInfo GetRouterInfo();
|
||||
/// 获取电脑的com端口名称
|
||||
extern std::vector<Text::String> GetComPorts();
|
||||
/// 安装带有.inf文件的驱动
|
||||
extern bool InstallDriver(const Text::String& infPath, bool* needReboot = NULL);
|
||||
/// 获取已安装的应用
|
||||
extern std::map<Text::String, Text::String> GetApps();
|
||||
/// 检测程序是否被调试
|
||||
extern bool CheckDebug();
|
||||
/// 检查程序是否正在运行 使用文件独占方式
|
||||
extern bool IsRunning(const Text::String& productName = "", bool lock = true);
|
||||
/// 添加一个程序到防火墙规则 ps:需要管理员权限运行
|
||||
extern void AddFirewallRule(const Text::String& programFile);
|
||||
//是否接管异常(仅限正式环境调用 使用vs启动会被vs接管异常)
|
||||
extern bool IsExceptionHijacked();
|
||||
};
|
||||
43
demo/kugou/include/Common/include/Ziper.h
Normal file
43
demo/kugou/include/Common/include/Ziper.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
#include "Text.h"
|
||||
#include "FileSystem.h"
|
||||
#include <Windows.h>
|
||||
|
||||
DECLARE_HANDLE(HZIP_Z);
|
||||
|
||||
/// <summary>
|
||||
/// 专门负责压缩的库
|
||||
/// </summary>
|
||||
class Ziper {
|
||||
HZIP_Z ptr = NULL;
|
||||
public:
|
||||
Ziper(const std::wstring& createFileName, const std::string& pwd = "");
|
||||
void AddFile(const std::wstring& showFileName, const std::wstring& localFileName);
|
||||
void AddFolder(const std::wstring& showFolder);
|
||||
void Close();
|
||||
virtual ~Ziper();
|
||||
public:
|
||||
static void Zip(const Text::String& _dirName, const Text::String& outFileName, const Text::String& pwd = "", std::function<bool(const Text::String&, int, int)> callback = NULL) {
|
||||
std::vector<FileSystem::FileInfo> result;
|
||||
Ziper zip(outFileName.unicode(), pwd);
|
||||
Text::String dirName = _dirName + "/";
|
||||
dirName = Path::Format(dirName);
|
||||
Directory::Find(dirName, result, "*.*", true);
|
||||
for (int i = 0; i < result.size(); i++)
|
||||
{
|
||||
Text::String ItemNmae = result[i].FileName.replace(dirName, "");
|
||||
if (result[i].IsFile()) {
|
||||
zip.AddFile(ItemNmae.unicode(), result[i].FileName.unicode());
|
||||
}
|
||||
else {
|
||||
zip.AddFolder(ItemNmae.unicode());
|
||||
}
|
||||
if (callback) {
|
||||
if (callback(ItemNmae, i, result.size())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
35
demo/kugou/include/Common/include/base64.h
Normal file
35
demo/kugou/include/Common/include/base64.h
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// base64 encoding and decoding with C++.
|
||||
// Version: 2.rc.09 (release candidate)
|
||||
//
|
||||
|
||||
#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
|
||||
#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
|
||||
|
||||
#include <string>
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <string_view>
|
||||
#endif // __cplusplus >= 201703L
|
||||
|
||||
std::string base64_encode (std::string const& s, bool url = false);
|
||||
std::string base64_encode_pem (std::string const& s);
|
||||
std::string base64_encode_mime(std::string const& s);
|
||||
|
||||
std::string base64_decode(std::string const& s, bool remove_linebreaks = false);
|
||||
std::string base64_encode(unsigned char const*, size_t len, bool url = false);
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//
|
||||
// Interface with std::string_view rather than const std::string&
|
||||
// Requires C++17
|
||||
// Provided by Yannic Bonenberger (https://github.com/Yannic)
|
||||
//
|
||||
std::string base64_encode (std::string_view s, bool url = false);
|
||||
std::string base64_encode_pem (std::string_view s);
|
||||
std::string base64_encode_mime(std::string_view s);
|
||||
|
||||
std::string base64_decode(std::string_view s, bool remove_linebreaks = false);
|
||||
#endif // __cplusplus >= 201703L
|
||||
|
||||
#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */
|
||||
39
demo/kugou/include/Common/include/curl/Makefile.am
Normal file
39
demo/kugou/include/Common/include/curl/Makefile.am
Normal file
@@ -0,0 +1,39 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
###########################################################################
|
||||
pkginclude_HEADERS = \
|
||||
curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \
|
||||
typecheck-gcc.h system.h urlapi.h options.h
|
||||
|
||||
pkgincludedir= $(includedir)/curl
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
CS_0 = @echo " RUN " $@;
|
||||
CS_1 =
|
||||
CS_ = $(CS_0)
|
||||
|
||||
checksrc:
|
||||
$(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/include/curl $(pkginclude_HEADERS)
|
||||
|
||||
if CURLDEBUG
|
||||
# for debug builds, we scan the sources on all regular make invokes
|
||||
all-local: checksrc
|
||||
endif
|
||||
714
demo/kugou/include/Common/include/curl/Makefile.in
Normal file
714
demo/kugou/include/Common/include/curl/Makefile.in
Normal file
@@ -0,0 +1,714 @@
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
am__is_gnu_make = { \
|
||||
if test -z '$(MAKELEVEL)'; then \
|
||||
false; \
|
||||
elif test -n '$(MAKE_HOST)'; then \
|
||||
true; \
|
||||
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
|
||||
true; \
|
||||
else \
|
||||
false; \
|
||||
fi; \
|
||||
}
|
||||
am__make_running_with_option = \
|
||||
case $${target_option-} in \
|
||||
?) ;; \
|
||||
*) echo "am__make_running_with_option: internal error: invalid" \
|
||||
"target option '$${target_option-}' specified" >&2; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
has_opt=no; \
|
||||
sane_makeflags=$$MAKEFLAGS; \
|
||||
if $(am__is_gnu_make); then \
|
||||
sane_makeflags=$$MFLAGS; \
|
||||
else \
|
||||
case $$MAKEFLAGS in \
|
||||
*\\[\ \ ]*) \
|
||||
bs=\\; \
|
||||
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
|
||||
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
|
||||
esac; \
|
||||
fi; \
|
||||
skip_next=no; \
|
||||
strip_trailopt () \
|
||||
{ \
|
||||
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
|
||||
}; \
|
||||
for flg in $$sane_makeflags; do \
|
||||
test $$skip_next = yes && { skip_next=no; continue; }; \
|
||||
case $$flg in \
|
||||
*=*|--*) continue;; \
|
||||
-*I) strip_trailopt 'I'; skip_next=yes;; \
|
||||
-*I?*) strip_trailopt 'I';; \
|
||||
-*O) strip_trailopt 'O'; skip_next=yes;; \
|
||||
-*O?*) strip_trailopt 'O';; \
|
||||
-*l) strip_trailopt 'l'; skip_next=yes;; \
|
||||
-*l?*) strip_trailopt 'l';; \
|
||||
-[dEDm]) skip_next=yes;; \
|
||||
-[JT]) skip_next=yes;; \
|
||||
esac; \
|
||||
case $$flg in \
|
||||
*$$target_option*) has_opt=yes; break;; \
|
||||
esac; \
|
||||
done; \
|
||||
test $$has_opt = yes
|
||||
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
|
||||
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = include/curl
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compile_check_sizeof.m4 \
|
||||
$(top_srcdir)/m4/curl-amissl.m4 \
|
||||
$(top_srcdir)/m4/curl-bearssl.m4 \
|
||||
$(top_srcdir)/m4/curl-compilers.m4 \
|
||||
$(top_srcdir)/m4/curl-confopts.m4 \
|
||||
$(top_srcdir)/m4/curl-functions.m4 \
|
||||
$(top_srcdir)/m4/curl-gnutls.m4 \
|
||||
$(top_srcdir)/m4/curl-mbedtls.m4 \
|
||||
$(top_srcdir)/m4/curl-mesalink.m4 $(top_srcdir)/m4/curl-nss.m4 \
|
||||
$(top_srcdir)/m4/curl-openssl.m4 \
|
||||
$(top_srcdir)/m4/curl-override.m4 \
|
||||
$(top_srcdir)/m4/curl-reentrant.m4 \
|
||||
$(top_srcdir)/m4/curl-rustls.m4 \
|
||||
$(top_srcdir)/m4/curl-schannel.m4 \
|
||||
$(top_srcdir)/m4/curl-sectransp.m4 \
|
||||
$(top_srcdir)/m4/curl-sysconfig.m4 \
|
||||
$(top_srcdir)/m4/curl-wolfssl.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
|
||||
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
|
||||
$(top_srcdir)/m4/xc-am-iface.m4 \
|
||||
$(top_srcdir)/m4/xc-cc-check.m4 \
|
||||
$(top_srcdir)/m4/xc-lt-iface.m4 \
|
||||
$(top_srcdir)/m4/xc-translit.m4 \
|
||||
$(top_srcdir)/m4/xc-val-flgs.m4 \
|
||||
$(top_srcdir)/m4/zz40-xc-ovr.m4 \
|
||||
$(top_srcdir)/m4/zz50-xc-ovr.m4 \
|
||||
$(top_srcdir)/m4/zz60-xc-ovr.m4 $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(pkginclude_HEADERS) \
|
||||
$(am__DIST_COMMON)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/lib/curl_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_P = $(am__v_P_@AM_V@)
|
||||
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
|
||||
am__v_P_0 = false
|
||||
am__v_P_1 = :
|
||||
AM_V_GEN = $(am__v_GEN_@AM_V@)
|
||||
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
am__v_GEN_1 =
|
||||
AM_V_at = $(am__v_at_@AM_V@)
|
||||
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
|
||||
am__v_at_0 = @
|
||||
am__v_at_1 =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
*) (install-info --version) >/dev/null 2>&1;; \
|
||||
esac
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__uninstall_files_from_dir = { \
|
||||
test -z "$$files" \
|
||||
|| { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
|
||||
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
|
||||
$(am__cd) "$$dir" && rm -f $$files; }; \
|
||||
}
|
||||
am__installdirs = "$(DESTDIR)$(pkgincludedir)"
|
||||
HEADERS = $(pkginclude_HEADERS)
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
am__uniquify_input = $(AWK) '\
|
||||
BEGIN { nonempty = 0; } \
|
||||
{ items[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in items) print i; }; } \
|
||||
'
|
||||
# Make sure the list of sources is unique. This is necessary because,
|
||||
# e.g., the same source file might be shared among _SOURCES variables
|
||||
# for different programs/libraries.
|
||||
am__define_uniq_tagged_files = \
|
||||
list='$(am__tagged_files)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
pkgincludedir = $(includedir)/curl
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AR_FLAGS = @AR_FLAGS@
|
||||
AS = @AS@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BLANK_AT_MAKETIME = @BLANK_AT_MAKETIME@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CFLAG_CURL_SYMBOL_HIDING = @CFLAG_CURL_SYMBOL_HIDING@
|
||||
CONFIGURE_OPTIONS = @CONFIGURE_OPTIONS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CPPFLAG_CURL_STATICLIB = @CPPFLAG_CURL_STATICLIB@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CURLVERSION = @CURLVERSION@
|
||||
CURL_CA_BUNDLE = @CURL_CA_BUNDLE@
|
||||
CURL_CFLAG_EXTRAS = @CURL_CFLAG_EXTRAS@
|
||||
CURL_DISABLE_DICT = @CURL_DISABLE_DICT@
|
||||
CURL_DISABLE_FILE = @CURL_DISABLE_FILE@
|
||||
CURL_DISABLE_FTP = @CURL_DISABLE_FTP@
|
||||
CURL_DISABLE_GOPHER = @CURL_DISABLE_GOPHER@
|
||||
CURL_DISABLE_HTTP = @CURL_DISABLE_HTTP@
|
||||
CURL_DISABLE_IMAP = @CURL_DISABLE_IMAP@
|
||||
CURL_DISABLE_LDAP = @CURL_DISABLE_LDAP@
|
||||
CURL_DISABLE_LDAPS = @CURL_DISABLE_LDAPS@
|
||||
CURL_DISABLE_MQTT = @CURL_DISABLE_MQTT@
|
||||
CURL_DISABLE_POP3 = @CURL_DISABLE_POP3@
|
||||
CURL_DISABLE_PROXY = @CURL_DISABLE_PROXY@
|
||||
CURL_DISABLE_RTSP = @CURL_DISABLE_RTSP@
|
||||
CURL_DISABLE_SMB = @CURL_DISABLE_SMB@
|
||||
CURL_DISABLE_SMTP = @CURL_DISABLE_SMTP@
|
||||
CURL_DISABLE_TELNET = @CURL_DISABLE_TELNET@
|
||||
CURL_DISABLE_TFTP = @CURL_DISABLE_TFTP@
|
||||
CURL_LT_SHLIB_VERSIONED_FLAVOUR = @CURL_LT_SHLIB_VERSIONED_FLAVOUR@
|
||||
CURL_NETWORK_AND_TIME_LIBS = @CURL_NETWORK_AND_TIME_LIBS@
|
||||
CURL_NETWORK_LIBS = @CURL_NETWORK_LIBS@
|
||||
CURL_WITH_MULTI_SSL = @CURL_WITH_MULTI_SSL@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFAULT_SSL_BACKEND = @DEFAULT_SSL_BACKEND@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
ENABLE_SHARED = @ENABLE_SHARED@
|
||||
ENABLE_STATIC = @ENABLE_STATIC@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
FISH_FUNCTIONS_DIR = @FISH_FUNCTIONS_DIR@
|
||||
GCOV = @GCOV@
|
||||
GREP = @GREP@
|
||||
HAVE_BROTLI = @HAVE_BROTLI@
|
||||
HAVE_GNUTLS_SRP = @HAVE_GNUTLS_SRP@
|
||||
HAVE_LDAP_SSL = @HAVE_LDAP_SSL@
|
||||
HAVE_LIBZ = @HAVE_LIBZ@
|
||||
HAVE_OPENSSL_SRP = @HAVE_OPENSSL_SRP@
|
||||
HAVE_PROTO_BSDSOCKET_H = @HAVE_PROTO_BSDSOCKET_H@
|
||||
HAVE_ZSTD = @HAVE_ZSTD@
|
||||
IDN_ENABLED = @IDN_ENABLED@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
IPV6_ENABLED = @IPV6_ENABLED@
|
||||
LCOV = @LCOV@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBCURL_LIBS = @LIBCURL_LIBS@
|
||||
LIBCURL_NO_SHARED = @LIBCURL_NO_SHARED@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANIFEST_TOOL = @MANIFEST_TOOL@
|
||||
MANOPT = @MANOPT@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
NROFF = @NROFF@
|
||||
NSS_LIBS = @NSS_LIBS@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PERL = @PERL@
|
||||
PKGADD_NAME = @PKGADD_NAME@
|
||||
PKGADD_PKG = @PKGADD_PKG@
|
||||
PKGADD_VENDOR = @PKGADD_VENDOR@
|
||||
PKGCONFIG = @PKGCONFIG@
|
||||
RANDOM_FILE = @RANDOM_FILE@
|
||||
RANLIB = @RANLIB@
|
||||
REQUIRE_LIB_DEPS = @REQUIRE_LIB_DEPS@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SSL_BACKENDS = @SSL_BACKENDS@
|
||||
SSL_ENABLED = @SSL_ENABLED@
|
||||
SSL_LIBS = @SSL_LIBS@
|
||||
STRIP = @STRIP@
|
||||
SUPPORT_FEATURES = @SUPPORT_FEATURES@
|
||||
SUPPORT_PROTOCOLS = @SUPPORT_PROTOCOLS@
|
||||
USE_ARES = @USE_ARES@
|
||||
USE_BEARSSL = @USE_BEARSSL@
|
||||
USE_GNUTLS = @USE_GNUTLS@
|
||||
USE_HYPER = @USE_HYPER@
|
||||
USE_LIBRTMP = @USE_LIBRTMP@
|
||||
USE_LIBSSH = @USE_LIBSSH@
|
||||
USE_LIBSSH2 = @USE_LIBSSH2@
|
||||
USE_MBEDTLS = @USE_MBEDTLS@
|
||||
USE_MESALINK = @USE_MESALINK@
|
||||
USE_NGHTTP2 = @USE_NGHTTP2@
|
||||
USE_NGHTTP3 = @USE_NGHTTP3@
|
||||
USE_NGTCP2 = @USE_NGTCP2@
|
||||
USE_NGTCP2_CRYPTO_GNUTLS = @USE_NGTCP2_CRYPTO_GNUTLS@
|
||||
USE_NGTCP2_CRYPTO_OPENSSL = @USE_NGTCP2_CRYPTO_OPENSSL@
|
||||
USE_NSS = @USE_NSS@
|
||||
USE_OPENLDAP = @USE_OPENLDAP@
|
||||
USE_QUICHE = @USE_QUICHE@
|
||||
USE_RUSTLS = @USE_RUSTLS@
|
||||
USE_SCHANNEL = @USE_SCHANNEL@
|
||||
USE_SECTRANSP = @USE_SECTRANSP@
|
||||
USE_UNIX_SOCKETS = @USE_UNIX_SOCKETS@
|
||||
USE_WIN32_CRYPTO = @USE_WIN32_CRYPTO@
|
||||
USE_WIN32_LARGE_FILES = @USE_WIN32_LARGE_FILES@
|
||||
USE_WIN32_SMALL_FILES = @USE_WIN32_SMALL_FILES@
|
||||
USE_WINDOWS_SSPI = @USE_WINDOWS_SSPI@
|
||||
USE_WOLFSSH = @USE_WOLFSSH@
|
||||
USE_WOLFSSL = @USE_WOLFSSL@
|
||||
VERSION = @VERSION@
|
||||
VERSIONNUM = @VERSIONNUM@
|
||||
ZLIB_LIBS = @ZLIB_LIBS@
|
||||
ZSH_FUNCTIONS_DIR = @ZSH_FUNCTIONS_DIR@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
libext = @libext@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
runstatedir = @runstatedir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
subdirs = @subdirs@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
###########################################################################
|
||||
pkginclude_HEADERS = \
|
||||
curl.h curlver.h easy.h mprintf.h stdcheaders.h multi.h \
|
||||
typecheck-gcc.h system.h urlapi.h options.h
|
||||
|
||||
CHECKSRC = $(CS_$(V))
|
||||
CS_0 = @echo " RUN " $@;
|
||||
CS_1 =
|
||||
CS_ = $(CS_0)
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/curl/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign include/curl/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
|
||||
if test -n "$$list"; then \
|
||||
echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \
|
||||
$(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \
|
||||
fi; \
|
||||
for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; \
|
||||
done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \
|
||||
$(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \
|
||||
done
|
||||
|
||||
uninstall-pkgincludeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
|
||||
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
|
||||
dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir)
|
||||
|
||||
ID: $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); mkid -fID $$unique
|
||||
tags: tags-am
|
||||
TAGS: tags
|
||||
|
||||
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
$(am__define_uniq_tagged_files); \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: ctags-am
|
||||
|
||||
CTAGS: ctags
|
||||
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
|
||||
$(am__define_uniq_tagged_files); \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
cscopelist: cscopelist-am
|
||||
|
||||
cscopelist-am: $(am__tagged_files)
|
||||
list='$(am__tagged_files)'; \
|
||||
case "$(srcdir)" in \
|
||||
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
|
||||
*) sdir=$(subdir)/$(srcdir) ;; \
|
||||
esac; \
|
||||
for i in $$list; do \
|
||||
if test -f "$$i"; then \
|
||||
echo "$(subdir)/$$i"; \
|
||||
else \
|
||||
echo "$$sdir/$$i"; \
|
||||
fi; \
|
||||
done >> $(top_builddir)/cscope.files
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
distdir-am: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
@CURLDEBUG_FALSE@all-local:
|
||||
all-am: Makefile $(HEADERS) all-local
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(pkgincludedir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
if test -z '$(STRIP)'; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
install; \
|
||||
else \
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
|
||||
fi
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-pkgincludeHEADERS
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-pkgincludeHEADERS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS TAGS all all-am all-local check check-am clean \
|
||||
clean-generic clean-libtool cscopelist-am ctags ctags-am \
|
||||
distclean distclean-generic distclean-libtool distclean-tags \
|
||||
distdir dvi dvi-am html html-am info info-am install \
|
||||
install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-pkgincludeHEADERS \
|
||||
install-ps install-ps-am install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-generic \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
|
||||
uninstall-am uninstall-pkgincludeHEADERS
|
||||
|
||||
.PRECIOUS: Makefile
|
||||
|
||||
|
||||
checksrc:
|
||||
$(CHECKSRC)@PERL@ $(top_srcdir)/lib/checksrc.pl -D$(top_srcdir)/include/curl $(pkginclude_HEADERS)
|
||||
|
||||
# for debug builds, we scan the sources on all regular make invokes
|
||||
@CURLDEBUG_TRUE@all-local: checksrc
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
3097
demo/kugou/include/Common/include/curl/curl.h
Normal file
3097
demo/kugou/include/Common/include/curl/curl.h
Normal file
File diff suppressed because it is too large
Load Diff
77
demo/kugou/include/Common/include/curl/curlver.h
Normal file
77
demo/kugou/include/Common/include/curl/curlver.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef CURLINC_CURLVER_H
|
||||
#define CURLINC_CURLVER_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* This header file contains nothing but libcurl version info, generated by
|
||||
a script at release-time. This was made its own header file in 7.11.2 */
|
||||
|
||||
/* This is the global package copyright */
|
||||
#define LIBCURL_COPYRIGHT "1996 - 2021 Daniel Stenberg, <daniel@haxx.se>."
|
||||
|
||||
/* This is the version number of the libcurl package from which this header
|
||||
file origins: */
|
||||
#define LIBCURL_VERSION "7.80.0"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBCURL_VERSION_MAJOR 7
|
||||
#define LIBCURL_VERSION_MINOR 80
|
||||
#define LIBCURL_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libcurl version number, meant for easier
|
||||
parsing and comparisons by programs. The LIBCURL_VERSION_NUM define will
|
||||
always follow this syntax:
|
||||
|
||||
0xXXYYZZ
|
||||
|
||||
Where XX, YY and ZZ are the main version, release and patch numbers in
|
||||
hexadecimal (using 8 bits each). All three numbers are always represented
|
||||
using two digits. 1.2 would appear as "0x010200" while version 9.11.7
|
||||
appears as "0x090b07".
|
||||
|
||||
This 6-digit (24 bits) hexadecimal number does not show pre-release number,
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
|
||||
Note: This define is the full hex number and _does not_ use the
|
||||
CURL_VERSION_BITS() macro since curl's own configure script greps for it
|
||||
and needs it to contain the full number.
|
||||
*/
|
||||
#define LIBCURL_VERSION_NUM 0x075000
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
* timestamp is not stored in git, as the timestamp is properly set in the
|
||||
* tarballs by the maketgz script.
|
||||
*
|
||||
* The format of the date follows this template:
|
||||
*
|
||||
* "2007-11-23"
|
||||
*/
|
||||
#define LIBCURL_TIMESTAMP "2021-11-10"
|
||||
|
||||
#define CURL_VERSION_BITS(x,y,z) ((x)<<16|(y)<<8|(z))
|
||||
#define CURL_AT_LEAST_VERSION(x,y,z) \
|
||||
(LIBCURL_VERSION_NUM >= CURL_VERSION_BITS(x, y, z))
|
||||
|
||||
#endif /* CURLINC_CURLVER_H */
|
||||
123
demo/kugou/include/Common/include/curl/easy.h
Normal file
123
demo/kugou/include/Common/include/curl/easy.h
Normal file
@@ -0,0 +1,123 @@
|
||||
#ifndef CURLINC_EASY_H
|
||||
#define CURLINC_EASY_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Flag bits in the curl_blob struct: */
|
||||
#define CURL_BLOB_COPY 1 /* tell libcurl to copy the data */
|
||||
#define CURL_BLOB_NOCOPY 0 /* tell libcurl to NOT copy the data */
|
||||
|
||||
struct curl_blob {
|
||||
void *data;
|
||||
size_t len;
|
||||
unsigned int flags; /* bit 0 is defined, the rest are reserved and should be
|
||||
left zeroes */
|
||||
};
|
||||
|
||||
CURL_EXTERN CURL *curl_easy_init(void);
|
||||
CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...);
|
||||
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl);
|
||||
CURL_EXTERN void curl_easy_cleanup(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_getinfo()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Request internal information from the curl session with this function. The
|
||||
* third argument MUST be a pointer to a long, a pointer to a char * or a
|
||||
* pointer to a double (as the documentation describes elsewhere). The data
|
||||
* pointed to will be filled in accordingly and can be relied upon only if the
|
||||
* function returns CURLE_OK. This function is intended to get used *AFTER* a
|
||||
* performed transfer, all results from this function are undefined until the
|
||||
* transfer is completed.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_duphandle()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistent connections cannot
|
||||
* be transferred. It is useful in multithreaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
CURL_EXTERN CURL *curl_easy_duphandle(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_reset()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Re-initializes a CURL handle to the default values. This puts back the
|
||||
* handle to the same state as it was in when it was just created.
|
||||
*
|
||||
* It does keep: live connections, the Session ID cache, the DNS cache and the
|
||||
* cookies.
|
||||
*/
|
||||
CURL_EXTERN void curl_easy_reset(CURL *curl);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_recv()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Receives data from the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_recv(CURL *curl, void *buffer, size_t buflen,
|
||||
size_t *n);
|
||||
|
||||
/*
|
||||
* NAME curl_easy_send()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Sends data over the connected socket. Use after successful
|
||||
* curl_easy_perform() with CURLOPT_CONNECT_ONLY option.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_send(CURL *curl, const void *buffer,
|
||||
size_t buflen, size_t *n);
|
||||
|
||||
|
||||
/*
|
||||
* NAME curl_easy_upkeep()
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Performs connection upkeep for the given session handle.
|
||||
*/
|
||||
CURL_EXTERN CURLcode curl_easy_upkeep(CURL *curl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
50
demo/kugou/include/Common/include/curl/mprintf.h
Normal file
50
demo/kugou/include/Common/include/curl/mprintf.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef CURLINC_MPRINTF_H
|
||||
#define CURLINC_MPRINTF_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h> /* needed for FILE */
|
||||
#include "curl.h" /* for CURL_EXTERN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
CURL_EXTERN int curl_mprintf(const char *format, ...);
|
||||
CURL_EXTERN int curl_mfprintf(FILE *fd, const char *format, ...);
|
||||
CURL_EXTERN int curl_msprintf(char *buffer, const char *format, ...);
|
||||
CURL_EXTERN int curl_msnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, ...);
|
||||
CURL_EXTERN int curl_mvprintf(const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvfprintf(FILE *fd, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsprintf(char *buffer, const char *format, va_list args);
|
||||
CURL_EXTERN int curl_mvsnprintf(char *buffer, size_t maxlength,
|
||||
const char *format, va_list args);
|
||||
CURL_EXTERN char *curl_maprintf(const char *format, ...);
|
||||
CURL_EXTERN char *curl_mvaprintf(const char *format, va_list args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_MPRINTF_H */
|
||||
456
demo/kugou/include/Common/include/curl/multi.h
Normal file
456
demo/kugou/include/Common/include/curl/multi.h
Normal file
@@ -0,0 +1,456 @@
|
||||
#ifndef CURLINC_MULTI_H
|
||||
#define CURLINC_MULTI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
/*
|
||||
This is an "external" header file. Don't give away any internals here!
|
||||
|
||||
GOALS
|
||||
|
||||
o Enable a "pull" interface. The application that uses libcurl decides where
|
||||
and when to ask libcurl to get/send data.
|
||||
|
||||
o Enable multiple simultaneous transfers in the same thread without making it
|
||||
complicated for the application.
|
||||
|
||||
o Enable the application to select() on its own file descriptors and curl's
|
||||
file descriptors simultaneous easily.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* This header file should not really need to include "curl.h" since curl.h
|
||||
* itself includes this file and we expect user applications to do #include
|
||||
* <curl/curl.h> without the need for especially including multi.h.
|
||||
*
|
||||
* For some reason we added this include here at one point, and rather than to
|
||||
* break existing (wrongly written) libcurl applications, we leave it as-is
|
||||
* but with this warning attached.
|
||||
*/
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(BUILDING_LIBCURL) || defined(CURL_STRICTER)
|
||||
typedef struct Curl_multi CURLM;
|
||||
#else
|
||||
typedef void CURLM;
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLM_CALL_MULTI_PERFORM = -1, /* please call curl_multi_perform() or
|
||||
curl_multi_socket*() soon */
|
||||
CURLM_OK,
|
||||
CURLM_BAD_HANDLE, /* the passed-in handle is not a valid CURLM handle */
|
||||
CURLM_BAD_EASY_HANDLE, /* an easy handle was not good/valid */
|
||||
CURLM_OUT_OF_MEMORY, /* if you ever get this, you're in deep sh*t */
|
||||
CURLM_INTERNAL_ERROR, /* this is a libcurl bug */
|
||||
CURLM_BAD_SOCKET, /* the passed in socket argument did not match */
|
||||
CURLM_UNKNOWN_OPTION, /* curl_multi_setopt() with unsupported option */
|
||||
CURLM_ADDED_ALREADY, /* an easy handle already added to a multi handle was
|
||||
attempted to get added - again */
|
||||
CURLM_RECURSIVE_API_CALL, /* an api function was called from inside a
|
||||
callback */
|
||||
CURLM_WAKEUP_FAILURE, /* wakeup is unavailable or failed */
|
||||
CURLM_BAD_FUNCTION_ARGUMENT, /* function called with a bad parameter */
|
||||
CURLM_LAST
|
||||
} CURLMcode;
|
||||
|
||||
/* just to make code nicer when using curl_multi_socket() you can now check
|
||||
for CURLM_CALL_MULTI_SOCKET too in the same style it works for
|
||||
curl_multi_perform() and CURLM_CALL_MULTI_PERFORM */
|
||||
#define CURLM_CALL_MULTI_SOCKET CURLM_CALL_MULTI_PERFORM
|
||||
|
||||
/* bitmask bits for CURLMOPT_PIPELINING */
|
||||
#define CURLPIPE_NOTHING 0L
|
||||
#define CURLPIPE_HTTP1 1L
|
||||
#define CURLPIPE_MULTIPLEX 2L
|
||||
|
||||
typedef enum {
|
||||
CURLMSG_NONE, /* first, not used */
|
||||
CURLMSG_DONE, /* This easy handle has completed. 'result' contains
|
||||
the CURLcode of the transfer */
|
||||
CURLMSG_LAST /* last, not used */
|
||||
} CURLMSG;
|
||||
|
||||
struct CURLMsg {
|
||||
CURLMSG msg; /* what this message means */
|
||||
CURL *easy_handle; /* the handle it concerns */
|
||||
union {
|
||||
void *whatever; /* message-specific data */
|
||||
CURLcode result; /* return code for transfer */
|
||||
} data;
|
||||
};
|
||||
typedef struct CURLMsg CURLMsg;
|
||||
|
||||
/* Based on poll(2) structure and values.
|
||||
* We don't use pollfd and POLL* constants explicitly
|
||||
* to cover platforms without poll(). */
|
||||
#define CURL_WAIT_POLLIN 0x0001
|
||||
#define CURL_WAIT_POLLPRI 0x0002
|
||||
#define CURL_WAIT_POLLOUT 0x0004
|
||||
|
||||
struct curl_waitfd {
|
||||
curl_socket_t fd;
|
||||
short events;
|
||||
short revents; /* not supported yet */
|
||||
};
|
||||
|
||||
/*
|
||||
* Name: curl_multi_init()
|
||||
*
|
||||
* Desc: inititalize multi-style curl usage
|
||||
*
|
||||
* Returns: a new CURLM handle to use in all 'curl_multi' functions.
|
||||
*/
|
||||
CURL_EXTERN CURLM *curl_multi_init(void);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_add_handle()
|
||||
*
|
||||
* Desc: add a standard curl handle to the multi stack
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_remove_handle()
|
||||
*
|
||||
* Desc: removes a curl handle from the multi stack again
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
|
||||
CURL *curl_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_fdset()
|
||||
*
|
||||
* Desc: Ask curl for its fd_set sets. The app can use these to select() or
|
||||
* poll() on. We want curl_multi_perform() called as soon as one of
|
||||
* them are ready.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
|
||||
fd_set *read_fd_set,
|
||||
fd_set *write_fd_set,
|
||||
fd_set *exc_fd_set,
|
||||
int *max_fd);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wait()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_poll()
|
||||
*
|
||||
* Desc: Poll on all fds within a CURLM set as well as any
|
||||
* additional fds passed to the function.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
|
||||
struct curl_waitfd extra_fds[],
|
||||
unsigned int extra_nfds,
|
||||
int timeout_ms,
|
||||
int *ret);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_wakeup()
|
||||
*
|
||||
* Desc: wakes up a sleeping curl_multi_poll call.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_perform()
|
||||
*
|
||||
* Desc: When the app thinks there's data available for curl it calls this
|
||||
* function to read/write whatever there is right now. This returns
|
||||
* as soon as the reads and writes are done. This function does not
|
||||
* require that there actually is data available for reading or that
|
||||
* data can be written, it can be called just in case. It returns
|
||||
* the number of handles that still transfer data in the second
|
||||
* argument's integer-pointer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code. *NOTE* that this only
|
||||
* returns errors etc regarding the whole multi stack. There might
|
||||
* still have occurred problems on individual transfers even when
|
||||
* this returns OK.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_cleanup()
|
||||
*
|
||||
* Desc: Cleans up and removes a whole multi stack. It does not free or
|
||||
* touch any individual easy handles in any way. We need to define
|
||||
* in what state those handles will be if this function is called
|
||||
* in the middle of a transfer.
|
||||
*
|
||||
* Returns: CURLMcode type, general multi error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_info_read()
|
||||
*
|
||||
* Desc: Ask the multi handle if there's any messages/informationals from
|
||||
* the individual transfers. Messages include informationals such as
|
||||
* error code from the transfer or just the fact that a transfer is
|
||||
* completed. More details on these should be written down as well.
|
||||
*
|
||||
* Repeated calls to this function will return a new struct each
|
||||
* time, until a special "end of msgs" struct is returned as a signal
|
||||
* that there is no more to get at this point.
|
||||
*
|
||||
* The data the returned pointer points to will not survive calling
|
||||
* curl_multi_cleanup().
|
||||
*
|
||||
* The 'CURLMsg' struct is meant to be very simple and only contain
|
||||
* very basic information. If more involved information is wanted,
|
||||
* we will provide the particular "transfer handle" in that struct
|
||||
* and that should/could/would be used in subsequent
|
||||
* curl_easy_getinfo() calls (or similar). The point being that we
|
||||
* must never expose complex structs to applications, as then we'll
|
||||
* undoubtably get backwards compatibility problems in the future.
|
||||
*
|
||||
* Returns: A pointer to a filled-in struct, or NULL if it failed or ran out
|
||||
* of structs. It also writes the number of messages left in the
|
||||
* queue (after this read) in the integer the second argument points
|
||||
* to.
|
||||
*/
|
||||
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
|
||||
int *msgs_in_queue);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_strerror()
|
||||
*
|
||||
* Desc: The curl_multi_strerror function may be used to turn a CURLMcode
|
||||
* value into the equivalent human readable error string. This is
|
||||
* useful for printing meaningful error messages.
|
||||
*
|
||||
* Returns: A pointer to a null-terminated error message.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_multi_strerror(CURLMcode);
|
||||
|
||||
/*
|
||||
* Name: curl_multi_socket() and
|
||||
* curl_multi_socket_all()
|
||||
*
|
||||
* Desc: An alternative version of curl_multi_perform() that allows the
|
||||
* application to pass in one of the file descriptors that have been
|
||||
* detected to have "action" on them and let libcurl perform.
|
||||
* See man page for details.
|
||||
*/
|
||||
#define CURL_POLL_NONE 0
|
||||
#define CURL_POLL_IN 1
|
||||
#define CURL_POLL_OUT 2
|
||||
#define CURL_POLL_INOUT 3
|
||||
#define CURL_POLL_REMOVE 4
|
||||
|
||||
#define CURL_SOCKET_TIMEOUT CURL_SOCKET_BAD
|
||||
|
||||
#define CURL_CSELECT_IN 0x01
|
||||
#define CURL_CSELECT_OUT 0x02
|
||||
#define CURL_CSELECT_ERR 0x04
|
||||
|
||||
typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
|
||||
curl_socket_t s, /* socket */
|
||||
int what, /* see above */
|
||||
void *userp, /* private callback
|
||||
pointer */
|
||||
void *socketp); /* private socket
|
||||
pointer */
|
||||
/*
|
||||
* Name: curl_multi_timer_callback
|
||||
*
|
||||
* Desc: Called by libcurl whenever the library detects a change in the
|
||||
* maximum number of milliseconds the app is allowed to wait before
|
||||
* curl_multi_socket() or curl_multi_perform() must be called
|
||||
* (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: The callback should return zero.
|
||||
*/
|
||||
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
|
||||
long timeout_ms, /* see above */
|
||||
void *userp); /* private callback
|
||||
pointer */
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket(CURLM *multi_handle, curl_socket_t s,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
|
||||
curl_socket_t s,
|
||||
int ev_bitmask,
|
||||
int *running_handles);
|
||||
|
||||
CURL_EXTERN CURLMcode curl_multi_socket_all(CURLM *multi_handle,
|
||||
int *running_handles);
|
||||
|
||||
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
|
||||
/* This macro below was added in 7.16.3 to push users who recompile to use
|
||||
the new curl_multi_socket_action() instead of the old curl_multi_socket()
|
||||
*/
|
||||
#define curl_multi_socket(x,y,z) curl_multi_socket_action(x,y,0,z)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Name: curl_multi_timeout()
|
||||
*
|
||||
* Desc: Returns the maximum number of milliseconds the app is allowed to
|
||||
* wait before curl_multi_socket() or curl_multi_perform() must be
|
||||
* called (to allow libcurl's timed events to take place).
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
|
||||
long *milliseconds);
|
||||
|
||||
typedef enum {
|
||||
/* This is the socket callback function pointer */
|
||||
CURLOPT(CURLMOPT_SOCKETFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 1),
|
||||
|
||||
/* This is the argument passed to the socket callback */
|
||||
CURLOPT(CURLMOPT_SOCKETDATA, CURLOPTTYPE_OBJECTPOINT, 2),
|
||||
|
||||
/* set to 1 to enable pipelining for this multi handle */
|
||||
CURLOPT(CURLMOPT_PIPELINING, CURLOPTTYPE_LONG, 3),
|
||||
|
||||
/* This is the timer callback function pointer */
|
||||
CURLOPT(CURLMOPT_TIMERFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 4),
|
||||
|
||||
/* This is the argument passed to the timer callback */
|
||||
CURLOPT(CURLMOPT_TIMERDATA, CURLOPTTYPE_OBJECTPOINT, 5),
|
||||
|
||||
/* maximum number of entries in the connection cache */
|
||||
CURLOPT(CURLMOPT_MAXCONNECTS, CURLOPTTYPE_LONG, 6),
|
||||
|
||||
/* maximum number of (pipelining) connections to one host */
|
||||
CURLOPT(CURLMOPT_MAX_HOST_CONNECTIONS, CURLOPTTYPE_LONG, 7),
|
||||
|
||||
/* maximum number of requests in a pipeline */
|
||||
CURLOPT(CURLMOPT_MAX_PIPELINE_LENGTH, CURLOPTTYPE_LONG, 8),
|
||||
|
||||
/* a connection with a content-length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CONTENT_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 9),
|
||||
|
||||
/* a connection with a chunk length longer than this
|
||||
will not be considered for pipelining */
|
||||
CURLOPT(CURLMOPT_CHUNK_LENGTH_PENALTY_SIZE, CURLOPTTYPE_OFF_T, 10),
|
||||
|
||||
/* a list of site names(+port) that are blocked from pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SITE_BL, CURLOPTTYPE_OBJECTPOINT, 11),
|
||||
|
||||
/* a list of server types that are blocked from pipelining */
|
||||
CURLOPT(CURLMOPT_PIPELINING_SERVER_BL, CURLOPTTYPE_OBJECTPOINT, 12),
|
||||
|
||||
/* maximum number of open connections in total */
|
||||
CURLOPT(CURLMOPT_MAX_TOTAL_CONNECTIONS, CURLOPTTYPE_LONG, 13),
|
||||
|
||||
/* This is the server push callback function pointer */
|
||||
CURLOPT(CURLMOPT_PUSHFUNCTION, CURLOPTTYPE_FUNCTIONPOINT, 14),
|
||||
|
||||
/* This is the argument passed to the server push callback */
|
||||
CURLOPT(CURLMOPT_PUSHDATA, CURLOPTTYPE_OBJECTPOINT, 15),
|
||||
|
||||
/* maximum number of concurrent streams to support on a connection */
|
||||
CURLOPT(CURLMOPT_MAX_CONCURRENT_STREAMS, CURLOPTTYPE_LONG, 16),
|
||||
|
||||
CURLMOPT_LASTENTRY /* the last unused */
|
||||
} CURLMoption;
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_setopt()
|
||||
*
|
||||
* Desc: Sets options for the multi handle.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
|
||||
CURLMoption option, ...);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_multi_assign()
|
||||
*
|
||||
* Desc: This function sets an association in the multi handle between the
|
||||
* given socket and a private pointer of the application. This is
|
||||
* (only) useful for curl_multi_socket uses.
|
||||
*
|
||||
* Returns: CURLM error code.
|
||||
*/
|
||||
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
|
||||
curl_socket_t sockfd, void *sockp);
|
||||
|
||||
|
||||
/*
|
||||
* Name: curl_push_callback
|
||||
*
|
||||
* Desc: This callback gets called when a new stream is being pushed by the
|
||||
* server. It approves or denies the new stream. It can also decide
|
||||
* to completely fail the connection.
|
||||
*
|
||||
* Returns: CURL_PUSH_OK, CURL_PUSH_DENY or CURL_PUSH_ERROROUT
|
||||
*/
|
||||
#define CURL_PUSH_OK 0
|
||||
#define CURL_PUSH_DENY 1
|
||||
#define CURL_PUSH_ERROROUT 2 /* added in 7.72.0 */
|
||||
|
||||
struct curl_pushheaders; /* forward declaration only */
|
||||
|
||||
CURL_EXTERN char *curl_pushheader_bynum(struct curl_pushheaders *h,
|
||||
size_t num);
|
||||
CURL_EXTERN char *curl_pushheader_byname(struct curl_pushheaders *h,
|
||||
const char *name);
|
||||
|
||||
typedef int (*curl_push_callback)(CURL *parent,
|
||||
CURL *easy,
|
||||
size_t num_headers,
|
||||
struct curl_pushheaders *headers,
|
||||
void *userp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
demo/kugou/include/Common/include/curl/options.h
Normal file
68
demo/kugou/include/Common/include/curl/options.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef CURLINC_OPTIONS_H
|
||||
#define CURLINC_OPTIONS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
CURLOT_LONG, /* long (a range of values) */
|
||||
CURLOT_VALUES, /* (a defined set or bitmask) */
|
||||
CURLOT_OFF_T, /* curl_off_t (a range of values) */
|
||||
CURLOT_OBJECT, /* pointer (void *) */
|
||||
CURLOT_STRING, /* (char * to zero terminated buffer) */
|
||||
CURLOT_SLIST, /* (struct curl_slist *) */
|
||||
CURLOT_CBPTR, /* (void * passed as-is to a callback) */
|
||||
CURLOT_BLOB, /* blob (struct curl_blob *) */
|
||||
CURLOT_FUNCTION /* function pointer */
|
||||
} curl_easytype;
|
||||
|
||||
/* Flag bits */
|
||||
|
||||
/* "alias" means it is provided for old programs to remain functional,
|
||||
we prefer another name */
|
||||
#define CURLOT_FLAG_ALIAS (1<<0)
|
||||
|
||||
/* The CURLOPTTYPE_* id ranges can still be used to figure out what type/size
|
||||
to use for curl_easy_setopt() for the given id */
|
||||
struct curl_easyoption {
|
||||
const char *name;
|
||||
CURLoption id;
|
||||
curl_easytype type;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_by_name(const char *name);
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_by_id (CURLoption id);
|
||||
|
||||
CURL_EXTERN const struct curl_easyoption *
|
||||
curl_easy_option_next(const struct curl_easyoption *prev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
#endif /* CURLINC_OPTIONS_H */
|
||||
33
demo/kugou/include/Common/include/curl/stdcheaders.h
Normal file
33
demo/kugou/include/Common/include/curl/stdcheaders.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef CURLINC_STDCHEADERS_H
|
||||
#define CURLINC_STDCHEADERS_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
size_t fread(void *, size_t, size_t, FILE *);
|
||||
size_t fwrite(const void *, size_t, size_t, FILE *);
|
||||
|
||||
int strcasecmp(const char *, const char *);
|
||||
int strncasecmp(const char *, const char *, size_t);
|
||||
|
||||
#endif /* CURLINC_STDCHEADERS_H */
|
||||
504
demo/kugou/include/Common/include/curl/system.h
Normal file
504
demo/kugou/include/Common/include/curl/system.h
Normal file
@@ -0,0 +1,504 @@
|
||||
#ifndef CURLINC_SYSTEM_H
|
||||
#define CURLINC_SYSTEM_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/*
|
||||
* Try to keep one section per platform, compiler and architecture, otherwise,
|
||||
* if an existing section is reused for a different one and later on the
|
||||
* original is adjusted, probably the piggybacking one can be adversely
|
||||
* changed.
|
||||
*
|
||||
* In order to differentiate between platforms/compilers/architectures use
|
||||
* only compiler built in predefined preprocessor symbols.
|
||||
*
|
||||
* curl_off_t
|
||||
* ----------
|
||||
*
|
||||
* For any given platform/compiler curl_off_t must be typedef'ed to a 64-bit
|
||||
* wide signed integral data type. The width of this data type must remain
|
||||
* constant and independent of any possible large file support settings.
|
||||
*
|
||||
* As an exception to the above, curl_off_t shall be typedef'ed to a 32-bit
|
||||
* wide signed integral data type if there is no 64-bit type.
|
||||
*
|
||||
* As a general rule, curl_off_t shall not be mapped to off_t. This rule shall
|
||||
* only be violated if off_t is the only 64-bit data type available and the
|
||||
* size of off_t is independent of large file support settings. Keep your
|
||||
* build on the safe side avoiding an off_t gating. If you have a 64-bit
|
||||
* off_t then take for sure that another 64-bit data type exists, dig deeper
|
||||
* and you will find it.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__DJGPP__) || defined(__GO32__)
|
||||
# if defined(__DJGPP__) && (__DJGPP__ > 1)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__SALFORDC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__BORLANDC__)
|
||||
# if (__BORLANDC__ < 0x520)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TURBOC__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__WATCOMC__)
|
||||
# if defined(__386__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__POCC__)
|
||||
# if (__POCC__ < 280)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# elif defined(_MSC_VER)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__LCC__)
|
||||
# if defined(__e2k__) /* MCST eLbrus C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# else /* Local (or Little) C Compiler */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
# endif
|
||||
|
||||
#elif defined(__SYMBIAN32__)
|
||||
# if defined(__EABI__) /* Treat all ARM compilers equally */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__CW32__)
|
||||
# pragma longlong on
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__VC32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__MWERKS__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(_WIN32_WCE)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__MINGW32__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_WS2TCPIP_H 1
|
||||
|
||||
#elif defined(__VMS)
|
||||
# if defined(__VAX)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T unsigned int
|
||||
|
||||
#elif defined(__OS400__)
|
||||
# if defined(__ILEC400__)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__MVS__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(__370__)
|
||||
# if defined(__IBMC__) || defined(__IBMCPP__)
|
||||
# if defined(_ILP32)
|
||||
# elif defined(_LP64)
|
||||
# endif
|
||||
# if defined(_LONG_LONG)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
# endif
|
||||
|
||||
#elif defined(TPF)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
#elif defined(__TINYC__) /* also known as tcc */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Oracle Solaris Studio */
|
||||
# if !defined(__LP64) && (defined(__ILP32) || \
|
||||
defined(__i386) || \
|
||||
defined(__sparcv8) || \
|
||||
defined(__sparcv8plus))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64) || \
|
||||
defined(__amd64) || defined(__sparcv9)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#elif defined(__xlc__) /* IBM xlc compiler */
|
||||
# if !defined(_LP64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP MSVC THE PENULTIMATE ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define CURL_TYPEOF_CURL_OFF_T __int64
|
||||
# define CURL_FORMAT_CURL_OFF_T "I64d"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "I64u"
|
||||
# define CURL_SUFFIX_CURL_OFF_T i64
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ui64
|
||||
# else
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
|
||||
/* ===================================== */
|
||||
/* KEEP GENERIC GCC THE LAST ENTRY */
|
||||
/* ===================================== */
|
||||
|
||||
#elif defined(__GNUC__) && !defined(_SCO_DS)
|
||||
# if !defined(__LP64__) && \
|
||||
(defined(__ILP32__) || defined(__i386__) || defined(__hppa__) || \
|
||||
defined(__ppc__) || defined(__powerpc__) || defined(__arm__) || \
|
||||
defined(__sparc__) || defined(__mips__) || defined(__sh__) || \
|
||||
defined(__XTENSA__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 4) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 2147483647L))
|
||||
# define CURL_TYPEOF_CURL_OFF_T long long
|
||||
# define CURL_FORMAT_CURL_OFF_T "lld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "llu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T LL
|
||||
# define CURL_SUFFIX_CURL_OFF_TU ULL
|
||||
# elif defined(__LP64__) || \
|
||||
defined(__x86_64__) || defined(__ppc64__) || defined(__sparc64__) || \
|
||||
defined(__e2k__) || \
|
||||
(defined(__SIZEOF_LONG__) && __SIZEOF_LONG__ == 8) || \
|
||||
(defined(__LONG_MAX__) && __LONG_MAX__ == 9223372036854775807L)
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# endif
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
|
||||
# define CURL_PULL_SYS_TYPES_H 1
|
||||
# define CURL_PULL_SYS_SOCKET_H 1
|
||||
|
||||
#else
|
||||
/* generic "safe guess" on old 32 bit style */
|
||||
# define CURL_TYPEOF_CURL_OFF_T long
|
||||
# define CURL_FORMAT_CURL_OFF_T "ld"
|
||||
# define CURL_FORMAT_CURL_OFF_TU "lu"
|
||||
# define CURL_SUFFIX_CURL_OFF_T L
|
||||
# define CURL_SUFFIX_CURL_OFF_TU UL
|
||||
# define CURL_TYPEOF_CURL_SOCKLEN_T int
|
||||
#endif
|
||||
|
||||
#ifdef _AIX
|
||||
/* AIX needs <sys/poll.h> */
|
||||
#define CURL_PULL_SYS_POLL_H
|
||||
#endif
|
||||
|
||||
|
||||
/* CURL_PULL_WS2TCPIP_H is defined above when inclusion of header file */
|
||||
/* ws2tcpip.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_WS2TCPIP_H
|
||||
# include <winsock2.h>
|
||||
# include <windows.h>
|
||||
# include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_TYPES_H is defined above when inclusion of header file */
|
||||
/* sys/types.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_TYPES_H
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
|
||||
/* sys/socket.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
/* CURL_PULL_SYS_POLL_H is defined above when inclusion of header file */
|
||||
/* sys/poll.h is required here to properly make type definitions below. */
|
||||
#ifdef CURL_PULL_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_socklen_t. */
|
||||
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
|
||||
typedef CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t;
|
||||
#endif
|
||||
|
||||
/* Data type definition of curl_off_t. */
|
||||
|
||||
#ifdef CURL_TYPEOF_CURL_OFF_T
|
||||
typedef CURL_TYPEOF_CURL_OFF_T curl_off_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* CURL_ISOCPP and CURL_OFF_T_C definitions are done here in order to allow
|
||||
* these to be visible and exported by the external libcurl interface API,
|
||||
* while also making them visible to the library internals, simply including
|
||||
* curl_setup.h, without actually needing to include curl.h internally.
|
||||
* If some day this section would grow big enough, all this should be moved
|
||||
* to its own header file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Figure out if we can use the ## preprocessor operator, which is supported
|
||||
* by ISO/ANSI C and C++. Some compilers support it without setting __STDC__
|
||||
* or __cplusplus so we need to carefully check for them too.
|
||||
*/
|
||||
|
||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) || \
|
||||
defined(__HP_aCC) || defined(__BORLANDC__) || defined(__LCC__) || \
|
||||
defined(__POCC__) || defined(__SALFORDC__) || defined(__HIGHC__) || \
|
||||
defined(__ILEC400__)
|
||||
/* This compiler is believed to have an ISO compatible preprocessor */
|
||||
#define CURL_ISOCPP
|
||||
#else
|
||||
/* This compiler is believed NOT to have an ISO compatible preprocessor */
|
||||
#undef CURL_ISOCPP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for minimum-width signed and unsigned curl_off_t integer constants.
|
||||
*/
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC__ == 0x0551)
|
||||
# define CURLINC_OFF_T_C_HLPR2(x) x
|
||||
# define CURLINC_OFF_T_C_HLPR1(x) CURLINC_OFF_T_C_HLPR2(x)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val) ## \
|
||||
CURLINC_OFF_T_C_HLPR1(CURL_SUFFIX_CURL_OFF_TU)
|
||||
#else
|
||||
# ifdef CURL_ISOCPP
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val ## Suffix
|
||||
# else
|
||||
# define CURLINC_OFF_T_C_HLPR2(Val,Suffix) Val/**/Suffix
|
||||
# endif
|
||||
# define CURLINC_OFF_T_C_HLPR1(Val,Suffix) CURLINC_OFF_T_C_HLPR2(Val,Suffix)
|
||||
# define CURL_OFF_T_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_T)
|
||||
# define CURL_OFF_TU_C(Val) CURLINC_OFF_T_C_HLPR1(Val,CURL_SUFFIX_CURL_OFF_TU)
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_SYSTEM_H */
|
||||
707
demo/kugou/include/Common/include/curl/typecheck-gcc.h
Normal file
707
demo/kugou/include/Common/include/curl/typecheck-gcc.h
Normal file
@@ -0,0 +1,707 @@
|
||||
#ifndef CURLINC_TYPECHECK_GCC_H
|
||||
#define CURLINC_TYPECHECK_GCC_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/* wraps curl_easy_setopt() with typechecking */
|
||||
|
||||
/* To add a new kind of warning, add an
|
||||
* if(curlcheck_sometype_option(_curl_opt))
|
||||
* if(!curlcheck_sometype(value))
|
||||
* _curl_easy_setopt_err_sometype();
|
||||
* block and define curlcheck_sometype_option, curlcheck_sometype and
|
||||
* _curl_easy_setopt_err_sometype below
|
||||
*
|
||||
* NOTE: We use two nested 'if' statements here instead of the && operator, in
|
||||
* order to work around gcc bug #32061. It affects only gcc 4.3.x/4.4.x
|
||||
* when compiling with -Wlogical-op.
|
||||
*
|
||||
* To add an option that uses the same type as an existing option, you'll just
|
||||
* need to extend the appropriate _curl_*_option macro
|
||||
*/
|
||||
#define curl_easy_setopt(handle, option, value) \
|
||||
__extension__({ \
|
||||
__typeof__(option) _curl_opt = option; \
|
||||
if(__builtin_constant_p(_curl_opt)) { \
|
||||
if(curlcheck_long_option(_curl_opt)) \
|
||||
if(!curlcheck_long(value)) \
|
||||
_curl_easy_setopt_err_long(); \
|
||||
if(curlcheck_off_t_option(_curl_opt)) \
|
||||
if(!curlcheck_off_t(value)) \
|
||||
_curl_easy_setopt_err_curl_off_t(); \
|
||||
if(curlcheck_string_option(_curl_opt)) \
|
||||
if(!curlcheck_string(value)) \
|
||||
_curl_easy_setopt_err_string(); \
|
||||
if(curlcheck_write_cb_option(_curl_opt)) \
|
||||
if(!curlcheck_write_cb(value)) \
|
||||
_curl_easy_setopt_err_write_callback(); \
|
||||
if((_curl_opt) == CURLOPT_RESOLVER_START_FUNCTION) \
|
||||
if(!curlcheck_resolver_start_callback(value)) \
|
||||
_curl_easy_setopt_err_resolver_start_callback(); \
|
||||
if((_curl_opt) == CURLOPT_READFUNCTION) \
|
||||
if(!curlcheck_read_cb(value)) \
|
||||
_curl_easy_setopt_err_read_cb(); \
|
||||
if((_curl_opt) == CURLOPT_IOCTLFUNCTION) \
|
||||
if(!curlcheck_ioctl_cb(value)) \
|
||||
_curl_easy_setopt_err_ioctl_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SOCKOPTFUNCTION) \
|
||||
if(!curlcheck_sockopt_cb(value)) \
|
||||
_curl_easy_setopt_err_sockopt_cb(); \
|
||||
if((_curl_opt) == CURLOPT_OPENSOCKETFUNCTION) \
|
||||
if(!curlcheck_opensocket_cb(value)) \
|
||||
_curl_easy_setopt_err_opensocket_cb(); \
|
||||
if((_curl_opt) == CURLOPT_PROGRESSFUNCTION) \
|
||||
if(!curlcheck_progress_cb(value)) \
|
||||
_curl_easy_setopt_err_progress_cb(); \
|
||||
if((_curl_opt) == CURLOPT_DEBUGFUNCTION) \
|
||||
if(!curlcheck_debug_cb(value)) \
|
||||
_curl_easy_setopt_err_debug_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SSL_CTX_FUNCTION) \
|
||||
if(!curlcheck_ssl_ctx_cb(value)) \
|
||||
_curl_easy_setopt_err_ssl_ctx_cb(); \
|
||||
if(curlcheck_conv_cb_option(_curl_opt)) \
|
||||
if(!curlcheck_conv_cb(value)) \
|
||||
_curl_easy_setopt_err_conv_cb(); \
|
||||
if((_curl_opt) == CURLOPT_SEEKFUNCTION) \
|
||||
if(!curlcheck_seek_cb(value)) \
|
||||
_curl_easy_setopt_err_seek_cb(); \
|
||||
if(curlcheck_cb_data_option(_curl_opt)) \
|
||||
if(!curlcheck_cb_data(value)) \
|
||||
_curl_easy_setopt_err_cb_data(); \
|
||||
if((_curl_opt) == CURLOPT_ERRORBUFFER) \
|
||||
if(!curlcheck_error_buffer(value)) \
|
||||
_curl_easy_setopt_err_error_buffer(); \
|
||||
if((_curl_opt) == CURLOPT_STDERR) \
|
||||
if(!curlcheck_FILE(value)) \
|
||||
_curl_easy_setopt_err_FILE(); \
|
||||
if(curlcheck_postfields_option(_curl_opt)) \
|
||||
if(!curlcheck_postfields(value)) \
|
||||
_curl_easy_setopt_err_postfields(); \
|
||||
if((_curl_opt) == CURLOPT_HTTPPOST) \
|
||||
if(!curlcheck_arr((value), struct curl_httppost)) \
|
||||
_curl_easy_setopt_err_curl_httpost(); \
|
||||
if((_curl_opt) == CURLOPT_MIMEPOST) \
|
||||
if(!curlcheck_ptr((value), curl_mime)) \
|
||||
_curl_easy_setopt_err_curl_mimepost(); \
|
||||
if(curlcheck_slist_option(_curl_opt)) \
|
||||
if(!curlcheck_arr((value), struct curl_slist)) \
|
||||
_curl_easy_setopt_err_curl_slist(); \
|
||||
if((_curl_opt) == CURLOPT_SHARE) \
|
||||
if(!curlcheck_ptr((value), CURLSH)) \
|
||||
_curl_easy_setopt_err_CURLSH(); \
|
||||
} \
|
||||
curl_easy_setopt(handle, _curl_opt, value); \
|
||||
})
|
||||
|
||||
/* wraps curl_easy_getinfo() with typechecking */
|
||||
#define curl_easy_getinfo(handle, info, arg) \
|
||||
__extension__({ \
|
||||
__typeof__(info) _curl_info = info; \
|
||||
if(__builtin_constant_p(_curl_info)) { \
|
||||
if(curlcheck_string_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), char *)) \
|
||||
_curl_easy_getinfo_err_string(); \
|
||||
if(curlcheck_long_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), long)) \
|
||||
_curl_easy_getinfo_err_long(); \
|
||||
if(curlcheck_double_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), double)) \
|
||||
_curl_easy_getinfo_err_double(); \
|
||||
if(curlcheck_slist_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_slist *)) \
|
||||
_curl_easy_getinfo_err_curl_slist(); \
|
||||
if(curlcheck_tlssessioninfo_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_tlssessioninfo *)) \
|
||||
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
|
||||
if(curlcheck_certinfo_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), struct curl_certinfo *)) \
|
||||
_curl_easy_getinfo_err_curl_certinfo(); \
|
||||
if(curlcheck_socket_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), curl_socket_t)) \
|
||||
_curl_easy_getinfo_err_curl_socket(); \
|
||||
if(curlcheck_off_t_info(_curl_info)) \
|
||||
if(!curlcheck_arr((arg), curl_off_t)) \
|
||||
_curl_easy_getinfo_err_curl_off_t(); \
|
||||
} \
|
||||
curl_easy_getinfo(handle, _curl_info, arg); \
|
||||
})
|
||||
|
||||
/*
|
||||
* For now, just make sure that the functions are called with three arguments
|
||||
*/
|
||||
#define curl_share_setopt(share,opt,param) curl_share_setopt(share,opt,param)
|
||||
#define curl_multi_setopt(handle,opt,param) curl_multi_setopt(handle,opt,param)
|
||||
|
||||
|
||||
/* the actual warnings, triggered by calling the _curl_easy_setopt_err*
|
||||
* functions */
|
||||
|
||||
/* To define a new warning, use _CURL_WARNING(identifier, "message") */
|
||||
#define CURLWARNING(id, message) \
|
||||
static void __attribute__((__warning__(message))) \
|
||||
__attribute__((__unused__)) __attribute__((__noinline__)) \
|
||||
id(void) { __asm__(""); }
|
||||
|
||||
CURLWARNING(_curl_easy_setopt_err_long,
|
||||
"curl_easy_setopt expects a long argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_off_t,
|
||||
"curl_easy_setopt expects a curl_off_t argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_string,
|
||||
"curl_easy_setopt expects a "
|
||||
"string ('char *' or char[]) argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_write_callback,
|
||||
"curl_easy_setopt expects a curl_write_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_resolver_start_callback,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_resolver_start_callback argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_read_cb,
|
||||
"curl_easy_setopt expects a curl_read_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_ioctl_cb,
|
||||
"curl_easy_setopt expects a curl_ioctl_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_sockopt_cb,
|
||||
"curl_easy_setopt expects a curl_sockopt_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_opensocket_cb,
|
||||
"curl_easy_setopt expects a "
|
||||
"curl_opensocket_callback argument for this option"
|
||||
)
|
||||
CURLWARNING(_curl_easy_setopt_err_progress_cb,
|
||||
"curl_easy_setopt expects a curl_progress_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_debug_cb,
|
||||
"curl_easy_setopt expects a curl_debug_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_ssl_ctx_cb,
|
||||
"curl_easy_setopt expects a curl_ssl_ctx_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_conv_cb,
|
||||
"curl_easy_setopt expects a curl_conv_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_seek_cb,
|
||||
"curl_easy_setopt expects a curl_seek_callback argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_cb_data,
|
||||
"curl_easy_setopt expects a "
|
||||
"private data pointer as argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_error_buffer,
|
||||
"curl_easy_setopt expects a "
|
||||
"char buffer of CURL_ERROR_SIZE as argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_FILE,
|
||||
"curl_easy_setopt expects a 'FILE *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_postfields,
|
||||
"curl_easy_setopt expects a 'void *' or 'char *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_httpost,
|
||||
"curl_easy_setopt expects a 'struct curl_httppost *' "
|
||||
"argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_mimepost,
|
||||
"curl_easy_setopt expects a 'curl_mime *' "
|
||||
"argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_curl_slist,
|
||||
"curl_easy_setopt expects a 'struct curl_slist *' argument for this option")
|
||||
CURLWARNING(_curl_easy_setopt_err_CURLSH,
|
||||
"curl_easy_setopt expects a CURLSH* argument for this option")
|
||||
|
||||
CURLWARNING(_curl_easy_getinfo_err_string,
|
||||
"curl_easy_getinfo expects a pointer to 'char *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_long,
|
||||
"curl_easy_getinfo expects a pointer to long for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_double,
|
||||
"curl_easy_getinfo expects a pointer to double for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_slist,
|
||||
"curl_easy_getinfo expects a pointer to 'struct curl_slist *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_tlssessioninfo *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_certinfo,
|
||||
"curl_easy_getinfo expects a pointer to "
|
||||
"'struct curl_certinfo *' for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_socket,
|
||||
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")
|
||||
CURLWARNING(_curl_easy_getinfo_err_curl_off_t,
|
||||
"curl_easy_getinfo expects a pointer to curl_off_t for this info")
|
||||
|
||||
/* groups of curl_easy_setops options that take the same type of argument */
|
||||
|
||||
/* To add a new option to one of the groups, just add
|
||||
* (option) == CURLOPT_SOMETHING
|
||||
* to the or-expression. If the option takes a long or curl_off_t, you don't
|
||||
* have to do anything
|
||||
*/
|
||||
|
||||
/* evaluates to true if option takes a long argument */
|
||||
#define curlcheck_long_option(option) \
|
||||
(0 < (option) && (option) < CURLOPTTYPE_OBJECTPOINT)
|
||||
|
||||
#define curlcheck_off_t_option(option) \
|
||||
(((option) > CURLOPTTYPE_OFF_T) && ((option) < CURLOPTTYPE_BLOB))
|
||||
|
||||
/* evaluates to true if option takes a char* argument */
|
||||
#define curlcheck_string_option(option) \
|
||||
((option) == CURLOPT_ABSTRACT_UNIX_SOCKET || \
|
||||
(option) == CURLOPT_ACCEPT_ENCODING || \
|
||||
(option) == CURLOPT_ALTSVC || \
|
||||
(option) == CURLOPT_CAINFO || \
|
||||
(option) == CURLOPT_CAPATH || \
|
||||
(option) == CURLOPT_COOKIE || \
|
||||
(option) == CURLOPT_COOKIEFILE || \
|
||||
(option) == CURLOPT_COOKIEJAR || \
|
||||
(option) == CURLOPT_COOKIELIST || \
|
||||
(option) == CURLOPT_CRLFILE || \
|
||||
(option) == CURLOPT_CUSTOMREQUEST || \
|
||||
(option) == CURLOPT_DEFAULT_PROTOCOL || \
|
||||
(option) == CURLOPT_DNS_INTERFACE || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP4 || \
|
||||
(option) == CURLOPT_DNS_LOCAL_IP6 || \
|
||||
(option) == CURLOPT_DNS_SERVERS || \
|
||||
(option) == CURLOPT_DOH_URL || \
|
||||
(option) == CURLOPT_EGDSOCKET || \
|
||||
(option) == CURLOPT_FTPPORT || \
|
||||
(option) == CURLOPT_FTP_ACCOUNT || \
|
||||
(option) == CURLOPT_FTP_ALTERNATIVE_TO_USER || \
|
||||
(option) == CURLOPT_HSTS || \
|
||||
(option) == CURLOPT_INTERFACE || \
|
||||
(option) == CURLOPT_ISSUERCERT || \
|
||||
(option) == CURLOPT_KEYPASSWD || \
|
||||
(option) == CURLOPT_KRBLEVEL || \
|
||||
(option) == CURLOPT_LOGIN_OPTIONS || \
|
||||
(option) == CURLOPT_MAIL_AUTH || \
|
||||
(option) == CURLOPT_MAIL_FROM || \
|
||||
(option) == CURLOPT_NETRC_FILE || \
|
||||
(option) == CURLOPT_NOPROXY || \
|
||||
(option) == CURLOPT_PASSWORD || \
|
||||
(option) == CURLOPT_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PRE_PROXY || \
|
||||
(option) == CURLOPT_PROXY || \
|
||||
(option) == CURLOPT_PROXYPASSWORD || \
|
||||
(option) == CURLOPT_PROXYUSERNAME || \
|
||||
(option) == CURLOPT_PROXYUSERPWD || \
|
||||
(option) == CURLOPT_PROXY_CAINFO || \
|
||||
(option) == CURLOPT_PROXY_CAPATH || \
|
||||
(option) == CURLOPT_PROXY_CRLFILE || \
|
||||
(option) == CURLOPT_PROXY_ISSUERCERT || \
|
||||
(option) == CURLOPT_PROXY_KEYPASSWD || \
|
||||
(option) == CURLOPT_PROXY_PINNEDPUBLICKEY || \
|
||||
(option) == CURLOPT_PROXY_SERVICE_NAME || \
|
||||
(option) == CURLOPT_PROXY_SSLCERT || \
|
||||
(option) == CURLOPT_PROXY_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSLKEY || \
|
||||
(option) == CURLOPT_PROXY_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_PROXY_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_PROXY_TLS13_CIPHERS || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_PROXY_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_RANDOM_FILE || \
|
||||
(option) == CURLOPT_RANGE || \
|
||||
(option) == CURLOPT_REFERER || \
|
||||
(option) == CURLOPT_REQUEST_TARGET || \
|
||||
(option) == CURLOPT_RTSP_SESSION_ID || \
|
||||
(option) == CURLOPT_RTSP_STREAM_URI || \
|
||||
(option) == CURLOPT_RTSP_TRANSPORT || \
|
||||
(option) == CURLOPT_SASL_AUTHZID || \
|
||||
(option) == CURLOPT_SERVICE_NAME || \
|
||||
(option) == CURLOPT_SOCKS5_GSSAPI_SERVICE || \
|
||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_MD5 || \
|
||||
(option) == CURLOPT_SSH_HOST_PUBLIC_KEY_SHA256 || \
|
||||
(option) == CURLOPT_SSH_KNOWNHOSTS || \
|
||||
(option) == CURLOPT_SSH_PRIVATE_KEYFILE || \
|
||||
(option) == CURLOPT_SSH_PUBLIC_KEYFILE || \
|
||||
(option) == CURLOPT_SSLCERT || \
|
||||
(option) == CURLOPT_SSLCERTTYPE || \
|
||||
(option) == CURLOPT_SSLENGINE || \
|
||||
(option) == CURLOPT_SSLKEY || \
|
||||
(option) == CURLOPT_SSLKEYTYPE || \
|
||||
(option) == CURLOPT_SSL_CIPHER_LIST || \
|
||||
(option) == CURLOPT_TLS13_CIPHERS || \
|
||||
(option) == CURLOPT_TLSAUTH_PASSWORD || \
|
||||
(option) == CURLOPT_TLSAUTH_TYPE || \
|
||||
(option) == CURLOPT_TLSAUTH_USERNAME || \
|
||||
(option) == CURLOPT_UNIX_SOCKET_PATH || \
|
||||
(option) == CURLOPT_URL || \
|
||||
(option) == CURLOPT_USERAGENT || \
|
||||
(option) == CURLOPT_USERNAME || \
|
||||
(option) == CURLOPT_AWS_SIGV4 || \
|
||||
(option) == CURLOPT_USERPWD || \
|
||||
(option) == CURLOPT_XOAUTH2_BEARER || \
|
||||
(option) == CURLOPT_SSL_EC_CURVES || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a curl_write_callback argument */
|
||||
#define curlcheck_write_cb_option(option) \
|
||||
((option) == CURLOPT_HEADERFUNCTION || \
|
||||
(option) == CURLOPT_WRITEFUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a curl_conv_callback argument */
|
||||
#define curlcheck_conv_cb_option(option) \
|
||||
((option) == CURLOPT_CONV_TO_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_NETWORK_FUNCTION || \
|
||||
(option) == CURLOPT_CONV_FROM_UTF8_FUNCTION)
|
||||
|
||||
/* evaluates to true if option takes a data argument to pass to a callback */
|
||||
#define curlcheck_cb_data_option(option) \
|
||||
((option) == CURLOPT_CHUNK_DATA || \
|
||||
(option) == CURLOPT_CLOSESOCKETDATA || \
|
||||
(option) == CURLOPT_DEBUGDATA || \
|
||||
(option) == CURLOPT_FNMATCH_DATA || \
|
||||
(option) == CURLOPT_HEADERDATA || \
|
||||
(option) == CURLOPT_HSTSREADDATA || \
|
||||
(option) == CURLOPT_HSTSWRITEDATA || \
|
||||
(option) == CURLOPT_INTERLEAVEDATA || \
|
||||
(option) == CURLOPT_IOCTLDATA || \
|
||||
(option) == CURLOPT_OPENSOCKETDATA || \
|
||||
(option) == CURLOPT_PREREQDATA || \
|
||||
(option) == CURLOPT_PROGRESSDATA || \
|
||||
(option) == CURLOPT_READDATA || \
|
||||
(option) == CURLOPT_SEEKDATA || \
|
||||
(option) == CURLOPT_SOCKOPTDATA || \
|
||||
(option) == CURLOPT_SSH_KEYDATA || \
|
||||
(option) == CURLOPT_SSL_CTX_DATA || \
|
||||
(option) == CURLOPT_WRITEDATA || \
|
||||
(option) == CURLOPT_RESOLVER_START_DATA || \
|
||||
(option) == CURLOPT_TRAILERDATA || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a POST data argument (void* or char*) */
|
||||
#define curlcheck_postfields_option(option) \
|
||||
((option) == CURLOPT_POSTFIELDS || \
|
||||
(option) == CURLOPT_COPYPOSTFIELDS || \
|
||||
0)
|
||||
|
||||
/* evaluates to true if option takes a struct curl_slist * argument */
|
||||
#define curlcheck_slist_option(option) \
|
||||
((option) == CURLOPT_HTTP200ALIASES || \
|
||||
(option) == CURLOPT_HTTPHEADER || \
|
||||
(option) == CURLOPT_MAIL_RCPT || \
|
||||
(option) == CURLOPT_POSTQUOTE || \
|
||||
(option) == CURLOPT_PREQUOTE || \
|
||||
(option) == CURLOPT_PROXYHEADER || \
|
||||
(option) == CURLOPT_QUOTE || \
|
||||
(option) == CURLOPT_RESOLVE || \
|
||||
(option) == CURLOPT_TELNETOPTIONS || \
|
||||
(option) == CURLOPT_CONNECT_TO || \
|
||||
0)
|
||||
|
||||
/* groups of curl_easy_getinfo infos that take the same type of argument */
|
||||
|
||||
/* evaluates to true if info expects a pointer to char * argument */
|
||||
#define curlcheck_string_info(info) \
|
||||
(CURLINFO_STRING < (info) && (info) < CURLINFO_LONG && \
|
||||
(info) != CURLINFO_PRIVATE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to long argument */
|
||||
#define curlcheck_long_info(info) \
|
||||
(CURLINFO_LONG < (info) && (info) < CURLINFO_DOUBLE)
|
||||
|
||||
/* evaluates to true if info expects a pointer to double argument */
|
||||
#define curlcheck_double_info(info) \
|
||||
(CURLINFO_DOUBLE < (info) && (info) < CURLINFO_SLIST)
|
||||
|
||||
/* true if info expects a pointer to struct curl_slist * argument */
|
||||
#define curlcheck_slist_info(info) \
|
||||
(((info) == CURLINFO_SSL_ENGINES) || ((info) == CURLINFO_COOKIELIST))
|
||||
|
||||
/* true if info expects a pointer to struct curl_tlssessioninfo * argument */
|
||||
#define curlcheck_tlssessioninfo_info(info) \
|
||||
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))
|
||||
|
||||
/* true if info expects a pointer to struct curl_certinfo * argument */
|
||||
#define curlcheck_certinfo_info(info) ((info) == CURLINFO_CERTINFO)
|
||||
|
||||
/* true if info expects a pointer to struct curl_socket_t argument */
|
||||
#define curlcheck_socket_info(info) \
|
||||
(CURLINFO_SOCKET < (info) && (info) < CURLINFO_OFF_T)
|
||||
|
||||
/* true if info expects a pointer to curl_off_t argument */
|
||||
#define curlcheck_off_t_info(info) \
|
||||
(CURLINFO_OFF_T < (info))
|
||||
|
||||
|
||||
/* typecheck helpers -- check whether given expression has requested type*/
|
||||
|
||||
/* For pointers, you can use the curlcheck_ptr/curlcheck_arr macros,
|
||||
* otherwise define a new macro. Search for __builtin_types_compatible_p
|
||||
* in the GCC manual.
|
||||
* NOTE: these macros MUST NOT EVALUATE their arguments! The argument is
|
||||
* the actual expression passed to the curl_easy_setopt macro. This
|
||||
* means that you can only apply the sizeof and __typeof__ operators, no
|
||||
* == or whatsoever.
|
||||
*/
|
||||
|
||||
/* XXX: should evaluate to true if expr is a pointer */
|
||||
#define curlcheck_any_ptr(expr) \
|
||||
(sizeof(expr) == sizeof(void *))
|
||||
|
||||
/* evaluates to true if expr is NULL */
|
||||
/* XXX: must not evaluate expr, so this check is not accurate */
|
||||
#define curlcheck_NULL(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), __typeof__(NULL)))
|
||||
|
||||
/* evaluates to true if expr is type*, const type* or NULL */
|
||||
#define curlcheck_ptr(expr, type) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), const type *))
|
||||
|
||||
/* evaluates to true if expr is one of type[], type*, NULL or const type* */
|
||||
#define curlcheck_arr(expr, type) \
|
||||
(curlcheck_ptr((expr), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), type []))
|
||||
|
||||
/* evaluates to true if expr is a string */
|
||||
#define curlcheck_string(expr) \
|
||||
(curlcheck_arr((expr), char) || \
|
||||
curlcheck_arr((expr), signed char) || \
|
||||
curlcheck_arr((expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is a long (no matter the signedness)
|
||||
* XXX: for now, int is also accepted (and therefore short and char, which
|
||||
* are promoted to int when passed to a variadic function) */
|
||||
#define curlcheck_long(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned long) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned int) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned short) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), signed char) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), unsigned char))
|
||||
|
||||
/* evaluates to true if expr is of type curl_off_t */
|
||||
#define curlcheck_off_t(expr) \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), curl_off_t))
|
||||
|
||||
/* evaluates to true if expr is abuffer suitable for CURLOPT_ERRORBUFFER */
|
||||
/* XXX: also check size of an char[] array? */
|
||||
#define curlcheck_error_buffer(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char *) || \
|
||||
__builtin_types_compatible_p(__typeof__(expr), char[]))
|
||||
|
||||
/* evaluates to true if expr is of type (const) void* or (const) FILE* */
|
||||
#if 0
|
||||
#define curlcheck_cb_data(expr) \
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_ptr((expr), FILE))
|
||||
#else /* be less strict */
|
||||
#define curlcheck_cb_data(expr) \
|
||||
curlcheck_any_ptr(expr)
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type FILE* */
|
||||
#define curlcheck_FILE(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
(__builtin_types_compatible_p(__typeof__(expr), FILE *)))
|
||||
|
||||
/* evaluates to true if expr can be passed as POST data (void* or char*) */
|
||||
#define curlcheck_postfields(expr) \
|
||||
(curlcheck_ptr((expr), void) || \
|
||||
curlcheck_arr((expr), char) || \
|
||||
curlcheck_arr((expr), unsigned char))
|
||||
|
||||
/* helper: __builtin_types_compatible_p distinguishes between functions and
|
||||
* function pointers, hide it */
|
||||
#define curlcheck_cb_compatible(func, type) \
|
||||
(__builtin_types_compatible_p(__typeof__(func), type) || \
|
||||
__builtin_types_compatible_p(__typeof__(func) *, type))
|
||||
|
||||
/* evaluates to true if expr is of type curl_resolver_start_callback */
|
||||
#define curlcheck_resolver_start_callback(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_resolver_start_callback))
|
||||
|
||||
/* evaluates to true if expr is of type curl_read_callback or "similar" */
|
||||
#define curlcheck_read_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), __typeof__(fread) *) || \
|
||||
curlcheck_cb_compatible((expr), curl_read_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_read_callback6))
|
||||
typedef size_t (*_curl_read_callback1)(char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback2)(char *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback3)(char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_read_callback4)(void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_read_callback5)(void *, size_t, size_t, const void *);
|
||||
typedef size_t (*_curl_read_callback6)(void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_write_callback or "similar" */
|
||||
#define curlcheck_write_cb(expr) \
|
||||
(curlcheck_read_cb(expr) || \
|
||||
curlcheck_cb_compatible((expr), __typeof__(fwrite) *) || \
|
||||
curlcheck_cb_compatible((expr), curl_write_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_write_callback6))
|
||||
typedef size_t (*_curl_write_callback1)(const char *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback2)(const char *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback3)(const char *, size_t, size_t, FILE *);
|
||||
typedef size_t (*_curl_write_callback4)(const void *, size_t, size_t, void *);
|
||||
typedef size_t (*_curl_write_callback5)(const void *, size_t, size_t,
|
||||
const void *);
|
||||
typedef size_t (*_curl_write_callback6)(const void *, size_t, size_t, FILE *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ioctl_callback or "similar" */
|
||||
#define curlcheck_ioctl_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_ioctl_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ioctl_callback4))
|
||||
typedef curlioerr (*_curl_ioctl_callback1)(CURL *, int, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback2)(CURL *, int, const void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback3)(CURL *, curliocmd, void *);
|
||||
typedef curlioerr (*_curl_ioctl_callback4)(CURL *, curliocmd, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_sockopt_callback or "similar" */
|
||||
#define curlcheck_sockopt_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_sockopt_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_sockopt_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_sockopt_callback2))
|
||||
typedef int (*_curl_sockopt_callback1)(void *, curl_socket_t, curlsocktype);
|
||||
typedef int (*_curl_sockopt_callback2)(const void *, curl_socket_t,
|
||||
curlsocktype);
|
||||
|
||||
/* evaluates to true if expr is of type curl_opensocket_callback or
|
||||
"similar" */
|
||||
#define curlcheck_opensocket_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_opensocket_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_opensocket_callback4))
|
||||
typedef curl_socket_t (*_curl_opensocket_callback1)
|
||||
(void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback2)
|
||||
(void *, curlsocktype, const struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback3)
|
||||
(const void *, curlsocktype, struct curl_sockaddr *);
|
||||
typedef curl_socket_t (*_curl_opensocket_callback4)
|
||||
(const void *, curlsocktype, const struct curl_sockaddr *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_progress_callback or "similar" */
|
||||
#define curlcheck_progress_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_progress_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_progress_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_progress_callback2))
|
||||
typedef int (*_curl_progress_callback1)(void *,
|
||||
double, double, double, double);
|
||||
typedef int (*_curl_progress_callback2)(const void *,
|
||||
double, double, double, double);
|
||||
|
||||
/* evaluates to true if expr is of type curl_debug_callback or "similar" */
|
||||
#define curlcheck_debug_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_debug_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback6) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback7) || \
|
||||
curlcheck_cb_compatible((expr), _curl_debug_callback8))
|
||||
typedef int (*_curl_debug_callback1) (CURL *,
|
||||
curl_infotype, char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback2) (CURL *,
|
||||
curl_infotype, char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback3) (CURL *,
|
||||
curl_infotype, const char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback4) (CURL *,
|
||||
curl_infotype, const char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback5) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback6) (CURL *,
|
||||
curl_infotype, unsigned char *, size_t, const void *);
|
||||
typedef int (*_curl_debug_callback7) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, void *);
|
||||
typedef int (*_curl_debug_callback8) (CURL *,
|
||||
curl_infotype, const unsigned char *, size_t, const void *);
|
||||
|
||||
/* evaluates to true if expr is of type curl_ssl_ctx_callback or "similar" */
|
||||
/* this is getting even messier... */
|
||||
#define curlcheck_ssl_ctx_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_ssl_ctx_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback4) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback5) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback6) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback7) || \
|
||||
curlcheck_cb_compatible((expr), _curl_ssl_ctx_callback8))
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback1)(CURL *, void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback2)(CURL *, void *, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback3)(CURL *, const void *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback4)(CURL *, const void *,
|
||||
const void *);
|
||||
#ifdef HEADER_SSL_H
|
||||
/* hack: if we included OpenSSL's ssl.h, we know about SSL_CTX
|
||||
* this will of course break if we're included before OpenSSL headers...
|
||||
*/
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback5)(CURL *, SSL_CTX *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback6)(CURL *, SSL_CTX *, const void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback7)(CURL *, const SSL_CTX *, void *);
|
||||
typedef CURLcode (*_curl_ssl_ctx_callback8)(CURL *, const SSL_CTX *,
|
||||
const void *);
|
||||
#else
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback5;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback6;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback7;
|
||||
typedef _curl_ssl_ctx_callback1 _curl_ssl_ctx_callback8;
|
||||
#endif
|
||||
|
||||
/* evaluates to true if expr is of type curl_conv_callback or "similar" */
|
||||
#define curlcheck_conv_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_conv_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback2) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback3) || \
|
||||
curlcheck_cb_compatible((expr), _curl_conv_callback4))
|
||||
typedef CURLcode (*_curl_conv_callback1)(char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback2)(const char *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback3)(void *, size_t length);
|
||||
typedef CURLcode (*_curl_conv_callback4)(const void *, size_t length);
|
||||
|
||||
/* evaluates to true if expr is of type curl_seek_callback or "similar" */
|
||||
#define curlcheck_seek_cb(expr) \
|
||||
(curlcheck_NULL(expr) || \
|
||||
curlcheck_cb_compatible((expr), curl_seek_callback) || \
|
||||
curlcheck_cb_compatible((expr), _curl_seek_callback1) || \
|
||||
curlcheck_cb_compatible((expr), _curl_seek_callback2))
|
||||
typedef CURLcode (*_curl_seek_callback1)(void *, curl_off_t, int);
|
||||
typedef CURLcode (*_curl_seek_callback2)(const void *, curl_off_t, int);
|
||||
|
||||
|
||||
#endif /* CURLINC_TYPECHECK_GCC_H */
|
||||
133
demo/kugou/include/Common/include/curl/urlapi.h
Normal file
133
demo/kugou/include/Common/include/curl/urlapi.h
Normal file
@@ -0,0 +1,133 @@
|
||||
#ifndef CURLINC_URLAPI_H
|
||||
#define CURLINC_URLAPI_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2018 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* the error codes for the URL API */
|
||||
typedef enum {
|
||||
CURLUE_OK,
|
||||
CURLUE_BAD_HANDLE, /* 1 */
|
||||
CURLUE_BAD_PARTPOINTER, /* 2 */
|
||||
CURLUE_MALFORMED_INPUT, /* 3 */
|
||||
CURLUE_BAD_PORT_NUMBER, /* 4 */
|
||||
CURLUE_UNSUPPORTED_SCHEME, /* 5 */
|
||||
CURLUE_URLDECODE, /* 6 */
|
||||
CURLUE_OUT_OF_MEMORY, /* 7 */
|
||||
CURLUE_USER_NOT_ALLOWED, /* 8 */
|
||||
CURLUE_UNKNOWN_PART, /* 9 */
|
||||
CURLUE_NO_SCHEME, /* 10 */
|
||||
CURLUE_NO_USER, /* 11 */
|
||||
CURLUE_NO_PASSWORD, /* 12 */
|
||||
CURLUE_NO_OPTIONS, /* 13 */
|
||||
CURLUE_NO_HOST, /* 14 */
|
||||
CURLUE_NO_PORT, /* 15 */
|
||||
CURLUE_NO_QUERY, /* 16 */
|
||||
CURLUE_NO_FRAGMENT, /* 17 */
|
||||
CURLUE_LAST
|
||||
} CURLUcode;
|
||||
|
||||
typedef enum {
|
||||
CURLUPART_URL,
|
||||
CURLUPART_SCHEME,
|
||||
CURLUPART_USER,
|
||||
CURLUPART_PASSWORD,
|
||||
CURLUPART_OPTIONS,
|
||||
CURLUPART_HOST,
|
||||
CURLUPART_PORT,
|
||||
CURLUPART_PATH,
|
||||
CURLUPART_QUERY,
|
||||
CURLUPART_FRAGMENT,
|
||||
CURLUPART_ZONEID /* added in 7.65.0 */
|
||||
} CURLUPart;
|
||||
|
||||
#define CURLU_DEFAULT_PORT (1<<0) /* return default port number */
|
||||
#define CURLU_NO_DEFAULT_PORT (1<<1) /* act as if no port number was set,
|
||||
if the port number matches the
|
||||
default for the scheme */
|
||||
#define CURLU_DEFAULT_SCHEME (1<<2) /* return default scheme if
|
||||
missing */
|
||||
#define CURLU_NON_SUPPORT_SCHEME (1<<3) /* allow non-supported scheme */
|
||||
#define CURLU_PATH_AS_IS (1<<4) /* leave dot sequences */
|
||||
#define CURLU_DISALLOW_USER (1<<5) /* no user+password allowed */
|
||||
#define CURLU_URLDECODE (1<<6) /* URL decode on get */
|
||||
#define CURLU_URLENCODE (1<<7) /* URL encode on set */
|
||||
#define CURLU_APPENDQUERY (1<<8) /* append a form style part */
|
||||
#define CURLU_GUESS_SCHEME (1<<9) /* legacy curl-style guessing */
|
||||
#define CURLU_NO_AUTHORITY (1<<10) /* Allow empty authority when the
|
||||
scheme is unknown. */
|
||||
#define CURLU_ALLOW_SPACE (1<<11) /* Allow spaces in the URL */
|
||||
|
||||
typedef struct Curl_URL CURLU;
|
||||
|
||||
/*
|
||||
* curl_url() creates a new CURLU handle and returns a pointer to it.
|
||||
* Must be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url(void);
|
||||
|
||||
/*
|
||||
* curl_url_cleanup() frees the CURLU handle and related resources used for
|
||||
* the URL parsing. It will not free strings previously returned with the URL
|
||||
* API.
|
||||
*/
|
||||
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
|
||||
|
||||
/*
|
||||
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
|
||||
* handle must also be freed with curl_url_cleanup().
|
||||
*/
|
||||
CURL_EXTERN CURLU *curl_url_dup(CURLU *in);
|
||||
|
||||
/*
|
||||
* curl_url_get() extracts a specific part of the URL from a CURLU
|
||||
* handle. Returns error code. The returned pointer MUST be freed with
|
||||
* curl_free() afterwards.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_get(CURLU *handle, CURLUPart what,
|
||||
char **part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
|
||||
* error code. The passed in string will be copied. Passing a NULL instead of
|
||||
* a part string, clears that part.
|
||||
*/
|
||||
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
|
||||
const char *part, unsigned int flags);
|
||||
|
||||
/*
|
||||
* curl_url_strerror() turns a CURLUcode value into the equivalent human
|
||||
* readable error string. This is useful for printing meaningful error
|
||||
* messages.
|
||||
*/
|
||||
CURL_EXTERN const char *curl_url_strerror(CURLUcode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* CURLINC_URLAPI_H */
|
||||
113
demo/kugou/include/Common/include/gzip/compress.hpp
Normal file
113
demo/kugou/include/Common/include/gzip/compress.hpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <gzip/config.hpp>
|
||||
|
||||
// zlib
|
||||
#include "zlib.h"
|
||||
|
||||
// std
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace gzip {
|
||||
|
||||
class Compressor
|
||||
{
|
||||
std::size_t max_;
|
||||
int level_;
|
||||
|
||||
public:
|
||||
Compressor(int level = Z_DEFAULT_COMPRESSION,
|
||||
std::size_t max_bytes = 2000000000) // by default refuse operation if uncompressed data is > 2GB
|
||||
: max_(max_bytes),
|
||||
level_(level)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename InputType>
|
||||
void compress(InputType& output,
|
||||
const char* data,
|
||||
std::size_t size) const
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
// Verify if size input will fit into unsigned int, type used for zlib's avail_in
|
||||
if (size > std::numeric_limits<unsigned int>::max())
|
||||
{
|
||||
throw std::runtime_error("size arg is too large to fit into unsigned int type");
|
||||
}
|
||||
#endif
|
||||
if (size > max_)
|
||||
{
|
||||
throw std::runtime_error("size may use more memory than intended when decompressing");
|
||||
}
|
||||
|
||||
z_stream deflate_s;
|
||||
deflate_s.zalloc = Z_NULL;
|
||||
deflate_s.zfree = Z_NULL;
|
||||
deflate_s.opaque = Z_NULL;
|
||||
deflate_s.avail_in = 0;
|
||||
deflate_s.next_in = Z_NULL;
|
||||
|
||||
// The windowBits parameter is the base two logarithm of the window size (the size of the history buffer).
|
||||
// It should be in the range 8..15 for this version of the library.
|
||||
// Larger values of this parameter result in better compression at the expense of memory usage.
|
||||
// This range of values also changes the decoding type:
|
||||
// -8 to -15 for raw deflate
|
||||
// 8 to 15 for zlib
|
||||
// (8 to 15) + 16 for gzip
|
||||
// (8 to 15) + 32 to automatically detect gzip/zlib header (decompression/inflate only)
|
||||
constexpr int window_bits = 15 + 16; // gzip with windowbits of 15
|
||||
|
||||
constexpr int mem_level = 8;
|
||||
// The memory requirements for deflate are (in bytes):
|
||||
// (1 << (window_bits+2)) + (1 << (mem_level+9))
|
||||
// with a default value of 8 for mem_level and our window_bits of 15
|
||||
// this is 128Kb
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
if (deflateInit2(&deflate_s, level_, Z_DEFLATED, window_bits, mem_level, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||
{
|
||||
throw std::runtime_error("deflate init failed");
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
deflate_s.next_in = reinterpret_cast<z_const Bytef*>(data);
|
||||
deflate_s.avail_in = static_cast<unsigned int>(size);
|
||||
|
||||
std::size_t size_compressed = 0;
|
||||
do
|
||||
{
|
||||
size_t increase = size / 2 + 1024;
|
||||
if (output.size() < (size_compressed + increase))
|
||||
{
|
||||
output.resize(size_compressed + increase);
|
||||
}
|
||||
// There is no way we see that "increase" would not fit in an unsigned int,
|
||||
// hence we use static cast here to avoid -Wshorten-64-to-32 error
|
||||
deflate_s.avail_out = static_cast<unsigned int>(increase);
|
||||
deflate_s.next_out = reinterpret_cast<Bytef*>((&output[0] + size_compressed));
|
||||
// From http://www.zlib.net/zlib_how.html
|
||||
// "deflate() has a return value that can indicate errors, yet we do not check it here.
|
||||
// Why not? Well, it turns out that deflate() can do no wrong here."
|
||||
// Basically only possible error is from deflateInit not working properly
|
||||
deflate(&deflate_s, Z_FINISH);
|
||||
size_compressed += (increase - deflate_s.avail_out);
|
||||
} while (deflate_s.avail_out == 0);
|
||||
|
||||
deflateEnd(&deflate_s);
|
||||
output.resize(size_compressed);
|
||||
}
|
||||
};
|
||||
|
||||
inline std::string compress(const char* data,
|
||||
std::size_t size,
|
||||
int level = Z_DEFAULT_COMPRESSION)
|
||||
{
|
||||
Compressor comp(level);
|
||||
std::string output;
|
||||
comp.compress(output, data, size);
|
||||
return output;
|
||||
}
|
||||
|
||||
} // namespace gzip
|
||||
5
demo/kugou/include/Common/include/gzip/config.hpp
Normal file
5
demo/kugou/include/Common/include/gzip/config.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef ZLIB_CONST
|
||||
#define ZLIB_CONST
|
||||
#endif
|
||||
105
demo/kugou/include/Common/include/gzip/decompress.hpp
Normal file
105
demo/kugou/include/Common/include/gzip/decompress.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include <gzip/config.hpp>
|
||||
|
||||
// zlib
|
||||
#include "zlib.h"
|
||||
|
||||
// std
|
||||
#include <limits>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace gzip {
|
||||
|
||||
class Decompressor
|
||||
{
|
||||
std::size_t max_;
|
||||
|
||||
public:
|
||||
Decompressor(std::size_t max_bytes = 1000000000) // by default refuse operation if compressed data is > 1GB
|
||||
: max_(max_bytes)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename OutputType>
|
||||
void decompress(OutputType& output,
|
||||
const char* data,
|
||||
std::size_t size) const
|
||||
{
|
||||
z_stream inflate_s;
|
||||
|
||||
inflate_s.zalloc = Z_NULL;
|
||||
inflate_s.zfree = Z_NULL;
|
||||
inflate_s.opaque = Z_NULL;
|
||||
inflate_s.avail_in = 0;
|
||||
inflate_s.next_in = Z_NULL;
|
||||
|
||||
// The windowBits parameter is the base two logarithm of the window size (the size of the history buffer).
|
||||
// It should be in the range 8..15 for this version of the library.
|
||||
// Larger values of this parameter result in better compression at the expense of memory usage.
|
||||
// This range of values also changes the decoding type:
|
||||
// -8 to -15 for raw deflate
|
||||
// 8 to 15 for zlib
|
||||
// (8 to 15) + 16 for gzip
|
||||
// (8 to 15) + 32 to automatically detect gzip/zlib header
|
||||
constexpr int window_bits = 15 + 32; // auto with windowbits of 15
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
if (inflateInit2(&inflate_s, window_bits) != Z_OK)
|
||||
{
|
||||
throw std::runtime_error("inflate init failed");
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
inflate_s.next_in = reinterpret_cast<z_const Bytef*>(data);
|
||||
|
||||
#ifdef DEBUG
|
||||
// Verify if size (long type) input will fit into unsigned int, type used for zlib's avail_in
|
||||
std::uint64_t size_64 = size * 2;
|
||||
if (size_64 > std::numeric_limits<unsigned int>::max())
|
||||
{
|
||||
inflateEnd(&inflate_s);
|
||||
throw std::runtime_error("size arg is too large to fit into unsigned int type x2");
|
||||
}
|
||||
#endif
|
||||
if (size > max_ || (size * 2) > max_)
|
||||
{
|
||||
inflateEnd(&inflate_s);
|
||||
throw std::runtime_error("size may use more memory than intended when decompressing");
|
||||
}
|
||||
inflate_s.avail_in = static_cast<unsigned int>(size);
|
||||
std::size_t size_uncompressed = 0;
|
||||
do
|
||||
{
|
||||
std::size_t resize_to = size_uncompressed + 2 * size;
|
||||
if (resize_to > max_)
|
||||
{
|
||||
inflateEnd(&inflate_s);
|
||||
throw std::runtime_error("size of output string will use more memory then intended when decompressing");
|
||||
}
|
||||
output.resize(resize_to);
|
||||
inflate_s.avail_out = static_cast<unsigned int>(2 * size);
|
||||
inflate_s.next_out = reinterpret_cast<Bytef*>(&output[0] + size_uncompressed);
|
||||
int ret = inflate(&inflate_s, Z_FINISH);
|
||||
if (ret != Z_STREAM_END && ret != Z_OK && ret != Z_BUF_ERROR)
|
||||
{
|
||||
std::string error_msg = inflate_s.msg;
|
||||
inflateEnd(&inflate_s);
|
||||
throw std::runtime_error(error_msg);
|
||||
}
|
||||
|
||||
size_uncompressed += (2 * size - inflate_s.avail_out);
|
||||
} while (inflate_s.avail_out == 0);
|
||||
inflateEnd(&inflate_s);
|
||||
output.resize(size_uncompressed);
|
||||
}
|
||||
};
|
||||
|
||||
inline std::string decompress(const char* data, std::size_t size)
|
||||
{
|
||||
Decompressor decomp;
|
||||
std::string output;
|
||||
decomp.decompress(output, data, size);
|
||||
return output;
|
||||
}
|
||||
|
||||
} // namespace gzip
|
||||
22
demo/kugou/include/Common/include/gzip/utils.hpp
Normal file
22
demo/kugou/include/Common/include/gzip/utils.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <cstdlib>
|
||||
|
||||
namespace gzip {
|
||||
|
||||
// These live in gzip.hpp because it doesnt need to use deps.
|
||||
// Otherwise, they would need to live in impl files if these methods used
|
||||
// zlib structures or functions like inflate/deflate)
|
||||
inline bool is_compressed(const char* data, std::size_t size)
|
||||
{
|
||||
return size > 2 &&
|
||||
(
|
||||
// zlib
|
||||
(
|
||||
static_cast<uint8_t>(data[0]) == 0x78 &&
|
||||
(static_cast<uint8_t>(data[1]) == 0x9C ||
|
||||
static_cast<uint8_t>(data[1]) == 0x01 ||
|
||||
static_cast<uint8_t>(data[1]) == 0xDA ||
|
||||
static_cast<uint8_t>(data[1]) == 0x5E)) ||
|
||||
// gzip
|
||||
(static_cast<uint8_t>(data[0]) == 0x1F && static_cast<uint8_t>(data[1]) == 0x8B));
|
||||
}
|
||||
} // namespace gzip
|
||||
16
demo/kugou/include/Common/include/gzip/version.hpp
Normal file
16
demo/kugou/include/Common/include/gzip/version.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
/// The major version number
|
||||
#define GZIP_VERSION_MAJOR 1
|
||||
|
||||
/// The minor version number
|
||||
#define GZIP_VERSION_MINOR 0
|
||||
|
||||
/// The patch number
|
||||
#define GZIP_VERSION_PATCH 0
|
||||
|
||||
/// The complete version number
|
||||
#define GZIP_VERSION_CODE (GZIP_VERSION_MAJOR * 10000 + GZIP_VERSION_MINOR * 100 + GZIP_VERSION_PATCH)
|
||||
|
||||
/// Version number as string
|
||||
#define GZIP_VERSION_STRING "1.0.0"
|
||||
10523
demo/kugou/include/Common/include/httplib.h
Normal file
10523
demo/kugou/include/Common/include/httplib.h
Normal file
File diff suppressed because it is too large
Load Diff
89
demo/kugou/include/Common/include/json/allocator.h
Normal file
89
demo/kugou/include/Common/include/json/allocator.h
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_ALLOCATOR_H_INCLUDED
|
||||
#define JSON_ALLOCATOR_H_INCLUDED
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
namespace Json {
|
||||
template <typename T> class SecureAllocator {
|
||||
public:
|
||||
// Type definitions
|
||||
using value_type = T;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* Allocate memory for N items using the standard allocator.
|
||||
*/
|
||||
pointer allocate(size_type n) {
|
||||
// allocate using "global operator new"
|
||||
return static_cast<pointer>(::operator new(n * sizeof(T)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Release memory which was allocated for N items at pointer P.
|
||||
*
|
||||
* The memory block is filled with zeroes before being released.
|
||||
*/
|
||||
void deallocate(pointer p, size_type n) {
|
||||
// memset_s is used because memset may be optimized away by the compiler
|
||||
memset_s(p, n * sizeof(T), 0, n * sizeof(T));
|
||||
// free using "global operator delete"
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an item in-place at pointer P.
|
||||
*/
|
||||
template <typename... Args> void construct(pointer p, Args&&... args) {
|
||||
// construct using "placement new" and "perfect forwarding"
|
||||
::new (static_cast<void*>(p)) T(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
size_type max_size() const { return size_t(-1) / sizeof(T); }
|
||||
|
||||
pointer address(reference x) const { return std::addressof(x); }
|
||||
|
||||
const_pointer address(const_reference x) const { return std::addressof(x); }
|
||||
|
||||
/**
|
||||
* Destroy an item in-place at pointer P.
|
||||
*/
|
||||
void destroy(pointer p) {
|
||||
// destroy using "explicit destructor"
|
||||
p->~T();
|
||||
}
|
||||
|
||||
// Boilerplate
|
||||
SecureAllocator() {}
|
||||
template <typename U> SecureAllocator(const SecureAllocator<U>&) {}
|
||||
template <typename U> struct rebind { using other = SecureAllocator<U>; };
|
||||
};
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator==(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
bool operator!=(const SecureAllocator<T>&, const SecureAllocator<U>&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // JSON_ALLOCATOR_H_INCLUDED
|
||||
61
demo/kugou/include/Common/include/json/assertions.h
Normal file
61
demo/kugou/include/Common/include/json/assertions.h
Normal file
@@ -0,0 +1,61 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_ASSERTIONS_H_INCLUDED
|
||||
#define JSON_ASSERTIONS_H_INCLUDED
|
||||
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
/** It should not be possible for a maliciously designed file to
|
||||
* cause an abort() or seg-fault, so these macros are used only
|
||||
* for pre-condition violations and internal logic errors.
|
||||
*/
|
||||
#if JSON_USE_EXCEPTION
|
||||
|
||||
// @todo <= add detail about condition in exception
|
||||
#define JSON_ASSERT(condition) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
Json::throwLogicError("assert json failed"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JSON_FAIL_MESSAGE(message) \
|
||||
do { \
|
||||
OStringStream oss; \
|
||||
oss << message; \
|
||||
Json::throwLogicError(oss.str()); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#else // JSON_USE_EXCEPTION
|
||||
|
||||
#define JSON_ASSERT(condition) assert(condition)
|
||||
|
||||
// The call to assert() will show the failure message in debug builds. In
|
||||
// release builds we abort, for a core-dump or debugger.
|
||||
#define JSON_FAIL_MESSAGE(message) \
|
||||
{ \
|
||||
OStringStream oss; \
|
||||
oss << message; \
|
||||
assert(false && oss.str().c_str()); \
|
||||
abort(); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define JSON_ASSERT_MESSAGE(condition, message) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
JSON_FAIL_MESSAGE(message); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif // JSON_ASSERTIONS_H_INCLUDED
|
||||
150
demo/kugou/include/Common/include/json/config.h
Normal file
150
demo/kugou/include/Common/include/json/config.h
Normal file
@@ -0,0 +1,150 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_CONFIG_H_INCLUDED
|
||||
#define JSON_CONFIG_H_INCLUDED
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
// If non-zero, the library uses exceptions to report bad input instead of C
|
||||
// assertion macros. The default is to use exceptions.
|
||||
#ifndef JSON_USE_EXCEPTION
|
||||
#define JSON_USE_EXCEPTION 1
|
||||
#endif
|
||||
|
||||
// Temporary, tracked for removal with issue #982.
|
||||
#ifndef JSON_USE_NULLREF
|
||||
#define JSON_USE_NULLREF 1
|
||||
#endif
|
||||
|
||||
/// If defined, indicates that the source file is amalgamated
|
||||
/// to prevent private header inclusion.
|
||||
/// Remarks: it is automatically defined in the generated amalgamated header.
|
||||
// #define JSON_IS_AMALGAMATION
|
||||
|
||||
// Export macros for DLL visibility
|
||||
#if defined(JSON_DLL_BUILD)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllexport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
#define JSON_API __attribute__((visibility("default")))
|
||||
#endif // if defined(_MSC_VER)
|
||||
|
||||
#elif defined(JSON_DLL)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
#define JSON_API __declspec(dllimport)
|
||||
#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
|
||||
#endif // if defined(_MSC_VER)
|
||||
#endif // ifdef JSON_DLL_BUILD
|
||||
|
||||
#if !defined(JSON_API)
|
||||
#define JSON_API
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
||||
#error \
|
||||
"ERROR: Visual Studio 12 (2013) with _MSC_VER=1800 is the oldest supported compiler with sufficient C++11 capabilities"
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// As recommended at
|
||||
// https://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
|
||||
extern JSON_API int msvc_pre1900_c99_snprintf(char* outBuf, size_t size,
|
||||
const char* format, ...);
|
||||
#define jsoncpp_snprintf msvc_pre1900_c99_snprintf
|
||||
#else
|
||||
#define jsoncpp_snprintf std::snprintf
|
||||
#endif
|
||||
|
||||
// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
|
||||
// integer
|
||||
// Storages, and 64 bits integer support is disabled.
|
||||
// #define JSON_NO_INT64 1
|
||||
|
||||
// JSONCPP_OVERRIDE is maintained for backwards compatibility of external tools.
|
||||
// C++11 should be used directly in JSONCPP.
|
||||
#define JSONCPP_OVERRIDE override
|
||||
|
||||
#ifdef __clang__
|
||||
#if __has_extension(attribute_deprecated_with_message)
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#endif
|
||||
#elif defined(__GNUC__) // not clang (gcc comes later since clang emulates gcc)
|
||||
#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
#elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#define JSONCPP_DEPRECATED(message) __attribute__((__deprecated__))
|
||||
#endif // GNUC version
|
||||
#elif defined(_MSC_VER) // MSVC (after clang because clang on Windows emulates
|
||||
// MSVC)
|
||||
#define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
|
||||
#endif // __clang__ || __GNUC__ || _MSC_VER
|
||||
|
||||
#if !defined(JSONCPP_DEPRECATED)
|
||||
#define JSONCPP_DEPRECATED(message)
|
||||
#endif // if !defined(JSONCPP_DEPRECATED)
|
||||
|
||||
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 6))
|
||||
#define JSON_USE_INT64_DOUBLE_CONVERSION 1
|
||||
#endif
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
#include "allocator.h"
|
||||
#include "version.h"
|
||||
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
using Int = int;
|
||||
using UInt = unsigned int;
|
||||
#if defined(JSON_NO_INT64)
|
||||
using LargestInt = int;
|
||||
using LargestUInt = unsigned int;
|
||||
#undef JSON_HAS_INT64
|
||||
#else // if defined(JSON_NO_INT64)
|
||||
// For Microsoft Visual use specific types as long long is not supported
|
||||
#if defined(_MSC_VER) // Microsoft Visual Studio
|
||||
using Int64 = __int64;
|
||||
using UInt64 = unsigned __int64;
|
||||
#else // if defined(_MSC_VER) // Other platforms, use long long
|
||||
using Int64 = int64_t;
|
||||
using UInt64 = uint64_t;
|
||||
#endif // if defined(_MSC_VER)
|
||||
using LargestInt = Int64;
|
||||
using LargestUInt = UInt64;
|
||||
#define JSON_HAS_INT64
|
||||
#endif // if defined(JSON_NO_INT64)
|
||||
|
||||
template <typename T>
|
||||
using Allocator =
|
||||
typename std::conditional<JSONCPP_USING_SECURE_MEMORY, SecureAllocator<T>,
|
||||
std::allocator<T>>::type;
|
||||
using String = std::basic_string<char, std::char_traits<char>, Allocator<char>>;
|
||||
using IStringStream =
|
||||
std::basic_istringstream<String::value_type, String::traits_type,
|
||||
String::allocator_type>;
|
||||
using OStringStream =
|
||||
std::basic_ostringstream<String::value_type, String::traits_type,
|
||||
String::allocator_type>;
|
||||
using IStream = std::istream;
|
||||
using OStream = std::ostream;
|
||||
} // namespace Json
|
||||
|
||||
// Legacy names (formerly macros).
|
||||
using JSONCPP_STRING = Json::String;
|
||||
using JSONCPP_ISTRINGSTREAM = Json::IStringStream;
|
||||
using JSONCPP_OSTRINGSTREAM = Json::OStringStream;
|
||||
using JSONCPP_ISTREAM = Json::IStream;
|
||||
using JSONCPP_OSTREAM = Json::OStream;
|
||||
|
||||
#endif // JSON_CONFIG_H_INCLUDED
|
||||
43
demo/kugou/include/Common/include/json/forwards.h
Normal file
43
demo/kugou/include/Common/include/json/forwards.h
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_FORWARDS_H_INCLUDED
|
||||
#define JSON_FORWARDS_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "config.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
namespace Json {
|
||||
|
||||
// writer.h
|
||||
class StreamWriter;
|
||||
class StreamWriterBuilder;
|
||||
class Writer;
|
||||
class FastWriter;
|
||||
class StyledWriter;
|
||||
class StyledStreamWriter;
|
||||
|
||||
// reader.h
|
||||
class Reader;
|
||||
class CharReader;
|
||||
class CharReaderBuilder;
|
||||
|
||||
// json_features.h
|
||||
class Features;
|
||||
|
||||
// value.h
|
||||
using ArrayIndex = unsigned int;
|
||||
class StaticString;
|
||||
class Path;
|
||||
class PathArgument;
|
||||
class Value;
|
||||
class ValueIteratorBase;
|
||||
class ValueIterator;
|
||||
class ValueConstIterator;
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#endif // JSON_FORWARDS_H_INCLUDED
|
||||
15
demo/kugou/include/Common/include/json/json.h
Normal file
15
demo/kugou/include/Common/include/json/json.h
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_JSON_H_INCLUDED
|
||||
#define JSON_JSON_H_INCLUDED
|
||||
|
||||
#include "config.h"
|
||||
#include "json_features.h"
|
||||
#include "reader.h"
|
||||
#include "value.h"
|
||||
#include "writer.h"
|
||||
|
||||
#endif // JSON_JSON_H_INCLUDED
|
||||
62
demo/kugou/include/Common/include/json/json_features.h
Normal file
62
demo/kugou/include/Common/include/json/json_features.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_FEATURES_H_INCLUDED
|
||||
#define JSON_FEATURES_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Configuration passed to reader and writer.
|
||||
* This configuration object can be used to force the Reader or Writer
|
||||
* to behave in a standard conforming way.
|
||||
*/
|
||||
class JSON_API Features {
|
||||
public:
|
||||
/** \brief A configuration that allows all features and assumes all strings
|
||||
* are UTF-8.
|
||||
* - C & C++ comments are allowed
|
||||
* - Root object can be any JSON value
|
||||
* - Assumes Value strings are encoded in UTF-8
|
||||
*/
|
||||
static Features all();
|
||||
|
||||
/** \brief A configuration that is strictly compatible with the JSON
|
||||
* specification.
|
||||
* - Comments are forbidden.
|
||||
* - Root object must be either an array or an object value.
|
||||
* - Assumes Value strings are encoded in UTF-8
|
||||
*/
|
||||
static Features strictMode();
|
||||
|
||||
/** \brief Initialize the configuration like JsonConfig::allFeatures;
|
||||
*/
|
||||
Features();
|
||||
|
||||
/// \c true if comments are allowed. Default: \c true.
|
||||
bool allowComments_{true};
|
||||
|
||||
/// \c true if root must be either an array or an object value. Default: \c
|
||||
/// false.
|
||||
bool strictRoot_{false};
|
||||
|
||||
/// \c true if dropped null placeholders are allowed. Default: \c false.
|
||||
bool allowDroppedNullPlaceholders_{false};
|
||||
|
||||
/// \c true if numeric object key are allowed. Default: \c false.
|
||||
bool allowNumericKeys_{false};
|
||||
};
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // JSON_FEATURES_H_INCLUDED
|
||||
406
demo/kugou/include/Common/include/json/reader.h
Normal file
406
demo/kugou/include/Common/include/json/reader.h
Normal file
@@ -0,0 +1,406 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_READER_H_INCLUDED
|
||||
#define JSON_READER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "json_features.h"
|
||||
#include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <deque>
|
||||
#include <iosfwd>
|
||||
#include <istream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
namespace Json {
|
||||
|
||||
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
|
||||
* Value.
|
||||
*
|
||||
* \deprecated Use CharReader and CharReaderBuilder.
|
||||
*/
|
||||
|
||||
class JSON_API Reader {
|
||||
public:
|
||||
using Char = char;
|
||||
using Location = const Char*;
|
||||
|
||||
/** \brief An error tagged with where in the JSON text it was encountered.
|
||||
*
|
||||
* The offsets give the [start, limit) range of bytes within the text. Note
|
||||
* that this is bytes, not codepoints.
|
||||
*/
|
||||
struct StructuredError {
|
||||
ptrdiff_t offset_start;
|
||||
ptrdiff_t offset_limit;
|
||||
String message;
|
||||
};
|
||||
|
||||
/** \brief Constructs a Reader allowing all features for parsing.
|
||||
* \deprecated Use CharReader and CharReaderBuilder.
|
||||
*/
|
||||
Reader();
|
||||
|
||||
/** \brief Constructs a Reader allowing the specified feature set for parsing.
|
||||
* \deprecated Use CharReader and CharReaderBuilder.
|
||||
*/
|
||||
Reader(const Features& features);
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||
* document.
|
||||
*
|
||||
* \param document UTF-8 encoded string containing the document
|
||||
* to read.
|
||||
* \param[out] root Contains the root value of the document if it
|
||||
* was successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing
|
||||
* them back during serialization, \c false to
|
||||
* discard comments. This parameter is ignored
|
||||
* if Features::allowComments_ is \c false.
|
||||
* \return \c true if the document was successfully parsed, \c false if an
|
||||
* error occurred.
|
||||
*/
|
||||
bool parse(const std::string& document, Value& root,
|
||||
bool collectComments = true);
|
||||
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||
* document.
|
||||
*
|
||||
* \param beginDoc Pointer on the beginning of the UTF-8 encoded
|
||||
* string of the document to read.
|
||||
* \param endDoc Pointer on the end of the UTF-8 encoded string
|
||||
* of the document to read. Must be >= beginDoc.
|
||||
* \param[out] root Contains the root value of the document if it
|
||||
* was successfully parsed.
|
||||
* \param collectComments \c true to collect comment and allow writing
|
||||
* them back during serialization, \c false to
|
||||
* discard comments. This parameter is ignored
|
||||
* if Features::allowComments_ is \c false.
|
||||
* \return \c true if the document was successfully parsed, \c false if an
|
||||
* error occurred.
|
||||
*/
|
||||
bool parse(const char* beginDoc, const char* endDoc, Value& root,
|
||||
bool collectComments = true);
|
||||
|
||||
/// \brief Parse from input stream.
|
||||
/// \see Json::operator>>(std::istream&, Json::Value&).
|
||||
bool parse(IStream& is, Value& root, bool collectComments = true);
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
*
|
||||
* \return Formatted error message with the list of errors with their
|
||||
* location in the parsed document. An empty string is returned if no error
|
||||
* occurred during parsing.
|
||||
* \deprecated Use getFormattedErrorMessages() instead (typo fix).
|
||||
*/
|
||||
JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
|
||||
String getFormatedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a user friendly string that list errors in the parsed
|
||||
* document.
|
||||
*
|
||||
* \return Formatted error message with the list of errors with their
|
||||
* location in the parsed document. An empty string is returned if no error
|
||||
* occurred during parsing.
|
||||
*/
|
||||
String getFormattedErrorMessages() const;
|
||||
|
||||
/** \brief Returns a vector of structured errors encountered while parsing.
|
||||
*
|
||||
* \return A (possibly empty) vector of StructuredError objects. Currently
|
||||
* only one error can be returned, but the caller should tolerate multiple
|
||||
* errors. This can occur if the parser recovers from a non-fatal parse
|
||||
* error and then encounters additional errors.
|
||||
*/
|
||||
std::vector<StructuredError> getStructuredErrors() const;
|
||||
|
||||
/** \brief Add a semantic error message.
|
||||
*
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \return \c true if the error was successfully added, \c false if the Value
|
||||
* offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const String& message);
|
||||
|
||||
/** \brief Add a semantic error message with extra context.
|
||||
*
|
||||
* \param value JSON Value location associated with the error
|
||||
* \param message The error message.
|
||||
* \param extra Additional JSON Value location to contextualize the error
|
||||
* \return \c true if the error was successfully added, \c false if either
|
||||
* Value offset exceeds the document size.
|
||||
*/
|
||||
bool pushError(const Value& value, const String& message, const Value& extra);
|
||||
|
||||
/** \brief Return whether there are any errors.
|
||||
*
|
||||
* \return \c true if there are no errors to report \c false if errors have
|
||||
* occurred.
|
||||
*/
|
||||
bool good() const;
|
||||
|
||||
private:
|
||||
enum TokenType {
|
||||
tokenEndOfStream = 0,
|
||||
tokenObjectBegin,
|
||||
tokenObjectEnd,
|
||||
tokenArrayBegin,
|
||||
tokenArrayEnd,
|
||||
tokenString,
|
||||
tokenNumber,
|
||||
tokenTrue,
|
||||
tokenFalse,
|
||||
tokenNull,
|
||||
tokenArraySeparator,
|
||||
tokenMemberSeparator,
|
||||
tokenComment,
|
||||
tokenError
|
||||
};
|
||||
|
||||
class Token {
|
||||
public:
|
||||
TokenType type_;
|
||||
Location start_;
|
||||
Location end_;
|
||||
};
|
||||
|
||||
class ErrorInfo {
|
||||
public:
|
||||
Token token_;
|
||||
String message_;
|
||||
Location extra_;
|
||||
};
|
||||
|
||||
using Errors = std::deque<ErrorInfo>;
|
||||
|
||||
bool readToken(Token& token);
|
||||
void skipSpaces();
|
||||
bool match(const Char* pattern, int patternLength);
|
||||
bool readComment();
|
||||
bool readCStyleComment();
|
||||
bool readCppStyleComment();
|
||||
bool readString();
|
||||
void readNumber();
|
||||
bool readValue();
|
||||
bool readObject(Token& token);
|
||||
bool readArray(Token& token);
|
||||
bool decodeNumber(Token& token);
|
||||
bool decodeNumber(Token& token, Value& decoded);
|
||||
bool decodeString(Token& token);
|
||||
bool decodeString(Token& token, String& decoded);
|
||||
bool decodeDouble(Token& token);
|
||||
bool decodeDouble(Token& token, Value& decoded);
|
||||
bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
|
||||
unsigned int& unicode);
|
||||
bool decodeUnicodeEscapeSequence(Token& token, Location& current,
|
||||
Location end, unsigned int& unicode);
|
||||
bool addError(const String& message, Token& token, Location extra = nullptr);
|
||||
bool recoverFromError(TokenType skipUntilToken);
|
||||
bool addErrorAndRecover(const String& message, Token& token,
|
||||
TokenType skipUntilToken);
|
||||
void skipUntilSpace();
|
||||
Value& currentValue();
|
||||
Char getNextChar();
|
||||
void getLocationLineAndColumn(Location location, int& line,
|
||||
int& column) const;
|
||||
String getLocationLineAndColumn(Location location) const;
|
||||
void addComment(Location begin, Location end, CommentPlacement placement);
|
||||
void skipCommentTokens(Token& token);
|
||||
|
||||
static bool containsNewLine(Location begin, Location end);
|
||||
static String normalizeEOL(Location begin, Location end);
|
||||
|
||||
using Nodes = std::stack<Value*>;
|
||||
Nodes nodes_;
|
||||
Errors errors_;
|
||||
String document_;
|
||||
Location begin_{};
|
||||
Location end_{};
|
||||
Location current_{};
|
||||
Location lastValueEnd_{};
|
||||
Value* lastValue_{};
|
||||
String commentsBefore_;
|
||||
Features features_;
|
||||
bool collectComments_{};
|
||||
}; // Reader
|
||||
|
||||
/** Interface for reading JSON from a char array.
|
||||
*/
|
||||
class JSON_API CharReader {
|
||||
public:
|
||||
virtual ~CharReader() = default;
|
||||
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
|
||||
* document. The document must be a UTF-8 encoded string containing the
|
||||
* document to read.
|
||||
*
|
||||
* \param beginDoc Pointer on the beginning of the UTF-8 encoded string
|
||||
* of the document to read.
|
||||
* \param endDoc Pointer on the end of the UTF-8 encoded string of the
|
||||
* document to read. Must be >= beginDoc.
|
||||
* \param[out] root Contains the root value of the document if it was
|
||||
* successfully parsed.
|
||||
* \param[out] errs Formatted error messages (if not NULL) a user
|
||||
* friendly string that lists errors in the parsed
|
||||
* document.
|
||||
* \return \c true if the document was successfully parsed, \c false if an
|
||||
* error occurred.
|
||||
*/
|
||||
virtual bool parse(char const* beginDoc, char const* endDoc, Value* root,
|
||||
String* errs) = 0;
|
||||
|
||||
class JSON_API Factory {
|
||||
public:
|
||||
virtual ~Factory() = default;
|
||||
/** \brief Allocate a CharReader via operator new().
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
virtual CharReader* newCharReader() const = 0;
|
||||
}; // Factory
|
||||
}; // CharReader
|
||||
|
||||
/** \brief Build a CharReader implementation.
|
||||
*
|
||||
* Usage:
|
||||
* \code
|
||||
* using namespace Json;
|
||||
* CharReaderBuilder builder;
|
||||
* builder["collectComments"] = false;
|
||||
* Value value;
|
||||
* String errs;
|
||||
* bool ok = parseFromStream(builder, std::cin, &value, &errs);
|
||||
* \endcode
|
||||
*/
|
||||
class JSON_API CharReaderBuilder : public CharReader::Factory {
|
||||
public:
|
||||
// Note: We use a Json::Value so that we can add data-members to this class
|
||||
// without a major version bump.
|
||||
/** Configuration of this builder.
|
||||
* These are case-sensitive.
|
||||
* Available settings (case-sensitive):
|
||||
* - `"collectComments": false or true`
|
||||
* - true to collect comment and allow writing them back during
|
||||
* serialization, false to discard comments. This parameter is ignored
|
||||
* if allowComments is false.
|
||||
* - `"allowComments": false or true`
|
||||
* - true if comments are allowed.
|
||||
* - `"allowTrailingCommas": false or true`
|
||||
* - true if trailing commas in objects and arrays are allowed.
|
||||
* - `"strictRoot": false or true`
|
||||
* - true if root must be either an array or an object value
|
||||
* - `"allowDroppedNullPlaceholders": false or true`
|
||||
* - true if dropped null placeholders are allowed. (See
|
||||
* StreamWriterBuilder.)
|
||||
* - `"allowNumericKeys": false or true`
|
||||
* - true if numeric object keys are allowed.
|
||||
* - `"allowSingleQuotes": false or true`
|
||||
* - true if '' are allowed for strings (both keys and values)
|
||||
* - `"stackLimit": integer`
|
||||
* - Exceeding stackLimit (recursive depth of `readValue()`) will cause an
|
||||
* exception.
|
||||
* - This is a security issue (seg-faults caused by deeply nested JSON), so
|
||||
* the default is low.
|
||||
* - `"failIfExtra": false or true`
|
||||
* - If true, `parse()` returns false when extra non-whitespace trails the
|
||||
* JSON value in the input string.
|
||||
* - `"rejectDupKeys": false or true`
|
||||
* - If true, `parse()` returns false when a key is duplicated within an
|
||||
* object.
|
||||
* - `"allowSpecialFloats": false or true`
|
||||
* - If true, special float values (NaNs and infinities) are allowed and
|
||||
* their values are lossfree restorable.
|
||||
* - `"skipBom": false or true`
|
||||
* - If true, if the input starts with the Unicode byte order mark (BOM),
|
||||
* it is skipped.
|
||||
*
|
||||
* You can examine 'settings_` yourself to see the defaults. You can also
|
||||
* write and read them just like any JSON Value.
|
||||
* \sa setDefaults()
|
||||
*/
|
||||
Json::Value settings_;
|
||||
|
||||
CharReaderBuilder();
|
||||
~CharReaderBuilder() override;
|
||||
|
||||
CharReader* newCharReader() const override;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
*/
|
||||
bool validate(Json::Value* invalid) const;
|
||||
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](const String& key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
|
||||
*/
|
||||
static void setDefaults(Json::Value* settings);
|
||||
/** Same as old Features::strictMode().
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
|
||||
*/
|
||||
static void strictMode(Json::Value* settings);
|
||||
};
|
||||
|
||||
/** Consume entire stream and use its begin/end.
|
||||
* Someday we might have a real StreamReader, but for now this
|
||||
* is convenient.
|
||||
*/
|
||||
bool JSON_API parseFromStream(CharReader::Factory const&, IStream&, Value* root,
|
||||
String* errs);
|
||||
|
||||
/** \brief Read from 'sin' into 'root'.
|
||||
*
|
||||
* Always keep comments from the input JSON.
|
||||
*
|
||||
* This can be used to read a file into a particular sub-object.
|
||||
* For example:
|
||||
* \code
|
||||
* Json::Value root;
|
||||
* cin >> root["dir"]["file"];
|
||||
* cout << root;
|
||||
* \endcode
|
||||
* Result:
|
||||
* \verbatim
|
||||
* {
|
||||
* "dir": {
|
||||
* "file": {
|
||||
* // The input stream JSON would be nested here.
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* \endverbatim
|
||||
* \throw std::exception on parse error.
|
||||
* \see Json::operator<<()
|
||||
*/
|
||||
JSON_API IStream& operator>>(IStream&, Value&);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#endif // JSON_READER_H_INCLUDED
|
||||
961
demo/kugou/include/Common/include/json/value.h
Normal file
961
demo/kugou/include/Common/include/json/value.h
Normal file
@@ -0,0 +1,961 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_H_INCLUDED
|
||||
#define JSON_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "forwards.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
|
||||
// Conditional NORETURN attribute on the throw functions would:
|
||||
// a) suppress false positives from static code analysis
|
||||
// b) possibly improve optimization opportunities.
|
||||
#if !defined(JSONCPP_NORETURN)
|
||||
#if defined(_MSC_VER) && _MSC_VER == 1800
|
||||
#define JSONCPP_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define JSONCPP_NORETURN [[noreturn]]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Support for '= delete' with template declarations was a late addition
|
||||
// to the c++11 standard and is rejected by clang 3.8 and Apple clang 8.2
|
||||
// even though these declare themselves to be c++11 compilers.
|
||||
#if !defined(JSONCPP_TEMPLATE_DELETE)
|
||||
#if defined(__clang__) && defined(__apple_build_version__)
|
||||
#if __apple_build_version__ <= 8000042
|
||||
#define JSONCPP_TEMPLATE_DELETE
|
||||
#endif
|
||||
#elif defined(__clang__)
|
||||
#if __clang_major__ == 3 && __clang_minor__ <= 8
|
||||
#define JSONCPP_TEMPLATE_DELETE
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(JSONCPP_TEMPLATE_DELETE)
|
||||
#define JSONCPP_TEMPLATE_DELETE = delete
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251 4275)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
/** \brief JSON (JavaScript Object Notation).
|
||||
*/
|
||||
namespace Json {
|
||||
|
||||
#if JSON_USE_EXCEPTION
|
||||
/** Base class for all exceptions we throw.
|
||||
*
|
||||
* We use nothing but these internally. Of course, STL can throw others.
|
||||
*/
|
||||
class JSON_API Exception : public std::exception {
|
||||
public:
|
||||
Exception(String msg);
|
||||
~Exception() noexcept override;
|
||||
char const* what() const noexcept override;
|
||||
|
||||
protected:
|
||||
String msg_;
|
||||
};
|
||||
|
||||
/** Exceptions which the user cannot easily avoid.
|
||||
*
|
||||
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API RuntimeError : public Exception {
|
||||
public:
|
||||
RuntimeError(String const& msg);
|
||||
};
|
||||
|
||||
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
|
||||
*
|
||||
* These are precondition-violations (user bugs) and internal errors (our bugs).
|
||||
*
|
||||
* \remark derived from Json::Exception
|
||||
*/
|
||||
class JSON_API LogicError : public Exception {
|
||||
public:
|
||||
LogicError(String const& msg);
|
||||
};
|
||||
#endif
|
||||
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwRuntimeError(String const& msg);
|
||||
/// used internally
|
||||
JSONCPP_NORETURN void throwLogicError(String const& msg);
|
||||
|
||||
/** \brief Type of the value held by a Value object.
|
||||
*/
|
||||
enum ValueType {
|
||||
nullValue = 0, ///< 'null' value
|
||||
intValue, ///< signed integer value
|
||||
uintValue, ///< unsigned integer value
|
||||
realValue, ///< double value
|
||||
stringValue, ///< UTF-8 string value
|
||||
booleanValue, ///< bool value
|
||||
arrayValue, ///< array value (ordered list)
|
||||
objectValue ///< object value (collection of name/value pairs).
|
||||
};
|
||||
|
||||
enum CommentPlacement {
|
||||
commentBefore = 0, ///< a comment placed on the line before a value
|
||||
commentAfterOnSameLine, ///< a comment just after a value on the same line
|
||||
commentAfter, ///< a comment on the line after a value (only make sense for
|
||||
/// root value)
|
||||
numberOfCommentPlacement
|
||||
};
|
||||
|
||||
/** \brief Type of precision for formatting of real values.
|
||||
*/
|
||||
enum PrecisionType {
|
||||
significantDigits = 0, ///< we set max number of significant digits in string
|
||||
decimalPlaces ///< we set max number of digits after "." in string
|
||||
};
|
||||
|
||||
/** \brief Lightweight wrapper to tag static string.
|
||||
*
|
||||
* Value constructor and objectValue member assignment takes advantage of the
|
||||
* StaticString and avoid the cost of string duplication when storing the
|
||||
* string or the member name.
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* Json::Value aValue( StaticString("some text") );
|
||||
* Json::Value object;
|
||||
* static const StaticString code("code");
|
||||
* object[code] = 1234;
|
||||
* \endcode
|
||||
*/
|
||||
class JSON_API StaticString {
|
||||
public:
|
||||
explicit StaticString(const char* czstring) : c_str_(czstring) {}
|
||||
|
||||
operator const char*() const { return c_str_; }
|
||||
|
||||
const char* c_str() const { return c_str_; }
|
||||
|
||||
private:
|
||||
const char* c_str_;
|
||||
};
|
||||
|
||||
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
|
||||
*
|
||||
* This class is a discriminated union wrapper that can represents a:
|
||||
* - signed integer [range: Value::minInt - Value::maxInt]
|
||||
* - unsigned integer (range: 0 - Value::maxUInt)
|
||||
* - double
|
||||
* - UTF-8 string
|
||||
* - boolean
|
||||
* - 'null'
|
||||
* - an ordered list of Value
|
||||
* - collection of name/value pairs (javascript object)
|
||||
*
|
||||
* The type of the held value is represented by a #ValueType and
|
||||
* can be obtained using type().
|
||||
*
|
||||
* Values of an #objectValue or #arrayValue can be accessed using operator[]()
|
||||
* methods.
|
||||
* Non-const methods will automatically create the a #nullValue element
|
||||
* if it does not exist.
|
||||
* The sequence of an #arrayValue will be automatically resized and initialized
|
||||
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
|
||||
*
|
||||
* The get() methods can be used to obtain default value in the case the
|
||||
* required element does not exist.
|
||||
*
|
||||
* It is possible to iterate over the list of member keys of an object using
|
||||
* the getMemberNames() method.
|
||||
*
|
||||
* \note #Value string-length fit in size_t, but keys must be < 2^30.
|
||||
* (The reason is an implementation detail.) A #CharReader will raise an
|
||||
* exception if a bound is exceeded to avoid security holes in your app,
|
||||
* but the Value API does *not* check bounds. That is the responsibility
|
||||
* of the caller.
|
||||
*/
|
||||
class JSON_API Value {
|
||||
friend class ValueIteratorBase;
|
||||
|
||||
public:
|
||||
using Members = std::vector<String>;
|
||||
using iterator = ValueIterator;
|
||||
using const_iterator = ValueConstIterator;
|
||||
using UInt = Json::UInt;
|
||||
using Int = Json::Int;
|
||||
#if defined(JSON_HAS_INT64)
|
||||
using UInt64 = Json::UInt64;
|
||||
using Int64 = Json::Int64;
|
||||
#endif // defined(JSON_HAS_INT64)
|
||||
using LargestInt = Json::LargestInt;
|
||||
using LargestUInt = Json::LargestUInt;
|
||||
using ArrayIndex = Json::ArrayIndex;
|
||||
|
||||
// Required for boost integration, e. g. BOOST_TEST
|
||||
using value_type = std::string;
|
||||
|
||||
#if JSON_USE_NULLREF
|
||||
// Binary compatibility kludges, do not use.
|
||||
static const Value& null;
|
||||
static const Value& nullRef;
|
||||
#endif
|
||||
|
||||
// null and nullRef are deprecated, use this instead.
|
||||
static Value const& nullSingleton();
|
||||
|
||||
/// Minimum signed integer value that can be stored in a Json::Value.
|
||||
static constexpr LargestInt minLargestInt =
|
||||
LargestInt(~(LargestUInt(-1) / 2));
|
||||
/// Maximum signed integer value that can be stored in a Json::Value.
|
||||
static constexpr LargestInt maxLargestInt = LargestInt(LargestUInt(-1) / 2);
|
||||
/// Maximum unsigned integer value that can be stored in a Json::Value.
|
||||
static constexpr LargestUInt maxLargestUInt = LargestUInt(-1);
|
||||
|
||||
/// Minimum signed int value that can be stored in a Json::Value.
|
||||
static constexpr Int minInt = Int(~(UInt(-1) / 2));
|
||||
/// Maximum signed int value that can be stored in a Json::Value.
|
||||
static constexpr Int maxInt = Int(UInt(-1) / 2);
|
||||
/// Maximum unsigned int value that can be stored in a Json::Value.
|
||||
static constexpr UInt maxUInt = UInt(-1);
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
/// Minimum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static constexpr Int64 minInt64 = Int64(~(UInt64(-1) / 2));
|
||||
/// Maximum signed 64 bits int value that can be stored in a Json::Value.
|
||||
static constexpr Int64 maxInt64 = Int64(UInt64(-1) / 2);
|
||||
/// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
|
||||
static constexpr UInt64 maxUInt64 = UInt64(-1);
|
||||
#endif // defined(JSON_HAS_INT64)
|
||||
/// Default precision for real value for string representation.
|
||||
static constexpr UInt defaultRealPrecision = 17;
|
||||
// The constant is hard-coded because some compiler have trouble
|
||||
// converting Value::maxUInt64 to a double correctly (AIX/xlC).
|
||||
// Assumes that UInt64 is a 64 bits integer.
|
||||
static constexpr double maxUInt64AsDouble = 18446744073709551615.0;
|
||||
// Workaround for bug in the NVIDIAs CUDA 9.1 nvcc compiler
|
||||
// when using gcc and clang backend compilers. CZString
|
||||
// cannot be defined as private. See issue #486
|
||||
#ifdef __NVCC__
|
||||
public:
|
||||
#else
|
||||
private:
|
||||
#endif
|
||||
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||
class CZString {
|
||||
public:
|
||||
enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
|
||||
CZString(ArrayIndex index);
|
||||
CZString(char const* str, unsigned length, DuplicationPolicy allocate);
|
||||
CZString(CZString const& other);
|
||||
CZString(CZString&& other) noexcept;
|
||||
~CZString();
|
||||
CZString& operator=(const CZString& other);
|
||||
CZString& operator=(CZString&& other) noexcept;
|
||||
|
||||
bool operator<(CZString const& other) const;
|
||||
bool operator==(CZString const& other) const;
|
||||
ArrayIndex index() const;
|
||||
// const char* c_str() const; ///< \deprecated
|
||||
char const* data() const;
|
||||
unsigned length() const;
|
||||
bool isStaticString() const;
|
||||
|
||||
private:
|
||||
void swap(CZString& other);
|
||||
|
||||
struct StringStorage {
|
||||
unsigned policy_ : 2;
|
||||
unsigned length_ : 30; // 1GB max
|
||||
};
|
||||
|
||||
char const* cstr_; // actually, a prefixed string, unless policy is noDup
|
||||
union {
|
||||
ArrayIndex index_;
|
||||
StringStorage storage_;
|
||||
};
|
||||
};
|
||||
|
||||
public:
|
||||
typedef std::map<CZString, Value> ObjectValues;
|
||||
#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Create a default Value of the given type.
|
||||
*
|
||||
* This is a very useful constructor.
|
||||
* To create an empty array, pass arrayValue.
|
||||
* To create an empty object, pass objectValue.
|
||||
* Another Value can then be set to this one by assignment.
|
||||
* This is useful since clear() and resize() will not alter types.
|
||||
*
|
||||
* Examples:
|
||||
* \code
|
||||
* Json::Value null_value; // null
|
||||
* Json::Value arr_value(Json::arrayValue); // []
|
||||
* Json::Value obj_value(Json::objectValue); // {}
|
||||
* \endcode
|
||||
*/
|
||||
Value(ValueType type = nullValue);
|
||||
Value(Int value);
|
||||
Value(UInt value);
|
||||
#if defined(JSON_HAS_INT64)
|
||||
Value(Int64 value);
|
||||
Value(UInt64 value);
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
Value(double value);
|
||||
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
|
||||
Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
|
||||
/**
|
||||
* \brief Constructs a value from a static string.
|
||||
*
|
||||
* Like other value string constructor but do not duplicate the string for
|
||||
* internal storage. The given string must remain alive after the call to
|
||||
* this constructor.
|
||||
*
|
||||
* \note This works only for null-terminated strings. (We cannot change the
|
||||
* size of this class, so we have nowhere to store the length, which might be
|
||||
* computed later for various operations.)
|
||||
*
|
||||
* Example of usage:
|
||||
* \code
|
||||
* static StaticString foo("some text");
|
||||
* Json::Value aValue(foo);
|
||||
* \endcode
|
||||
*/
|
||||
Value(const StaticString& value);
|
||||
Value(const String& value);
|
||||
Value(bool value);
|
||||
Value(std::nullptr_t ptr) = delete;
|
||||
Value(const Value& other);
|
||||
Value(Value&& other) noexcept;
|
||||
~Value();
|
||||
|
||||
/// \note Overwrite existing comments. To preserve comments, use
|
||||
/// #swapPayload().
|
||||
Value& operator=(const Value& other);
|
||||
Value& operator=(Value&& other) noexcept;
|
||||
|
||||
/// Swap everything.
|
||||
void swap(Value& other);
|
||||
/// Swap values but leave comments and source offsets in place.
|
||||
void swapPayload(Value& other);
|
||||
|
||||
/// copy everything.
|
||||
void copy(const Value& other);
|
||||
/// copy values but leave comments and source offsets in place.
|
||||
void copyPayload(const Value& other);
|
||||
|
||||
ValueType type() const;
|
||||
|
||||
/// Compare payload only, not comments etc.
|
||||
bool operator<(const Value& other) const;
|
||||
bool operator<=(const Value& other) const;
|
||||
bool operator>=(const Value& other) const;
|
||||
bool operator>(const Value& other) const;
|
||||
bool operator==(const Value& other) const;
|
||||
bool operator!=(const Value& other) const;
|
||||
int compare(const Value& other) const;
|
||||
|
||||
const char* asCString() const; ///< Embedded zeroes could cause you trouble!
|
||||
#if JSONCPP_USING_SECURE_MEMORY
|
||||
unsigned getCStringLength() const; // Allows you to understand the length of
|
||||
// the CString
|
||||
#endif
|
||||
String asString() const; ///< Embedded zeroes are possible.
|
||||
/** Get raw char* of string-value.
|
||||
* \return false if !string. (Seg-fault if str or end are NULL.)
|
||||
*/
|
||||
bool getString(char const** begin, char const** end) const;
|
||||
Int asInt() const;
|
||||
UInt asUInt() const;
|
||||
#if defined(JSON_HAS_INT64)
|
||||
Int64 asInt64() const;
|
||||
UInt64 asUInt64() const;
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
LargestInt asLargestInt() const;
|
||||
LargestUInt asLargestUInt() const;
|
||||
float asFloat() const;
|
||||
double asDouble() const;
|
||||
bool asBool() const;
|
||||
|
||||
bool isNull() const;
|
||||
bool isBool() const;
|
||||
bool isInt() const;
|
||||
bool isInt64() const;
|
||||
bool isUInt() const;
|
||||
bool isUInt64() const;
|
||||
bool isIntegral() const;
|
||||
bool isDouble() const;
|
||||
bool isNumeric() const;
|
||||
bool isString() const;
|
||||
bool isArray() const;
|
||||
bool isObject() const;
|
||||
|
||||
/// The `as<T>` and `is<T>` member function templates and specializations.
|
||||
template <typename T> T as() const JSONCPP_TEMPLATE_DELETE;
|
||||
template <typename T> bool is() const JSONCPP_TEMPLATE_DELETE;
|
||||
|
||||
bool isConvertibleTo(ValueType other) const;
|
||||
|
||||
/// Number of values in array or object
|
||||
ArrayIndex size() const;
|
||||
|
||||
/// \brief Return true if empty array, empty object, or null;
|
||||
/// otherwise, false.
|
||||
bool empty() const;
|
||||
|
||||
/// Return !isNull()
|
||||
explicit operator bool() const;
|
||||
|
||||
/// Remove all object members and array elements.
|
||||
/// \pre type() is arrayValue, objectValue, or nullValue
|
||||
/// \post type() is unchanged
|
||||
void clear();
|
||||
|
||||
/// Resize the array to newSize elements.
|
||||
/// New elements are initialized to null.
|
||||
/// May only be called on nullValue or arrayValue.
|
||||
/// \pre type() is arrayValue or nullValue
|
||||
/// \post type() is arrayValue
|
||||
void resize(ArrayIndex newSize);
|
||||
|
||||
///@{
|
||||
/// Access an array element (zero based index). If the array contains less
|
||||
/// than index element, then null value are inserted in the array so that
|
||||
/// its size is index+1.
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
Value& operator[](ArrayIndex index);
|
||||
Value& operator[](int index);
|
||||
///@}
|
||||
|
||||
///@{
|
||||
/// Access an array element (zero based index).
|
||||
/// (You may need to say 'value[0u]' to get your compiler to distinguish
|
||||
/// this from the operator[] which takes a string.)
|
||||
const Value& operator[](ArrayIndex index) const;
|
||||
const Value& operator[](int index) const;
|
||||
///@}
|
||||
|
||||
/// If the array contains at least index+1 elements, returns the element
|
||||
/// value, otherwise returns defaultValue.
|
||||
Value get(ArrayIndex index, const Value& defaultValue) const;
|
||||
/// Return true if index < size().
|
||||
bool isValidIndex(ArrayIndex index) const;
|
||||
/// \brief Append value to array at the end.
|
||||
///
|
||||
/// Equivalent to jsonvalue[jsonvalue.size()] = value;
|
||||
Value& append(const Value& value);
|
||||
Value& append(Value&& value);
|
||||
|
||||
/// \brief Insert value in array at specific index
|
||||
bool insert(ArrayIndex index, const Value& newValue);
|
||||
bool insert(ArrayIndex index, Value&& newValue);
|
||||
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
/// \note Because of our implementation, keys are limited to 2^30 -1 chars.
|
||||
/// Exceeding that will cause an exception.
|
||||
Value& operator[](const char* key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
const Value& operator[](const char* key) const;
|
||||
/// Access an object value by name, create a null member if it does not exist.
|
||||
/// \param key may contain embedded nulls.
|
||||
Value& operator[](const String& key);
|
||||
/// Access an object value by name, returns null if there is no member with
|
||||
/// that name.
|
||||
/// \param key may contain embedded nulls.
|
||||
const Value& operator[](const String& key) const;
|
||||
/** \brief Access an object value by name, create a null member if it does not
|
||||
* exist.
|
||||
*
|
||||
* If the object has no entry for that name, then the member name used to
|
||||
* store the new entry is not duplicated.
|
||||
* Example of use:
|
||||
* \code
|
||||
* Json::Value object;
|
||||
* static const StaticString code("code");
|
||||
* object[code] = 1234;
|
||||
* \endcode
|
||||
*/
|
||||
Value& operator[](const StaticString& key);
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
Value get(const char* key, const Value& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \note key may contain embedded nulls.
|
||||
Value get(const char* begin, const char* end,
|
||||
const Value& defaultValue) const;
|
||||
/// Return the member named key if it exist, defaultValue otherwise.
|
||||
/// \note deep copy
|
||||
/// \param key may contain embedded nulls.
|
||||
Value get(const String& key, const Value& defaultValue) const;
|
||||
/// Most general and efficient version of isMember()const, get()const,
|
||||
/// and operator[]const
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||
Value const* find(char const* begin, char const* end) const;
|
||||
/// Most general and efficient version of object-mutators.
|
||||
/// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
|
||||
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
|
||||
Value* demand(char const* begin, char const* end);
|
||||
/// \brief Remove and return the named member.
|
||||
///
|
||||
/// Do nothing if it did not exist.
|
||||
/// \pre type() is objectValue or nullValue
|
||||
/// \post type() is unchanged
|
||||
void removeMember(const char* key);
|
||||
/// Same as removeMember(const char*)
|
||||
/// \param key may contain embedded nulls.
|
||||
void removeMember(const String& key);
|
||||
/// Same as removeMember(const char* begin, const char* end, Value* removed),
|
||||
/// but 'key' is null-terminated.
|
||||
bool removeMember(const char* key, Value* removed);
|
||||
/** \brief Remove the named map member.
|
||||
*
|
||||
* Update 'removed' iff removed.
|
||||
* \param key may contain embedded nulls.
|
||||
* \return true iff removed (no exceptions)
|
||||
*/
|
||||
bool removeMember(String const& key, Value* removed);
|
||||
/// Same as removeMember(String const& key, Value* removed)
|
||||
bool removeMember(const char* begin, const char* end, Value* removed);
|
||||
/** \brief Remove the indexed array element.
|
||||
*
|
||||
* O(n) expensive operations.
|
||||
* Update 'removed' iff removed.
|
||||
* \return true if removed (no exceptions)
|
||||
*/
|
||||
bool removeIndex(ArrayIndex index, Value* removed);
|
||||
|
||||
/// Return true if the object has a member named key.
|
||||
/// \note 'key' must be null-terminated.
|
||||
bool isMember(const char* key) const;
|
||||
/// Return true if the object has a member named key.
|
||||
/// \param key may contain embedded nulls.
|
||||
bool isMember(const String& key) const;
|
||||
/// Same as isMember(String const& key)const
|
||||
bool isMember(const char* begin, const char* end) const;
|
||||
|
||||
/// \brief Return a list of the member names.
|
||||
///
|
||||
/// If null, return an empty list.
|
||||
/// \pre type() is objectValue or nullValue
|
||||
/// \post if type() was nullValue, it remains nullValue
|
||||
Members getMemberNames() const;
|
||||
|
||||
/// \deprecated Always pass len.
|
||||
JSONCPP_DEPRECATED("Use setComment(String const&) instead.")
|
||||
void setComment(const char* comment, CommentPlacement placement) {
|
||||
setComment(String(comment, strlen(comment)), placement);
|
||||
}
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(const char* comment, size_t len, CommentPlacement placement) {
|
||||
setComment(String(comment, len), placement);
|
||||
}
|
||||
/// Comments must be //... or /* ... */
|
||||
void setComment(String comment, CommentPlacement placement);
|
||||
bool hasComment(CommentPlacement placement) const;
|
||||
/// Include delimiters and embedded newlines.
|
||||
String getComment(CommentPlacement placement) const;
|
||||
|
||||
String toString() const;
|
||||
String toStyledString() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
/// \brief Returns a reference to the first element in the `Value`.
|
||||
/// Requires that this value holds an array or json object, with at least one element.
|
||||
const Value& front() const;
|
||||
|
||||
/// \brief Returns a reference to the first element in the `Value`.
|
||||
/// Requires that this value holds an array or json object, with at least one element.
|
||||
Value& front();
|
||||
|
||||
/// \brief Returns a reference to the last element in the `Value`.
|
||||
/// Requires that value holds an array or json object, with at least one element.
|
||||
const Value& back() const;
|
||||
|
||||
/// \brief Returns a reference to the last element in the `Value`.
|
||||
/// Requires that this value holds an array or json object, with at least one element.
|
||||
Value& back();
|
||||
|
||||
// Accessors for the [start, limit) range of bytes within the JSON text from
|
||||
// which this value was parsed, if any.
|
||||
void setOffsetStart(ptrdiff_t start);
|
||||
void setOffsetLimit(ptrdiff_t limit);
|
||||
ptrdiff_t getOffsetStart() const;
|
||||
ptrdiff_t getOffsetLimit() const;
|
||||
|
||||
private:
|
||||
void setType(ValueType v) {
|
||||
bits_.value_type_ = static_cast<unsigned char>(v);
|
||||
}
|
||||
bool isAllocated() const { return bits_.allocated_; }
|
||||
void setIsAllocated(bool v) { bits_.allocated_ = v; }
|
||||
|
||||
void initBasic(ValueType type, bool allocated = false);
|
||||
void dupPayload(const Value& other);
|
||||
void releasePayload();
|
||||
void dupMeta(const Value& other);
|
||||
|
||||
Value& resolveReference(const char* key);
|
||||
Value& resolveReference(const char* key, const char* end);
|
||||
|
||||
// struct MemberNamesTransform
|
||||
//{
|
||||
// typedef const char *result_type;
|
||||
// const char *operator()( const CZString &name ) const
|
||||
// {
|
||||
// return name.c_str();
|
||||
// }
|
||||
//};
|
||||
|
||||
union ValueHolder {
|
||||
LargestInt int_;
|
||||
LargestUInt uint_;
|
||||
double real_;
|
||||
bool bool_;
|
||||
char* string_; // if allocated_, ptr to { unsigned, char[] }.
|
||||
ObjectValues* map_;
|
||||
} value_;
|
||||
|
||||
struct {
|
||||
// Really a ValueType, but types should agree for bitfield packing.
|
||||
unsigned int value_type_ : 8;
|
||||
// Unless allocated_, string_ must be null-terminated.
|
||||
unsigned int allocated_ : 1;
|
||||
} bits_;
|
||||
|
||||
class Comments {
|
||||
public:
|
||||
Comments() = default;
|
||||
Comments(const Comments& that);
|
||||
Comments(Comments&& that) noexcept;
|
||||
Comments& operator=(const Comments& that);
|
||||
Comments& operator=(Comments&& that) noexcept;
|
||||
bool has(CommentPlacement slot) const;
|
||||
String get(CommentPlacement slot) const;
|
||||
void set(CommentPlacement slot, String comment);
|
||||
|
||||
private:
|
||||
using Array = std::array<String, numberOfCommentPlacement>;
|
||||
std::unique_ptr<Array> ptr_;
|
||||
};
|
||||
Comments comments_;
|
||||
|
||||
// [start, limit) byte offsets in the source JSON text from which this Value
|
||||
// was extracted.
|
||||
ptrdiff_t start_;
|
||||
ptrdiff_t limit_;
|
||||
};
|
||||
|
||||
template <> inline bool Value::as<bool>() const { return asBool(); }
|
||||
template <> inline bool Value::is<bool>() const { return isBool(); }
|
||||
|
||||
template <> inline Int Value::as<Int>() const { return asInt(); }
|
||||
template <> inline bool Value::is<Int>() const { return isInt(); }
|
||||
|
||||
template <> inline UInt Value::as<UInt>() const { return asUInt(); }
|
||||
template <> inline bool Value::is<UInt>() const { return isUInt(); }
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
template <> inline Int64 Value::as<Int64>() const { return asInt64(); }
|
||||
template <> inline bool Value::is<Int64>() const { return isInt64(); }
|
||||
|
||||
template <> inline UInt64 Value::as<UInt64>() const { return asUInt64(); }
|
||||
template <> inline bool Value::is<UInt64>() const { return isUInt64(); }
|
||||
#endif
|
||||
|
||||
template <> inline double Value::as<double>() const { return asDouble(); }
|
||||
template <> inline bool Value::is<double>() const { return isDouble(); }
|
||||
|
||||
template <> inline String Value::as<String>() const { return asString(); }
|
||||
template <> inline bool Value::is<String>() const { return isString(); }
|
||||
|
||||
/// These `as` specializations are type conversions, and do not have a
|
||||
/// corresponding `is`.
|
||||
template <> inline float Value::as<float>() const { return asFloat(); }
|
||||
template <> inline const char* Value::as<const char*>() const {
|
||||
return asCString();
|
||||
}
|
||||
|
||||
/** \brief Experimental and untested: represents an element of the "path" to
|
||||
* access a node.
|
||||
*/
|
||||
class JSON_API PathArgument {
|
||||
public:
|
||||
friend class Path;
|
||||
|
||||
PathArgument();
|
||||
PathArgument(ArrayIndex index);
|
||||
PathArgument(const char* key);
|
||||
PathArgument(String key);
|
||||
|
||||
private:
|
||||
enum Kind { kindNone = 0, kindIndex, kindKey };
|
||||
String key_;
|
||||
ArrayIndex index_{};
|
||||
Kind kind_{kindNone};
|
||||
};
|
||||
|
||||
/** \brief Experimental and untested: represents a "path" to access a node.
|
||||
*
|
||||
* Syntax:
|
||||
* - "." => root node
|
||||
* - ".[n]" => elements at index 'n' of root node (an array value)
|
||||
* - ".name" => member named 'name' of root node (an object value)
|
||||
* - ".name1.name2.name3"
|
||||
* - ".[0][1][2].name1[3]"
|
||||
* - ".%" => member name is provided as parameter
|
||||
* - ".[%]" => index is provided as parameter
|
||||
*/
|
||||
class JSON_API Path {
|
||||
public:
|
||||
Path(const String& path, const PathArgument& a1 = PathArgument(),
|
||||
const PathArgument& a2 = PathArgument(),
|
||||
const PathArgument& a3 = PathArgument(),
|
||||
const PathArgument& a4 = PathArgument(),
|
||||
const PathArgument& a5 = PathArgument());
|
||||
|
||||
const Value& resolve(const Value& root) const;
|
||||
Value resolve(const Value& root, const Value& defaultValue) const;
|
||||
/// Creates the "path" to access the specified node and returns a reference on
|
||||
/// the node.
|
||||
Value& make(Value& root) const;
|
||||
|
||||
private:
|
||||
using InArgs = std::vector<const PathArgument*>;
|
||||
using Args = std::vector<PathArgument>;
|
||||
|
||||
void makePath(const String& path, const InArgs& in);
|
||||
void addPathInArg(const String& path, const InArgs& in,
|
||||
InArgs::const_iterator& itInArg, PathArgument::Kind kind);
|
||||
static void invalidPath(const String& path, int location);
|
||||
|
||||
Args args_;
|
||||
};
|
||||
|
||||
/** \brief base class for Value iterators.
|
||||
*
|
||||
*/
|
||||
class JSON_API ValueIteratorBase {
|
||||
public:
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using size_t = unsigned int;
|
||||
using difference_type = int;
|
||||
using SelfType = ValueIteratorBase;
|
||||
|
||||
bool operator==(const SelfType& other) const { return isEqual(other); }
|
||||
|
||||
bool operator!=(const SelfType& other) const { return !isEqual(other); }
|
||||
|
||||
difference_type operator-(const SelfType& other) const {
|
||||
return other.computeDistance(*this);
|
||||
}
|
||||
|
||||
/// Return either the index or the member name of the referenced value as a
|
||||
/// Value.
|
||||
Value key() const;
|
||||
|
||||
/// Return the index of the referenced Value, or -1 if it is not an
|
||||
/// arrayValue.
|
||||
UInt index() const;
|
||||
|
||||
/// Return the member name of the referenced Value, or "" if it is not an
|
||||
/// objectValue.
|
||||
/// \note Avoid `c_str()` on result, as embedded zeroes are possible.
|
||||
String name() const;
|
||||
|
||||
/// Return the member name of the referenced Value. "" if it is not an
|
||||
/// objectValue.
|
||||
/// \deprecated This cannot be used for UTF-8 strings, since there can be
|
||||
/// embedded nulls.
|
||||
JSONCPP_DEPRECATED("Use `key = name();` instead.")
|
||||
char const* memberName() const;
|
||||
/// Return the member name of the referenced Value, or NULL if it is not an
|
||||
/// objectValue.
|
||||
/// \note Better version than memberName(). Allows embedded nulls.
|
||||
char const* memberName(char const** end) const;
|
||||
|
||||
protected:
|
||||
/*! Internal utility functions to assist with implementing
|
||||
* other iterator functions. The const and non-const versions
|
||||
* of the "deref" protected methods expose the protected
|
||||
* current_ member variable in a way that can often be
|
||||
* optimized away by the compiler.
|
||||
*/
|
||||
const Value& deref() const;
|
||||
Value& deref();
|
||||
|
||||
void increment();
|
||||
|
||||
void decrement();
|
||||
|
||||
difference_type computeDistance(const SelfType& other) const;
|
||||
|
||||
bool isEqual(const SelfType& other) const;
|
||||
|
||||
void copy(const SelfType& other);
|
||||
|
||||
private:
|
||||
Value::ObjectValues::iterator current_;
|
||||
// Indicates that iterator is for a null value.
|
||||
bool isNull_{true};
|
||||
|
||||
public:
|
||||
// For some reason, BORLAND needs these at the end, rather
|
||||
// than earlier. No idea why.
|
||||
ValueIteratorBase();
|
||||
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
|
||||
};
|
||||
|
||||
/** \brief const iterator for object and array value.
|
||||
*
|
||||
*/
|
||||
class JSON_API ValueConstIterator : public ValueIteratorBase {
|
||||
friend class Value;
|
||||
|
||||
public:
|
||||
using value_type = const Value;
|
||||
// typedef unsigned int size_t;
|
||||
// typedef int difference_type;
|
||||
using reference = const Value&;
|
||||
using pointer = const Value*;
|
||||
using SelfType = ValueConstIterator;
|
||||
|
||||
ValueConstIterator();
|
||||
ValueConstIterator(ValueIterator const& other);
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
*/
|
||||
explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
|
||||
|
||||
public:
|
||||
SelfType& operator=(const ValueIteratorBase& other);
|
||||
|
||||
SelfType operator++(int) {
|
||||
SelfType temp(*this);
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType operator--(int) {
|
||||
SelfType temp(*this);
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType& operator--() {
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelfType& operator++() {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator*() const { return deref(); }
|
||||
|
||||
pointer operator->() const { return &deref(); }
|
||||
};
|
||||
|
||||
/** \brief Iterator for object and array value.
|
||||
*/
|
||||
class JSON_API ValueIterator : public ValueIteratorBase {
|
||||
friend class Value;
|
||||
|
||||
public:
|
||||
using value_type = Value;
|
||||
using size_t = unsigned int;
|
||||
using difference_type = int;
|
||||
using reference = Value&;
|
||||
using pointer = Value*;
|
||||
using SelfType = ValueIterator;
|
||||
|
||||
ValueIterator();
|
||||
explicit ValueIterator(const ValueConstIterator& other);
|
||||
ValueIterator(const ValueIterator& other);
|
||||
|
||||
private:
|
||||
/*! \internal Use by Value to create an iterator.
|
||||
*/
|
||||
explicit ValueIterator(const Value::ObjectValues::iterator& current);
|
||||
|
||||
public:
|
||||
SelfType& operator=(const SelfType& other);
|
||||
|
||||
SelfType operator++(int) {
|
||||
SelfType temp(*this);
|
||||
++*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType operator--(int) {
|
||||
SelfType temp(*this);
|
||||
--*this;
|
||||
return temp;
|
||||
}
|
||||
|
||||
SelfType& operator--() {
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
SelfType& operator++() {
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*! The return value of non-const iterators can be
|
||||
* changed, so the these functions are not const
|
||||
* because the returned references/pointers can be used
|
||||
* to change state of the base class.
|
||||
*/
|
||||
reference operator*() const { return const_cast<reference>(deref()); }
|
||||
pointer operator->() const { return const_cast<pointer>(&deref()); }
|
||||
};
|
||||
|
||||
inline void swap(Value& a, Value& b) { a.swap(b); }
|
||||
|
||||
inline const Value& Value::front() const { return *begin(); }
|
||||
|
||||
inline Value& Value::front() { return *begin(); }
|
||||
|
||||
inline const Value& Value::back() const { return *(--end()); }
|
||||
|
||||
inline Value& Value::back() { return *(--end()); }
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#endif // JSON_H_INCLUDED
|
||||
28
demo/kugou/include/Common/include/json/version.h
Normal file
28
demo/kugou/include/Common/include/json/version.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef JSON_VERSION_H_INCLUDED
|
||||
#define JSON_VERSION_H_INCLUDED
|
||||
|
||||
// Note: version must be updated in three places when doing a release. This
|
||||
// annoying process ensures that amalgamate, CMake, and meson all report the
|
||||
// correct version.
|
||||
// 1. /meson.build
|
||||
// 2. /include/json/version.h
|
||||
// 3. /CMakeLists.txt
|
||||
// IMPORTANT: also update the SOVERSION!!
|
||||
|
||||
#define JSONCPP_VERSION_STRING "1.9.5"
|
||||
#define JSONCPP_VERSION_MAJOR 1
|
||||
#define JSONCPP_VERSION_MINOR 9
|
||||
#define JSONCPP_VERSION_PATCH 5
|
||||
#define JSONCPP_VERSION_QUALIFIER
|
||||
#define JSONCPP_VERSION_HEXA \
|
||||
((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | \
|
||||
(JSONCPP_VERSION_PATCH << 8))
|
||||
|
||||
#ifdef JSONCPP_USING_SECURE_MEMORY
|
||||
#undef JSONCPP_USING_SECURE_MEMORY
|
||||
#endif
|
||||
#define JSONCPP_USING_SECURE_MEMORY 0
|
||||
// If non-zero, the library zeroes any memory that it has allocated before
|
||||
// it frees its memory.
|
||||
|
||||
#endif // JSON_VERSION_H_INCLUDED
|
||||
370
demo/kugou/include/Common/include/json/writer.h
Normal file
370
demo/kugou/include/Common/include/json/writer.h
Normal file
@@ -0,0 +1,370 @@
|
||||
// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
|
||||
// Distributed under MIT license, or public domain if desired and
|
||||
// recognized in your jurisdiction.
|
||||
// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
|
||||
|
||||
#ifndef JSON_WRITER_H_INCLUDED
|
||||
#define JSON_WRITER_H_INCLUDED
|
||||
|
||||
#if !defined(JSON_IS_AMALGAMATION)
|
||||
#include "value.h"
|
||||
#endif // if !defined(JSON_IS_AMALGAMATION)
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Disable warning C4251: <data member>: <type> needs to have dll-interface to
|
||||
// be used by...
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4251)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack()
|
||||
|
||||
namespace Json {
|
||||
|
||||
class Value;
|
||||
|
||||
/**
|
||||
*
|
||||
* Usage:
|
||||
* \code
|
||||
* using namespace Json;
|
||||
* void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
|
||||
* { std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
|
||||
* writer->write(value, &std::cout);
|
||||
* std::cout << std::endl; // add lf and flush
|
||||
* }
|
||||
* \endcode
|
||||
*/
|
||||
class JSON_API StreamWriter {
|
||||
protected:
|
||||
OStream* sout_; // not owned; will not delete
|
||||
public:
|
||||
StreamWriter();
|
||||
virtual ~StreamWriter();
|
||||
/** Write Value into document as configured in sub-class.
|
||||
* Do not take ownership of sout, but maintain a reference during function.
|
||||
* \pre sout != NULL
|
||||
* \return zero on success (For now, we always return zero, so check the
|
||||
* stream instead.) \throw std::exception possibly, depending on
|
||||
* configuration
|
||||
*/
|
||||
virtual int write(Value const& root, OStream* sout) = 0;
|
||||
|
||||
/** \brief A simple abstract factory.
|
||||
*/
|
||||
class JSON_API Factory {
|
||||
public:
|
||||
virtual ~Factory();
|
||||
/** \brief Allocate a CharReader via operator new().
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
virtual StreamWriter* newStreamWriter() const = 0;
|
||||
}; // Factory
|
||||
}; // StreamWriter
|
||||
|
||||
/** \brief Write into stringstream, then return string, for convenience.
|
||||
* A StreamWriter will be created from the factory, used, and then deleted.
|
||||
*/
|
||||
String JSON_API writeString(StreamWriter::Factory const& factory,
|
||||
Value const& root);
|
||||
|
||||
/** \brief Build a StreamWriter implementation.
|
||||
|
||||
* Usage:
|
||||
* \code
|
||||
* using namespace Json;
|
||||
* Value value = ...;
|
||||
* StreamWriterBuilder builder;
|
||||
* builder["commentStyle"] = "None";
|
||||
* builder["indentation"] = " "; // or whatever you like
|
||||
* std::unique_ptr<Json::StreamWriter> writer(
|
||||
* builder.newStreamWriter());
|
||||
* writer->write(value, &std::cout);
|
||||
* std::cout << std::endl; // add lf and flush
|
||||
* \endcode
|
||||
*/
|
||||
class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
|
||||
public:
|
||||
// Note: We use a Json::Value so that we can add data-members to this class
|
||||
// without a major version bump.
|
||||
/** Configuration of this builder.
|
||||
* Available settings (case-sensitive):
|
||||
* - "commentStyle": "None" or "All"
|
||||
* - "indentation": "<anything>".
|
||||
* - Setting this to an empty string also omits newline characters.
|
||||
* - "enableYAMLCompatibility": false or true
|
||||
* - slightly change the whitespace around colons
|
||||
* - "dropNullPlaceholders": false or true
|
||||
* - Drop the "null" string from the writer's output for nullValues.
|
||||
* Strictly speaking, this is not valid JSON. But when the output is being
|
||||
* fed to a browser's JavaScript, it makes for smaller output and the
|
||||
* browser can handle the output just fine.
|
||||
* - "useSpecialFloats": false or true
|
||||
* - If true, outputs non-finite floating point values in the following way:
|
||||
* NaN values as "NaN", positive infinity as "Infinity", and negative
|
||||
* infinity as "-Infinity".
|
||||
* - "precision": int
|
||||
* - Number of precision digits for formatting of real values.
|
||||
* - "precisionType": "significant"(default) or "decimal"
|
||||
* - Type of precision for formatting of real values.
|
||||
* - "emitUTF8": false or true
|
||||
* - If true, outputs raw UTF8 strings instead of escaping them.
|
||||
|
||||
* You can examine 'settings_` yourself
|
||||
* to see the defaults. You can also write and read them just like any
|
||||
* JSON Value.
|
||||
* \sa setDefaults()
|
||||
*/
|
||||
Json::Value settings_;
|
||||
|
||||
StreamWriterBuilder();
|
||||
~StreamWriterBuilder() override;
|
||||
|
||||
/**
|
||||
* \throw std::exception if something goes wrong (e.g. invalid settings)
|
||||
*/
|
||||
StreamWriter* newStreamWriter() const override;
|
||||
|
||||
/** \return true if 'settings' are legal and consistent;
|
||||
* otherwise, indicate bad settings via 'invalid'.
|
||||
*/
|
||||
bool validate(Json::Value* invalid) const;
|
||||
/** A simple way to update a specific setting.
|
||||
*/
|
||||
Value& operator[](const String& key);
|
||||
|
||||
/** Called by ctor, but you can use this to reset settings_.
|
||||
* \pre 'settings' != NULL (but Json::null is fine)
|
||||
* \remark Defaults:
|
||||
* \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
|
||||
*/
|
||||
static void setDefaults(Json::Value* settings);
|
||||
};
|
||||
|
||||
/** \brief Abstract class for writers.
|
||||
* \deprecated Use StreamWriter. (And really, this is an implementation detail.)
|
||||
*/
|
||||
class JSON_API Writer {
|
||||
public:
|
||||
virtual ~Writer();
|
||||
|
||||
virtual String write(const Value& root) = 0;
|
||||
};
|
||||
|
||||
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
|
||||
*without formatting (not human friendly).
|
||||
*
|
||||
* The JSON document is written in a single line. It is not intended for 'human'
|
||||
*consumption,
|
||||
* but may be useful to support feature such as RPC where bandwidth is limited.
|
||||
* \sa Reader, Value
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||
#endif
|
||||
class JSON_API FastWriter
|
||||
: public Writer {
|
||||
public:
|
||||
FastWriter();
|
||||
~FastWriter() override = default;
|
||||
|
||||
void enableYAMLCompatibility();
|
||||
|
||||
/** \brief Drop the "null" string from the writer's output for nullValues.
|
||||
* Strictly speaking, this is not valid JSON. But when the output is being
|
||||
* fed to a browser's JavaScript, it makes for smaller output and the
|
||||
* browser can handle the output just fine.
|
||||
*/
|
||||
void dropNullPlaceholders();
|
||||
|
||||
void omitEndingLineFeed();
|
||||
|
||||
public: // overridden from Writer
|
||||
String write(const Value& root) override;
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
|
||||
String document_;
|
||||
bool yamlCompatibilityEnabled_{false};
|
||||
bool dropNullPlaceholders_{false};
|
||||
bool omitEndingLineFeed_{false};
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||
*human friendly way.
|
||||
*
|
||||
* The rules for line break and indent are as follow:
|
||||
* - Object value:
|
||||
* - if empty then print {} without indent and line break
|
||||
* - if not empty the print '{', line break & indent, print one value per
|
||||
*line
|
||||
* and then unindent and line break and print '}'.
|
||||
* - Array value:
|
||||
* - if empty then print [] without indent and line break
|
||||
* - if the array contains no object value, empty array or some other value
|
||||
*types,
|
||||
* and all the values fit on one lines, then print the array on a single
|
||||
*line.
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputted according to their
|
||||
*#CommentPlacement.
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||
#endif
|
||||
class JSON_API
|
||||
StyledWriter : public Writer {
|
||||
public:
|
||||
StyledWriter();
|
||||
~StyledWriter() override = default;
|
||||
|
||||
public: // overridden from Writer
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param root Value to serialize.
|
||||
* \return String containing the JSON document that represents the root value.
|
||||
*/
|
||||
String write(const Value& root) override;
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultilineArray(const Value& value);
|
||||
void pushValue(const String& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const String& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
static bool hasCommentForValue(const Value& value);
|
||||
static String normalizeEOL(const String& text);
|
||||
|
||||
using ChildValues = std::vector<String>;
|
||||
|
||||
ChildValues childValues_;
|
||||
String document_;
|
||||
String indentString_;
|
||||
unsigned int rightMargin_{74};
|
||||
unsigned int indentSize_{3};
|
||||
bool addChildValues_{false};
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
|
||||
human friendly way,
|
||||
to a stream rather than to a string.
|
||||
*
|
||||
* The rules for line break and indent are as follow:
|
||||
* - Object value:
|
||||
* - if empty then print {} without indent and line break
|
||||
* - if not empty the print '{', line break & indent, print one value per
|
||||
line
|
||||
* and then unindent and line break and print '}'.
|
||||
* - Array value:
|
||||
* - if empty then print [] without indent and line break
|
||||
* - if the array contains no object value, empty array or some other value
|
||||
types,
|
||||
* and all the values fit on one lines, then print the array on a single
|
||||
line.
|
||||
* - otherwise, it the values do not fit on one line, or the array contains
|
||||
* object or non empty array, then print one value per line.
|
||||
*
|
||||
* If the Value have comments then they are outputted according to their
|
||||
#CommentPlacement.
|
||||
*
|
||||
* \sa Reader, Value, Value::setComment()
|
||||
* \deprecated Use StreamWriterBuilder.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996) // Deriving from deprecated class
|
||||
#endif
|
||||
class JSON_API
|
||||
StyledStreamWriter {
|
||||
public:
|
||||
/**
|
||||
* \param indentation Each level will be indented by this amount extra.
|
||||
*/
|
||||
StyledStreamWriter(String indentation = "\t");
|
||||
~StyledStreamWriter() = default;
|
||||
|
||||
public:
|
||||
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
|
||||
* \param out Stream to write to. (Can be ostringstream, e.g.)
|
||||
* \param root Value to serialize.
|
||||
* \note There is no point in deriving from Writer, since write() should not
|
||||
* return a value.
|
||||
*/
|
||||
void write(OStream& out, const Value& root);
|
||||
|
||||
private:
|
||||
void writeValue(const Value& value);
|
||||
void writeArrayValue(const Value& value);
|
||||
bool isMultilineArray(const Value& value);
|
||||
void pushValue(const String& value);
|
||||
void writeIndent();
|
||||
void writeWithIndent(const String& value);
|
||||
void indent();
|
||||
void unindent();
|
||||
void writeCommentBeforeValue(const Value& root);
|
||||
void writeCommentAfterValueOnSameLine(const Value& root);
|
||||
static bool hasCommentForValue(const Value& value);
|
||||
static String normalizeEOL(const String& text);
|
||||
|
||||
using ChildValues = std::vector<String>;
|
||||
|
||||
ChildValues childValues_;
|
||||
OStream* document_;
|
||||
String indentString_;
|
||||
unsigned int rightMargin_{74};
|
||||
String indentation_;
|
||||
bool addChildValues_ : 1;
|
||||
bool indented_ : 1;
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#if defined(JSON_HAS_INT64)
|
||||
String JSON_API valueToString(Int value);
|
||||
String JSON_API valueToString(UInt value);
|
||||
#endif // if defined(JSON_HAS_INT64)
|
||||
String JSON_API valueToString(LargestInt value);
|
||||
String JSON_API valueToString(LargestUInt value);
|
||||
String JSON_API valueToString(
|
||||
double value, unsigned int precision = Value::defaultRealPrecision,
|
||||
PrecisionType precisionType = PrecisionType::significantDigits);
|
||||
String JSON_API valueToString(bool value);
|
||||
String JSON_API valueToQuotedString(const char* value);
|
||||
|
||||
/// \brief Output using the StyledStreamWriter.
|
||||
/// \see Json::operator>>()
|
||||
JSON_API OStream& operator<<(OStream&, const Value& root);
|
||||
|
||||
} // namespace Json
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
#pragma warning(pop)
|
||||
#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
|
||||
|
||||
#endif // JSON_WRITER_H_INCLUDED
|
||||
121
demo/kugou/include/Common/include/mysql/big_endian.h
Normal file
121
demo/kugou/include/Common/include/mysql/big_endian.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 <string.h>
|
||||
|
||||
/*
|
||||
Data in big-endian format.
|
||||
*/
|
||||
static inline void float4store(uchar *T, float A)
|
||||
{ *(T)= ((uchar *) &A)[3];
|
||||
*((T)+1)=(char) ((uchar *) &A)[2];
|
||||
*((T)+2)=(char) ((uchar *) &A)[1];
|
||||
*((T)+3)=(char) ((uchar *) &A)[0]; }
|
||||
|
||||
static inline void float4get (float *V, const uchar *M)
|
||||
{ float def_temp;
|
||||
((uchar*) &def_temp)[0]=(M)[3];
|
||||
((uchar*) &def_temp)[1]=(M)[2];
|
||||
((uchar*) &def_temp)[2]=(M)[1];
|
||||
((uchar*) &def_temp)[3]=(M)[0];
|
||||
(*V)=def_temp; }
|
||||
|
||||
static inline void float8store(uchar *T, double V)
|
||||
{ *(T)= ((uchar *) &V)[7];
|
||||
*((T)+1)=(char) ((uchar *) &V)[6];
|
||||
*((T)+2)=(char) ((uchar *) &V)[5];
|
||||
*((T)+3)=(char) ((uchar *) &V)[4];
|
||||
*((T)+4)=(char) ((uchar *) &V)[3];
|
||||
*((T)+5)=(char) ((uchar *) &V)[2];
|
||||
*((T)+6)=(char) ((uchar *) &V)[1];
|
||||
*((T)+7)=(char) ((uchar *) &V)[0]; }
|
||||
|
||||
static inline void float8get (double *V, const uchar *M)
|
||||
{ double def_temp;
|
||||
((uchar*) &def_temp)[0]=(M)[7];
|
||||
((uchar*) &def_temp)[1]=(M)[6];
|
||||
((uchar*) &def_temp)[2]=(M)[5];
|
||||
((uchar*) &def_temp)[3]=(M)[4];
|
||||
((uchar*) &def_temp)[4]=(M)[3];
|
||||
((uchar*) &def_temp)[5]=(M)[2];
|
||||
((uchar*) &def_temp)[6]=(M)[1];
|
||||
((uchar*) &def_temp)[7]=(M)[0];
|
||||
(*V) = def_temp; }
|
||||
|
||||
static inline void ushortget(uint16 *V, const uchar *pM)
|
||||
{ *V = (uint16) (((uint16) ((uchar) (pM)[1]))+
|
||||
((uint16) ((uint16) (pM)[0]) << 8)); }
|
||||
static inline void shortget (int16 *V, const uchar *pM)
|
||||
{ *V = (short) (((short) ((uchar) (pM)[1]))+
|
||||
((short) ((short) (pM)[0]) << 8)); }
|
||||
static inline void longget (int32 *V, const uchar *pM)
|
||||
{ int32 def_temp;
|
||||
((uchar*) &def_temp)[0]=(pM)[0];
|
||||
((uchar*) &def_temp)[1]=(pM)[1];
|
||||
((uchar*) &def_temp)[2]=(pM)[2];
|
||||
((uchar*) &def_temp)[3]=(pM)[3];
|
||||
(*V)=def_temp; }
|
||||
static inline void ulongget (uint32 *V, const uchar *pM)
|
||||
{ uint32 def_temp;
|
||||
((uchar*) &def_temp)[0]=(pM)[0];
|
||||
((uchar*) &def_temp)[1]=(pM)[1];
|
||||
((uchar*) &def_temp)[2]=(pM)[2];
|
||||
((uchar*) &def_temp)[3]=(pM)[3];
|
||||
(*V)=def_temp; }
|
||||
static inline void shortstore(uchar *T, int16 A)
|
||||
{ uint def_temp=(uint) (A) ;
|
||||
*(((char*)T)+1)=(char)(def_temp);
|
||||
*(((char*)T)+0)=(char)(def_temp >> 8); }
|
||||
static inline void longstore (uchar *T, int32 A)
|
||||
{ *(((char*)T)+3)=((A));
|
||||
*(((char*)T)+2)=(((A) >> 8));
|
||||
*(((char*)T)+1)=(((A) >> 16));
|
||||
*(((char*)T)+0)=(((A) >> 24)); }
|
||||
|
||||
static inline void floatget(float *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void floatstore(uchar *T, float V)
|
||||
{
|
||||
memcpy((T), (&V), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void doubleget(double *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(double));
|
||||
}
|
||||
|
||||
static inline void doublestore(uchar *T, double V)
|
||||
{
|
||||
memcpy((T), &V, sizeof(double));
|
||||
}
|
||||
|
||||
static inline void longlongget(longlong *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(ulonglong));
|
||||
}
|
||||
static inline void longlongstore(uchar *T, longlong V)
|
||||
{
|
||||
memcpy((T), &V, sizeof(ulonglong));
|
||||
}
|
||||
82
demo/kugou/include/Common/include/mysql/binary_log_types.h
Normal file
82
demo/kugou/include/Common/include/mysql/binary_log_types.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
@file binary_log_types.h
|
||||
|
||||
@brief This file contains the field type.
|
||||
|
||||
|
||||
@note This file can be imported both from C and C++ code, so the
|
||||
definitions have to be constructed to support this.
|
||||
*/
|
||||
|
||||
#ifndef BINARY_LOG_TYPES_INCLUDED
|
||||
#define BINARY_LOG_TYPES_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Constants exported from this package.
|
||||
*/
|
||||
|
||||
typedef enum enum_field_types {
|
||||
MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY,
|
||||
MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG,
|
||||
MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE,
|
||||
MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP,
|
||||
MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24,
|
||||
MYSQL_TYPE_DATE, MYSQL_TYPE_TIME,
|
||||
MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR,
|
||||
MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR,
|
||||
MYSQL_TYPE_BIT,
|
||||
MYSQL_TYPE_TIMESTAMP2,
|
||||
MYSQL_TYPE_DATETIME2,
|
||||
MYSQL_TYPE_TIME2,
|
||||
MYSQL_TYPE_JSON=245,
|
||||
MYSQL_TYPE_NEWDECIMAL=246,
|
||||
MYSQL_TYPE_ENUM=247,
|
||||
MYSQL_TYPE_SET=248,
|
||||
MYSQL_TYPE_TINY_BLOB=249,
|
||||
MYSQL_TYPE_MEDIUM_BLOB=250,
|
||||
MYSQL_TYPE_LONG_BLOB=251,
|
||||
MYSQL_TYPE_BLOB=252,
|
||||
MYSQL_TYPE_VAR_STRING=253,
|
||||
MYSQL_TYPE_STRING=254,
|
||||
MYSQL_TYPE_GEOMETRY=255
|
||||
} enum_field_types;
|
||||
|
||||
#define DATETIME_MAX_DECIMALS 6
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* BINARY_LOG_TYPES_INCLUDED */
|
||||
104
demo/kugou/include/Common/include/mysql/byte_order_generic.h
Normal file
104
demo/kugou/include/Common/include/mysql/byte_order_generic.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
Endianness-independent definitions for architectures other
|
||||
than the x86 architecture.
|
||||
*/
|
||||
static inline int16 sint2korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(int16) (((int16) (A[0])) +
|
||||
((int16) (A[1]) << 8))
|
||||
;
|
||||
}
|
||||
|
||||
static inline int32 sint4korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(int32) (((int32) (A[0])) +
|
||||
(((int32) (A[1]) << 8)) +
|
||||
(((int32) (A[2]) << 16)) +
|
||||
(((int32) (A[3]) << 24)))
|
||||
;
|
||||
}
|
||||
|
||||
static inline uint16 uint2korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(uint16) (((uint16) (A[0])) +
|
||||
((uint16) (A[1]) << 8))
|
||||
;
|
||||
}
|
||||
|
||||
static inline uint32 uint4korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(uint32) (((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24))
|
||||
;
|
||||
}
|
||||
|
||||
static inline ulonglong uint8korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((ulonglong)(((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24)) +
|
||||
(((ulonglong) (((uint32) (A[4])) +
|
||||
(((uint32) (A[5])) << 8) +
|
||||
(((uint32) (A[6])) << 16) +
|
||||
(((uint32) (A[7])) << 24))) <<
|
||||
32))
|
||||
;
|
||||
}
|
||||
|
||||
static inline longlong sint8korr(const uchar *A)
|
||||
{
|
||||
return (longlong) uint8korr(A);
|
||||
}
|
||||
|
||||
static inline void int2store(uchar *T, uint16 A)
|
||||
{
|
||||
uint def_temp= A ;
|
||||
*(T)= (uchar)(def_temp);
|
||||
*(T+1)= (uchar)(def_temp >> 8);
|
||||
}
|
||||
|
||||
static inline void int4store(uchar *T, uint32 A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)=(uchar) (A >> 8);
|
||||
*(T+2)=(uchar) (A >> 16);
|
||||
*(T+3)=(uchar) (A >> 24);
|
||||
}
|
||||
|
||||
static inline void int8store(uchar *T, ulonglong A)
|
||||
{
|
||||
uint def_temp= (uint) A,
|
||||
def_temp2= (uint) (A >> 32);
|
||||
int4store(T, def_temp);
|
||||
int4store(T+4,def_temp2);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
Optimized functions for the x86 architecture (_WIN32 included).
|
||||
|
||||
x86 handles misaligned reads and writes just fine, so suppress
|
||||
UBSAN warnings for these functions.
|
||||
*/
|
||||
static inline int16 sint2korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline int16 sint2korr(const uchar *A) { return *((int16*) A); }
|
||||
|
||||
static inline int32 sint4korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline int32 sint4korr(const uchar *A) { return *((int32*) A); }
|
||||
|
||||
static inline uint16 uint2korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline uint16 uint2korr(const uchar *A) { return *((uint16*) A); }
|
||||
|
||||
static inline uint32 uint4korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline uint32 uint4korr(const uchar *A) { return *((uint32*) A); }
|
||||
|
||||
static inline ulonglong uint8korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline ulonglong uint8korr(const uchar *A) { return *((ulonglong*) A);}
|
||||
|
||||
static inline longlong sint8korr(const uchar *A) SUPPRESS_UBSAN;
|
||||
static inline longlong sint8korr(const uchar *A) { return *((longlong*) A); }
|
||||
|
||||
static inline void int2store(uchar *T, uint16 A) SUPPRESS_UBSAN;
|
||||
static inline void int2store(uchar *T, uint16 A)
|
||||
{
|
||||
*((uint16*) T)= A;
|
||||
}
|
||||
|
||||
static inline void int4store(uchar *T, uint32 A) SUPPRESS_UBSAN;
|
||||
static inline void int4store(uchar *T, uint32 A)
|
||||
{
|
||||
*((uint32*) T)= A;
|
||||
}
|
||||
|
||||
static inline void int8store(uchar *T, ulonglong A) SUPPRESS_UBSAN;
|
||||
static inline void int8store(uchar *T, ulonglong A)
|
||||
{
|
||||
*((ulonglong*) T)= A;
|
||||
}
|
||||
144
demo/kugou/include/Common/include/mysql/decimal.h
Normal file
144
demo/kugou/include/Common/include/mysql/decimal.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef DECIMAL_INCLUDED
|
||||
#define DECIMAL_INCLUDED
|
||||
|
||||
typedef enum
|
||||
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
|
||||
decimal_round_mode;
|
||||
typedef int32 decimal_digit_t;
|
||||
|
||||
/**
|
||||
intg is the number of *decimal* digits (NOT number of decimal_digit_t's !)
|
||||
before the point
|
||||
frac is the number of decimal digits after the point
|
||||
len is the length of buf (length of allocated space) in decimal_digit_t's,
|
||||
not in bytes
|
||||
sign false means positive, true means negative
|
||||
buf is an array of decimal_digit_t's
|
||||
*/
|
||||
typedef struct st_decimal_t {
|
||||
int intg, frac, len;
|
||||
my_bool sign;
|
||||
decimal_digit_t *buf;
|
||||
} decimal_t;
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
int internal_str2dec(const char *from, decimal_t *to, char **end,
|
||||
my_bool fixed);
|
||||
int decimal2string(const decimal_t *from, char *to, int *to_len,
|
||||
int fixed_precision, int fixed_decimals,
|
||||
char filler);
|
||||
int decimal2ulonglong(decimal_t *from, ulonglong *to);
|
||||
int ulonglong2decimal(ulonglong from, decimal_t *to);
|
||||
int decimal2longlong(decimal_t *from, longlong *to);
|
||||
int longlong2decimal(longlong from, decimal_t *to);
|
||||
int decimal2double(const decimal_t *from, double *to);
|
||||
int double2decimal(double from, decimal_t *to);
|
||||
int decimal_actual_fraction(decimal_t *from);
|
||||
int decimal2bin(decimal_t *from, uchar *to, int precision, int scale);
|
||||
int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale);
|
||||
|
||||
/**
|
||||
Convert decimal to lldiv_t.
|
||||
The integer part is stored in to->quot.
|
||||
The fractional part is multiplied to 10^9 and stored to to->rem.
|
||||
@param from Decimal value
|
||||
@param to lldiv_t value
|
||||
@retval 0 on success
|
||||
@retval !0 in error
|
||||
*/
|
||||
int decimal2lldiv_t(const decimal_t *from, lldiv_t *to);
|
||||
|
||||
/**
|
||||
Convert doube to lldiv_t.
|
||||
The integer part is stored in to->quot.
|
||||
The fractional part is multiplied to 10^9 and stored to to->rem.
|
||||
@param from Decimal value
|
||||
@param to lldiv_t value
|
||||
@retval 0 on success
|
||||
@retval !0 in error
|
||||
*/
|
||||
|
||||
int double2lldiv_t(double from, lldiv_t *to);
|
||||
int decimal_size(int precision, int scale);
|
||||
int decimal_bin_size(int precision, int scale);
|
||||
int decimal_result_size(decimal_t *from1, decimal_t *from2, char op,
|
||||
int param);
|
||||
|
||||
int decimal_intg(const decimal_t *from);
|
||||
int decimal_add(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_sub(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_cmp(const decimal_t *from1, const decimal_t *from2);
|
||||
int decimal_mul(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_div(const decimal_t *from1, const decimal_t *from2, decimal_t *to,
|
||||
int scale_incr);
|
||||
int decimal_mod(const decimal_t *from1, const decimal_t *from2, decimal_t *to);
|
||||
int decimal_round(const decimal_t *from, decimal_t *to, int new_scale,
|
||||
decimal_round_mode mode);
|
||||
int decimal_is_zero(const decimal_t *from);
|
||||
void max_decimal(int precision, int frac, decimal_t *to);
|
||||
|
||||
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
|
||||
#define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1)
|
||||
|
||||
/* set a decimal_t to zero */
|
||||
|
||||
#define decimal_make_zero(dec) do { \
|
||||
(dec)->buf[0]=0; \
|
||||
(dec)->intg=1; \
|
||||
(dec)->frac=0; \
|
||||
(dec)->sign=0; \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
returns the length of the buffer to hold string representation
|
||||
of the decimal (including decimal dot, possible sign and \0)
|
||||
*/
|
||||
|
||||
#define decimal_string_size(dec) (((dec)->intg ? (dec)->intg : 1) + \
|
||||
(dec)->frac + ((dec)->frac > 0) + 2)
|
||||
|
||||
/*
|
||||
conventions:
|
||||
|
||||
decimal_smth() == 0 -- everything's ok
|
||||
decimal_smth() <= 1 -- result is usable, but precision loss is possible
|
||||
decimal_smth() <= 2 -- result can be unusable, most significant digits
|
||||
could've been lost
|
||||
decimal_smth() > 2 -- no result was generated
|
||||
*/
|
||||
|
||||
#define E_DEC_OK 0
|
||||
#define E_DEC_TRUNCATED 1
|
||||
#define E_DEC_OVERFLOW 2
|
||||
#define E_DEC_DIV_ZERO 4
|
||||
#define E_DEC_BAD_NUM 8
|
||||
#define E_DEC_OOM 16
|
||||
|
||||
#define E_DEC_ERROR 31
|
||||
#define E_DEC_FATAL_ERROR 30
|
||||
|
||||
#endif // !MYSQL_ABI_CHECK
|
||||
|
||||
#endif
|
||||
120
demo/kugou/include/Common/include/mysql/errmsg.h
Normal file
120
demo/kugou/include/Common/include/mysql/errmsg.h
Normal file
@@ -0,0 +1,120 @@
|
||||
#ifndef ERRMSG_INCLUDED
|
||||
#define ERRMSG_INCLUDED
|
||||
|
||||
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
/* Error messages for MySQL clients */
|
||||
/* (Error messages for the daemon are in sql/share/errmsg.txt) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void init_client_errs(void);
|
||||
void finish_client_errs(void);
|
||||
extern const char *client_errors[]; /* Error messages */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CR_MIN_ERROR 2000 /* For easier client code */
|
||||
#define CR_MAX_ERROR 2999
|
||||
#if !defined(ER)
|
||||
#define ER(X) (((X) >= CR_ERROR_FIRST && (X) <= CR_ERROR_LAST)? \
|
||||
client_errors[(X)-CR_ERROR_FIRST]: client_errors[CR_UNKNOWN_ERROR])
|
||||
|
||||
#endif
|
||||
#define CLIENT_ERRMAP 2 /* Errormap used by my_error() */
|
||||
|
||||
/* Do not add error numbers before CR_ERROR_FIRST. */
|
||||
/* If necessary to add lower numbers, change CR_ERROR_FIRST accordingly. */
|
||||
#define CR_ERROR_FIRST 2000 /*Copy first error nr.*/
|
||||
#define CR_UNKNOWN_ERROR 2000
|
||||
#define CR_SOCKET_CREATE_ERROR 2001
|
||||
#define CR_CONNECTION_ERROR 2002
|
||||
#define CR_CONN_HOST_ERROR 2003
|
||||
#define CR_IPSOCK_ERROR 2004
|
||||
#define CR_UNKNOWN_HOST 2005
|
||||
#define CR_SERVER_GONE_ERROR 2006
|
||||
#define CR_VERSION_ERROR 2007
|
||||
#define CR_OUT_OF_MEMORY 2008
|
||||
#define CR_WRONG_HOST_INFO 2009
|
||||
#define CR_LOCALHOST_CONNECTION 2010
|
||||
#define CR_TCP_CONNECTION 2011
|
||||
#define CR_SERVER_HANDSHAKE_ERR 2012
|
||||
#define CR_SERVER_LOST 2013
|
||||
#define CR_COMMANDS_OUT_OF_SYNC 2014
|
||||
#define CR_NAMEDPIPE_CONNECTION 2015
|
||||
#define CR_NAMEDPIPEWAIT_ERROR 2016
|
||||
#define CR_NAMEDPIPEOPEN_ERROR 2017
|
||||
#define CR_NAMEDPIPESETSTATE_ERROR 2018
|
||||
#define CR_CANT_READ_CHARSET 2019
|
||||
#define CR_NET_PACKET_TOO_LARGE 2020
|
||||
#define CR_EMBEDDED_CONNECTION 2021
|
||||
#define CR_PROBE_SLAVE_STATUS 2022
|
||||
#define CR_PROBE_SLAVE_HOSTS 2023
|
||||
#define CR_PROBE_SLAVE_CONNECT 2024
|
||||
#define CR_PROBE_MASTER_CONNECT 2025
|
||||
#define CR_SSL_CONNECTION_ERROR 2026
|
||||
#define CR_MALFORMED_PACKET 2027
|
||||
#define CR_WRONG_LICENSE 2028
|
||||
|
||||
/* new 4.1 error codes */
|
||||
#define CR_NULL_POINTER 2029
|
||||
#define CR_NO_PREPARE_STMT 2030
|
||||
#define CR_PARAMS_NOT_BOUND 2031
|
||||
#define CR_DATA_TRUNCATED 2032
|
||||
#define CR_NO_PARAMETERS_EXISTS 2033
|
||||
#define CR_INVALID_PARAMETER_NO 2034
|
||||
#define CR_INVALID_BUFFER_USE 2035
|
||||
#define CR_UNSUPPORTED_PARAM_TYPE 2036
|
||||
|
||||
#define CR_SHARED_MEMORY_CONNECTION 2037
|
||||
#define CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR 2038
|
||||
#define CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR 2039
|
||||
#define CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR 2040
|
||||
#define CR_SHARED_MEMORY_CONNECT_MAP_ERROR 2041
|
||||
#define CR_SHARED_MEMORY_FILE_MAP_ERROR 2042
|
||||
#define CR_SHARED_MEMORY_MAP_ERROR 2043
|
||||
#define CR_SHARED_MEMORY_EVENT_ERROR 2044
|
||||
#define CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR 2045
|
||||
#define CR_SHARED_MEMORY_CONNECT_SET_ERROR 2046
|
||||
#define CR_CONN_UNKNOW_PROTOCOL 2047
|
||||
#define CR_INVALID_CONN_HANDLE 2048
|
||||
#define CR_UNUSED_1 2049
|
||||
#define CR_FETCH_CANCELED 2050
|
||||
#define CR_NO_DATA 2051
|
||||
#define CR_NO_STMT_METADATA 2052
|
||||
#define CR_NO_RESULT_SET 2053
|
||||
#define CR_NOT_IMPLEMENTED 2054
|
||||
#define CR_SERVER_LOST_EXTENDED 2055
|
||||
#define CR_STMT_CLOSED 2056
|
||||
#define CR_NEW_STMT_METADATA 2057
|
||||
#define CR_ALREADY_CONNECTED 2058
|
||||
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
|
||||
#define CR_DUPLICATE_CONNECTION_ATTR 2060
|
||||
#define CR_AUTH_PLUGIN_ERR 2061
|
||||
#define CR_INSECURE_API_ERR 2062
|
||||
#define CR_ERROR_LAST /*Copy last error nr:*/ 2062
|
||||
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
|
||||
|
||||
#endif /* ERRMSG_INCLUDED */
|
||||
163
demo/kugou/include/Common/include/mysql/keycache.h
Normal file
163
demo/kugou/include/Common/include/mysql/keycache.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
/* Key cache variable structures */
|
||||
|
||||
#ifndef _keycache_h
|
||||
#define _keycache_h
|
||||
|
||||
#include "my_sys.h" /* flush_type */
|
||||
|
||||
C_MODE_START
|
||||
|
||||
/* declare structures that is used by st_key_cache */
|
||||
|
||||
struct st_block_link;
|
||||
typedef struct st_block_link BLOCK_LINK;
|
||||
struct st_hash_link;
|
||||
typedef struct st_hash_link HASH_LINK;
|
||||
|
||||
/* Thread specific variables */
|
||||
typedef struct st_keycache_thread_var
|
||||
{
|
||||
mysql_cond_t suspend;
|
||||
struct st_keycache_thread_var *next,**prev;
|
||||
void *opt_info;
|
||||
} st_keycache_thread_var;
|
||||
|
||||
/* info about requests in a waiting queue */
|
||||
typedef struct st_keycache_wqueue
|
||||
{
|
||||
st_keycache_thread_var *last_thread; /* circular list of waiting threads */
|
||||
} KEYCACHE_WQUEUE;
|
||||
|
||||
#define CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
|
||||
|
||||
/*
|
||||
The key cache structure
|
||||
It also contains read-only statistics parameters.
|
||||
*/
|
||||
|
||||
typedef struct st_key_cache
|
||||
{
|
||||
my_bool key_cache_inited;
|
||||
my_bool in_resize; /* true during resize operation */
|
||||
my_bool resize_in_flush; /* true during flush of resize operation */
|
||||
my_bool can_be_used; /* usage of cache for read/write is allowed */
|
||||
size_t key_cache_mem_size; /* specified size of the cache memory */
|
||||
uint key_cache_block_size; /* size of the page buffer of a cache block */
|
||||
ulonglong min_warm_blocks; /* min number of warm blocks; */
|
||||
ulonglong age_threshold; /* age threshold for hot blocks */
|
||||
ulonglong keycache_time; /* total number of block link operations */
|
||||
uint hash_entries; /* max number of entries in the hash table */
|
||||
int hash_links; /* max number of hash links */
|
||||
int hash_links_used; /* number of hash links currently used */
|
||||
int disk_blocks; /* max number of blocks in the cache */
|
||||
ulong blocks_used; /* maximum number of concurrently used blocks */
|
||||
ulong blocks_unused; /* number of currently unused blocks */
|
||||
ulong blocks_changed; /* number of currently dirty blocks */
|
||||
ulong warm_blocks; /* number of blocks in warm sub-chain */
|
||||
ulong cnt_for_resize_op; /* counter to block resize operation */
|
||||
long blocks_available; /* number of blocks available in the LRU chain */
|
||||
HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
|
||||
HASH_LINK *hash_link_root; /* memory for hash table links */
|
||||
HASH_LINK *free_hash_list; /* list of free hash links */
|
||||
BLOCK_LINK *free_block_list; /* list of free blocks */
|
||||
BLOCK_LINK *block_root; /* memory for block links */
|
||||
uchar *block_mem; /* memory for block buffers */
|
||||
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
|
||||
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
|
||||
mysql_mutex_t cache_lock; /* to lock access to the cache structure */
|
||||
KEYCACHE_WQUEUE resize_queue; /* threads waiting during resize operation */
|
||||
/*
|
||||
Waiting for a zero resize count. Using a queue for symmetry though
|
||||
only one thread can wait here.
|
||||
*/
|
||||
KEYCACHE_WQUEUE waiting_for_resize_cnt;
|
||||
KEYCACHE_WQUEUE waiting_for_hash_link; /* waiting for a free hash link */
|
||||
KEYCACHE_WQUEUE waiting_for_block; /* requests waiting for a free block */
|
||||
BLOCK_LINK *changed_blocks[CHANGED_BLOCKS_HASH]; /* hash for dirty file bl.*/
|
||||
BLOCK_LINK *file_blocks[CHANGED_BLOCKS_HASH]; /* hash for other file bl.*/
|
||||
|
||||
/*
|
||||
The following variables are and variables used to hold parameters for
|
||||
initializing the key cache.
|
||||
*/
|
||||
|
||||
ulonglong param_buff_size; /* size the memory allocated for the cache */
|
||||
ulonglong param_block_size; /* size of the blocks in the key cache */
|
||||
ulonglong param_division_limit; /* min. percentage of warm blocks */
|
||||
ulonglong param_age_threshold; /* determines when hot block is downgraded */
|
||||
|
||||
/* Statistics variables. These are reset in reset_key_cache_counters(). */
|
||||
ulong global_blocks_changed; /* number of currently dirty blocks */
|
||||
ulonglong global_cache_w_requests;/* number of write requests (write hits) */
|
||||
ulonglong global_cache_write; /* number of writes from cache to files */
|
||||
ulonglong global_cache_r_requests;/* number of read requests (read hits) */
|
||||
ulonglong global_cache_read; /* number of reads from files to cache */
|
||||
|
||||
int blocks; /* max number of blocks in the cache */
|
||||
my_bool in_init; /* Set to 1 in MySQL during init/resize */
|
||||
} KEY_CACHE;
|
||||
|
||||
/* The default key cache */
|
||||
extern KEY_CACHE dflt_key_cache_var, *dflt_key_cache;
|
||||
|
||||
extern int init_key_cache(KEY_CACHE *keycache, ulonglong key_cache_block_size,
|
||||
size_t use_mem, ulonglong division_limit,
|
||||
ulonglong age_threshold);
|
||||
extern int resize_key_cache(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
ulonglong key_cache_block_size,
|
||||
size_t use_mem, ulonglong division_limit,
|
||||
ulonglong age_threshold);
|
||||
extern uchar *key_cache_read(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length,int return_buffer);
|
||||
extern int key_cache_insert(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length);
|
||||
extern int key_cache_write(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
File file, my_off_t filepos, int level,
|
||||
uchar *buff, uint length,
|
||||
uint block_length,int force_write);
|
||||
extern int flush_key_blocks(KEY_CACHE *keycache,
|
||||
st_keycache_thread_var *thread_var,
|
||||
int file, enum flush_type type);
|
||||
extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup);
|
||||
|
||||
/* Functions to handle multiple key caches */
|
||||
extern my_bool multi_keycache_init(void);
|
||||
extern void multi_keycache_free(void);
|
||||
extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length);
|
||||
extern my_bool multi_key_cache_set(const uchar *key, uint length,
|
||||
KEY_CACHE *key_cache);
|
||||
extern void multi_key_cache_change(KEY_CACHE *old_data,
|
||||
KEY_CACHE *new_data);
|
||||
extern int reset_key_cache_counters(const char *name,
|
||||
KEY_CACHE *key_cache);
|
||||
C_MODE_END
|
||||
#endif /* _keycache_h */
|
||||
105
demo/kugou/include/Common/include/mysql/little_endian.h
Normal file
105
demo/kugou/include/Common/include/mysql/little_endian.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#ifndef LITTLE_ENDIAN_INCLUDED
|
||||
#define LITTLE_ENDIAN_INCLUDED
|
||||
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
Data in little-endian format.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static inline void float4get (float *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void float4store(uchar *V, float M)
|
||||
{
|
||||
memcpy(V, (&M), sizeof(float));
|
||||
}
|
||||
|
||||
static inline void float8get (double *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, M, sizeof(double));
|
||||
}
|
||||
|
||||
static inline void float8store(uchar *V, double M)
|
||||
{
|
||||
memcpy(V, &M, sizeof(double));
|
||||
}
|
||||
|
||||
static inline void floatget (float *V, const uchar *M) { float4get(V, M); }
|
||||
static inline void floatstore (uchar *V, float M) { float4store(V, M); }
|
||||
|
||||
/* Bi-endian hardware.... */
|
||||
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
|
||||
static inline void doublestore(uchar *T, double V)
|
||||
{ *(((char*)T)+0)=(char) ((uchar *) &V)[4];
|
||||
*(((char*)T)+1)=(char) ((uchar *) &V)[5];
|
||||
*(((char*)T)+2)=(char) ((uchar *) &V)[6];
|
||||
*(((char*)T)+3)=(char) ((uchar *) &V)[7];
|
||||
*(((char*)T)+4)=(char) ((uchar *) &V)[0];
|
||||
*(((char*)T)+5)=(char) ((uchar *) &V)[1];
|
||||
*(((char*)T)+6)=(char) ((uchar *) &V)[2];
|
||||
*(((char*)T)+7)=(char) ((uchar *) &V)[3]; }
|
||||
static inline void doubleget(double *V, const uchar *M)
|
||||
{ double def_temp;
|
||||
((uchar*) &def_temp)[0]=(M)[4];
|
||||
((uchar*) &def_temp)[1]=(M)[5];
|
||||
((uchar*) &def_temp)[2]=(M)[6];
|
||||
((uchar*) &def_temp)[3]=(M)[7];
|
||||
((uchar*) &def_temp)[4]=(M)[0];
|
||||
((uchar*) &def_temp)[5]=(M)[1];
|
||||
((uchar*) &def_temp)[6]=(M)[2];
|
||||
((uchar*) &def_temp)[7]=(M)[3];
|
||||
(*V) = def_temp; }
|
||||
|
||||
#else /* Bi-endian hardware.... */
|
||||
|
||||
static inline void doublestore(uchar *T, double V) { memcpy(T, &V, sizeof(double)); }
|
||||
static inline void doubleget (double *V, const uchar *M) { memcpy(V, M, sizeof(double)); }
|
||||
|
||||
#endif /* Bi-endian hardware.... */
|
||||
|
||||
static inline void ushortget(uint16 *V, const uchar *pM) { *V= uint2korr(pM); }
|
||||
static inline void shortget (int16 *V, const uchar *pM) { *V= sint2korr(pM); }
|
||||
static inline void longget (int32 *V, const uchar *pM) { *V= sint4korr(pM); }
|
||||
static inline void ulongget (uint32 *V, const uchar *pM) { *V= uint4korr(pM); }
|
||||
static inline void shortstore(uchar *T, int16 V) { int2store(T, V); }
|
||||
static inline void longstore (uchar *T, int32 V) { int4store(T, V); }
|
||||
|
||||
static inline void longlongget(longlong *V, const uchar *M)
|
||||
{
|
||||
memcpy(V, (M), sizeof(ulonglong));
|
||||
}
|
||||
static inline void longlongstore(uchar *T, longlong V)
|
||||
{
|
||||
memcpy((T), &V, sizeof(ulonglong));
|
||||
}
|
||||
|
||||
#endif /* LITTLE_ENDIAN_INCLUDED */
|
||||
813
demo/kugou/include/Common/include/mysql/m_ctype.h
Normal file
813
demo/kugou/include/Common/include/mysql/m_ctype.h
Normal file
@@ -0,0 +1,813 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
A better inplementation of the UNIX ctype(3) library.
|
||||
*/
|
||||
|
||||
#ifndef _m_ctype_h
|
||||
#define _m_ctype_h
|
||||
|
||||
#include "my_global.h" /* uint16, uchar */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MY_CS_NAME_SIZE 32
|
||||
#define MY_CS_CTYPE_TABLE_SIZE 257
|
||||
#define MY_CS_TO_LOWER_TABLE_SIZE 256
|
||||
#define MY_CS_TO_UPPER_TABLE_SIZE 256
|
||||
#define MY_CS_SORT_ORDER_TABLE_SIZE 256
|
||||
#define MY_CS_TO_UNI_TABLE_SIZE 256
|
||||
|
||||
#define CHARSET_DIR "charsets/"
|
||||
|
||||
#define my_wc_t ulong
|
||||
|
||||
#define MY_CS_REPLACEMENT_CHARACTER 0xFFFD
|
||||
|
||||
/*
|
||||
On i386 we store Unicode->CS conversion tables for
|
||||
some character sets using Big-endian order,
|
||||
to copy two bytes at onces.
|
||||
This gives some performance improvement.
|
||||
*/
|
||||
#ifdef __i386__
|
||||
#define MB2(x) (((x) >> 8) + (((x) & 0xFF) << 8))
|
||||
#define MY_PUT_MB2(s, code) { *((uint16*)(s))= (code); }
|
||||
#else
|
||||
#define MB2(x) (x)
|
||||
#define MY_PUT_MB2(s, code) { (s)[0]= code >> 8; (s)[1]= code & 0xFF; }
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
typedef struct unicase_info_char_st
|
||||
{
|
||||
uint32 toupper;
|
||||
uint32 tolower;
|
||||
uint32 sort;
|
||||
} MY_UNICASE_CHARACTER;
|
||||
|
||||
|
||||
typedef struct unicase_info_st
|
||||
{
|
||||
my_wc_t maxchar;
|
||||
const MY_UNICASE_CHARACTER **page;
|
||||
} MY_UNICASE_INFO;
|
||||
|
||||
|
||||
extern MY_UNICASE_INFO my_unicase_default;
|
||||
extern MY_UNICASE_INFO my_unicase_turkish;
|
||||
extern MY_UNICASE_INFO my_unicase_mysql500;
|
||||
extern MY_UNICASE_INFO my_unicase_unicode520;
|
||||
|
||||
#define MY_UCA_MAX_CONTRACTION 6
|
||||
#define MY_UCA_MAX_WEIGHT_SIZE 8
|
||||
#define MY_UCA_WEIGHT_LEVELS 1
|
||||
|
||||
typedef struct my_contraction_t
|
||||
{
|
||||
my_wc_t ch[MY_UCA_MAX_CONTRACTION]; /* Character sequence */
|
||||
uint16 weight[MY_UCA_MAX_WEIGHT_SIZE];/* Its weight string, 0-terminated */
|
||||
my_bool with_context;
|
||||
} MY_CONTRACTION;
|
||||
|
||||
|
||||
|
||||
typedef struct my_contraction_list_t
|
||||
{
|
||||
size_t nitems; /* Number of items in the list */
|
||||
MY_CONTRACTION *item; /* List of contractions */
|
||||
char *flags; /* Character flags, e.g. "is contraction head") */
|
||||
} MY_CONTRACTIONS;
|
||||
|
||||
|
||||
my_bool my_uca_can_be_contraction_head(const MY_CONTRACTIONS *c, my_wc_t wc);
|
||||
my_bool my_uca_can_be_contraction_tail(const MY_CONTRACTIONS *c, my_wc_t wc);
|
||||
uint16 *my_uca_contraction2_weight(const MY_CONTRACTIONS *c,
|
||||
my_wc_t wc1, my_wc_t wc2);
|
||||
|
||||
|
||||
/* Collation weights on a single level (e.g. primary, secondary, tertiarty) */
|
||||
typedef struct my_uca_level_info_st
|
||||
{
|
||||
my_wc_t maxchar;
|
||||
uchar *lengths;
|
||||
uint16 **weights;
|
||||
MY_CONTRACTIONS contractions;
|
||||
} MY_UCA_WEIGHT_LEVEL;
|
||||
|
||||
|
||||
typedef struct uca_info_st
|
||||
{
|
||||
MY_UCA_WEIGHT_LEVEL level[MY_UCA_WEIGHT_LEVELS];
|
||||
|
||||
/* Logical positions */
|
||||
my_wc_t first_non_ignorable;
|
||||
my_wc_t last_non_ignorable;
|
||||
my_wc_t first_primary_ignorable;
|
||||
my_wc_t last_primary_ignorable;
|
||||
my_wc_t first_secondary_ignorable;
|
||||
my_wc_t last_secondary_ignorable;
|
||||
my_wc_t first_tertiary_ignorable;
|
||||
my_wc_t last_tertiary_ignorable;
|
||||
my_wc_t first_trailing;
|
||||
my_wc_t last_trailing;
|
||||
my_wc_t first_variable;
|
||||
my_wc_t last_variable;
|
||||
|
||||
} MY_UCA_INFO;
|
||||
|
||||
|
||||
|
||||
extern MY_UCA_INFO my_uca_v400;
|
||||
|
||||
|
||||
typedef struct uni_ctype_st
|
||||
{
|
||||
uchar pctype;
|
||||
uchar *ctype;
|
||||
} MY_UNI_CTYPE;
|
||||
|
||||
extern MY_UNI_CTYPE my_uni_ctype[256];
|
||||
|
||||
/* wm_wc and wc_mb return codes */
|
||||
#define MY_CS_ILSEQ 0 /* Wrong by sequence: wb_wc */
|
||||
#define MY_CS_ILUNI 0 /* Cannot encode Unicode to charset: wc_mb */
|
||||
#define MY_CS_TOOSMALL -101 /* Need at least one byte: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL2 -102 /* Need at least two bytes: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL3 -103 /* Need at least three bytes: wc_mb and mb_wc */
|
||||
/* These following three are currently not really used */
|
||||
#define MY_CS_TOOSMALL4 -104 /* Need at least 4 bytes: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL5 -105 /* Need at least 5 bytes: wc_mb and mb_wc */
|
||||
#define MY_CS_TOOSMALL6 -106 /* Need at least 6 bytes: wc_mb and mb_wc */
|
||||
/* A helper macros for "need at least n bytes" */
|
||||
#define MY_CS_TOOSMALLN(n) (-100-(n))
|
||||
|
||||
#define MY_SEQ_INTTAIL 1
|
||||
#define MY_SEQ_SPACES 2
|
||||
|
||||
/* My charsets_list flags */
|
||||
#define MY_CS_COMPILED 1 /* compiled-in sets */
|
||||
#define MY_CS_CONFIG 2 /* sets that have a *.conf file */
|
||||
#define MY_CS_INDEX 4 /* sets listed in the Index file */
|
||||
#define MY_CS_LOADED 8 /* sets that are currently loaded */
|
||||
#define MY_CS_BINSORT 16 /* if binary sort order */
|
||||
#define MY_CS_PRIMARY 32 /* if primary collation */
|
||||
#define MY_CS_STRNXFRM 64 /* if strnxfrm is used for sort */
|
||||
#define MY_CS_UNICODE 128 /* is a charset is BMP Unicode */
|
||||
#define MY_CS_READY 256 /* if a charset is initialized */
|
||||
#define MY_CS_AVAILABLE 512 /* If either compiled-in or loaded*/
|
||||
#define MY_CS_CSSORT 1024 /* if case sensitive sort order */
|
||||
#define MY_CS_HIDDEN 2048 /* don't display in SHOW */
|
||||
#define MY_CS_PUREASCII 4096 /* if a charset is pure ascii */
|
||||
#define MY_CS_NONASCII 8192 /* if not ASCII-compatible */
|
||||
#define MY_CS_UNICODE_SUPPLEMENT 16384 /* Non-BMP Unicode characters */
|
||||
#define MY_CS_LOWER_SORT 32768 /* If use lower case as weight */
|
||||
#define MY_CHARSET_UNDEFINED 0
|
||||
|
||||
/* Character repertoire flags */
|
||||
#define MY_REPERTOIRE_ASCII 1 /* Pure ASCII U+0000..U+007F */
|
||||
#define MY_REPERTOIRE_EXTENDED 2 /* Extended characters: U+0080..U+FFFF */
|
||||
#define MY_REPERTOIRE_UNICODE30 3 /* ASCII | EXTENDED: U+0000..U+FFFF */
|
||||
|
||||
/* Flags for strxfrm */
|
||||
#define MY_STRXFRM_LEVEL1 0x00000001 /* for primary weights */
|
||||
#define MY_STRXFRM_LEVEL2 0x00000002 /* for secondary weights */
|
||||
#define MY_STRXFRM_LEVEL3 0x00000004 /* for tertiary weights */
|
||||
#define MY_STRXFRM_LEVEL4 0x00000008 /* fourth level weights */
|
||||
#define MY_STRXFRM_LEVEL5 0x00000010 /* fifth level weights */
|
||||
#define MY_STRXFRM_LEVEL6 0x00000020 /* sixth level weights */
|
||||
#define MY_STRXFRM_LEVEL_ALL 0x0000003F /* Bit OR for the above six */
|
||||
#define MY_STRXFRM_NLEVELS 6 /* Number of possible levels*/
|
||||
|
||||
#define MY_STRXFRM_PAD_WITH_SPACE 0x00000040 /* if pad result with spaces */
|
||||
#define MY_STRXFRM_PAD_TO_MAXLEN 0x00000080 /* if pad tail(for filesort) */
|
||||
|
||||
#define MY_STRXFRM_DESC_LEVEL1 0x00000100 /* if desc order for level1 */
|
||||
#define MY_STRXFRM_DESC_LEVEL2 0x00000200 /* if desc order for level2 */
|
||||
#define MY_STRXFRM_DESC_LEVEL3 0x00000300 /* if desc order for level3 */
|
||||
#define MY_STRXFRM_DESC_LEVEL4 0x00000800 /* if desc order for level4 */
|
||||
#define MY_STRXFRM_DESC_LEVEL5 0x00001000 /* if desc order for level5 */
|
||||
#define MY_STRXFRM_DESC_LEVEL6 0x00002000 /* if desc order for level6 */
|
||||
#define MY_STRXFRM_DESC_SHIFT 8
|
||||
|
||||
#define MY_STRXFRM_UNUSED_00004000 0x00004000 /* for future extensions */
|
||||
#define MY_STRXFRM_UNUSED_00008000 0x00008000 /* for future extensions */
|
||||
|
||||
#define MY_STRXFRM_REVERSE_LEVEL1 0x00010000 /* if reverse order for level1 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL2 0x00020000 /* if reverse order for level2 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL3 0x00040000 /* if reverse order for level3 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL4 0x00080000 /* if reverse order for level4 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL5 0x00100000 /* if reverse order for level5 */
|
||||
#define MY_STRXFRM_REVERSE_LEVEL6 0x00200000 /* if reverse order for level6 */
|
||||
#define MY_STRXFRM_REVERSE_SHIFT 16
|
||||
|
||||
|
||||
typedef struct my_uni_idx_st
|
||||
{
|
||||
uint16 from;
|
||||
uint16 to;
|
||||
const uchar *tab;
|
||||
} MY_UNI_IDX;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint beg;
|
||||
uint end;
|
||||
uint mb_len;
|
||||
} my_match_t;
|
||||
|
||||
struct charset_info_st;
|
||||
|
||||
typedef struct my_charset_loader_st
|
||||
{
|
||||
char error[128];
|
||||
void *(*once_alloc)(size_t);
|
||||
void *(*mem_malloc)(size_t);
|
||||
void *(*mem_realloc)(void *, size_t);
|
||||
void (*mem_free)(void *);
|
||||
void (*reporter)(enum loglevel, const char *format, ...);
|
||||
int (*add_collation)(struct charset_info_st *cs);
|
||||
} MY_CHARSET_LOADER;
|
||||
|
||||
|
||||
extern int (*my_string_stack_guard)(int);
|
||||
|
||||
/* See strings/CHARSET_INFO.txt for information about this structure */
|
||||
typedef struct my_collation_handler_st
|
||||
{
|
||||
my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *);
|
||||
/* Collation routines */
|
||||
int (*strnncoll)(const struct charset_info_st *,
|
||||
const uchar *, size_t, const uchar *, size_t, my_bool);
|
||||
int (*strnncollsp)(const struct charset_info_st *,
|
||||
const uchar *, size_t, const uchar *, size_t,
|
||||
my_bool diff_if_only_endspace_difference);
|
||||
size_t (*strnxfrm)(const struct charset_info_st *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
size_t (*strnxfrmlen)(const struct charset_info_st *, size_t);
|
||||
my_bool (*like_range)(const struct charset_info_st *,
|
||||
const char *s, size_t s_length,
|
||||
pchar w_prefix, pchar w_one, pchar w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_len, size_t *max_len);
|
||||
int (*wildcmp)(const struct charset_info_st *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape,int w_one, int w_many);
|
||||
|
||||
int (*strcasecmp)(const struct charset_info_st *, const char *,
|
||||
const char *);
|
||||
|
||||
uint (*instr)(const struct charset_info_st *,
|
||||
const char *b, size_t b_length,
|
||||
const char *s, size_t s_length,
|
||||
my_match_t *match, uint nmatch);
|
||||
|
||||
/* Hash calculation */
|
||||
void (*hash_sort)(const struct charset_info_st *cs, const uchar *key,
|
||||
size_t len, ulong *nr1, ulong *nr2);
|
||||
my_bool (*propagate)(const struct charset_info_st *cs, const uchar *str,
|
||||
size_t len);
|
||||
} MY_COLLATION_HANDLER;
|
||||
|
||||
extern MY_COLLATION_HANDLER my_collation_mb_bin_handler;
|
||||
extern MY_COLLATION_HANDLER my_collation_8bit_bin_handler;
|
||||
extern MY_COLLATION_HANDLER my_collation_8bit_simple_ci_handler;
|
||||
extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler;
|
||||
|
||||
/* Some typedef to make it easy for C++ to make function pointers */
|
||||
typedef int (*my_charset_conv_mb_wc)(const struct charset_info_st *,
|
||||
my_wc_t *, const uchar *, const uchar *);
|
||||
typedef int (*my_charset_conv_wc_mb)(const struct charset_info_st *, my_wc_t,
|
||||
uchar *, uchar *);
|
||||
typedef size_t (*my_charset_conv_case)(const struct charset_info_st *,
|
||||
char *, size_t, char *, size_t);
|
||||
|
||||
|
||||
/* See strings/CHARSET_INFO.txt about information on this structure */
|
||||
typedef struct my_charset_handler_st
|
||||
{
|
||||
my_bool (*init)(struct charset_info_st *, MY_CHARSET_LOADER *loader);
|
||||
/* Multibyte routines */
|
||||
uint (*ismbchar)(const struct charset_info_st *, const char *,
|
||||
const char *);
|
||||
uint (*mbcharlen)(const struct charset_info_st *, uint c);
|
||||
size_t (*numchars)(const struct charset_info_st *, const char *b,
|
||||
const char *e);
|
||||
size_t (*charpos)(const struct charset_info_st *, const char *b,
|
||||
const char *e, size_t pos);
|
||||
size_t (*well_formed_len)(const struct charset_info_st *,
|
||||
const char *b,const char *e,
|
||||
size_t nchars, int *error);
|
||||
size_t (*lengthsp)(const struct charset_info_st *, const char *ptr,
|
||||
size_t length);
|
||||
size_t (*numcells)(const struct charset_info_st *, const char *b,
|
||||
const char *e);
|
||||
|
||||
/* Unicode conversion */
|
||||
my_charset_conv_mb_wc mb_wc;
|
||||
my_charset_conv_wc_mb wc_mb;
|
||||
|
||||
/* CTYPE scanner */
|
||||
int (*ctype)(const struct charset_info_st *cs, int *ctype,
|
||||
const uchar *s, const uchar *e);
|
||||
|
||||
/* Functions for case and sort conversion */
|
||||
size_t (*caseup_str)(const struct charset_info_st *, char *);
|
||||
size_t (*casedn_str)(const struct charset_info_st *, char *);
|
||||
|
||||
my_charset_conv_case caseup;
|
||||
my_charset_conv_case casedn;
|
||||
|
||||
/* Charset dependant snprintf() */
|
||||
size_t (*snprintf)(const struct charset_info_st *, char *to, size_t n,
|
||||
const char *fmt,
|
||||
...) MY_ATTRIBUTE((format(printf, 4, 5)));
|
||||
size_t (*long10_to_str)(const struct charset_info_st *, char *to, size_t n,
|
||||
int radix, long int val);
|
||||
size_t (*longlong10_to_str)(const struct charset_info_st *, char *to,
|
||||
size_t n, int radix, longlong val);
|
||||
|
||||
void (*fill)(const struct charset_info_st *, char *to, size_t len,
|
||||
int fill);
|
||||
|
||||
/* String-to-number conversion routines */
|
||||
long (*strntol)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
ulong (*strntoul)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
longlong (*strntoll)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
ulonglong (*strntoull)(const struct charset_info_st *, const char *s,
|
||||
size_t l, int base, char **e, int *err);
|
||||
double (*strntod)(const struct charset_info_st *, char *s,
|
||||
size_t l, char **e, int *err);
|
||||
longlong (*strtoll10)(const struct charset_info_st *cs,
|
||||
const char *nptr, char **endptr, int *error);
|
||||
ulonglong (*strntoull10rnd)(const struct charset_info_st *cs,
|
||||
const char *str, size_t length,
|
||||
int unsigned_fl,
|
||||
char **endptr, int *error);
|
||||
size_t (*scan)(const struct charset_info_st *, const char *b,
|
||||
const char *e, int sq);
|
||||
} MY_CHARSET_HANDLER;
|
||||
|
||||
extern MY_CHARSET_HANDLER my_charset_8bit_handler;
|
||||
extern MY_CHARSET_HANDLER my_charset_ascii_handler;
|
||||
extern MY_CHARSET_HANDLER my_charset_ucs2_handler;
|
||||
|
||||
|
||||
/*
|
||||
We define this CHARSET_INFO_DEFINED here to prevent a repeat of the
|
||||
typedef in hash.c, which will cause a compiler error.
|
||||
*/
|
||||
#define CHARSET_INFO_DEFINED
|
||||
|
||||
/* See strings/CHARSET_INFO.txt about information on this structure */
|
||||
typedef struct charset_info_st
|
||||
{
|
||||
uint number;
|
||||
uint primary_number;
|
||||
uint binary_number;
|
||||
uint state;
|
||||
const char *csname;
|
||||
const char *name;
|
||||
const char *comment;
|
||||
const char *tailoring;
|
||||
const uchar *ctype;
|
||||
const uchar *to_lower;
|
||||
const uchar *to_upper;
|
||||
const uchar *sort_order;
|
||||
MY_UCA_INFO *uca; /* This can be changed in apply_one_rule() */
|
||||
const uint16 *tab_to_uni;
|
||||
const MY_UNI_IDX *tab_from_uni;
|
||||
const MY_UNICASE_INFO *caseinfo;
|
||||
const struct lex_state_maps_st *state_maps; /* parser internal data */
|
||||
const uchar *ident_map; /* parser internal data */
|
||||
uint strxfrm_multiply;
|
||||
uchar caseup_multiply;
|
||||
uchar casedn_multiply;
|
||||
uint mbminlen;
|
||||
uint mbmaxlen;
|
||||
uint mbmaxlenlen;
|
||||
my_wc_t min_sort_char;
|
||||
my_wc_t max_sort_char; /* For LIKE optimization */
|
||||
uchar pad_char;
|
||||
my_bool escape_with_backslash_is_dangerous;
|
||||
uchar levels_for_compare;
|
||||
uchar levels_for_order;
|
||||
|
||||
MY_CHARSET_HANDLER *cset;
|
||||
MY_COLLATION_HANDLER *coll;
|
||||
|
||||
} CHARSET_INFO;
|
||||
#define ILLEGAL_CHARSET_INFO_NUMBER (~0U)
|
||||
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename;
|
||||
|
||||
extern CHARSET_INFO my_charset_big5_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_big5_bin;
|
||||
extern CHARSET_INFO my_charset_cp932_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_cp932_bin;
|
||||
extern CHARSET_INFO my_charset_cp1250_czech_ci;
|
||||
extern CHARSET_INFO my_charset_eucjpms_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_eucjpms_bin;
|
||||
extern CHARSET_INFO my_charset_euckr_korean_ci;
|
||||
extern CHARSET_INFO my_charset_euckr_bin;
|
||||
extern CHARSET_INFO my_charset_gb2312_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_gb2312_bin;
|
||||
extern CHARSET_INFO my_charset_gbk_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_gbk_bin;
|
||||
extern CHARSET_INFO my_charset_gb18030_chinese_ci;
|
||||
extern CHARSET_INFO my_charset_gb18030_bin;
|
||||
extern CHARSET_INFO my_charset_latin1_german2_ci;
|
||||
extern CHARSET_INFO my_charset_latin1_bin;
|
||||
extern CHARSET_INFO my_charset_latin2_czech_ci;
|
||||
extern CHARSET_INFO my_charset_sjis_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_sjis_bin;
|
||||
extern CHARSET_INFO my_charset_tis620_thai_ci;
|
||||
extern CHARSET_INFO my_charset_tis620_bin;
|
||||
extern CHARSET_INFO my_charset_ucs2_general_ci;
|
||||
extern CHARSET_INFO my_charset_ucs2_bin;
|
||||
extern CHARSET_INFO my_charset_ucs2_unicode_ci;
|
||||
extern CHARSET_INFO my_charset_ucs2_general_mysql500_ci;
|
||||
extern CHARSET_INFO my_charset_ujis_japanese_ci;
|
||||
extern CHARSET_INFO my_charset_ujis_bin;
|
||||
extern CHARSET_INFO my_charset_utf16_bin;
|
||||
extern CHARSET_INFO my_charset_utf16_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf16_unicode_ci;
|
||||
extern CHARSET_INFO my_charset_utf16le_bin;
|
||||
extern CHARSET_INFO my_charset_utf16le_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf32_bin;
|
||||
extern CHARSET_INFO my_charset_utf32_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf32_unicode_ci;
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf8_tolower_ci;
|
||||
extern CHARSET_INFO my_charset_utf8_unicode_ci;
|
||||
extern CHARSET_INFO my_charset_utf8_bin;
|
||||
extern CHARSET_INFO my_charset_utf8_general_mysql500_ci;
|
||||
extern CHARSET_INFO my_charset_utf8mb4_bin;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_general_ci;
|
||||
extern CHARSET_INFO my_charset_utf8mb4_unicode_ci;
|
||||
#define MY_UTF8MB3 "utf8"
|
||||
#define MY_UTF8MB4 "utf8mb4"
|
||||
|
||||
|
||||
/* declarations for simple charsets */
|
||||
extern size_t my_strnxfrm_simple(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
size_t my_strnxfrmlen_simple(const CHARSET_INFO *, size_t);
|
||||
extern int my_strnncoll_simple(const CHARSET_INFO *, const uchar *, size_t,
|
||||
const uchar *, size_t, my_bool);
|
||||
|
||||
extern int my_strnncollsp_simple(const CHARSET_INFO *, const uchar *, size_t,
|
||||
const uchar *, size_t,
|
||||
my_bool diff_if_only_endspace_difference);
|
||||
|
||||
extern void my_hash_sort_simple(const CHARSET_INFO *cs,
|
||||
const uchar *key, size_t len,
|
||||
ulong *nr1, ulong *nr2);
|
||||
|
||||
extern size_t my_lengthsp_8bit(const CHARSET_INFO *cs, const char *ptr,
|
||||
size_t length);
|
||||
|
||||
extern uint my_instr_simple(const struct charset_info_st *,
|
||||
const char *b, size_t b_length,
|
||||
const char *s, size_t s_length,
|
||||
my_match_t *match, uint nmatch);
|
||||
|
||||
|
||||
/* Functions for 8bit */
|
||||
extern size_t my_caseup_str_8bit(const CHARSET_INFO *, char *);
|
||||
extern size_t my_casedn_str_8bit(const CHARSET_INFO *, char *);
|
||||
extern size_t my_caseup_8bit(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_8bit(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
|
||||
extern int my_strcasecmp_8bit(const CHARSET_INFO * cs, const char *,
|
||||
const char *);
|
||||
|
||||
int my_mb_wc_8bit(const CHARSET_INFO *cs,my_wc_t *wc, const uchar *s,
|
||||
const uchar *e);
|
||||
int my_wc_mb_8bit(const CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e);
|
||||
|
||||
int my_mb_ctype_8bit(const CHARSET_INFO *,int *, const uchar *,const uchar *);
|
||||
int my_mb_ctype_mb(const CHARSET_INFO *,int *, const uchar *,const uchar *);
|
||||
|
||||
size_t my_scan_8bit(const CHARSET_INFO *cs, const char *b, const char *e,
|
||||
int sq);
|
||||
|
||||
size_t my_snprintf_8bit(const struct charset_info_st *, char *to, size_t n,
|
||||
const char *fmt, ...)
|
||||
MY_ATTRIBUTE((format(printf, 4, 5)));
|
||||
|
||||
long my_strntol_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
ulong my_strntoul_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
longlong my_strntoll_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
ulonglong my_strntoull_8bit(const CHARSET_INFO *, const char *s, size_t l,
|
||||
int base, char **e, int *err);
|
||||
double my_strntod_8bit(const CHARSET_INFO *, char *s, size_t l, char **e,
|
||||
int *err);
|
||||
size_t my_long10_to_str_8bit(const CHARSET_INFO *, char *to, size_t l,
|
||||
int radix, long int val);
|
||||
size_t my_longlong10_to_str_8bit(const CHARSET_INFO *, char *to, size_t l,
|
||||
int radix, longlong val);
|
||||
|
||||
longlong my_strtoll10_8bit(const CHARSET_INFO *cs,
|
||||
const char *nptr, char **endptr, int *error);
|
||||
longlong my_strtoll10_ucs2(const CHARSET_INFO *cs,
|
||||
const char *nptr, char **endptr, int *error);
|
||||
|
||||
ulonglong my_strntoull10rnd_8bit(const CHARSET_INFO *cs,
|
||||
const char *str, size_t length, int
|
||||
unsigned_fl, char **endptr, int *error);
|
||||
ulonglong my_strntoull10rnd_ucs2(const CHARSET_INFO *cs,
|
||||
const char *str, size_t length,
|
||||
int unsigned_fl, char **endptr, int *error);
|
||||
|
||||
void my_fill_8bit(const CHARSET_INFO *cs, char* to, size_t l, int fill);
|
||||
|
||||
/* For 8-bit character set */
|
||||
my_bool my_like_range_simple(const CHARSET_INFO *cs,
|
||||
const char *ptr, size_t ptr_length,
|
||||
pbool escape, pbool w_one, pbool w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_length, size_t *max_length);
|
||||
|
||||
/* For ASCII-based multi-byte character sets with mbminlen=1 */
|
||||
my_bool my_like_range_mb(const CHARSET_INFO *cs,
|
||||
const char *ptr, size_t ptr_length,
|
||||
pbool escape, pbool w_one, pbool w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_length, size_t *max_length);
|
||||
|
||||
/* For other character sets, with arbitrary mbminlen and mbmaxlen numbers */
|
||||
my_bool my_like_range_generic(const CHARSET_INFO *cs,
|
||||
const char *ptr, size_t ptr_length,
|
||||
pbool escape, pbool w_one, pbool w_many,
|
||||
size_t res_length,
|
||||
char *min_str, char *max_str,
|
||||
size_t *min_length, size_t *max_length);
|
||||
|
||||
int my_wildcmp_8bit(const CHARSET_INFO *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
|
||||
int my_wildcmp_bin(const CHARSET_INFO *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
|
||||
size_t my_numchars_8bit(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_numcells_8bit(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_charpos_8bit(const CHARSET_INFO *, const char *b, const char *e,
|
||||
size_t pos);
|
||||
size_t my_well_formed_len_8bit(const CHARSET_INFO *, const char *b,
|
||||
const char *e, size_t pos, int *error);
|
||||
uint my_mbcharlen_8bit(const CHARSET_INFO *, uint c);
|
||||
|
||||
|
||||
/* Functions for multibyte charsets */
|
||||
extern size_t my_caseup_str_mb(const CHARSET_INFO *, char *);
|
||||
extern size_t my_casedn_str_mb(const CHARSET_INFO *, char *);
|
||||
extern size_t my_caseup_mb(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_mb(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_caseup_mb_varlen(const CHARSET_INFO *, char *src,
|
||||
size_t srclen, char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_mb_varlen(const CHARSET_INFO *, char *src,
|
||||
size_t srclen, char *dst, size_t dstlen);
|
||||
extern size_t my_caseup_ujis(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern size_t my_casedn_ujis(const CHARSET_INFO *, char *src, size_t srclen,
|
||||
char *dst, size_t dstlen);
|
||||
extern int my_strcasecmp_mb(const CHARSET_INFO * cs,const char *,
|
||||
const char *);
|
||||
|
||||
int my_wildcmp_mb(const CHARSET_INFO *,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
size_t my_numchars_mb(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_numcells_mb(const CHARSET_INFO *, const char *b, const char *e);
|
||||
size_t my_charpos_mb(const CHARSET_INFO *, const char *b, const char *e,
|
||||
size_t pos);
|
||||
size_t my_well_formed_len_mb(const CHARSET_INFO *, const char *b,
|
||||
const char *e, size_t pos, int *error);
|
||||
uint my_instr_mb(const struct charset_info_st *,
|
||||
const char *b, size_t b_length,
|
||||
const char *s, size_t s_length,
|
||||
my_match_t *match, uint nmatch);
|
||||
|
||||
int my_strnncoll_mb_bin(const CHARSET_INFO * cs,
|
||||
const uchar *s, size_t slen,
|
||||
const uchar *t, size_t tlen,
|
||||
my_bool t_is_prefix);
|
||||
|
||||
int my_strnncollsp_mb_bin(const CHARSET_INFO *cs,
|
||||
const uchar *a, size_t a_length,
|
||||
const uchar *b, size_t b_length,
|
||||
my_bool diff_if_only_endspace_difference);
|
||||
|
||||
int my_wildcmp_mb_bin(const CHARSET_INFO *cs,
|
||||
const char *str,const char *str_end,
|
||||
const char *wildstr,const char *wildend,
|
||||
int escape, int w_one, int w_many);
|
||||
|
||||
int my_strcasecmp_mb_bin(const CHARSET_INFO * cs MY_ATTRIBUTE((unused)),
|
||||
const char *s, const char *t);
|
||||
|
||||
void my_hash_sort_mb_bin(const CHARSET_INFO *cs MY_ATTRIBUTE((unused)),
|
||||
const uchar *key, size_t len,ulong *nr1, ulong *nr2);
|
||||
|
||||
size_t my_strnxfrm_mb(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
|
||||
size_t my_strnxfrm_unicode(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
|
||||
size_t my_strnxfrm_unicode_full_bin(const CHARSET_INFO *,
|
||||
uchar *dst, size_t dstlen, uint nweights,
|
||||
const uchar *src, size_t srclen, uint flags);
|
||||
size_t my_strnxfrmlen_unicode_full_bin(const CHARSET_INFO *, size_t);
|
||||
|
||||
int my_wildcmp_unicode(const CHARSET_INFO *cs,
|
||||
const char *str, const char *str_end,
|
||||
const char *wildstr, const char *wildend,
|
||||
int escape, int w_one, int w_many,
|
||||
const MY_UNICASE_INFO *weights);
|
||||
|
||||
extern my_bool my_parse_charset_xml(MY_CHARSET_LOADER *loader,
|
||||
const char *buf, size_t buflen);
|
||||
extern char *my_strchr(const CHARSET_INFO *cs, const char *str,
|
||||
const char *end, pchar c);
|
||||
extern size_t my_strcspn(const CHARSET_INFO *cs, const char *str,
|
||||
const char *end, const char *reject,
|
||||
size_t reject_length);
|
||||
|
||||
my_bool my_propagate_simple(const CHARSET_INFO *cs, const uchar *str,
|
||||
size_t len);
|
||||
my_bool my_propagate_complex(const CHARSET_INFO *cs, const uchar *str,
|
||||
size_t len);
|
||||
|
||||
|
||||
uint my_string_repertoire(const CHARSET_INFO *cs, const char *str, size_t len);
|
||||
my_bool my_charset_is_ascii_based(const CHARSET_INFO *cs);
|
||||
my_bool my_charset_is_8bit_pure_ascii(const CHARSET_INFO *cs);
|
||||
uint my_charset_repertoire(const CHARSET_INFO *cs);
|
||||
|
||||
|
||||
uint my_strxfrm_flag_normalize(uint flags, uint nlevels);
|
||||
void my_strxfrm_desc_and_reverse(uchar *str, uchar *strend,
|
||||
uint flags, uint level);
|
||||
size_t my_strxfrm_pad_desc_and_reverse(const CHARSET_INFO *cs,
|
||||
uchar *str, uchar *frmend, uchar *strend,
|
||||
uint nweights, uint flags, uint level);
|
||||
|
||||
my_bool my_charset_is_ascii_compatible(const CHARSET_INFO *cs);
|
||||
|
||||
const MY_CONTRACTIONS *my_charset_get_contractions(const CHARSET_INFO *cs,
|
||||
int level);
|
||||
|
||||
extern size_t my_vsnprintf_ex(const CHARSET_INFO *cs, char *to, size_t n,
|
||||
const char* fmt, va_list ap);
|
||||
|
||||
size_t my_convert(char *to, size_t to_length, const CHARSET_INFO *to_cs,
|
||||
const char *from, size_t from_length,
|
||||
const CHARSET_INFO *from_cs, uint *errors);
|
||||
|
||||
uint my_mbcharlen_ptr(const CHARSET_INFO *cs, const char *s, const char *e);
|
||||
|
||||
#define _MY_U 01 /* Upper case */
|
||||
#define _MY_L 02 /* Lower case */
|
||||
#define _MY_NMR 04 /* Numeral (digit) */
|
||||
#define _MY_SPC 010 /* Spacing character */
|
||||
#define _MY_PNT 020 /* Punctuation */
|
||||
#define _MY_CTR 040 /* Control character */
|
||||
#define _MY_B 0100 /* Blank */
|
||||
#define _MY_X 0200 /* heXadecimal digit */
|
||||
|
||||
|
||||
#define my_isascii(c) (!((c) & ~0177))
|
||||
#define my_toascii(c) ((c) & 0177)
|
||||
#define my_tocntrl(c) ((c) & 31)
|
||||
#define my_toprint(c) ((c) | 64)
|
||||
#define my_toupper(s,c) (char) ((s)->to_upper[(uchar) (c)])
|
||||
#define my_tolower(s,c) (char) ((s)->to_lower[(uchar) (c)])
|
||||
#define my_isalpha(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L))
|
||||
#define my_isupper(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_U)
|
||||
#define my_islower(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_L)
|
||||
#define my_isdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_NMR)
|
||||
#define my_isxdigit(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_X)
|
||||
#define my_isalnum(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_U | _MY_L | _MY_NMR))
|
||||
#define my_isspace(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_SPC)
|
||||
#define my_ispunct(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_PNT)
|
||||
#define my_isprint(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR | _MY_B))
|
||||
#define my_isgraph(s, c) (((s)->ctype+1)[(uchar) (c)] & (_MY_PNT | _MY_U | _MY_L | _MY_NMR))
|
||||
#define my_iscntrl(s, c) (((s)->ctype+1)[(uchar) (c)] & _MY_CTR)
|
||||
|
||||
/* Some macros that should be cleaned up a little */
|
||||
#define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_')
|
||||
#define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_')
|
||||
|
||||
#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT)
|
||||
#define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM)
|
||||
#define my_strnxfrm(cs, d, dl, s, sl) \
|
||||
((cs)->coll->strnxfrm((cs), (d), (dl), (dl), (s), (sl), MY_STRXFRM_PAD_WITH_SPACE))
|
||||
#define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d), 0))
|
||||
#define my_like_range(s, a, b, c, d, e, f, g, h, i, j) \
|
||||
((s)->coll->like_range((s), (a), (b), (c), (d), (e), (f), (g), (h), (i), (j)))
|
||||
#define my_wildcmp(cs,s,se,w,we,e,o,m) ((cs)->coll->wildcmp((cs),(s),(se),(w),(we),(e),(o),(m)))
|
||||
#define my_strcasecmp(s, a, b) ((s)->coll->strcasecmp((s), (a), (b)))
|
||||
#define my_charpos(cs, b, e, num) (cs)->cset->charpos((cs), (const char*) (b), (const char *)(e), (num))
|
||||
|
||||
|
||||
#define use_mb(s) ((s)->cset->ismbchar != NULL)
|
||||
#define my_ismbchar(s, a, b) ((s)->cset->ismbchar((s), (a), (b)))
|
||||
#define my_mbcharlen(s, a) ((s)->cset->mbcharlen((s),(a)))
|
||||
/**
|
||||
Get the length of gb18030 code by the given two leading bytes
|
||||
|
||||
@param[in] s charset_info
|
||||
@param[in] a first byte of gb18030 code
|
||||
@param[in] b second byte of gb18030 code
|
||||
@return the length of gb18030 code starting with given two bytes,
|
||||
the length would be 2 or 4 for valid gb18030 code,
|
||||
or 0 for invalid gb18030 code
|
||||
*/
|
||||
#define my_mbcharlen_2(s, a, b) ((s)->cset->mbcharlen((s),((((a) & 0xFF) << 8) + ((b) & 0xFF))))
|
||||
/**
|
||||
Get the maximum length of leading bytes needed to determine the length of a
|
||||
multi-byte gb18030 code
|
||||
|
||||
@param[in] s charset_info
|
||||
@return number of leading bytes we need, would be 2 for gb18030
|
||||
and 1 for all other charsets
|
||||
*/
|
||||
#define my_mbmaxlenlen(s) ((s)->mbmaxlenlen)
|
||||
/**
|
||||
Judge if the given byte is a possible leading byte for a charset.
|
||||
For gb18030 whose mbmaxlenlen is 2, we can't determine the length of
|
||||
a multi-byte character by looking at the first byte only
|
||||
|
||||
@param[in] s charset_info
|
||||
@param[in] i possible leading byte
|
||||
@return true if it is, otherwise false
|
||||
*/
|
||||
#define my_ismb1st(s, i) \
|
||||
(my_mbcharlen((s), (i)) > 1 || \
|
||||
(my_mbmaxlenlen((s)) == 2 && my_mbcharlen((s), (i)) == 0))
|
||||
|
||||
#define my_caseup_str(s, a) ((s)->cset->caseup_str((s), (a)))
|
||||
#define my_casedn_str(s, a) ((s)->cset->casedn_str((s), (a)))
|
||||
#define my_strntol(s, a, b, c, d, e) ((s)->cset->strntol((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntoul(s, a, b, c, d, e) ((s)->cset->strntoul((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntoll(s, a, b, c, d, e) ((s)->cset->strntoll((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
|
||||
#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _m_ctype_h */
|
||||
348
demo/kugou/include/Common/include/mysql/m_string.h
Normal file
348
demo/kugou/include/Common/include/mysql/m_string.h
Normal file
@@ -0,0 +1,348 @@
|
||||
/*
|
||||
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _m_string_h
|
||||
#define _m_string_h
|
||||
|
||||
#include "my_global.h" /* HAVE_* */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define bfill please_use_memset_rather_than_bfill
|
||||
#define bzero please_use_memset_rather_than_bzero
|
||||
#define bmove please_use_memmove_rather_than_bmove
|
||||
#define strmov please_use_my_stpcpy_or_my_stpmov_rather_than_strmov
|
||||
#define strnmov please_use_my_stpncpy_or_my_stpnmov_rather_than_strnmov
|
||||
|
||||
#include "mysql/service_my_snprintf.h"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
my_str_malloc(), my_str_realloc() and my_str_free() are assigned to
|
||||
implementations in strings/alloc.c, but can be overridden in
|
||||
the calling program.
|
||||
*/
|
||||
extern void *(*my_str_malloc)(size_t);
|
||||
extern void *(*my_str_realloc)(void *, size_t);
|
||||
extern void (*my_str_free)(void *);
|
||||
|
||||
/* Declared in int2str() */
|
||||
extern char _dig_vec_upper[];
|
||||
extern char _dig_vec_lower[];
|
||||
|
||||
/* Prototypes for string functions */
|
||||
|
||||
extern void bchange(uchar *dst,size_t old_len,const uchar *src,
|
||||
size_t new_len,size_t tot_len);
|
||||
extern void strappend(char *s,size_t len,pchar fill);
|
||||
extern char *strend(const char *s);
|
||||
extern char *strcend(const char *, pchar);
|
||||
extern char *strfill(char * s,size_t len,pchar fill);
|
||||
extern char *strmake(char *dst,const char *src,size_t length);
|
||||
|
||||
extern char *my_stpmov(char *dst,const char *src);
|
||||
extern char *my_stpnmov(char *dst, const char *src, size_t n);
|
||||
extern char *strcont(const char *src, const char *set);
|
||||
extern char *strxmov(char *dst, const char *src, ...);
|
||||
extern char *strxnmov(char *dst, size_t len, const char *src, ...);
|
||||
|
||||
/**
|
||||
Copy a string from src to dst until (and including) terminating null byte.
|
||||
|
||||
@param dst Destination
|
||||
@param src Source
|
||||
|
||||
@note src and dst cannot overlap.
|
||||
Use my_stpmov() if src and dst overlaps.
|
||||
|
||||
@note Unsafe, consider using my_stpnpy() instead.
|
||||
|
||||
@return pointer to terminating null byte.
|
||||
*/
|
||||
static inline char *my_stpcpy(char *dst, const char *src)
|
||||
{
|
||||
#if defined(HAVE_BUILTIN_STPCPY)
|
||||
return __builtin_stpcpy(dst, src);
|
||||
#elif defined(HAVE_STPCPY)
|
||||
return stpcpy(dst, src);
|
||||
#else
|
||||
/* Fallback to implementation supporting overlap. */
|
||||
return my_stpmov(dst, src);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Copy fixed-size string from src to dst.
|
||||
|
||||
@param dst Destination
|
||||
@param src Source
|
||||
@param n Maximum number of characters to copy.
|
||||
|
||||
@note src and dst cannot overlap
|
||||
Use my_stpnmov() if src and dst overlaps.
|
||||
|
||||
@return pointer to terminating null byte.
|
||||
*/
|
||||
static inline char *my_stpncpy(char *dst, const char *src, size_t n)
|
||||
{
|
||||
#if defined(HAVE_STPNCPY)
|
||||
return stpncpy(dst, src, n);
|
||||
#else
|
||||
/* Fallback to implementation supporting overlap. */
|
||||
return my_stpnmov(dst, src, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline longlong my_strtoll(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _strtoi64(nptr, endptr, base);
|
||||
#else
|
||||
return strtoll(nptr, endptr, base);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline ulonglong my_strtoull(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _strtoui64(nptr, endptr, base);
|
||||
#else
|
||||
return strtoull(nptr, endptr, base);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline char *my_strtok_r(char *str, const char *delim, char **saveptr)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return strtok_s(str, delim, saveptr);
|
||||
#else
|
||||
return strtok_r(str, delim, saveptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* native_ rather than my_ since my_strcasecmp already exists */
|
||||
static inline int native_strcasecmp(const char *s1, const char *s2)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _stricmp(s1, s2);
|
||||
#else
|
||||
return strcasecmp(s1, s2);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* native_ rather than my_ for consistency with native_strcasecmp */
|
||||
static inline int native_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
#if defined _WIN32
|
||||
return _strnicmp(s1, s2, n);
|
||||
#else
|
||||
return strncasecmp(s1, s2, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Prototypes of normal stringfunctions (with may ours) */
|
||||
#ifndef HAVE_STRNLEN
|
||||
extern size_t strnlen(const char *s, size_t n);
|
||||
#endif
|
||||
|
||||
extern int is_prefix(const char *, const char *);
|
||||
|
||||
/* Conversion routines */
|
||||
typedef enum {
|
||||
MY_GCVT_ARG_FLOAT,
|
||||
MY_GCVT_ARG_DOUBLE
|
||||
} my_gcvt_arg_type;
|
||||
|
||||
double my_strtod(const char *str, char **end, int *error);
|
||||
double my_atof(const char *nptr);
|
||||
size_t my_fcvt(double x, int precision, char *to, my_bool *error);
|
||||
size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
|
||||
my_bool *error);
|
||||
|
||||
#define NOT_FIXED_DEC 31
|
||||
|
||||
/*
|
||||
The longest string my_fcvt can return is 311 + "precision" bytes.
|
||||
Here we assume that we never cal my_fcvt() with precision >= NOT_FIXED_DEC
|
||||
(+ 1 byte for the terminating '\0').
|
||||
*/
|
||||
#define FLOATING_POINT_BUFFER (311 + NOT_FIXED_DEC)
|
||||
|
||||
/*
|
||||
We want to use the 'e' format in some cases even if we have enough space
|
||||
for the 'f' one just to mimic sprintf("%.15g") behavior for large integers,
|
||||
and to improve it for numbers < 10^(-4).
|
||||
That is, for |x| < 1 we require |x| >= 10^(-15), and for |x| > 1 we require
|
||||
it to be integer and be <= 10^DBL_DIG for the 'f' format to be used.
|
||||
We don't lose precision, but make cases like "1e200" or "0.00001" look nicer.
|
||||
*/
|
||||
#define MAX_DECPT_FOR_F_FORMAT DBL_DIG
|
||||
|
||||
/*
|
||||
The maximum possible field width for my_gcvt() conversion.
|
||||
(DBL_DIG + 2) significant digits + sign + "." + ("e-NNN" or
|
||||
MAX_DECPT_FOR_F_FORMAT zeros for cases when |x|<1 and the 'f' format is used).
|
||||
*/
|
||||
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + MY_MAX(5, MAX_DECPT_FOR_F_FORMAT)) \
|
||||
|
||||
extern char *llstr(longlong value,char *buff);
|
||||
extern char *ullstr(longlong value,char *buff);
|
||||
|
||||
extern char *int2str(long val, char *dst, int radix, int upcase);
|
||||
extern char *int10_to_str(long val,char *dst,int radix);
|
||||
extern char *str2int(const char *src,int radix,long lower,long upper,
|
||||
long *val);
|
||||
longlong my_strtoll10(const char *nptr, char **endptr, int *error);
|
||||
#if SIZEOF_LONG == SIZEOF_LONG_LONG
|
||||
#define ll2str(A,B,C,D) int2str((A),(B),(C),(D))
|
||||
#define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
|
||||
#undef strtoll
|
||||
#define strtoll(A,B,C) strtol((A),(B),(C))
|
||||
#define strtoull(A,B,C) strtoul((A),(B),(C))
|
||||
#else
|
||||
extern char *ll2str(longlong val,char *dst,int radix, int upcase);
|
||||
extern char *longlong10_to_str(longlong val,char *dst,int radix);
|
||||
#endif
|
||||
#define longlong2str(A,B,C) ll2str((A),(B),(C),1)
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
LEX_STRING -- a pair of a C-string and its length.
|
||||
(it's part of the plugin API as a MYSQL_LEX_STRING)
|
||||
Ditto LEX_CSTRING/MYSQL_LEX_CSTRING.
|
||||
*/
|
||||
|
||||
#include <mysql/mysql_lex_string.h>
|
||||
typedef struct st_mysql_lex_string LEX_STRING;
|
||||
typedef struct st_mysql_const_lex_string LEX_CSTRING;
|
||||
|
||||
#define STRING_WITH_LEN(X) (X), ((sizeof(X) - 1))
|
||||
#define USTRING_WITH_LEN(X) ((uchar*) X), ((sizeof(X) - 1))
|
||||
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((sizeof(X) - 1))
|
||||
|
||||
|
||||
/**
|
||||
Skip trailing space.
|
||||
|
||||
On most systems reading memory in larger chunks (ideally equal to the size of
|
||||
the chinks that the machine physically reads from memory) causes fewer memory
|
||||
access loops and hence increased performance.
|
||||
This is why the 'int' type is used : it's closest to that (according to how
|
||||
it's defined in C).
|
||||
So when we determine the amount of whitespace at the end of a string we do
|
||||
the following :
|
||||
1. We divide the string into 3 zones :
|
||||
a) from the start of the string (__start) to the first multiple
|
||||
of sizeof(int) (__start_words)
|
||||
b) from the end of the string (__end) to the last multiple of sizeof(int)
|
||||
(__end_words)
|
||||
c) a zone that is aligned to sizeof(int) and can be safely accessed
|
||||
through an int *
|
||||
2. We start comparing backwards from (c) char-by-char. If all we find is
|
||||
space then we continue
|
||||
3. If there are elements in zone (b) we compare them as unsigned ints to a
|
||||
int mask (SPACE_INT) consisting of all spaces
|
||||
4. Finally we compare the remaining part (a) of the string char by char.
|
||||
This covers for the last non-space unsigned int from 3. (if any)
|
||||
|
||||
This algorithm works well for relatively larger strings, but it will slow
|
||||
the things down for smaller strings (because of the additional calculations
|
||||
and checks compared to the naive method). Thus the barrier of length 20
|
||||
is added.
|
||||
|
||||
@param ptr pointer to the input string
|
||||
@param len the length of the string
|
||||
@return the last non-space character
|
||||
*/
|
||||
#if defined(__sparc) || defined(__sparcv9)
|
||||
static inline const uchar *skip_trailing_space(const uchar *ptr,size_t len)
|
||||
{
|
||||
/* SPACE_INT is a word that contains only spaces */
|
||||
#if SIZEOF_INT == 4
|
||||
const unsigned SPACE_INT= 0x20202020U;
|
||||
#elif SIZEOF_INT == 8
|
||||
const unsigned SPACE_INT= 0x2020202020202020ULL;
|
||||
#else
|
||||
#error define the appropriate constant for a word full of spaces
|
||||
#endif
|
||||
|
||||
const uchar *end= ptr + len;
|
||||
|
||||
if (len > 20)
|
||||
{
|
||||
const uchar *end_words= (const uchar *)(intptr)
|
||||
(((ulonglong)(intptr)end) / SIZEOF_INT * SIZEOF_INT);
|
||||
const uchar *start_words= (const uchar *)(intptr)
|
||||
((((ulonglong)(intptr)ptr) + SIZEOF_INT - 1) / SIZEOF_INT * SIZEOF_INT);
|
||||
|
||||
DBUG_ASSERT(end_words > ptr);
|
||||
while (end > end_words && end[-1] == 0x20)
|
||||
end--;
|
||||
if (end[-1] == 0x20 && start_words < end_words)
|
||||
while (end > start_words && ((unsigned *)end)[-1] == SPACE_INT)
|
||||
end -= SIZEOF_INT;
|
||||
}
|
||||
while (end > ptr && end[-1] == 0x20)
|
||||
end--;
|
||||
return (end);
|
||||
}
|
||||
#else
|
||||
/*
|
||||
Reads 8 bytes at a time, ignoring alignment.
|
||||
We use uint8korr, which is fast (it simply reads a *ulonglong)
|
||||
on all platforms, except sparc.
|
||||
*/
|
||||
static inline const uchar *skip_trailing_space(const uchar *ptr, size_t len)
|
||||
{
|
||||
const uchar *end= ptr + len;
|
||||
while (end - ptr >= 8)
|
||||
{
|
||||
if (uint8korr(end-8) != 0x2020202020202020ULL)
|
||||
break;
|
||||
end-= 8;
|
||||
}
|
||||
while (end > ptr && end[-1] == 0x20)
|
||||
end--;
|
||||
return (end);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str)
|
||||
{
|
||||
lex_str->str= (char *) c_str;
|
||||
lex_str->length= strlen(c_str);
|
||||
}
|
||||
|
||||
static inline void lex_cstring_set(LEX_CSTRING *lex_str, const char *c_str)
|
||||
{
|
||||
lex_str->str= c_str;
|
||||
lex_str->length= strlen(c_str);
|
||||
}
|
||||
|
||||
#endif
|
||||
90
demo/kugou/include/Common/include/mysql/my_alloc.h
Normal file
90
demo/kugou/include/Common/include/mysql/my_alloc.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
Data structures for mysys/my_alloc.c (root memory allocator)
|
||||
*/
|
||||
|
||||
#ifndef _my_alloc_h
|
||||
#define _my_alloc_h
|
||||
|
||||
#define ALLOC_MAX_BLOCK_TO_DROP 4096
|
||||
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
|
||||
|
||||
/* PSI_memory_key */
|
||||
#include "mysql/psi/psi_memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct st_used_mem
|
||||
{ /* struct for once_alloc (block) */
|
||||
struct st_used_mem *next; /* Next block in use */
|
||||
unsigned int left; /* memory left in block */
|
||||
unsigned int size; /* size of block */
|
||||
} USED_MEM;
|
||||
|
||||
|
||||
typedef struct st_mem_root
|
||||
{
|
||||
USED_MEM *free; /* blocks with free memory in it */
|
||||
USED_MEM *used; /* blocks almost without free memory */
|
||||
USED_MEM *pre_alloc; /* preallocated block */
|
||||
/* if block have less memory it will be put in 'used' list */
|
||||
size_t min_malloc;
|
||||
size_t block_size; /* initial block size */
|
||||
unsigned int block_num; /* allocated blocks counter */
|
||||
/*
|
||||
first free block in queue test counter (if it exceed
|
||||
MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list)
|
||||
*/
|
||||
unsigned int first_block_usage;
|
||||
|
||||
/*
|
||||
Maximum amount of memory this mem_root can hold. A value of 0
|
||||
implies there is no limit.
|
||||
*/
|
||||
size_t max_capacity;
|
||||
|
||||
/* Allocated size for this mem_root */
|
||||
|
||||
size_t allocated_size;
|
||||
|
||||
/* Enable this for error reporting if capacity is exceeded */
|
||||
my_bool error_for_capacity_exceeded;
|
||||
|
||||
void (*error_handler)(void);
|
||||
|
||||
PSI_memory_key m_psi_key;
|
||||
} MEM_ROOT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
225
demo/kugou/include/Common/include/mysql/my_byteorder.h
Normal file
225
demo/kugou/include/Common/include/mysql/my_byteorder.h
Normal file
@@ -0,0 +1,225 @@
|
||||
#ifndef MY_BYTEORDER_INCLUDED
|
||||
#define MY_BYTEORDER_INCLUDED
|
||||
|
||||
/* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
|
||||
/*
|
||||
Functions for reading and storing in machine independent
|
||||
format (low byte first). There are 'korr' (assume 'corrector') variants
|
||||
for integer types, but 'get' (assume 'getter') for floating point types.
|
||||
*/
|
||||
#if defined(__i386__) || defined(_WIN32) || defined(__x86_64__)
|
||||
#include "byte_order_generic_x86.h"
|
||||
#else
|
||||
#include "byte_order_generic.h"
|
||||
#endif
|
||||
|
||||
static inline int32 sint3korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((int32) (((A[2]) & 128) ?
|
||||
(((uint32) 255L << 24) |
|
||||
(((uint32) A[2]) << 16) |
|
||||
(((uint32) A[1]) << 8) |
|
||||
((uint32) A[0])) :
|
||||
(((uint32) A[2]) << 16) |
|
||||
(((uint32) A[1]) << 8) |
|
||||
((uint32) A[0])))
|
||||
;
|
||||
}
|
||||
|
||||
static inline uint32 uint3korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
(uint32) (((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16))
|
||||
;
|
||||
}
|
||||
|
||||
static inline ulonglong uint5korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((ulonglong)(((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24)) +
|
||||
(((ulonglong) (A[4])) << 32))
|
||||
;
|
||||
}
|
||||
|
||||
static inline ulonglong uint6korr(const uchar *A)
|
||||
{
|
||||
return
|
||||
((ulonglong)(((uint32) (A[0])) +
|
||||
(((uint32) (A[1])) << 8) +
|
||||
(((uint32) (A[2])) << 16) +
|
||||
(((uint32) (A[3])) << 24)) +
|
||||
(((ulonglong) (A[4])) << 32) +
|
||||
(((ulonglong) (A[5])) << 40))
|
||||
;
|
||||
}
|
||||
|
||||
static inline void int3store(uchar *T, uint A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)= (uchar) (A >> 8);
|
||||
*(T+2)= (uchar) (A >> 16);
|
||||
}
|
||||
|
||||
static inline void int5store(uchar *T, ulonglong A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)= (uchar) (A >> 8);
|
||||
*(T+2)= (uchar) (A >> 16);
|
||||
*(T+3)= (uchar) (A >> 24);
|
||||
*(T+4)= (uchar) (A >> 32);
|
||||
}
|
||||
|
||||
static inline void int6store(uchar *T, ulonglong A)
|
||||
{
|
||||
*(T)= (uchar) (A);
|
||||
*(T+1)= (uchar) (A >> 8);
|
||||
*(T+2)= (uchar) (A >> 16);
|
||||
*(T+3)= (uchar) (A >> 24);
|
||||
*(T+4)= (uchar) (A >> 32);
|
||||
*(T+5)= (uchar) (A >> 40);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
static inline int16 sint2korr(const char *pT)
|
||||
{
|
||||
return sint2korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline uint16 uint2korr(const char *pT)
|
||||
{
|
||||
return uint2korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline uint32 uint3korr(const char *pT)
|
||||
{
|
||||
return uint3korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline int32 sint3korr(const char *pT)
|
||||
{
|
||||
return sint3korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline uint32 uint4korr(const char *pT)
|
||||
{
|
||||
return uint4korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline int32 sint4korr(const char *pT)
|
||||
{
|
||||
return sint4korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline ulonglong uint6korr(const char *pT)
|
||||
{
|
||||
return uint6korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline ulonglong uint8korr(const char *pT)
|
||||
{
|
||||
return uint8korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
static inline longlong sint8korr(const char *pT)
|
||||
{
|
||||
return sint8korr(static_cast<const uchar*>(static_cast<const void*>(pT)));
|
||||
}
|
||||
|
||||
|
||||
static inline void int2store(char *pT, uint16 A)
|
||||
{
|
||||
int2store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int3store(char *pT, uint A)
|
||||
{
|
||||
int3store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int4store(char *pT, uint32 A)
|
||||
{
|
||||
int4store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int5store(char *pT, ulonglong A)
|
||||
{
|
||||
int5store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int6store(char *pT, ulonglong A)
|
||||
{
|
||||
int6store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
static inline void int8store(char *pT, ulonglong A)
|
||||
{
|
||||
int8store(static_cast<uchar*>(static_cast<void*>(pT)), A);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
Functions for reading and storing in machine format from/to
|
||||
short/long to/from some place in memory V should be a variable
|
||||
and M a pointer to byte.
|
||||
*/
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#include "big_endian.h"
|
||||
#else
|
||||
#include "little_endian.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
static inline void float4store(char *V, float M)
|
||||
{
|
||||
float4store(static_cast<uchar*>(static_cast<void*>(V)), M);
|
||||
}
|
||||
|
||||
static inline void float8get(double *V, const char *M)
|
||||
{
|
||||
float8get(V, static_cast<const uchar*>(static_cast<const void*>(M)));
|
||||
}
|
||||
|
||||
static inline void float8store(char *V, double M)
|
||||
{
|
||||
float8store(static_cast<uchar*>(static_cast<void*>(V)), M);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* MY_BYTEORDER_INCLUDED */
|
||||
76
demo/kugou/include/Common/include/mysql/my_command.h
Normal file
76
demo/kugou/include/Common/include/mysql/my_command.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _mysql_command_h
|
||||
#define _mysql_command_h
|
||||
|
||||
/**
|
||||
@enum enum_server_command
|
||||
@brief You should add new commands to the end of this list, otherwise old
|
||||
servers won't be able to handle them as 'unsupported'.
|
||||
*/
|
||||
enum enum_server_command
|
||||
{
|
||||
COM_SLEEP,
|
||||
COM_QUIT,
|
||||
COM_INIT_DB,
|
||||
COM_QUERY,
|
||||
COM_FIELD_LIST,
|
||||
COM_CREATE_DB,
|
||||
COM_DROP_DB,
|
||||
COM_REFRESH,
|
||||
COM_SHUTDOWN,
|
||||
COM_STATISTICS,
|
||||
COM_PROCESS_INFO,
|
||||
COM_CONNECT,
|
||||
COM_PROCESS_KILL,
|
||||
COM_DEBUG,
|
||||
COM_PING,
|
||||
COM_TIME,
|
||||
COM_DELAYED_INSERT,
|
||||
COM_CHANGE_USER,
|
||||
COM_BINLOG_DUMP,
|
||||
COM_TABLE_DUMP,
|
||||
COM_CONNECT_OUT,
|
||||
COM_REGISTER_SLAVE,
|
||||
COM_STMT_PREPARE,
|
||||
COM_STMT_EXECUTE,
|
||||
COM_STMT_SEND_LONG_DATA,
|
||||
COM_STMT_CLOSE,
|
||||
COM_STMT_RESET,
|
||||
COM_SET_OPTION,
|
||||
COM_STMT_FETCH,
|
||||
COM_DAEMON,
|
||||
COM_BINLOG_DUMP_GTID,
|
||||
COM_RESET_CONNECTION,
|
||||
/* don't forget to update const char *command_name[] in sql_parse.cc */
|
||||
|
||||
/* Must be last */
|
||||
COM_END
|
||||
};
|
||||
|
||||
#endif /* _mysql_command_h */
|
||||
190
demo/kugou/include/Common/include/mysql/my_compiler.h
Normal file
190
demo/kugou/include/Common/include/mysql/my_compiler.h
Normal file
@@ -0,0 +1,190 @@
|
||||
#ifndef MY_COMPILER_INCLUDED
|
||||
#define MY_COMPILER_INCLUDED
|
||||
|
||||
/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
Header for compiler-dependent features.
|
||||
|
||||
Intended to contain a set of reusable wrappers for preprocessor
|
||||
macros, attributes, pragmas, and any other features that are
|
||||
specific to a target compiler.
|
||||
*/
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
#if defined __GNUC__
|
||||
/*
|
||||
Convenience macro to test the minimum required GCC version.
|
||||
These should be used with care as Clang also sets __GNUC__ and
|
||||
__GNUC_MINOR__ (currently to 4.2). Prefer using feature specific
|
||||
CMake checks in configure.cmake instead.
|
||||
*/
|
||||
# define MY_GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
|
||||
#else
|
||||
# define MY_GNUC_PREREQ(maj, min) (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
The macros below are borrowed from include/linux/compiler.h in the
|
||||
Linux kernel. Use them to indicate the likelyhood of the truthfulness
|
||||
of a condition. This serves two purposes - newer versions of gcc will be
|
||||
able to optimize for branch predication, which could yield siginficant
|
||||
performance gains in frequently executed sections of the code, and the
|
||||
other reason to use them is for documentation
|
||||
*/
|
||||
#ifdef HAVE_BUILTIN_EXPECT
|
||||
|
||||
// likely/unlikely are likely to clash with other symbols, do not #define
|
||||
#if defined(__cplusplus)
|
||||
inline bool likely(bool expr)
|
||||
{
|
||||
return __builtin_expect(expr, true);
|
||||
}
|
||||
inline bool unlikely(bool expr)
|
||||
{
|
||||
return __builtin_expect(expr, false);
|
||||
}
|
||||
#else
|
||||
# define likely(x) __builtin_expect((x),1)
|
||||
# define unlikely(x) __builtin_expect((x),0)
|
||||
#endif
|
||||
|
||||
#else /* HAVE_BUILTIN_EXPECT */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
inline bool likely(bool expr)
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
inline bool unlikely(bool expr)
|
||||
{
|
||||
return expr;
|
||||
}
|
||||
#else
|
||||
# define likely(x) (x)
|
||||
# define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_BUILTIN_EXPECT */
|
||||
|
||||
/* Comunicate to the compiler the unreachability of the code. */
|
||||
#ifdef HAVE_BUILTIN_UNREACHABLE
|
||||
# define MY_ASSERT_UNREACHABLE() __builtin_unreachable()
|
||||
#else
|
||||
# define MY_ASSERT_UNREACHABLE() do { assert(0); } while (0)
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ || defined __SUNPRO_C || defined __SUNPRO_CC
|
||||
/* Specifies the minimum alignment of a type. */
|
||||
# define MY_ALIGNOF(type) __alignof__(type)
|
||||
/* Determine the alignment requirement of a type. */
|
||||
# define MY_ALIGNED(n) __attribute__((__aligned__((n))))
|
||||
/* Microsoft Visual C++ */
|
||||
#elif defined _MSC_VER
|
||||
# define MY_ALIGNOF(type) __alignof(type)
|
||||
# define MY_ALIGNED(n) __declspec(align(n))
|
||||
#else /* Make sure they are defined for other compilers. */
|
||||
# define MY_ALIGNOF(type)
|
||||
# define MY_ALIGNED(size)
|
||||
#endif
|
||||
|
||||
/* Visual Studio requires '__inline' for C code */
|
||||
#if !defined(__cplusplus) && defined(_MSC_VER)
|
||||
# define inline __inline
|
||||
#endif
|
||||
|
||||
/* Provide __func__ macro definition for Visual Studio. */
|
||||
#if defined(_MSC_VER)
|
||||
# define __func__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
/**
|
||||
C++ Type Traits
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
|
||||
/**
|
||||
Opaque storage with a particular alignment.
|
||||
Partial specialization used due to MSVC++.
|
||||
*/
|
||||
template<size_t alignment> struct my_alignment_imp;
|
||||
template<> struct MY_ALIGNED(1) my_alignment_imp<1> {};
|
||||
template<> struct MY_ALIGNED(2) my_alignment_imp<2> {};
|
||||
template<> struct MY_ALIGNED(4) my_alignment_imp<4> {};
|
||||
template<> struct MY_ALIGNED(8) my_alignment_imp<8> {};
|
||||
template<> struct MY_ALIGNED(16) my_alignment_imp<16> {};
|
||||
|
||||
/**
|
||||
A POD type with a given size and alignment.
|
||||
|
||||
@remark If the compiler does not support a alignment attribute
|
||||
(MY_ALIGN macro), the default alignment of a double is
|
||||
used instead.
|
||||
|
||||
@tparam size The minimum size.
|
||||
@tparam alignment The desired alignment: 1, 2, 4, 8 or 16.
|
||||
*/
|
||||
template <size_t size, size_t alignment>
|
||||
struct my_aligned_storage
|
||||
{
|
||||
union
|
||||
{
|
||||
char data[size];
|
||||
my_alignment_imp<alignment> align;
|
||||
};
|
||||
};
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
Disable MY_ATTRIBUTE for Sun Studio and Visual Studio.
|
||||
Note that Sun Studio supports some __attribute__ variants,
|
||||
but not format or unused which we use quite a lot.
|
||||
*/
|
||||
#ifndef MY_ATTRIBUTE
|
||||
#if defined(__GNUC__)
|
||||
# define MY_ATTRIBUTE(A) __attribute__(A)
|
||||
#else
|
||||
# define MY_ATTRIBUTE(A)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_attribute(no_sanitize_undefined)
|
||||
# define SUPPRESS_UBSAN __attribute__((no_sanitize_undefined))
|
||||
#else
|
||||
# define SUPPRESS_UBSAN
|
||||
#endif
|
||||
|
||||
#endif /* MY_COMPILER_INCLUDED */
|
||||
466
demo/kugou/include/Common/include/mysql/my_config.h
Normal file
466
demo/kugou/include/Common/include/mysql/my_config.h
Normal file
@@ -0,0 +1,466 @@
|
||||
/* Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MY_CONFIG_H
|
||||
#define MY_CONFIG_H
|
||||
|
||||
/*
|
||||
* From configure.cmake, in order of appearance
|
||||
*/
|
||||
/* #undef HAVE_LLVM_LIBCPP */
|
||||
#define _LARGEFILE_SOURCE 1
|
||||
|
||||
/* Libraries */
|
||||
/* #undef HAVE_LIBM */
|
||||
/* #undef HAVE_LIBNSL */
|
||||
/* #undef HAVE_LIBCRYPT */
|
||||
/* #undef HAVE_LIBSOCKET */
|
||||
/* #undef HAVE_LIBDL */
|
||||
/* #undef HAVE_LIBRT */
|
||||
/* #undef HAVE_LIBWRAP */
|
||||
/* #undef HAVE_LIBWRAP_PROTOTYPES */
|
||||
|
||||
/* Header files */
|
||||
/* #undef HAVE_ALLOCA_H */
|
||||
/* #undef HAVE_ARPA_INET_H */
|
||||
/* #undef HAVE_CRYPT_H */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
/* #undef HAVE_EXECINFO_H */
|
||||
/* #undef HAVE_FPU_CONTROL_H */
|
||||
/* #undef HAVE_GRP_H */
|
||||
/* #undef HAVE_IEEEFP_H */
|
||||
/* #undef HAVE_LANGINFO_H */
|
||||
#define HAVE_MALLOC_H 1
|
||||
/* #undef HAVE_NETINET_IN_H */
|
||||
/* #undef HAVE_POLL_H */
|
||||
/* #undef HAVE_PWD_H */
|
||||
/* #undef HAVE_STRINGS_H */
|
||||
/* #undef HAVE_SYS_CDEFS_H */
|
||||
/* #undef HAVE_SYS_IOCTL_H */
|
||||
/* #undef HAVE_SYS_MMAN_H */
|
||||
/* #undef HAVE_SYS_RESOURCE_H */
|
||||
/* #undef HAVE_SYS_SELECT_H */
|
||||
/* #undef HAVE_SYS_SOCKET_H */
|
||||
/* #undef HAVE_TERM_H */
|
||||
/* #undef HAVE_TERMIOS_H */
|
||||
/* #undef HAVE_TERMIO_H */
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
/* #undef HAVE_SYS_WAIT_H */
|
||||
/* #undef HAVE_SYS_PARAM_H */
|
||||
/* #undef HAVE_FNMATCH_H */
|
||||
/* #undef HAVE_SYS_UN_H */
|
||||
/* #undef HAVE_SASL_SASL_H */
|
||||
|
||||
/* Libevent */
|
||||
/* #undef HAVE_DEVPOLL */
|
||||
/* #undef HAVE_SYS_DEVPOLL_H */
|
||||
/* #undef HAVE_SYS_EPOLL_H */
|
||||
/* #undef HAVE_TAILQFOREACH */
|
||||
|
||||
/* Functions */
|
||||
#define HAVE_ALIGNED_MALLOC 1
|
||||
/* #undef HAVE_BACKTRACE */
|
||||
/* #undef HAVE_PRINTSTACK */
|
||||
/* #undef HAVE_INDEX */
|
||||
/* #undef HAVE_CLOCK_GETTIME */
|
||||
/* #undef HAVE_CUSERID */
|
||||
/* #undef HAVE_DIRECTIO */
|
||||
/* #undef HAVE_FTRUNCATE */
|
||||
#define HAVE_COMPRESS 1
|
||||
/* #undef HAVE_CRYPT */
|
||||
/* #undef HAVE_DLOPEN */
|
||||
/* #undef HAVE_FCHMOD */
|
||||
/* #undef HAVE_FCNTL */
|
||||
/* #undef HAVE_FDATASYNC */
|
||||
/* #undef HAVE_DECL_FDATASYNC */
|
||||
/* #undef HAVE_FEDISABLEEXCEPT */
|
||||
/* #undef HAVE_FSEEKO */
|
||||
/* #undef HAVE_FSYNC */
|
||||
/* #undef HAVE_GETHOSTBYADDR_R */
|
||||
/* #undef HAVE_GETHRTIME */
|
||||
/* #undef HAVE_GETNAMEINFO */
|
||||
/* #undef HAVE_GETPASS */
|
||||
/* #undef HAVE_GETPASSPHRASE */
|
||||
/* #undef HAVE_GETPWNAM */
|
||||
/* #undef HAVE_GETPWUID */
|
||||
/* #undef HAVE_GETRLIMIT */
|
||||
/* #undef HAVE_GETRUSAGE */
|
||||
/* #undef HAVE_INITGROUPS */
|
||||
/* #undef HAVE_ISSETUGID */
|
||||
/* #undef HAVE_GETUID */
|
||||
/* #undef HAVE_GETEUID */
|
||||
/* #undef HAVE_GETGID */
|
||||
/* #undef HAVE_GETEGID */
|
||||
/* #undef HAVE_LSTAT */
|
||||
/* #undef HAVE_MADVISE */
|
||||
/* #undef HAVE_MALLOC_INFO */
|
||||
/* #undef HAVE_MEMRCHR */
|
||||
/* #undef HAVE_MLOCK */
|
||||
/* #undef HAVE_MLOCKALL */
|
||||
/* #undef HAVE_MMAP64 */
|
||||
/* #undef HAVE_POLL */
|
||||
/* #undef HAVE_POSIX_FALLOCATE */
|
||||
/* #undef HAVE_POSIX_MEMALIGN */
|
||||
/* #undef HAVE_PREAD */
|
||||
/* #undef HAVE_PTHREAD_CONDATTR_SETCLOCK */
|
||||
/* #undef HAVE_PTHREAD_SIGMASK */
|
||||
/* #undef HAVE_READLINK */
|
||||
/* #undef HAVE_REALPATH */
|
||||
/* #undef HAVE_SETFD */
|
||||
/* #undef HAVE_SIGACTION */
|
||||
/* #undef HAVE_SLEEP */
|
||||
/* #undef HAVE_STPCPY */
|
||||
/* #undef HAVE_STPNCPY */
|
||||
/* #undef HAVE_STRLCPY */
|
||||
#define HAVE_STRNLEN 1
|
||||
/* #undef HAVE_STRLCAT */
|
||||
/* #undef HAVE_STRSIGNAL */
|
||||
/* #undef HAVE_FGETLN */
|
||||
/* #undef HAVE_STRSEP */
|
||||
#define HAVE_TELL 1
|
||||
/* #undef HAVE_VASPRINTF */
|
||||
/* #undef HAVE_MEMALIGN */
|
||||
/* #undef HAVE_NL_LANGINFO */
|
||||
/* #undef HAVE_HTONLL */
|
||||
/* #undef DNS_USE_CPU_CLOCK_FOR_ID */
|
||||
/* #undef HAVE_EPOLL */
|
||||
/* #undef HAVE_EVENT_PORTS */
|
||||
/* #undef HAVE_INET_NTOP */
|
||||
/* #undef HAVE_WORKING_KQUEUE */
|
||||
/* #undef HAVE_TIMERADD */
|
||||
/* #undef HAVE_TIMERCLEAR */
|
||||
/* #undef HAVE_TIMERCMP */
|
||||
/* #undef HAVE_TIMERISSET */
|
||||
|
||||
/* WL2373 */
|
||||
/* #undef HAVE_SYS_TIME_H */
|
||||
/* #undef HAVE_SYS_TIMES_H */
|
||||
/* #undef HAVE_TIMES */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
|
||||
/* Symbols */
|
||||
/* #undef HAVE_LRAND48 */
|
||||
/* #undef GWINSZ_IN_SYS_IOCTL */
|
||||
/* #undef FIONREAD_IN_SYS_IOCTL */
|
||||
/* #undef FIONREAD_IN_SYS_FILIO */
|
||||
/* #undef HAVE_SIGEV_THREAD_ID */
|
||||
/* #undef HAVE_SIGEV_PORT */
|
||||
#define HAVE_LOG2 1
|
||||
|
||||
#define HAVE_ISINF 1
|
||||
|
||||
/* #undef HAVE_KQUEUE_TIMERS */
|
||||
/* #undef HAVE_POSIX_TIMERS */
|
||||
|
||||
/* Endianess */
|
||||
/* #undef WORDS_BIGENDIAN */
|
||||
|
||||
/* Type sizes */
|
||||
#define SIZEOF_VOIDP 4
|
||||
#define SIZEOF_CHARP 4
|
||||
#define SIZEOF_LONG 4
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_OFF_T 4
|
||||
#define SIZEOF_TIME_T 8
|
||||
/* #undef HAVE_UINT */
|
||||
/* #undef HAVE_ULONG */
|
||||
/* #undef HAVE_U_INT32_T */
|
||||
/* #undef HAVE_STRUCT_TIMESPEC */
|
||||
|
||||
/* Support for tagging symbols with __attribute__((visibility("hidden"))) */
|
||||
/* #undef HAVE_VISIBILITY_HIDDEN */
|
||||
|
||||
/* Code tests*/
|
||||
#define STACK_DIRECTION -1
|
||||
/* #undef TIME_WITH_SYS_TIME */
|
||||
#define NO_FCNTL_NONBLOCK 1
|
||||
/* #undef HAVE_PAUSE_INSTRUCTION */
|
||||
/* #undef HAVE_FAKE_PAUSE_INSTRUCTION */
|
||||
/* #undef HAVE_HMT_PRIORITY_INSTRUCTION */
|
||||
/* #undef HAVE_ABI_CXA_DEMANGLE */
|
||||
/* #undef HAVE_BUILTIN_UNREACHABLE */
|
||||
/* #undef HAVE_BUILTIN_EXPECT */
|
||||
/* #undef HAVE_BUILTIN_STPCPY */
|
||||
/* #undef HAVE_GCC_ATOMIC_BUILTINS */
|
||||
/* #undef HAVE_GCC_SYNC_BUILTINS */
|
||||
/* #undef HAVE_VALGRIND */
|
||||
/* #undef HAVE_PTHREAD_THREADID_NP */
|
||||
|
||||
/* IPV6 */
|
||||
/* #undef HAVE_NETINET_IN6_H */
|
||||
#define HAVE_STRUCT_SOCKADDR_IN6 1
|
||||
#define HAVE_STRUCT_IN6_ADDR 1
|
||||
#define HAVE_IPV6 1
|
||||
|
||||
/* #undef ss_family */
|
||||
/* #undef HAVE_SOCKADDR_IN_SIN_LEN */
|
||||
/* #undef HAVE_SOCKADDR_IN6_SIN6_LEN */
|
||||
|
||||
/*
|
||||
* Platform specific CMake files
|
||||
*/
|
||||
#define MACHINE_TYPE "AMD64"
|
||||
/* #undef HAVE_LINUX_LARGE_PAGES */
|
||||
/* #undef HAVE_SOLARIS_LARGE_PAGES */
|
||||
/* #undef HAVE_SOLARIS_ATOMIC */
|
||||
/* #undef HAVE_SOLARIS_STYLE_GETHOST */
|
||||
#define SYSTEM_TYPE "Win32"
|
||||
/* Windows stuff, mostly functions, that have Posix analogs but named differently */
|
||||
/* #undef IPPROTO_IPV6 */
|
||||
/* #undef IPV6_V6ONLY */
|
||||
/* This should mean case insensitive file system */
|
||||
#define FN_NO_CASE_SENSE 1
|
||||
|
||||
/*
|
||||
* From main CMakeLists.txt
|
||||
*/
|
||||
#define MAX_INDEXES 64U
|
||||
/* #undef WITH_INNODB_MEMCACHED */
|
||||
/* #undef ENABLE_MEMCACHED_SASL */
|
||||
/* #undef ENABLE_MEMCACHED_SASL_PWDB */
|
||||
#define ENABLED_PROFILING 1
|
||||
/* #undef HAVE_ASAN */
|
||||
#define ENABLED_LOCAL_INFILE 1
|
||||
#define OPTIMIZER_TRACE 1
|
||||
#define DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server 5.7"
|
||||
#define SHAREDIR "share"
|
||||
#define DEFAULT_BASEDIR "C:/Program Files/MySQL/MySQL Server 5.7"
|
||||
#define MYSQL_DATADIR "C:/Program Files/MySQL/MySQL Server 5.7/data"
|
||||
#define MYSQL_KEYRINGDIR "C:/Program Files/MySQL/MySQL Server 5.7/keyring"
|
||||
#define DEFAULT_CHARSET_HOME "C:/Program Files/MySQL/MySQL Server 5.7"
|
||||
#define PLUGINDIR "C:/Program Files/MySQL/MySQL Server 5.7/lib/plugin"
|
||||
/* #undef DEFAULT_SYSCONFDIR */
|
||||
#define DEFAULT_TMPDIR ""
|
||||
#define INSTALL_SBINDIR "/bin"
|
||||
#define INSTALL_BINDIR "/bin"
|
||||
#define INSTALL_MYSQLSHAREDIR "/share"
|
||||
#define INSTALL_SHAREDIR "/share"
|
||||
#define INSTALL_PLUGINDIR "/lib/plugin"
|
||||
#define INSTALL_INCLUDEDIR "/include"
|
||||
#define INSTALL_SCRIPTDIR "/scripts"
|
||||
#define INSTALL_MYSQLDATADIR "/data"
|
||||
#define INSTALL_MYSQLKEYRINGDIR "/keyring"
|
||||
/* #undef INSTALL_PLUGINTESTDIR */
|
||||
#define INSTALL_INFODIR "/docs"
|
||||
#define INSTALL_MYSQLTESTDIR "/mysql-test"
|
||||
#define INSTALL_DOCREADMEDIR "/."
|
||||
#define INSTALL_DOCDIR "/docs"
|
||||
#define INSTALL_MANDIR "/man"
|
||||
#define INSTALL_SUPPORTFILESDIR "/support-files"
|
||||
#define INSTALL_LIBDIR "/lib"
|
||||
|
||||
/*
|
||||
* Readline
|
||||
*/
|
||||
/* #undef HAVE_MBSTATE_T */
|
||||
/* #undef HAVE_LANGINFO_CODESET */
|
||||
/* #undef HAVE_WCSDUP */
|
||||
/* #undef HAVE_WCHAR_T */
|
||||
/* #undef HAVE_WINT_T */
|
||||
/* #undef HAVE_CURSES_H */
|
||||
/* #undef HAVE_NCURSES_H */
|
||||
/* #undef USE_LIBEDIT_INTERFACE */
|
||||
/* #undef HAVE_HIST_ENTRY */
|
||||
/* #undef USE_NEW_EDITLINE_INTERFACE */
|
||||
|
||||
/*
|
||||
* Libedit
|
||||
*/
|
||||
/* #undef HAVE_GETLINE */
|
||||
/* #undef HAVE___SECURE_GETENV */
|
||||
/* #undef HAVE_SECURE_GETENV */
|
||||
/* #undef HAVE_VIS */
|
||||
/* #undef HAVE_UNVIS */
|
||||
/* #undef HAVE_GETPW_R_DRAFT */
|
||||
/* #undef HAVE_GETPW_R_POSIX */
|
||||
|
||||
/*
|
||||
* DTrace
|
||||
*/
|
||||
/* #undef HAVE_DTRACE */
|
||||
|
||||
/*
|
||||
* Character sets
|
||||
*/
|
||||
#define MYSQL_DEFAULT_CHARSET_NAME "latin1"
|
||||
#define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
|
||||
#define HAVE_CHARSET_armscii8 1
|
||||
#define HAVE_CHARSET_ascii 1
|
||||
#define HAVE_CHARSET_big5 1
|
||||
#define HAVE_CHARSET_cp1250 1
|
||||
#define HAVE_CHARSET_cp1251 1
|
||||
#define HAVE_CHARSET_cp1256 1
|
||||
#define HAVE_CHARSET_cp1257 1
|
||||
#define HAVE_CHARSET_cp850 1
|
||||
#define HAVE_CHARSET_cp852 1
|
||||
#define HAVE_CHARSET_cp866 1
|
||||
#define HAVE_CHARSET_cp932 1
|
||||
#define HAVE_CHARSET_dec8 1
|
||||
#define HAVE_CHARSET_eucjpms 1
|
||||
#define HAVE_CHARSET_euckr 1
|
||||
#define HAVE_CHARSET_gb2312 1
|
||||
#define HAVE_CHARSET_gbk 1
|
||||
#define HAVE_CHARSET_gb18030 1
|
||||
#define HAVE_CHARSET_geostd8 1
|
||||
#define HAVE_CHARSET_greek 1
|
||||
#define HAVE_CHARSET_hebrew 1
|
||||
#define HAVE_CHARSET_hp8 1
|
||||
#define HAVE_CHARSET_keybcs2 1
|
||||
#define HAVE_CHARSET_koi8r 1
|
||||
#define HAVE_CHARSET_koi8u 1
|
||||
#define HAVE_CHARSET_latin1 1
|
||||
#define HAVE_CHARSET_latin2 1
|
||||
#define HAVE_CHARSET_latin5 1
|
||||
#define HAVE_CHARSET_latin7 1
|
||||
#define HAVE_CHARSET_macce 1
|
||||
#define HAVE_CHARSET_macroman 1
|
||||
#define HAVE_CHARSET_sjis 1
|
||||
#define HAVE_CHARSET_swe7 1
|
||||
#define HAVE_CHARSET_tis620 1
|
||||
#define HAVE_CHARSET_ucs2 1
|
||||
#define HAVE_CHARSET_ujis 1
|
||||
#define HAVE_CHARSET_utf8mb4 1
|
||||
/* #undef HAVE_CHARSET_utf8mb3 */
|
||||
#define HAVE_CHARSET_utf8 1
|
||||
#define HAVE_CHARSET_utf16 1
|
||||
#define HAVE_CHARSET_utf32 1
|
||||
#define HAVE_UCA_COLLATIONS 1
|
||||
|
||||
/*
|
||||
* Feature set
|
||||
*/
|
||||
#define WITH_PARTITION_STORAGE_ENGINE 1
|
||||
|
||||
/*
|
||||
* Performance schema
|
||||
*/
|
||||
#define WITH_PERFSCHEMA_STORAGE_ENGINE 1
|
||||
/* #undef DISABLE_PSI_THREAD */
|
||||
/* #undef DISABLE_PSI_MUTEX */
|
||||
/* #undef DISABLE_PSI_RWLOCK */
|
||||
/* #undef DISABLE_PSI_COND */
|
||||
/* #undef DISABLE_PSI_FILE */
|
||||
/* #undef DISABLE_PSI_TABLE */
|
||||
/* #undef DISABLE_PSI_SOCKET */
|
||||
/* #undef DISABLE_PSI_STAGE */
|
||||
/* #undef DISABLE_PSI_STATEMENT */
|
||||
/* #undef DISABLE_PSI_SP */
|
||||
/* #undef DISABLE_PSI_PS */
|
||||
/* #undef DISABLE_PSI_IDLE */
|
||||
/* #undef DISABLE_PSI_STATEMENT_DIGEST */
|
||||
/* #undef DISABLE_PSI_METADATA */
|
||||
/* #undef DISABLE_PSI_MEMORY */
|
||||
/* #undef DISABLE_PSI_TRANSACTION */
|
||||
|
||||
/*
|
||||
* syscall
|
||||
*/
|
||||
/* #undef HAVE_SYS_THREAD_SELFID */
|
||||
/* #undef HAVE_SYS_GETTID */
|
||||
/* #undef HAVE_PTHREAD_GETTHREADID_NP */
|
||||
/* #undef HAVE_PTHREAD_SETNAME_NP */
|
||||
/* #undef HAVE_INTEGER_PTHREAD_SELF */
|
||||
|
||||
/* Platform-specific C++ compiler behaviors we rely upon */
|
||||
|
||||
/*
|
||||
This macro defines whether the compiler in use needs a 'typename' keyword
|
||||
to access the types defined inside a class template, such types are called
|
||||
dependent types. Some compilers require it, some others forbid it, and some
|
||||
others may work with or without it. For example, GCC requires the 'typename'
|
||||
keyword whenever needing to access a type inside a template, but msvc
|
||||
forbids it.
|
||||
*/
|
||||
#define HAVE_IMPLICIT_DEPENDENT_NAME_TYPING 1
|
||||
|
||||
|
||||
/*
|
||||
* MySQL version
|
||||
*/
|
||||
#define DOT_FRM_VERSION 6
|
||||
#define MYSQL_VERSION_MAJOR 5
|
||||
#define MYSQL_VERSION_MINOR 7
|
||||
#define MYSQL_VERSION_PATCH 30
|
||||
#define MYSQL_VERSION_EXTRA ""
|
||||
#define PACKAGE "mysql"
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
#define PACKAGE_NAME "MySQL Server"
|
||||
#define PACKAGE_STRING "MySQL Server 5.7.30"
|
||||
#define PACKAGE_TARNAME "mysql"
|
||||
#define PACKAGE_VERSION "5.7.30"
|
||||
#define VERSION "5.7.30"
|
||||
#define PROTOCOL_VERSION 10
|
||||
|
||||
/*
|
||||
* CPU info
|
||||
*/
|
||||
#define CPU_LEVEL1_DCACHE_LINESIZE 64
|
||||
|
||||
/*
|
||||
* NDB
|
||||
*/
|
||||
/* #undef WITH_NDBCLUSTER_STORAGE_ENGINE */
|
||||
/* #undef HAVE_PTHREAD_SETSCHEDPARAM */
|
||||
|
||||
/*
|
||||
* Other
|
||||
*/
|
||||
/* #undef EXTRA_DEBUG */
|
||||
/* #undef HAVE_CHOWN */
|
||||
|
||||
/*
|
||||
* Hardcoded values needed by libevent/NDB/memcached
|
||||
*/
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_GETADDRINFO 1
|
||||
#define HAVE_INTTYPES_H 1
|
||||
/* libevent's select.c is not Windows compatible */
|
||||
#ifndef _WIN32
|
||||
#define HAVE_SELECT 1
|
||||
#endif
|
||||
#define HAVE_SIGNAL_H 1
|
||||
#define HAVE_STDARG_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
#define HAVE_STDLIB_H 1
|
||||
#define HAVE_STRDUP 1
|
||||
#define HAVE_STRTOK_R 1
|
||||
#define HAVE_STRTOLL 1
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
#define SIZEOF_CHAR 1
|
||||
|
||||
/*
|
||||
* Needed by libevent
|
||||
*/
|
||||
/* #undef HAVE_SOCKLEN_T */
|
||||
|
||||
/* For --secure-file-priv */
|
||||
#define DEFAULT_SECURE_FILE_PRIV_DIR "NULL"
|
||||
#define DEFAULT_SECURE_FILE_PRIV_EMBEDDED_DIR "NULL"
|
||||
/* #undef HAVE_LIBNUMA */
|
||||
|
||||
/* For default value of --early_plugin_load */
|
||||
/* #undef DEFAULT_EARLY_PLUGIN_LOAD */
|
||||
|
||||
#endif
|
||||
257
demo/kugou/include/Common/include/mysql/my_dbug.h
Normal file
257
demo/kugou/include/Common/include/mysql/my_dbug.h
Normal file
@@ -0,0 +1,257 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MY_DBUG_INCLUDED
|
||||
#define MY_DBUG_INCLUDED
|
||||
|
||||
#include "my_global.h" /* MYSQL_PLUGIN_IMPORT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if !defined(DBUG_OFF)
|
||||
|
||||
struct _db_stack_frame_ {
|
||||
const char *func; /* function name of the previous stack frame */
|
||||
const char *file; /* filename of the function of previous frame */
|
||||
uint level; /* this nesting level, highest bit enables tracing */
|
||||
struct _db_stack_frame_ *prev; /* pointer to the previous frame */
|
||||
};
|
||||
|
||||
struct _db_code_state_;
|
||||
extern MYSQL_PLUGIN_IMPORT my_bool _dbug_on_;
|
||||
extern my_bool _db_keyword_(struct _db_code_state_ *, const char *, int);
|
||||
extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len);
|
||||
extern int _db_explain_init_(char *buf, size_t len);
|
||||
extern int _db_is_pushed_(void);
|
||||
extern void _db_setjmp_(void);
|
||||
extern void _db_longjmp_(void);
|
||||
extern void _db_process_(const char *name);
|
||||
extern void _db_push_(const char *control);
|
||||
extern void _db_pop_(void);
|
||||
extern void _db_set_(const char *control);
|
||||
extern void _db_set_init_(const char *control);
|
||||
extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
|
||||
struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_return_(uint _line_, struct _db_stack_frame_ *_stack_frame_);
|
||||
extern void _db_pargs_(uint _line_,const char *keyword);
|
||||
extern int _db_enabled_();
|
||||
extern void _db_doprnt_(const char *format,...)
|
||||
MY_ATTRIBUTE((format(printf, 1, 2)));
|
||||
extern void _db_doputs_(const char *log);
|
||||
extern void _db_dump_(uint _line_,const char *keyword,
|
||||
const unsigned char *memory, size_t length);
|
||||
extern void _db_end_(void);
|
||||
extern void _db_lock_file_(void);
|
||||
extern void _db_unlock_file_(void);
|
||||
extern FILE *_db_fp_(void);
|
||||
extern void _db_flush_();
|
||||
extern const char* _db_get_func_(void);
|
||||
|
||||
#define DBUG_ENTER(a) struct _db_stack_frame_ _db_stack_frame_; \
|
||||
_db_enter_ (a,__FILE__,__LINE__,&_db_stack_frame_)
|
||||
#define DBUG_LEAVE _db_return_ (__LINE__, &_db_stack_frame_)
|
||||
#define DBUG_RETURN(a1) do {DBUG_LEAVE; return(a1);} while(0)
|
||||
#define DBUG_VOID_RETURN do {DBUG_LEAVE; return;} while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword), 0)) { a1 }} while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) \
|
||||
do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword), 0) ? (a1) : (a2))
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) \
|
||||
(_db_keyword_(0,(keyword), 1) ? (a1) : (a2))
|
||||
#define DBUG_PRINT(keyword,arglist) \
|
||||
do \
|
||||
{ \
|
||||
if (_dbug_on_) \
|
||||
{ \
|
||||
_db_pargs_(__LINE__,keyword); \
|
||||
if (_db_enabled_()) \
|
||||
{ \
|
||||
_db_doprnt_ arglist; \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
An alternate to DBUG_PRINT() macro, which takes a single string
|
||||
as the second argument.
|
||||
*/
|
||||
#define DBUG_PUTS(keyword,arg) \
|
||||
do \
|
||||
{ \
|
||||
if (_dbug_on_) \
|
||||
{ \
|
||||
_db_pargs_(__LINE__,keyword); \
|
||||
if (_db_enabled_()) \
|
||||
{ \
|
||||
_db_doputs_(arg); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define DBUG_PUSH(a1) _db_push_ (a1)
|
||||
#define DBUG_POP() _db_pop_ ()
|
||||
#define DBUG_SET(a1) _db_set_ (a1)
|
||||
#define DBUG_SET_INITIAL(a1) _db_set_init_ (a1)
|
||||
#define DBUG_PROCESS(a1) _db_process_(a1)
|
||||
#define DBUG_FILE _db_fp_()
|
||||
#define DBUG_SETJMP(a1) (_db_setjmp_ (), setjmp (a1))
|
||||
#define DBUG_LONGJMP(a1,a2) (_db_longjmp_ (), longjmp (a1, a2))
|
||||
#define DBUG_DUMP(keyword,a1,a2) _db_dump_(__LINE__,keyword,a1,a2)
|
||||
#define DBUG_END() _db_end_ ()
|
||||
#define DBUG_LOCK_FILE _db_lock_file_()
|
||||
#define DBUG_UNLOCK_FILE _db_unlock_file_()
|
||||
#define DBUG_ASSERT(A) assert(A)
|
||||
#define DBUG_EXPLAIN(buf,len) _db_explain_(0, (buf),(len))
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len) _db_explain_init_((buf),(len))
|
||||
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
|
||||
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
|
||||
#ifndef _WIN32
|
||||
#define DBUG_ABORT() (_db_flush_(), abort())
|
||||
#else
|
||||
/*
|
||||
Avoid popup with abort/retry/ignore buttons. When BUG#31745 is fixed we can
|
||||
call abort() instead of _exit(2) (now it would cause a "test signal" popup).
|
||||
*/
|
||||
#include <crtdbg.h>
|
||||
#define DBUG_ABORT() (_db_flush_(),\
|
||||
(void)_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE),\
|
||||
(void)_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR),\
|
||||
_exit(2))
|
||||
#endif
|
||||
#define DBUG_CHECK_CRASH(func, op) \
|
||||
do { char _dbuf_[255]; strxnmov(_dbuf_, sizeof(_dbuf_)-1, (func), (op)); \
|
||||
DBUG_EXECUTE_IF(_dbuf_, DBUG_ABORT()); } while(0)
|
||||
#define DBUG_CRASH_ENTER(func) \
|
||||
DBUG_ENTER(func); DBUG_CHECK_CRASH(func, "_crash_enter")
|
||||
#define DBUG_CRASH_RETURN(val) \
|
||||
DBUG_CHECK_CRASH(_db_get_func_(), "_crash_return")
|
||||
#define DBUG_CRASH_VOID_RETURN \
|
||||
DBUG_CHECK_CRASH (_db_get_func_(), "_crash_return")
|
||||
|
||||
/*
|
||||
Make the program fail, without creating a core file.
|
||||
abort() will send SIGABRT which (most likely) generates core.
|
||||
Use SIGKILL instead, which cannot be caught.
|
||||
We also pause the current thread, until the signal is actually delivered.
|
||||
An alternative would be to use _exit(EXIT_FAILURE),
|
||||
but then valgrind would report lots of memory leaks.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define DBUG_SUICIDE() DBUG_ABORT()
|
||||
#else
|
||||
extern void _db_suicide_();
|
||||
extern void _db_flush_gcov_();
|
||||
#define DBUG_SUICIDE() (_db_flush_(), _db_suicide_())
|
||||
#endif
|
||||
|
||||
#else /* No debugger */
|
||||
|
||||
#define DBUG_ENTER(a1)
|
||||
#define DBUG_LEAVE
|
||||
#define DBUG_RETURN(a1) do { return(a1); } while(0)
|
||||
#define DBUG_VOID_RETURN do { return; } while(0)
|
||||
#define DBUG_EXECUTE(keyword,a1) do { } while(0)
|
||||
#define DBUG_EXECUTE_IF(keyword,a1) do { } while(0)
|
||||
#define DBUG_EVALUATE(keyword,a1,a2) (a2)
|
||||
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
|
||||
#define DBUG_PRINT(keyword,arglist) do { } while(0)
|
||||
#define DBUG_PUTS(keyword,arg) do { } while(0)
|
||||
#define DBUG_LOG(keyword,arglist) do { } while(0)
|
||||
#define DBUG_PUSH(a1) do { } while(0)
|
||||
#define DBUG_SET(a1) do { } while(0)
|
||||
#define DBUG_SET_INITIAL(a1) do { } while(0)
|
||||
#define DBUG_POP() do { } while(0)
|
||||
#define DBUG_PROCESS(a1) do { } while(0)
|
||||
#define DBUG_SETJMP(a1) setjmp(a1)
|
||||
#define DBUG_LONGJMP(a1) longjmp(a1)
|
||||
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
|
||||
#define DBUG_END() do { } while(0)
|
||||
#define DBUG_ASSERT(A) do { } while(0)
|
||||
#define DBUG_LOCK_FILE do { } while(0)
|
||||
#define DBUG_FILE (stderr)
|
||||
#define DBUG_UNLOCK_FILE do { } while(0)
|
||||
#define DBUG_EXPLAIN(buf,len)
|
||||
#define DBUG_EXPLAIN_INITIAL(buf,len)
|
||||
#define DEBUGGER_OFF do { } while(0)
|
||||
#define DEBUGGER_ON do { } while(0)
|
||||
#define DBUG_ABORT() do { } while(0)
|
||||
#define DBUG_CRASH_ENTER(func)
|
||||
#define DBUG_CRASH_RETURN(val) do { return(val); } while(0)
|
||||
#define DBUG_CRASH_VOID_RETURN do { return; } while(0)
|
||||
#define DBUG_SUICIDE() do { } while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef EXTRA_DEBUG
|
||||
/**
|
||||
Sync points allow us to force the server to reach a certain line of code
|
||||
and block there until the client tells the server it is ok to go on.
|
||||
The client tells the server to block with SELECT GET_LOCK()
|
||||
and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult
|
||||
concurrency problems
|
||||
*/
|
||||
#define DBUG_SYNC_POINT(lock_name,lock_timeout) \
|
||||
debug_sync_point(lock_name,lock_timeout)
|
||||
void debug_sync_point(const char* lock_name, uint lock_timeout);
|
||||
#else
|
||||
#define DBUG_SYNC_POINT(lock_name,lock_timeout)
|
||||
#endif /* EXTRA_DEBUG */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if !defined(DBUG_OFF)
|
||||
#include <sstream>
|
||||
|
||||
/*
|
||||
A C++ interface to the DBUG_PUTS macro. The DBUG_LOG macro also
|
||||
takes two arguments. The first argument is the keyword, as that of the
|
||||
DBUG_PRINT. The 2nd argument 'v' will be passed to a C++ output stream.
|
||||
This enables the use of C++ style output stream operator. In the code, it
|
||||
will be used as follows:
|
||||
|
||||
DBUG_LOG("blob", "space: " << space_id);
|
||||
|
||||
Note: DBUG_PRINT() has a limitation of 1024 bytes for a single
|
||||
print out. This limitation is not there for DBUG_PUTS and DBUG_LOG
|
||||
macros.
|
||||
*/
|
||||
|
||||
#define DBUG_LOG(keyword, v) do { \
|
||||
std::ostringstream sout; \
|
||||
sout << v; \
|
||||
DBUG_PUTS(keyword, sout.str().c_str()); \
|
||||
} while(0)
|
||||
#endif /* DBUG_OFF */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* MY_DBUG_INCLUDED */
|
||||
100
demo/kugou/include/Common/include/mysql/my_dir.h
Normal file
100
demo/kugou/include/Common/include/mysql/my_dir.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MY_DIR_H
|
||||
#define MY_DIR_H
|
||||
|
||||
#include "my_global.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Defines for my_dir and my_stat */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define S_IROTH _S_IREAD
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#endif
|
||||
|
||||
#define MY_S_IFMT S_IFMT /* type of file */
|
||||
#define MY_S_IFDIR S_IFDIR /* directory */
|
||||
#define MY_S_IFCHR S_IFCHR /* character special */
|
||||
#define MY_S_IFBLK S_IFBLK /* block special */
|
||||
#define MY_S_IFREG S_IFREG /* regular */
|
||||
#define MY_S_IFIFO S_IFIFO /* fifo */
|
||||
#define MY_S_ISUID S_ISUID /* set user id on execution */
|
||||
#define MY_S_ISGID S_ISGID /* set group id on execution */
|
||||
#define MY_S_ISVTX S_ISVTX /* save swapped text even after use */
|
||||
#define MY_S_IREAD S_IREAD /* read permission, owner */
|
||||
#define MY_S_IWRITE S_IWRITE /* write permission, owner */
|
||||
#define MY_S_IEXEC S_IEXEC /* execute/search permission, owner */
|
||||
|
||||
#define MY_S_ISDIR(m) (((m) & MY_S_IFMT) == MY_S_IFDIR)
|
||||
#define MY_S_ISCHR(m) (((m) & MY_S_IFMT) == MY_S_IFCHR)
|
||||
#define MY_S_ISBLK(m) (((m) & MY_S_IFMT) == MY_S_IFBLK)
|
||||
#define MY_S_ISREG(m) (((m) & MY_S_IFMT) == MY_S_IFREG)
|
||||
#define MY_S_ISFIFO(m) (((m) & MY_S_IFMT) == MY_S_IFIFO)
|
||||
|
||||
#define MY_DONT_SORT 512 /* my_lib; Don't sort files */
|
||||
#define MY_WANT_STAT 1024 /* my_lib; stat files */
|
||||
|
||||
/* typedefs for my_dir & my_stat */
|
||||
|
||||
#if(_MSC_VER)
|
||||
#define MY_STAT struct _stati64 /* 64 bit file size */
|
||||
#else
|
||||
#define MY_STAT struct stat /* Orginal struct have what we need */
|
||||
#endif
|
||||
|
||||
/* Struct describing one file returned from my_dir */
|
||||
typedef struct fileinfo
|
||||
{
|
||||
char *name;
|
||||
MY_STAT *mystat;
|
||||
} FILEINFO;
|
||||
|
||||
typedef struct st_my_dir /* Struct returned from my_dir */
|
||||
{
|
||||
/*
|
||||
These members are just copies of parts of DYNAMIC_ARRAY structure,
|
||||
which is allocated right after the end of MY_DIR structure (MEM_ROOT
|
||||
for storing names is also resides there). We've left them here because
|
||||
we don't want to change code that uses my_dir.
|
||||
*/
|
||||
struct fileinfo *dir_entry;
|
||||
uint number_off_files;
|
||||
} MY_DIR;
|
||||
|
||||
extern MY_DIR *my_dir(const char *path,myf MyFlags);
|
||||
extern void my_dirend(MY_DIR *buffer);
|
||||
extern MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags);
|
||||
extern int my_fstat(int filenr, MY_STAT *stat_area, myf MyFlags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MY_DIR_H */
|
||||
|
||||
156
demo/kugou/include/Common/include/mysql/my_getopt.h
Normal file
156
demo/kugou/include/Common/include/mysql/my_getopt.h
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _my_getopt_h
|
||||
#define _my_getopt_h
|
||||
|
||||
#include "my_sys.h" /* loglevel */
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#define GET_NO_ARG 1
|
||||
#define GET_BOOL 2
|
||||
#define GET_INT 3
|
||||
#define GET_UINT 4
|
||||
#define GET_LONG 5
|
||||
#define GET_ULONG 6
|
||||
#define GET_LL 7
|
||||
#define GET_ULL 8
|
||||
#define GET_STR 9
|
||||
#define GET_STR_ALLOC 10
|
||||
#define GET_DISABLED 11
|
||||
#define GET_ENUM 12
|
||||
#define GET_SET 13
|
||||
#define GET_DOUBLE 14
|
||||
#define GET_FLAGSET 15
|
||||
#define GET_PASSWORD 16
|
||||
|
||||
#if SIZEOF_INT == 4
|
||||
#define GET_INT32 GET_INT
|
||||
#define GET_UINT32 GET_UINT
|
||||
#elif SIZEOF_LONG == 4
|
||||
#define GET_INT32 GET_LONG
|
||||
#define GET_UINT32 GET_ULONG
|
||||
#else
|
||||
#error Neither int or long is of 4 bytes width
|
||||
#endif
|
||||
|
||||
#define GET_ASK_ADDR 128
|
||||
#define GET_TYPE_MASK 127
|
||||
|
||||
/**
|
||||
Enumeration of the my_option::arg_type attributes.
|
||||
It should be noted that for historical reasons variables with the combination
|
||||
arg_type=NO_ARG, my_option::var_type=GET_BOOL still accepts
|
||||
arguments. This is someone counter intuitive and care should be taken
|
||||
if the code is refactored.
|
||||
*/
|
||||
enum get_opt_arg_type { NO_ARG, OPT_ARG, REQUIRED_ARG };
|
||||
|
||||
struct st_typelib;
|
||||
|
||||
struct my_option
|
||||
{
|
||||
const char *name; /**< Name of the option. name=NULL
|
||||
marks the end of the my_option[]
|
||||
array.
|
||||
*/
|
||||
int id; /**< For 0<id<=255 it's means one
|
||||
character for a short option
|
||||
(like -A), if >255 no short option
|
||||
is created, but a long option still
|
||||
can be identified uniquely in the
|
||||
my_get_one_option() callback.
|
||||
If an opton needs neither special
|
||||
treatment in the my_get_one_option()
|
||||
nor one-letter short equivalent
|
||||
use id=0.
|
||||
id=-1 is a special case and is used
|
||||
to generate deprecation warnings for
|
||||
plugin options. It should not be
|
||||
used for anything else.
|
||||
*/
|
||||
const char *comment; /**< option comment, for autom. --help.
|
||||
if it's NULL the option is not
|
||||
visible in --help.
|
||||
*/
|
||||
void *value; /**< A pointer to the variable value */
|
||||
void *u_max_value; /**< The user def. max variable value */
|
||||
struct st_typelib *typelib; /**< Pointer to possible values */
|
||||
ulong var_type; /**< GET_BOOL, GET_ULL, etc */
|
||||
enum get_opt_arg_type arg_type; /**< e.g. REQUIRED_ARG or OPT_ARG */
|
||||
longlong def_value; /**< Default value */
|
||||
longlong min_value; /**< Min allowed value (for numbers) */
|
||||
ulonglong max_value; /**< Max allowed value (for numbers) */
|
||||
longlong sub_size; /**< Unused */
|
||||
long block_size; /**< Value should be a mult. of this (for numbers) */
|
||||
void *app_type; /**< To be used by an application */
|
||||
};
|
||||
|
||||
|
||||
typedef my_bool (*my_get_one_option)(int, const struct my_option *, char *);
|
||||
/**
|
||||
Used to retrieve a reference to the object (variable) that holds the value
|
||||
for the given option. For example, if var_type is GET_UINT, the function
|
||||
must return a pointer to a variable of type uint. A argument is stored in
|
||||
the location pointed to by the returned pointer.
|
||||
*/
|
||||
typedef void *(*my_getopt_value)(const char *, size_t, const struct my_option *,
|
||||
int *);
|
||||
|
||||
|
||||
extern char *disabled_my_option;
|
||||
extern my_bool my_getopt_print_errors;
|
||||
extern my_bool my_getopt_skip_unknown;
|
||||
extern my_error_reporter my_getopt_error_reporter;
|
||||
|
||||
extern int handle_options (int *argc, char ***argv,
|
||||
const struct my_option *longopts, my_get_one_option);
|
||||
extern int my_handle_options (int *argc, char ***argv,
|
||||
const struct my_option *longopts,
|
||||
my_get_one_option,
|
||||
const char **command_list, my_bool ignore_unknown_option);
|
||||
extern void print_cmdline_password_warning();
|
||||
extern void my_cleanup_options(const struct my_option *options);
|
||||
extern void my_cleanup_options(const struct my_option *options);
|
||||
extern void my_print_help(const struct my_option *options);
|
||||
extern void my_print_variables(const struct my_option *options);
|
||||
extern void my_print_variables_ex(const struct my_option *options, FILE* file);
|
||||
extern void my_getopt_register_get_addr(my_getopt_value);
|
||||
|
||||
ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
|
||||
my_bool *fix);
|
||||
longlong getopt_ll_limit_value(longlong, const struct my_option *,
|
||||
my_bool *fix);
|
||||
double getopt_double_limit_value(double num, const struct my_option *optp,
|
||||
my_bool *fix);
|
||||
my_bool getopt_compare_strings(const char *s, const char *t, uint length);
|
||||
ulonglong max_of_int_range(int var_type);
|
||||
|
||||
ulonglong getopt_double2ulonglong(double);
|
||||
double getopt_ulonglong2double(ulonglong);
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* _my_getopt_h */
|
||||
|
||||
804
demo/kugou/include/Common/include/mysql/my_global.h
Normal file
804
demo/kugou/include/Common/include/mysql/my_global.h
Normal file
@@ -0,0 +1,804 @@
|
||||
/*
|
||||
Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MY_GLOBAL_INCLUDED
|
||||
#define MY_GLOBAL_INCLUDED
|
||||
|
||||
/*
|
||||
This include file should be included first in every header file.
|
||||
|
||||
This makes sure my_config.h is included to get platform specific
|
||||
symbols defined and it makes sure a lot of platform/compiler
|
||||
differences are mitigated.
|
||||
*/
|
||||
|
||||
#include "my_config.h"
|
||||
|
||||
#define __STDC_LIMIT_MACROS /* Enable C99 limit macros */
|
||||
#define __STDC_FORMAT_MACROS /* Enable C99 printf format macros */
|
||||
#define _USE_MATH_DEFINES /* Get access to M_PI, M_E, etc. in math.h */
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Include common headers.*/
|
||||
# include <winsock2.h>
|
||||
# include <ws2tcpip.h> /* SOCKET */
|
||||
# include <io.h> /* access(), chmod() */
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <errno.h> /* Recommended by debian */
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#if !defined(_WIN32)
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#ifdef MY_MSCRT_DEBUG
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
A lot of our programs uses asserts, so better to always include it
|
||||
This also fixes a problem when people uses DBUG_ASSERT without including
|
||||
assert.h
|
||||
*/
|
||||
#include <assert.h>
|
||||
|
||||
/* Include standard definitions of operator new and delete. */
|
||||
#ifdef __cplusplus
|
||||
# include <new>
|
||||
#endif
|
||||
|
||||
#include "my_compiler.h"
|
||||
|
||||
|
||||
/*
|
||||
InnoDB depends on some MySQL internals which other plugins should not
|
||||
need. This is because of InnoDB's foreign key support, "safe" binlog
|
||||
truncation, and other similar legacy features.
|
||||
|
||||
We define accessors for these internals unconditionally, but do not
|
||||
expose them in mysql/plugin.h. They are declared in ha_innodb.h for
|
||||
InnoDB's use.
|
||||
*/
|
||||
#define INNODB_COMPATIBILITY_HOOKS
|
||||
|
||||
/* Macros to make switching between C and C++ mode easier */
|
||||
#ifdef __cplusplus
|
||||
#define C_MODE_START extern "C" {
|
||||
#define C_MODE_END }
|
||||
#else
|
||||
#define C_MODE_START
|
||||
#define C_MODE_END
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
|
||||
#define HAVE_PSI_INTERFACE
|
||||
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
|
||||
|
||||
/* Make it easier to add conditional code in _expressions_ */
|
||||
#ifdef _WIN32
|
||||
#define IF_WIN(A,B) A
|
||||
#else
|
||||
#define IF_WIN(A,B) B
|
||||
#endif
|
||||
|
||||
#if defined (_WIN32)
|
||||
/*
|
||||
off_t is 32 bit long. We do not use C runtime functions
|
||||
with off_t but native Win32 file IO APIs, that work with
|
||||
64 bit offsets.
|
||||
*/
|
||||
#undef SIZEOF_OFF_T
|
||||
#define SIZEOF_OFF_T 8
|
||||
|
||||
static inline void sleep(unsigned long seconds)
|
||||
{
|
||||
Sleep(seconds * 1000);
|
||||
}
|
||||
|
||||
/* Define missing access() modes. */
|
||||
#define F_OK 0
|
||||
#define W_OK 2
|
||||
#define R_OK 4 /* Test for read permission. */
|
||||
|
||||
/* Define missing file locking constants. */
|
||||
#define F_RDLCK 1
|
||||
#define F_WRLCK 2
|
||||
#define F_UNLCK 3
|
||||
#define F_TO_EOF 0x3FFFFFFF
|
||||
|
||||
#define O_NONBLOCK 1 /* For emulation of fcntl() */
|
||||
|
||||
/*
|
||||
SHUT_RDWR is called SD_BOTH in windows and
|
||||
is defined to 2 in winsock2.h
|
||||
#define SD_BOTH 0x02
|
||||
*/
|
||||
#define SHUT_RDWR 0x02
|
||||
|
||||
/* Shared memory and named pipe connections are supported. */
|
||||
#define shared_memory_buffer_length 16000
|
||||
#define default_shared_memory_base_name "MYSQL"
|
||||
#endif /* _WIN32*/
|
||||
|
||||
/**
|
||||
Cast a member of a structure to the structure that contains it.
|
||||
|
||||
@param ptr Pointer to the member.
|
||||
@param type Type of the structure that contains the member.
|
||||
@param member Name of the member within the structure.
|
||||
*/
|
||||
#define my_container_of(ptr, type, member) \
|
||||
((type *)((char *)ptr - offsetof(type, member)))
|
||||
|
||||
/* an assert that works at compile-time. only for constant expression */
|
||||
#define compile_time_assert(X) \
|
||||
do \
|
||||
{ \
|
||||
typedef char compile_time_assert[(X) ? 1 : -1] MY_ATTRIBUTE((unused)); \
|
||||
} while(0)
|
||||
|
||||
#define QUOTE_ARG(x) #x /* Quote argument (before cpp) */
|
||||
#define STRINGIFY_ARG(x) QUOTE_ARG(x) /* Quote argument, after cpp */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SO_EXT ".dll"
|
||||
#elif defined(__APPLE__)
|
||||
#define SO_EXT ".dylib"
|
||||
#else
|
||||
#define SO_EXT ".so"
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_UINT)
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
#endif
|
||||
|
||||
#define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
|
||||
#define MY_TEST(a) ((a) ? 1 : 0)
|
||||
#define set_if_bigger(a,b) do { if ((a) < (b)) (a)=(b); } while(0)
|
||||
#define set_if_smaller(a,b) do { if ((a) > (b)) (a)=(b); } while(0)
|
||||
#define test_all_bits(a,b) (((a) & (b)) == (b))
|
||||
#define array_elements(A) ((uint) (sizeof(A)/sizeof(A[0])))
|
||||
|
||||
/* Define some general constants */
|
||||
#ifndef TRUE
|
||||
#define TRUE (1) /* Logical true */
|
||||
#define FALSE (0) /* Logical false */
|
||||
#endif
|
||||
|
||||
/* Some types that is different between systems */
|
||||
|
||||
typedef int File; /* File descriptor */
|
||||
#ifdef _WIN32
|
||||
typedef SOCKET my_socket;
|
||||
#else
|
||||
typedef int my_socket; /* File descriptor for sockets */
|
||||
#define INVALID_SOCKET -1
|
||||
#endif
|
||||
C_MODE_START
|
||||
typedef void (*sig_return)();/* Returns type from signal */
|
||||
C_MODE_END
|
||||
#if defined(__GNUC__)
|
||||
typedef char pchar; /* Mixed prototypes can take char */
|
||||
typedef char pbool; /* Mixed prototypes can take char */
|
||||
#else
|
||||
typedef int pchar; /* Mixed prototypes can't take char */
|
||||
typedef int pbool; /* Mixed prototypes can't take char */
|
||||
#endif
|
||||
C_MODE_START
|
||||
typedef int (*qsort_cmp)(const void *,const void *);
|
||||
typedef int (*qsort_cmp2)(const void*, const void *,const void *);
|
||||
C_MODE_END
|
||||
#ifdef _WIN32
|
||||
typedef int socket_len_t;
|
||||
typedef int sigset_t;
|
||||
typedef int mode_t;
|
||||
typedef SSIZE_T ssize_t;
|
||||
#else
|
||||
typedef socklen_t socket_len_t;
|
||||
#endif
|
||||
typedef socket_len_t SOCKET_SIZE_TYPE; /* Used by NDB */
|
||||
|
||||
/* file create flags */
|
||||
|
||||
#ifndef O_SHARE /* Probably not windows */
|
||||
#define O_SHARE 0 /* Flag to my_open for shared files */
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0 /* Flag to my_open for binary files */
|
||||
#endif
|
||||
#ifndef FILE_BINARY
|
||||
#define FILE_BINARY O_BINARY /* Flag to my_fopen for binary streams */
|
||||
#endif
|
||||
#ifdef HAVE_FCNTL
|
||||
#define HAVE_FCNTL_LOCK
|
||||
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
|
||||
#endif
|
||||
#endif /* O_SHARE */
|
||||
|
||||
#ifndef O_TEMPORARY
|
||||
#define O_TEMPORARY 0
|
||||
#endif
|
||||
#ifndef O_SHORT_LIVED
|
||||
#define O_SHORT_LIVED 0
|
||||
#endif
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
|
||||
/* additional file share flags for win32 */
|
||||
#ifdef _WIN32
|
||||
#define _SH_DENYRWD 0x110 /* deny read/write mode & delete */
|
||||
#define _SH_DENYWRD 0x120 /* deny write mode & delete */
|
||||
#define _SH_DENYRDD 0x130 /* deny read mode & delete */
|
||||
#define _SH_DENYDEL 0x140 /* deny delete only */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
|
||||
/* General constants */
|
||||
#define FN_LEN 256 /* Max file name len */
|
||||
#define FN_HEADLEN 253 /* Max length of filepart of file name */
|
||||
#define FN_EXTLEN 20 /* Max length of extension (part of FN_LEN) */
|
||||
#define FN_REFLEN 512 /* Max length of full path-name */
|
||||
#define FN_REFLEN_SE 4000 /* Max length of full path-name in SE */
|
||||
#define FN_EXTCHAR '.'
|
||||
#define FN_HOMELIB '~' /* ~/ is used as abbrev for home dir */
|
||||
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
|
||||
#define FN_PARENTDIR ".." /* Parent directory; Must be a string */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define FN_LIBCHAR '\\'
|
||||
#define FN_LIBCHAR2 '/'
|
||||
#define FN_DIRSEP "/\\" /* Valid directory separators */
|
||||
#define FN_EXEEXT ".exe"
|
||||
#define FN_SOEXT ".dll"
|
||||
#define FN_ROOTDIR "\\"
|
||||
#define FN_DEVCHAR ':'
|
||||
#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
|
||||
#else
|
||||
#define FN_LIBCHAR '/'
|
||||
/*
|
||||
FN_LIBCHAR2 is not defined on !Windows. Use is_directory_separator().
|
||||
*/
|
||||
#define FN_DIRSEP "/" /* Valid directory separators */
|
||||
#define FN_EXEEXT ""
|
||||
#define FN_SOEXT ".so"
|
||||
#define FN_ROOTDIR "/"
|
||||
#endif
|
||||
|
||||
static inline int is_directory_separator(char c)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return c == FN_LIBCHAR || c == FN_LIBCHAR2;
|
||||
#else
|
||||
return c == FN_LIBCHAR;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
MY_FILE_MIN is Windows speciality and is used to quickly detect
|
||||
the mismatch of CRT and mysys file IO usage on Windows at runtime.
|
||||
CRT file descriptors can be in the range 0-2047, whereas descriptors returned
|
||||
by my_open() will start with 2048. If a file descriptor with value less then
|
||||
MY_FILE_MIN is passed to mysys IO function, chances are it stemms from
|
||||
open()/fileno() and not my_open()/my_fileno.
|
||||
|
||||
For Posix, mysys functions are light wrappers around libc, and MY_FILE_MIN
|
||||
is logically 0.
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_FILE_MIN 2048
|
||||
#else
|
||||
#define MY_FILE_MIN 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
MY_NFILE is the default size of my_file_info array.
|
||||
|
||||
It is larger on Windows, because it all file handles are stored in my_file_info
|
||||
Default size is 16384 and this should be enough for most cases.If it is not
|
||||
enough, --max-open-files with larger value can be used.
|
||||
|
||||
For Posix , my_file_info array is only used to store filenames for
|
||||
error reporting and its size is not a limitation for number of open files.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#define MY_NFILE (16384 + MY_FILE_MIN)
|
||||
#else
|
||||
#define MY_NFILE 64
|
||||
#endif
|
||||
|
||||
#define OS_FILE_LIMIT UINT_MAX
|
||||
|
||||
/*
|
||||
Io buffer size; Must be a power of 2 and a multiple of 512. May be
|
||||
smaller what the disk page size. This influences the speed of the
|
||||
isam btree library. eg to big to slow.
|
||||
*/
|
||||
#define IO_SIZE 4096
|
||||
/*
|
||||
How much overhead does malloc have. The code often allocates
|
||||
something like 1024-MALLOC_OVERHEAD bytes
|
||||
*/
|
||||
#define MALLOC_OVERHEAD 8
|
||||
|
||||
/* get memory in huncs */
|
||||
#define ONCE_ALLOC_INIT (uint) (4096-MALLOC_OVERHEAD)
|
||||
/* Typical record cash */
|
||||
#define RECORD_CACHE_SIZE (uint) (64*1024-MALLOC_OVERHEAD)
|
||||
/* Typical key cash */
|
||||
#define KEY_CACHE_SIZE (uint) (8*1024*1024)
|
||||
/* Default size of a key cache block */
|
||||
#define KEY_CACHE_BLOCK_SIZE (uint) 1024
|
||||
|
||||
|
||||
/* Some defines of functions for portability */
|
||||
|
||||
#if (_WIN32)
|
||||
#if !defined(_WIN64)
|
||||
inline double my_ulonglong2double(unsigned long long value)
|
||||
{
|
||||
long long nr=(long long) value;
|
||||
if (nr >= 0)
|
||||
return (double) nr;
|
||||
return (18446744073709551616.0 + (double) nr);
|
||||
}
|
||||
#define ulonglong2double my_ulonglong2double
|
||||
#define my_off_t2double my_ulonglong2double
|
||||
#endif /* _WIN64 */
|
||||
inline unsigned long long my_double2ulonglong(double d)
|
||||
{
|
||||
double t= d - (double) 0x8000000000000000ULL;
|
||||
|
||||
if (t >= 0)
|
||||
return ((unsigned long long) t) + 0x8000000000000000ULL;
|
||||
return (unsigned long long) d;
|
||||
}
|
||||
#define double2ulonglong my_double2ulonglong
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef ulonglong2double
|
||||
#define ulonglong2double(A) ((double) (ulonglong) (A))
|
||||
#define my_off_t2double(A) ((double) (my_off_t) (A))
|
||||
#endif
|
||||
#ifndef double2ulonglong
|
||||
#define double2ulonglong(A) ((ulonglong) (double) (A))
|
||||
#endif
|
||||
|
||||
#define INT_MIN64 (~0x7FFFFFFFFFFFFFFFLL)
|
||||
#define INT_MAX64 0x7FFFFFFFFFFFFFFFLL
|
||||
#define INT_MIN32 (~0x7FFFFFFFL)
|
||||
#define INT_MAX32 0x7FFFFFFFL
|
||||
#define UINT_MAX32 0xFFFFFFFFL
|
||||
#define INT_MIN24 (~0x007FFFFF)
|
||||
#define INT_MAX24 0x007FFFFF
|
||||
#define UINT_MAX24 0x00FFFFFF
|
||||
#define INT_MIN16 (~0x7FFF)
|
||||
#define INT_MAX16 0x7FFF
|
||||
#define UINT_MAX16 0xFFFF
|
||||
#define INT_MIN8 (~0x7F)
|
||||
#define INT_MAX8 0x7F
|
||||
#define UINT_MAX8 0xFF
|
||||
|
||||
#ifndef SIZE_T_MAX
|
||||
#define SIZE_T_MAX (~((size_t) 0))
|
||||
#endif
|
||||
|
||||
// Our ifdef trickery for my_isfinite does not work with gcc/solaris unless we:
|
||||
#ifdef HAVE_IEEEFP_H
|
||||
#include <ieeefp.h>
|
||||
#endif
|
||||
|
||||
#if (__cplusplus >= 201103L)
|
||||
/* For C++11 use the new std functions rather than C99 macros. */
|
||||
#include <cmath>
|
||||
#define my_isfinite(X) std::isfinite(X)
|
||||
#define my_isnan(X) std::isnan(X)
|
||||
#define my_isinf(X) std::isinf(X)
|
||||
#else
|
||||
#ifdef HAVE_LLVM_LIBCPP /* finite is deprecated in libc++ */
|
||||
#define my_isfinite(X) isfinite(X)
|
||||
#elif defined _WIN32
|
||||
#define my_isfinite(X) _finite(X)
|
||||
#else
|
||||
#define my_isfinite(X) finite(X)
|
||||
#endif
|
||||
#define my_isnan(X) isnan(X)
|
||||
#ifdef HAVE_ISINF
|
||||
/* System-provided isinf() is available and safe to use */
|
||||
#define my_isinf(X) isinf(X)
|
||||
#else /* !HAVE_ISINF */
|
||||
#define my_isinf(X) (!my_isfinite(X) && !my_isnan(X))
|
||||
#endif
|
||||
#endif /* __cplusplus >= 201103L */
|
||||
|
||||
/*
|
||||
Max size that must be added to a so that we know Size to make
|
||||
adressable obj.
|
||||
*/
|
||||
#if SIZEOF_CHARP == 4
|
||||
typedef long my_ptrdiff_t;
|
||||
#else
|
||||
typedef long long my_ptrdiff_t;
|
||||
#endif
|
||||
|
||||
#define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1))
|
||||
#define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double))
|
||||
/* Size to make adressable obj. */
|
||||
#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size)
|
||||
#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B))
|
||||
|
||||
/*
|
||||
Custom version of standard offsetof() macro which can be used to get
|
||||
offsets of members in class for non-POD types (according to the current
|
||||
version of C++ standard offsetof() macro can't be used in such cases and
|
||||
attempt to do so causes warnings to be emitted, OTOH in many cases it is
|
||||
still OK to assume that all instances of the class has the same offsets
|
||||
for the same members).
|
||||
|
||||
This is temporary solution which should be removed once File_parser class
|
||||
and related routines are refactored.
|
||||
*/
|
||||
|
||||
#define my_offsetof(TYPE, MEMBER) \
|
||||
((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
|
||||
|
||||
#define NullS (char *) 0
|
||||
|
||||
#ifdef _WIN32
|
||||
#define STDCALL __stdcall
|
||||
#else
|
||||
#define STDCALL
|
||||
#endif
|
||||
|
||||
/* Typdefs for easyier portability */
|
||||
|
||||
typedef unsigned char uchar; /* Short for unsigned char */
|
||||
typedef signed char int8; /* Signed integer >= 8 bits */
|
||||
typedef unsigned char uint8; /* Unsigned integer >= 8 bits */
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
#if SIZEOF_INT == 4
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
#elif SIZEOF_LONG == 4
|
||||
typedef long int32;
|
||||
typedef unsigned long uint32;
|
||||
#else
|
||||
#error Neither int or long is of 4 bytes width
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ULONG)
|
||||
typedef unsigned long ulong; /* Short for unsigned long */
|
||||
#endif
|
||||
/*
|
||||
Using [unsigned] long long is preferable as [u]longlong because we use
|
||||
[unsigned] long long unconditionally in many places,
|
||||
for example in constants with [U]LL suffix.
|
||||
*/
|
||||
typedef unsigned long long int ulonglong; /* ulong or unsigned long long */
|
||||
typedef long long int longlong;
|
||||
typedef longlong int64;
|
||||
typedef ulonglong uint64;
|
||||
|
||||
#if defined (_WIN32)
|
||||
typedef unsigned __int64 my_ulonglong;
|
||||
#else
|
||||
typedef unsigned long long my_ulonglong;
|
||||
#endif
|
||||
|
||||
#if SIZEOF_CHARP == SIZEOF_INT
|
||||
typedef int intptr;
|
||||
#elif SIZEOF_CHARP == SIZEOF_LONG
|
||||
typedef long intptr;
|
||||
#elif SIZEOF_CHARP == SIZEOF_LONG_LONG
|
||||
typedef long long intptr;
|
||||
#else
|
||||
#error sizeof(void *) is neither sizeof(int) nor sizeof(long) nor sizeof(long long)
|
||||
#endif
|
||||
|
||||
#define MY_ERRPTR ((void*)(intptr)1)
|
||||
|
||||
#if defined(_WIN32)
|
||||
typedef unsigned long long my_off_t;
|
||||
typedef unsigned long long os_off_t;
|
||||
#else
|
||||
typedef off_t os_off_t;
|
||||
#if SIZEOF_OFF_T > 4
|
||||
typedef ulonglong my_off_t;
|
||||
#else
|
||||
typedef unsigned long my_off_t;
|
||||
#endif
|
||||
#endif /*_WIN32*/
|
||||
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
|
||||
|
||||
/*
|
||||
TODO Convert these to use Bitmap class.
|
||||
*/
|
||||
typedef ulonglong table_map; /* Used for table bits in join */
|
||||
typedef ulonglong nesting_map; /* Used for flags of nesting constructs */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define socket_errno WSAGetLastError()
|
||||
#define SOCKET_EINTR WSAEINTR
|
||||
#define SOCKET_EAGAIN WSAEINPROGRESS
|
||||
#define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define SOCKET_EADDRINUSE WSAEADDRINUSE
|
||||
#define SOCKET_ETIMEDOUT WSAETIMEDOUT
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define SOCKET_ENFILE ENFILE
|
||||
#define SOCKET_EMFILE EMFILE
|
||||
#else /* Unix */
|
||||
#define socket_errno errno
|
||||
#define closesocket(A) close(A)
|
||||
#define SOCKET_EINTR EINTR
|
||||
#define SOCKET_EAGAIN EAGAIN
|
||||
#define SOCKET_EWOULDBLOCK EWOULDBLOCK
|
||||
#define SOCKET_EADDRINUSE EADDRINUSE
|
||||
#define SOCKET_ETIMEDOUT ETIMEDOUT
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
#define SOCKET_ENFILE ENFILE
|
||||
#define SOCKET_EMFILE EMFILE
|
||||
#endif
|
||||
|
||||
typedef int myf; /* Type of MyFlags in my_funcs */
|
||||
typedef char my_bool; /* Small bool */
|
||||
|
||||
/* Macros for converting *constants* to the right type */
|
||||
#define MYF(v) (myf) (v)
|
||||
|
||||
/* Some helper macros */
|
||||
#define YESNO(X) ((X) ? "yes" : "no")
|
||||
|
||||
#define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */
|
||||
|
||||
#include <my_byteorder.h>
|
||||
|
||||
#ifdef HAVE_CHARSET_utf8
|
||||
#define MYSQL_UNIVERSAL_CLIENT_CHARSET "utf8"
|
||||
#else
|
||||
#define MYSQL_UNIVERSAL_CLIENT_CHARSET MYSQL_DEFAULT_CHARSET_NAME
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
|
||||
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
|
||||
#define dlclose(lib) FreeLibrary((HMODULE)lib)
|
||||
#ifndef HAVE_DLOPEN
|
||||
#define HAVE_DLOPEN
|
||||
#endif
|
||||
#define DLERROR_GENERATE(errmsg, error_number) \
|
||||
char win_errormsg[2048]; \
|
||||
if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, \
|
||||
0, error_number, 0, win_errormsg, 2048, NULL)) \
|
||||
{ \
|
||||
char *ptr; \
|
||||
for (ptr= &win_errormsg[0] + strlen(win_errormsg) - 1; \
|
||||
ptr >= &win_errormsg[0] && strchr("\r\n\t\0x20", *ptr); \
|
||||
ptr--) \
|
||||
*ptr= 0; \
|
||||
errmsg= win_errormsg; \
|
||||
} \
|
||||
else \
|
||||
errmsg= ""
|
||||
#define dlerror() ""
|
||||
#define dlopen_errno GetLastError()
|
||||
|
||||
#else /* _WIN32 */
|
||||
#define DLERROR_GENERATE(errmsg, error_number) errmsg= dlerror()
|
||||
#define dlopen_errno errno
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* Length of decimal number represented by INT32. */
|
||||
#define MY_INT32_NUM_DECIMAL_DIGITS 11U
|
||||
|
||||
/* Length of decimal number represented by INT64. */
|
||||
#define MY_INT64_NUM_DECIMAL_DIGITS 21U
|
||||
|
||||
/* Define some useful general macros (should be done after all headers). */
|
||||
#define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
|
||||
#if !defined(__cplusplus) && !defined(bool)
|
||||
#define bool In_C_you_should_use_my_bool_instead()
|
||||
#endif
|
||||
|
||||
/*
|
||||
MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
|
||||
(i.e variables) for usage in storage engine loadable plugins.
|
||||
Outside of Windows, it is dummy.
|
||||
*/
|
||||
#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
|
||||
#define MYSQL_PLUGIN_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_IMPORT
|
||||
#endif
|
||||
|
||||
#include <my_dbug.h>
|
||||
|
||||
#ifdef EMBEDDED_LIBRARY
|
||||
#define NO_EMBEDDED_ACCESS_CHECKS
|
||||
/* Things we don't need in the embedded version of MySQL */
|
||||
#undef HAVE_OPENSSL
|
||||
#endif /* EMBEDDED_LIBRARY */
|
||||
|
||||
|
||||
enum loglevel {
|
||||
ERROR_LEVEL= 0,
|
||||
WARNING_LEVEL= 1,
|
||||
INFORMATION_LEVEL= 2
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
/****************************************************************************
|
||||
** Replacements for localtime_r and gmtime_r
|
||||
****************************************************************************/
|
||||
|
||||
static inline struct tm *localtime_r(const time_t *timep, struct tm *tmp)
|
||||
{
|
||||
localtime_s(tmp, timep);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static inline struct tm *gmtime_r(const time_t *clock, struct tm *res)
|
||||
{
|
||||
gmtime_s(res, clock);
|
||||
return res;
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifndef HAVE_STRUCT_TIMESPEC /* Windows before VS2015 */
|
||||
/*
|
||||
Declare a union to make sure FILETIME is properly aligned
|
||||
so it can be used directly as a 64 bit value. The value
|
||||
stored is in 100ns units.
|
||||
*/
|
||||
union ft64 {
|
||||
FILETIME ft;
|
||||
__int64 i64;
|
||||
};
|
||||
|
||||
struct timespec {
|
||||
union ft64 tv;
|
||||
/* The max timeout value in millisecond for native_cond_timedwait */
|
||||
long max_timeout_msec;
|
||||
};
|
||||
|
||||
#endif /* !HAVE_STRUCT_TIMESPEC */
|
||||
|
||||
C_MODE_START
|
||||
extern ulonglong my_getsystime(void);
|
||||
C_MODE_END
|
||||
|
||||
static inline void set_timespec_nsec(struct timespec *abstime, ulonglong nsec)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TIMESPEC
|
||||
ulonglong now= my_getsystime() + (nsec / 100);
|
||||
ulonglong tv_sec= now / 10000000ULL;
|
||||
#if SIZEOF_TIME_T < SIZEOF_LONG_LONG
|
||||
/* Ensure that the number of seconds don't overflow. */
|
||||
tv_sec= MY_MIN(tv_sec, ((ulonglong)INT_MAX32));
|
||||
#endif
|
||||
abstime->tv_sec= (time_t)tv_sec;
|
||||
abstime->tv_nsec= (now % 10000000ULL) * 100 + (nsec % 100);
|
||||
#else /* !HAVE_STRUCT_TIMESPEC */
|
||||
ulonglong max_timeout_msec= (nsec / 1000000);
|
||||
union ft64 tv;
|
||||
GetSystemTimeAsFileTime(&tv.ft);
|
||||
abstime->tv.i64= tv.i64 + (__int64)(nsec / 100);
|
||||
#if SIZEOF_LONG < SIZEOF_LONG_LONG
|
||||
/* Ensure that the msec value doesn't overflow. */
|
||||
max_timeout_msec= MY_MIN(max_timeout_msec, ((ulonglong)INT_MAX32));
|
||||
#endif
|
||||
abstime->max_timeout_msec= (long)max_timeout_msec;
|
||||
#endif /* !HAVE_STRUCT_TIMESPEC */
|
||||
}
|
||||
|
||||
static inline void set_timespec(struct timespec *abstime, ulonglong sec)
|
||||
{
|
||||
set_timespec_nsec(abstime, sec * 1000000000ULL);
|
||||
}
|
||||
|
||||
/**
|
||||
Compare two timespec structs.
|
||||
|
||||
@retval 1 If ts1 ends after ts2.
|
||||
@retval -1 If ts1 ends before ts2.
|
||||
@retval 0 If ts1 is equal to ts2.
|
||||
*/
|
||||
static inline int cmp_timespec(struct timespec *ts1, struct timespec *ts2)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TIMESPEC
|
||||
if (ts1->tv_sec > ts2->tv_sec ||
|
||||
(ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec > ts2->tv_nsec))
|
||||
return 1;
|
||||
if (ts1->tv_sec < ts2->tv_sec ||
|
||||
(ts1->tv_sec == ts2->tv_sec && ts1->tv_nsec < ts2->tv_nsec))
|
||||
return -1;
|
||||
#else
|
||||
if (ts1->tv.i64 > ts2->tv.i64)
|
||||
return 1;
|
||||
if (ts1->tv.i64 < ts2->tv.i64)
|
||||
return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline ulonglong diff_timespec(struct timespec *ts1, struct timespec *ts2)
|
||||
{
|
||||
#ifdef HAVE_STRUCT_TIMESPEC
|
||||
return (ts1->tv_sec - ts2->tv_sec) * 1000000000ULL +
|
||||
ts1->tv_nsec - ts2->tv_nsec;
|
||||
#else
|
||||
return (ts1->tv.i64 - ts2->tv.i64) * 100;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef int MY_MODE;
|
||||
#else
|
||||
typedef mode_t MY_MODE;
|
||||
#endif /* _WIN32 */
|
||||
|
||||
/* File permissions */
|
||||
#define USER_READ (1L << 0)
|
||||
#define USER_WRITE (1L << 1)
|
||||
#define USER_EXECUTE (1L << 2)
|
||||
#define GROUP_READ (1L << 3)
|
||||
#define GROUP_WRITE (1L << 4)
|
||||
#define GROUP_EXECUTE (1L << 5)
|
||||
#define OTHERS_READ (1L << 6)
|
||||
#define OTHERS_WRITE (1L << 7)
|
||||
#define OTHERS_EXECUTE (1L << 8)
|
||||
#define USER_RWX USER_READ | USER_WRITE | USER_EXECUTE
|
||||
#define GROUP_RWX GROUP_READ | GROUP_WRITE | GROUP_EXECUTE
|
||||
#define OTHERS_RWX OTHERS_READ | OTHERS_WRITE | OTHERS_EXECUTE
|
||||
|
||||
/* Defaults */
|
||||
#define DEFAULT_SSL_CA_CERT "ca.pem"
|
||||
#define DEFAULT_SSL_CA_KEY "ca-key.pem"
|
||||
#define DEFAULT_SSL_SERVER_CERT "server-cert.pem"
|
||||
#define DEFAULT_SSL_SERVER_KEY "server-key.pem"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define strcasecmp _stricmp
|
||||
#endif
|
||||
#endif // MY_GLOBAL_INCLUDED
|
||||
57
demo/kugou/include/Common/include/mysql/my_list.h
Normal file
57
demo/kugou/include/Common/include/mysql/my_list.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _list_h_
|
||||
#define _list_h_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct st_list {
|
||||
struct st_list *prev,*next;
|
||||
void *data;
|
||||
} LIST;
|
||||
|
||||
typedef int (*list_walk_action)(void *,void *);
|
||||
|
||||
extern LIST *list_add(LIST *root,LIST *element);
|
||||
extern LIST *list_delete(LIST *root,LIST *element);
|
||||
extern LIST *list_cons(void *data,LIST *root);
|
||||
extern LIST *list_reverse(LIST *root);
|
||||
extern void list_free(LIST *root,unsigned int free_data);
|
||||
extern unsigned int list_length(LIST *);
|
||||
extern int list_walk(LIST *,list_walk_action action,unsigned char * argument);
|
||||
|
||||
#define list_rest(a) ((a)->next)
|
||||
#define list_push(a,b) (a)=list_cons((b),(a))
|
||||
#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
992
demo/kugou/include/Common/include/mysql/my_sys.h
Normal file
992
demo/kugou/include/Common/include/mysql/my_sys.h
Normal file
@@ -0,0 +1,992 @@
|
||||
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _my_sys_h
|
||||
#define _my_sys_h
|
||||
|
||||
#include "my_global.h" /* C_MODE_START, C_MODE_END */
|
||||
#include "m_ctype.h" /* for CHARSET_INFO */
|
||||
|
||||
#include "my_thread.h" /* Needed for psi.h */
|
||||
#include "mysql/psi/psi.h"
|
||||
#include "mysql/service_mysql_alloc.h"
|
||||
#include "mysql/psi/mysql_memory.h"
|
||||
#include "mysql/psi/mysql_thread.h"
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
# include <valgrind/valgrind.h>
|
||||
# define MEM_MALLOCLIKE_BLOCK(p1, p2, p3, p4) VALGRIND_MALLOCLIKE_BLOCK(p1, p2, p3, p4)
|
||||
# define MEM_FREELIKE_BLOCK(p1, p2) VALGRIND_FREELIKE_BLOCK(p1, p2)
|
||||
# include <valgrind/memcheck.h>
|
||||
# define MEM_UNDEFINED(a,len) VALGRIND_MAKE_MEM_UNDEFINED(a,len)
|
||||
# define MEM_NOACCESS(a,len) VALGRIND_MAKE_MEM_NOACCESS(a,len)
|
||||
# define MEM_CHECK_ADDRESSABLE(a,len) VALGRIND_CHECK_MEM_IS_ADDRESSABLE(a,len)
|
||||
#else /* HAVE_VALGRIND */
|
||||
# define MEM_MALLOCLIKE_BLOCK(p1, p2, p3, p4) do {} while (0)
|
||||
# define MEM_FREELIKE_BLOCK(p1, p2) do {} while (0)
|
||||
# define MEM_UNDEFINED(a,len) ((void) 0)
|
||||
# define MEM_NOACCESS(a,len) ((void) 0)
|
||||
# define MEM_CHECK_ADDRESSABLE(a,len) ((void) 0)
|
||||
#endif /* HAVE_VALGRIND */
|
||||
|
||||
#include <typelib.h>
|
||||
|
||||
#define MY_INIT(name) { my_progname= name; my_init(); }
|
||||
|
||||
/**
|
||||
Max length of an error message generated by mysys utilities.
|
||||
Some mysys functions produce error messages. These mostly go
|
||||
to stderr.
|
||||
This constant defines the size of the buffer used to format
|
||||
the message. It should be kept in sync with MYSQL_ERRMSG_SIZE,
|
||||
since sometimes mysys errors are stored in the server diagnostics
|
||||
area, and we would like to avoid unexpected truncation.
|
||||
*/
|
||||
#define MYSYS_ERRMSG_SIZE (512)
|
||||
#define MYSYS_STRERROR_SIZE (128)
|
||||
|
||||
#define MY_FILE_ERROR ((size_t) -1)
|
||||
|
||||
/* General bitmaps for my_func's */
|
||||
#define MY_FFNF 1 /* Fatal if file not found */
|
||||
#define MY_FNABP 2 /* Fatal if not all bytes read/writen */
|
||||
#define MY_NABP 4 /* Error if not all bytes read/writen */
|
||||
#define MY_FAE 8 /* Fatal if any error */
|
||||
#define MY_WME 16 /* Write message on error */
|
||||
#define MY_WAIT_IF_FULL 32 /* Wait and try again if disk full error */
|
||||
#define MY_IGNORE_BADFD 32 /* my_sync: ignore 'bad descriptor' errors */
|
||||
#define MY_SYNC_DIR 8192 /* my_create/delete/rename: sync directory */
|
||||
#define MY_UNUSED 64 /* Unused (was support for RAID) */
|
||||
#define MY_FULL_IO 512 /* For my_read - loop intil I/O is complete */
|
||||
#define MY_DONT_CHECK_FILESIZE 128 /* Option to init_io_cache() */
|
||||
#define MY_LINK_WARNING 32 /* my_redel() gives warning if links */
|
||||
#define MY_COPYTIME 64 /* my_redel() copys time */
|
||||
#define MY_DELETE_OLD 256 /* my_create_with_symlink() */
|
||||
#define MY_RESOLVE_LINK 128 /* my_realpath(); Only resolve links */
|
||||
#define MY_HOLD_ORIGINAL_MODES 128 /* my_copy() holds to file modes */
|
||||
#define MY_REDEL_MAKE_BACKUP 256
|
||||
#define MY_REDEL_NO_COPY_STAT 512 /* my_redel() doesn't call my_copystat() */
|
||||
#define MY_SEEK_NOT_DONE 32 /* my_lock may have to do a seek */
|
||||
#define MY_DONT_WAIT 64 /* my_lock() don't wait if can't lock */
|
||||
#define MY_ZEROFILL 32 /* my_malloc(), fill array with zero */
|
||||
#define MY_ALLOW_ZERO_PTR 64 /* my_realloc() ; zero ptr -> malloc */
|
||||
#define MY_FREE_ON_ERROR 128 /* my_realloc() ; Free old ptr on error */
|
||||
#define MY_HOLD_ON_ERROR 256 /* my_realloc() ; Return old ptr on error */
|
||||
#define MY_DONT_OVERWRITE_FILE 1024 /* my_copy: Don't overwrite file */
|
||||
#define MY_THREADSAFE 2048 /* my_seek(): lock fd mutex */
|
||||
#define MY_SYNC 4096 /* my_copy(): sync dst file */
|
||||
|
||||
#define MYF_RW MYF(MY_WME+MY_NABP) /* For my_read & my_write */
|
||||
|
||||
#define MY_CHECK_ERROR 1 /* Params to my_end; Check open-close */
|
||||
#define MY_GIVE_INFO 2 /* Give time info about process*/
|
||||
#define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */
|
||||
|
||||
/* Flags for my_error() */
|
||||
#define ME_BELL 4 /* DEPRECATED: Ring bell then printing message */
|
||||
#define ME_ERRORLOG 64 /* Write the error message to error log */
|
||||
#define ME_FATALERROR 1024 /* Fatal statement error */
|
||||
|
||||
/* Bits in last argument to fn_format */
|
||||
#define MY_REPLACE_DIR 1 /* replace dir in name with 'dir' */
|
||||
#define MY_REPLACE_EXT 2 /* replace extension with 'ext' */
|
||||
#define MY_UNPACK_FILENAME 4 /* Unpack name (~ -> home) */
|
||||
#define MY_PACK_FILENAME 8 /* Pack name (home -> ~) */
|
||||
#define MY_RESOLVE_SYMLINKS 16 /* Resolve all symbolic links */
|
||||
#define MY_RETURN_REAL_PATH 32 /* return full path for file */
|
||||
#define MY_SAFE_PATH 64 /* Return NULL if too long path */
|
||||
#define MY_RELATIVE_PATH 128 /* name is relative to 'dir' */
|
||||
#define MY_APPEND_EXT 256 /* add 'ext' as additional extension*/
|
||||
|
||||
|
||||
/* My seek flags */
|
||||
#define MY_SEEK_SET 0
|
||||
#define MY_SEEK_CUR 1
|
||||
#define MY_SEEK_END 2
|
||||
|
||||
/* Some constants */
|
||||
#define MY_WAIT_FOR_USER_TO_FIX_PANIC 60 /* in seconds */
|
||||
#define MY_WAIT_GIVE_USER_A_MESSAGE 10 /* Every 10 times of prev */
|
||||
#define MIN_COMPRESS_LENGTH 50 /* Don't compress small bl. */
|
||||
#define DFLT_INIT_HITS 3
|
||||
|
||||
/* root_alloc flags */
|
||||
#define MY_KEEP_PREALLOC 1
|
||||
#define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */
|
||||
|
||||
/* Internal error numbers (for assembler functions) */
|
||||
#define MY_ERRNO_EDOM 33
|
||||
#define MY_ERRNO_ERANGE 34
|
||||
|
||||
/* Bits for get_date timeflag */
|
||||
#define GETDATE_DATE_TIME 1
|
||||
#define GETDATE_SHORT_DATE 2
|
||||
#define GETDATE_HHMMSSTIME 4
|
||||
#define GETDATE_GMT 8
|
||||
#define GETDATE_FIXEDLENGTH 16
|
||||
#define GETDATE_T_DELIMITER 32
|
||||
#define GETDATE_SHORT_DATE_FULL_YEAR 64
|
||||
|
||||
/* defines when allocating data */
|
||||
extern void *my_multi_malloc(PSI_memory_key key, myf flags, ...);
|
||||
|
||||
/*
|
||||
Switch to my_malloc() if the memory block to be allocated is bigger than
|
||||
max_alloca_sz.
|
||||
*/
|
||||
extern PSI_memory_key key_memory_max_alloca;
|
||||
#define my_safe_alloca(size, max_alloca_sz) ((size <= max_alloca_sz) ? \
|
||||
my_alloca(size) : \
|
||||
my_malloc(key_memory_max_alloca, size, MYF(0)))
|
||||
#define my_safe_afree(ptr, size, max_alloca_sz) if (size > max_alloca_sz) \
|
||||
my_free(ptr)
|
||||
|
||||
#if !defined(DBUG_OFF) || defined(HAVE_VALGRIND)
|
||||
/**
|
||||
Put bad content in memory to be sure it will segfault if dereferenced.
|
||||
With Valgrind, verify that memory is addressable, and mark it undefined.
|
||||
We cache value of B because if B is expression which depends on A, memset()
|
||||
trashes value of B.
|
||||
*/
|
||||
#define TRASH(A,B) do { \
|
||||
void *p = (A); \
|
||||
const size_t l= (B); \
|
||||
MEM_CHECK_ADDRESSABLE(A, l); \
|
||||
memset(p, 0x8F, l); \
|
||||
MEM_UNDEFINED(A, l); \
|
||||
} while (0)
|
||||
#else
|
||||
#define TRASH(A,B) do {} while(0)
|
||||
#endif
|
||||
#if defined(ENABLED_DEBUG_SYNC)
|
||||
extern void (*debug_sync_C_callback_ptr)(const char *, size_t);
|
||||
#define DEBUG_SYNC_C(_sync_point_name_) do { \
|
||||
if (debug_sync_C_callback_ptr != NULL) \
|
||||
(*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
|
||||
while(0)
|
||||
#define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_) do { \
|
||||
if (debug_sync_C_callback_ptr != NULL && thd) \
|
||||
(*debug_sync_C_callback_ptr)(STRING_WITH_LEN(_sync_point_name_)); } \
|
||||
while(0)
|
||||
#else
|
||||
#define DEBUG_SYNC_C(_sync_point_name_)
|
||||
#define DEBUG_SYNC_C_IF_THD(thd, _sync_point_name_)
|
||||
#endif /* defined(ENABLED_DEBUG_SYNC) */
|
||||
|
||||
#ifdef HAVE_LINUX_LARGE_PAGES
|
||||
extern uint my_get_large_page_size(void);
|
||||
extern uchar * my_large_malloc(PSI_memory_key key, size_t size, myf my_flags);
|
||||
extern void my_large_free(uchar *ptr);
|
||||
extern my_bool my_use_large_pages;
|
||||
extern uint my_large_page_size;
|
||||
#else
|
||||
#define my_get_large_page_size() (0)
|
||||
#define my_large_malloc(A,B,C) my_malloc((A),(B),(C))
|
||||
#define my_large_free(A) my_free((A))
|
||||
#endif /* HAVE_LINUX_LARGE_PAGES */
|
||||
|
||||
#define my_alloca(SZ) alloca((size_t) (SZ))
|
||||
|
||||
#include <errno.h> /* errno is a define */
|
||||
|
||||
extern char *home_dir; /* Home directory for user */
|
||||
extern const char *my_progname; /* program-name (printed in errors) */
|
||||
extern char curr_dir[]; /* Current directory for user */
|
||||
extern void (*error_handler_hook)(uint my_err, const char *str,myf MyFlags);
|
||||
extern void (*fatal_error_handler_hook)(uint my_err, const char *str,
|
||||
myf MyFlags);
|
||||
extern void (*local_message_hook)(enum loglevel ll,
|
||||
const char *format, va_list args);
|
||||
extern uint my_file_limit;
|
||||
extern MYSQL_PLUGIN_IMPORT ulong my_thread_stack_size;
|
||||
|
||||
/*
|
||||
Hooks for reporting execution stage information. The server implementation
|
||||
of these will also set THD::current_cond/current_mutex.
|
||||
By having hooks, we avoid direct dependencies on server code.
|
||||
*/
|
||||
extern void (*enter_cond_hook)(void *opaque_thd,
|
||||
mysql_cond_t *cond,
|
||||
mysql_mutex_t *mutex,
|
||||
const PSI_stage_info *stage,
|
||||
PSI_stage_info *old_stage,
|
||||
const char *src_function,
|
||||
const char *src_file,
|
||||
int src_line);
|
||||
|
||||
extern void (*exit_cond_hook)(void *opaque_thd,
|
||||
const PSI_stage_info *stage,
|
||||
const char *src_function,
|
||||
const char *src_file,
|
||||
int src_line);
|
||||
|
||||
/*
|
||||
Hook for checking if the thread has been killed.
|
||||
*/
|
||||
extern int (*is_killed_hook)(const void *opaque_thd);
|
||||
|
||||
/* charsets */
|
||||
#define MY_ALL_CHARSETS_SIZE 2048
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *default_charset_info;
|
||||
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *all_charsets[MY_ALL_CHARSETS_SIZE];
|
||||
extern CHARSET_INFO compiled_charsets[];
|
||||
|
||||
/* statistics */
|
||||
extern ulong my_file_opened,my_stream_opened, my_tmp_file_created;
|
||||
extern ulong my_file_total_opened;
|
||||
extern my_bool my_init_done;
|
||||
|
||||
extern MYSQL_PLUGIN_IMPORT int my_umask; /* Default creation mask */
|
||||
extern int my_umask_dir;
|
||||
|
||||
extern ulong my_default_record_cache_size;
|
||||
extern my_bool my_disable_locking,
|
||||
my_enable_symlinks;
|
||||
extern char wild_many,wild_one,wild_prefix;
|
||||
extern const char *charsets_dir;
|
||||
|
||||
enum cache_type
|
||||
{
|
||||
TYPE_NOT_SET= 0, READ_CACHE, WRITE_CACHE,
|
||||
SEQ_READ_APPEND /* sequential read or append */,
|
||||
READ_FIFO, READ_NET,WRITE_NET};
|
||||
|
||||
enum flush_type
|
||||
{
|
||||
FLUSH_KEEP, /* flush block and keep it in the cache */
|
||||
FLUSH_RELEASE, /* flush block and remove it from the cache */
|
||||
FLUSH_IGNORE_CHANGED, /* remove block from the cache */
|
||||
/*
|
||||
As my_disable_flush_pagecache_blocks is always 0, the following option
|
||||
is strictly equivalent to FLUSH_KEEP
|
||||
*/
|
||||
FLUSH_FORCE_WRITE
|
||||
};
|
||||
|
||||
enum file_type
|
||||
{
|
||||
UNOPEN = 0, FILE_BY_OPEN, FILE_BY_CREATE, STREAM_BY_FOPEN, STREAM_BY_FDOPEN,
|
||||
FILE_BY_MKSTEMP, FILE_BY_DUP
|
||||
};
|
||||
|
||||
struct st_my_file_info
|
||||
{
|
||||
char *name;
|
||||
#ifdef _WIN32
|
||||
HANDLE fhandle; /* win32 file handle */
|
||||
int oflag; /* open flags, e.g O_APPEND */
|
||||
#endif
|
||||
enum file_type type;
|
||||
};
|
||||
|
||||
extern struct st_my_file_info *my_file_info;
|
||||
|
||||
/* needed for client-only build */
|
||||
#ifndef PSI_FILE_KEY_DEFINED
|
||||
typedef unsigned int PSI_file_key;
|
||||
#define PSI_FILE_KEY_DEFINED
|
||||
#endif
|
||||
|
||||
typedef struct st_dynamic_array
|
||||
{
|
||||
uchar *buffer;
|
||||
uint elements,max_element;
|
||||
uint alloc_increment;
|
||||
uint size_of_element;
|
||||
PSI_memory_key m_psi_key;
|
||||
} DYNAMIC_ARRAY;
|
||||
|
||||
typedef struct st_my_tmpdir
|
||||
{
|
||||
char **list;
|
||||
uint cur, max;
|
||||
mysql_mutex_t mutex;
|
||||
} MY_TMPDIR;
|
||||
|
||||
typedef struct st_dynamic_string
|
||||
{
|
||||
char *str;
|
||||
size_t length,max_length,alloc_increment;
|
||||
} DYNAMIC_STRING;
|
||||
|
||||
struct st_io_cache;
|
||||
typedef int (*IO_CACHE_CALLBACK)(struct st_io_cache*);
|
||||
|
||||
typedef struct st_io_cache_share
|
||||
{
|
||||
mysql_mutex_t mutex; /* To sync on reads into buffer. */
|
||||
mysql_cond_t cond; /* To wait for signals. */
|
||||
mysql_cond_t cond_writer; /* For a synchronized writer. */
|
||||
/* Offset in file corresponding to the first byte of buffer. */
|
||||
my_off_t pos_in_file;
|
||||
/* If a synchronized write cache is the source of the data. */
|
||||
struct st_io_cache *source_cache;
|
||||
uchar *buffer; /* The read buffer. */
|
||||
uchar *read_end; /* Behind last valid byte of buffer. */
|
||||
int running_threads; /* threads not in lock. */
|
||||
int total_threads; /* threads sharing the cache. */
|
||||
int error; /* Last error. */
|
||||
} IO_CACHE_SHARE;
|
||||
|
||||
typedef struct st_io_cache /* Used when cacheing files */
|
||||
{
|
||||
/* Offset in file corresponding to the first byte of uchar* buffer. */
|
||||
my_off_t pos_in_file;
|
||||
/*
|
||||
The offset of end of file for READ_CACHE and WRITE_CACHE.
|
||||
For SEQ_READ_APPEND it the maximum of the actual end of file and
|
||||
the position represented by read_end.
|
||||
*/
|
||||
my_off_t end_of_file;
|
||||
/* Points to current read position in the buffer */
|
||||
uchar *read_pos;
|
||||
/* the non-inclusive boundary in the buffer for the currently valid read */
|
||||
uchar *read_end;
|
||||
uchar *buffer; /* The read buffer */
|
||||
/* Used in ASYNC_IO */
|
||||
uchar *request_pos;
|
||||
|
||||
/* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */
|
||||
uchar *write_buffer;
|
||||
/*
|
||||
Only used in SEQ_READ_APPEND, and points to the current read position
|
||||
in the write buffer. Note that reads in SEQ_READ_APPEND caches can
|
||||
happen from both read buffer (uchar* buffer) and write buffer
|
||||
(uchar* write_buffer).
|
||||
*/
|
||||
uchar *append_read_pos;
|
||||
/* Points to current write position in the write buffer */
|
||||
uchar *write_pos;
|
||||
/* The non-inclusive boundary of the valid write area */
|
||||
uchar *write_end;
|
||||
|
||||
/*
|
||||
Current_pos and current_end are convenience variables used by
|
||||
my_b_tell() and other routines that need to know the current offset
|
||||
current_pos points to &write_pos, and current_end to &write_end in a
|
||||
WRITE_CACHE, and &read_pos and &read_end respectively otherwise
|
||||
*/
|
||||
uchar **current_pos, **current_end;
|
||||
|
||||
/*
|
||||
The lock is for append buffer used in SEQ_READ_APPEND cache
|
||||
need mutex copying from append buffer to read buffer.
|
||||
*/
|
||||
mysql_mutex_t append_buffer_lock;
|
||||
/*
|
||||
The following is used when several threads are reading the
|
||||
same file in parallel. They are synchronized on disk
|
||||
accesses reading the cached part of the file asynchronously.
|
||||
It should be set to NULL to disable the feature. Only
|
||||
READ_CACHE mode is supported.
|
||||
*/
|
||||
IO_CACHE_SHARE *share;
|
||||
|
||||
/*
|
||||
A caller will use my_b_read() macro to read from the cache
|
||||
if the data is already in cache, it will be simply copied with
|
||||
memcpy() and internal variables will be accordinging updated with
|
||||
no functions invoked. However, if the data is not fully in the cache,
|
||||
my_b_read() will call read_function to fetch the data. read_function
|
||||
must never be invoked directly.
|
||||
*/
|
||||
int (*read_function)(struct st_io_cache *,uchar *,size_t);
|
||||
/*
|
||||
Same idea as in the case of read_function, except my_b_write() needs to
|
||||
be replaced with my_b_append() for a SEQ_READ_APPEND cache
|
||||
*/
|
||||
int (*write_function)(struct st_io_cache *,const uchar *,size_t);
|
||||
/*
|
||||
Specifies the type of the cache. Depending on the type of the cache
|
||||
certain operations might not be available and yield unpredicatable
|
||||
results. Details to be documented later
|
||||
*/
|
||||
enum cache_type type;
|
||||
/*
|
||||
Callbacks when the actual read I/O happens. These were added and
|
||||
are currently used for binary logging of LOAD DATA INFILE - when a
|
||||
block is read from the file, we create a block create/append event, and
|
||||
when IO_CACHE is closed, we create an end event. These functions could,
|
||||
of course be used for other things
|
||||
*/
|
||||
IO_CACHE_CALLBACK pre_read;
|
||||
IO_CACHE_CALLBACK post_read;
|
||||
IO_CACHE_CALLBACK pre_close;
|
||||
/*
|
||||
Counts the number of times, when we were forced to use disk. We use it to
|
||||
increase the binlog_cache_disk_use and binlog_stmt_cache_disk_use status
|
||||
variables.
|
||||
*/
|
||||
ulong disk_writes;
|
||||
void* arg; /* for use by pre/post_read */
|
||||
char *file_name; /* if used with 'open_cached_file' */
|
||||
char *dir,*prefix;
|
||||
File file; /* file descriptor */
|
||||
PSI_file_key file_key; /* instrumented file key */
|
||||
|
||||
/*
|
||||
seek_not_done is set by my_b_seek() to inform the upcoming read/write
|
||||
operation that a seek needs to be preformed prior to the actual I/O
|
||||
error is 0 if the cache operation was successful, -1 if there was a
|
||||
"hard" error, and the actual number of I/O-ed bytes if the read/write was
|
||||
partial.
|
||||
*/
|
||||
int seek_not_done,error;
|
||||
/* buffer_length is memory size allocated for buffer or write_buffer */
|
||||
size_t buffer_length;
|
||||
/* read_length is the same as buffer_length except when we use async io */
|
||||
size_t read_length;
|
||||
myf myflags; /* Flags used to my_read/my_write */
|
||||
/*
|
||||
alloced_buffer is 1 if the buffer was allocated by init_io_cache() and
|
||||
0 if it was supplied by the user.
|
||||
Currently READ_NET is the only one that will use a buffer allocated
|
||||
somewhere else
|
||||
*/
|
||||
my_bool alloced_buffer;
|
||||
} IO_CACHE;
|
||||
|
||||
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
|
||||
|
||||
/*
|
||||
Subset of struct stat fields filled by stat/lstat/fstat that uniquely
|
||||
identify a file
|
||||
*/
|
||||
typedef struct st_file_id
|
||||
{
|
||||
dev_t st_dev;
|
||||
ino_t st_ino;
|
||||
} ST_FILE_ID;
|
||||
|
||||
typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
|
||||
MY_ATTRIBUTE((format(printf, 2, 3)));
|
||||
|
||||
extern my_error_reporter my_charset_error_reporter;
|
||||
|
||||
/* defines for mf_iocache */
|
||||
extern PSI_file_key key_file_io_cache;
|
||||
|
||||
/* Test if buffer is inited */
|
||||
#define my_b_clear(info) (info)->buffer=0
|
||||
#define my_b_inited(info) (info)->buffer
|
||||
#define my_b_EOF INT_MIN
|
||||
|
||||
#define my_b_read(info,Buffer,Count) \
|
||||
((info)->read_pos + (Count) <= (info)->read_end ?\
|
||||
(memcpy(Buffer,(info)->read_pos,(size_t) (Count)), \
|
||||
((info)->read_pos+=(Count)),0) :\
|
||||
(*(info)->read_function)((info),Buffer,Count))
|
||||
|
||||
#define my_b_write(info,Buffer,Count) \
|
||||
((info)->write_pos + (Count) <=(info)->write_end ?\
|
||||
(memcpy((info)->write_pos, (Buffer), (size_t)(Count)),\
|
||||
((info)->write_pos+=(Count)),0) : \
|
||||
(*(info)->write_function)((info),(uchar *)(Buffer),(Count)))
|
||||
|
||||
#define my_b_get(info) \
|
||||
((info)->read_pos != (info)->read_end ?\
|
||||
((info)->read_pos++, (int) (uchar) (info)->read_pos[-1]) :\
|
||||
_my_b_get(info))
|
||||
|
||||
#define my_b_tell(info) ((info)->pos_in_file + \
|
||||
(size_t) (*(info)->current_pos - (info)->request_pos))
|
||||
|
||||
#define my_b_get_buffer_start(info) (info)->request_pos
|
||||
#define my_b_get_bytes_in_buffer(info) (char*) (info)->read_end - \
|
||||
(char*) my_b_get_buffer_start(info)
|
||||
#define my_b_get_pos_in_file(info) (info)->pos_in_file
|
||||
|
||||
/* tell write offset in the SEQ_APPEND cache */
|
||||
int my_b_copy_to_file(IO_CACHE *cache, FILE *file);
|
||||
my_off_t my_b_append_tell(IO_CACHE* info);
|
||||
my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */
|
||||
|
||||
#define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \
|
||||
*(info)->current_pos)
|
||||
|
||||
typedef uint32 ha_checksum;
|
||||
|
||||
#include <my_alloc.h>
|
||||
|
||||
|
||||
/* Prototypes for mysys and my_func functions */
|
||||
|
||||
extern int my_copy(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_delete(const char *name,myf MyFlags);
|
||||
extern int my_getwd(char * buf,size_t size,myf MyFlags);
|
||||
extern int my_setwd(const char *dir,myf MyFlags);
|
||||
extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags);
|
||||
extern void *my_once_alloc(size_t Size,myf MyFlags);
|
||||
extern void my_once_free(void);
|
||||
extern char *my_once_strdup(const char *src,myf myflags);
|
||||
extern void *my_once_memdup(const void *src, size_t len, myf myflags);
|
||||
extern File my_open(const char *FileName,int Flags,myf MyFlags);
|
||||
extern File my_register_filename(File fd, const char *FileName,
|
||||
enum file_type type_of_file,
|
||||
uint error_message_number, myf MyFlags);
|
||||
extern File my_create(const char *FileName,int CreateFlags,
|
||||
int AccessFlags, myf MyFlags);
|
||||
extern int my_close(File Filedes,myf MyFlags);
|
||||
extern int my_mkdir(const char *dir, int Flags, myf MyFlags);
|
||||
extern int my_readlink(char *to, const char *filename, myf MyFlags);
|
||||
extern int my_is_symlink(const char *filename, ST_FILE_ID *file_id);
|
||||
extern int my_realpath(char *to, const char *filename, myf MyFlags);
|
||||
extern int my_is_same_file(File file, const ST_FILE_ID *file_id);
|
||||
extern File my_create_with_symlink(const char *linkname, const char *filename,
|
||||
int createflags, int access_flags,
|
||||
myf MyFlags);
|
||||
extern int my_delete_with_symlink(const char *name, myf MyFlags);
|
||||
extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags);
|
||||
extern int my_symlink(const char *content, const char *linkname, myf MyFlags);
|
||||
extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags);
|
||||
extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset,
|
||||
myf MyFlags);
|
||||
extern int my_rename(const char *from,const char *to,myf MyFlags);
|
||||
extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_tell(File fd,myf MyFlags);
|
||||
extern size_t my_write(File Filedes,const uchar *Buffer,size_t Count,
|
||||
myf MyFlags);
|
||||
extern size_t my_pwrite(File Filedes,const uchar *Buffer,size_t Count,
|
||||
my_off_t offset,myf MyFlags);
|
||||
extern size_t my_fread(FILE *stream,uchar *Buffer,size_t Count,myf MyFlags);
|
||||
extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count,
|
||||
myf MyFlags);
|
||||
extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags);
|
||||
extern my_off_t my_ftell(FILE *stream,myf MyFlags);
|
||||
|
||||
/* implemented in my_syslog.c */
|
||||
|
||||
// Maximum size of message that will be logged.
|
||||
#define MAX_SYSLOG_MESSAGE_SIZE 1024
|
||||
|
||||
/* Platform-independent SysLog support */
|
||||
|
||||
/* facilities on unixoid syslog. harmless on systemd / Win platforms. */
|
||||
typedef struct st_syslog_facility { int id; const char *name; } SYSLOG_FACILITY;
|
||||
extern SYSLOG_FACILITY syslog_facility[];
|
||||
|
||||
enum my_syslog_options { MY_SYSLOG_PIDS= 1 };
|
||||
|
||||
int my_openlog(const char *eventSourceName, int option, int facility);
|
||||
int my_closelog();
|
||||
int my_syslog(const CHARSET_INFO *cs, enum loglevel level, const char *msg);
|
||||
|
||||
/* implemented in my_memmem.c */
|
||||
extern void *my_memmem(const void *haystack, size_t haystacklen,
|
||||
const void *needle, size_t needlelen);
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
extern int my_access(const char *path, int amode);
|
||||
#else
|
||||
#define my_access access
|
||||
#endif
|
||||
|
||||
extern int check_if_legal_filename(const char *path);
|
||||
extern int check_if_legal_tablename(const char *path);
|
||||
|
||||
#ifdef _WIN32
|
||||
extern my_bool is_filename_allowed(const char *name, size_t length,
|
||||
my_bool allow_current_dir);
|
||||
#else /* _WIN32 */
|
||||
# define is_filename_allowed(name, length, allow_cwd) (TRUE)
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef _WIN32
|
||||
extern int nt_share_delete(const char *name,myf MyFlags);
|
||||
#define my_delete_allow_opened(fname,flags) nt_share_delete((fname),(flags))
|
||||
#else
|
||||
#define my_delete_allow_opened(fname,flags) my_delete((fname),(flags))
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Windows-only functions (CRT equivalents)*/
|
||||
extern HANDLE my_get_osfhandle(File fd);
|
||||
extern void my_osmaperr(unsigned long last_error);
|
||||
#endif
|
||||
|
||||
extern const char* get_global_errmsg(int nr);
|
||||
extern void wait_for_free_space(const char *filename, int errors);
|
||||
extern FILE *my_fopen(const char *FileName,int Flags,myf MyFlags);
|
||||
extern FILE *my_fdopen(File Filedes,const char *name, int Flags,myf MyFlags);
|
||||
extern FILE *my_freopen(const char *path, const char *mode, FILE *stream);
|
||||
extern int my_fclose(FILE *fd,myf MyFlags);
|
||||
extern File my_fileno(FILE *fd);
|
||||
extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags);
|
||||
extern void thr_set_sync_wait_callback(void (*before_sync)(void),
|
||||
void (*after_sync)(void));
|
||||
extern int my_sync(File fd, myf my_flags);
|
||||
extern int my_sync_dir(const char *dir_name, myf my_flags);
|
||||
extern int my_sync_dir_by_file(const char *file_name, myf my_flags);
|
||||
extern char *my_strerror(char *buf, size_t len, int errnum);
|
||||
extern const char *my_get_err_msg(int nr);
|
||||
extern void my_error(int nr,myf MyFlags, ...);
|
||||
extern void my_printf_error(uint my_err, const char *format,
|
||||
myf MyFlags, ...)
|
||||
MY_ATTRIBUTE((format(printf, 2, 4)));
|
||||
extern void my_printv_error(uint error, const char *format, myf MyFlags,
|
||||
va_list ap);
|
||||
extern int my_error_register(const char* (*get_errmsg) (int),
|
||||
int first, int last);
|
||||
extern my_bool my_error_unregister(int first, int last);
|
||||
extern void my_message(uint my_err, const char *str,myf MyFlags);
|
||||
extern void my_message_stderr(uint my_err, const char *str, myf MyFlags);
|
||||
void my_message_local_stderr(enum loglevel ll,
|
||||
const char *format, va_list args);
|
||||
extern void my_message_local(enum loglevel ll, const char *format, ...);
|
||||
extern my_bool my_init(void);
|
||||
extern void my_end(int infoflag);
|
||||
extern int my_redel(const char *from, const char *to, int MyFlags);
|
||||
extern int my_copystat(const char *from, const char *to, int MyFlags);
|
||||
extern char * my_filename(File fd);
|
||||
extern MY_MODE get_file_perm(ulong perm_flags);
|
||||
extern my_bool my_chmod(const char *filename, ulong perm_flags, myf my_flags);
|
||||
|
||||
#ifdef EXTRA_DEBUG
|
||||
void my_print_open_files(void);
|
||||
#else
|
||||
#define my_print_open_files()
|
||||
#endif
|
||||
|
||||
extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist);
|
||||
extern char *my_tmpdir(MY_TMPDIR *tmpdir);
|
||||
extern void free_tmpdir(MY_TMPDIR *tmpdir);
|
||||
|
||||
extern size_t dirname_part(char * to,const char *name, size_t *to_res_length);
|
||||
extern size_t dirname_length(const char *name);
|
||||
#define base_name(A) (A+dirname_length(A))
|
||||
extern int test_if_hard_path(const char *dir_name);
|
||||
extern my_bool has_path(const char *name);
|
||||
extern char *convert_dirname(char *to, const char *from, const char *from_end);
|
||||
extern void to_unix_path(char * name);
|
||||
extern char * fn_ext(const char *name);
|
||||
extern char * fn_same(char * toname,const char *name,int flag);
|
||||
extern char * fn_format(char * to,const char *name,const char *dir,
|
||||
const char *form, uint flag);
|
||||
extern size_t strlength(const char *str);
|
||||
extern void pack_dirname(char * to,const char *from);
|
||||
extern size_t normalize_dirname(char * to, const char *from);
|
||||
extern size_t unpack_dirname(char * to,const char *from);
|
||||
extern size_t cleanup_dirname(char * to,const char *from);
|
||||
extern size_t system_filename(char * to,const char *from);
|
||||
extern size_t unpack_filename(char * to,const char *from);
|
||||
extern char * intern_filename(char * to,const char *from);
|
||||
extern int pack_filename(char * to, const char *name, size_t max_length);
|
||||
extern char * my_path(char * to,const char *progname,
|
||||
const char *own_pathname_part);
|
||||
extern char * my_load_path(char * to, const char *path,
|
||||
const char *own_path_prefix);
|
||||
extern int wild_compare(const char *str,const char *wildstr,
|
||||
pbool str_is_pattern);
|
||||
extern my_bool array_append_string_unique(const char *str,
|
||||
const char **array, size_t size);
|
||||
extern void get_date(char * to,int timeflag,time_t use_time);
|
||||
extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr,
|
||||
pbool remove_garbage);
|
||||
|
||||
extern my_bool radixsort_is_appliccable(uint n_items, size_t size_of_element);
|
||||
extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
|
||||
size_t size_of_element,uchar *buffer[]);
|
||||
extern void my_qsort(void *base_ptr, size_t total_elems, size_t size,
|
||||
qsort_cmp cmp);
|
||||
extern void my_qsort2(void *base_ptr, size_t total_elems, size_t size,
|
||||
qsort2_cmp cmp, const void *cmp_argument);
|
||||
void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos);
|
||||
my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
|
||||
extern int init_io_cache_ext(IO_CACHE *info,File file,size_t cachesize,
|
||||
enum cache_type type,my_off_t seek_offset,
|
||||
pbool use_async_io, myf cache_myflags,
|
||||
PSI_file_key file_key);
|
||||
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,
|
||||
enum cache_type type,my_off_t seek_offset,
|
||||
pbool use_async_io, myf cache_myflags);
|
||||
extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type,
|
||||
my_off_t seek_offset,pbool use_async_io,
|
||||
pbool clear_cache);
|
||||
extern void setup_io_cache(IO_CACHE* info);
|
||||
extern int _my_b_read(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern int _my_b_read_r(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare,
|
||||
IO_CACHE *write_cache, uint num_threads);
|
||||
extern void remove_io_thread(IO_CACHE *info);
|
||||
extern int _my_b_seq_read(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern int _my_b_net_read(IO_CACHE *info,uchar *Buffer,size_t Count);
|
||||
extern int _my_b_get(IO_CACHE *info);
|
||||
extern int _my_b_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
|
||||
extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count);
|
||||
extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count);
|
||||
|
||||
extern int my_block_write(IO_CACHE *info, const uchar *Buffer,
|
||||
size_t Count, my_off_t pos);
|
||||
extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock);
|
||||
|
||||
#define flush_io_cache(info) my_b_flush_io_cache((info),1)
|
||||
|
||||
extern int end_io_cache(IO_CACHE *info);
|
||||
extern size_t my_b_fill(IO_CACHE *info);
|
||||
extern void my_b_seek(IO_CACHE *info,my_off_t pos);
|
||||
extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length);
|
||||
extern my_off_t my_b_filelength(IO_CACHE *info);
|
||||
extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...)
|
||||
MY_ATTRIBUTE((format(printf, 2, 3)));
|
||||
extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap);
|
||||
extern my_bool open_cached_file(IO_CACHE *cache,const char *dir,
|
||||
const char *prefix, size_t cache_size,
|
||||
myf cache_myflags);
|
||||
extern my_bool real_open_cached_file(IO_CACHE *cache);
|
||||
extern void close_cached_file(IO_CACHE *cache);
|
||||
File create_temp_file(char *to, const char *dir, const char *pfx,
|
||||
int mode, myf MyFlags);
|
||||
|
||||
// Use Prealloced_array or std::vector or something similar in C++
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern my_bool my_init_dynamic_array(DYNAMIC_ARRAY *array,
|
||||
PSI_memory_key key,
|
||||
uint element_size,
|
||||
void *init_buffer,
|
||||
uint init_alloc,
|
||||
uint alloc_increment);
|
||||
/* init_dynamic_array() function is deprecated */
|
||||
extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size,
|
||||
uint init_alloc, uint alloc_increment);
|
||||
#define dynamic_element(array,array_index,type) \
|
||||
((type)((array)->buffer) +(array_index))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Some functions are still in use in C++, because HASH uses DYNAMIC_ARRAY */
|
||||
extern my_bool insert_dynamic(DYNAMIC_ARRAY *array, const void *element);
|
||||
extern void *alloc_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void *pop_dynamic(DYNAMIC_ARRAY*);
|
||||
extern void get_dynamic(DYNAMIC_ARRAY *array, void *element, uint array_index);
|
||||
extern void claim_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void delete_dynamic(DYNAMIC_ARRAY *array);
|
||||
extern void freeze_size(DYNAMIC_ARRAY *array);
|
||||
static inline void reset_dynamic(DYNAMIC_ARRAY *array)
|
||||
{
|
||||
array->elements= 0;
|
||||
}
|
||||
|
||||
extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
|
||||
size_t init_alloc,size_t alloc_increment);
|
||||
extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append);
|
||||
my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
|
||||
size_t length);
|
||||
extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append,
|
||||
...);
|
||||
extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str);
|
||||
extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size);
|
||||
extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n);
|
||||
extern void dynstr_free(DYNAMIC_STRING *str);
|
||||
#define alloc_root_inited(A) ((A)->min_malloc != 0)
|
||||
#define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8)
|
||||
#define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0)
|
||||
extern void init_alloc_root(PSI_memory_key key,
|
||||
MEM_ROOT *mem_root, size_t block_size,
|
||||
size_t pre_alloc_size);
|
||||
extern void *alloc_root(MEM_ROOT *mem_root, size_t Size);
|
||||
extern void *multi_alloc_root(MEM_ROOT *mem_root, ...);
|
||||
extern void claim_root(MEM_ROOT *root);
|
||||
extern void free_root(MEM_ROOT *root, myf MyFLAGS);
|
||||
extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size,
|
||||
size_t prealloc_size);
|
||||
extern char *strdup_root(MEM_ROOT *root,const char *str);
|
||||
static inline char *safe_strdup_root(MEM_ROOT *root, const char *str)
|
||||
{
|
||||
return str ? strdup_root(root, str) : 0;
|
||||
}
|
||||
extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len);
|
||||
extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len);
|
||||
extern void set_memroot_max_capacity(MEM_ROOT *mem_root, size_t size);
|
||||
extern void set_memroot_error_reporting(MEM_ROOT *mem_root,
|
||||
my_bool report_error);
|
||||
extern my_bool my_compress(uchar *, size_t *, size_t *);
|
||||
extern my_bool my_uncompress(uchar *, size_t , size_t *);
|
||||
extern uchar *my_compress_alloc(const uchar *packet, size_t *len,
|
||||
size_t *complen);
|
||||
extern int packfrm(uchar *, size_t, uchar **, size_t *);
|
||||
extern int unpackfrm(uchar **, size_t *, const uchar *);
|
||||
|
||||
extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem,
|
||||
size_t count);
|
||||
|
||||
/* Wait a given number of microseconds */
|
||||
static inline void my_sleep(time_t m_seconds)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep((DWORD)m_seconds/1000+1); /* Sleep() has millisecond arg */
|
||||
#else
|
||||
struct timeval t;
|
||||
t.tv_sec= m_seconds / 1000000L;
|
||||
t.tv_usec= m_seconds % 1000000L;
|
||||
select(0,0,0,0,&t); /* sleep */
|
||||
#endif
|
||||
}
|
||||
|
||||
extern ulong crc32(ulong crc, const uchar *buf, uint len);
|
||||
extern uint my_set_max_open_files(uint files);
|
||||
void my_free_open_file_info(void);
|
||||
|
||||
extern time_t my_time(myf flags);
|
||||
extern ulonglong my_getsystime(void);
|
||||
extern ulonglong my_micro_time();
|
||||
extern my_bool my_gethwaddr(uchar *to);
|
||||
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
|
||||
#ifndef MAP_NOSYNC
|
||||
#define MAP_NOSYNC 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
Not defined in FreeBSD 11.
|
||||
Was never implemented in FreeBSD, so we just set it to 0.
|
||||
*/
|
||||
#ifndef MAP_NORESERVE
|
||||
#define MAP_NORESERVE 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMAP64
|
||||
#define my_mmap(a,b,c,d,e,f) mmap64(a,b,c,d,e,f)
|
||||
#else
|
||||
#define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f)
|
||||
#endif
|
||||
#define my_munmap(a,b) munmap((a),(b))
|
||||
|
||||
#else
|
||||
/* not a complete set of mmap() flags, but only those that nesessary */
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define MAP_NORESERVE 0
|
||||
#define MAP_SHARED 0x0001
|
||||
#define MAP_PRIVATE 0x0002
|
||||
#define MAP_NOSYNC 0x0800
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
#define MS_SYNC 0x0000
|
||||
|
||||
void *my_mmap(void *, size_t, int, int, int, my_off_t);
|
||||
int my_munmap(void *, size_t);
|
||||
#endif
|
||||
|
||||
/* my_getpagesize */
|
||||
static inline int my_getpagesize()
|
||||
{
|
||||
#ifndef _WIN32
|
||||
return getpagesize();
|
||||
#else
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
return (int)si.dwPageSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
int my_msync(int, void *, size_t, int);
|
||||
|
||||
/* character sets */
|
||||
extern void my_charset_loader_init_mysys(MY_CHARSET_LOADER *loader);
|
||||
extern uint get_charset_number(const char *cs_name, uint cs_flags);
|
||||
extern uint get_collation_number(const char *name);
|
||||
extern const char *get_charset_name(uint cs_number);
|
||||
|
||||
extern CHARSET_INFO *get_charset(uint cs_number, myf flags);
|
||||
extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags);
|
||||
extern CHARSET_INFO *my_collation_get_by_name(MY_CHARSET_LOADER *loader,
|
||||
const char *name, myf flags);
|
||||
extern CHARSET_INFO *get_charset_by_csname(const char *cs_name,
|
||||
uint cs_flags, myf my_flags);
|
||||
extern CHARSET_INFO *my_charset_get_by_name(MY_CHARSET_LOADER *loader,
|
||||
const char *name,
|
||||
uint cs_flags, myf my_flags);
|
||||
extern my_bool resolve_charset(const char *cs_name,
|
||||
const CHARSET_INFO *default_cs,
|
||||
const CHARSET_INFO **cs);
|
||||
extern my_bool resolve_collation(const char *cl_name,
|
||||
const CHARSET_INFO *default_cl,
|
||||
const CHARSET_INFO **cl);
|
||||
extern void free_charsets(void);
|
||||
extern char *get_charsets_dir(char *buf);
|
||||
extern my_bool my_charset_same(const CHARSET_INFO *cs1,
|
||||
const CHARSET_INFO *cs2);
|
||||
extern my_bool init_compiled_charsets(myf flags);
|
||||
extern void add_compiled_collation(CHARSET_INFO *cs);
|
||||
extern size_t escape_string_for_mysql(const CHARSET_INFO *charset_info,
|
||||
char *to, size_t to_length,
|
||||
const char *from, size_t length);
|
||||
#ifdef _WIN32
|
||||
/* File system character set */
|
||||
extern CHARSET_INFO *fs_character_set(void);
|
||||
#endif
|
||||
extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info,
|
||||
char *to, size_t to_length,
|
||||
const char *from, size_t length, char quote);
|
||||
#ifdef _WIN32
|
||||
extern my_bool have_tcpip; /* Is set if tcpip is used */
|
||||
|
||||
/* implemented in my_windac.c */
|
||||
|
||||
int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror,
|
||||
DWORD owner_rights, DWORD everybody_rights);
|
||||
|
||||
void my_security_attr_free(SECURITY_ATTRIBUTES *sa);
|
||||
|
||||
/* implemented in my_conio.c */
|
||||
my_bool my_win_is_console(FILE *file);
|
||||
char *my_win_console_readline(const CHARSET_INFO *cs, char *mbbuf, size_t mbbufsize,
|
||||
size_t *nread);
|
||||
void my_win_console_write(const CHARSET_INFO *cs, const char *data, size_t datalen);
|
||||
void my_win_console_fputs(const CHARSET_INFO *cs, const char *data);
|
||||
void my_win_console_putc(const CHARSET_INFO *cs, int c);
|
||||
void my_win_console_vfprintf(const CHARSET_INFO *cs, const char *fmt, va_list args);
|
||||
int my_win_translate_command_line_args(const CHARSET_INFO *cs, int *ac, char ***av);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef HAVE_PSI_INTERFACE
|
||||
extern MYSQL_PLUGIN_IMPORT struct PSI_bootstrap *PSI_hook;
|
||||
extern void set_psi_server(PSI *psi);
|
||||
void my_init_mysys_psi_keys(void);
|
||||
#endif
|
||||
|
||||
struct st_mysql_file;
|
||||
extern struct st_mysql_file *mysql_stdin;
|
||||
|
||||
C_MODE_END
|
||||
#endif /* _my_sys_h */
|
||||
199
demo/kugou/include/Common/include/mysql/my_thread.h
Normal file
199
demo/kugou/include/Common/include/mysql/my_thread.h
Normal file
@@ -0,0 +1,199 @@
|
||||
/* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
/* Defines to make different thread packages compatible */
|
||||
|
||||
#ifndef MY_THREAD_INCLUDED
|
||||
#define MY_THREAD_INCLUDED
|
||||
|
||||
#include "my_global.h" /* my_bool */
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifndef ETIME
|
||||
#define ETIME ETIMEDOUT /* For FreeBSD */
|
||||
#endif
|
||||
|
||||
#ifndef ETIMEDOUT
|
||||
#define ETIMEDOUT 145 /* Win32 doesn't have this */
|
||||
#endif
|
||||
|
||||
/*
|
||||
MySQL can survive with 32K, but some glibc libraries require > 128K stack
|
||||
To resolve hostnames. Also recursive stored procedures needs stack.
|
||||
*/
|
||||
#if defined(__sparc) && (defined(__SUNPRO_CC) || defined(__SUNPRO_C))
|
||||
#define STACK_MULTIPLIER 2UL
|
||||
#else
|
||||
#define STACK_MULTIPLIER 1UL
|
||||
#endif
|
||||
|
||||
#if SIZEOF_CHARP > 4
|
||||
#define DEFAULT_THREAD_STACK (STACK_MULTIPLIER * 256UL * 1024UL)
|
||||
#else
|
||||
#define DEFAULT_THREAD_STACK (STACK_MULTIPLIER * 192UL * 1024UL)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERNC extern "C"
|
||||
#else
|
||||
#define EXTERNC
|
||||
#endif
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef volatile LONG my_thread_once_t;
|
||||
typedef DWORD my_thread_t;
|
||||
typedef struct thread_attr
|
||||
{
|
||||
DWORD dwStackSize;
|
||||
int detachstate;
|
||||
} my_thread_attr_t;
|
||||
#define MY_THREAD_CREATE_JOINABLE 0
|
||||
#define MY_THREAD_CREATE_DETACHED 1
|
||||
typedef void * (__cdecl *my_start_routine)(void *);
|
||||
#define MY_THREAD_ONCE_INIT 0
|
||||
#define MY_THREAD_ONCE_INPROGRESS 1
|
||||
#define MY_THREAD_ONCE_DONE 2
|
||||
#else
|
||||
typedef pthread_once_t my_thread_once_t;
|
||||
typedef pthread_t my_thread_t;
|
||||
typedef pthread_attr_t my_thread_attr_t;
|
||||
#define MY_THREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
|
||||
#define MY_THREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
|
||||
typedef void *(* my_start_routine)(void *);
|
||||
#define MY_THREAD_ONCE_INIT PTHREAD_ONCE_INIT
|
||||
#endif
|
||||
|
||||
typedef struct st_my_thread_handle
|
||||
{
|
||||
my_thread_t thread;
|
||||
#ifdef _WIN32
|
||||
HANDLE handle;
|
||||
#endif
|
||||
} my_thread_handle;
|
||||
|
||||
int my_thread_once(my_thread_once_t *once_control, void (*init_routine)(void));
|
||||
|
||||
static inline my_thread_t my_thread_self()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return GetCurrentThreadId();
|
||||
#else
|
||||
return pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_equal(my_thread_t t1, my_thread_t t2)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return t1 == t2;
|
||||
#else
|
||||
return pthread_equal(t1, t2);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_init(my_thread_attr_t *attr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->dwStackSize= 0;
|
||||
/* Set to joinable by default to match Linux */
|
||||
attr->detachstate= MY_THREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_init(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_destroy(my_thread_attr_t *attr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->dwStackSize= 0;
|
||||
/* Set to joinable by default to match Linux */
|
||||
attr->detachstate= MY_THREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_destroy(attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_setstacksize(my_thread_attr_t *attr,
|
||||
size_t stacksize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->dwStackSize= (DWORD)stacksize;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_setstacksize(attr, stacksize);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_setdetachstate(my_thread_attr_t *attr,
|
||||
int detachstate)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
attr->detachstate= detachstate;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_setdetachstate(attr, detachstate);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_thread_attr_getstacksize(my_thread_attr_t *attr,
|
||||
size_t *stacksize)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
*stacksize= (size_t)attr->dwStackSize;
|
||||
return 0;
|
||||
#else
|
||||
return pthread_attr_getstacksize(attr, stacksize);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void my_thread_yield()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
SwitchToThread();
|
||||
#else
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
int my_thread_create(my_thread_handle *thread, const my_thread_attr_t *attr,
|
||||
my_start_routine func, void *arg);
|
||||
int my_thread_join(my_thread_handle *thread, void **value_ptr);
|
||||
int my_thread_cancel(my_thread_handle *thread);
|
||||
void my_thread_exit(void *value_ptr);
|
||||
|
||||
|
||||
extern my_bool my_thread_global_init();
|
||||
extern void my_thread_global_reinit();
|
||||
extern void my_thread_global_end();
|
||||
extern my_bool my_thread_init();
|
||||
extern void my_thread_end();
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif /* MY_THREAD_INCLUDED */
|
||||
114
demo/kugou/include/Common/include/mysql/my_thread_local.h
Normal file
114
demo/kugou/include/Common/include/mysql/my_thread_local.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MY_THREAD_LOCAL_INCLUDED
|
||||
#define MY_THREAD_LOCAL_INCLUDED
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
struct _db_code_state_;
|
||||
typedef uint32 my_thread_id;
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef DWORD thread_local_key_t;
|
||||
#else
|
||||
typedef pthread_key_t thread_local_key_t;
|
||||
#endif
|
||||
|
||||
static inline int my_create_thread_local_key(thread_local_key_t *key,
|
||||
void (*destructor)(void *))
|
||||
{
|
||||
#ifdef _WIN32
|
||||
*key= TlsAlloc();
|
||||
return (*key == TLS_OUT_OF_INDEXES);
|
||||
#else
|
||||
return pthread_key_create(key, destructor);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_delete_thread_local_key(thread_local_key_t key)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return !TlsFree(key);
|
||||
#else
|
||||
return pthread_key_delete(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void* my_get_thread_local(thread_local_key_t key)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return TlsGetValue(key);
|
||||
#else
|
||||
return pthread_getspecific(key);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int my_set_thread_local(thread_local_key_t key,
|
||||
void *value)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return !TlsSetValue(key, value);
|
||||
#else
|
||||
return pthread_setspecific(key, value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieve the MySQL thread-local storage variant of errno.
|
||||
*/
|
||||
int my_errno();
|
||||
|
||||
/**
|
||||
Set the MySQL thread-local storage variant of errno.
|
||||
*/
|
||||
void set_my_errno(int my_errno);
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
thr_winerr is used for returning the original OS error-code in Windows,
|
||||
my_osmaperr() returns EINVAL for all unknown Windows errors, hence we
|
||||
preserve the original Windows Error code in thr_winerr.
|
||||
*/
|
||||
int thr_winerr();
|
||||
|
||||
void set_thr_winerr(int winerr);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
/* Return pointer to DBUG for holding current state */
|
||||
struct _db_code_state_ **my_thread_var_dbug();
|
||||
|
||||
my_thread_id my_thread_var_id();
|
||||
|
||||
void set_my_thread_var_id(my_thread_id id);
|
||||
|
||||
#endif
|
||||
|
||||
C_MODE_END
|
||||
|
||||
#endif // MY_THREAD_LOCAL_INCLUDED
|
||||
103
demo/kugou/include/Common/include/mysql/my_xml.h
Normal file
103
demo/kugou/include/Common/include/mysql/my_xml.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
|
||||
#ifndef _my_xml_h
|
||||
#define _my_xml_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define MY_XML_OK 0
|
||||
#define MY_XML_ERROR 1
|
||||
|
||||
/*
|
||||
A flag whether to use absolute tag names in call-back functions,
|
||||
like "a", "a.b" and "a.b.c" (used in character set file parser),
|
||||
or relative names like "a", "b" and "c".
|
||||
*/
|
||||
#define MY_XML_FLAG_RELATIVE_NAMES 1
|
||||
|
||||
/*
|
||||
A flag whether to skip normilization of text values before calling
|
||||
call-back functions: i.e. skip leading/trailing spaces,
|
||||
\r, \n, \t characters.
|
||||
*/
|
||||
#define MY_XML_FLAG_SKIP_TEXT_NORMALIZATION 2
|
||||
|
||||
enum my_xml_node_type
|
||||
{
|
||||
MY_XML_NODE_TAG, /* can have TAG, ATTR and TEXT children */
|
||||
MY_XML_NODE_ATTR, /* can have TEXT children */
|
||||
MY_XML_NODE_TEXT /* cannot have children */
|
||||
};
|
||||
|
||||
typedef struct xml_stack_st
|
||||
{
|
||||
int flags;
|
||||
enum my_xml_node_type current_node_type;
|
||||
char errstr[128];
|
||||
|
||||
struct {
|
||||
char static_buffer[128];
|
||||
char *buffer;
|
||||
size_t buffer_size;
|
||||
char *start;
|
||||
char *end;
|
||||
} attr;
|
||||
|
||||
const char *beg;
|
||||
const char *cur;
|
||||
const char *end;
|
||||
void *user_data;
|
||||
int (*enter)(struct xml_stack_st *st,const char *val, size_t len);
|
||||
int (*value)(struct xml_stack_st *st,const char *val, size_t len);
|
||||
int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len);
|
||||
} MY_XML_PARSER;
|
||||
|
||||
void my_xml_parser_create(MY_XML_PARSER *st);
|
||||
void my_xml_parser_free(MY_XML_PARSER *st);
|
||||
int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len);
|
||||
|
||||
void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
|
||||
const char *,
|
||||
size_t len));
|
||||
void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
|
||||
const char *,
|
||||
size_t len));
|
||||
void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *,
|
||||
const char *,
|
||||
size_t len));
|
||||
void my_xml_set_user_data(MY_XML_PARSER *st, void *);
|
||||
|
||||
size_t my_xml_error_pos(MY_XML_PARSER *st);
|
||||
uint my_xml_error_lineno(MY_XML_PARSER *st);
|
||||
|
||||
const char *my_xml_error_string(MY_XML_PARSER *st);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _my_xml_h */
|
||||
741
demo/kugou/include/Common/include/mysql/mysql.h
Normal file
741
demo/kugou/include/Common/include/mysql/mysql.h
Normal file
@@ -0,0 +1,741 @@
|
||||
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
This file defines the client API to MySQL and also the ABI of the
|
||||
dynamically linked libmysqlclient.
|
||||
|
||||
The ABI should never be changed in a released product of MySQL,
|
||||
thus you need to take great care when changing the file. In case
|
||||
the file is changed so the ABI is broken, you must also update
|
||||
the SHARED_LIB_MAJOR_VERSION in cmake/mysql_version.cmake
|
||||
*/
|
||||
|
||||
#ifndef _mysql_h
|
||||
#define _mysql_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef MY_GLOBAL_INCLUDED /* If not standard header */
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
typedef char my_bool;
|
||||
#if !defined(_WIN32)
|
||||
#define STDCALL
|
||||
#else
|
||||
#define STDCALL __stdcall
|
||||
#endif
|
||||
|
||||
#ifndef my_socket_defined
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#ifdef WIN32_LEAN_AND_MEAN
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#define my_socket SOCKET
|
||||
#else
|
||||
typedef int my_socket;
|
||||
#endif /* _WIN32 */
|
||||
#endif /* my_socket_defined */
|
||||
#endif /* MY_GLOBAL_INCLUDED */
|
||||
|
||||
#include "mysql_version.h"
|
||||
#include "mysql_com.h"
|
||||
#include "mysql_time.h"
|
||||
|
||||
#include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */
|
||||
|
||||
/* Include declarations of plug-in API */
|
||||
#include "mysql/client_plugin.h"
|
||||
|
||||
extern unsigned int mysql_port;
|
||||
extern char *mysql_unix_port;
|
||||
|
||||
#define CLIENT_NET_READ_TIMEOUT 365*24*3600 /* Timeout on read */
|
||||
#define CLIENT_NET_WRITE_TIMEOUT 365*24*3600 /* Timeout on write */
|
||||
|
||||
#define IS_PRI_KEY(n) ((n) & PRI_KEY_FLAG)
|
||||
#define IS_NOT_NULL(n) ((n) & NOT_NULL_FLAG)
|
||||
#define IS_BLOB(n) ((n) & BLOB_FLAG)
|
||||
/**
|
||||
Returns true if the value is a number which does not need quotes for
|
||||
the sql_lex.cc parser to parse correctly.
|
||||
*/
|
||||
#define IS_NUM(t) (((t) <= MYSQL_TYPE_INT24 && (t) != MYSQL_TYPE_TIMESTAMP) || (t) == MYSQL_TYPE_YEAR || (t) == MYSQL_TYPE_NEWDECIMAL)
|
||||
#define IS_LONGDATA(t) ((t) >= MYSQL_TYPE_TINY_BLOB && (t) <= MYSQL_TYPE_STRING)
|
||||
|
||||
|
||||
typedef struct st_mysql_field {
|
||||
char *name; /* Name of column */
|
||||
char *org_name; /* Original column name, if an alias */
|
||||
char *table; /* Table of column if column was a field */
|
||||
char *org_table; /* Org table name, if table was an alias */
|
||||
char *db; /* Database for table */
|
||||
char *catalog; /* Catalog for table */
|
||||
char *def; /* Default value (set by mysql_list_fields) */
|
||||
unsigned long length; /* Width of column (create length) */
|
||||
unsigned long max_length; /* Max width for selected set */
|
||||
unsigned int name_length;
|
||||
unsigned int org_name_length;
|
||||
unsigned int table_length;
|
||||
unsigned int org_table_length;
|
||||
unsigned int db_length;
|
||||
unsigned int catalog_length;
|
||||
unsigned int def_length;
|
||||
unsigned int flags; /* Div flags */
|
||||
unsigned int decimals; /* Number of decimals in field */
|
||||
unsigned int charsetnr; /* Character set */
|
||||
enum enum_field_types type; /* Type of field. See mysql_com.h for types */
|
||||
void *extension;
|
||||
} MYSQL_FIELD;
|
||||
|
||||
typedef char **MYSQL_ROW; /* return data as array of strings */
|
||||
typedef unsigned int MYSQL_FIELD_OFFSET; /* offset to current field */
|
||||
|
||||
#ifndef MY_GLOBAL_INCLUDED
|
||||
#if defined (_WIN32)
|
||||
typedef unsigned __int64 my_ulonglong;
|
||||
#else
|
||||
typedef unsigned long long my_ulonglong;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "typelib.h"
|
||||
|
||||
#define MYSQL_COUNT_ERROR (~(my_ulonglong) 0)
|
||||
|
||||
/* backward compatibility define - to be removed eventually */
|
||||
#define ER_WARN_DATA_TRUNCATED WARN_DATA_TRUNCATED
|
||||
|
||||
typedef struct st_mysql_rows {
|
||||
struct st_mysql_rows *next; /* list of rows */
|
||||
MYSQL_ROW data;
|
||||
unsigned long length;
|
||||
} MYSQL_ROWS;
|
||||
|
||||
typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */
|
||||
|
||||
#include "my_alloc.h"
|
||||
|
||||
typedef struct embedded_query_result EMBEDDED_QUERY_RESULT;
|
||||
typedef struct st_mysql_data {
|
||||
MYSQL_ROWS *data;
|
||||
struct embedded_query_result *embedded_info;
|
||||
MEM_ROOT alloc;
|
||||
my_ulonglong rows;
|
||||
unsigned int fields;
|
||||
/* extra info for embedded library */
|
||||
void *extension;
|
||||
} MYSQL_DATA;
|
||||
|
||||
enum mysql_option
|
||||
{
|
||||
MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_COMPRESS, MYSQL_OPT_NAMED_PIPE,
|
||||
MYSQL_INIT_COMMAND, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP,
|
||||
MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_OPT_LOCAL_INFILE,
|
||||
MYSQL_OPT_PROTOCOL, MYSQL_SHARED_MEMORY_BASE_NAME, MYSQL_OPT_READ_TIMEOUT,
|
||||
MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_USE_RESULT,
|
||||
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
|
||||
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
|
||||
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
|
||||
MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
|
||||
MYSQL_OPT_BIND,
|
||||
MYSQL_OPT_SSL_KEY, MYSQL_OPT_SSL_CERT,
|
||||
MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CIPHER,
|
||||
MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH,
|
||||
MYSQL_OPT_CONNECT_ATTR_RESET, MYSQL_OPT_CONNECT_ATTR_ADD,
|
||||
MYSQL_OPT_CONNECT_ATTR_DELETE,
|
||||
MYSQL_SERVER_PUBLIC_KEY,
|
||||
MYSQL_ENABLE_CLEARTEXT_PLUGIN,
|
||||
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS,
|
||||
MYSQL_OPT_SSL_ENFORCE,
|
||||
MYSQL_OPT_MAX_ALLOWED_PACKET, MYSQL_OPT_NET_BUFFER_LENGTH,
|
||||
MYSQL_OPT_TLS_VERSION,
|
||||
MYSQL_OPT_SSL_MODE,
|
||||
MYSQL_OPT_GET_SERVER_PUBLIC_KEY
|
||||
};
|
||||
|
||||
/**
|
||||
@todo remove the "extension", move st_mysql_options completely
|
||||
out of mysql.h
|
||||
*/
|
||||
struct st_mysql_options_extention;
|
||||
|
||||
struct st_mysql_options {
|
||||
unsigned int connect_timeout, read_timeout, write_timeout;
|
||||
unsigned int port, protocol;
|
||||
unsigned long client_flag;
|
||||
char *host,*user,*password,*unix_socket,*db;
|
||||
struct st_dynamic_array *init_commands;
|
||||
char *my_cnf_file,*my_cnf_group, *charset_dir, *charset_name;
|
||||
char *ssl_key; /* PEM key file */
|
||||
char *ssl_cert; /* PEM cert file */
|
||||
char *ssl_ca; /* PEM CA file */
|
||||
char *ssl_capath; /* PEM directory of CA-s? */
|
||||
char *ssl_cipher; /* cipher to use */
|
||||
char *shared_memory_base_name;
|
||||
unsigned long max_allowed_packet;
|
||||
my_bool use_ssl; /* Deprecated ! Former use_ssl */
|
||||
my_bool compress,named_pipe;
|
||||
my_bool unused1;
|
||||
my_bool unused2;
|
||||
my_bool unused3;
|
||||
my_bool unused4;
|
||||
enum mysql_option methods_to_use;
|
||||
union {
|
||||
/*
|
||||
The ip/hostname to use when authenticating
|
||||
client against embedded server built with
|
||||
grant tables - only used in embedded server
|
||||
*/
|
||||
char *client_ip;
|
||||
|
||||
/*
|
||||
The local address to bind when connecting to
|
||||
remote server - not used in embedded server
|
||||
*/
|
||||
char *bind_address;
|
||||
} ci;
|
||||
my_bool unused5;
|
||||
/* 0 - never report, 1 - always report (default) */
|
||||
my_bool report_data_truncation;
|
||||
|
||||
/* function pointers for local infile support */
|
||||
int (*local_infile_init)(void **, const char *, void *);
|
||||
int (*local_infile_read)(void *, char *, unsigned int);
|
||||
void (*local_infile_end)(void *);
|
||||
int (*local_infile_error)(void *, char *, unsigned int);
|
||||
void *local_infile_userdata;
|
||||
struct st_mysql_options_extention *extension;
|
||||
};
|
||||
|
||||
enum mysql_status
|
||||
{
|
||||
MYSQL_STATUS_READY, MYSQL_STATUS_GET_RESULT, MYSQL_STATUS_USE_RESULT,
|
||||
MYSQL_STATUS_STATEMENT_GET_RESULT
|
||||
};
|
||||
|
||||
enum mysql_protocol_type
|
||||
{
|
||||
MYSQL_PROTOCOL_DEFAULT, MYSQL_PROTOCOL_TCP, MYSQL_PROTOCOL_SOCKET,
|
||||
MYSQL_PROTOCOL_PIPE, MYSQL_PROTOCOL_MEMORY
|
||||
};
|
||||
|
||||
enum mysql_ssl_mode
|
||||
{
|
||||
SSL_MODE_DISABLED= 1, SSL_MODE_PREFERRED, SSL_MODE_REQUIRED,
|
||||
SSL_MODE_VERIFY_CA, SSL_MODE_VERIFY_IDENTITY
|
||||
};
|
||||
|
||||
typedef struct character_set
|
||||
{
|
||||
unsigned int number; /* character set number */
|
||||
unsigned int state; /* character set state */
|
||||
const char *csname; /* collation name */
|
||||
const char *name; /* character set name */
|
||||
const char *comment; /* comment */
|
||||
const char *dir; /* character set directory */
|
||||
unsigned int mbminlen; /* min. length for multibyte strings */
|
||||
unsigned int mbmaxlen; /* max. length for multibyte strings */
|
||||
} MY_CHARSET_INFO;
|
||||
|
||||
struct st_mysql_methods;
|
||||
struct st_mysql_stmt;
|
||||
|
||||
typedef struct st_mysql
|
||||
{
|
||||
NET net; /* Communication parameters */
|
||||
unsigned char *connector_fd; /* ConnectorFd for SSL */
|
||||
char *host,*user,*passwd,*unix_socket,*server_version,*host_info;
|
||||
char *info, *db;
|
||||
struct charset_info_st *charset;
|
||||
MYSQL_FIELD *fields;
|
||||
MEM_ROOT field_alloc;
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* id if insert on table with NEXTNR */
|
||||
my_ulonglong extra_info; /* Not used */
|
||||
unsigned long thread_id; /* Id for connection in server */
|
||||
unsigned long packet_length;
|
||||
unsigned int port;
|
||||
unsigned long client_flag,server_capabilities;
|
||||
unsigned int protocol_version;
|
||||
unsigned int field_count;
|
||||
unsigned int server_status;
|
||||
unsigned int server_language;
|
||||
unsigned int warning_count;
|
||||
struct st_mysql_options options;
|
||||
enum mysql_status status;
|
||||
my_bool free_me; /* If free in mysql_close */
|
||||
my_bool reconnect; /* set to 1 if automatic reconnect */
|
||||
|
||||
/* session-wide random string */
|
||||
char scramble[SCRAMBLE_LENGTH+1];
|
||||
my_bool unused1;
|
||||
void *unused2, *unused3, *unused4, *unused5;
|
||||
|
||||
LIST *stmts; /* list of all statements */
|
||||
const struct st_mysql_methods *methods;
|
||||
void *thd;
|
||||
/*
|
||||
Points to boolean flag in MYSQL_RES or MYSQL_STMT. We set this flag
|
||||
from mysql_stmt_close if close had to cancel result set of this object.
|
||||
*/
|
||||
my_bool *unbuffered_fetch_owner;
|
||||
/* needed for embedded server - no net buffer to store the 'info' */
|
||||
char *info_buffer;
|
||||
void *extension;
|
||||
} MYSQL;
|
||||
|
||||
|
||||
typedef struct st_mysql_res {
|
||||
my_ulonglong row_count;
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_DATA *data;
|
||||
MYSQL_ROWS *data_cursor;
|
||||
unsigned long *lengths; /* column lengths of current row */
|
||||
MYSQL *handle; /* for unbuffered reads */
|
||||
const struct st_mysql_methods *methods;
|
||||
MYSQL_ROW row; /* If unbuffered read */
|
||||
MYSQL_ROW current_row; /* buffer to current row */
|
||||
MEM_ROOT field_alloc;
|
||||
unsigned int field_count, current_field;
|
||||
my_bool eof; /* Used by mysql_fetch_row */
|
||||
/* mysql_stmt_close() had to cancel this result */
|
||||
my_bool unbuffered_fetch_cancelled;
|
||||
void *extension;
|
||||
} MYSQL_RES;
|
||||
|
||||
|
||||
#if !defined(MYSQL_SERVER) && !defined(MYSQL_CLIENT)
|
||||
#define MYSQL_CLIENT
|
||||
#endif
|
||||
|
||||
/*
|
||||
Set up and bring down the server; to ensure that applications will
|
||||
work when linked against either the standard client library or the
|
||||
embedded server library, these functions should be called.
|
||||
*/
|
||||
int STDCALL mysql_server_init(int argc, char **argv, char **groups);
|
||||
void STDCALL mysql_server_end(void);
|
||||
|
||||
/*
|
||||
mysql_server_init/end need to be called when using libmysqld or
|
||||
libmysqlclient (exactly, mysql_server_init() is called by mysql_init() so
|
||||
you don't need to call it explicitely; but you need to call
|
||||
mysql_server_end() to free memory). The names are a bit misleading
|
||||
(mysql_SERVER* to be used when using libmysqlCLIENT). So we add more general
|
||||
names which suit well whether you're using libmysqld or libmysqlclient. We
|
||||
intend to promote these aliases over the mysql_server* ones.
|
||||
*/
|
||||
#define mysql_library_init mysql_server_init
|
||||
#define mysql_library_end mysql_server_end
|
||||
|
||||
|
||||
/*
|
||||
Set up and bring down a thread; these function should be called
|
||||
for each thread in an application which opens at least one MySQL
|
||||
connection. All uses of the connection(s) should be between these
|
||||
function calls.
|
||||
*/
|
||||
my_bool STDCALL mysql_thread_init(void);
|
||||
void STDCALL mysql_thread_end(void);
|
||||
|
||||
/*
|
||||
Functions to get information from the MYSQL and MYSQL_RES structures
|
||||
Should definitely be used if one uses shared libraries.
|
||||
*/
|
||||
|
||||
my_ulonglong STDCALL mysql_num_rows(MYSQL_RES *res);
|
||||
unsigned int STDCALL mysql_num_fields(MYSQL_RES *res);
|
||||
my_bool STDCALL mysql_eof(MYSQL_RES *res);
|
||||
MYSQL_FIELD *STDCALL mysql_fetch_field_direct(MYSQL_RES *res,
|
||||
unsigned int fieldnr);
|
||||
MYSQL_FIELD * STDCALL mysql_fetch_fields(MYSQL_RES *res);
|
||||
MYSQL_ROW_OFFSET STDCALL mysql_row_tell(MYSQL_RES *res);
|
||||
MYSQL_FIELD_OFFSET STDCALL mysql_field_tell(MYSQL_RES *res);
|
||||
|
||||
unsigned int STDCALL mysql_field_count(MYSQL *mysql);
|
||||
my_ulonglong STDCALL mysql_affected_rows(MYSQL *mysql);
|
||||
my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql);
|
||||
unsigned int STDCALL mysql_errno(MYSQL *mysql);
|
||||
const char * STDCALL mysql_error(MYSQL *mysql);
|
||||
const char *STDCALL mysql_sqlstate(MYSQL *mysql);
|
||||
unsigned int STDCALL mysql_warning_count(MYSQL *mysql);
|
||||
const char * STDCALL mysql_info(MYSQL *mysql);
|
||||
unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
|
||||
const char * STDCALL mysql_character_set_name(MYSQL *mysql);
|
||||
int STDCALL mysql_set_character_set(MYSQL *mysql, const char *csname);
|
||||
|
||||
MYSQL * STDCALL mysql_init(MYSQL *mysql);
|
||||
my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
|
||||
const char *cert, const char *ca,
|
||||
const char *capath, const char *cipher);
|
||||
const char * STDCALL mysql_get_ssl_cipher(MYSQL *mysql);
|
||||
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
|
||||
const char *passwd, const char *db);
|
||||
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
|
||||
const char *user,
|
||||
const char *passwd,
|
||||
const char *db,
|
||||
unsigned int port,
|
||||
const char *unix_socket,
|
||||
unsigned long clientflag);
|
||||
int STDCALL mysql_select_db(MYSQL *mysql, const char *db);
|
||||
int STDCALL mysql_query(MYSQL *mysql, const char *q);
|
||||
int STDCALL mysql_send_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
int STDCALL mysql_real_query(MYSQL *mysql, const char *q,
|
||||
unsigned long length);
|
||||
MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql);
|
||||
MYSQL_RES * STDCALL mysql_use_result(MYSQL *mysql);
|
||||
|
||||
void STDCALL mysql_get_character_set_info(MYSQL *mysql,
|
||||
MY_CHARSET_INFO *charset);
|
||||
|
||||
int STDCALL mysql_session_track_get_first(MYSQL *mysql,
|
||||
enum enum_session_state_type type,
|
||||
const char **data,
|
||||
size_t *length);
|
||||
int STDCALL mysql_session_track_get_next(MYSQL *mysql,
|
||||
enum enum_session_state_type type,
|
||||
const char **data,
|
||||
size_t *length);
|
||||
/* local infile support */
|
||||
|
||||
#define LOCAL_INFILE_ERROR_LEN 512
|
||||
|
||||
void
|
||||
mysql_set_local_infile_handler(MYSQL *mysql,
|
||||
int (*local_infile_init)(void **, const char *,
|
||||
void *),
|
||||
int (*local_infile_read)(void *, char *,
|
||||
unsigned int),
|
||||
void (*local_infile_end)(void *),
|
||||
int (*local_infile_error)(void *, char*,
|
||||
unsigned int),
|
||||
void *);
|
||||
|
||||
void
|
||||
mysql_set_local_infile_default(MYSQL *mysql);
|
||||
|
||||
int STDCALL mysql_shutdown(MYSQL *mysql,
|
||||
enum mysql_enum_shutdown_level
|
||||
shutdown_level);
|
||||
int STDCALL mysql_dump_debug_info(MYSQL *mysql);
|
||||
int STDCALL mysql_refresh(MYSQL *mysql,
|
||||
unsigned int refresh_options);
|
||||
int STDCALL mysql_kill(MYSQL *mysql,unsigned long pid);
|
||||
int STDCALL mysql_set_server_option(MYSQL *mysql,
|
||||
enum enum_mysql_set_option
|
||||
option);
|
||||
int STDCALL mysql_ping(MYSQL *mysql);
|
||||
const char * STDCALL mysql_stat(MYSQL *mysql);
|
||||
const char * STDCALL mysql_get_server_info(MYSQL *mysql);
|
||||
const char * STDCALL mysql_get_client_info(void);
|
||||
unsigned long STDCALL mysql_get_client_version(void);
|
||||
const char * STDCALL mysql_get_host_info(MYSQL *mysql);
|
||||
unsigned long STDCALL mysql_get_server_version(MYSQL *mysql);
|
||||
unsigned int STDCALL mysql_get_proto_info(MYSQL *mysql);
|
||||
MYSQL_RES * STDCALL mysql_list_dbs(MYSQL *mysql,const char *wild);
|
||||
MYSQL_RES * STDCALL mysql_list_tables(MYSQL *mysql,const char *wild);
|
||||
MYSQL_RES * STDCALL mysql_list_processes(MYSQL *mysql);
|
||||
int STDCALL mysql_options(MYSQL *mysql,enum mysql_option option,
|
||||
const void *arg);
|
||||
int STDCALL mysql_options4(MYSQL *mysql,enum mysql_option option,
|
||||
const void *arg1, const void *arg2);
|
||||
int STDCALL mysql_get_option(MYSQL *mysql, enum mysql_option option,
|
||||
const void *arg);
|
||||
void STDCALL mysql_free_result(MYSQL_RES *result);
|
||||
void STDCALL mysql_data_seek(MYSQL_RES *result,
|
||||
my_ulonglong offset);
|
||||
MYSQL_ROW_OFFSET STDCALL mysql_row_seek(MYSQL_RES *result,
|
||||
MYSQL_ROW_OFFSET offset);
|
||||
MYSQL_FIELD_OFFSET STDCALL mysql_field_seek(MYSQL_RES *result,
|
||||
MYSQL_FIELD_OFFSET offset);
|
||||
MYSQL_ROW STDCALL mysql_fetch_row(MYSQL_RES *result);
|
||||
unsigned long * STDCALL mysql_fetch_lengths(MYSQL_RES *result);
|
||||
MYSQL_FIELD * STDCALL mysql_fetch_field(MYSQL_RES *result);
|
||||
MYSQL_RES * STDCALL mysql_list_fields(MYSQL *mysql, const char *table,
|
||||
const char *wild);
|
||||
unsigned long STDCALL mysql_escape_string(char *to,const char *from,
|
||||
unsigned long from_length);
|
||||
unsigned long STDCALL mysql_hex_string(char *to,const char *from,
|
||||
unsigned long from_length);
|
||||
unsigned long STDCALL mysql_real_escape_string(MYSQL *mysql,
|
||||
char *to,const char *from,
|
||||
unsigned long length);
|
||||
unsigned long STDCALL mysql_real_escape_string_quote(MYSQL *mysql,
|
||||
char *to, const char *from,
|
||||
unsigned long length, char quote);
|
||||
void STDCALL mysql_debug(const char *debug);
|
||||
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
|
||||
unsigned int STDCALL mysql_thread_safe(void);
|
||||
my_bool STDCALL mysql_embedded(void);
|
||||
my_bool STDCALL mysql_read_query_result(MYSQL *mysql);
|
||||
int STDCALL mysql_reset_connection(MYSQL *mysql);
|
||||
|
||||
/*
|
||||
The following definitions are added for the enhanced
|
||||
client-server protocol
|
||||
*/
|
||||
|
||||
/* statement state */
|
||||
enum enum_mysql_stmt_state
|
||||
{
|
||||
MYSQL_STMT_INIT_DONE= 1, MYSQL_STMT_PREPARE_DONE, MYSQL_STMT_EXECUTE_DONE,
|
||||
MYSQL_STMT_FETCH_DONE
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
This structure is used to define bind information, and
|
||||
internally by the client library.
|
||||
Public members with their descriptions are listed below
|
||||
(conventionally `On input' refers to the binds given to
|
||||
mysql_stmt_bind_param, `On output' refers to the binds given
|
||||
to mysql_stmt_bind_result):
|
||||
|
||||
buffer_type - One of the MYSQL_* types, used to describe
|
||||
the host language type of buffer.
|
||||
On output: if column type is different from
|
||||
buffer_type, column value is automatically converted
|
||||
to buffer_type before it is stored in the buffer.
|
||||
buffer - On input: points to the buffer with input data.
|
||||
On output: points to the buffer capable to store
|
||||
output data.
|
||||
The type of memory pointed by buffer must correspond
|
||||
to buffer_type. See the correspondence table in
|
||||
the comment to mysql_stmt_bind_param.
|
||||
|
||||
The two above members are mandatory for any kind of bind.
|
||||
|
||||
buffer_length - the length of the buffer. You don't have to set
|
||||
it for any fixed length buffer: float, double,
|
||||
int, etc. It must be set however for variable-length
|
||||
types, such as BLOBs or STRINGs.
|
||||
|
||||
length - On input: in case when lengths of input values
|
||||
are different for each execute, you can set this to
|
||||
point at a variable containining value length. This
|
||||
way the value length can be different in each execute.
|
||||
If length is not NULL, buffer_length is not used.
|
||||
Note, length can even point at buffer_length if
|
||||
you keep bind structures around while fetching:
|
||||
this way you can change buffer_length before
|
||||
each execution, everything will work ok.
|
||||
On output: if length is set, mysql_stmt_fetch will
|
||||
write column length into it.
|
||||
|
||||
is_null - On input: points to a boolean variable that should
|
||||
be set to TRUE for NULL values.
|
||||
This member is useful only if your data may be
|
||||
NULL in some but not all cases.
|
||||
If your data is never NULL, is_null should be set to 0.
|
||||
If your data is always NULL, set buffer_type
|
||||
to MYSQL_TYPE_NULL, and is_null will not be used.
|
||||
|
||||
is_unsigned - On input: used to signify that values provided for one
|
||||
of numeric types are unsigned.
|
||||
On output describes signedness of the output buffer.
|
||||
If, taking into account is_unsigned flag, column data
|
||||
is out of range of the output buffer, data for this column
|
||||
is regarded truncated. Note that this has no correspondence
|
||||
to the sign of result set column, if you need to find it out
|
||||
use mysql_stmt_result_metadata.
|
||||
error - where to write a truncation error if it is present.
|
||||
possible error value is:
|
||||
0 no truncation
|
||||
1 value is out of range or buffer is too small
|
||||
|
||||
Please note that MYSQL_BIND also has internals members.
|
||||
*/
|
||||
|
||||
typedef struct st_mysql_bind
|
||||
{
|
||||
unsigned long *length; /* output length pointer */
|
||||
my_bool *is_null; /* Pointer to null indicator */
|
||||
void *buffer; /* buffer to get/put data */
|
||||
/* set this if you want to track data truncations happened during fetch */
|
||||
my_bool *error;
|
||||
unsigned char *row_ptr; /* for the current data position */
|
||||
void (*store_param_func)(NET *net, struct st_mysql_bind *param);
|
||||
void (*fetch_result)(struct st_mysql_bind *, MYSQL_FIELD *,
|
||||
unsigned char **row);
|
||||
void (*skip_result)(struct st_mysql_bind *, MYSQL_FIELD *,
|
||||
unsigned char **row);
|
||||
/* output buffer length, must be set when fetching str/binary */
|
||||
unsigned long buffer_length;
|
||||
unsigned long offset; /* offset position for char/binary fetch */
|
||||
unsigned long length_value; /* Used if length is 0 */
|
||||
unsigned int param_number; /* For null count and error messages */
|
||||
unsigned int pack_length; /* Internal length for packed data */
|
||||
enum enum_field_types buffer_type; /* buffer type */
|
||||
my_bool error_value; /* used if error is 0 */
|
||||
my_bool is_unsigned; /* set if integer type is unsigned */
|
||||
my_bool long_data_used; /* If used with mysql_send_long_data */
|
||||
my_bool is_null_value; /* Used if is_null is 0 */
|
||||
void *extension;
|
||||
} MYSQL_BIND;
|
||||
|
||||
|
||||
struct st_mysql_stmt_extension;
|
||||
|
||||
/* statement handler */
|
||||
typedef struct st_mysql_stmt
|
||||
{
|
||||
MEM_ROOT mem_root; /* root allocations */
|
||||
LIST list; /* list to keep track of all stmts */
|
||||
MYSQL *mysql; /* connection handle */
|
||||
MYSQL_BIND *params; /* input parameters */
|
||||
MYSQL_BIND *bind; /* output parameters */
|
||||
MYSQL_FIELD *fields; /* result set metadata */
|
||||
MYSQL_DATA result; /* cached result set */
|
||||
MYSQL_ROWS *data_cursor; /* current row in cached result */
|
||||
/*
|
||||
mysql_stmt_fetch() calls this function to fetch one row (it's different
|
||||
for buffered, unbuffered and cursor fetch).
|
||||
*/
|
||||
int (*read_row_func)(struct st_mysql_stmt *stmt,
|
||||
unsigned char **row);
|
||||
/* copy of mysql->affected_rows after statement execution */
|
||||
my_ulonglong affected_rows;
|
||||
my_ulonglong insert_id; /* copy of mysql->insert_id */
|
||||
unsigned long stmt_id; /* Id for prepared statement */
|
||||
unsigned long flags; /* i.e. type of cursor to open */
|
||||
unsigned long prefetch_rows; /* number of rows per one COM_FETCH */
|
||||
/*
|
||||
Copied from mysql->server_status after execute/fetch to know
|
||||
server-side cursor status for this statement.
|
||||
*/
|
||||
unsigned int server_status;
|
||||
unsigned int last_errno; /* error code */
|
||||
unsigned int param_count; /* input parameter count */
|
||||
unsigned int field_count; /* number of columns in result set */
|
||||
enum enum_mysql_stmt_state state; /* statement state */
|
||||
char last_error[MYSQL_ERRMSG_SIZE]; /* error message */
|
||||
char sqlstate[SQLSTATE_LENGTH+1];
|
||||
/* Types of input parameters should be sent to server */
|
||||
my_bool send_types_to_server;
|
||||
my_bool bind_param_done; /* input buffers were supplied */
|
||||
unsigned char bind_result_done; /* output buffers were supplied */
|
||||
/* mysql_stmt_close() had to cancel this result */
|
||||
my_bool unbuffered_fetch_cancelled;
|
||||
/*
|
||||
Is set to true if we need to calculate field->max_length for
|
||||
metadata fields when doing mysql_stmt_store_result.
|
||||
*/
|
||||
my_bool update_max_length;
|
||||
struct st_mysql_stmt_extension *extension;
|
||||
} MYSQL_STMT;
|
||||
|
||||
enum enum_stmt_attr_type
|
||||
{
|
||||
/*
|
||||
When doing mysql_stmt_store_result calculate max_length attribute
|
||||
of statement metadata. This is to be consistent with the old API,
|
||||
where this was done automatically.
|
||||
In the new API we do that only by request because it slows down
|
||||
mysql_stmt_store_result sufficiently.
|
||||
*/
|
||||
STMT_ATTR_UPDATE_MAX_LENGTH,
|
||||
/*
|
||||
unsigned long with combination of cursor flags (read only, for update,
|
||||
etc)
|
||||
*/
|
||||
STMT_ATTR_CURSOR_TYPE,
|
||||
/*
|
||||
Amount of rows to retrieve from server per one fetch if using cursors.
|
||||
Accepts unsigned long attribute in the range 1 - ulong_max
|
||||
*/
|
||||
STMT_ATTR_PREFETCH_ROWS
|
||||
};
|
||||
|
||||
|
||||
MYSQL_STMT * STDCALL mysql_stmt_init(MYSQL *mysql);
|
||||
int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query,
|
||||
unsigned long length);
|
||||
int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt);
|
||||
int STDCALL mysql_stmt_fetch(MYSQL_STMT *stmt);
|
||||
int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind_arg,
|
||||
unsigned int column,
|
||||
unsigned long offset);
|
||||
int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt);
|
||||
unsigned long STDCALL mysql_stmt_param_count(MYSQL_STMT * stmt);
|
||||
my_bool STDCALL mysql_stmt_attr_set(MYSQL_STMT *stmt,
|
||||
enum enum_stmt_attr_type attr_type,
|
||||
const void *attr);
|
||||
my_bool STDCALL mysql_stmt_attr_get(MYSQL_STMT *stmt,
|
||||
enum enum_stmt_attr_type attr_type,
|
||||
void *attr);
|
||||
my_bool STDCALL mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
|
||||
my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd);
|
||||
my_bool STDCALL mysql_stmt_close(MYSQL_STMT * stmt);
|
||||
my_bool STDCALL mysql_stmt_reset(MYSQL_STMT * stmt);
|
||||
my_bool STDCALL mysql_stmt_free_result(MYSQL_STMT *stmt);
|
||||
my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt,
|
||||
unsigned int param_number,
|
||||
const char *data,
|
||||
unsigned long length);
|
||||
MYSQL_RES *STDCALL mysql_stmt_result_metadata(MYSQL_STMT *stmt);
|
||||
MYSQL_RES *STDCALL mysql_stmt_param_metadata(MYSQL_STMT *stmt);
|
||||
unsigned int STDCALL mysql_stmt_errno(MYSQL_STMT * stmt);
|
||||
const char *STDCALL mysql_stmt_error(MYSQL_STMT * stmt);
|
||||
const char *STDCALL mysql_stmt_sqlstate(MYSQL_STMT * stmt);
|
||||
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_seek(MYSQL_STMT *stmt,
|
||||
MYSQL_ROW_OFFSET offset);
|
||||
MYSQL_ROW_OFFSET STDCALL mysql_stmt_row_tell(MYSQL_STMT *stmt);
|
||||
void STDCALL mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong offset);
|
||||
my_ulonglong STDCALL mysql_stmt_num_rows(MYSQL_STMT *stmt);
|
||||
my_ulonglong STDCALL mysql_stmt_affected_rows(MYSQL_STMT *stmt);
|
||||
my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt);
|
||||
unsigned int STDCALL mysql_stmt_field_count(MYSQL_STMT *stmt);
|
||||
|
||||
my_bool STDCALL mysql_commit(MYSQL * mysql);
|
||||
my_bool STDCALL mysql_rollback(MYSQL * mysql);
|
||||
my_bool STDCALL mysql_autocommit(MYSQL * mysql, my_bool auto_mode);
|
||||
my_bool STDCALL mysql_more_results(MYSQL *mysql);
|
||||
int STDCALL mysql_next_result(MYSQL *mysql);
|
||||
int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt);
|
||||
void STDCALL mysql_close(MYSQL *sock);
|
||||
|
||||
|
||||
/* status return codes */
|
||||
#define MYSQL_NO_DATA 100
|
||||
#define MYSQL_DATA_TRUNCATED 101
|
||||
|
||||
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
|
||||
|
||||
#define HAVE_MYSQL_REAL_CONNECT
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _mysql_h */
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
#ifndef CLIENT_AUTHENTICATION_H
|
||||
#define CLIENT_AUTHENTICATION_H
|
||||
#include <my_global.h>
|
||||
#include "mysql.h"
|
||||
#include "mysql/client_plugin.h"
|
||||
|
||||
C_MODE_START
|
||||
int sha256_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
|
||||
int sha256_password_init(char *, size_t, int, va_list);
|
||||
int sha256_password_deinit(void);
|
||||
int caching_sha2_password_auth_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql);
|
||||
int caching_sha2_password_init(char *, size_t, int, va_list);
|
||||
int caching_sha2_password_deinit(void);
|
||||
C_MODE_END
|
||||
|
||||
#endif
|
||||
|
||||
214
demo/kugou/include/Common/include/mysql/mysql/client_plugin.h
Normal file
214
demo/kugou/include/Common/include/mysql/mysql/client_plugin.h
Normal file
@@ -0,0 +1,214 @@
|
||||
#ifndef MYSQL_CLIENT_PLUGIN_INCLUDED
|
||||
/* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
MySQL Client Plugin API
|
||||
|
||||
This file defines the API for plugins that work on the client side
|
||||
*/
|
||||
#define MYSQL_CLIENT_PLUGIN_INCLUDED
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
On Windows, exports from DLL need to be declared.
|
||||
Also, plugin needs to be declared as extern "C" because MSVC
|
||||
unlike other compilers, uses C++ mangling for variables not only
|
||||
for functions.
|
||||
*/
|
||||
|
||||
#undef MYSQL_PLUGIN_EXPORT
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(MYSQL_DYNAMIC_PLUGIN)
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#else /* MYSQL_DYNAMIC_PLUGIN */
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_PLUGIN_EXPORT extern "C"
|
||||
#else
|
||||
#define MYSQL_PLUGIN_EXPORT
|
||||
#endif
|
||||
#endif /*MYSQL_DYNAMIC_PLUGIN */
|
||||
#else /*_MSC_VER */
|
||||
#define MYSQL_PLUGIN_EXPORT
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* known plugin types */
|
||||
#define MYSQL_CLIENT_reserved1 0
|
||||
#define MYSQL_CLIENT_reserved2 1
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN 2
|
||||
#define MYSQL_CLIENT_TRACE_PLUGIN 3
|
||||
|
||||
#define MYSQL_CLIENT_AUTHENTICATION_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
#define MYSQL_CLIENT_TRACE_PLUGIN_INTERFACE_VERSION 0x0100
|
||||
|
||||
#define MYSQL_CLIENT_MAX_PLUGINS 4
|
||||
|
||||
#define mysql_declare_client_plugin(X) \
|
||||
MYSQL_PLUGIN_EXPORT struct st_mysql_client_plugin_ ## X \
|
||||
_mysql_client_plugin_declaration_ = { \
|
||||
MYSQL_CLIENT_ ## X ## _PLUGIN, \
|
||||
MYSQL_CLIENT_ ## X ## _PLUGIN_INTERFACE_VERSION,
|
||||
#define mysql_end_client_plugin }
|
||||
|
||||
/* generic plugin header structure */
|
||||
#define MYSQL_CLIENT_PLUGIN_HEADER \
|
||||
int type; \
|
||||
unsigned int interface_version; \
|
||||
const char *name; \
|
||||
const char *author; \
|
||||
const char *desc; \
|
||||
unsigned int version[3]; \
|
||||
const char *license; \
|
||||
void *mysql_api; \
|
||||
int (*init)(char *, size_t, int, va_list); \
|
||||
int (*deinit)(void); \
|
||||
int (*options)(const char *option, const void *);
|
||||
|
||||
struct st_mysql_client_plugin
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
};
|
||||
|
||||
struct st_mysql;
|
||||
|
||||
/******** authentication plugin specific declarations *********/
|
||||
#include "plugin_auth_common.h"
|
||||
|
||||
struct st_mysql_client_plugin_AUTHENTICATION
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql);
|
||||
};
|
||||
|
||||
/******** using plugins ************/
|
||||
|
||||
/**
|
||||
loads a plugin and initializes it
|
||||
|
||||
@param mysql MYSQL structure.
|
||||
@param name a name of the plugin to load
|
||||
@param type type of plugin that should be loaded, -1 to disable type check
|
||||
@param argc number of arguments to pass to the plugin initialization
|
||||
function
|
||||
@param ... arguments for the plugin initialization function
|
||||
|
||||
@retval
|
||||
a pointer to the loaded plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, ...);
|
||||
|
||||
/**
|
||||
loads a plugin and initializes it, taking va_list as an argument
|
||||
|
||||
This is the same as mysql_load_plugin, but take va_list instead of
|
||||
a list of arguments.
|
||||
|
||||
@param mysql MYSQL structure.
|
||||
@param name a name of the plugin to load
|
||||
@param type type of plugin that should be loaded, -1 to disable type check
|
||||
@param argc number of arguments to pass to the plugin initialization
|
||||
function
|
||||
@param args arguments for the plugin initialization function
|
||||
|
||||
@retval
|
||||
a pointer to the loaded plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, va_list args);
|
||||
|
||||
/**
|
||||
finds an already loaded plugin by name, or loads it, if necessary
|
||||
|
||||
@param mysql MYSQL structure.
|
||||
@param name a name of the plugin to load
|
||||
@param type type of plugin that should be loaded
|
||||
|
||||
@retval
|
||||
a pointer to the plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
|
||||
|
||||
/**
|
||||
adds a plugin structure to the list of loaded plugins
|
||||
|
||||
This is useful if an application has the necessary functionality
|
||||
(for example, a special load data handler) statically linked into
|
||||
the application binary. It can use this function to register the plugin
|
||||
directly, avoiding the need to factor it out into a shared object.
|
||||
|
||||
@param mysql MYSQL structure. It is only used for error reporting
|
||||
@param plugin an st_mysql_client_plugin structure to register
|
||||
|
||||
@retval
|
||||
a pointer to the plugin, or NULL in case of a failure
|
||||
*/
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_register_plugin(struct st_mysql *mysql,
|
||||
struct st_mysql_client_plugin *plugin);
|
||||
|
||||
/**
|
||||
set plugin options
|
||||
|
||||
Can be used to set extra options and affect behavior for a plugin.
|
||||
This function may be called multiple times to set several options
|
||||
|
||||
@param plugin an st_mysql_client_plugin structure
|
||||
@param option a string which specifies the option to set
|
||||
@param value value for the option.
|
||||
|
||||
@retval 0 on success, 1 in case of failure
|
||||
**/
|
||||
int mysql_plugin_options(struct st_mysql_client_plugin *plugin,
|
||||
const char *option, const void *value);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
struct st_mysql_client_plugin
|
||||
{
|
||||
int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(void); int (*options)(const char *option, const void *);
|
||||
};
|
||||
struct st_mysql;
|
||||
#include "plugin_auth_common.h"
|
||||
typedef struct st_plugin_vio_info
|
||||
{
|
||||
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
|
||||
MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
|
||||
int socket;
|
||||
} MYSQL_PLUGIN_VIO_INFO;
|
||||
typedef struct st_plugin_vio
|
||||
{
|
||||
int (*read_packet)(struct st_plugin_vio *vio,
|
||||
unsigned char **buf);
|
||||
int (*write_packet)(struct st_plugin_vio *vio,
|
||||
const unsigned char *packet,
|
||||
int packet_len);
|
||||
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
|
||||
} MYSQL_PLUGIN_VIO;
|
||||
struct st_mysql_client_plugin_AUTHENTICATION
|
||||
{
|
||||
int type; unsigned int interface_version; const char *name; const char *author; const char *desc; unsigned int version[3]; const char *license; void *mysql_api; int (*init)(char *, size_t, int, va_list); int (*deinit)(void); int (*options)(const char *option, const void *);
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, struct st_mysql *mysql);
|
||||
};
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, ...);
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_load_plugin_v(struct st_mysql *mysql, const char *name, int type,
|
||||
int argc, va_list args);
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_find_plugin(struct st_mysql *mysql, const char *name, int type);
|
||||
struct st_mysql_client_plugin *
|
||||
mysql_client_register_plugin(struct st_mysql *mysql,
|
||||
struct st_mysql_client_plugin *plugin);
|
||||
int mysql_plugin_options(struct st_mysql_client_plugin *plugin,
|
||||
const char *option, const void *value);
|
||||
132
demo/kugou/include/Common/include/mysql/mysql/com_data.h
Normal file
132
demo/kugou/include/Common/include/mysql/mysql/com_data.h
Normal file
@@ -0,0 +1,132 @@
|
||||
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
#ifndef PLUGIN_PROTOCOL_INCLUDED
|
||||
#define PLUGIN_PROTOCOL_INCLUDED
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include "my_global.h" /* Needed for my_bool in mysql_com.h */
|
||||
#include "mysql_com.h" /* mysql_enum_shutdown_level */
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@file
|
||||
Definition of COM_DATA to be used with the Command service as data input
|
||||
structure.
|
||||
*/
|
||||
|
||||
|
||||
typedef struct st_com_init_db_data
|
||||
{
|
||||
const char *db_name;
|
||||
unsigned long length;
|
||||
} COM_INIT_DB_DATA;
|
||||
|
||||
typedef struct st_com_refresh_data
|
||||
{
|
||||
unsigned char options;
|
||||
} COM_REFRESH_DATA;
|
||||
|
||||
typedef struct st_com_shutdown_data
|
||||
{
|
||||
enum mysql_enum_shutdown_level level;
|
||||
} COM_SHUTDOWN_DATA;
|
||||
|
||||
typedef struct st_com_kill_data
|
||||
{
|
||||
unsigned long id;
|
||||
} COM_KILL_DATA;
|
||||
|
||||
typedef struct st_com_set_option_data
|
||||
{
|
||||
unsigned int opt_command;
|
||||
} COM_SET_OPTION_DATA;
|
||||
|
||||
typedef struct st_com_stmt_execute_data
|
||||
{
|
||||
unsigned long stmt_id;
|
||||
unsigned long flags;
|
||||
unsigned char *params;
|
||||
unsigned long params_length;
|
||||
} COM_STMT_EXECUTE_DATA;
|
||||
|
||||
typedef struct st_com_stmt_fetch_data
|
||||
{
|
||||
unsigned long stmt_id;
|
||||
unsigned long num_rows;
|
||||
} COM_STMT_FETCH_DATA;
|
||||
|
||||
typedef struct st_com_stmt_send_long_data_data
|
||||
{
|
||||
unsigned long stmt_id;
|
||||
unsigned int param_number;
|
||||
unsigned char *longdata;
|
||||
unsigned long length;
|
||||
} COM_STMT_SEND_LONG_DATA_DATA;
|
||||
|
||||
typedef struct st_com_stmt_prepare_data
|
||||
{
|
||||
const char *query;
|
||||
unsigned int length;
|
||||
} COM_STMT_PREPARE_DATA;
|
||||
|
||||
typedef struct st_stmt_close_data
|
||||
{
|
||||
unsigned int stmt_id;
|
||||
} COM_STMT_CLOSE_DATA;
|
||||
|
||||
typedef struct st_com_stmt_reset_data
|
||||
{
|
||||
unsigned int stmt_id;
|
||||
} COM_STMT_RESET_DATA;
|
||||
|
||||
typedef struct st_com_query_data
|
||||
{
|
||||
const char *query;
|
||||
unsigned int length;
|
||||
} COM_QUERY_DATA;
|
||||
|
||||
typedef struct st_com_field_list_data
|
||||
{
|
||||
unsigned char *table_name;
|
||||
unsigned int table_name_length;
|
||||
const unsigned char *query;
|
||||
unsigned int query_length;
|
||||
} COM_FIELD_LIST_DATA;
|
||||
|
||||
union COM_DATA {
|
||||
COM_INIT_DB_DATA com_init_db;
|
||||
COM_REFRESH_DATA com_refresh;
|
||||
COM_SHUTDOWN_DATA com_shutdown;
|
||||
COM_KILL_DATA com_kill;
|
||||
COM_SET_OPTION_DATA com_set_option;
|
||||
COM_STMT_EXECUTE_DATA com_stmt_execute;
|
||||
COM_STMT_FETCH_DATA com_stmt_fetch;
|
||||
COM_STMT_SEND_LONG_DATA_DATA com_stmt_send_long_data;
|
||||
COM_STMT_PREPARE_DATA com_stmt_prepare;
|
||||
COM_STMT_CLOSE_DATA com_stmt_close;
|
||||
COM_STMT_RESET_DATA com_stmt_reset;
|
||||
COM_QUERY_DATA com_query;
|
||||
COM_FIELD_LIST_DATA com_field_list;
|
||||
};
|
||||
|
||||
#endif /* PLUGIN_PROTOCOL_INCLUDED */
|
||||
43
demo/kugou/include/Common/include/mysql/mysql/get_password.h
Normal file
43
demo/kugou/include/Common/include/mysql/mysql/get_password.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
/*
|
||||
** Ask for a password from tty
|
||||
** This is an own file to avoid conflicts with curses
|
||||
*/
|
||||
|
||||
#ifndef MYSQL_GET_PASSWORD_H_INCLUDED
|
||||
#define MYSQL_GET_PASSWORD_H_INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef char *(* strdup_handler_t)(const char *, int);
|
||||
char *get_tty_password_ext(const char *opt_message,
|
||||
strdup_handler_t strdup_function);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ! MYSQL_GET_PASSWORD_H_INCLUDED */
|
||||
@@ -0,0 +1,206 @@
|
||||
/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef GROUP_REPLICATION_PRIV_INCLUDE
|
||||
#define GROUP_REPLICATION_PRIV_INCLUDE
|
||||
|
||||
#ifndef MYSQL_SERVER
|
||||
#define MYSQL_SERVER
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_REPLICATION
|
||||
#define HAVE_REPLICATION
|
||||
#endif
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_thread.h>
|
||||
#include <my_sys.h>
|
||||
|
||||
#include <debug_sync.h>
|
||||
#include <log_event.h>
|
||||
#include <replication.h>
|
||||
#include <rpl_channel_service_interface.h>
|
||||
#include <rpl_gtid.h>
|
||||
#include <rpl_write_set_handler.h>
|
||||
|
||||
|
||||
/**
|
||||
Server side initializations.
|
||||
*/
|
||||
int group_replication_init();
|
||||
|
||||
|
||||
/**
|
||||
Returns the server connection attribute
|
||||
|
||||
@Note This method implementation is on sql_class.cc
|
||||
|
||||
@return the pthread for the connection attribute.
|
||||
*/
|
||||
my_thread_attr_t *get_connection_attrib();
|
||||
|
||||
/**
|
||||
Returns the server hostname, port and uuid.
|
||||
|
||||
@param[out] hostname
|
||||
@param[out] port
|
||||
@param[out] uuid
|
||||
@param[out] server_version
|
||||
@param[out] server_ssl_variables
|
||||
|
||||
*/
|
||||
void get_server_parameters(char **hostname, uint *port, char **uuid,
|
||||
unsigned int *server_version,
|
||||
st_server_ssl_variables* server_ssl_variables);
|
||||
|
||||
/**
|
||||
Returns the server_id.
|
||||
|
||||
@return server_id
|
||||
*/
|
||||
ulong get_server_id();
|
||||
|
||||
/**
|
||||
Returns the server auto_increment_increment
|
||||
|
||||
@return auto_increment_increment
|
||||
*/
|
||||
ulong get_auto_increment_increment();
|
||||
|
||||
|
||||
/**
|
||||
Returns the server auto_increment_offset
|
||||
|
||||
@return auto_increment_offset
|
||||
*/
|
||||
ulong get_auto_increment_offset();
|
||||
|
||||
|
||||
/**
|
||||
Set server auto_increment_increment
|
||||
|
||||
@param[in] auto_increment_increment
|
||||
*/
|
||||
void set_auto_increment_increment(ulong auto_increment_increment);
|
||||
|
||||
|
||||
/**
|
||||
Set server auto_increment_offset
|
||||
|
||||
@param[in] auto_increment_offset
|
||||
*/
|
||||
void set_auto_increment_offset(ulong auto_increment_offset);
|
||||
|
||||
|
||||
/**
|
||||
Returns a struct containing all server startup information needed to evaluate
|
||||
if one has conditions to proceed executing master-master replication.
|
||||
|
||||
@param[out] requirements
|
||||
|
||||
@param[in] has_lock Caller should set this to true if the calling
|
||||
thread holds gtid_mode_lock; otherwise set it to false.
|
||||
*/
|
||||
void get_server_startup_prerequirements(Trans_context_info& requirements,
|
||||
bool has_lock);
|
||||
|
||||
|
||||
/**
|
||||
Returns the server GTID_EXECUTED encoded as a binary string.
|
||||
|
||||
@note Memory allocated to encoded_gtid_executed must be release by caller.
|
||||
|
||||
@param[out] encoded_gtid_executed binary string
|
||||
@param[out] length binary string length
|
||||
*/
|
||||
bool get_server_encoded_gtid_executed(uchar **encoded_gtid_executed,
|
||||
size_t *length);
|
||||
|
||||
#if !defined(DBUG_OFF)
|
||||
/**
|
||||
Returns a text representation of a encoded GTID set.
|
||||
|
||||
@note Memory allocated to returned pointer must be release by caller.
|
||||
|
||||
@param[in] encoded_gtid_set binary string
|
||||
@param[in] length binary string length
|
||||
|
||||
@return a pointer to text representation of the encoded set
|
||||
*/
|
||||
char* encoded_gtid_set_to_string(uchar *encoded_gtid_set, size_t length);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Return last gno for a given sidno, see
|
||||
Gtid_state::get_last_executed_gno() for details.
|
||||
*/
|
||||
rpl_gno get_last_executed_gno(rpl_sidno sidno);
|
||||
|
||||
|
||||
/**
|
||||
Return sidno for a given sid, see Sid_map::add_sid() for details.
|
||||
*/
|
||||
rpl_sidno get_sidno_from_global_sid_map(rpl_sid sid);
|
||||
|
||||
|
||||
/**
|
||||
Set slave thread default options.
|
||||
|
||||
@param[in] thd The thread
|
||||
*/
|
||||
void set_slave_thread_options(THD* thd);
|
||||
|
||||
|
||||
/**
|
||||
Add thread to Global_THD_manager singleton.
|
||||
|
||||
@param[in] thd The thread
|
||||
*/
|
||||
void global_thd_manager_add_thd(THD *thd);
|
||||
|
||||
|
||||
/**
|
||||
Remove thread from Global_THD_manager singleton.
|
||||
|
||||
@param[in] thd The thread
|
||||
*/
|
||||
void global_thd_manager_remove_thd(THD *thd);
|
||||
|
||||
/**
|
||||
Function that returns the write set extraction algorithm name.
|
||||
|
||||
@param[in] algorithm The algorithm value
|
||||
|
||||
@return the algorithm name
|
||||
*/
|
||||
const char* get_write_set_algorithm_string(unsigned int algorithm);
|
||||
|
||||
/**
|
||||
Returns the value of slave_max_allowed_packet.
|
||||
|
||||
@return slave_max_allowed_packet
|
||||
*/
|
||||
unsigned long get_slave_max_allowed_packet();
|
||||
|
||||
#endif /* GROUP_REPLICATION_PRIV_INCLUDE */
|
||||
|
||||
62
demo/kugou/include/Common/include/mysql/mysql/innodb_priv.h
Normal file
62
demo/kugou/include/Common/include/mysql/mysql/innodb_priv.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 Street, Fifth Floor, Boston, MA 02110-1301, USA */
|
||||
|
||||
#ifndef INNODB_PRIV_INCLUDED
|
||||
#define INNODB_PRIV_INCLUDED
|
||||
|
||||
/** @file Declaring server-internal functions that are used by InnoDB. */
|
||||
|
||||
class THD;
|
||||
|
||||
int get_quote_char_for_identifier(THD *thd, const char *name, size_t length);
|
||||
bool schema_table_store_record(THD *thd, TABLE *table);
|
||||
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
|
||||
bool check_global_access(THD *thd, ulong want_access);
|
||||
size_t strconvert(CHARSET_INFO *from_cs, const char *from,
|
||||
CHARSET_INFO *to_cs, char *to, size_t to_length,
|
||||
uint *errors);
|
||||
void sql_print_error(const char *format, ...);
|
||||
|
||||
/**
|
||||
Store record to I_S table, convert HEAP table to InnoDB table if necessary.
|
||||
|
||||
@param[in] thd thread handler
|
||||
@param[in] table Information schema table to be updated
|
||||
@param[in] make_ondisk if true, convert heap table to on disk table.
|
||||
default value is true.
|
||||
@return 0 on success
|
||||
@return error code on failure.
|
||||
*/
|
||||
int schema_table_store_record2(THD *thd, TABLE *table, bool make_ondisk);
|
||||
|
||||
/**
|
||||
Convert HEAP table to InnoDB table if necessary
|
||||
|
||||
@param[in] thd thread handler
|
||||
@param[in] table Information schema table to be converted.
|
||||
@param[in] error the error code returned previously.
|
||||
@return false on success, true on error.
|
||||
*/
|
||||
bool convert_heap_table_to_ondisk(THD *thd, TABLE *table, int error);
|
||||
|
||||
|
||||
#endif /* INNODB_PRIV_INCLUDED */
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MYSQL_LEX_STRING_INCLUDED
|
||||
#define MYSQL_LEX_STRING_INCLUDED
|
||||
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
|
||||
struct st_mysql_const_lex_string
|
||||
{
|
||||
const char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_const_lex_string MYSQL_LEX_CSTRING;
|
||||
|
||||
#endif // MYSQL_LEX_STRING_INCLUDED
|
||||
752
demo/kugou/include/Common/include/mysql/mysql/plugin.h
Normal file
752
demo/kugou/include/Common/include/mysql/mysql/plugin.h
Normal file
@@ -0,0 +1,752 @@
|
||||
/* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _my_plugin_h
|
||||
#define _my_plugin_h
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <stddef.h>
|
||||
#include "mysql_version.h" /* MYSQL_VERSION_ID */
|
||||
#endif
|
||||
|
||||
/*
|
||||
On Windows, exports from DLL need to be declared.
|
||||
Also, plugin needs to be declared as extern "C" because MSVC
|
||||
unlike other compilers, uses C++ mangling for variables not only
|
||||
for functions.
|
||||
*/
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(MYSQL_DYNAMIC_PLUGIN)
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#else /* MYSQL_DYNAMIC_PLUGIN */
|
||||
#ifdef __cplusplus
|
||||
#define MYSQL_PLUGIN_EXPORT extern "C"
|
||||
#else
|
||||
#define MYSQL_PLUGIN_EXPORT
|
||||
#endif
|
||||
#endif /*MYSQL_DYNAMIC_PLUGIN */
|
||||
#else /*_MSC_VER */
|
||||
#define MYSQL_PLUGIN_EXPORT
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
class THD;
|
||||
class Item;
|
||||
#define MYSQL_THD THD*
|
||||
#else
|
||||
#define MYSQL_THD void*
|
||||
#endif
|
||||
|
||||
typedef void * MYSQL_PLUGIN;
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <mysql/services.h>
|
||||
#endif
|
||||
|
||||
#define MYSQL_XIDDATASIZE 128
|
||||
/**
|
||||
struct st_mysql_xid is binary compatible with the XID structure as
|
||||
in the X/Open CAE Specification, Distributed Transaction Processing:
|
||||
The XA Specification, X/Open Company Ltd., 1991.
|
||||
http://www.opengroup.org/bookstore/catalog/c193.htm
|
||||
|
||||
@see XID in sql/handler.h
|
||||
*/
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
long bqual_length;
|
||||
char data[MYSQL_XIDDATASIZE]; /* Not \0-terminated */
|
||||
};
|
||||
typedef struct st_mysql_xid MYSQL_XID;
|
||||
|
||||
/*************************************************************************
|
||||
Plugin API. Common for all plugin types.
|
||||
*/
|
||||
|
||||
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0107
|
||||
|
||||
/*
|
||||
The allowable types of plugins
|
||||
*/
|
||||
#define MYSQL_UDF_PLUGIN 0 /* User-defined function */
|
||||
#define MYSQL_STORAGE_ENGINE_PLUGIN 1 /* Storage Engine */
|
||||
#define MYSQL_FTPARSER_PLUGIN 2 /* Full-text parser plugin */
|
||||
#define MYSQL_DAEMON_PLUGIN 3 /* The daemon/raw plugin type */
|
||||
#define MYSQL_INFORMATION_SCHEMA_PLUGIN 4 /* The I_S plugin type */
|
||||
#define MYSQL_AUDIT_PLUGIN 5 /* The Audit plugin type */
|
||||
#define MYSQL_REPLICATION_PLUGIN 6 /* The replication plugin type */
|
||||
#define MYSQL_AUTHENTICATION_PLUGIN 7 /* The authentication plugin type */
|
||||
#define MYSQL_VALIDATE_PASSWORD_PLUGIN 8 /* validate password plugin type */
|
||||
#define MYSQL_GROUP_REPLICATION_PLUGIN 9 /* The Group Replication plugin */
|
||||
#define MYSQL_KEYRING_PLUGIN 10 /* The Keyring plugin type */
|
||||
#define MYSQL_MAX_PLUGIN_TYPE_NUM 11 /* The number of plugin types */
|
||||
|
||||
/* We use the following strings to define licenses for plugins */
|
||||
#define PLUGIN_LICENSE_PROPRIETARY 0
|
||||
#define PLUGIN_LICENSE_GPL 1
|
||||
#define PLUGIN_LICENSE_BSD 2
|
||||
|
||||
#define PLUGIN_LICENSE_PROPRIETARY_STRING "PROPRIETARY"
|
||||
#define PLUGIN_LICENSE_GPL_STRING "GPL"
|
||||
#define PLUGIN_LICENSE_BSD_STRING "BSD"
|
||||
|
||||
/*
|
||||
Macros for beginning and ending plugin declarations. Between
|
||||
mysql_declare_plugin and mysql_declare_plugin_end there should
|
||||
be a st_mysql_plugin struct for each plugin to be declared.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MYSQL_DYNAMIC_PLUGIN
|
||||
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
|
||||
MYSQL_PLUGIN_EXPORT int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \
|
||||
MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_mysql_plugin); \
|
||||
MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[]= {
|
||||
#else
|
||||
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
|
||||
MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \
|
||||
MYSQL_PLUGIN_EXPORT int _mysql_sizeof_struct_st_plugin_= sizeof(struct st_mysql_plugin); \
|
||||
MYSQL_PLUGIN_EXPORT struct st_mysql_plugin _mysql_plugin_declarations_[]= {
|
||||
#endif
|
||||
|
||||
#define mysql_declare_plugin(NAME) \
|
||||
__MYSQL_DECLARE_PLUGIN(NAME, \
|
||||
builtin_ ## NAME ## _plugin_interface_version, \
|
||||
builtin_ ## NAME ## _sizeof_struct_st_plugin, \
|
||||
builtin_ ## NAME ## _plugin)
|
||||
|
||||
#define mysql_declare_plugin_end ,{0,0,0,0,0,0,0,0,0,0,0,0,0}}
|
||||
|
||||
/**
|
||||
Declarations for SHOW STATUS support in plugins
|
||||
*/
|
||||
enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL,
|
||||
SHOW_INT, ///< shown as _unsigned_ int
|
||||
SHOW_LONG, ///< shown as _unsigned_ long
|
||||
SHOW_LONGLONG, ///< shown as _unsigned_ longlong
|
||||
SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
#ifdef MYSQL_SERVER
|
||||
/*
|
||||
This include defines server-only values of the enum.
|
||||
Using them in plugins is not supported.
|
||||
*/
|
||||
#include "sql_plugin_enum.h"
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
Status variable scope.
|
||||
Only GLOBAL status variable scope is available in plugins.
|
||||
*/
|
||||
enum enum_mysql_show_scope
|
||||
{
|
||||
SHOW_SCOPE_UNDEF,
|
||||
SHOW_SCOPE_GLOBAL
|
||||
#ifdef MYSQL_SERVER
|
||||
/* Server-only values. Not supported in plugins. */
|
||||
,
|
||||
SHOW_SCOPE_SESSION,
|
||||
SHOW_SCOPE_ALL
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
SHOW STATUS Server status variable
|
||||
*/
|
||||
struct st_mysql_show_var
|
||||
{
|
||||
const char *name;
|
||||
char *value;
|
||||
enum enum_mysql_show_type type;
|
||||
enum enum_mysql_show_scope scope;
|
||||
};
|
||||
|
||||
#define SHOW_VAR_MAX_NAME_LEN 64
|
||||
#define SHOW_VAR_FUNC_BUFF_SIZE 1024
|
||||
typedef int (*mysql_show_var_func)(MYSQL_THD, struct st_mysql_show_var*, char *);
|
||||
|
||||
|
||||
/*
|
||||
Constants for plugin flags.
|
||||
*/
|
||||
|
||||
#define PLUGIN_OPT_NO_INSTALL 1UL /* Not dynamically loadable */
|
||||
#define PLUGIN_OPT_NO_UNINSTALL 2UL /* Not dynamically unloadable */
|
||||
|
||||
|
||||
/*
|
||||
declarations for server variables and command line options
|
||||
*/
|
||||
|
||||
|
||||
#define PLUGIN_VAR_BOOL 0x0001
|
||||
#define PLUGIN_VAR_INT 0x0002
|
||||
#define PLUGIN_VAR_LONG 0x0003
|
||||
#define PLUGIN_VAR_LONGLONG 0x0004
|
||||
#define PLUGIN_VAR_STR 0x0005
|
||||
#define PLUGIN_VAR_ENUM 0x0006
|
||||
#define PLUGIN_VAR_SET 0x0007
|
||||
#define PLUGIN_VAR_DOUBLE 0x0008
|
||||
#define PLUGIN_VAR_UNSIGNED 0x0080
|
||||
#define PLUGIN_VAR_THDLOCAL 0x0100 /* Variable is per-connection */
|
||||
#define PLUGIN_VAR_READONLY 0x0200 /* Server variable is read only */
|
||||
#define PLUGIN_VAR_NOSYSVAR 0x0400 /* Not a server variable */
|
||||
#define PLUGIN_VAR_NOCMDOPT 0x0800 /* Not a command line option */
|
||||
#define PLUGIN_VAR_NOCMDARG 0x1000 /* No argument for cmd line */
|
||||
#define PLUGIN_VAR_RQCMDARG 0x0000 /* Argument required for cmd line */
|
||||
#define PLUGIN_VAR_OPCMDARG 0x2000 /* Argument optional for cmd line */
|
||||
#define PLUGIN_VAR_NODEFAULT 0x4000 /* SET DEFAULT is prohibited */
|
||||
#define PLUGIN_VAR_MEMALLOC 0x8000 /* String needs memory allocated */
|
||||
#define PLUGIN_VAR_INVISIBLE 0x10000 /* Variable should not be shown */
|
||||
|
||||
struct st_mysql_sys_var;
|
||||
struct st_mysql_value;
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
(*mysql_var_check_func)()
|
||||
thd thread handle
|
||||
var dynamic variable being altered
|
||||
save pointer to temporary storage
|
||||
value user provided value
|
||||
RETURN
|
||||
0 user provided value is OK and the update func may be called.
|
||||
any other value indicates error.
|
||||
|
||||
This function should parse the user provided value and store in the
|
||||
provided temporary storage any data as required by the update func.
|
||||
There is sufficient space in the temporary storage to store a double.
|
||||
Note that the update func may not be called if any other error occurs
|
||||
so any memory allocated should be thread-local so that it may be freed
|
||||
automatically at the end of the statement.
|
||||
*/
|
||||
|
||||
typedef int (*mysql_var_check_func)(MYSQL_THD thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *save, struct st_mysql_value *value);
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
(*mysql_var_update_func)()
|
||||
thd thread handle
|
||||
var dynamic variable being altered
|
||||
var_ptr pointer to dynamic variable
|
||||
save pointer to temporary storage
|
||||
RETURN
|
||||
NONE
|
||||
|
||||
This function should use the validated value stored in the temporary store
|
||||
and persist it in the provided pointer to the dynamic variable.
|
||||
For example, strings may require memory to be allocated.
|
||||
*/
|
||||
typedef void (*mysql_var_update_func)(MYSQL_THD thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *var_ptr, const void *save);
|
||||
|
||||
|
||||
/* the following declarations are for internal use only */
|
||||
|
||||
|
||||
#define PLUGIN_VAR_MASK \
|
||||
(PLUGIN_VAR_READONLY | PLUGIN_VAR_NOSYSVAR | \
|
||||
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_NOCMDARG | \
|
||||
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_MEMALLOC | \
|
||||
PLUGIN_VAR_NODEFAULT | PLUGIN_VAR_INVISIBLE)
|
||||
|
||||
#define MYSQL_PLUGIN_VAR_HEADER \
|
||||
int flags; \
|
||||
const char *name; \
|
||||
const char *comment; \
|
||||
mysql_var_check_func check; \
|
||||
mysql_var_update_func update
|
||||
|
||||
#define MYSQL_SYSVAR_NAME(name) mysql_sysvar_ ## name
|
||||
#define MYSQL_SYSVAR(name) \
|
||||
((struct st_mysql_sys_var *)&(MYSQL_SYSVAR_NAME(name)))
|
||||
|
||||
/*
|
||||
for global variables, the value pointer is the first
|
||||
element after the header, the default value is the second.
|
||||
for thread variables, the value offset is the first
|
||||
element after the header, the default value is the second.
|
||||
*/
|
||||
|
||||
|
||||
#define DECLARE_MYSQL_SYSVAR_BASIC(name, type) struct { \
|
||||
MYSQL_PLUGIN_VAR_HEADER; \
|
||||
type *value; \
|
||||
const type def_val; \
|
||||
} MYSQL_SYSVAR_NAME(name)
|
||||
|
||||
#define DECLARE_MYSQL_SYSVAR_SIMPLE(name, type) struct { \
|
||||
MYSQL_PLUGIN_VAR_HEADER; \
|
||||
type *value; type def_val; \
|
||||
type min_val; type max_val; \
|
||||
type blk_sz; \
|
||||
} MYSQL_SYSVAR_NAME(name)
|
||||
|
||||
#define DECLARE_MYSQL_SYSVAR_TYPELIB(name, type) struct { \
|
||||
MYSQL_PLUGIN_VAR_HEADER; \
|
||||
type *value; type def_val; \
|
||||
TYPELIB *typelib; \
|
||||
} MYSQL_SYSVAR_NAME(name)
|
||||
|
||||
#define DECLARE_THDVAR_FUNC(type) \
|
||||
type *(*resolve)(MYSQL_THD thd, int offset)
|
||||
|
||||
#define DECLARE_MYSQL_THDVAR_BASIC(name, type) struct { \
|
||||
MYSQL_PLUGIN_VAR_HEADER; \
|
||||
int offset; \
|
||||
const type def_val; \
|
||||
DECLARE_THDVAR_FUNC(type); \
|
||||
} MYSQL_SYSVAR_NAME(name)
|
||||
|
||||
#define DECLARE_MYSQL_THDVAR_SIMPLE(name, type) struct { \
|
||||
MYSQL_PLUGIN_VAR_HEADER; \
|
||||
int offset; \
|
||||
type def_val; type min_val; \
|
||||
type max_val; type blk_sz; \
|
||||
DECLARE_THDVAR_FUNC(type); \
|
||||
} MYSQL_SYSVAR_NAME(name)
|
||||
|
||||
#define DECLARE_MYSQL_THDVAR_TYPELIB(name, type) struct { \
|
||||
MYSQL_PLUGIN_VAR_HEADER; \
|
||||
int offset; \
|
||||
type def_val; \
|
||||
DECLARE_THDVAR_FUNC(type); \
|
||||
TYPELIB *typelib; \
|
||||
} MYSQL_SYSVAR_NAME(name)
|
||||
|
||||
|
||||
/*
|
||||
the following declarations are for use by plugin implementors
|
||||
*/
|
||||
|
||||
#define MYSQL_SYSVAR_BOOL(name, varname, opt, comment, check, update, def) \
|
||||
DECLARE_MYSQL_SYSVAR_BASIC(name, char) = { \
|
||||
PLUGIN_VAR_BOOL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def}
|
||||
|
||||
#define MYSQL_SYSVAR_STR(name, varname, opt, comment, check, update, def) \
|
||||
DECLARE_MYSQL_SYSVAR_BASIC(name, char *) = { \
|
||||
PLUGIN_VAR_STR | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def}
|
||||
|
||||
#define MYSQL_SYSVAR_INT(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, int) = { \
|
||||
PLUGIN_VAR_INT | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_SYSVAR_UINT(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned int) = { \
|
||||
PLUGIN_VAR_INT | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_SYSVAR_LONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long) = { \
|
||||
PLUGIN_VAR_LONG | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_SYSVAR_ULONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long) = { \
|
||||
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_SYSVAR_LONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, long long) = { \
|
||||
PLUGIN_VAR_LONGLONG | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_SYSVAR_ULONGLONG(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
|
||||
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
|
||||
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
|
||||
PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, typelib }
|
||||
|
||||
#define MYSQL_SYSVAR_SET(name, varname, opt, comment, check, update, def, typelib) \
|
||||
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long long) = { \
|
||||
PLUGIN_VAR_SET | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, typelib }
|
||||
|
||||
#define MYSQL_SYSVAR_DOUBLE(name, varname, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_SYSVAR_SIMPLE(name, double) = { \
|
||||
PLUGIN_VAR_DOUBLE | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, &varname, def, min, max, blk }
|
||||
|
||||
#define MYSQL_THDVAR_BOOL(name, opt, comment, check, update, def) \
|
||||
DECLARE_MYSQL_THDVAR_BASIC(name, char) = { \
|
||||
PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, NULL}
|
||||
|
||||
#define MYSQL_THDVAR_STR(name, opt, comment, check, update, def) \
|
||||
DECLARE_MYSQL_THDVAR_BASIC(name, char *) = { \
|
||||
PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, NULL}
|
||||
|
||||
#define MYSQL_THDVAR_INT(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, int) = { \
|
||||
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
#define MYSQL_THDVAR_UINT(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned int) = { \
|
||||
PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
#define MYSQL_THDVAR_LONG(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, long) = { \
|
||||
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
#define MYSQL_THDVAR_ULONG(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long) = { \
|
||||
PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
#define MYSQL_THDVAR_LONGLONG(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, long long) = { \
|
||||
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
#define MYSQL_THDVAR_ULONGLONG(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, unsigned long long) = { \
|
||||
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
#define MYSQL_THDVAR_ENUM(name, opt, comment, check, update, def, typelib) \
|
||||
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long) = { \
|
||||
PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, NULL, typelib }
|
||||
|
||||
#define MYSQL_THDVAR_SET(name, opt, comment, check, update, def, typelib) \
|
||||
DECLARE_MYSQL_THDVAR_TYPELIB(name, unsigned long long) = { \
|
||||
PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, NULL, typelib }
|
||||
|
||||
#define MYSQL_THDVAR_DOUBLE(name, opt, comment, check, update, def, min, max, blk) \
|
||||
DECLARE_MYSQL_THDVAR_SIMPLE(name, double) = { \
|
||||
PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL | ((opt) & PLUGIN_VAR_MASK), \
|
||||
#name, comment, check, update, -1, def, min, max, blk, NULL }
|
||||
|
||||
/* accessor macros */
|
||||
|
||||
#define SYSVAR(name) \
|
||||
(*(MYSQL_SYSVAR_NAME(name).value))
|
||||
|
||||
/* when thd == null, result points to global value */
|
||||
#define THDVAR(thd, name) \
|
||||
(*(MYSQL_SYSVAR_NAME(name).resolve(thd, MYSQL_SYSVAR_NAME(name).offset)))
|
||||
|
||||
|
||||
/*
|
||||
Plugin description structure.
|
||||
*/
|
||||
|
||||
struct st_mysql_plugin
|
||||
{
|
||||
int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */
|
||||
void *info; /* pointer to type-specific plugin descriptor */
|
||||
const char *name; /* plugin name */
|
||||
const char *author; /* plugin author (for I_S.PLUGINS) */
|
||||
const char *descr; /* general descriptive text (for I_S.PLUGINS) */
|
||||
int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
|
||||
int (*init)(MYSQL_PLUGIN); /* the function to invoke when plugin is loaded */
|
||||
int (*deinit)(MYSQL_PLUGIN);/* the function to invoke when plugin is unloaded */
|
||||
unsigned int version; /* plugin version (for I_S.PLUGINS) */
|
||||
struct st_mysql_show_var *status_vars;
|
||||
struct st_mysql_sys_var **system_vars;
|
||||
void * __reserved1; /* reserved for dependency checking */
|
||||
unsigned long flags; /* flags for plugin */
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
|
||||
*/
|
||||
#define MYSQL_FTPARSER_INTERFACE_VERSION 0x0101
|
||||
|
||||
/*************************************************************************
|
||||
API for Query Rewrite plugin. (MYSQL_QUERY_REWRITE_PLUGIN)
|
||||
*/
|
||||
|
||||
#define MYSQL_REWRITE_PRE_PARSE_INTERFACE_VERSION 0x0010
|
||||
#define MYSQL_REWRITE_POST_PARSE_INTERFACE_VERSION 0x0010
|
||||
|
||||
/*************************************************************************
|
||||
API for Storage Engine plugin. (MYSQL_DAEMON_PLUGIN)
|
||||
*/
|
||||
|
||||
/* handlertons of different MySQL releases are incompatible */
|
||||
#define MYSQL_DAEMON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
|
||||
|
||||
/*
|
||||
Here we define only the descriptor structure, that is referred from
|
||||
st_mysql_plugin.
|
||||
*/
|
||||
|
||||
struct st_mysql_daemon
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
API for I_S plugin. (MYSQL_INFORMATION_SCHEMA_PLUGIN)
|
||||
*/
|
||||
|
||||
/* handlertons of different MySQL releases are incompatible */
|
||||
#define MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
|
||||
|
||||
/*
|
||||
Here we define only the descriptor structure, that is referred from
|
||||
st_mysql_plugin.
|
||||
*/
|
||||
|
||||
struct st_mysql_information_schema
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
API for Storage Engine plugin. (MYSQL_STORAGE_ENGINE_PLUGIN)
|
||||
*/
|
||||
|
||||
/* handlertons of different MySQL releases are incompatible */
|
||||
#define MYSQL_HANDLERTON_INTERFACE_VERSION (MYSQL_VERSION_ID << 8)
|
||||
|
||||
/*
|
||||
The real API is in the sql/handler.h
|
||||
Here we define only the descriptor structure, that is referred from
|
||||
st_mysql_plugin.
|
||||
*/
|
||||
|
||||
struct st_mysql_storage_engine
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
|
||||
struct handlerton;
|
||||
|
||||
|
||||
/*
|
||||
API for Replication plugin. (MYSQL_REPLICATION_PLUGIN)
|
||||
*/
|
||||
#define MYSQL_REPLICATION_INTERFACE_VERSION 0x0400
|
||||
|
||||
/**
|
||||
Replication plugin descriptor
|
||||
*/
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
st_mysql_value struct for reading values from mysqld.
|
||||
Used by server variables framework to parse user-provided values.
|
||||
Will be used for arguments when implementing UDFs.
|
||||
|
||||
Note that val_str() returns a string in temporary memory
|
||||
that will be freed at the end of statement. Copy the string
|
||||
if you need it to persist.
|
||||
*/
|
||||
|
||||
#define MYSQL_VALUE_TYPE_STRING 0
|
||||
#define MYSQL_VALUE_TYPE_REAL 1
|
||||
#define MYSQL_VALUE_TYPE_INT 2
|
||||
|
||||
struct st_mysql_value
|
||||
{
|
||||
int (*value_type)(struct st_mysql_value *);
|
||||
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
|
||||
int (*val_real)(struct st_mysql_value *, double *realbuf);
|
||||
int (*val_int)(struct st_mysql_value *, long long *intbuf);
|
||||
int (*is_unsigned)(struct st_mysql_value *);
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
Miscellaneous functions for plugin implementors
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int thd_in_lock_tables(const MYSQL_THD thd);
|
||||
int thd_tablespace_op(const MYSQL_THD thd);
|
||||
long long thd_test_options(const MYSQL_THD thd, long long test_options);
|
||||
int thd_sql_command(const MYSQL_THD thd);
|
||||
const char *set_thd_proc_info(MYSQL_THD thd, const char *info,
|
||||
const char *calling_func,
|
||||
const char *calling_file,
|
||||
const unsigned int calling_line);
|
||||
void **thd_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
|
||||
void thd_storage_lock_wait(MYSQL_THD thd, long long value);
|
||||
int thd_tx_isolation(const MYSQL_THD thd);
|
||||
int thd_tx_is_read_only(const MYSQL_THD thd);
|
||||
MYSQL_THD thd_tx_arbitrate(MYSQL_THD requestor, MYSQL_THD holder);
|
||||
int thd_tx_priority(const MYSQL_THD thd);
|
||||
int thd_tx_is_dd_trx(const MYSQL_THD thd);
|
||||
char *thd_security_context(MYSQL_THD thd, char *buffer, size_t length,
|
||||
size_t max_query_len);
|
||||
/* Increments the row counter, see THD::row_count */
|
||||
void thd_inc_row_count(MYSQL_THD thd);
|
||||
int thd_allow_batch(MYSQL_THD thd);
|
||||
|
||||
|
||||
/**
|
||||
Mark transaction to rollback and mark error as fatal to a
|
||||
sub-statement if in sub statement mode.
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param all if all != 0, rollback the main transaction
|
||||
*/
|
||||
|
||||
void thd_mark_transaction_to_rollback(MYSQL_THD thd, int all);
|
||||
|
||||
/**
|
||||
Create a temporary file.
|
||||
|
||||
@details
|
||||
The temporary file is created in a location specified by the mysql
|
||||
server configuration (--tmpdir option). The caller does not need to
|
||||
delete the file, it will be deleted automatically.
|
||||
|
||||
@param prefix prefix for temporary file name
|
||||
@retval -1 error
|
||||
@retval >= 0 a file handle that can be passed to dup or my_close
|
||||
*/
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
|
||||
/**
|
||||
Check the killed state of a connection
|
||||
|
||||
@details
|
||||
In MySQL support for the KILL statement is cooperative. The KILL
|
||||
statement only sets a "killed" flag. This function returns the value
|
||||
of that flag. A thread should check it often, especially inside
|
||||
time-consuming loops, and gracefully abort the operation if it is
|
||||
non-zero.
|
||||
|
||||
@param thd user thread connection handle
|
||||
@retval 0 the connection is active
|
||||
@retval 1 the connection has been killed
|
||||
*/
|
||||
int thd_killed(const MYSQL_THD thd);
|
||||
|
||||
/**
|
||||
Set the killed status of the current statement.
|
||||
|
||||
@param thd user thread connection handle
|
||||
*/
|
||||
void thd_set_kill_status(const MYSQL_THD thd);
|
||||
|
||||
/**
|
||||
Get binary log position for latest written entry.
|
||||
|
||||
@note The file variable will be set to a buffer holding the name of
|
||||
the file name currently, but this can change if a rotation
|
||||
occur. Copy the string if you want to retain it.
|
||||
|
||||
@param thd Use thread connection handle
|
||||
@param file_var Pointer to variable that will hold the file name.
|
||||
@param pos_var Pointer to variable that will hold the file position.
|
||||
*/
|
||||
void thd_binlog_pos(const MYSQL_THD thd,
|
||||
const char **file_var,
|
||||
unsigned long long *pos_var);
|
||||
|
||||
/**
|
||||
Return the thread id of a user thread
|
||||
|
||||
@param thd user thread connection handle
|
||||
@return thread id
|
||||
*/
|
||||
unsigned long thd_get_thread_id(const MYSQL_THD thd);
|
||||
|
||||
/**
|
||||
Get the XID for this connection's transaction
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param xid location where identifier is stored
|
||||
*/
|
||||
void thd_get_xid(const MYSQL_THD thd, MYSQL_XID *xid);
|
||||
|
||||
/**
|
||||
Invalidate the query cache for a given table.
|
||||
|
||||
@param thd user thread connection handle
|
||||
@param key databasename/tablename in the canonical format.
|
||||
@param key_length length of key in bytes, including the PATH separator
|
||||
@param using_trx flag: TRUE if using transactions, FALSE otherwise
|
||||
*/
|
||||
void mysql_query_cache_invalidate4(MYSQL_THD thd,
|
||||
const char *key, unsigned int key_length,
|
||||
int using_trx);
|
||||
|
||||
|
||||
/**
|
||||
Provide a handler data getter to simplify coding
|
||||
*/
|
||||
void *thd_get_ha_data(const MYSQL_THD thd, const struct handlerton *hton);
|
||||
|
||||
|
||||
/**
|
||||
Provide a handler data setter to simplify coding
|
||||
|
||||
@details
|
||||
Set ha_data pointer (storage engine per-connection information).
|
||||
|
||||
To avoid unclean deactivation (uninstall) of storage engine plugin
|
||||
in the middle of transaction, additional storage engine plugin
|
||||
lock is acquired.
|
||||
|
||||
If ha_data is not null and storage engine plugin was not locked
|
||||
by thd_set_ha_data() in this connection before, storage engine
|
||||
plugin gets locked.
|
||||
|
||||
If ha_data is null and storage engine plugin was locked by
|
||||
thd_set_ha_data() in this connection before, storage engine
|
||||
plugin lock gets released.
|
||||
|
||||
If handlerton::close_connection() didn't reset ha_data, server does
|
||||
it immediately after calling handlerton::close_connection().
|
||||
*/
|
||||
void thd_set_ha_data(MYSQL_THD thd, const struct handlerton *hton,
|
||||
const void *ha_data);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _my_plugin_h */
|
||||
565
demo/kugou/include/Common/include/mysql/mysql/plugin_audit.h
Normal file
565
demo/kugou/include/Common/include/mysql/mysql/plugin_audit.h
Normal file
@@ -0,0 +1,565 @@
|
||||
/* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _my_audit_h
|
||||
#define _my_audit_h
|
||||
|
||||
#include "plugin.h"
|
||||
#include "mysql/mysql_lex_string.h"
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include "m_string.h"
|
||||
#endif
|
||||
#include "my_command.h"
|
||||
#include "my_sqlcommand.h"
|
||||
|
||||
#define MYSQL_AUDIT_INTERFACE_VERSION 0x0401
|
||||
|
||||
/**
|
||||
@enum mysql_event_class_t
|
||||
|
||||
Audit event classes.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_GENERAL_CLASS = 0,
|
||||
MYSQL_AUDIT_CONNECTION_CLASS = 1,
|
||||
MYSQL_AUDIT_PARSE_CLASS = 2,
|
||||
MYSQL_AUDIT_AUTHORIZATION_CLASS = 3,
|
||||
MYSQL_AUDIT_TABLE_ACCESS_CLASS = 4,
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_CLASS = 5,
|
||||
MYSQL_AUDIT_SERVER_STARTUP_CLASS = 6,
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS = 7,
|
||||
MYSQL_AUDIT_COMMAND_CLASS = 8,
|
||||
MYSQL_AUDIT_QUERY_CLASS = 9,
|
||||
MYSQL_AUDIT_STORED_PROGRAM_CLASS = 10,
|
||||
/* This item must be last in the list. */
|
||||
MYSQL_AUDIT_CLASS_MASK_SIZE
|
||||
} mysql_event_class_t;
|
||||
|
||||
/**
|
||||
@struct st_mysql_audit
|
||||
|
||||
The descriptor structure that is referred from st_mysql_plugin.
|
||||
*/
|
||||
struct st_mysql_audit
|
||||
{
|
||||
/**
|
||||
Interface version.
|
||||
*/
|
||||
int interface_version;
|
||||
|
||||
/**
|
||||
Event occurs when the event class consumer is to be
|
||||
disassociated from the specified THD.This would typically occur
|
||||
before some operation which may require sleeping - such as when
|
||||
waiting for the next query from the client.
|
||||
*/
|
||||
void (*release_thd)(MYSQL_THD);
|
||||
|
||||
/**
|
||||
Invoked whenever an event occurs which is of any
|
||||
class for which the plugin has interest.The second argument
|
||||
indicates the specific event class and the third argument is data
|
||||
as required for that class.
|
||||
*/
|
||||
int (*event_notify)(MYSQL_THD, mysql_event_class_t, const void *);
|
||||
|
||||
/**
|
||||
An array of bits used to indicate what event classes
|
||||
that this plugin wants to receive.
|
||||
*/
|
||||
unsigned long class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
|
||||
};
|
||||
|
||||
/**
|
||||
@typedef enum_sql_command_t
|
||||
|
||||
SQL command type definition.
|
||||
*/
|
||||
typedef enum enum_sql_command enum_sql_command_t;
|
||||
|
||||
/**
|
||||
@enum mysql_event_general_subclass_t
|
||||
|
||||
Events for the MYSQL_AUDIT_GENERAL_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** occurs before emitting to the general query log. */
|
||||
MYSQL_AUDIT_GENERAL_LOG = 1 << 0,
|
||||
/** occurs before transmitting errors to the user. */
|
||||
MYSQL_AUDIT_GENERAL_ERROR = 1 << 1,
|
||||
/** occurs after transmitting a resultset to the user. */
|
||||
MYSQL_AUDIT_GENERAL_RESULT = 1 << 2,
|
||||
/** occurs after transmitting a resultset or errors */
|
||||
MYSQL_AUDIT_GENERAL_STATUS = 1 << 3
|
||||
} mysql_event_general_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_GENERAL_ALL (MYSQL_AUDIT_GENERAL_LOG | \
|
||||
MYSQL_AUDIT_GENERAL_ERROR | \
|
||||
MYSQL_AUDIT_GENERAL_RESULT | \
|
||||
MYSQL_AUDIT_GENERAL_STATUS)
|
||||
/**
|
||||
@struct mysql_event_general
|
||||
|
||||
Structure for the MYSQL_AUDIT_GENERAL_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_general
|
||||
{
|
||||
mysql_event_general_subclass_t event_subclass;
|
||||
int general_error_code;
|
||||
unsigned long general_thread_id;
|
||||
MYSQL_LEX_CSTRING general_user;
|
||||
MYSQL_LEX_CSTRING general_command;
|
||||
MYSQL_LEX_CSTRING general_query;
|
||||
struct charset_info_st *general_charset;
|
||||
unsigned long long general_time;
|
||||
unsigned long long general_rows;
|
||||
MYSQL_LEX_CSTRING general_host;
|
||||
MYSQL_LEX_CSTRING general_sql_command;
|
||||
MYSQL_LEX_CSTRING general_external_user;
|
||||
MYSQL_LEX_CSTRING general_ip;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_connection_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_CONNECTION_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** occurs after authentication phase is completed. */
|
||||
MYSQL_AUDIT_CONNECTION_CONNECT = 1 << 0,
|
||||
/** occurs after connection is terminated. */
|
||||
MYSQL_AUDIT_CONNECTION_DISCONNECT = 1 << 1,
|
||||
/** occurs after COM_CHANGE_USER RPC is completed. */
|
||||
MYSQL_AUDIT_CONNECTION_CHANGE_USER = 1 << 2,
|
||||
/** occurs before authentication. */
|
||||
MYSQL_AUDIT_CONNECTION_PRE_AUTHENTICATE = 1 << 3
|
||||
} mysql_event_connection_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_CONNECTION_ALL (MYSQL_AUDIT_CONNECTION_CONNECT | \
|
||||
MYSQL_AUDIT_CONNECTION_DISCONNECT | \
|
||||
MYSQL_AUDIT_CONNECTION_CHANGE_USER | \
|
||||
MYSQL_AUDIT_CONNECTION_PRE_AUTHENTICATE)
|
||||
/**
|
||||
@struct mysql_event_connection
|
||||
|
||||
Structure for the MYSQL_AUDIT_CONNECTION_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_connection
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_connection_subclass_t event_subclass;
|
||||
/** Current status of the connection. */
|
||||
int status;
|
||||
/** Connection id. */
|
||||
unsigned long connection_id;
|
||||
/** User name of this connection. */
|
||||
MYSQL_LEX_CSTRING user;
|
||||
/** Priv user name. */
|
||||
MYSQL_LEX_CSTRING priv_user;
|
||||
/** External user name. */
|
||||
MYSQL_LEX_CSTRING external_user;
|
||||
/** Proxy user used for this connection. */
|
||||
MYSQL_LEX_CSTRING proxy_user;
|
||||
/** Connection host. */
|
||||
MYSQL_LEX_CSTRING host;
|
||||
/** IP of the connection. */
|
||||
MYSQL_LEX_CSTRING ip;
|
||||
/** Database name specified at connection time. */
|
||||
MYSQL_LEX_CSTRING database;
|
||||
/** Connection type:
|
||||
- 0 Undefined
|
||||
- 1 TCP/IP
|
||||
- 2 Socket
|
||||
- 3 Named pipe
|
||||
- 4 SSL
|
||||
- 5 Shared memory
|
||||
*/
|
||||
int connection_type;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_parse_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_PARSE_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** occurs before the query parsing. */
|
||||
MYSQL_AUDIT_PARSE_PREPARSE = 1 << 0,
|
||||
/** occurs after the query parsing. */
|
||||
MYSQL_AUDIT_PARSE_POSTPARSE = 1 << 1
|
||||
} mysql_event_parse_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_PARSE_ALL (MYSQL_AUDIT_PARSE_PREPARSE | \
|
||||
MYSQL_AUDIT_PARSE_POSTPARSE)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_PARSE_REWRITE_PLUGIN_NONE = 0,
|
||||
/// mysql_event_parse::flags Must be set by a plugin if the query is rewritten.
|
||||
MYSQL_AUDIT_PARSE_REWRITE_PLUGIN_QUERY_REWRITTEN = 1 << 0,
|
||||
/// mysql_event_parse::flags Is set by the server if the query is prepared statement.
|
||||
MYSQL_AUDIT_PARSE_REWRITE_PLUGIN_IS_PREPARED_STATEMENT = 1 << 1
|
||||
} mysql_event_parse_rewrite_plugin_flag;
|
||||
|
||||
/** Data for the MYSQL_AUDIT_PARSE events */
|
||||
struct mysql_event_parse
|
||||
{
|
||||
/** MYSQL_AUDIT_[PRE|POST]_PARSE event id */
|
||||
mysql_event_parse_subclass_t event_subclass;
|
||||
|
||||
/** one of FLAG_REWRITE_PLUGIN_* */
|
||||
mysql_event_parse_rewrite_plugin_flag *flags;
|
||||
|
||||
/** input: the original query text */
|
||||
MYSQL_LEX_CSTRING query;
|
||||
|
||||
/** output: returns the null-terminated rewriten query allocated by my_malloc() */
|
||||
MYSQL_LEX_CSTRING *rewritten_query;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_authorization_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_AUTHORIZATION_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_AUTHORIZATION_USER = 1 << 0,
|
||||
/** Occurs when database privilege is checked. */
|
||||
MYSQL_AUDIT_AUTHORIZATION_DB = 1 << 1,
|
||||
/** Occurs when table privilege is checked. */
|
||||
MYSQL_AUDIT_AUTHORIZATION_TABLE = 1 << 2,
|
||||
/** Occurs when column privilege is checked. */
|
||||
MYSQL_AUDIT_AUTHORIZATION_COLUMN = 1 << 3,
|
||||
/** Occurs when procedure privilege is checked. */
|
||||
MYSQL_AUDIT_AUTHORIZATION_PROCEDURE = 1 << 4,
|
||||
/** Occurs when proxy privilege is checked. */
|
||||
MYSQL_AUDIT_AUTHORIZATION_PROXY = 1 << 5
|
||||
} mysql_event_authorization_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_AUTHORIZATION_ALL (MYSQL_AUDIT_AUTHORIZATION_USER | \
|
||||
MYSQL_AUDIT_AUTHORIZATION_DB | \
|
||||
MYSQL_AUDIT_AUTHORIZATION_TABLE | \
|
||||
MYSQL_AUDIT_AUTHORIZATION_COLUMN | \
|
||||
MYSQL_AUDIT_AUTHORIZATION_PROCEDURE | \
|
||||
MYSQL_AUDIT_AUTHORIZATION_PROXY)
|
||||
/**
|
||||
@struct mysql_event_authorization
|
||||
|
||||
Structure for MYSQL_AUDIT_AUTHORIZATION_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_authorization
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_authorization_subclass_t event_subclass;
|
||||
/** Event status. */
|
||||
int status;
|
||||
/** Connection id. */
|
||||
unsigned int connection_id;
|
||||
/** SQL command id. */
|
||||
enum_sql_command_t sql_command_id;
|
||||
/** SQL query text. */
|
||||
MYSQL_LEX_CSTRING query;
|
||||
/** SQL query charset. */
|
||||
const struct charset_info_st *query_charset;
|
||||
/** Database name. */
|
||||
MYSQL_LEX_CSTRING database;
|
||||
/** Table name. */
|
||||
MYSQL_LEX_CSTRING table;
|
||||
/** Other name associated with the event. */
|
||||
MYSQL_LEX_CSTRING object;
|
||||
/** Requested authorization privileges. */
|
||||
unsigned long requested_privilege;
|
||||
/** Currently granted authorization privileges. */
|
||||
unsigned long granted_privilege;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_table_row_access_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_TABLE_ACCES_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Occurs when table data are read. */
|
||||
MYSQL_AUDIT_TABLE_ACCESS_READ = 1 << 0,
|
||||
/** Occurs when table data are inserted. */
|
||||
MYSQL_AUDIT_TABLE_ACCESS_INSERT = 1 << 1,
|
||||
/** Occurs when table data are updated. */
|
||||
MYSQL_AUDIT_TABLE_ACCESS_UPDATE = 1 << 2,
|
||||
/** Occurs when table data are deleted. */
|
||||
MYSQL_AUDIT_TABLE_ACCESS_DELETE = 1 << 3
|
||||
} mysql_event_table_access_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_TABLE_ACCESS_ALL (MYSQL_AUDIT_TABLE_ACCESS_READ | \
|
||||
MYSQL_AUDIT_TABLE_ACCESS_INSERT | \
|
||||
MYSQL_AUDIT_TABLE_ACCESS_UPDATE | \
|
||||
MYSQL_AUDIT_TABLE_ACCESS_DELETE)
|
||||
|
||||
/**
|
||||
@struct mysql_event_table_row_access
|
||||
|
||||
Structure for MYSQL_AUDIT_TABLE_ACCES_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_table_access
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_table_access_subclass_t event_subclass;
|
||||
/** Connection id. */
|
||||
unsigned long connection_id;
|
||||
/** SQL command id. */
|
||||
enum_sql_command_t sql_command_id;
|
||||
/** SQL query. */
|
||||
MYSQL_LEX_CSTRING query;
|
||||
/** SQL query charset. */
|
||||
const struct charset_info_st *query_charset;
|
||||
/** Database name. */
|
||||
MYSQL_LEX_CSTRING table_database;
|
||||
/** Table name. */
|
||||
MYSQL_LEX_CSTRING table_name;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_global_variable_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_GLOBAL_VARIABLE_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Occurs when global variable is retrieved. */
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_GET = 1 << 0,
|
||||
/** Occurs when global variable is set. */
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_SET = 1 << 1
|
||||
} mysql_event_global_variable_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_GLOBAL_VARIABLE_ALL (MYSQL_AUDIT_GLOBAL_VARIABLE_GET | \
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_SET)
|
||||
|
||||
/** Events for MYSQL_AUDIT_GLOBAL_VARIABLE_CLASS event class. */
|
||||
struct mysql_event_global_variable
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_global_variable_subclass_t event_subclass;
|
||||
/** Connection id. */
|
||||
unsigned long connection_id;
|
||||
/** SQL command id. */
|
||||
enum_sql_command_t sql_command_id;
|
||||
/** Variable name. */
|
||||
MYSQL_LEX_CSTRING variable_name;
|
||||
/** Variable value. */
|
||||
MYSQL_LEX_CSTRING variable_value;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_server_startup_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_SERVER_STARTUP_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Occurs after all subsystem are initialized during system start. */
|
||||
MYSQL_AUDIT_SERVER_STARTUP_STARTUP = 1 << 0
|
||||
} mysql_event_server_startup_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_SERVER_STARTUP_ALL (MYSQL_AUDIT_SERVER_STARTUP_STARTUP)
|
||||
|
||||
/**
|
||||
@struct mysql_event_server_startup
|
||||
|
||||
Structure for MYSQL_AUDIT_SERVER_STARTUP_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_server_startup
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_server_startup_subclass_t event_subclass;
|
||||
/** Command line arguments. */
|
||||
const char **argv;
|
||||
/** Command line arguments count. */
|
||||
unsigned int argc;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_server_shutdown_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Occurs when global variable is set. */
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_SHUTDOWN = 1 << 0
|
||||
} mysql_event_server_shutdown_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_SERVER_SHUTDOWN_ALL (MYSQL_AUDIT_SERVER_SHUTDOWN_SHUTDOWN)
|
||||
|
||||
/**
|
||||
@enum mysql_server_shutdown_reason_t
|
||||
|
||||
Server shutdown reason.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** User requested shut down. */
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_REASON_SHUTDOWN,
|
||||
/** The server aborts. */
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_REASON_ABORT
|
||||
} mysql_server_shutdown_reason_t;
|
||||
|
||||
/**
|
||||
@struct mysql_event_server_shutdown
|
||||
|
||||
Structure for MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_server_shutdown
|
||||
{
|
||||
/** Shutdown event. */
|
||||
mysql_event_server_shutdown_subclass_t event_subclass;
|
||||
/** Exit code associated with the shutdown event. */
|
||||
int exit_code;
|
||||
/** Shutdown reason. */
|
||||
mysql_server_shutdown_reason_t reason;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_command_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_COMMAND_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Command start event. */
|
||||
MYSQL_AUDIT_COMMAND_START = 1 << 0,
|
||||
/** Command end event. */
|
||||
MYSQL_AUDIT_COMMAND_END = 1 << 1
|
||||
} mysql_event_command_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_COMMAND_ALL (MYSQL_AUDIT_COMMAND_START | \
|
||||
MYSQL_AUDIT_COMMAND_END)
|
||||
/**
|
||||
@typedef enum_server_command_t
|
||||
|
||||
Server command type definition.
|
||||
*/
|
||||
typedef enum enum_server_command enum_server_command_t;
|
||||
|
||||
/**
|
||||
@struct mysql_event_command
|
||||
|
||||
Event for MYSQL_AUDIT_COMMAND_CLASS event class.
|
||||
Events generated as a result of RPC command requests.
|
||||
*/
|
||||
struct mysql_event_command
|
||||
{
|
||||
/** Command event subclass. */
|
||||
mysql_event_command_subclass_t event_subclass;
|
||||
/** Command event status. */
|
||||
int status;
|
||||
/** Connection id. */
|
||||
unsigned long connection_id;
|
||||
/** Command id. */
|
||||
enum_server_command_t command_id;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_query_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_QUERY_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Query start event. */
|
||||
MYSQL_AUDIT_QUERY_START = 1 << 0,
|
||||
/** Nested query start event. */
|
||||
MYSQL_AUDIT_QUERY_NESTED_START = 1 << 1,
|
||||
/** Query post parse event. */
|
||||
MYSQL_AUDIT_QUERY_STATUS_END = 1 << 2,
|
||||
/** Nested query status end event. */
|
||||
MYSQL_AUDIT_QUERY_NESTED_STATUS_END = 1 << 3
|
||||
} mysql_event_query_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_QUERY_ALL (MYSQL_AUDIT_QUERY_START | \
|
||||
MYSQL_AUDIT_QUERY_NESTED_START | \
|
||||
MYSQL_AUDIT_QUERY_STATUS_END | \
|
||||
MYSQL_AUDIT_QUERY_NESTED_STATUS_END)
|
||||
/**
|
||||
@struct mysql_event_command
|
||||
|
||||
Event for MYSQL_AUDIT_COMMAND_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_query
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_query_subclass_t event_subclass;
|
||||
/** Event status. */
|
||||
int status;
|
||||
/** Connection id. */
|
||||
unsigned long connection_id;
|
||||
/** SQL command id. */
|
||||
enum_sql_command_t sql_command_id;
|
||||
/** SQL query. */
|
||||
MYSQL_LEX_CSTRING query;
|
||||
/** SQL query charset. */
|
||||
const struct charset_info_st *query_charset;
|
||||
};
|
||||
|
||||
/**
|
||||
@enum mysql_event_stored_program_subclass_t
|
||||
|
||||
Events for MYSQL_AUDIT_STORED_PROGRAM_CLASS event class.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** Stored program execution event. */
|
||||
MYSQL_AUDIT_STORED_PROGRAM_EXECUTE = 1 << 0
|
||||
} mysql_event_stored_program_subclass_t;
|
||||
|
||||
#define MYSQL_AUDIT_STORED_PROGRAM_ALL (MYSQL_AUDIT_STORED_PROGRAM_EXECUTE)
|
||||
|
||||
/**
|
||||
@struct mysql_event_command
|
||||
|
||||
Event for MYSQL_AUDIT_COMMAND_CLASS event class.
|
||||
*/
|
||||
struct mysql_event_stored_program
|
||||
{
|
||||
/** Event subclass. */
|
||||
mysql_event_stored_program_subclass_t event_subclass;
|
||||
/** Connection id. */
|
||||
unsigned long connection_id;
|
||||
/** SQL command id. */
|
||||
enum_sql_command_t sql_command_id;
|
||||
/** SQL query text. */
|
||||
MYSQL_LEX_CSTRING query;
|
||||
/** SQL query charset. */
|
||||
const struct charset_info_st *query_charset;
|
||||
/** The Database the procedure is defined in. */
|
||||
MYSQL_LEX_CSTRING database;
|
||||
/** Name of the stored program. */
|
||||
MYSQL_LEX_CSTRING name;
|
||||
/** Stored program parameters. */
|
||||
void *parameters;
|
||||
};
|
||||
|
||||
#endif
|
||||
514
demo/kugou/include/Common/include/mysql/mysql/plugin_audit.h.pp
Normal file
514
demo/kugou/include/Common/include/mysql/mysql/plugin_audit.h.pp
Normal file
@@ -0,0 +1,514 @@
|
||||
#include "plugin.h"
|
||||
typedef void * MYSQL_PLUGIN;
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
long bqual_length;
|
||||
char data[128];
|
||||
};
|
||||
typedef struct st_mysql_xid MYSQL_XID;
|
||||
enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL,
|
||||
SHOW_INT,
|
||||
SHOW_LONG,
|
||||
SHOW_LONGLONG,
|
||||
SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
};
|
||||
enum enum_mysql_show_scope
|
||||
{
|
||||
SHOW_SCOPE_UNDEF,
|
||||
SHOW_SCOPE_GLOBAL
|
||||
};
|
||||
struct st_mysql_show_var
|
||||
{
|
||||
const char *name;
|
||||
char *value;
|
||||
enum enum_mysql_show_type type;
|
||||
enum enum_mysql_show_scope scope;
|
||||
};
|
||||
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, char *);
|
||||
struct st_mysql_sys_var;
|
||||
struct st_mysql_value;
|
||||
typedef int (*mysql_var_check_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *save, struct st_mysql_value *value);
|
||||
typedef void (*mysql_var_update_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *var_ptr, const void *save);
|
||||
struct st_mysql_plugin
|
||||
{
|
||||
int type;
|
||||
void *info;
|
||||
const char *name;
|
||||
const char *author;
|
||||
const char *descr;
|
||||
int license;
|
||||
int (*init)(MYSQL_PLUGIN);
|
||||
int (*deinit)(MYSQL_PLUGIN);
|
||||
unsigned int version;
|
||||
struct st_mysql_show_var *status_vars;
|
||||
struct st_mysql_sys_var **system_vars;
|
||||
void * __reserved1;
|
||||
unsigned long flags;
|
||||
};
|
||||
struct st_mysql_daemon
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_information_schema
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_storage_engine
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct handlerton;
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_value
|
||||
{
|
||||
int (*value_type)(struct st_mysql_value *);
|
||||
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
|
||||
int (*val_real)(struct st_mysql_value *, double *realbuf);
|
||||
int (*val_int)(struct st_mysql_value *, long long *intbuf);
|
||||
int (*is_unsigned)(struct st_mysql_value *);
|
||||
};
|
||||
int thd_in_lock_tables(const void* thd);
|
||||
int thd_tablespace_op(const void* thd);
|
||||
long long thd_test_options(const void* thd, long long test_options);
|
||||
int thd_sql_command(const void* thd);
|
||||
const char *set_thd_proc_info(void* thd, const char *info,
|
||||
const char *calling_func,
|
||||
const char *calling_file,
|
||||
const unsigned int calling_line);
|
||||
void **thd_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_storage_lock_wait(void* thd, long long value);
|
||||
int thd_tx_isolation(const void* thd);
|
||||
int thd_tx_is_read_only(const void* thd);
|
||||
void* thd_tx_arbitrate(void* requestor, void* holder);
|
||||
int thd_tx_priority(const void* thd);
|
||||
int thd_tx_is_dd_trx(const void* thd);
|
||||
char *thd_security_context(void* thd, char *buffer, size_t length,
|
||||
size_t max_query_len);
|
||||
void thd_inc_row_count(void* thd);
|
||||
int thd_allow_batch(void* thd);
|
||||
void thd_mark_transaction_to_rollback(void* thd, int all);
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
int thd_killed(const void* thd);
|
||||
void thd_set_kill_status(const void* thd);
|
||||
void thd_binlog_pos(const void* thd,
|
||||
const char **file_var,
|
||||
unsigned long long *pos_var);
|
||||
unsigned long thd_get_thread_id(const void* thd);
|
||||
void thd_get_xid(const void* thd, MYSQL_XID *xid);
|
||||
void mysql_query_cache_invalidate4(void* thd,
|
||||
const char *key, unsigned int key_length,
|
||||
int using_trx);
|
||||
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_set_ha_data(void* thd, const struct handlerton *hton,
|
||||
const void *ha_data);
|
||||
#include "mysql/mysql_lex_string.h"
|
||||
struct st_mysql_lex_string
|
||||
{
|
||||
char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
|
||||
struct st_mysql_const_lex_string
|
||||
{
|
||||
const char *str;
|
||||
size_t length;
|
||||
};
|
||||
typedef struct st_mysql_const_lex_string MYSQL_LEX_CSTRING;
|
||||
#include "my_command.h"
|
||||
enum enum_server_command
|
||||
{
|
||||
COM_SLEEP,
|
||||
COM_QUIT,
|
||||
COM_INIT_DB,
|
||||
COM_QUERY,
|
||||
COM_FIELD_LIST,
|
||||
COM_CREATE_DB,
|
||||
COM_DROP_DB,
|
||||
COM_REFRESH,
|
||||
COM_SHUTDOWN,
|
||||
COM_STATISTICS,
|
||||
COM_PROCESS_INFO,
|
||||
COM_CONNECT,
|
||||
COM_PROCESS_KILL,
|
||||
COM_DEBUG,
|
||||
COM_PING,
|
||||
COM_TIME,
|
||||
COM_DELAYED_INSERT,
|
||||
COM_CHANGE_USER,
|
||||
COM_BINLOG_DUMP,
|
||||
COM_TABLE_DUMP,
|
||||
COM_CONNECT_OUT,
|
||||
COM_REGISTER_SLAVE,
|
||||
COM_STMT_PREPARE,
|
||||
COM_STMT_EXECUTE,
|
||||
COM_STMT_SEND_LONG_DATA,
|
||||
COM_STMT_CLOSE,
|
||||
COM_STMT_RESET,
|
||||
COM_SET_OPTION,
|
||||
COM_STMT_FETCH,
|
||||
COM_DAEMON,
|
||||
COM_BINLOG_DUMP_GTID,
|
||||
COM_RESET_CONNECTION,
|
||||
COM_END
|
||||
};
|
||||
#include "my_sqlcommand.h"
|
||||
enum enum_sql_command {
|
||||
SQLCOM_SELECT,
|
||||
SQLCOM_CREATE_TABLE,
|
||||
SQLCOM_CREATE_INDEX,
|
||||
SQLCOM_ALTER_TABLE,
|
||||
SQLCOM_UPDATE,
|
||||
SQLCOM_INSERT,
|
||||
SQLCOM_INSERT_SELECT,
|
||||
SQLCOM_DELETE,
|
||||
SQLCOM_TRUNCATE,
|
||||
SQLCOM_DROP_TABLE,
|
||||
SQLCOM_DROP_INDEX,
|
||||
SQLCOM_SHOW_DATABASES,
|
||||
SQLCOM_SHOW_TABLES,
|
||||
SQLCOM_SHOW_FIELDS,
|
||||
SQLCOM_SHOW_KEYS,
|
||||
SQLCOM_SHOW_VARIABLES,
|
||||
SQLCOM_SHOW_STATUS,
|
||||
SQLCOM_SHOW_ENGINE_LOGS,
|
||||
SQLCOM_SHOW_ENGINE_STATUS,
|
||||
SQLCOM_SHOW_ENGINE_MUTEX,
|
||||
SQLCOM_SHOW_PROCESSLIST,
|
||||
SQLCOM_SHOW_MASTER_STAT,
|
||||
SQLCOM_SHOW_SLAVE_STAT,
|
||||
SQLCOM_SHOW_GRANTS,
|
||||
SQLCOM_SHOW_CREATE,
|
||||
SQLCOM_SHOW_CHARSETS,
|
||||
SQLCOM_SHOW_COLLATIONS,
|
||||
SQLCOM_SHOW_CREATE_DB,
|
||||
SQLCOM_SHOW_TABLE_STATUS,
|
||||
SQLCOM_SHOW_TRIGGERS,
|
||||
SQLCOM_LOAD,
|
||||
SQLCOM_SET_OPTION,
|
||||
SQLCOM_LOCK_TABLES,
|
||||
SQLCOM_UNLOCK_TABLES,
|
||||
SQLCOM_GRANT,
|
||||
SQLCOM_CHANGE_DB,
|
||||
SQLCOM_CREATE_DB,
|
||||
SQLCOM_DROP_DB,
|
||||
SQLCOM_ALTER_DB,
|
||||
SQLCOM_REPAIR,
|
||||
SQLCOM_REPLACE,
|
||||
SQLCOM_REPLACE_SELECT,
|
||||
SQLCOM_CREATE_FUNCTION,
|
||||
SQLCOM_DROP_FUNCTION,
|
||||
SQLCOM_REVOKE,
|
||||
SQLCOM_OPTIMIZE,
|
||||
SQLCOM_CHECK,
|
||||
SQLCOM_ASSIGN_TO_KEYCACHE,
|
||||
SQLCOM_PRELOAD_KEYS,
|
||||
SQLCOM_FLUSH,
|
||||
SQLCOM_KILL,
|
||||
SQLCOM_ANALYZE,
|
||||
SQLCOM_ROLLBACK,
|
||||
SQLCOM_ROLLBACK_TO_SAVEPOINT,
|
||||
SQLCOM_COMMIT,
|
||||
SQLCOM_SAVEPOINT,
|
||||
SQLCOM_RELEASE_SAVEPOINT,
|
||||
SQLCOM_SLAVE_START,
|
||||
SQLCOM_SLAVE_STOP,
|
||||
SQLCOM_START_GROUP_REPLICATION,
|
||||
SQLCOM_STOP_GROUP_REPLICATION,
|
||||
SQLCOM_BEGIN,
|
||||
SQLCOM_CHANGE_MASTER,
|
||||
SQLCOM_CHANGE_REPLICATION_FILTER,
|
||||
SQLCOM_RENAME_TABLE,
|
||||
SQLCOM_RESET,
|
||||
SQLCOM_PURGE,
|
||||
SQLCOM_PURGE_BEFORE,
|
||||
SQLCOM_SHOW_BINLOGS,
|
||||
SQLCOM_SHOW_OPEN_TABLES,
|
||||
SQLCOM_HA_OPEN,
|
||||
SQLCOM_HA_CLOSE,
|
||||
SQLCOM_HA_READ,
|
||||
SQLCOM_SHOW_SLAVE_HOSTS,
|
||||
SQLCOM_DELETE_MULTI,
|
||||
SQLCOM_UPDATE_MULTI,
|
||||
SQLCOM_SHOW_BINLOG_EVENTS,
|
||||
SQLCOM_DO,
|
||||
SQLCOM_SHOW_WARNS,
|
||||
SQLCOM_EMPTY_QUERY,
|
||||
SQLCOM_SHOW_ERRORS,
|
||||
SQLCOM_SHOW_STORAGE_ENGINES,
|
||||
SQLCOM_SHOW_PRIVILEGES,
|
||||
SQLCOM_HELP,
|
||||
SQLCOM_CREATE_USER,
|
||||
SQLCOM_DROP_USER,
|
||||
SQLCOM_RENAME_USER,
|
||||
SQLCOM_REVOKE_ALL,
|
||||
SQLCOM_CHECKSUM,
|
||||
SQLCOM_CREATE_PROCEDURE,
|
||||
SQLCOM_CREATE_SPFUNCTION,
|
||||
SQLCOM_CALL,
|
||||
SQLCOM_DROP_PROCEDURE,
|
||||
SQLCOM_ALTER_PROCEDURE,
|
||||
SQLCOM_ALTER_FUNCTION,
|
||||
SQLCOM_SHOW_CREATE_PROC,
|
||||
SQLCOM_SHOW_CREATE_FUNC,
|
||||
SQLCOM_SHOW_STATUS_PROC,
|
||||
SQLCOM_SHOW_STATUS_FUNC,
|
||||
SQLCOM_PREPARE,
|
||||
SQLCOM_EXECUTE,
|
||||
SQLCOM_DEALLOCATE_PREPARE,
|
||||
SQLCOM_CREATE_VIEW,
|
||||
SQLCOM_DROP_VIEW,
|
||||
SQLCOM_CREATE_TRIGGER,
|
||||
SQLCOM_DROP_TRIGGER,
|
||||
SQLCOM_XA_START,
|
||||
SQLCOM_XA_END,
|
||||
SQLCOM_XA_PREPARE,
|
||||
SQLCOM_XA_COMMIT,
|
||||
SQLCOM_XA_ROLLBACK,
|
||||
SQLCOM_XA_RECOVER,
|
||||
SQLCOM_SHOW_PROC_CODE,
|
||||
SQLCOM_SHOW_FUNC_CODE,
|
||||
SQLCOM_ALTER_TABLESPACE,
|
||||
SQLCOM_INSTALL_PLUGIN,
|
||||
SQLCOM_UNINSTALL_PLUGIN,
|
||||
SQLCOM_BINLOG_BASE64_EVENT,
|
||||
SQLCOM_SHOW_PLUGINS,
|
||||
SQLCOM_CREATE_SERVER,
|
||||
SQLCOM_DROP_SERVER,
|
||||
SQLCOM_ALTER_SERVER,
|
||||
SQLCOM_CREATE_EVENT,
|
||||
SQLCOM_ALTER_EVENT,
|
||||
SQLCOM_DROP_EVENT,
|
||||
SQLCOM_SHOW_CREATE_EVENT,
|
||||
SQLCOM_SHOW_EVENTS,
|
||||
SQLCOM_SHOW_CREATE_TRIGGER,
|
||||
SQLCOM_ALTER_DB_UPGRADE,
|
||||
SQLCOM_SHOW_PROFILE,
|
||||
SQLCOM_SHOW_PROFILES,
|
||||
SQLCOM_SIGNAL,
|
||||
SQLCOM_RESIGNAL,
|
||||
SQLCOM_SHOW_RELAYLOG_EVENTS,
|
||||
SQLCOM_GET_DIAGNOSTICS,
|
||||
SQLCOM_ALTER_USER,
|
||||
SQLCOM_EXPLAIN_OTHER,
|
||||
SQLCOM_SHOW_CREATE_USER,
|
||||
SQLCOM_SHUTDOWN,
|
||||
SQLCOM_ALTER_INSTANCE,
|
||||
SQLCOM_END
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_GENERAL_CLASS = 0,
|
||||
MYSQL_AUDIT_CONNECTION_CLASS = 1,
|
||||
MYSQL_AUDIT_PARSE_CLASS = 2,
|
||||
MYSQL_AUDIT_AUTHORIZATION_CLASS = 3,
|
||||
MYSQL_AUDIT_TABLE_ACCESS_CLASS = 4,
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_CLASS = 5,
|
||||
MYSQL_AUDIT_SERVER_STARTUP_CLASS = 6,
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_CLASS = 7,
|
||||
MYSQL_AUDIT_COMMAND_CLASS = 8,
|
||||
MYSQL_AUDIT_QUERY_CLASS = 9,
|
||||
MYSQL_AUDIT_STORED_PROGRAM_CLASS = 10,
|
||||
MYSQL_AUDIT_CLASS_MASK_SIZE
|
||||
} mysql_event_class_t;
|
||||
struct st_mysql_audit
|
||||
{
|
||||
int interface_version;
|
||||
void (*release_thd)(void*);
|
||||
int (*event_notify)(void*, mysql_event_class_t, const void *);
|
||||
unsigned long class_mask[MYSQL_AUDIT_CLASS_MASK_SIZE];
|
||||
};
|
||||
typedef enum enum_sql_command enum_sql_command_t;
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_GENERAL_LOG = 1 << 0,
|
||||
MYSQL_AUDIT_GENERAL_ERROR = 1 << 1,
|
||||
MYSQL_AUDIT_GENERAL_RESULT = 1 << 2,
|
||||
MYSQL_AUDIT_GENERAL_STATUS = 1 << 3
|
||||
} mysql_event_general_subclass_t;
|
||||
struct mysql_event_general
|
||||
{
|
||||
mysql_event_general_subclass_t event_subclass;
|
||||
int general_error_code;
|
||||
unsigned long general_thread_id;
|
||||
MYSQL_LEX_CSTRING general_user;
|
||||
MYSQL_LEX_CSTRING general_command;
|
||||
MYSQL_LEX_CSTRING general_query;
|
||||
struct charset_info_st *general_charset;
|
||||
unsigned long long general_time;
|
||||
unsigned long long general_rows;
|
||||
MYSQL_LEX_CSTRING general_host;
|
||||
MYSQL_LEX_CSTRING general_sql_command;
|
||||
MYSQL_LEX_CSTRING general_external_user;
|
||||
MYSQL_LEX_CSTRING general_ip;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_CONNECTION_CONNECT = 1 << 0,
|
||||
MYSQL_AUDIT_CONNECTION_DISCONNECT = 1 << 1,
|
||||
MYSQL_AUDIT_CONNECTION_CHANGE_USER = 1 << 2,
|
||||
MYSQL_AUDIT_CONNECTION_PRE_AUTHENTICATE = 1 << 3
|
||||
} mysql_event_connection_subclass_t;
|
||||
struct mysql_event_connection
|
||||
{
|
||||
mysql_event_connection_subclass_t event_subclass;
|
||||
int status;
|
||||
unsigned long connection_id;
|
||||
MYSQL_LEX_CSTRING user;
|
||||
MYSQL_LEX_CSTRING priv_user;
|
||||
MYSQL_LEX_CSTRING external_user;
|
||||
MYSQL_LEX_CSTRING proxy_user;
|
||||
MYSQL_LEX_CSTRING host;
|
||||
MYSQL_LEX_CSTRING ip;
|
||||
MYSQL_LEX_CSTRING database;
|
||||
int connection_type;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_PARSE_PREPARSE = 1 << 0,
|
||||
MYSQL_AUDIT_PARSE_POSTPARSE = 1 << 1
|
||||
} mysql_event_parse_subclass_t;
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_PARSE_REWRITE_PLUGIN_NONE = 0,
|
||||
MYSQL_AUDIT_PARSE_REWRITE_PLUGIN_QUERY_REWRITTEN = 1 << 0,
|
||||
MYSQL_AUDIT_PARSE_REWRITE_PLUGIN_IS_PREPARED_STATEMENT = 1 << 1
|
||||
} mysql_event_parse_rewrite_plugin_flag;
|
||||
struct mysql_event_parse
|
||||
{
|
||||
mysql_event_parse_subclass_t event_subclass;
|
||||
mysql_event_parse_rewrite_plugin_flag *flags;
|
||||
MYSQL_LEX_CSTRING query;
|
||||
MYSQL_LEX_CSTRING *rewritten_query;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_AUTHORIZATION_USER = 1 << 0,
|
||||
MYSQL_AUDIT_AUTHORIZATION_DB = 1 << 1,
|
||||
MYSQL_AUDIT_AUTHORIZATION_TABLE = 1 << 2,
|
||||
MYSQL_AUDIT_AUTHORIZATION_COLUMN = 1 << 3,
|
||||
MYSQL_AUDIT_AUTHORIZATION_PROCEDURE = 1 << 4,
|
||||
MYSQL_AUDIT_AUTHORIZATION_PROXY = 1 << 5
|
||||
} mysql_event_authorization_subclass_t;
|
||||
struct mysql_event_authorization
|
||||
{
|
||||
mysql_event_authorization_subclass_t event_subclass;
|
||||
int status;
|
||||
unsigned int connection_id;
|
||||
enum_sql_command_t sql_command_id;
|
||||
MYSQL_LEX_CSTRING query;
|
||||
const struct charset_info_st *query_charset;
|
||||
MYSQL_LEX_CSTRING database;
|
||||
MYSQL_LEX_CSTRING table;
|
||||
MYSQL_LEX_CSTRING object;
|
||||
unsigned long requested_privilege;
|
||||
unsigned long granted_privilege;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_TABLE_ACCESS_READ = 1 << 0,
|
||||
MYSQL_AUDIT_TABLE_ACCESS_INSERT = 1 << 1,
|
||||
MYSQL_AUDIT_TABLE_ACCESS_UPDATE = 1 << 2,
|
||||
MYSQL_AUDIT_TABLE_ACCESS_DELETE = 1 << 3
|
||||
} mysql_event_table_access_subclass_t;
|
||||
struct mysql_event_table_access
|
||||
{
|
||||
mysql_event_table_access_subclass_t event_subclass;
|
||||
unsigned long connection_id;
|
||||
enum_sql_command_t sql_command_id;
|
||||
MYSQL_LEX_CSTRING query;
|
||||
const struct charset_info_st *query_charset;
|
||||
MYSQL_LEX_CSTRING table_database;
|
||||
MYSQL_LEX_CSTRING table_name;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_GET = 1 << 0,
|
||||
MYSQL_AUDIT_GLOBAL_VARIABLE_SET = 1 << 1
|
||||
} mysql_event_global_variable_subclass_t;
|
||||
struct mysql_event_global_variable
|
||||
{
|
||||
mysql_event_global_variable_subclass_t event_subclass;
|
||||
unsigned long connection_id;
|
||||
enum_sql_command_t sql_command_id;
|
||||
MYSQL_LEX_CSTRING variable_name;
|
||||
MYSQL_LEX_CSTRING variable_value;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_SERVER_STARTUP_STARTUP = 1 << 0
|
||||
} mysql_event_server_startup_subclass_t;
|
||||
struct mysql_event_server_startup
|
||||
{
|
||||
mysql_event_server_startup_subclass_t event_subclass;
|
||||
const char **argv;
|
||||
unsigned int argc;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_SHUTDOWN = 1 << 0
|
||||
} mysql_event_server_shutdown_subclass_t;
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_REASON_SHUTDOWN,
|
||||
MYSQL_AUDIT_SERVER_SHUTDOWN_REASON_ABORT
|
||||
} mysql_server_shutdown_reason_t;
|
||||
struct mysql_event_server_shutdown
|
||||
{
|
||||
mysql_event_server_shutdown_subclass_t event_subclass;
|
||||
int exit_code;
|
||||
mysql_server_shutdown_reason_t reason;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_COMMAND_START = 1 << 0,
|
||||
MYSQL_AUDIT_COMMAND_END = 1 << 1
|
||||
} mysql_event_command_subclass_t;
|
||||
typedef enum enum_server_command enum_server_command_t;
|
||||
struct mysql_event_command
|
||||
{
|
||||
mysql_event_command_subclass_t event_subclass;
|
||||
int status;
|
||||
unsigned long connection_id;
|
||||
enum_server_command_t command_id;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_QUERY_START = 1 << 0,
|
||||
MYSQL_AUDIT_QUERY_NESTED_START = 1 << 1,
|
||||
MYSQL_AUDIT_QUERY_STATUS_END = 1 << 2,
|
||||
MYSQL_AUDIT_QUERY_NESTED_STATUS_END = 1 << 3
|
||||
} mysql_event_query_subclass_t;
|
||||
struct mysql_event_query
|
||||
{
|
||||
mysql_event_query_subclass_t event_subclass;
|
||||
int status;
|
||||
unsigned long connection_id;
|
||||
enum_sql_command_t sql_command_id;
|
||||
MYSQL_LEX_CSTRING query;
|
||||
const struct charset_info_st *query_charset;
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
MYSQL_AUDIT_STORED_PROGRAM_EXECUTE = 1 << 0
|
||||
} mysql_event_stored_program_subclass_t;
|
||||
struct mysql_event_stored_program
|
||||
{
|
||||
mysql_event_stored_program_subclass_t event_subclass;
|
||||
unsigned long connection_id;
|
||||
enum_sql_command_t sql_command_id;
|
||||
MYSQL_LEX_CSTRING query;
|
||||
const struct charset_info_st *query_charset;
|
||||
MYSQL_LEX_CSTRING database;
|
||||
MYSQL_LEX_CSTRING name;
|
||||
void *parameters;
|
||||
};
|
||||
185
demo/kugou/include/Common/include/mysql/mysql/plugin_auth.h
Normal file
185
demo/kugou/include/Common/include/mysql/mysql/plugin_auth.h
Normal file
@@ -0,0 +1,185 @@
|
||||
#ifndef MYSQL_PLUGIN_AUTH_INCLUDED
|
||||
/* Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
Authentication Plugin API.
|
||||
|
||||
This file defines the API for server authentication plugins.
|
||||
*/
|
||||
|
||||
#define MYSQL_PLUGIN_AUTH_INCLUDED
|
||||
|
||||
#include <mysql/plugin.h>
|
||||
|
||||
#define MYSQL_AUTHENTICATION_INTERFACE_VERSION 0x0101
|
||||
|
||||
#include "plugin_auth_common.h"
|
||||
|
||||
/* defines for MYSQL_SERVER_AUTH_INFO.password_used */
|
||||
|
||||
#define PASSWORD_USED_NO 0
|
||||
#define PASSWORD_USED_YES 1
|
||||
#define PASSWORD_USED_NO_MENTION 2
|
||||
|
||||
/* Authentication flags */
|
||||
|
||||
#define AUTH_FLAG_PRIVILEGED_USER_FOR_PASSWORD_CHANGE (1L << 0)
|
||||
#define AUTH_FLAG_USES_INTERNAL_STORAGE (1L << 1)
|
||||
|
||||
/**
|
||||
Provides server plugin access to authentication information
|
||||
*/
|
||||
typedef struct st_mysql_server_auth_info
|
||||
{
|
||||
/**
|
||||
User name as sent by the client and shown in USER().
|
||||
NULL if the client packet with the user name was not received yet.
|
||||
*/
|
||||
char *user_name;
|
||||
|
||||
/**
|
||||
Length of user_name
|
||||
*/
|
||||
unsigned int user_name_length;
|
||||
|
||||
/**
|
||||
A corresponding column value from the mysql.user table for the
|
||||
matching account name
|
||||
*/
|
||||
const char *auth_string;
|
||||
|
||||
/**
|
||||
Length of auth_string
|
||||
*/
|
||||
unsigned long auth_string_length;
|
||||
|
||||
/**
|
||||
Matching account name as found in the mysql.user table.
|
||||
A plugin can override it with another name that will be
|
||||
used by MySQL for authorization, and shown in CURRENT_USER()
|
||||
*/
|
||||
char authenticated_as[MYSQL_USERNAME_LENGTH+1];
|
||||
|
||||
|
||||
/**
|
||||
The unique user name that was used by the plugin to authenticate.
|
||||
Plugins should put null-terminated UTF-8 here.
|
||||
Available through the @@EXTERNAL_USER variable.
|
||||
*/
|
||||
char external_user[512];
|
||||
|
||||
/**
|
||||
This only affects the "Authentication failed. Password used: %s"
|
||||
error message. has the following values :
|
||||
0 : %s will be NO.
|
||||
1 : %s will be YES.
|
||||
2 : there will be no %s.
|
||||
Set it as appropriate or ignore at will.
|
||||
*/
|
||||
int password_used;
|
||||
|
||||
/**
|
||||
Set to the name of the connected client host, if it can be resolved,
|
||||
or to its IP address otherwise.
|
||||
*/
|
||||
const char *host_or_ip;
|
||||
|
||||
/**
|
||||
Length of host_or_ip
|
||||
*/
|
||||
unsigned int host_or_ip_length;
|
||||
|
||||
} MYSQL_SERVER_AUTH_INFO;
|
||||
|
||||
/**
|
||||
Server authentication plugin descriptor
|
||||
*/
|
||||
struct st_mysql_auth
|
||||
{
|
||||
int interface_version; /** version plugin uses */
|
||||
/**
|
||||
A plugin that a client must use for authentication with this server
|
||||
plugin. Can be NULL to mean "any plugin".
|
||||
*/
|
||||
const char *client_auth_plugin;
|
||||
/**
|
||||
Function provided by the plugin which should perform authentication (using
|
||||
the vio functions if necessary) and return 0 if successful. The plugin can
|
||||
also fill the info.authenticated_as field if a different username should be
|
||||
used for authorization.
|
||||
*/
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info);
|
||||
/**
|
||||
New plugin API to generate password digest out of authentication string.
|
||||
This function will first invoke a service to check for validity of the
|
||||
password based on the policies defined and then generate encrypted hash
|
||||
|
||||
@param[OUT] outbuf A buffer provided by server which will hold the
|
||||
authentication string generated by plugin.
|
||||
@param[INOUT] outbuflen Length of server provided buffer as IN param and
|
||||
length of plugin generated string as OUT param.
|
||||
@param[IN] inbuf auth string provided by user.
|
||||
@param[IN] inbuflen auth string length.
|
||||
|
||||
@retval 0 OK
|
||||
1 ERROR
|
||||
|
||||
*/
|
||||
int (*generate_authentication_string)(char *outbuf,
|
||||
unsigned int *outbuflen, const char *inbuf, unsigned int inbuflen);
|
||||
/**
|
||||
Plugin API to validate password digest.
|
||||
|
||||
@param[IN] inbuf hash string to be validated.
|
||||
@param[IN] buflen hash string length.
|
||||
|
||||
@retval 0 OK
|
||||
1 ERROR
|
||||
|
||||
*/
|
||||
int (*validate_authentication_string)(char* const inbuf, unsigned int buflen);
|
||||
/**
|
||||
Plugin API to convert scrambled password to binary form
|
||||
based on scramble type.
|
||||
|
||||
@param[IN] password The password hash containing the salt.
|
||||
@param[IN] password_len The length of the password hash.
|
||||
@param[INOUT] salt Used as password hash based on the
|
||||
authentication plugin.
|
||||
@param[INOUT] salt_len The length of salt.
|
||||
|
||||
@retval 0 OK
|
||||
1 ERROR
|
||||
|
||||
*/
|
||||
int (*set_salt)(const char *password, unsigned int password_len,
|
||||
unsigned char* salt, unsigned char *salt_len);
|
||||
/**
|
||||
Authentication plugin capabilities
|
||||
*/
|
||||
const unsigned long authentication_flags;
|
||||
};
|
||||
#endif
|
||||
|
||||
153
demo/kugou/include/Common/include/mysql/mysql/plugin_auth.h.pp
Normal file
153
demo/kugou/include/Common/include/mysql/mysql/plugin_auth.h.pp
Normal file
@@ -0,0 +1,153 @@
|
||||
#include <mysql/plugin.h>
|
||||
typedef void * MYSQL_PLUGIN;
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
long bqual_length;
|
||||
char data[128];
|
||||
};
|
||||
typedef struct st_mysql_xid MYSQL_XID;
|
||||
enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL,
|
||||
SHOW_INT,
|
||||
SHOW_LONG,
|
||||
SHOW_LONGLONG,
|
||||
SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
};
|
||||
enum enum_mysql_show_scope
|
||||
{
|
||||
SHOW_SCOPE_UNDEF,
|
||||
SHOW_SCOPE_GLOBAL
|
||||
};
|
||||
struct st_mysql_show_var
|
||||
{
|
||||
const char *name;
|
||||
char *value;
|
||||
enum enum_mysql_show_type type;
|
||||
enum enum_mysql_show_scope scope;
|
||||
};
|
||||
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, char *);
|
||||
struct st_mysql_sys_var;
|
||||
struct st_mysql_value;
|
||||
typedef int (*mysql_var_check_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *save, struct st_mysql_value *value);
|
||||
typedef void (*mysql_var_update_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *var_ptr, const void *save);
|
||||
struct st_mysql_plugin
|
||||
{
|
||||
int type;
|
||||
void *info;
|
||||
const char *name;
|
||||
const char *author;
|
||||
const char *descr;
|
||||
int license;
|
||||
int (*init)(MYSQL_PLUGIN);
|
||||
int (*deinit)(MYSQL_PLUGIN);
|
||||
unsigned int version;
|
||||
struct st_mysql_show_var *status_vars;
|
||||
struct st_mysql_sys_var **system_vars;
|
||||
void * __reserved1;
|
||||
unsigned long flags;
|
||||
};
|
||||
struct st_mysql_daemon
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_information_schema
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_storage_engine
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct handlerton;
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_value
|
||||
{
|
||||
int (*value_type)(struct st_mysql_value *);
|
||||
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
|
||||
int (*val_real)(struct st_mysql_value *, double *realbuf);
|
||||
int (*val_int)(struct st_mysql_value *, long long *intbuf);
|
||||
int (*is_unsigned)(struct st_mysql_value *);
|
||||
};
|
||||
int thd_in_lock_tables(const void* thd);
|
||||
int thd_tablespace_op(const void* thd);
|
||||
long long thd_test_options(const void* thd, long long test_options);
|
||||
int thd_sql_command(const void* thd);
|
||||
const char *set_thd_proc_info(void* thd, const char *info,
|
||||
const char *calling_func,
|
||||
const char *calling_file,
|
||||
const unsigned int calling_line);
|
||||
void **thd_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_storage_lock_wait(void* thd, long long value);
|
||||
int thd_tx_isolation(const void* thd);
|
||||
int thd_tx_is_read_only(const void* thd);
|
||||
void* thd_tx_arbitrate(void* requestor, void* holder);
|
||||
int thd_tx_priority(const void* thd);
|
||||
int thd_tx_is_dd_trx(const void* thd);
|
||||
char *thd_security_context(void* thd, char *buffer, size_t length,
|
||||
size_t max_query_len);
|
||||
void thd_inc_row_count(void* thd);
|
||||
int thd_allow_batch(void* thd);
|
||||
void thd_mark_transaction_to_rollback(void* thd, int all);
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
int thd_killed(const void* thd);
|
||||
void thd_set_kill_status(const void* thd);
|
||||
void thd_binlog_pos(const void* thd,
|
||||
const char **file_var,
|
||||
unsigned long long *pos_var);
|
||||
unsigned long thd_get_thread_id(const void* thd);
|
||||
void thd_get_xid(const void* thd, MYSQL_XID *xid);
|
||||
void mysql_query_cache_invalidate4(void* thd,
|
||||
const char *key, unsigned int key_length,
|
||||
int using_trx);
|
||||
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_set_ha_data(void* thd, const struct handlerton *hton,
|
||||
const void *ha_data);
|
||||
#include "plugin_auth_common.h"
|
||||
typedef struct st_plugin_vio_info
|
||||
{
|
||||
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
|
||||
MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
|
||||
int socket;
|
||||
} MYSQL_PLUGIN_VIO_INFO;
|
||||
typedef struct st_plugin_vio
|
||||
{
|
||||
int (*read_packet)(struct st_plugin_vio *vio,
|
||||
unsigned char **buf);
|
||||
int (*write_packet)(struct st_plugin_vio *vio,
|
||||
const unsigned char *packet,
|
||||
int packet_len);
|
||||
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
|
||||
} MYSQL_PLUGIN_VIO;
|
||||
typedef struct st_mysql_server_auth_info
|
||||
{
|
||||
char *user_name;
|
||||
unsigned int user_name_length;
|
||||
const char *auth_string;
|
||||
unsigned long auth_string_length;
|
||||
char authenticated_as[96 +1];
|
||||
char external_user[512];
|
||||
int password_used;
|
||||
const char *host_or_ip;
|
||||
unsigned int host_or_ip_length;
|
||||
} MYSQL_SERVER_AUTH_INFO;
|
||||
struct st_mysql_auth
|
||||
{
|
||||
int interface_version;
|
||||
const char *client_auth_plugin;
|
||||
int (*authenticate_user)(MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *info);
|
||||
int (*generate_authentication_string)(char *outbuf,
|
||||
unsigned int *outbuflen, const char *inbuf, unsigned int inbuflen);
|
||||
int (*validate_authentication_string)(char* const inbuf, unsigned int buflen);
|
||||
int (*set_salt)(const char *password, unsigned int password_len,
|
||||
unsigned char* salt, unsigned char *salt_len);
|
||||
const unsigned long authentication_flags;
|
||||
};
|
||||
@@ -0,0 +1,155 @@
|
||||
#ifndef MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
|
||||
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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.
|
||||
|
||||
Without limiting anything contained in the foregoing, this file,
|
||||
which is part of C Driver for MySQL (Connector/C), is also subject to the
|
||||
Universal FOSS Exception, version 1.0, a copy of which can be found at
|
||||
http://oss.oracle.com/licenses/universal-foss-exception.
|
||||
|
||||
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 */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
This file defines constants and data structures that are the same for
|
||||
both client- and server-side authentication plugins.
|
||||
*/
|
||||
#define MYSQL_PLUGIN_AUTH_COMMON_INCLUDED
|
||||
|
||||
/** the max allowed length for a user name */
|
||||
#define MYSQL_USERNAME_LENGTH 96
|
||||
|
||||
/**
|
||||
return values of the plugin authenticate_user() method.
|
||||
*/
|
||||
|
||||
/**
|
||||
Authentication failed, plugin internal error.
|
||||
An error occurred in the authentication plugin itself.
|
||||
These errors are reported in table performance_schema.host_cache,
|
||||
column COUNT_AUTH_PLUGIN_ERRORS.
|
||||
*/
|
||||
#define CR_AUTH_PLUGIN_ERROR 3
|
||||
/**
|
||||
Authentication failed, client server handshake.
|
||||
An error occurred during the client server handshake.
|
||||
These errors are reported in table performance_schema.host_cache,
|
||||
column COUNT_HANDSHAKE_ERRORS.
|
||||
*/
|
||||
#define CR_AUTH_HANDSHAKE 2
|
||||
/**
|
||||
Authentication failed, user credentials.
|
||||
For example, wrong passwords.
|
||||
These errors are reported in table performance_schema.host_cache,
|
||||
column COUNT_AUTHENTICATION_ERRORS.
|
||||
*/
|
||||
#define CR_AUTH_USER_CREDENTIALS 1
|
||||
/**
|
||||
Authentication failed. Additionally, all other CR_xxx values
|
||||
(libmysql error code) can be used too.
|
||||
|
||||
The client plugin may set the error code and the error message directly
|
||||
in the MYSQL structure and return CR_ERROR. If a CR_xxx specific error
|
||||
code was returned, an error message in the MYSQL structure will be
|
||||
overwritten. If CR_ERROR is returned without setting the error in MYSQL,
|
||||
CR_UNKNOWN_ERROR will be user.
|
||||
*/
|
||||
#define CR_ERROR 0
|
||||
/**
|
||||
Authentication (client part) was successful. It does not mean that the
|
||||
authentication as a whole was successful, usually it only means
|
||||
that the client was able to send the user name and the password to the
|
||||
server. If CR_OK is returned, the libmysql reads the next packet expecting
|
||||
it to be one of OK, ERROR, or CHANGE_PLUGIN packets.
|
||||
*/
|
||||
#define CR_OK -1
|
||||
/**
|
||||
Authentication was successful.
|
||||
It means that the client has done its part successfully and also that
|
||||
a plugin has read the last packet (one of OK, ERROR, CHANGE_PLUGIN).
|
||||
In this case, libmysql will not read a packet from the server,
|
||||
but it will use the data at mysql->net.read_pos.
|
||||
|
||||
A plugin may return this value if the number of roundtrips in the
|
||||
authentication protocol is not known in advance, and the client plugin
|
||||
needs to read one packet more to determine if the authentication is finished
|
||||
or not.
|
||||
*/
|
||||
#define CR_OK_HANDSHAKE_COMPLETE -2
|
||||
|
||||
/**
|
||||
Flag to be passed back to server from authentication plugins via
|
||||
authenticated_as when proxy mapping should be done by the server.
|
||||
*/
|
||||
#define PROXY_FLAG 0
|
||||
|
||||
/*
|
||||
We need HANDLE definition if on Windows. Define WIN32_LEAN_AND_MEAN (if
|
||||
not already done) to minimize amount of imported declarations.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
typedef struct st_plugin_vio_info
|
||||
{
|
||||
enum { MYSQL_VIO_INVALID, MYSQL_VIO_TCP, MYSQL_VIO_SOCKET,
|
||||
MYSQL_VIO_PIPE, MYSQL_VIO_MEMORY } protocol;
|
||||
int socket; /**< it's set, if the protocol is SOCKET or TCP */
|
||||
#ifdef _WIN32
|
||||
HANDLE handle; /**< it's set, if the protocol is PIPE or MEMORY */
|
||||
#endif
|
||||
} MYSQL_PLUGIN_VIO_INFO;
|
||||
|
||||
/**
|
||||
Provides plugin access to communication channel
|
||||
*/
|
||||
typedef struct st_plugin_vio
|
||||
{
|
||||
/**
|
||||
Plugin provides a pointer reference and this function sets it to the
|
||||
contents of any incoming packet. Returns the packet length, or -1 if
|
||||
the plugin should terminate.
|
||||
*/
|
||||
int (*read_packet)(struct st_plugin_vio *vio,
|
||||
unsigned char **buf);
|
||||
|
||||
/**
|
||||
Plugin provides a buffer with data and the length and this
|
||||
function sends it as a packet. Returns 0 on success, 1 on failure.
|
||||
*/
|
||||
int (*write_packet)(struct st_plugin_vio *vio,
|
||||
const unsigned char *packet,
|
||||
int packet_len);
|
||||
|
||||
/**
|
||||
Fills in a st_plugin_vio_info structure, providing the information
|
||||
about the connection.
|
||||
*/
|
||||
void (*info)(struct st_plugin_vio *vio, struct st_plugin_vio_info *info);
|
||||
|
||||
} MYSQL_PLUGIN_VIO;
|
||||
|
||||
#endif
|
||||
|
||||
221
demo/kugou/include/Common/include/mysql/mysql/plugin_ftparser.h
Normal file
221
demo/kugou/include/Common/include/mysql/mysql/plugin_ftparser.h
Normal file
@@ -0,0 +1,221 @@
|
||||
/* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef _my_plugin_ftparser_h
|
||||
#define _my_plugin_ftparser_h
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
/*************************************************************************
|
||||
API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
|
||||
*/
|
||||
|
||||
|
||||
/* Parsing modes. Set in MYSQL_FTPARSER_PARAM::mode */
|
||||
enum enum_ftparser_mode
|
||||
{
|
||||
/*
|
||||
Fast and simple mode. This mode is used for indexing, and natural
|
||||
language queries.
|
||||
|
||||
The parser is expected to return only those words that go into the
|
||||
index. Stopwords or too short/long words should not be returned. The
|
||||
'boolean_info' argument of mysql_add_word() does not have to be set.
|
||||
*/
|
||||
MYSQL_FTPARSER_SIMPLE_MODE= 0,
|
||||
|
||||
/*
|
||||
Parse with stopwords mode. This mode is used in boolean searches for
|
||||
"phrase matching."
|
||||
|
||||
The parser is not allowed to ignore words in this mode. Every word
|
||||
should be returned, including stopwords and words that are too short
|
||||
or long. The 'boolean_info' argument of mysql_add_word() does not
|
||||
have to be set.
|
||||
*/
|
||||
MYSQL_FTPARSER_WITH_STOPWORDS= 1,
|
||||
|
||||
/*
|
||||
Parse in boolean mode. This mode is used to parse a boolean query string.
|
||||
|
||||
The parser should provide a valid MYSQL_FTPARSER_BOOLEAN_INFO
|
||||
structure in the 'boolean_info' argument to mysql_add_word().
|
||||
Usually that means that the parser should recognize boolean operators
|
||||
in the parsing stream and set appropriate fields in
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO structure accordingly. As for
|
||||
MYSQL_FTPARSER_WITH_STOPWORDS mode, no word should be ignored.
|
||||
Instead, use FT_TOKEN_STOPWORD for the token type of such a word.
|
||||
*/
|
||||
MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
|
||||
};
|
||||
|
||||
/*
|
||||
Token types for boolean mode searching (used for the type member of
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO struct)
|
||||
|
||||
FT_TOKEN_EOF: End of data.
|
||||
FT_TOKEN_WORD: Regular word.
|
||||
FT_TOKEN_LEFT_PAREN: Left parenthesis (start of group/sub-expression).
|
||||
FT_TOKEN_RIGHT_PAREN: Right parenthesis (end of group/sub-expression).
|
||||
FT_TOKEN_STOPWORD: Stopword.
|
||||
*/
|
||||
|
||||
enum enum_ft_token_type
|
||||
{
|
||||
FT_TOKEN_EOF= 0,
|
||||
FT_TOKEN_WORD= 1,
|
||||
FT_TOKEN_LEFT_PAREN= 2,
|
||||
FT_TOKEN_RIGHT_PAREN= 3,
|
||||
FT_TOKEN_STOPWORD= 4
|
||||
};
|
||||
|
||||
/*
|
||||
This structure is used in boolean search mode only. It conveys
|
||||
boolean-mode metadata to the MySQL search engine for every word in
|
||||
the search query. A valid instance of this structure must be filled
|
||||
in by the plugin parser and passed as an argument in the call to
|
||||
mysql_add_word (the callback function in the MYSQL_FTPARSER_PARAM
|
||||
structure) when a query is parsed in boolean mode.
|
||||
|
||||
type: The token type. Should be one of the enum_ft_token_type values.
|
||||
|
||||
yesno: Whether the word must be present for a match to occur:
|
||||
>0 Must be present
|
||||
<0 Must not be present
|
||||
0 Neither; the word is optional but its presence increases the relevance
|
||||
With the default settings of the ft_boolean_syntax system variable,
|
||||
>0 corresponds to the '+' operator, <0 corrresponds to the '-' operator,
|
||||
and 0 means neither operator was used.
|
||||
|
||||
weight_adjust: A weighting factor that determines how much a match
|
||||
for the word counts. Positive values increase, negative - decrease the
|
||||
relative word's importance in the query.
|
||||
|
||||
wasign: The sign of the word's weight in the query. If it's non-negative
|
||||
the match for the word will increase document relevance, if it's
|
||||
negative - decrease (the word becomes a "noise word", the less of it the
|
||||
better).
|
||||
|
||||
trunc: Corresponds to the '*' operator in the default setting of the
|
||||
ft_boolean_syntax system variable.
|
||||
|
||||
position: Start position in bytes of the word in the document, used by InnoDB FTS.
|
||||
*/
|
||||
|
||||
typedef struct st_mysql_ftparser_boolean_info
|
||||
{
|
||||
enum enum_ft_token_type type;
|
||||
int yesno;
|
||||
int weight_adjust;
|
||||
char wasign;
|
||||
char trunc;
|
||||
int position;
|
||||
/* These are parser state and must be removed. */
|
||||
char prev;
|
||||
char *quot;
|
||||
} MYSQL_FTPARSER_BOOLEAN_INFO;
|
||||
|
||||
/*
|
||||
The following flag means that buffer with a string (document, word)
|
||||
may be overwritten by the caller before the end of the parsing (that is
|
||||
before st_mysql_ftparser::deinit() call). If one needs the string
|
||||
to survive between two successive calls of the parsing function, she
|
||||
needs to save a copy of it. The flag may be set by MySQL before calling
|
||||
st_mysql_ftparser::parse(), or it may be set by a plugin before calling
|
||||
st_mysql_ftparser_param::mysql_parse() or
|
||||
st_mysql_ftparser_param::mysql_add_word().
|
||||
*/
|
||||
#define MYSQL_FTFLAGS_NEED_COPY 1
|
||||
|
||||
/*
|
||||
An argument of the full-text parser plugin. This structure is
|
||||
filled in by MySQL server and passed to the parsing function of the
|
||||
plugin as an in/out parameter.
|
||||
|
||||
mysql_parse: A pointer to the built-in parser implementation of the
|
||||
server. It's set by the server and can be used by the parser plugin
|
||||
to invoke the MySQL default parser. If plugin's role is to extract
|
||||
textual data from .doc, .pdf or .xml content, it might extract
|
||||
plaintext from the content, and then pass the text to the default
|
||||
MySQL parser to be parsed.
|
||||
|
||||
mysql_add_word: A server callback to add a new word. When parsing
|
||||
a document, the server sets this to point at a function that adds
|
||||
the word to MySQL full-text index. When parsing a search query,
|
||||
this function will add the new word to the list of words to search
|
||||
for. The boolean_info argument can be NULL for all cases except
|
||||
when mode is MYSQL_FTPARSER_FULL_BOOLEAN_INFO.
|
||||
|
||||
ftparser_state: A generic pointer. The plugin can set it to point
|
||||
to information to be used internally for its own purposes.
|
||||
|
||||
mysql_ftparam: This is set by the server. It is used by MySQL functions
|
||||
called via mysql_parse() and mysql_add_word() callback. The plugin
|
||||
should not modify it.
|
||||
|
||||
cs: Information about the character set of the document or query string.
|
||||
|
||||
doc: A pointer to the document or query string to be parsed.
|
||||
|
||||
length: Length of the document or query string, in bytes.
|
||||
|
||||
flags: See MYSQL_FTFLAGS_* constants above.
|
||||
|
||||
mode: The parsing mode. With boolean operators, with stopwords, or
|
||||
nothing. See enum_ftparser_mode above.
|
||||
*/
|
||||
|
||||
typedef struct st_mysql_ftparser_param
|
||||
{
|
||||
int (*mysql_parse)(struct st_mysql_ftparser_param *,
|
||||
char *doc, int doc_len);
|
||||
int (*mysql_add_word)(struct st_mysql_ftparser_param *,
|
||||
char *word, int word_len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
|
||||
void *ftparser_state;
|
||||
void *mysql_ftparam;
|
||||
const struct charset_info_st *cs;
|
||||
char *doc;
|
||||
int length;
|
||||
int flags;
|
||||
enum enum_ftparser_mode mode;
|
||||
} MYSQL_FTPARSER_PARAM;
|
||||
|
||||
/*
|
||||
Full-text parser descriptor.
|
||||
|
||||
interface_version is, e.g., MYSQL_FTPARSER_INTERFACE_VERSION.
|
||||
The parsing, initialization, and deinitialization functions are
|
||||
invoked per SQL statement for which the parser is used.
|
||||
*/
|
||||
|
||||
struct st_mysql_ftparser
|
||||
{
|
||||
int interface_version;
|
||||
int (*parse)(MYSQL_FTPARSER_PARAM *param);
|
||||
int (*init)(MYSQL_FTPARSER_PARAM *param);
|
||||
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#include "plugin.h"
|
||||
typedef void * MYSQL_PLUGIN;
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
long bqual_length;
|
||||
char data[128];
|
||||
};
|
||||
typedef struct st_mysql_xid MYSQL_XID;
|
||||
enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL,
|
||||
SHOW_INT,
|
||||
SHOW_LONG,
|
||||
SHOW_LONGLONG,
|
||||
SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
};
|
||||
enum enum_mysql_show_scope
|
||||
{
|
||||
SHOW_SCOPE_UNDEF,
|
||||
SHOW_SCOPE_GLOBAL
|
||||
};
|
||||
struct st_mysql_show_var
|
||||
{
|
||||
const char *name;
|
||||
char *value;
|
||||
enum enum_mysql_show_type type;
|
||||
enum enum_mysql_show_scope scope;
|
||||
};
|
||||
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, char *);
|
||||
struct st_mysql_sys_var;
|
||||
struct st_mysql_value;
|
||||
typedef int (*mysql_var_check_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *save, struct st_mysql_value *value);
|
||||
typedef void (*mysql_var_update_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *var_ptr, const void *save);
|
||||
struct st_mysql_plugin
|
||||
{
|
||||
int type;
|
||||
void *info;
|
||||
const char *name;
|
||||
const char *author;
|
||||
const char *descr;
|
||||
int license;
|
||||
int (*init)(MYSQL_PLUGIN);
|
||||
int (*deinit)(MYSQL_PLUGIN);
|
||||
unsigned int version;
|
||||
struct st_mysql_show_var *status_vars;
|
||||
struct st_mysql_sys_var **system_vars;
|
||||
void * __reserved1;
|
||||
unsigned long flags;
|
||||
};
|
||||
struct st_mysql_daemon
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_information_schema
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_storage_engine
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct handlerton;
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_value
|
||||
{
|
||||
int (*value_type)(struct st_mysql_value *);
|
||||
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
|
||||
int (*val_real)(struct st_mysql_value *, double *realbuf);
|
||||
int (*val_int)(struct st_mysql_value *, long long *intbuf);
|
||||
int (*is_unsigned)(struct st_mysql_value *);
|
||||
};
|
||||
int thd_in_lock_tables(const void* thd);
|
||||
int thd_tablespace_op(const void* thd);
|
||||
long long thd_test_options(const void* thd, long long test_options);
|
||||
int thd_sql_command(const void* thd);
|
||||
const char *set_thd_proc_info(void* thd, const char *info,
|
||||
const char *calling_func,
|
||||
const char *calling_file,
|
||||
const unsigned int calling_line);
|
||||
void **thd_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_storage_lock_wait(void* thd, long long value);
|
||||
int thd_tx_isolation(const void* thd);
|
||||
int thd_tx_is_read_only(const void* thd);
|
||||
void* thd_tx_arbitrate(void* requestor, void* holder);
|
||||
int thd_tx_priority(const void* thd);
|
||||
int thd_tx_is_dd_trx(const void* thd);
|
||||
char *thd_security_context(void* thd, char *buffer, size_t length,
|
||||
size_t max_query_len);
|
||||
void thd_inc_row_count(void* thd);
|
||||
int thd_allow_batch(void* thd);
|
||||
void thd_mark_transaction_to_rollback(void* thd, int all);
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
int thd_killed(const void* thd);
|
||||
void thd_set_kill_status(const void* thd);
|
||||
void thd_binlog_pos(const void* thd,
|
||||
const char **file_var,
|
||||
unsigned long long *pos_var);
|
||||
unsigned long thd_get_thread_id(const void* thd);
|
||||
void thd_get_xid(const void* thd, MYSQL_XID *xid);
|
||||
void mysql_query_cache_invalidate4(void* thd,
|
||||
const char *key, unsigned int key_length,
|
||||
int using_trx);
|
||||
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_set_ha_data(void* thd, const struct handlerton *hton,
|
||||
const void *ha_data);
|
||||
enum enum_ftparser_mode
|
||||
{
|
||||
MYSQL_FTPARSER_SIMPLE_MODE= 0,
|
||||
MYSQL_FTPARSER_WITH_STOPWORDS= 1,
|
||||
MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
|
||||
};
|
||||
enum enum_ft_token_type
|
||||
{
|
||||
FT_TOKEN_EOF= 0,
|
||||
FT_TOKEN_WORD= 1,
|
||||
FT_TOKEN_LEFT_PAREN= 2,
|
||||
FT_TOKEN_RIGHT_PAREN= 3,
|
||||
FT_TOKEN_STOPWORD= 4
|
||||
};
|
||||
typedef struct st_mysql_ftparser_boolean_info
|
||||
{
|
||||
enum enum_ft_token_type type;
|
||||
int yesno;
|
||||
int weight_adjust;
|
||||
char wasign;
|
||||
char trunc;
|
||||
int position;
|
||||
char prev;
|
||||
char *quot;
|
||||
} MYSQL_FTPARSER_BOOLEAN_INFO;
|
||||
typedef struct st_mysql_ftparser_param
|
||||
{
|
||||
int (*mysql_parse)(struct st_mysql_ftparser_param *,
|
||||
char *doc, int doc_len);
|
||||
int (*mysql_add_word)(struct st_mysql_ftparser_param *,
|
||||
char *word, int word_len,
|
||||
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
|
||||
void *ftparser_state;
|
||||
void *mysql_ftparam;
|
||||
const struct charset_info_st *cs;
|
||||
char *doc;
|
||||
int length;
|
||||
int flags;
|
||||
enum enum_ftparser_mode mode;
|
||||
} MYSQL_FTPARSER_PARAM;
|
||||
struct st_mysql_ftparser
|
||||
{
|
||||
int interface_version;
|
||||
int (*parse)(MYSQL_FTPARSER_PARAM *param);
|
||||
int (*init)(MYSQL_FTPARSER_PARAM *param);
|
||||
int (*deinit)(MYSQL_FTPARSER_PARAM *param);
|
||||
};
|
||||
@@ -0,0 +1,159 @@
|
||||
/* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_PLUGIN_GROUP_REPLICATION_INCLUDED
|
||||
#define MYSQL_PLUGIN_GROUP_REPLICATION_INCLUDED
|
||||
|
||||
/* API for Group Peplication plugin. (MYSQL_GROUP_REPLICATION_PLUGIN) */
|
||||
|
||||
#include <mysql/plugin.h>
|
||||
#define MYSQL_GROUP_REPLICATION_INTERFACE_VERSION 0x0101
|
||||
|
||||
/*
|
||||
Callbacks for get_connection_status_info function.
|
||||
|
||||
context field can have NULL value, plugin will always pass it
|
||||
through all callbacks, independent of its value.
|
||||
Its value will not be used by plugin.
|
||||
|
||||
All callbacks are mandatory.
|
||||
*/
|
||||
typedef struct st_group_replication_connection_status_callbacks
|
||||
{
|
||||
void* const context;
|
||||
void (*set_channel_name)(void* const context, const char& value, size_t length);
|
||||
void (*set_group_name)(void* const context, const char& value, size_t length);
|
||||
void (*set_source_uuid)(void* const context, const char& value, size_t length);
|
||||
void (*set_service_state)(void* const context, bool state);
|
||||
} GROUP_REPLICATION_CONNECTION_STATUS_CALLBACKS;
|
||||
|
||||
/*
|
||||
Callbacks for get_group_members_info function.
|
||||
|
||||
context field can have NULL value, plugin will always pass it
|
||||
through all callbacks, independent of its value.
|
||||
Its value will not be used by plugin.
|
||||
|
||||
All callbacks are mandatory.
|
||||
*/
|
||||
typedef struct st_group_replication_group_members_callbacks
|
||||
{
|
||||
void* const context;
|
||||
void (*set_channel_name)(void* const context, const char& value, size_t length);
|
||||
void (*set_member_id)(void* const context, const char& value, size_t length);
|
||||
void (*set_member_host)(void* const context, const char& value, size_t length);
|
||||
void (*set_member_port)(void* const context, unsigned int value);
|
||||
void (*set_member_state)(void* const context, const char& value, size_t length);
|
||||
} GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS;
|
||||
|
||||
/*
|
||||
Callbacks for get_group_member_stats_info function.
|
||||
|
||||
context field can have NULL value, plugin will always pass it
|
||||
through all callbacks, independent of its value.
|
||||
Its value will not be used by plugin.
|
||||
|
||||
All callbacks are mandatory.
|
||||
*/
|
||||
typedef struct st_group_replication_member_stats_callbacks
|
||||
{
|
||||
void* const context;
|
||||
void (*set_channel_name)(void* const context, const char& value, size_t length);
|
||||
void (*set_view_id)(void* const context, const char& value, size_t length);
|
||||
void (*set_member_id)(void* const context, const char& value, size_t length);
|
||||
void (*set_transactions_committed)(void* const context, const char& value, size_t length);
|
||||
void (*set_last_conflict_free_transaction)(void* const context, const char& value, size_t length);
|
||||
void (*set_transactions_in_queue)(void* const context, unsigned long long int value);
|
||||
void (*set_transactions_certified)(void* const context, unsigned long long int value);
|
||||
void (*set_transactions_conflicts_detected)(void* const context, unsigned long long int value);
|
||||
void (*set_transactions_rows_in_validation)(void* const context, unsigned long long int value);
|
||||
} GROUP_REPLICATION_GROUP_MEMBER_STATS_CALLBACKS;
|
||||
|
||||
struct st_mysql_group_replication
|
||||
{
|
||||
int interface_version;
|
||||
|
||||
/*
|
||||
This function is used to start the group replication.
|
||||
*/
|
||||
int (*start)();
|
||||
/*
|
||||
This function is used to stop the group replication.
|
||||
*/
|
||||
int (*stop)();
|
||||
/*
|
||||
This function is used to get the current group replication running status.
|
||||
*/
|
||||
bool (*is_running)();
|
||||
/*
|
||||
This function initializes conflict checking module with info received
|
||||
from group on this member.
|
||||
|
||||
@param info View_change_log_event with conflict checking info.
|
||||
*/
|
||||
int (*set_retrieved_certification_info)(void* info);
|
||||
|
||||
/*
|
||||
This function is used to fetch information for group replication kernel stats.
|
||||
|
||||
@param callbacks The set of callbacks and its context used to set the
|
||||
information on caller.
|
||||
|
||||
@note The caller is responsible to free memory from the info structure and
|
||||
from all its fields.
|
||||
*/
|
||||
bool (*get_connection_status_info)
|
||||
(const GROUP_REPLICATION_CONNECTION_STATUS_CALLBACKS& callbacks);
|
||||
|
||||
/*
|
||||
This function is used to fetch information for group replication members.
|
||||
|
||||
@param callbacks The set of callbacks and its context used to set the
|
||||
information on caller.
|
||||
|
||||
@note The caller is responsible to free memory from the info structure and
|
||||
from all its fields.
|
||||
*/
|
||||
bool (*get_group_members_info)
|
||||
(unsigned int index,
|
||||
const GROUP_REPLICATION_GROUP_MEMBERS_CALLBACKS& callbacks);
|
||||
|
||||
/*
|
||||
This function is used to fetch information for group replication members statistics.
|
||||
|
||||
@param callbacks The set of callbacks and its context used to set the
|
||||
information on caller.
|
||||
|
||||
@note The caller is responsible to free memory from the info structure and
|
||||
from all its fields.
|
||||
*/
|
||||
bool (*get_group_member_stats_info)
|
||||
(const GROUP_REPLICATION_GROUP_MEMBER_STATS_CALLBACKS& callbacks);
|
||||
|
||||
/*
|
||||
Get number of group replication members.
|
||||
*/
|
||||
unsigned int (*get_members_number_info)();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
191
demo/kugou/include/Common/include/mysql/mysql/plugin_keyring.h
Normal file
191
demo/kugou/include/Common/include/mysql/mysql/plugin_keyring.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/* Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MYSQL_PLUGIN_KEYRING_INCLUDED
|
||||
#define MYSQL_PLUGIN_KEYRING_INCLUDED
|
||||
|
||||
/**
|
||||
API for keyring plugin. (MYSQL_KEYRING_PLUGIN)
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
#define MYSQL_KEYRING_INTERFACE_VERSION 0x0101
|
||||
|
||||
/**
|
||||
The descriptor structure for the plugin, that is referred from
|
||||
st_mysql_plugin.
|
||||
*/
|
||||
|
||||
struct st_mysql_keyring
|
||||
{
|
||||
int interface_version;
|
||||
/*!
|
||||
Add key to the keyring.
|
||||
|
||||
Obfuscates and adds the key to the keyring. The key is associated with
|
||||
key_id and user_id (unique key identifier).
|
||||
|
||||
@param[in] key_id id of the key to store
|
||||
@param[in] key_type type of the key to store
|
||||
@param[in] user_id id of the owner of the key
|
||||
@param[in] key the key itself to be stored. The memory of the key is
|
||||
copied by the keyring, thus the key itself can be freed
|
||||
after it was stored in the keyring.
|
||||
@param[in] key_len the length of the key to be stored
|
||||
|
||||
@return Operation status
|
||||
@retval 0 OK
|
||||
@retval 1 ERROR
|
||||
*/
|
||||
my_bool (*mysql_key_store)(const char *key_id, const char *key_type,
|
||||
const char* user_id, const void *key, size_t key_len);
|
||||
/*!
|
||||
Fetches key from the keyring.
|
||||
|
||||
De-obfuscates and retrieves key associated with key_id and user_id from the
|
||||
keyring.
|
||||
|
||||
@param[in] key_id id of the key to fetch
|
||||
@param[out] key_type type of the fetched key
|
||||
@param[in] user_id id of the owner of the key
|
||||
@param[out] key the fetched key itself. The memory for this key is
|
||||
allocated by the keyring and needs to be freed by the
|
||||
user when no longer needed. Prior to freeing the memory
|
||||
it needs to be obfuscated or zeroed.
|
||||
@param[out] key_len the length of the fetched key
|
||||
|
||||
@return Operation status
|
||||
@retval 0 OK
|
||||
@retval 1 ERROR
|
||||
*/
|
||||
my_bool (*mysql_key_fetch)(const char *key_id, char **key_type,
|
||||
const char *user_id, void **key, size_t *key_len);
|
||||
|
||||
/*!
|
||||
Removes key from the keyring.
|
||||
|
||||
Removes the key associated with key_id and user_id from the
|
||||
keyring.
|
||||
|
||||
@param[in] key_id id of the key to remove
|
||||
@param[in] user_id id of the owner of the key to remove
|
||||
|
||||
@return Operation status
|
||||
@retval 0 OK
|
||||
@retval 1 ERROR
|
||||
*/
|
||||
my_bool (*mysql_key_remove)(const char *key_id, const char *user_id);
|
||||
|
||||
/*!
|
||||
Generates and stores the key.
|
||||
|
||||
Generates a random key of length key_len, associates it with key_id, user_id
|
||||
and stores it in the keyring.
|
||||
|
||||
@param[in] key_id id of the key to generate
|
||||
@param[in] key_type type of the key to generate
|
||||
@param[in] user_id id of the owner of the generated key
|
||||
@param[in] key_len length of the key to generate
|
||||
|
||||
@return Operation status
|
||||
@retval 0 OK
|
||||
@retval 1 ERROR
|
||||
*/
|
||||
my_bool (*mysql_key_generate)(const char *key_id, const char *key_type,
|
||||
const char *user_id, size_t key_len);
|
||||
|
||||
/**
|
||||
Keys_iterator object refers to an iterator which is used to iterate
|
||||
on a list which refers to Key_metadata. Key_metadata hold information
|
||||
about individual keys keyd_id and user_id. Keys_iterator should be used
|
||||
in following sequence only.
|
||||
|
||||
void* iterator_ptr;
|
||||
char key_id[64]= { 0 };
|
||||
char user_id[64]= { 0 };
|
||||
|
||||
plugin_handle->mysql_key_iterator_init(&iterator_ptr);
|
||||
|
||||
if (iterator_ptr == NULL)
|
||||
report error;
|
||||
|
||||
while (!(plugin_handle->mysql_key_iterator_get_key(iterator_ptr,
|
||||
key_id, user_id)))
|
||||
{
|
||||
Fetch the keys.
|
||||
Perform operations on the fetched keys.
|
||||
..
|
||||
}
|
||||
plugin_handle->mysql_key_iterator_deinit(iterator_ptr);
|
||||
|
||||
init() method accepts a void pointer which is the made to point to
|
||||
Keys_iterator instance. Keys_iterator instance internal pointer points
|
||||
to Key_metadata list. This list holds information about all keys stored
|
||||
in the backed end data store of keyring plugin. After call to init()
|
||||
please check iterator_ptr.
|
||||
|
||||
get_key() method accepts the above iterator_ptr as IN param and then
|
||||
fills the passes in key_id and user_id with valid values. This can be
|
||||
used to fetch actual key information. Every call to this method will
|
||||
change internal pointers to advance to next position, so that the next
|
||||
call will fetch the next key.
|
||||
|
||||
deinit() method frees all internal pointers along with iterator_ptr.
|
||||
*/
|
||||
/**
|
||||
Initialize an iterator.
|
||||
|
||||
@param[out] key_iterator Iterator used to fetch individual keys
|
||||
from key_container.
|
||||
|
||||
@return VOID
|
||||
*/
|
||||
void (*mysql_key_iterator_init)(void** key_iterator);
|
||||
|
||||
/**
|
||||
Deinitialize an iterator.
|
||||
|
||||
@param[in] key_iterator Iterator used to fetch individual keys
|
||||
from key_container.
|
||||
|
||||
@return VOID
|
||||
*/
|
||||
void (*mysql_key_iterator_deinit)(void* key_iterator);
|
||||
|
||||
/**
|
||||
Get details of key. Every call to this service will change
|
||||
internal pointers to advance to next position, so that the next call
|
||||
will fetch the next key. In case iterator moves to the end, this service
|
||||
will return error.
|
||||
|
||||
@param[in] key_iterator Iterator used to fetch individual keys
|
||||
from key_container.
|
||||
@param[out] key_id id of the key
|
||||
@param[out] user_id id of the owner
|
||||
|
||||
@return Operation status
|
||||
@retval 0 OK
|
||||
@retval 1 ERROR
|
||||
*/
|
||||
bool (*mysql_key_iterator_get_key)(void* key_iterator, char *key_id, char *user_id);
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,127 @@
|
||||
#include "plugin.h"
|
||||
typedef void * MYSQL_PLUGIN;
|
||||
struct st_mysql_xid {
|
||||
long formatID;
|
||||
long gtrid_length;
|
||||
long bqual_length;
|
||||
char data[128];
|
||||
};
|
||||
typedef struct st_mysql_xid MYSQL_XID;
|
||||
enum enum_mysql_show_type
|
||||
{
|
||||
SHOW_UNDEF, SHOW_BOOL,
|
||||
SHOW_INT,
|
||||
SHOW_LONG,
|
||||
SHOW_LONGLONG,
|
||||
SHOW_CHAR, SHOW_CHAR_PTR,
|
||||
SHOW_ARRAY, SHOW_FUNC, SHOW_DOUBLE
|
||||
};
|
||||
enum enum_mysql_show_scope
|
||||
{
|
||||
SHOW_SCOPE_UNDEF,
|
||||
SHOW_SCOPE_GLOBAL
|
||||
};
|
||||
struct st_mysql_show_var
|
||||
{
|
||||
const char *name;
|
||||
char *value;
|
||||
enum enum_mysql_show_type type;
|
||||
enum enum_mysql_show_scope scope;
|
||||
};
|
||||
typedef int (*mysql_show_var_func)(void*, struct st_mysql_show_var*, char *);
|
||||
struct st_mysql_sys_var;
|
||||
struct st_mysql_value;
|
||||
typedef int (*mysql_var_check_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *save, struct st_mysql_value *value);
|
||||
typedef void (*mysql_var_update_func)(void* thd,
|
||||
struct st_mysql_sys_var *var,
|
||||
void *var_ptr, const void *save);
|
||||
struct st_mysql_plugin
|
||||
{
|
||||
int type;
|
||||
void *info;
|
||||
const char *name;
|
||||
const char *author;
|
||||
const char *descr;
|
||||
int license;
|
||||
int (*init)(MYSQL_PLUGIN);
|
||||
int (*deinit)(MYSQL_PLUGIN);
|
||||
unsigned int version;
|
||||
struct st_mysql_show_var *status_vars;
|
||||
struct st_mysql_sys_var **system_vars;
|
||||
void * __reserved1;
|
||||
unsigned long flags;
|
||||
};
|
||||
struct st_mysql_daemon
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_information_schema
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_storage_engine
|
||||
{
|
||||
int interface_version;
|
||||
};
|
||||
struct handlerton;
|
||||
struct Mysql_replication {
|
||||
int interface_version;
|
||||
};
|
||||
struct st_mysql_value
|
||||
{
|
||||
int (*value_type)(struct st_mysql_value *);
|
||||
const char *(*val_str)(struct st_mysql_value *, char *buffer, int *length);
|
||||
int (*val_real)(struct st_mysql_value *, double *realbuf);
|
||||
int (*val_int)(struct st_mysql_value *, long long *intbuf);
|
||||
int (*is_unsigned)(struct st_mysql_value *);
|
||||
};
|
||||
int thd_in_lock_tables(const void* thd);
|
||||
int thd_tablespace_op(const void* thd);
|
||||
long long thd_test_options(const void* thd, long long test_options);
|
||||
int thd_sql_command(const void* thd);
|
||||
const char *set_thd_proc_info(void* thd, const char *info,
|
||||
const char *calling_func,
|
||||
const char *calling_file,
|
||||
const unsigned int calling_line);
|
||||
void **thd_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_storage_lock_wait(void* thd, long long value);
|
||||
int thd_tx_isolation(const void* thd);
|
||||
int thd_tx_is_read_only(const void* thd);
|
||||
void* thd_tx_arbitrate(void* requestor, void* holder);
|
||||
int thd_tx_priority(const void* thd);
|
||||
int thd_tx_is_dd_trx(const void* thd);
|
||||
char *thd_security_context(void* thd, char *buffer, size_t length,
|
||||
size_t max_query_len);
|
||||
void thd_inc_row_count(void* thd);
|
||||
int thd_allow_batch(void* thd);
|
||||
void thd_mark_transaction_to_rollback(void* thd, int all);
|
||||
int mysql_tmpfile(const char *prefix);
|
||||
int thd_killed(const void* thd);
|
||||
void thd_set_kill_status(const void* thd);
|
||||
void thd_binlog_pos(const void* thd,
|
||||
const char **file_var,
|
||||
unsigned long long *pos_var);
|
||||
unsigned long thd_get_thread_id(const void* thd);
|
||||
void thd_get_xid(const void* thd, MYSQL_XID *xid);
|
||||
void mysql_query_cache_invalidate4(void* thd,
|
||||
const char *key, unsigned int key_length,
|
||||
int using_trx);
|
||||
void *thd_get_ha_data(const void* thd, const struct handlerton *hton);
|
||||
void thd_set_ha_data(void* thd, const struct handlerton *hton,
|
||||
const void *ha_data);
|
||||
struct st_mysql_keyring
|
||||
{
|
||||
int interface_version;
|
||||
my_bool (*mysql_key_store)(const char *key_id, const char *key_type,
|
||||
const char* user_id, const void *key, size_t key_len);
|
||||
my_bool (*mysql_key_fetch)(const char *key_id, char **key_type,
|
||||
const char *user_id, void **key, size_t *key_len);
|
||||
my_bool (*mysql_key_remove)(const char *key_id, const char *user_id);
|
||||
my_bool (*mysql_key_generate)(const char *key_id, const char *key_type,
|
||||
const char *user_id, size_t key_len);
|
||||
void (*mysql_key_iterator_init)(void** key_iterator);
|
||||
void (*mysql_key_iterator_deinit)(void* key_iterator);
|
||||
bool (*mysql_key_iterator_get_key)(void* key_iterator, char *key_id, char *user_id);
|
||||
};
|
||||
356
demo/kugou/include/Common/include/mysql/mysql/plugin_trace.h
Normal file
356
demo/kugou/include/Common/include/mysql/mysql/plugin_trace.h
Normal file
@@ -0,0 +1,356 @@
|
||||
/* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef PLUGIN_TRACE_INCLUDED
|
||||
#define PLUGIN_TRACE_INCLUDED
|
||||
/**
|
||||
@file
|
||||
|
||||
========================================================================
|
||||
Declarations for client-side plugins of type MYSQL_CLIENT_TRACE_PLUGIN
|
||||
========================================================================
|
||||
|
||||
See libmysql/mysql_trace.c for a brief description of the client-side
|
||||
protocol tracing infrastructure.
|
||||
*/
|
||||
|
||||
|
||||
#include <mysql/client_plugin.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Lists of protocol stages and trace events
|
||||
=========================================
|
||||
|
||||
These lists are defined with PROTOCOL_STAGE_LIST() and TRACE_EVENT_LIST(),
|
||||
respectively. Macros accept a disposition name as an argument.
|
||||
|
||||
For example, to process list of protocol stages using disposition "foo",
|
||||
define protocol_stage_foo(Stage) macro and then put
|
||||
|
||||
PROTOCOL_STAGE_LIST(foo)
|
||||
|
||||
in your code. This will expand to sequence of protocol_stage_foo(X)
|
||||
macros where X ranges over the list of protocol stages, and these macros
|
||||
should generate the actual code. See below how this technique is used
|
||||
to generate protocol_stage and trace_events enums.
|
||||
*/
|
||||
|
||||
/**
|
||||
Protocol stages
|
||||
---------------
|
||||
|
||||
A client following the MySQL protocol goes through several stages of it. Each
|
||||
stage determines what packets can be expected from the server or can be send
|
||||
by the client.
|
||||
|
||||
Upon receiving each trace event, trace plugin will be notified of the current
|
||||
protocol stage so that it can correctly interpret the event.
|
||||
|
||||
These are the possible protocol stages and the transitions between them.
|
||||
|
||||
.. digraph:: protocol_stages
|
||||
|
||||
CONNECTING -> WAIT_FOR_INIT_PACKET;
|
||||
CONNECTING -> DISCONNECTED [ label = "failed connection" ];
|
||||
|
||||
WAIT_FOR_INIT_PACKET -> AUTHENTICATE;
|
||||
WAIT_FOR_INIT_PACKET -> SSL_NEGOTIATION -> AUTHENTICATE;
|
||||
|
||||
AUTHENTICATE -> READY_FOR_COMMAND [ label = "accepted" ];
|
||||
AUTHENTICATE -> DISCONNECTED [ label = "rejected" ];
|
||||
|
||||
READY_FOR_COMMAND -> DISCONNECTED [ label = "COM_QUIT" ];
|
||||
READY_FOR_COMMAND -> AUTHENTICATE [ label="after change user" ];
|
||||
READY_FOR_COMMAND -> WAIT_FOR_PACKET
|
||||
[ label="wait for a single packet after, e.g., COM_STATISTICS" ];
|
||||
READY_FOR_COMMAND -> WAIT_FOR_RESULT;
|
||||
READY_FOR_COMMAND -> WAIT_FOR_PS_DESCRIPTION
|
||||
[ label="after prepare command" ];
|
||||
|
||||
WAIT_FOR_PACKET -> READY_FOR_COMAND;
|
||||
|
||||
WAIT_FOR_RESULT -> READY_FOR_COMMAND [ label="simple reply" ];
|
||||
WAIT_FOR_RESULT -> WAIT_FOR_FIELD_DEF;
|
||||
WAIT_FOR_RESULT -> FILE_REQUEST;
|
||||
|
||||
WAIT_FOR_FIELD_DEF -> WAIT_FOR_ROW [ label="in a resultset" ];
|
||||
WAIT_FOR_FIELD_DEF -> READY_FOR_COMMAND
|
||||
[ label="after describe table or prepare command" ];
|
||||
|
||||
WAIT_FOR_ROW -> READY_FOR_COMMAND;
|
||||
WAIT_FOR_ROW -> WAIT_FOR_RESULT [ label="multi-resultset" ];
|
||||
|
||||
WAIT_FOR_PS_DESCRIPTION -> WAIT_FOR_PARAM_DEF;
|
||||
WAIT_FOR_PS_DESCRIPTION -> READY_FOR_COMMAND
|
||||
[ label="no params and result" ];
|
||||
WAIT_FOR_PS_DESCRIPTION -> WAIT_FOR_FIELD_DEF [ label="no params" ];
|
||||
|
||||
WAIT_FOR_PARAM_DEF -> WAIT_FOR_FIELD_DEF;
|
||||
WAIT_FOR_PARAM_DEF -> READY_FOR_COMMAND [ label="no result" ];
|
||||
|
||||
FILE_REQUEST -> WAIT_FOR_RESULT [label="when whole file sent"];
|
||||
*/
|
||||
|
||||
#define PROTOCOL_STAGE_LIST(X) \
|
||||
protocol_stage_ ## X(CONNECTING) \
|
||||
protocol_stage_ ## X(WAIT_FOR_INIT_PACKET) \
|
||||
protocol_stage_ ## X(AUTHENTICATE) \
|
||||
protocol_stage_ ## X(SSL_NEGOTIATION) \
|
||||
protocol_stage_ ## X(READY_FOR_COMMAND) \
|
||||
protocol_stage_ ## X(WAIT_FOR_PACKET) \
|
||||
protocol_stage_ ## X(WAIT_FOR_RESULT) \
|
||||
protocol_stage_ ## X(WAIT_FOR_FIELD_DEF) \
|
||||
protocol_stage_ ## X(WAIT_FOR_ROW) \
|
||||
protocol_stage_ ## X(FILE_REQUEST) \
|
||||
protocol_stage_ ## X(WAIT_FOR_PS_DESCRIPTION) \
|
||||
protocol_stage_ ## X(WAIT_FOR_PARAM_DEF) \
|
||||
protocol_stage_ ## X(DISCONNECTED)
|
||||
|
||||
/**
|
||||
Trace events
|
||||
------------
|
||||
|
||||
The following events are generated during the various stages of the
|
||||
client-server conversation.
|
||||
|
||||
---------------------- -----------------------------------------------------
|
||||
Connection events
|
||||
---------------------- -----------------------------------------------------
|
||||
CONNECTING Client is connecting to the server.
|
||||
CONNECTED Physical connection has been established.
|
||||
DISCONNECTED Connection with server was broken.
|
||||
---------------------- -----------------------------------------------------
|
||||
SSL events
|
||||
---------------------- -----------------------------------------------------
|
||||
SEND_SSL_REQUEST Client is sending SSL connection request.
|
||||
SSL_CONNECT Client is initiating SSL handshake.
|
||||
SSL_CONNECTED SSL connection has been established.
|
||||
---------------------- -----------------------------------------------------
|
||||
Authentication events
|
||||
---------------------- -----------------------------------------------------
|
||||
CHALLENGE_RECEIVED Client received authentication challenge.
|
||||
AUTH_PLUGIN Client selects an authentication plugin to be used
|
||||
in the following authentication exchange.
|
||||
SEND_AUTH_RESPONSE Client sends response to the authentication
|
||||
challenge.
|
||||
SEND_AUTH_DATA Client sends extra authentication data packet.
|
||||
AUTHENTICATED Server has accepted connection.
|
||||
---------------------- -----------------------------------------------------
|
||||
Command phase events
|
||||
---------------------- -----------------------------------------------------
|
||||
SEND_COMMAND Client is sending a command to the server.
|
||||
SEND_FILE Client is sending local file contents to the server.
|
||||
---------------------- -----------------------------------------------------
|
||||
General events
|
||||
---------------------- -----------------------------------------------------
|
||||
READ_PACKET Client starts waiting for a packet from server.
|
||||
PACKET_RECEIVED A packet from server has been received.
|
||||
PACKET_SENT After successful sending of a packet to the server.
|
||||
ERROR Client detected an error.
|
||||
---------------------- -----------------------------------------------------
|
||||
*/
|
||||
|
||||
#define TRACE_EVENT_LIST(X) \
|
||||
trace_event_ ## X(ERROR) \
|
||||
trace_event_ ## X(CONNECTING) \
|
||||
trace_event_ ## X(CONNECTED) \
|
||||
trace_event_ ## X(DISCONNECTED) \
|
||||
trace_event_ ## X(SEND_SSL_REQUEST) \
|
||||
trace_event_ ## X(SSL_CONNECT) \
|
||||
trace_event_ ## X(SSL_CONNECTED) \
|
||||
trace_event_ ## X(INIT_PACKET_RECEIVED) \
|
||||
trace_event_ ## X(AUTH_PLUGIN) \
|
||||
trace_event_ ## X(SEND_AUTH_RESPONSE) \
|
||||
trace_event_ ## X(SEND_AUTH_DATA) \
|
||||
trace_event_ ## X(AUTHENTICATED) \
|
||||
trace_event_ ## X(SEND_COMMAND) \
|
||||
trace_event_ ## X(SEND_FILE) \
|
||||
trace_event_ ## X(READ_PACKET) \
|
||||
trace_event_ ## X(PACKET_RECEIVED) \
|
||||
trace_event_ ## X(PACKET_SENT)
|
||||
|
||||
/**
|
||||
Some trace events have additional arguments. These are stored in
|
||||
st_trace_event_args structure. Various events store their arguments in the
|
||||
structure as follows. Unused members are set to 0/NULL.
|
||||
|
||||
AUTH_PLUGIN
|
||||
------------- ----------------------------------
|
||||
plugin_name the name of the plugin
|
||||
------------- ----------------------------------
|
||||
|
||||
SEND_COMMAND
|
||||
------------- ----------------------------------
|
||||
cmd the command code
|
||||
hdr pointer to command packet header
|
||||
hdr_len length of the header
|
||||
pkt pointer to command arguments
|
||||
pkt_len length of arguments
|
||||
------------- ----------------------------------
|
||||
|
||||
Other SEND_* and *_RECEIVED events
|
||||
------------- ----------------------------------
|
||||
pkt the data sent or received
|
||||
pkt_len length of the data
|
||||
------------- ----------------------------------
|
||||
|
||||
PACKET_SENT
|
||||
------------- ----------------------------------
|
||||
pkt_len number of bytes sent
|
||||
------------- ----------------------------------
|
||||
*/
|
||||
|
||||
struct st_trace_event_args
|
||||
{
|
||||
const char *plugin_name;
|
||||
int cmd;
|
||||
const unsigned char *hdr;
|
||||
size_t hdr_len;
|
||||
const unsigned char *pkt;
|
||||
size_t pkt_len;
|
||||
};
|
||||
|
||||
|
||||
/* Definitions of protocol_stage and trace_event enums. */
|
||||
|
||||
#define protocol_stage_enum(X) PROTOCOL_STAGE_ ## X,
|
||||
|
||||
enum protocol_stage {
|
||||
PROTOCOL_STAGE_LIST(enum)
|
||||
PROTOCOL_STAGE_LAST
|
||||
};
|
||||
|
||||
#define trace_event_enum(X) TRACE_EVENT_ ## X,
|
||||
|
||||
enum trace_event {
|
||||
TRACE_EVENT_LIST(enum)
|
||||
TRACE_EVENT_LAST
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Trace plugin methods
|
||||
====================
|
||||
*/
|
||||
|
||||
struct st_mysql_client_plugin_TRACE;
|
||||
struct st_mysql;
|
||||
|
||||
/**
|
||||
Trace plugin tracing_start() method.
|
||||
|
||||
Called when tracing with this plugin starts on a connection. A trace
|
||||
plugin might want to maintain per-connection information. It can
|
||||
return a pointer to memory area holding such information. It will be
|
||||
stored in a connection handle and passed to other plugin methods.
|
||||
|
||||
@param self pointer to the plugin instance
|
||||
@param connection_handle
|
||||
@param stage protocol stage in which tracing has started - currently
|
||||
it is always CONNECTING stage.
|
||||
|
||||
@return A pointer to plugin-specific, per-connection data if any.
|
||||
*/
|
||||
|
||||
typedef
|
||||
void* (tracing_start_callback)(struct st_mysql_client_plugin_TRACE *self,
|
||||
struct st_mysql *connection_handle,
|
||||
enum protocol_stage stage);
|
||||
|
||||
/**
|
||||
Trace plugin tracing_stop() method.
|
||||
|
||||
Called when tracing of the connection has ended. If a plugin
|
||||
allocated any per-connection resources, it should de-allocate them
|
||||
here.
|
||||
|
||||
@param self pointer to the plugin instance
|
||||
@param connection_handle
|
||||
@param plugin_data pointer to plugin's per-connection data.
|
||||
*/
|
||||
|
||||
typedef
|
||||
void (tracing_stop_callback)(struct st_mysql_client_plugin_TRACE *self,
|
||||
struct st_mysql *connection_handle,
|
||||
void *plugin_data);
|
||||
|
||||
/**
|
||||
Trace plugin trace_event() method.
|
||||
|
||||
Called when a trace event occurs. Plugin can decide to stop tracing
|
||||
this connection by returning non-zero value.
|
||||
|
||||
@param self pointer to the plugin instance
|
||||
@param plugin_data pointer to plugin's per-connection data
|
||||
@param connection_handle
|
||||
@param stage current protocol stage
|
||||
@param event the trace event
|
||||
@param args trace event arguments
|
||||
|
||||
@return Non-zero if tracing of the connection should end here.
|
||||
*/
|
||||
|
||||
typedef
|
||||
int (trace_event_handler)(struct st_mysql_client_plugin_TRACE *self,
|
||||
void *plugin_data,
|
||||
struct st_mysql *connection_handle,
|
||||
enum protocol_stage stage,
|
||||
enum trace_event event,
|
||||
struct st_trace_event_args args);
|
||||
|
||||
|
||||
struct st_mysql_client_plugin_TRACE
|
||||
{
|
||||
MYSQL_CLIENT_PLUGIN_HEADER
|
||||
tracing_start_callback *tracing_start;
|
||||
tracing_stop_callback *tracing_stop;
|
||||
trace_event_handler *trace_event;
|
||||
};
|
||||
|
||||
/**
|
||||
The global trace_plugin pointer. If it is not NULL, it points at a
|
||||
loaded trace plugin which should be used to trace all connections made
|
||||
to the server.
|
||||
*/
|
||||
extern
|
||||
struct st_mysql_client_plugin_TRACE *trace_plugin;
|
||||
|
||||
#ifndef DBUG_OFF
|
||||
|
||||
/*
|
||||
Functions for getting names of trace events and protocol
|
||||
stages for debugging purposes.
|
||||
*/
|
||||
const char* protocol_stage_name(enum protocol_stage stage);
|
||||
const char* trace_event_name(enum trace_event ev);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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 */
|
||||
|
||||
#ifndef MYSQL_PLUGIN_VALIDATE_PASSWORD_INCLUDED
|
||||
#define MYSQL_PLUGIN_VALIDATE_PASSWORD_INCLUDED
|
||||
|
||||
/* API for validate_password plugin. (MYSQL_VALIDATE_PASSWORD_PLUGIN) */
|
||||
|
||||
#include <mysql/plugin.h>
|
||||
#define MYSQL_VALIDATE_PASSWORD_INTERFACE_VERSION 0x0100
|
||||
|
||||
/*
|
||||
The descriptor structure for the plugin, that is referred from
|
||||
st_mysql_plugin.
|
||||
*/
|
||||
|
||||
typedef void* mysql_string_handle;
|
||||
|
||||
struct st_mysql_validate_password
|
||||
{
|
||||
int interface_version;
|
||||
/*
|
||||
This function retuns TRUE for passwords which satisfy the password
|
||||
policy (as choosen by plugin variable) and FALSE for all other
|
||||
password
|
||||
*/
|
||||
int (*validate_password)(mysql_string_handle password);
|
||||
/*
|
||||
This function returns the password strength (0-100) depending
|
||||
upon the policies
|
||||
*/
|
||||
int (*get_password_strength)(mysql_string_handle password);
|
||||
};
|
||||
#endif
|
||||
1440
demo/kugou/include/Common/include/mysql/mysql/psi/mysql_file.h
Normal file
1440
demo/kugou/include/Common/include/mysql/mysql/psi/mysql_file.h
Normal file
File diff suppressed because it is too large
Load Diff
103
demo/kugou/include/Common/include/mysql/mysql/psi/mysql_idle.h
Normal file
103
demo/kugou/include/Common/include/mysql/mysql/psi/mysql_idle.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_IDLE_H
|
||||
#define MYSQL_IDLE_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_idle.h
|
||||
Instrumentation helpers for idle waits.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_IDLE_CALL
|
||||
#define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Idle_instrumentation Idle Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def MYSQL_START_IDLE_WAIT
|
||||
Instrumentation helper for table io_waits.
|
||||
This instrumentation marks the start of a wait event.
|
||||
@param LOCKER the locker
|
||||
@param STATE the locker state
|
||||
@sa MYSQL_END_IDLE_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_IDLE_INTERFACE
|
||||
#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
|
||||
LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
|
||||
#else
|
||||
#define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@def MYSQL_END_IDLE_WAIT
|
||||
Instrumentation helper for idle waits.
|
||||
This instrumentation marks the end of a wait event.
|
||||
@param LOCKER the locker
|
||||
@sa MYSQL_START_IDLE_WAIT.
|
||||
*/
|
||||
#ifdef HAVE_PSI_IDLE_INTERFACE
|
||||
#define MYSQL_END_IDLE_WAIT(LOCKER) \
|
||||
inline_mysql_end_idle_wait(LOCKER)
|
||||
#else
|
||||
#define MYSQL_END_IDLE_WAIT(LOCKER) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_IDLE_INTERFACE
|
||||
/**
|
||||
Instrumentation calls for MYSQL_START_IDLE_WAIT.
|
||||
@sa MYSQL_END_IDLE_WAIT.
|
||||
*/
|
||||
static inline struct PSI_idle_locker *
|
||||
inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
|
||||
const char *src_file, int src_line)
|
||||
{
|
||||
struct PSI_idle_locker *locker;
|
||||
locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
|
||||
return locker;
|
||||
}
|
||||
|
||||
/**
|
||||
Instrumentation calls for MYSQL_END_IDLE_WAIT.
|
||||
@sa MYSQL_START_IDLE_WAIT.
|
||||
*/
|
||||
static inline void
|
||||
inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
|
||||
{
|
||||
if (likely(locker != NULL))
|
||||
PSI_IDLE_CALL(end_idle_wait)(locker);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end of group Idle_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
128
demo/kugou/include/Common/include/mysql/mysql/psi/mysql_mdl.h
Normal file
128
demo/kugou/include/Common/include/mysql/mysql/psi/mysql_mdl.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_MDL_H
|
||||
#define MYSQL_MDL_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_mdl.h
|
||||
Instrumentation helpers for metadata locks.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_METADATA_CALL
|
||||
#define PSI_METADATA_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Thread_instrumentation Metadata Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def mysql_mdl_create(K, M, A)
|
||||
Instrumented metadata lock creation.
|
||||
@param I Metadata lock identity
|
||||
@param K Metadata key
|
||||
@param T Metadata lock type
|
||||
@param D Metadata lock duration
|
||||
@param S Metadata lock status
|
||||
@param F request source file
|
||||
@param L request source line
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
#define mysql_mdl_create(I, K, T, D, S, F, L) \
|
||||
inline_mysql_mdl_create(I, K, T, D, S, F, L)
|
||||
#else
|
||||
#define mysql_mdl_create(I, K, T, D, S, F, L) NULL
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
#define mysql_mdl_set_status(L, S) \
|
||||
inline_mysql_mdl_set_status(L, S)
|
||||
#else
|
||||
#define mysql_mdl_set_status(L, S) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@def mysql_mdl_destroy(M)
|
||||
Instrumented metadata lock destruction.
|
||||
@param M Metadata lock
|
||||
*/
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
#define mysql_mdl_destroy(M) \
|
||||
inline_mysql_mdl_destroy(M, __FILE__, __LINE__)
|
||||
#else
|
||||
#define mysql_mdl_destroy(M) \
|
||||
do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PSI_METADATA_INTERFACE
|
||||
|
||||
static inline PSI_metadata_lock *
|
||||
inline_mysql_mdl_create(void *identity,
|
||||
const MDL_key *mdl_key,
|
||||
enum_mdl_type mdl_type,
|
||||
enum_mdl_duration mdl_duration,
|
||||
MDL_ticket::enum_psi_status mdl_status,
|
||||
const char *src_file, uint src_line)
|
||||
{
|
||||
PSI_metadata_lock *result;
|
||||
|
||||
/* static_cast: Fit a round C++ enum peg into a square C int hole ... */
|
||||
result= PSI_METADATA_CALL(create_metadata_lock)
|
||||
(identity,
|
||||
mdl_key,
|
||||
static_cast<opaque_mdl_type> (mdl_type),
|
||||
static_cast<opaque_mdl_duration> (mdl_duration),
|
||||
static_cast<opaque_mdl_status> (mdl_status),
|
||||
src_file, src_line);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline void inline_mysql_mdl_set_status(
|
||||
PSI_metadata_lock *psi,
|
||||
MDL_ticket::enum_psi_status mdl_status)
|
||||
{
|
||||
if (psi != NULL)
|
||||
PSI_METADATA_CALL(set_metadata_lock_status)(psi, mdl_status);
|
||||
}
|
||||
|
||||
static inline void inline_mysql_mdl_destroy(
|
||||
PSI_metadata_lock *psi,
|
||||
const char *src_file, uint src_line)
|
||||
{
|
||||
if (psi != NULL)
|
||||
PSI_METADATA_CALL(destroy_metadata_lock)(psi);
|
||||
}
|
||||
#endif /* HAVE_PSI_METADATA_INTERFACE */
|
||||
|
||||
/** @} (end of group Metadata_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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,
|
||||
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
|
||||
|
||||
#ifndef MYSQL_MEMORY_H
|
||||
#define MYSQL_MEMORY_H
|
||||
|
||||
/**
|
||||
@file mysql/psi/mysql_memory.h
|
||||
Instrumentation helpers for memory allocation.
|
||||
*/
|
||||
|
||||
#include "mysql/psi/psi.h"
|
||||
|
||||
#ifndef PSI_MEMORY_CALL
|
||||
#define PSI_MEMORY_CALL(M) PSI_DYNAMIC_CALL(M)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup Memory_instrumentation Memory Instrumentation
|
||||
@ingroup Instrumentation_interface
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
@def mysql_memory_register(P1, P2, P3)
|
||||
Memory registration.
|
||||
*/
|
||||
#define mysql_memory_register(P1, P2, P3) \
|
||||
inline_mysql_memory_register(P1, P2, P3)
|
||||
|
||||
static inline void inline_mysql_memory_register(
|
||||
#ifdef HAVE_PSI_MEMORY_INTERFACE
|
||||
const char *category,
|
||||
PSI_memory_info *info,
|
||||
int count)
|
||||
#else
|
||||
const char *category MY_ATTRIBUTE((unused)),
|
||||
void *info MY_ATTRIBUTE((unused)),
|
||||
int count MY_ATTRIBUTE((unused)))
|
||||
#endif
|
||||
{
|
||||
#ifdef HAVE_PSI_MEMORY_INTERFACE
|
||||
PSI_MEMORY_CALL(register_memory)(category, info, count);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @} (end of group Memory_instrumentation) */
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user