mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
base64 service
This commit is contained in:
@ -1,62 +0,0 @@
|
||||
/* Copyright (c) 2003-2006 MySQL AB
|
||||
Use is subject to license terms
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
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 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 __BASE64_H_INCLUDED__
|
||||
#define __BASE64_H_INCLUDED__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
Calculate how much memory needed for dst of base64_encode()
|
||||
*/
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
|
||||
/*
|
||||
Maximum length base64_encode_needed_length() can accept with no overflow.
|
||||
*/
|
||||
int base64_encode_max_arg_length(void);
|
||||
|
||||
/*
|
||||
Calculate how much memory needed for dst of base64_decode()
|
||||
*/
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
|
||||
/*
|
||||
Maximum length base64_decode_needed_length() can accept with no overflow.
|
||||
*/
|
||||
int base64_decode_max_arg_length();
|
||||
|
||||
/*
|
||||
Encode data as a base64 string
|
||||
*/
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
|
||||
/*
|
||||
Decode a base64 string into data
|
||||
*/
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
|
||||
/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
|
||||
#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !__BASE64_H_INCLUDED__ */
|
@ -176,6 +176,22 @@ size_t my_md5_context_size();
|
||||
void my_md5_init(void *context);
|
||||
void my_md5_input(void *context, const unsigned char *buf, size_t len);
|
||||
void my_md5_result(void *context, unsigned char *digest);
|
||||
extern struct base64_service_st {
|
||||
int (*base64_needed_encoded_length_ptr)(int length_of_data);
|
||||
int (*base64_encode_max_arg_length_ptr)(void);
|
||||
int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
|
||||
int (*base64_decode_max_arg_length_ptr)();
|
||||
int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
|
||||
int (*base64_decode_ptr)(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
} *base64_service;
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
int base64_encode_max_arg_length(void);
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
int base64_decode_max_arg_length();
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
typedef struct logger_handle_st LOGGER_HANDLE;
|
||||
extern struct logger_service_st {
|
||||
void (*logger_init_mutexes)();
|
||||
|
@ -176,6 +176,22 @@ size_t my_md5_context_size();
|
||||
void my_md5_init(void *context);
|
||||
void my_md5_input(void *context, const unsigned char *buf, size_t len);
|
||||
void my_md5_result(void *context, unsigned char *digest);
|
||||
extern struct base64_service_st {
|
||||
int (*base64_needed_encoded_length_ptr)(int length_of_data);
|
||||
int (*base64_encode_max_arg_length_ptr)(void);
|
||||
int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
|
||||
int (*base64_decode_max_arg_length_ptr)();
|
||||
int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
|
||||
int (*base64_decode_ptr)(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
} *base64_service;
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
int base64_encode_max_arg_length(void);
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
int base64_decode_max_arg_length();
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
typedef struct logger_handle_st LOGGER_HANDLE;
|
||||
extern struct logger_service_st {
|
||||
void (*logger_init_mutexes)();
|
||||
|
@ -176,6 +176,22 @@ size_t my_md5_context_size();
|
||||
void my_md5_init(void *context);
|
||||
void my_md5_input(void *context, const unsigned char *buf, size_t len);
|
||||
void my_md5_result(void *context, unsigned char *digest);
|
||||
extern struct base64_service_st {
|
||||
int (*base64_needed_encoded_length_ptr)(int length_of_data);
|
||||
int (*base64_encode_max_arg_length_ptr)(void);
|
||||
int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
|
||||
int (*base64_decode_max_arg_length_ptr)();
|
||||
int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
|
||||
int (*base64_decode_ptr)(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
} *base64_service;
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
int base64_encode_max_arg_length(void);
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
int base64_decode_max_arg_length();
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
typedef struct logger_handle_st LOGGER_HANDLE;
|
||||
extern struct logger_service_st {
|
||||
void (*logger_init_mutexes)();
|
||||
|
@ -176,6 +176,22 @@ size_t my_md5_context_size();
|
||||
void my_md5_init(void *context);
|
||||
void my_md5_input(void *context, const unsigned char *buf, size_t len);
|
||||
void my_md5_result(void *context, unsigned char *digest);
|
||||
extern struct base64_service_st {
|
||||
int (*base64_needed_encoded_length_ptr)(int length_of_data);
|
||||
int (*base64_encode_max_arg_length_ptr)(void);
|
||||
int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
|
||||
int (*base64_decode_max_arg_length_ptr)();
|
||||
int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
|
||||
int (*base64_decode_ptr)(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
} *base64_service;
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
int base64_encode_max_arg_length(void);
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
int base64_decode_max_arg_length();
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
typedef struct logger_handle_st LOGGER_HANDLE;
|
||||
extern struct logger_service_st {
|
||||
void (*logger_init_mutexes)();
|
||||
|
@ -176,6 +176,22 @@ size_t my_md5_context_size();
|
||||
void my_md5_init(void *context);
|
||||
void my_md5_input(void *context, const unsigned char *buf, size_t len);
|
||||
void my_md5_result(void *context, unsigned char *digest);
|
||||
extern struct base64_service_st {
|
||||
int (*base64_needed_encoded_length_ptr)(int length_of_data);
|
||||
int (*base64_encode_max_arg_length_ptr)(void);
|
||||
int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
|
||||
int (*base64_decode_max_arg_length_ptr)();
|
||||
int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
|
||||
int (*base64_decode_ptr)(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
} *base64_service;
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
int base64_encode_max_arg_length(void);
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
int base64_decode_max_arg_length();
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
typedef struct logger_handle_st LOGGER_HANDLE;
|
||||
extern struct logger_service_st {
|
||||
void (*logger_init_mutexes)();
|
||||
|
82
include/mysql/service_base64.h
Normal file
82
include/mysql/service_base64.h
Normal file
@ -0,0 +1,82 @@
|
||||
#ifndef MYSQL_SERVICE_BASE64_INCLUDED
|
||||
/* Copyright (c) 2017, MariaDB
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
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 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
|
||||
my base64 service
|
||||
|
||||
Functions for base64 en- and decoding
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef MYSQL_ABI_CHECK
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
|
||||
#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1
|
||||
|
||||
extern struct base64_service_st {
|
||||
int (*base64_needed_encoded_length_ptr)(int length_of_data);
|
||||
int (*base64_encode_max_arg_length_ptr)(void);
|
||||
int (*base64_needed_decoded_length_ptr)(int length_of_encoded_data);
|
||||
int (*base64_decode_max_arg_length_ptr)();
|
||||
int (*base64_encode_ptr)(const void *src, size_t src_len, char *dst);
|
||||
int (*base64_decode_ptr)(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
} *base64_service;
|
||||
|
||||
#ifdef MYSQL_DYNAMIC_PLUGIN
|
||||
|
||||
#define base64_needed_encoded_length(A) base64_service->base64_needed_encoded_length_ptr(A)
|
||||
#define base64_encode_max_arg_length() base64_service->base64_encode_max_arg_length_ptr()
|
||||
#define base64_needed_decoded_length(A) base64_service->base64_needed_decoded_length_ptr(A)
|
||||
#define base64_decode_max_arg_length() base64_service->base64_decode_max_arg_length_ptr()
|
||||
#define base64_encode(A,B,C) base64_service->base64_encode_ptr(A,B,C)
|
||||
#define base64_decode(A,B,C,D,E) base64_service->base64_decode_ptr(A,B,C,D,E)
|
||||
|
||||
#else
|
||||
|
||||
/* Calculate how much memory needed for dst of base64_encode() */
|
||||
int base64_needed_encoded_length(int length_of_data);
|
||||
|
||||
/* Maximum length base64_encode_needed_length() can accept with no overflow. */
|
||||
int base64_encode_max_arg_length(void);
|
||||
|
||||
/* Calculate how much memory needed for dst of base64_decode() */
|
||||
int base64_needed_decoded_length(int length_of_encoded_data);
|
||||
|
||||
/* Maximum length base64_decode_needed_length() can accept with no overflow. */
|
||||
int base64_decode_max_arg_length();
|
||||
|
||||
/* Encode data as a base64 string */
|
||||
int base64_encode(const void *src, size_t src_len, char *dst);
|
||||
|
||||
/* Decode a base64 string into data */
|
||||
int base64_decode(const char *src, size_t src_len,
|
||||
void *dst, const char **end_ptr, int flags);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MYSQL_SERVICE_BASE64_INCLUDED
|
||||
#endif
|
@ -29,6 +29,7 @@ extern "C" {
|
||||
#include <mysql/service_sha2.h>
|
||||
#include <mysql/service_sha1.h>
|
||||
#include <mysql/service_md5.h>
|
||||
#include <mysql/service_base64.h>
|
||||
#include <mysql/service_logger.h>
|
||||
#include <mysql/service_thd_autoinc.h>
|
||||
#include <mysql/service_thd_error_context.h>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#define VERSION_my_md5 0x0100
|
||||
#define VERSION_wsrep 0x0201
|
||||
#define VERSION_logger 0x0100
|
||||
#define VERSION_base64 0x0100
|
||||
#define VERSION_thd_autoinc 0x0100
|
||||
#define VERSION_thd_error_context 0x0100
|
||||
#define VERSION_thd_specifics 0x0100
|
||||
|
@ -28,6 +28,7 @@ SET(MYSQLSERVICES_SOURCES
|
||||
my_sha2_service.c
|
||||
my_sha1_service.c
|
||||
my_md5_service.c
|
||||
base64_service.c
|
||||
wsrep_service.c
|
||||
encryption_service.c
|
||||
encryption_scheme_service.c
|
||||
|
18
libservices/base64_service.c
Normal file
18
libservices/base64_service.c
Normal file
@ -0,0 +1,18 @@
|
||||
/* Copyright (c) 2017 MariaDB
|
||||
Use is subject to license terms.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
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 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 <service_versions.h>
|
||||
SERVICE_VERSION base64_service= (void*)VERSION_base64;
|
@ -17,7 +17,6 @@
|
||||
#include <my_global.h>
|
||||
#include <m_string.h> /* strchr() */
|
||||
#include <m_ctype.h> /* my_isspace() */
|
||||
#include <base64.h>
|
||||
|
||||
#ifndef MAIN
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <base64.h>
|
||||
|
||||
#if defined (_WIN32)
|
||||
#define HAVE_SYS_UTSNAME_H
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include "password.h" // my_make_scrambled_password,
|
||||
// my_make_scrambled_password_323
|
||||
#include <m_ctype.h>
|
||||
#include <base64.h>
|
||||
#include <my_md5.h>
|
||||
#include <zlib.h>
|
||||
C_MODE_START
|
||||
|
@ -46,7 +46,6 @@
|
||||
#include "wsrep_mysqld.h"
|
||||
#endif /* MYSQL_CLIENT */
|
||||
|
||||
#include <base64.h>
|
||||
#include <my_bitmap.h>
|
||||
#include "rpl_utility.h"
|
||||
#include "rpl_constants.h"
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "sql_parse.h" // check_global_access
|
||||
#include "sql_acl.h" // *_ACL
|
||||
#include "rpl_rli.h"
|
||||
#include "base64.h"
|
||||
#include "slave.h" // apply_event_and_update_pos
|
||||
#include "log_event.h" // Format_description_log_event,
|
||||
// EVENT_LEN_OFFSET,
|
||||
|
@ -119,6 +119,15 @@ static struct thd_autoinc_service_st thd_autoinc_handler= {
|
||||
thd_get_autoinc
|
||||
};
|
||||
|
||||
static struct base64_service_st base64_handler= {
|
||||
base64_needed_encoded_length,
|
||||
base64_encode_max_arg_length,
|
||||
base64_needed_decoded_length,
|
||||
base64_decode_max_arg_length,
|
||||
base64_encode,
|
||||
base64_decode
|
||||
};
|
||||
|
||||
static struct thd_error_context_service_st thd_error_conext_handler= {
|
||||
thd_get_error_message,
|
||||
thd_get_error_number,
|
||||
@ -195,6 +204,7 @@ static struct st_service_ref list_of_services[]=
|
||||
{ "my_sha1_service", VERSION_my_sha1, &my_sha1_handler},
|
||||
{ "my_md5_service", VERSION_my_md5, &my_md5_handler},
|
||||
{ "logger_service", VERSION_logger, &logger_service_handler },
|
||||
{ "base64_service", VERSION_base64, &base64_handler },
|
||||
{ "thd_autoinc_service", VERSION_thd_autoinc, &thd_autoinc_handler },
|
||||
{ "wsrep_service", VERSION_wsrep, &wsrep_handler },
|
||||
{ "encryption_service", VERSION_encryption, &encryption_handler },
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
#include <my_global.h>
|
||||
#include <my_sys.h>
|
||||
#include <base64.h>
|
||||
#include <tap.h>
|
||||
#include <string.h>
|
||||
|
||||
|
Reference in New Issue
Block a user