MySQL 9.1.0
Source Code Documentation
common.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 Without limiting anything contained in the foregoing, this file,
16 which is part of C Driver for MySQL (Connector/C), is also subject to the
17 Universal FOSS Exception, version 1.0, a copy of which can be found at
18 http://oss.oracle.com/licenses/universal-foss-exception.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License, version 2.0, for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
28
29#ifndef COMMON_H_
30#define COMMON_H_
31
32#include <cstring>
33#include <iostream>
34#include <sstream>
35
36#include "my_byteorder.h"
37#include "my_inttypes.h"
38
39/* Length of random salt in base64 format */
40#define BASE64_CHALLENGE_LENGTH 45
41
42typedef void (*plugin_messages_callback)(const char *msg);
43typedef int (*plugin_messages_callback_get_uint)(unsigned int *val);
45 char *buffer, const unsigned int buffer_len);
49
50/* Define type of message */
51enum class message_type {
52 INFO, /* directed to stdout */
53 ERROR, /* directed to stderr */
54};
55
56enum class input_type {
57 UINT, /* get unsigned int input */
58 PASSWORD /* get password */
59};
60/*
61 Helper method to redirect plugin specific messages to a registered callback
62 method or to stdout/stderr.
63*/
64void get_plugin_messages(const std::string &msg, message_type type);
65int get_user_input(const std::string &msg, input_type type, void *arg,
66 const unsigned int *optional_arg_size = nullptr);
67
68/**
69 Helper method to convert base64 string to url safe base64.
70*/
71void url_compatible_base64(char *url_compatible_str, size_t len,
72 char *base64_str);
73bool generate_sha256(const unsigned char *in_key, unsigned int in_key_length,
74 unsigned char *hash, unsigned int &hash_length);
75
76#endif // COMMON_H_
input_type
Definition: common.h:56
void url_compatible_base64(char *url_compatible_str, size_t len, char *base64_str)
Helper method to convert base64 string to url safe base64.
Definition: common.cc:111
plugin_messages_callback mc
Definition: webauthn_client_plugin.cc:55
int(* plugin_messages_callback_get_uint)(unsigned int *val)
Definition: common.h:43
int(* plugin_messages_callback_get_password)(char *buffer, const unsigned int buffer_len)
Definition: common.h:44
message_type
Definition: common.h:51
int get_user_input(const std::string &msg, input_type type, void *arg, const unsigned int *optional_arg_size=nullptr)
Definition: common.cc:61
plugin_messages_callback_get_password mc_get_password
Definition: webauthn_client_plugin.cc:57
bool generate_sha256(const unsigned char *in_key, unsigned int in_key_length, unsigned char *hash, unsigned int &hash_length)
Definition: common.cc:130
plugin_messages_callback_get_uint mc_get_uint
Definition: webauthn_client_plugin.cc:56
void get_plugin_messages(const std::string &msg, message_type type)
Definition: common.cc:43
void(* plugin_messages_callback)(const char *msg)
Definition: common.h:42
Functions for reading and storing in machine-independent format.
Some integer typedefs for easier portability.
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
required string type
Definition: replication_group_member_actions.proto:34