id
int64
0
755k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
65
repo_stars
int64
100
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
9 values
repo_extraction_date
stringclasses
92 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
751,535
sha512.h
w1hkj_fldigi/src/include/mbedtls/sha512.h
/** * \file sha512.h * \brief This file contains SHA-384 and SHA-512 definitions and functions. * * The Secure Hash Algorithms 384 and 512 (SHA-384 and SHA-512) cryptographic * hash functions are defined in <em>FIPS 180-4: Secure Hash Standard (SHS)</em>. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SHA512_H #define MBEDTLS_SHA512_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> /* MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED -0x0039 /**< SHA-512 hardware accelerator failed */ #define MBEDTLS_ERR_SHA512_BAD_INPUT_DATA -0x0075 /**< SHA-512 input data was malformed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_SHA512_ALT) // Regular implementation // /** * \brief The SHA-512 context structure. * * The structure is used both for SHA-384 and for SHA-512 * checksum calculations. The choice between these two is * made in the call to mbedtls_sha512_starts_ret(). */ typedef struct mbedtls_sha512_context { uint64_t total[2]; /*!< The number of Bytes processed. */ uint64_t state[8]; /*!< The intermediate digest state. */ unsigned char buffer[128]; /*!< The data block being processed. */ int is384; /*!< Determines which function to use: 0: Use SHA-512, or 1: Use SHA-384. */ } mbedtls_sha512_context; #else /* MBEDTLS_SHA512_ALT */ #include "sha512_alt.h" #endif /* MBEDTLS_SHA512_ALT */ /** * \brief This function initializes a SHA-512 context. * * \param ctx The SHA-512 context to initialize. This must * not be \c NULL. */ void mbedtls_sha512_init( mbedtls_sha512_context *ctx ); /** * \brief This function clears a SHA-512 context. * * \param ctx The SHA-512 context to clear. This may be \c NULL, * in which case this function does nothing. If it * is not \c NULL, it must point to an initialized * SHA-512 context. */ void mbedtls_sha512_free( mbedtls_sha512_context *ctx ); /** * \brief This function clones the state of a SHA-512 context. * * \param dst The destination context. This must be initialized. * \param src The context to clone. This must be initialized. */ void mbedtls_sha512_clone( mbedtls_sha512_context *dst, const mbedtls_sha512_context *src ); /** * \brief This function starts a SHA-384 or SHA-512 checksum * calculation. * * \param ctx The SHA-512 context to use. This must be initialized. * \param is384 Determines which function to use. This must be * either \c for SHA-512, or \c 1 for SHA-384. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 ); /** * \brief This function feeds an input buffer into an ongoing * SHA-512 checksum calculation. * * \param ctx The SHA-512 context. This must be initialized * and have a hash operation started. * \param input The buffer holding the input data. This must * be a readable buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the SHA-512 operation, and writes * the result to the output buffer. This function is for * internal use only. * * \param ctx The SHA-512 context. This must be initialized * and have a hash operation started. * \param output The SHA-384 or SHA-512 checksum result. * This must be a writable buffer of length \c 64 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, unsigned char output[64] ); /** * \brief This function processes a single data block within * the ongoing SHA-512 computation. * * \param ctx The SHA-512 context. This must be initialized. * \param data The buffer holding one block of data. This * must be a readable buffer of length \c 128 Bytes. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function starts a SHA-384 or SHA-512 checksum * calculation. * * \deprecated Superseded by mbedtls_sha512_starts_ret() in 2.7.0 * * \param ctx The SHA-512 context to use. This must be initialized. * \param is384 Determines which function to use. This must be either * \c 0 for SHA-512 or \c 1 for SHA-384. */ MBEDTLS_DEPRECATED void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 ); /** * \brief This function feeds an input buffer into an ongoing * SHA-512 checksum calculation. * * \deprecated Superseded by mbedtls_sha512_update_ret() in 2.7.0. * * \param ctx The SHA-512 context. This must be initialized * and have a hash operation started. * \param input The buffer holding the data. This must be a readable * buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the SHA-512 operation, and writes * the result to the output buffer. * * \deprecated Superseded by mbedtls_sha512_finish_ret() in 2.7.0. * * \param ctx The SHA-512 context. This must be initialized * and have a hash operation started. * \param output The SHA-384 or SHA-512 checksum result. This must * be a writable buffer of size \c 64 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] ); /** * \brief This function processes a single data block within * the ongoing SHA-512 computation. This function is for * internal use only. * * \deprecated Superseded by mbedtls_internal_sha512_process() in 2.7.0. * * \param ctx The SHA-512 context. This must be initialized. * \param data The buffer holding one block of data. This must be * a readable buffer of length \c 128 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief This function calculates the SHA-512 or SHA-384 * checksum of a buffer. * * The function allocates the context, performs the * calculation, and frees the context. * * The SHA-512 result is calculated as * output = SHA-512(input buffer). * * \param input The buffer holding the input data. This must be * a readable buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. * \param output The SHA-384 or SHA-512 checksum result. * This must be a writable buffer of length \c 64 Bytes. * \param is384 Determines which function to use. This must be either * \c 0 for SHA-512, or \c 1 for SHA-384. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_sha512_ret( const unsigned char *input, size_t ilen, unsigned char output[64], int is384 ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function calculates the SHA-512 or SHA-384 * checksum of a buffer. * * The function allocates the context, performs the * calculation, and frees the context. * * The SHA-512 result is calculated as * output = SHA-512(input buffer). * * \deprecated Superseded by mbedtls_sha512_ret() in 2.7.0 * * \param input The buffer holding the data. This must be a * readable buffer of length \p ilen Bytes. * \param ilen The length of the input data in Bytes. * \param output The SHA-384 or SHA-512 checksum result. This must * be a writable buffer of length \c 64 Bytes. * \param is384 Determines which function to use. This must be either * \c 0 for SHA-512, or \c 1 for SHA-384. */ MBEDTLS_DEPRECATED void mbedtls_sha512( const unsigned char *input, size_t ilen, unsigned char output[64], int is384 ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief The SHA-384 or SHA-512 checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_sha512_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_sha512.h */
11,331
C++
.h
274
37.229927
110
0.620083
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,536
net.h
w1hkj_fldigi/src/include/mbedtls/net.h
/** * \file net.h * * \brief Deprecated header file that includes net_sockets.h * * \deprecated Superseded by mbedtls/net_sockets.h */ /* * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #if !defined(MBEDTLS_DEPRECATED_REMOVED) #include "net_sockets.h" #if defined(MBEDTLS_DEPRECATED_WARNING) #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" #endif /* MBEDTLS_DEPRECATED_WARNING */ #endif /* !MBEDTLS_DEPRECATED_REMOVED */
1,297
C++
.h
33
37.515152
75
0.749802
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,537
md2.h
w1hkj_fldigi/src/include/mbedtls/md2.h
/** * \file md2.h * * \brief MD2 message digest algorithm (hash function) * * \warning MD2 is considered a weak message digest and its use constitutes a * security risk. We recommend considering stronger message digests * instead. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) * */ #ifndef MBEDTLS_MD2_H #define MBEDTLS_MD2_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> /* MBEDTLS_ERR_MD2_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B /**< MD2 hardware accelerator failed */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_MD2_ALT) // Regular implementation // /** * \brief MD2 context structure * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ typedef struct mbedtls_md2_context { unsigned char cksum[16]; /*!< checksum of the data block */ unsigned char state[48]; /*!< intermediate digest state */ unsigned char buffer[16]; /*!< data block being processed */ size_t left; /*!< amount of data in buffer */ } mbedtls_md2_context; #else /* MBEDTLS_MD2_ALT */ #include "md2_alt.h" #endif /* MBEDTLS_MD2_ALT */ /** * \brief Initialize MD2 context * * \param ctx MD2 context to be initialized * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md2_init( mbedtls_md2_context *ctx ); /** * \brief Clear MD2 context * * \param ctx MD2 context to be cleared * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md2_free( mbedtls_md2_context *ctx ); /** * \brief Clone (the state of) an MD2 context * * \param dst The destination context * \param src The context to be cloned * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ void mbedtls_md2_clone( mbedtls_md2_context *dst, const mbedtls_md2_context *src ); /** * \brief MD2 context setup * * \param ctx context to be initialized * * \return 0 if successful * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx ); /** * \brief MD2 process buffer * * \param ctx MD2 context * \param input buffer holding the data * \param ilen length of the input data * * \return 0 if successful * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md2_update_ret( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD2 final digest * * \param ctx MD2 context * \param output MD2 checksum result * * \return 0 if successful * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md2_finish_ret( mbedtls_md2_context *ctx, unsigned char output[16] ); /** * \brief MD2 process data block (internal use only) * * \param ctx MD2 context * * \return 0 if successful * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_internal_md2_process( mbedtls_md2_context *ctx ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief MD2 context setup * * \deprecated Superseded by mbedtls_md2_starts_ret() in 2.7.0 * * \param ctx context to be initialized * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md2_starts( mbedtls_md2_context *ctx ); /** * \brief MD2 process buffer * * \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0 * * \param ctx MD2 context * \param input buffer holding the data * \param ilen length of the input data * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen ); /** * \brief MD2 final digest * * \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0 * * \param ctx MD2 context * \param output MD2 checksum result * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] ); /** * \brief MD2 process data block (internal use only) * * \deprecated Superseded by mbedtls_internal_md2_process() in 2.7.0 * * \param ctx MD2 context * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md2_process( mbedtls_md2_context *ctx ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Output = MD2( input buffer ) * * \param input buffer holding the data * \param ilen length of the input data * \param output MD2 checksum result * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md2_ret( const unsigned char *input, size_t ilen, unsigned char output[16] ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief Output = MD2( input buffer ) * * \deprecated Superseded by mbedtls_md2_ret() in 2.7.0 * * \param input buffer holding the data * \param ilen length of the input data * \param output MD2 checksum result * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed * * \warning MD2 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * */ int mbedtls_md2_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* mbedtls_md2.h */
9,398
C++
.h
279
30.580645
106
0.641852
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,538
ecdsa.h
w1hkj_fldigi/src/include/mbedtls/ecdsa.h
/** * \file ecdsa.h * * \brief This file contains ECDSA definitions and functions. * * The Elliptic Curve Digital Signature Algorithm (ECDSA) is defined in * <em>Standards for Efficient Cryptography Group (SECG): * SEC1 Elliptic Curve Cryptography</em>. * The use of ECDSA for TLS is defined in <em>RFC-4492: Elliptic Curve * Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS)</em>. * */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ECDSA_H #define MBEDTLS_ECDSA_H #include "ecp.h" #include "md.h" /* * RFC-4492 page 20: * * Ecdsa-Sig-Value ::= SEQUENCE { * r INTEGER, * s INTEGER * } * * Size is at most * 1 (tag) + 1 (len) + 1 (initial 0) + ECP_MAX_BYTES for each of r and s, * twice that + 1 (tag) + 2 (len) for the sequence * (assuming ECP_MAX_BYTES is less than 126 for r and s, * and less than 124 (total len <= 255) for the sequence) */ #if MBEDTLS_ECP_MAX_BYTES > 124 #error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN" #endif /** The maximal size of an ECDSA signature in Bytes. */ #define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) ) #ifdef __cplusplus extern "C" { #endif /** * \brief The ECDSA context structure. * * \warning Performing multiple operations concurrently on the same * ECDSA context is not supported; objects of this type * should not be shared between multiple threads. */ typedef mbedtls_ecp_keypair mbedtls_ecdsa_context; #if defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Internal restart context for ecdsa_verify() * * \note Opaque struct, defined in ecdsa.c */ typedef struct mbedtls_ecdsa_restart_ver mbedtls_ecdsa_restart_ver_ctx; /** * \brief Internal restart context for ecdsa_sign() * * \note Opaque struct, defined in ecdsa.c */ typedef struct mbedtls_ecdsa_restart_sig mbedtls_ecdsa_restart_sig_ctx; #if defined(MBEDTLS_ECDSA_DETERMINISTIC) /** * \brief Internal restart context for ecdsa_sign_det() * * \note Opaque struct, defined in ecdsa.c */ typedef struct mbedtls_ecdsa_restart_det mbedtls_ecdsa_restart_det_ctx; #endif /** * \brief General context for resuming ECDSA operations */ typedef struct { mbedtls_ecp_restart_ctx ecp; /*!< base context for ECP restart and shared administrative info */ mbedtls_ecdsa_restart_ver_ctx *ver; /*!< ecdsa_verify() sub-context */ mbedtls_ecdsa_restart_sig_ctx *sig; /*!< ecdsa_sign() sub-context */ #if defined(MBEDTLS_ECDSA_DETERMINISTIC) mbedtls_ecdsa_restart_det_ctx *det; /*!< ecdsa_sign_det() sub-context */ #endif } mbedtls_ecdsa_restart_ctx; #else /* MBEDTLS_ECP_RESTARTABLE */ /* Now we can declare functions that take a pointer to that */ typedef void mbedtls_ecdsa_restart_ctx; #endif /* MBEDTLS_ECP_RESTARTABLE */ /** * \brief This function computes the ECDSA signature of a * previously-hashed message. * * \note The deterministic version implemented in * mbedtls_ecdsa_sign_det() is usually preferred. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated * as defined in <em>Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography</em>, section * 4.1.3, step 5. * * \see ecp.h * * \param grp The context for the elliptic curve to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param r The MPI context in which to store the first part * the signature. This must be initialized. * \param s The MPI context in which to store the second part * the signature. This must be initialized. * \param d The private signing key. This must be initialized. * \param buf The content to be signed. This is usually the hash of * the original data to be signed. This must be a readable * buffer of length \p blen Bytes. It may be \c NULL if * \p blen is zero. * \param blen The length of \p buf in Bytes. * \param f_rng The RNG function. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng doesn't need a context parameter. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX * or \c MBEDTLS_MPI_XXX error code on failure. */ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #if defined(MBEDTLS_ECDSA_DETERMINISTIC) /** * \brief This function computes the ECDSA signature of a * previously-hashed message, deterministic version. * * For more information, see <em>RFC-6979: Deterministic * Usage of the Digital Signature Algorithm (DSA) and Elliptic * Curve Digital Signature Algorithm (ECDSA)</em>. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in <em>Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography</em>, section * 4.1.3, step 5. * * \see ecp.h * * \param grp The context for the elliptic curve to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param r The MPI context in which to store the first part * the signature. This must be initialized. * \param s The MPI context in which to store the second part * the signature. This must be initialized. * \param d The private signing key. This must be initialized * and setup, for example through mbedtls_ecp_gen_privkey(). * \param buf The hashed content to be signed. This must be a readable * buffer of length \p blen Bytes. It may be \c NULL if * \p blen is zero. * \param blen The length of \p buf in Bytes. * \param md_alg The hash algorithm used to hash the original data. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX * error code on failure. */ int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, mbedtls_md_type_t md_alg ); #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ /** * \brief This function verifies the ECDSA signature of a * previously-hashed message. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in <em>Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography</em>, section * 4.1.4, step 3. * * \see ecp.h * * \param grp The ECP group to use. * This must be initialized and have group parameters * set, for example through mbedtls_ecp_group_load(). * \param buf The hashed content that was signed. This must be a readable * buffer of length \p blen Bytes. It may be \c NULL if * \p blen is zero. * \param blen The length of \p buf in Bytes. * \param Q The public key to use for verification. This must be * initialized and setup. * \param r The first integer of the signature. * This must be initialized. * \param s The second integer of the signature. * This must be initialized. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the signature * is invalid. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX * error code on failure for any other reason. */ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, const unsigned char *buf, size_t blen, const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s); /** * \brief This function computes the ECDSA signature and writes it * to a buffer, serialized as defined in <em>RFC-4492: * Elliptic Curve Cryptography (ECC) Cipher Suites for * Transport Layer Security (TLS)</em>. * * \warning It is not thread-safe to use the same context in * multiple threads. * * \note The deterministic version is used if * #MBEDTLS_ECDSA_DETERMINISTIC is defined. For more * information, see <em>RFC-6979: Deterministic Usage * of the Digital Signature Algorithm (DSA) and Elliptic * Curve Digital Signature Algorithm (ECDSA)</em>. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in <em>Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography</em>, section * 4.1.3, step 5. * * \see ecp.h * * \param ctx The ECDSA context to use. This must be initialized * and have a group and private key bound to it, for example * via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair(). * \param md_alg The message digest that was used to hash the message. * \param hash The message hash to be signed. This must be a readable * buffer of length \p blen Bytes. * \param hlen The length of the hash \p hash in Bytes. * \param sig The buffer to which to write the signature. This must be a * writable buffer of length at least twice as large as the * size of the curve used, plus 9. For example, 73 Bytes if * a 256-bit curve is used. A buffer length of * #MBEDTLS_ECDSA_MAX_LEN is always safe. * \param slen The address at which to store the actual length of * the signature written. Must not be \c NULL. * \param f_rng The RNG function. This must not be \c NULL if * #MBEDTLS_ECDSA_DETERMINISTIC is unset. Otherwise, * it is unused and may be set to \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't use a context. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or * \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function computes the ECDSA signature and writes it * to a buffer, in a restartable way. * * \see \c mbedtls_ecdsa_write_signature() * * \note This function is like \c mbedtls_ecdsa_write_signature() * but it can return early and restart according to the limit * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. * * \param ctx The ECDSA context to use. This must be initialized * and have a group and private key bound to it, for example * via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair(). * \param md_alg The message digest that was used to hash the message. * \param hash The message hash to be signed. This must be a readable * buffer of length \p blen Bytes. * \param hlen The length of the hash \p hash in Bytes. * \param sig The buffer to which to write the signature. This must be a * writable buffer of length at least twice as large as the * size of the curve used, plus 9. For example, 73 Bytes if * a 256-bit curve is used. A buffer length of * #MBEDTLS_ECDSA_MAX_LEN is always safe. * \param slen The address at which to store the actual length of * the signature written. Must not be \c NULL. * \param f_rng The RNG function. This must not be \c NULL if * #MBEDTLS_ECDSA_DETERMINISTIC is unset. Otherwise, * it is unused and may be set to \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng is \c NULL or doesn't use a context. * \param rs_ctx The restart context to use. This may be \c NULL to disable * restarting. If it is not \c NULL, it must point to an * initialized restart context. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or * \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_ecdsa_write_signature_restartable( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_ecdsa_restart_ctx *rs_ctx ); #if defined(MBEDTLS_ECDSA_DETERMINISTIC) #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function computes an ECDSA signature and writes * it to a buffer, serialized as defined in <em>RFC-4492: * Elliptic Curve Cryptography (ECC) Cipher Suites for * Transport Layer Security (TLS)</em>. * * The deterministic version is defined in <em>RFC-6979: * Deterministic Usage of the Digital Signature Algorithm (DSA) * and Elliptic Curve Digital Signature Algorithm (ECDSA)</em>. * * \warning It is not thread-safe to use the same context in * multiple threads. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in <em>Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography</em>, section * 4.1.3, step 5. * * \see ecp.h * * \deprecated Superseded by mbedtls_ecdsa_write_signature() in * Mbed TLS version 2.0 and later. * * \param ctx The ECDSA context to use. This must be initialized * and have a group and private key bound to it, for example * via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair(). * \param hash The message hash to be signed. This must be a readable * buffer of length \p blen Bytes. * \param hlen The length of the hash \p hash in Bytes. * \param sig The buffer to which to write the signature. This must be a * writable buffer of length at least twice as large as the * size of the curve used, plus 9. For example, 73 Bytes if * a 256-bit curve is used. A buffer length of * #MBEDTLS_ECDSA_MAX_LEN is always safe. * \param slen The address at which to store the actual length of * the signature written. Must not be \c NULL. * \param md_alg The message digest that was used to hash the message. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or * \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, mbedtls_md_type_t md_alg ) MBEDTLS_DEPRECATED; #undef MBEDTLS_DEPRECATED #endif /* MBEDTLS_DEPRECATED_REMOVED */ #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ /** * \brief This function reads and verifies an ECDSA signature. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in <em>Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography</em>, section * 4.1.4, step 3. * * \see ecp.h * * \param ctx The ECDSA context to use. This must be initialized * and have a group and public key bound to it. * \param hash The message hash that was signed. This must be a readable * buffer of length \p size Bytes. * \param hlen The size of the hash \p hash. * \param sig The signature to read and verify. This must be a readable * buffer of length \p slen Bytes. * \param slen The size of \p sig in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid. * \return #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if there is a valid * signature in \p sig, but its length is less than \p siglen. * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX * error code on failure for any other reason. */ int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen ); /** * \brief This function reads and verifies an ECDSA signature, * in a restartable way. * * \see \c mbedtls_ecdsa_read_signature() * * \note This function is like \c mbedtls_ecdsa_read_signature() * but it can return early and restart according to the limit * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. * * \param ctx The ECDSA context to use. This must be initialized * and have a group and public key bound to it. * \param hash The message hash that was signed. This must be a readable * buffer of length \p size Bytes. * \param hlen The size of the hash \p hash. * \param sig The signature to read and verify. This must be a readable * buffer of length \p slen Bytes. * \param slen The size of \p sig in Bytes. * \param rs_ctx The restart context to use. This may be \c NULL to disable * restarting. If it is not \c NULL, it must point to an * initialized restart context. * * \return \c 0 on success. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid. * \return #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if there is a valid * signature in \p sig, but its length is less than \p siglen. * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). * \return Another \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX * error code on failure for any other reason. */ int mbedtls_ecdsa_read_signature_restartable( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen, mbedtls_ecdsa_restart_ctx *rs_ctx ); /** * \brief This function generates an ECDSA keypair on the given curve. * * \see ecp.h * * \param ctx The ECDSA context to store the keypair in. * This must be initialized. * \param gid The elliptic curve to use. One of the various * \c MBEDTLS_ECP_DP_XXX macros depending on configuration. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG context to be passed to \p f_rng. This may be * \c NULL if \p f_rng doesn't need a context argument. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX code on failure. */ int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This function sets up an ECDSA context from an EC key pair. * * \see ecp.h * * \param ctx The ECDSA context to setup. This must be initialized. * \param key The EC key to use. This must be initialized and hold * a private-public key pair or a public key. In the former * case, the ECDSA context may be used for signature creation * and verification after this call. In the latter case, it * may be used for signature verification. * * \return \c 0 on success. * \return An \c MBEDTLS_ERR_ECP_XXX code on failure. */ int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key ); /** * \brief This function initializes an ECDSA context. * * \param ctx The ECDSA context to initialize. * This must not be \c NULL. */ void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx ); /** * \brief This function frees an ECDSA context. * * \param ctx The ECDSA context to free. This may be \c NULL, * in which case this function does nothing. If it * is not \c NULL, it must be initialized. */ void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx ); #if defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Initialize a restart context. * * \param ctx The restart context to initialize. * This must not be \c NULL. */ void mbedtls_ecdsa_restart_init( mbedtls_ecdsa_restart_ctx *ctx ); /** * \brief Free the components of a restart context. * * \param ctx The restart context to free. This may be \c NULL, * in which case this function does nothing. If it * is not \c NULL, it must be initialized. */ void mbedtls_ecdsa_restart_free( mbedtls_ecdsa_restart_ctx *ctx ); #endif /* MBEDTLS_ECP_RESTARTABLE */ #ifdef __cplusplus } #endif #endif /* ecdsa.h */
24,905
C++
.h
512
45.183594
85
0.602692
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,539
md.h
w1hkj_fldigi/src/include/mbedtls/md.h
/** * \file md.h * * \brief This file contains the generic message-digest wrapper. * * \author Adriaan de Jong <dejong@fox-it.com> */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_MD_H #define MBEDTLS_MD_H #include <stddef.h> #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */ #define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */ #define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */ /* MBEDTLS_ERR_MD_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280 /**< MD hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif /** * \brief Supported message digests. * * \warning MD2, MD4, MD5 and SHA-1 are considered weak message digests and * their use constitutes a security risk. We recommend considering * stronger message digests instead. * */ typedef enum { MBEDTLS_MD_NONE=0, /**< None. */ MBEDTLS_MD_MD2, /**< The MD2 message digest. */ MBEDTLS_MD_MD4, /**< The MD4 message digest. */ MBEDTLS_MD_MD5, /**< The MD5 message digest. */ MBEDTLS_MD_SHA1, /**< The SHA-1 message digest. */ MBEDTLS_MD_SHA224, /**< The SHA-224 message digest. */ MBEDTLS_MD_SHA256, /**< The SHA-256 message digest. */ MBEDTLS_MD_SHA384, /**< The SHA-384 message digest. */ MBEDTLS_MD_SHA512, /**< The SHA-512 message digest. */ MBEDTLS_MD_RIPEMD160, /**< The RIPEMD-160 message digest. */ } mbedtls_md_type_t; #if defined(MBEDTLS_SHA512_C) #define MBEDTLS_MD_MAX_SIZE 64 /* longest known is SHA512 */ #else #define MBEDTLS_MD_MAX_SIZE 32 /* longest known is SHA256 or less */ #endif /** * Opaque struct defined in md_internal.h. */ typedef struct mbedtls_md_info_t mbedtls_md_info_t; /** * The generic message-digest context. */ typedef struct mbedtls_md_context_t { /** Information about the associated message digest. */ const mbedtls_md_info_t *md_info; /** The digest-specific context. */ void *md_ctx; /** The HMAC part of the context. */ void *hmac_ctx; } mbedtls_md_context_t; /** * \brief This function returns the list of digests supported by the * generic digest module. * * \return A statically allocated array of digests. Each element * in the returned list is an integer belonging to the * message-digest enumeration #mbedtls_md_type_t. * The last entry is 0. */ const int *mbedtls_md_list( void ); /** * \brief This function returns the message-digest information * associated with the given digest name. * * \param md_name The name of the digest to search for. * * \return The message-digest information associated with \p md_name. * \return NULL if the associated message-digest information is not found. */ const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name ); /** * \brief This function returns the message-digest information * associated with the given digest type. * * \param md_type The type of digest to search for. * * \return The message-digest information associated with \p md_type. * \return NULL if the associated message-digest information is not found. */ const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type ); /** * \brief This function initializes a message-digest context without * binding it to a particular message-digest algorithm. * * This function should always be called first. It prepares the * context for mbedtls_md_setup() for binding it to a * message-digest algorithm. */ void mbedtls_md_init( mbedtls_md_context_t *ctx ); /** * \brief This function clears the internal structure of \p ctx and * frees any embedded internal structure, but does not free * \p ctx itself. * * If you have called mbedtls_md_setup() on \p ctx, you must * call mbedtls_md_free() when you are no longer using the * context. * Calling this function if you have previously * called mbedtls_md_init() and nothing else is optional. * You must not call this function if you have not called * mbedtls_md_init(). */ void mbedtls_md_free( mbedtls_md_context_t *ctx ); #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) #define MBEDTLS_DEPRECATED __attribute__((deprecated)) #else #define MBEDTLS_DEPRECATED #endif /** * \brief This function selects the message digest algorithm to use, * and allocates internal structures. * * It should be called after mbedtls_md_init() or mbedtls_md_free(). * Makes it necessary to call mbedtls_md_free() later. * * \deprecated Superseded by mbedtls_md_setup() in 2.0.0 * * \param ctx The context to set up. * \param md_info The information structure of the message-digest algorithm * to use. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. * \return #MBEDTLS_ERR_MD_ALLOC_FAILED on memory-allocation failure. */ int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED; #undef MBEDTLS_DEPRECATED #endif /* MBEDTLS_DEPRECATED_REMOVED */ /** * \brief This function selects the message digest algorithm to use, * and allocates internal structures. * * It should be called after mbedtls_md_init() or * mbedtls_md_free(). Makes it necessary to call * mbedtls_md_free() later. * * \param ctx The context to set up. * \param md_info The information structure of the message-digest algorithm * to use. * \param hmac Defines if HMAC is used. 0: HMAC is not used (saves some memory), * or non-zero: HMAC is used with this context. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. * \return #MBEDTLS_ERR_MD_ALLOC_FAILED on memory-allocation failure. */ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac ); /** * \brief This function clones the state of an message-digest * context. * * \note You must call mbedtls_md_setup() on \c dst before calling * this function. * * \note The two contexts must have the same type, * for example, both are SHA-256. * * \warning This function clones the message-digest state, not the * HMAC state. * * \param dst The destination context. * \param src The context to be cloned. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification failure. */ int mbedtls_md_clone( mbedtls_md_context_t *dst, const mbedtls_md_context_t *src ); /** * \brief This function extracts the message-digest size from the * message-digest information structure. * * \param md_info The information structure of the message-digest algorithm * to use. * * \return The size of the message-digest output in Bytes. */ unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info ); /** * \brief This function extracts the message-digest type from the * message-digest information structure. * * \param md_info The information structure of the message-digest algorithm * to use. * * \return The type of the message digest. */ mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info ); /** * \brief This function extracts the message-digest name from the * message-digest information structure. * * \param md_info The information structure of the message-digest algorithm * to use. * * \return The name of the message digest. */ const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info ); /** * \brief This function starts a message-digest computation. * * You must call this function after setting up the context * with mbedtls_md_setup(), and before passing data with * mbedtls_md_update(). * * \param ctx The generic message-digest context. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_starts( mbedtls_md_context_t *ctx ); /** * \brief This function feeds an input buffer into an ongoing * message-digest computation. * * You must call mbedtls_md_starts() before calling this * function. You may call this function multiple times. * Afterwards, call mbedtls_md_finish(). * * \param ctx The generic message-digest context. * \param input The buffer holding the input data. * \param ilen The length of the input data. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the digest operation, * and writes the result to the output buffer. * * Call this function after a call to mbedtls_md_starts(), * followed by any number of calls to mbedtls_md_update(). * Afterwards, you may either clear the context with * mbedtls_md_free(), or call mbedtls_md_starts() to reuse * the context for another digest operation with the same * algorithm. * * \param ctx The generic message-digest context. * \param output The buffer for the generic message-digest checksum result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ); /** * \brief This function calculates the message-digest of a buffer, * with respect to a configurable message-digest algorithm * in a single call. * * The result is calculated as * Output = message_digest(input buffer). * * \param md_info The information structure of the message-digest algorithm * to use. * \param input The buffer holding the data. * \param ilen The length of the input data. * \param output The generic message-digest checksum result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output ); #if defined(MBEDTLS_FS_IO) /** * \brief This function calculates the message-digest checksum * result of the contents of the provided file. * * The result is calculated as * Output = message_digest(file contents). * * \param md_info The information structure of the message-digest algorithm * to use. * \param path The input file name. * \param output The generic message-digest checksum result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_FILE_IO_ERROR on an I/O error accessing * the file pointed by \p path. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA if \p md_info was NULL. */ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigned char *output ); #endif /* MBEDTLS_FS_IO */ /** * \brief This function sets the HMAC key and prepares to * authenticate a new message. * * Call this function after mbedtls_md_setup(), to use * the MD context for an HMAC calculation, then call * mbedtls_md_hmac_update() to provide the input data, and * mbedtls_md_hmac_finish() to get the HMAC value. * * \param ctx The message digest context containing an embedded HMAC * context. * \param key The HMAC secret key. * \param keylen The length of the HMAC key in Bytes. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen ); /** * \brief This function feeds an input buffer into an ongoing HMAC * computation. * * Call mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset() * before calling this function. * You may call this function multiple times to pass the * input piecewise. * Afterwards, call mbedtls_md_hmac_finish(). * * \param ctx The message digest context containing an embedded HMAC * context. * \param input The buffer holding the input data. * \param ilen The length of the input data. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ); /** * \brief This function finishes the HMAC operation, and writes * the result to the output buffer. * * Call this function after mbedtls_md_hmac_starts() and * mbedtls_md_hmac_update() to get the HMAC value. Afterwards * you may either call mbedtls_md_free() to clear the context, * or call mbedtls_md_hmac_reset() to reuse the context with * the same HMAC key. * * \param ctx The message digest context containing an embedded HMAC * context. * \param output The generic HMAC checksum result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output); /** * \brief This function prepares to authenticate a new message with * the same key as the previous HMAC operation. * * You may call this function after mbedtls_md_hmac_finish(). * Afterwards call mbedtls_md_hmac_update() to pass the new * input. * * \param ctx The message digest context containing an embedded HMAC * context. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ); /** * \brief This function calculates the full generic HMAC * on the input buffer with the provided key. * * The function allocates the context, performs the * calculation, and frees the context. * * The HMAC result is calculated as * output = generic HMAC(hmac key, input buffer). * * \param md_info The information structure of the message-digest algorithm * to use. * \param key The HMAC secret key. * \param keylen The length of the HMAC secret key in Bytes. * \param input The buffer holding the input data. * \param ilen The length of the input data. * \param output The generic HMAC result. * * \return \c 0 on success. * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification * failure. */ int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, unsigned char *output ); /* Internal use */ int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data ); #ifdef __cplusplus } #endif #endif /* MBEDTLS_MD_H */
18,205
C++
.h
434
39.693548
113
0.62137
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,540
net_sockets.h
w1hkj_fldigi/src/include/mbedtls/net_sockets.h
/** * \file net_sockets.h * * \brief Network sockets abstraction layer to integrate Mbed TLS into a * BSD-style sockets API. * * The network sockets module provides an example integration of the * Mbed TLS library into a BSD sockets implementation. The module is * intended to be an example of how Mbed TLS can be integrated into a * networking stack, as well as to be Mbed TLS's network integration * for its supported platforms. * * The module is intended only to be used with the Mbed TLS library and * is not intended to be used by third party application software * directly. * * The supported platforms are as follows: * * Microsoft Windows and Windows CE * * POSIX/Unix platforms including Linux, OS X * */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_NET_SOCKETS_H #define MBEDTLS_NET_SOCKETS_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "ssl.h" #include <stddef.h> #include <stdint.h> #define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */ #define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */ #define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */ #define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */ #define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */ #define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */ #define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */ #define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */ #define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */ #define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */ #define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */ #define MBEDTLS_ERR_NET_POLL_FAILED -0x0047 /**< Polling the net context failed. */ #define MBEDTLS_ERR_NET_BAD_INPUT_DATA -0x0049 /**< Input invalid. */ #define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */ #define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */ #define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */ #define MBEDTLS_NET_POLL_READ 1 /**< Used in \c mbedtls_net_poll to check for pending data */ #define MBEDTLS_NET_POLL_WRITE 2 /**< Used in \c mbedtls_net_poll to check if write possible */ #ifdef __cplusplus extern "C" { #endif /** * Wrapper type for sockets. * * Currently backed by just a file descriptor, but might be more in the future * (eg two file descriptors for combined IPv4 + IPv6 support, or additional * structures for hand-made UDP demultiplexing). */ typedef struct mbedtls_net_context { int fd; /**< The underlying file descriptor */ } mbedtls_net_context; /** * \brief Initialize a context * Just makes the context ready to be used or freed safely. * * \param ctx Context to initialize */ void mbedtls_net_init( mbedtls_net_context *ctx ); /** * \brief Initiate a connection with host:port in the given protocol * * \param ctx Socket to use * \param host Host to connect to * \param port Port to connect to * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP * * \return 0 if successful, or one of: * MBEDTLS_ERR_NET_SOCKET_FAILED, * MBEDTLS_ERR_NET_UNKNOWN_HOST, * MBEDTLS_ERR_NET_CONNECT_FAILED * * \note Sets the socket in connected mode even with UDP. */ int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto ); /** * \brief Create a receiving socket on bind_ip:port in the chosen * protocol. If bind_ip == NULL, all interfaces are bound. * * \param ctx Socket to use * \param bind_ip IP to bind to, can be NULL * \param port Port number to use * \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP * * \return 0 if successful, or one of: * MBEDTLS_ERR_NET_SOCKET_FAILED, * MBEDTLS_ERR_NET_BIND_FAILED, * MBEDTLS_ERR_NET_LISTEN_FAILED * * \note Regardless of the protocol, opens the sockets and binds it. * In addition, make the socket listening if protocol is TCP. */ int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto ); /** * \brief Accept a connection from a remote client * * \param bind_ctx Relevant socket * \param client_ctx Will contain the connected client socket * \param client_ip Will contain the client IP address, can be NULL * \param buf_size Size of the client_ip buffer * \param ip_len Will receive the size of the client IP written, * can be NULL if client_ip is null * * \return 0 if successful, or * MBEDTLS_ERR_NET_ACCEPT_FAILED, or * MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small, * MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to * non-blocking and accept() would block. */ int mbedtls_net_accept( mbedtls_net_context *bind_ctx, mbedtls_net_context *client_ctx, void *client_ip, size_t buf_size, size_t *ip_len ); /** * \brief Check and wait for the context to be ready for read/write * * \param ctx Socket to check * \param rw Bitflag composed of MBEDTLS_NET_POLL_READ and * MBEDTLS_NET_POLL_WRITE specifying the events * to wait for: * - If MBEDTLS_NET_POLL_READ is set, the function * will return as soon as the net context is available * for reading. * - If MBEDTLS_NET_POLL_WRITE is set, the function * will return as soon as the net context is available * for writing. * \param timeout Maximal amount of time to wait before returning, * in milliseconds. If \c timeout is zero, the * function returns immediately. If \c timeout is * -1u, the function blocks potentially indefinitely. * * \return Bitmask composed of MBEDTLS_NET_POLL_READ/WRITE * on success or timeout, or a negative return code otherwise. */ int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout ); /** * \brief Set the socket blocking * * \param ctx Socket to set * * \return 0 if successful, or a non-zero error code */ int mbedtls_net_set_block( mbedtls_net_context *ctx ); /** * \brief Set the socket non-blocking * * \param ctx Socket to set * * \return 0 if successful, or a non-zero error code */ int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ); /** * \brief Portable usleep helper * * \param usec Amount of microseconds to sleep * * \note Real amount of time slept will not be less than * select()'s timeout granularity (typically, 10ms). */ void mbedtls_net_usleep( unsigned long usec ); /** * \brief Read at most 'len' characters. If no error occurs, * the actual amount read is returned. * * \param ctx Socket * \param buf The buffer to write to * \param len Maximum length of the buffer * * \return the number of bytes received, * or a non-zero error code; with a non-blocking socket, * MBEDTLS_ERR_SSL_WANT_READ indicates read() would block. */ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ); /** * \brief Write at most 'len' characters. If no error occurs, * the actual amount read is returned. * * \param ctx Socket * \param buf The buffer to read from * \param len The length of the buffer * * \return the number of bytes sent, * or a non-zero error code; with a non-blocking socket, * MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block. */ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); /** * \brief Read at most 'len' characters, blocking for at most * 'timeout' seconds. If no error occurs, the actual amount * read is returned. * * \param ctx Socket * \param buf The buffer to write to * \param len Maximum length of the buffer * \param timeout Maximum number of milliseconds to wait for data * 0 means no timeout (wait forever) * * \return the number of bytes received, * or a non-zero error code: * MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out, * MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal. * * \note This function will block (until data becomes available or * timeout is reached) even if the socket is set to * non-blocking. Handling timeouts with non-blocking reads * requires a different strategy. */ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, uint32_t timeout ); /** * \brief Gracefully shutdown the connection and free associated data * * \param ctx The context to free */ void mbedtls_net_free( mbedtls_net_context *ctx ); #ifdef __cplusplus } #endif #endif /* net_sockets.h */
11,066
C++
.h
250
42.156
126
0.632169
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,541
ecp_internal.h
w1hkj_fldigi/src/include/mbedtls/ecp_internal.h
/** * \file ecp_internal.h * * \brief Function declarations for alternative implementation of elliptic curve * point arithmetic. */ /* * Copyright (C) 2016, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ /* * References: * * [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records. * <http://cr.yp.to/ecdh/curve25519-20060209.pdf> * * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis * for elliptic curve cryptosystems. In : Cryptographic Hardware and * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302. * <http://link.springer.com/chapter/10.1007/3-540-48059-5_25> * * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to * render ECC resistant against Side Channel Attacks. IACR Cryptology * ePrint Archive, 2004, vol. 2004, p. 342. * <http://eprint.iacr.org/2004/342.pdf> * * [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters. * <http://www.secg.org/sec2-v2.pdf> * * [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic * Curve Cryptography. * * [6] Digital Signature Standard (DSS), FIPS 186-4. * <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf> * * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer * Security (TLS), RFC 4492. * <https://tools.ietf.org/search/rfc4492> * * [8] <http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html> * * [9] COHEN, Henri. A Course in Computational Algebraic Number Theory. * Springer Science & Business Media, 1 Aug 2000 */ #ifndef MBEDTLS_ECP_INTERNAL_H #define MBEDTLS_ECP_INTERNAL_H #if defined(MBEDTLS_ECP_INTERNAL_ALT) /** * \brief Indicate if the Elliptic Curve Point module extension can * handle the group. * * \param grp The pointer to the elliptic curve group that will be the * basis of the cryptographic computations. * * \return Non-zero if successful. */ unsigned char mbedtls_internal_ecp_grp_capable( const mbedtls_ecp_group *grp ); /** * \brief Initialise the Elliptic Curve Point module extension. * * If mbedtls_internal_ecp_grp_capable returns true for a * group, this function has to be able to initialise the * module for it. * * This module can be a driver to a crypto hardware * accelerator, for which this could be an initialise function. * * \param grp The pointer to the group the module needs to be * initialised for. * * \return 0 if successful. */ int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ); /** * \brief Frees and deallocates the Elliptic Curve Point module * extension. * * \param grp The pointer to the group the module was initialised for. */ void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ); #if defined(ECP_SHORTWEIERSTRASS) #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) /** * \brief Randomize jacobian coordinates: * (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l. * * \param grp Pointer to the group representing the curve. * * \param pt The point on the curve to be randomised, given with Jacobian * coordinates. * * \param f_rng A function pointer to the random number generator. * * \param p_rng A pointer to the random number generator state. * * \return 0 if successful. */ int mbedtls_internal_ecp_randomize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #endif #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) /** * \brief Addition: R = P + Q, mixed affine-Jacobian coordinates. * * The coordinates of Q must be normalized (= affine), * but those of P don't need to. R is not normalized. * * This function is used only as a subrutine of * ecp_mul_comb(). * * Special cases: (1) P or Q is zero, (2) R is zero, * (3) P == Q. * None of these cases can happen as intermediate step in * ecp_mul_comb(): * - at each step, P, Q and R are multiples of the base * point, the factor being less than its order, so none of * them is zero; * - Q is an odd multiple of the base point, P an even * multiple, due to the choice of precomputed points in the * modified comb method. * So branches for these cases do not leak secret information. * * We accept Q->Z being unset (saving memory in tables) as * meaning 1. * * Cost in field operations if done by [5] 3.22: * 1A := 8M + 3S * * \param grp Pointer to the group representing the curve. * * \param R Pointer to a point structure to hold the result. * * \param P Pointer to the first summand, given with Jacobian * coordinates * * \param Q Pointer to the second summand, given with affine * coordinates. * * \return 0 if successful. */ int mbedtls_internal_ecp_add_mixed( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ); #endif /** * \brief Point doubling R = 2 P, Jacobian coordinates. * * Cost: 1D := 3M + 4S (A == 0) * 4M + 4S (A == -3) * 3M + 6S + 1a otherwise * when the implementation is based on the "dbl-1998-cmo-2" * doubling formulas in [8] and standard optimizations are * applied when curve parameter A is one of { 0, -3 }. * * \param grp Pointer to the group representing the curve. * * \param R Pointer to a point structure to hold the result. * * \param P Pointer to the point that has to be doubled, given with * Jacobian coordinates. * * \return 0 if successful. */ #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) int mbedtls_internal_ecp_double_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_ecp_point *P ); #endif /** * \brief Normalize jacobian coordinates of an array of (pointers to) * points. * * Using Montgomery's trick to perform only one inversion mod P * the cost is: * 1N(t) := 1I + (6t - 3)M + 1S * (See for example Algorithm 10.3.4. in [9]) * * This function is used only as a subrutine of * ecp_mul_comb(). * * Warning: fails (returning an error) if one of the points is * zero! * This should never happen, see choice of w in ecp_mul_comb(). * * \param grp Pointer to the group representing the curve. * * \param T Array of pointers to the points to normalise. * * \param t_len Number of elements in the array. * * \return 0 if successful, * an error if one of the points is zero. */ #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) int mbedtls_internal_ecp_normalize_jac_many( const mbedtls_ecp_group *grp, mbedtls_ecp_point *T[], size_t t_len ); #endif /** * \brief Normalize jacobian coordinates so that Z == 0 || Z == 1. * * Cost in field operations if done by [5] 3.2.1: * 1N := 1I + 3M + 1S * * \param grp Pointer to the group representing the curve. * * \param pt pointer to the point to be normalised. This is an * input/output parameter. * * \return 0 if successful. */ #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) int mbedtls_internal_ecp_normalize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt ); #endif #endif /* ECP_SHORTWEIERSTRASS */ #if defined(ECP_MONTGOMERY) #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) int mbedtls_internal_ecp_double_add_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, const mbedtls_mpi *d ); #endif /** * \brief Randomize projective x/z coordinates: * (X, Z) -> (l X, l Z) for random l * * \param grp pointer to the group representing the curve * * \param P the point on the curve to be randomised given with * projective coordinates. This is an input/output parameter. * * \param f_rng a function pointer to the random number generator * * \param p_rng a pointer to the random number generator state * * \return 0 if successful */ #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) int mbedtls_internal_ecp_randomize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #endif /** * \brief Normalize Montgomery x/z coordinates: X = X/Z, Z = 1. * * \param grp pointer to the group representing the curve * * \param P pointer to the point to be normalised. This is an * input/output parameter. * * \return 0 if successful */ #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P ); #endif #endif /* ECP_MONTGOMERY */ #endif /* MBEDTLS_ECP_INTERNAL_ALT */ #endif /* ecp_internal.h */
10,701
C++
.h
274
36.850365
80
0.619066
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,542
asn1write.h
w1hkj_fldigi/src/include/mbedtls/asn1write.h
/** * \file asn1write.h * * \brief ASN.1 buffer writing functionality */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ASN1_WRITE_H #define MBEDTLS_ASN1_WRITE_H #include "asn1.h" #define MBEDTLS_ASN1_CHK_ADD(g, f) \ do { \ if( ( ret = f ) < 0 ) \ return( ret ); \ else \ g += ret; \ } while( 0 ) #ifdef __cplusplus extern "C" { #endif /** * \brief Write a length field in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param len The length value to write. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len ); /** * \brief Write an ASN.1 tag in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param tag The tag to write. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag ); /** * \brief Write raw buffer data. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param buf The data buffer to write. * \param size The length of the data buffer. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size ); #if defined(MBEDTLS_BIGNUM_C) /** * \brief Write a arbitrary-precision number (#MBEDTLS_ASN1_INTEGER) * in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param X The MPI to write. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X ); #endif /* MBEDTLS_BIGNUM_C */ /** * \brief Write a NULL tag (#MBEDTLS_ASN1_NULL) with zero data * in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start ); /** * \brief Write an OID tag (#MBEDTLS_ASN1_OID) and data * in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param oid The OID to write. * \param oid_len The length of the OID. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start, const char *oid, size_t oid_len ); /** * \brief Write an AlgorithmIdentifier sequence in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param oid The OID of the algorithm to write. * \param oid_len The length of the algorithm's OID. * \param par_len The length of the parameters, which must be already written. * If 0, NULL parameters are added * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, const char *oid, size_t oid_len, size_t par_len ); /** * \brief Write a boolean tag (#MBEDTLS_ASN1_BOOLEAN) and value * in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param boolean The boolean value to write, either \c 0 or \c 1. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean ); /** * \brief Write an int tag (#MBEDTLS_ASN1_INTEGER) and value * in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param val The integer value to write. * * \return The number of bytes written to \p p on success. * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ); /** * \brief Write a string in ASN.1 format using a specific * string encoding tag. * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param tag The string encoding tag to write, e.g. * #MBEDTLS_ASN1_UTF8_STRING. * \param text The string to write. * \param text_len The length of \p text in bytes (which might * be strictly larger than the number of characters). * * \return The number of bytes written to \p p on success. * \return A negative error code on failure. */ int mbedtls_asn1_write_tagged_string( unsigned char **p, unsigned char *start, int tag, const char *text, size_t text_len ); /** * \brief Write a string in ASN.1 format using the PrintableString * string encoding tag (#MBEDTLS_ASN1_PRINTABLE_STRING). * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param text The string to write. * \param text_len The length of \p text in bytes (which might * be strictly larger than the number of characters). * * \return The number of bytes written to \p p on success. * \return A negative error code on failure. */ int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, const char *text, size_t text_len ); /** * \brief Write a UTF8 string in ASN.1 format using the UTF8String * string encoding tag (#MBEDTLS_ASN1_PRINTABLE_STRING). * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param text The string to write. * \param text_len The length of \p text in bytes (which might * be strictly larger than the number of characters). * * \return The number of bytes written to \p p on success. * \return A negative error code on failure. */ int mbedtls_asn1_write_utf8_string( unsigned char **p, unsigned char *start, const char *text, size_t text_len ); /** * \brief Write a string in ASN.1 format using the IA5String * string encoding tag (#MBEDTLS_ASN1_IA5_STRING). * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param text The string to write. * \param text_len The length of \p text in bytes (which might * be strictly larger than the number of characters). * * \return The number of bytes written to \p p on success. * \return A negative error code on failure. */ int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, const char *text, size_t text_len ); /** * \brief Write a bitstring tag (#MBEDTLS_ASN1_BIT_STRING) and * value in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param buf The bitstring to write. * \param bits The total number of bits in the bitstring. * * \return The number of bytes written to \p p on success. * \return A negative error code on failure. */ int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start, const unsigned char *buf, size_t bits ); /** * \brief Write an octet string tag (#MBEDTLS_ASN1_OCTET_STRING) * and value in ASN.1 format. * * \note This function works backwards in data buffer. * * \param p The reference to the current position pointer. * \param start The start of the buffer, for bounds-checking. * \param buf The buffer holding the data to write. * \param size The length of the data buffer \p buf. * * \return The number of bytes written to \p p on success. * \return A negative error code on failure. */ int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start, const unsigned char *buf, size_t size ); /** * \brief Create or find a specific named_data entry for writing in a * sequence or list based on the OID. If not already in there, * a new entry is added to the head of the list. * Warning: Destructive behaviour for the val data! * * \param list The pointer to the location of the head of the list to seek * through (will be updated in case of a new entry). * \param oid The OID to look for. * \param oid_len The size of the OID. * \param val The data to store (can be \c NULL if you want to fill * it by hand). * \param val_len The minimum length of the data buffer needed. * * \return A pointer to the new / existing entry on success. * \return \c NULL if if there was a memory allocation error. */ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data **list, const char *oid, size_t oid_len, const unsigned char *val, size_t val_len ); #ifdef __cplusplus } #endif #endif /* MBEDTLS_ASN1_WRITE_H */
13,460
C++
.h
303
40.023102
87
0.60475
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,543
x509_crt.h
w1hkj_fldigi/src/include/mbedtls/x509_crt.h
/** * \file x509_crt.h * * \brief X.509 certificate parsing and writing */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_X509_CRT_H #define MBEDTLS_X509_CRT_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include "x509.h" #include "x509_crl.h" /** * \addtogroup x509_module * \{ */ #ifdef __cplusplus extern "C" { #endif /** * \name Structures and functions for parsing and writing X.509 certificates * \{ */ /** * Container for an X.509 certificate. The certificate may be chained. */ typedef struct mbedtls_x509_crt { mbedtls_x509_buf raw; /**< The raw certificate data (DER). */ mbedtls_x509_buf tbs; /**< The raw certificate body (DER). The part that is To Be Signed. */ int version; /**< The X.509 version. (1=v1, 2=v2, 3=v3) */ mbedtls_x509_buf serial; /**< Unique id for certificate issued by a specific CA. */ mbedtls_x509_buf sig_oid; /**< Signature algorithm, e.g. sha1RSA */ mbedtls_x509_buf issuer_raw; /**< The raw issuer data (DER). Used for quick comparison. */ mbedtls_x509_buf subject_raw; /**< The raw subject data (DER). Used for quick comparison. */ mbedtls_x509_name issuer; /**< The parsed issuer data (named information object). */ mbedtls_x509_name subject; /**< The parsed subject data (named information object). */ mbedtls_x509_time valid_from; /**< Start time of certificate validity. */ mbedtls_x509_time valid_to; /**< End time of certificate validity. */ mbedtls_pk_context pk; /**< Container for the public key context. */ mbedtls_x509_buf issuer_id; /**< Optional X.509 v2/v3 issuer unique identifier. */ mbedtls_x509_buf subject_id; /**< Optional X.509 v2/v3 subject unique identifier. */ mbedtls_x509_buf v3_ext; /**< Optional X.509 v3 extensions. */ mbedtls_x509_sequence subject_alt_names; /**< Optional list of Subject Alternative Names (Only dNSName supported). */ int ext_types; /**< Bit string containing detected and parsed extensions */ int ca_istrue; /**< Optional Basic Constraint extension value: 1 if this certificate belongs to a CA, 0 otherwise. */ int max_pathlen; /**< Optional Basic Constraint extension value: The maximum path length to the root certificate. Path length is 1 higher than RFC 5280 'meaning', so 1+ */ unsigned int key_usage; /**< Optional key usage extension value: See the values in x509.h */ mbedtls_x509_sequence ext_key_usage; /**< Optional list of extended key usage OIDs. */ unsigned char ns_cert_type; /**< Optional Netscape certificate type extension value: See the values in x509.h */ mbedtls_x509_buf sig; /**< Signature: hash of the tbs part signed with the private key. */ mbedtls_md_type_t sig_md; /**< Internal representation of the MD algorithm of the signature algorithm, e.g. MBEDTLS_MD_SHA256 */ mbedtls_pk_type_t sig_pk; /**< Internal representation of the Public Key algorithm of the signature algorithm, e.g. MBEDTLS_PK_RSA */ void *sig_opts; /**< Signature options to be passed to mbedtls_pk_verify_ext(), e.g. for RSASSA-PSS */ struct mbedtls_x509_crt *next; /**< Next certificate in the CA-chain. */ } mbedtls_x509_crt; /** * Build flag from an algorithm/curve identifier (pk, md, ecp) * Since 0 is always XXX_NONE, ignore it. */ #define MBEDTLS_X509_ID_FLAG( id ) ( 1 << ( id - 1 ) ) /** * Security profile for certificate verification. * * All lists are bitfields, built by ORing flags from MBEDTLS_X509_ID_FLAG(). */ typedef struct mbedtls_x509_crt_profile { uint32_t allowed_mds; /**< MDs for signatures */ uint32_t allowed_pks; /**< PK algs for signatures */ uint32_t allowed_curves; /**< Elliptic curves for ECDSA */ uint32_t rsa_min_bitlen; /**< Minimum size for RSA keys */ } mbedtls_x509_crt_profile; #define MBEDTLS_X509_CRT_VERSION_1 0 #define MBEDTLS_X509_CRT_VERSION_2 1 #define MBEDTLS_X509_CRT_VERSION_3 2 #define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32 #define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15 #if !defined( MBEDTLS_X509_MAX_FILE_PATH_LEN ) #define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 #endif /** * Container for writing a certificate (CRT) */ typedef struct mbedtls_x509write_cert { int version; mbedtls_mpi serial; mbedtls_pk_context *subject_key; mbedtls_pk_context *issuer_key; mbedtls_asn1_named_data *subject; mbedtls_asn1_named_data *issuer; mbedtls_md_type_t md_alg; char not_before[MBEDTLS_X509_RFC5280_UTC_TIME_LEN + 1]; char not_after[MBEDTLS_X509_RFC5280_UTC_TIME_LEN + 1]; mbedtls_asn1_named_data *extensions; } mbedtls_x509write_cert; /** * Item in a verification chain: cert and flags for it */ typedef struct { mbedtls_x509_crt *crt; uint32_t flags; } mbedtls_x509_crt_verify_chain_item; /** * Max size of verification chain: end-entity + intermediates + trusted root */ #define MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE ( MBEDTLS_X509_MAX_INTERMEDIATE_CA + 2 ) /** * Verification chain as built by \c mbedtls_crt_verify_chain() */ typedef struct { mbedtls_x509_crt_verify_chain_item items[MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE]; unsigned len; } mbedtls_x509_crt_verify_chain; #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Context for resuming X.509 verify operations */ typedef struct { /* for check_signature() */ mbedtls_pk_restart_ctx pk; /* for find_parent_in() */ mbedtls_x509_crt *parent; /* non-null iff parent_in in progress */ mbedtls_x509_crt *fallback_parent; int fallback_signature_is_good; /* for find_parent() */ int parent_is_trusted; /* -1 if find_parent is not in progress */ /* for verify_chain() */ enum { x509_crt_rs_none, x509_crt_rs_find_parent, } in_progress; /* none if no operation is in progress */ int self_cnt; mbedtls_x509_crt_verify_chain ver_chain; } mbedtls_x509_crt_restart_ctx; #else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ /* Now we can declare functions that take a pointer to that */ typedef void mbedtls_x509_crt_restart_ctx; #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * Default security profile. Should provide a good balance between security * and compatibility with current deployments. */ extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default; /** * Expected next default profile. Recommended for new deployments. * Currently targets a 128-bit security level, except for RSA-2048. */ extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_next; /** * NSA Suite B profile. */ extern const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb; /** * \brief Parse a single DER formatted certificate and add it * to the chained list. * * \param chain points to the start of the chain * \param buf buffer holding the certificate DER data * \param buflen size of the buffer * * \return 0 if successful, or a specific X509 or PEM error code */ int mbedtls_x509_crt_parse_der( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen ); /** * \brief Parse one DER-encoded or one or more concatenated PEM-encoded * certificates and add them to the chained list. * * For CRTs in PEM encoding, the function parses permissively: * if at least one certificate can be parsed, the function * returns the number of certificates for which parsing failed * (hence \c 0 if all certificates were parsed successfully). * If no certificate could be parsed, the function returns * the first (negative) error encountered during parsing. * * PEM encoded certificates may be interleaved by other data * such as human readable descriptions of their content, as * long as the certificates are enclosed in the PEM specific * '-----{BEGIN/END} CERTIFICATE-----' delimiters. * * \param chain The chain to which to add the parsed certificates. * \param buf The buffer holding the certificate data in PEM or DER format. * For certificates in PEM encoding, this may be a concatenation * of multiple certificates; for DER encoding, the buffer must * comprise exactly one certificate. * \param buflen The size of \p buf, including the terminating \c NULL byte * in case of PEM encoded data. * * \return \c 0 if all certificates were parsed successfully. * \return The (positive) number of certificates that couldn't * be parsed if parsing was partly successful (see above). * \return A negative X509 or PEM error code otherwise. * */ int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen ); #if defined(MBEDTLS_FS_IO) /** * \brief Load one or more certificates and add them * to the chained list. Parses permissively. If some * certificates can be parsed, the result is the number * of failed certificates it encountered. If none complete * correctly, the first error is returned. * * \param chain points to the start of the chain * \param path filename to read the certificates from * * \return 0 if all certificates parsed successfully, a positive number * if partly successful or a specific X509 or PEM error code */ int mbedtls_x509_crt_parse_file( mbedtls_x509_crt *chain, const char *path ); /** * \brief Load one or more certificate files from a path and add them * to the chained list. Parses permissively. If some * certificates can be parsed, the result is the number * of failed certificates it encountered. If none complete * correctly, the first error is returned. * * \param chain points to the start of the chain * \param path directory / folder to read the certificate files from * * \return 0 if all certificates parsed successfully, a positive number * if partly successful or a specific X509 or PEM error code */ int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path ); #endif /* MBEDTLS_FS_IO */ /** * \brief Returns an informational string about the * certificate. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param prefix A line prefix * \param crt The X509 certificate to represent * * \return The length of the string written (not including the * terminated nul byte), or a negative error code. */ int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix, const mbedtls_x509_crt *crt ); /** * \brief Returns an informational string about the * verification status of a certificate. * * \param buf Buffer to write to * \param size Maximum size of buffer * \param prefix A line prefix * \param flags Verification flags created by mbedtls_x509_crt_verify() * * \return The length of the string written (not including the * terminated nul byte), or a negative error code. */ int mbedtls_x509_crt_verify_info( char *buf, size_t size, const char *prefix, uint32_t flags ); /** * \brief Verify the certificate signature * * The verify callback is a user-supplied callback that * can clear / modify / add flags for a certificate. If set, * the verification callback is called for each * certificate in the chain (from the trust-ca down to the * presented crt). The parameters for the callback are: * (void *parameter, mbedtls_x509_crt *crt, int certificate_depth, * int *flags). With the flags representing current flags for * that specific certificate and the certificate depth from * the bottom (Peer cert depth = 0). * * All flags left after returning from the callback * are also returned to the application. The function should * return 0 for anything (including invalid certificates) * other than fatal error, as a non-zero return code * immediately aborts the verification process. For fatal * errors, a specific error code should be used (different * from MBEDTLS_ERR_X509_CERT_VERIFY_FAILED which should not * be returned at this point), or MBEDTLS_ERR_X509_FATAL_ERROR * can be used if no better code is available. * * \note In case verification failed, the results can be displayed * using \c mbedtls_x509_crt_verify_info() * * \note Same as \c mbedtls_x509_crt_verify_with_profile() with the * default security profile. * * \note It is your responsibility to provide up-to-date CRLs for * all trusted CAs. If no CRL is provided for the CA that was * used to sign the certificate, CRL verification is skipped * silently, that is *without* setting any flag. * * \note The \c trust_ca list can contain two types of certificates: * (1) those of trusted root CAs, so that certificates * chaining up to those CAs will be trusted, and (2) * self-signed end-entity certificates to be trusted (for * specific peers you know) - in that case, the self-signed * certificate doesn't need to have the CA bit set. * * \param crt a certificate (chain) to be verified * \param trust_ca the list of trusted CAs (see note above) * \param ca_crl the list of CRLs for trusted CAs (see note above) * \param cn expected Common Name (can be set to * NULL if the CN must not be verified) * \param flags result of the verification * \param f_vrfy verification function * \param p_vrfy verification parameter * * \return 0 (and flags set to 0) if the chain was verified and valid, * MBEDTLS_ERR_X509_CERT_VERIFY_FAILED if the chain was verified * but found to be invalid, in which case *flags will have one * or more MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX * flags set, or another error (and flags set to 0xffffffff) * in case of a fatal error encountered during the * verification process. */ int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt, mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, const char *cn, uint32_t *flags, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy ); /** * \brief Verify the certificate signature according to profile * * \note Same as \c mbedtls_x509_crt_verify(), but with explicit * security profile. * * \note The restrictions on keys (RSA minimum size, allowed curves * for ECDSA) apply to all certificates: trusted root, * intermediate CAs if any, and end entity certificate. * * \param crt a certificate (chain) to be verified * \param trust_ca the list of trusted CAs * \param ca_crl the list of CRLs for trusted CAs * \param profile security profile for verification * \param cn expected Common Name (can be set to * NULL if the CN must not be verified) * \param flags result of the verification * \param f_vrfy verification function * \param p_vrfy verification parameter * * \return 0 if successful or MBEDTLS_ERR_X509_CERT_VERIFY_FAILED * in which case *flags will have one or more * MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX flags * set, * or another error in case of a fatal error encountered * during the verification process. */ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, const mbedtls_x509_crt_profile *profile, const char *cn, uint32_t *flags, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy ); /** * \brief Restartable version of \c mbedtls_crt_verify_with_profile() * * \note Performs the same job as \c mbedtls_crt_verify_with_profile() * but can return early and restart according to the limit * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. * * \param crt a certificate (chain) to be verified * \param trust_ca the list of trusted CAs * \param ca_crl the list of CRLs for trusted CAs * \param profile security profile for verification * \param cn expected Common Name (can be set to * NULL if the CN must not be verified) * \param flags result of the verification * \param f_vrfy verification function * \param p_vrfy verification parameter * \param rs_ctx restart context (NULL to disable restart) * * \return See \c mbedtls_crt_verify_with_profile(), or * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of * operations was reached: see \c mbedtls_ecp_set_max_ops(). */ int mbedtls_x509_crt_verify_restartable( mbedtls_x509_crt *crt, mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, const mbedtls_x509_crt_profile *profile, const char *cn, uint32_t *flags, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy, mbedtls_x509_crt_restart_ctx *rs_ctx ); #if defined(MBEDTLS_X509_CHECK_KEY_USAGE) /** * \brief Check usage of certificate against keyUsage extension. * * \param crt Leaf certificate used. * \param usage Intended usage(s) (eg MBEDTLS_X509_KU_KEY_ENCIPHERMENT * before using the certificate to perform an RSA key * exchange). * * \note Except for decipherOnly and encipherOnly, a bit set in the * usage argument means this bit MUST be set in the * certificate. For decipherOnly and encipherOnly, it means * that bit MAY be set. * * \return 0 is these uses of the certificate are allowed, * MBEDTLS_ERR_X509_BAD_INPUT_DATA if the keyUsage extension * is present but does not match the usage argument. * * \note You should only call this function on leaf certificates, on * (intermediate) CAs the keyUsage extension is automatically * checked by \c mbedtls_x509_crt_verify(). */ int mbedtls_x509_crt_check_key_usage( const mbedtls_x509_crt *crt, unsigned int usage ); #endif /* MBEDTLS_X509_CHECK_KEY_USAGE) */ #if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) /** * \brief Check usage of certificate against extendedKeyUsage. * * \param crt Leaf certificate used. * \param usage_oid Intended usage (eg MBEDTLS_OID_SERVER_AUTH or * MBEDTLS_OID_CLIENT_AUTH). * \param usage_len Length of usage_oid (eg given by MBEDTLS_OID_SIZE()). * * \return 0 if this use of the certificate is allowed, * MBEDTLS_ERR_X509_BAD_INPUT_DATA if not. * * \note Usually only makes sense on leaf certificates. */ int mbedtls_x509_crt_check_extended_key_usage( const mbedtls_x509_crt *crt, const char *usage_oid, size_t usage_len ); #endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */ #if defined(MBEDTLS_X509_CRL_PARSE_C) /** * \brief Verify the certificate revocation status * * \param crt a certificate to be verified * \param crl the CRL to verify against * * \return 1 if the certificate is revoked, 0 otherwise * */ int mbedtls_x509_crt_is_revoked( const mbedtls_x509_crt *crt, const mbedtls_x509_crl *crl ); #endif /* MBEDTLS_X509_CRL_PARSE_C */ /** * \brief Initialize a certificate (chain) * * \param crt Certificate chain to initialize */ void mbedtls_x509_crt_init( mbedtls_x509_crt *crt ); /** * \brief Unallocate all certificate data * * \param crt Certificate chain to free */ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ); #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /** * \brief Initialize a restart context */ void mbedtls_x509_crt_restart_init( mbedtls_x509_crt_restart_ctx *ctx ); /** * \brief Free the components of a restart context */ void mbedtls_x509_crt_restart_free( mbedtls_x509_crt_restart_ctx *ctx ); #endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ /* \} name */ /* \} addtogroup x509_module */ #if defined(MBEDTLS_X509_CRT_WRITE_C) /** * \brief Initialize a CRT writing context * * \param ctx CRT context to initialize */ void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx ); /** * \brief Set the verion for a Certificate * Default: MBEDTLS_X509_CRT_VERSION_3 * * \param ctx CRT context to use * \param version version to set (MBEDTLS_X509_CRT_VERSION_1, MBEDTLS_X509_CRT_VERSION_2 or * MBEDTLS_X509_CRT_VERSION_3) */ void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version ); /** * \brief Set the serial number for a Certificate. * * \param ctx CRT context to use * \param serial serial number to set * * \return 0 if successful */ int mbedtls_x509write_crt_set_serial( mbedtls_x509write_cert *ctx, const mbedtls_mpi *serial ); /** * \brief Set the validity period for a Certificate * Timestamps should be in string format for UTC timezone * i.e. "YYYYMMDDhhmmss" * e.g. "20131231235959" for December 31st 2013 * at 23:59:59 * * \param ctx CRT context to use * \param not_before not_before timestamp * \param not_after not_after timestamp * * \return 0 if timestamp was parsed successfully, or * a specific error code */ int mbedtls_x509write_crt_set_validity( mbedtls_x509write_cert *ctx, const char *not_before, const char *not_after ); /** * \brief Set the issuer name for a Certificate * Issuer names should contain a comma-separated list * of OID types and values: * e.g. "C=UK,O=ARM,CN=mbed TLS CA" * * \param ctx CRT context to use * \param issuer_name issuer name to set * * \return 0 if issuer name was parsed successfully, or * a specific error code */ int mbedtls_x509write_crt_set_issuer_name( mbedtls_x509write_cert *ctx, const char *issuer_name ); /** * \brief Set the subject name for a Certificate * Subject names should contain a comma-separated list * of OID types and values: * e.g. "C=UK,O=ARM,CN=mbed TLS Server 1" * * \param ctx CRT context to use * \param subject_name subject name to set * * \return 0 if subject name was parsed successfully, or * a specific error code */ int mbedtls_x509write_crt_set_subject_name( mbedtls_x509write_cert *ctx, const char *subject_name ); /** * \brief Set the subject public key for the certificate * * \param ctx CRT context to use * \param key public key to include */ void mbedtls_x509write_crt_set_subject_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ); /** * \brief Set the issuer key used for signing the certificate * * \param ctx CRT context to use * \param key private key to sign with */ void mbedtls_x509write_crt_set_issuer_key( mbedtls_x509write_cert *ctx, mbedtls_pk_context *key ); /** * \brief Set the MD algorithm to use for the signature * (e.g. MBEDTLS_MD_SHA1) * * \param ctx CRT context to use * \param md_alg MD algorithm to use */ void mbedtls_x509write_crt_set_md_alg( mbedtls_x509write_cert *ctx, mbedtls_md_type_t md_alg ); /** * \brief Generic function to add to or replace an extension in the * CRT * * \param ctx CRT context to use * \param oid OID of the extension * \param oid_len length of the OID * \param critical if the extension is critical (per the RFC's definition) * \param val value of the extension OCTET STRING * \param val_len length of the value data * * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED */ int mbedtls_x509write_crt_set_extension( mbedtls_x509write_cert *ctx, const char *oid, size_t oid_len, int critical, const unsigned char *val, size_t val_len ); /** * \brief Set the basicConstraints extension for a CRT * * \param ctx CRT context to use * \param is_ca is this a CA certificate * \param max_pathlen maximum length of certificate chains below this * certificate (only for CA certificates, -1 is * inlimited) * * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED */ int mbedtls_x509write_crt_set_basic_constraints( mbedtls_x509write_cert *ctx, int is_ca, int max_pathlen ); #if defined(MBEDTLS_SHA1_C) /** * \brief Set the subjectKeyIdentifier extension for a CRT * Requires that mbedtls_x509write_crt_set_subject_key() has been * called before * * \param ctx CRT context to use * * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED */ int mbedtls_x509write_crt_set_subject_key_identifier( mbedtls_x509write_cert *ctx ); /** * \brief Set the authorityKeyIdentifier extension for a CRT * Requires that mbedtls_x509write_crt_set_issuer_key() has been * called before * * \param ctx CRT context to use * * \return 0 if successful, or a MBEDTLS_ERR_X509_ALLOC_FAILED */ int mbedtls_x509write_crt_set_authority_key_identifier( mbedtls_x509write_cert *ctx ); #endif /* MBEDTLS_SHA1_C */ /** * \brief Set the Key Usage Extension flags * (e.g. MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_KEY_CERT_SIGN) * * \param ctx CRT context to use * \param key_usage key usage flags to set * * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED */ int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, unsigned int key_usage ); /** * \brief Set the Netscape Cert Type flags * (e.g. MBEDTLS_X509_NS_CERT_TYPE_SSL_CLIENT | MBEDTLS_X509_NS_CERT_TYPE_EMAIL) * * \param ctx CRT context to use * \param ns_cert_type Netscape Cert Type flags to set * * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED */ int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx, unsigned char ns_cert_type ); /** * \brief Free the contents of a CRT write context * * \param ctx CRT context to free */ void mbedtls_x509write_crt_free( mbedtls_x509write_cert *ctx ); /** * \brief Write a built up certificate to a X509 DER structure * Note: data is written at the end of the buffer! Use the * return value to determine where you should start * using the buffer * * \param ctx certificate to write away * \param buf buffer to write to * \param size size of the buffer * \param f_rng RNG function (for signature, see note) * \param p_rng RNG parameter * * \return length of data written if successful, or a specific * error code * * \note f_rng may be NULL if RSA is used for signature and the * signature is made offline (otherwise f_rng is desirable * for countermeasures against timing attacks). * ECDSA signatures always require a non-NULL f_rng. */ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #if defined(MBEDTLS_PEM_WRITE_C) /** * \brief Write a built up certificate to a X509 PEM string * * \param ctx certificate to write away * \param buf buffer to write to * \param size size of the buffer * \param f_rng RNG function (for signature, see note) * \param p_rng RNG parameter * * \return 0 if successful, or a specific error code * * \note f_rng may be NULL if RSA is used for signature and the * signature is made offline (otherwise f_rng is desirable * for countermeasures against timing attacks). * ECDSA signatures always require a non-NULL f_rng. */ int mbedtls_x509write_crt_pem( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); #endif /* MBEDTLS_PEM_WRITE_C */ #endif /* MBEDTLS_X509_CRT_WRITE_C */ #ifdef __cplusplus } #endif #endif /* mbedtls_x509_crt.h */
31,695
C++
.h
711
41.085795
186
0.632814
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,544
ecjpake.h
w1hkj_fldigi/src/include/mbedtls/ecjpake.h
/** * \file ecjpake.h * * \brief Elliptic curve J-PAKE */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_ECJPAKE_H #define MBEDTLS_ECJPAKE_H /* * J-PAKE is a password-authenticated key exchange that allows deriving a * strong shared secret from a (potentially low entropy) pre-shared * passphrase, with forward secrecy and mutual authentication. * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling * * This file implements the Elliptic Curve variant of J-PAKE, * as defined in Chapter 7.4 of the Thread v1.0 Specification, * available to members of the Thread Group http://threadgroup.org/ * * As the J-PAKE algorithm is inherently symmetric, so is our API. * Each party needs to send its first round message, in any order, to the * other party, then each sends its second round message, in any order. * The payloads are serialized in a way suitable for use in TLS, but could * also be use outside TLS. */ #include "ecp.h" #include "md.h" #ifdef __cplusplus extern "C" { #endif /** * Roles in the EC J-PAKE exchange */ typedef enum { MBEDTLS_ECJPAKE_CLIENT = 0, /**< Client */ MBEDTLS_ECJPAKE_SERVER, /**< Server */ } mbedtls_ecjpake_role; #if !defined(MBEDTLS_ECJPAKE_ALT) /** * EC J-PAKE context structure. * * J-PAKE is a symmetric protocol, except for the identifiers used in * Zero-Knowledge Proofs, and the serialization of the second message * (KeyExchange) as defined by the Thread spec. * * In order to benefit from this symmetry, we choose a different naming * convetion from the Thread v1.0 spec. Correspondance is indicated in the * description as a pair C: client name, S: server name */ typedef struct mbedtls_ecjpake_context { const mbedtls_md_info_t *md_info; /**< Hash to use */ mbedtls_ecp_group grp; /**< Elliptic curve */ mbedtls_ecjpake_role role; /**< Are we client or server? */ int point_format; /**< Format for point export */ mbedtls_ecp_point Xm1; /**< My public key 1 C: X1, S: X3 */ mbedtls_ecp_point Xm2; /**< My public key 2 C: X2, S: X4 */ mbedtls_ecp_point Xp1; /**< Peer public key 1 C: X3, S: X1 */ mbedtls_ecp_point Xp2; /**< Peer public key 2 C: X4, S: X2 */ mbedtls_ecp_point Xp; /**< Peer public key C: Xs, S: Xc */ mbedtls_mpi xm1; /**< My private key 1 C: x1, S: x3 */ mbedtls_mpi xm2; /**< My private key 2 C: x2, S: x4 */ mbedtls_mpi s; /**< Pre-shared secret (passphrase) */ } mbedtls_ecjpake_context; #else /* MBEDTLS_ECJPAKE_ALT */ #include "ecjpake_alt.h" #endif /* MBEDTLS_ECJPAKE_ALT */ /** * \brief Initialize an ECJPAKE context. * * \param ctx The ECJPAKE context to initialize. * This must not be \c NULL. */ void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx ); /** * \brief Set up an ECJPAKE context for use. * * \note Currently the only values for hash/curve allowed by the * standard are #MBEDTLS_MD_SHA256/#MBEDTLS_ECP_DP_SECP256R1. * * \param ctx The ECJPAKE context to set up. This must be initialized. * \param role The role of the caller. This must be either * #MBEDTLS_ECJPAKE_CLIENT or #MBEDTLS_ECJPAKE_SERVER. * \param hash The identifier of the hash function to use, * for example #MBEDTLS_MD_SHA256. * \param curve The identifier of the elliptic curve to use, * for example #MBEDTLS_ECP_DP_SECP256R1. * \param secret The pre-shared secret (passphrase). This must be * a readable buffer of length \p len Bytes. It need * only be valid for the duration of this call. * \param len The length of the pre-shared secret \p secret. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, mbedtls_ecjpake_role role, mbedtls_md_type_t hash, mbedtls_ecp_group_id curve, const unsigned char *secret, size_t len ); /** * \brief Check if an ECJPAKE context is ready for use. * * \param ctx The ECJPAKE context to check. This must be * initialized. * * \return \c 0 if the context is ready for use. * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise. */ int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx ); /** * \brief Generate and write the first round message * (TLS: contents of the Client/ServerHello extension, * excluding extension type and length bytes). * * \param ctx The ECJPAKE context to use. This must be * initialized and set up. * \param buf The buffer to write the contents to. This must be a * writable buffer of length \p len Bytes. * \param len The length of \p buf in Bytes. * \param olen The address at which to store the total number * of Bytes written to \p buf. This must not be \c NULL. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. This * may be \c NULL if \p f_rng doesn't use a context. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Read and process the first round message * (TLS: contents of the Client/ServerHello extension, * excluding extension type and length bytes). * * \param ctx The ECJPAKE context to use. This must be initialized * and set up. * \param buf The buffer holding the first round message. This must * be a readable buffer of length \p len Bytes. * \param len The length in Bytes of \p buf. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx, const unsigned char *buf, size_t len ); /** * \brief Generate and write the second round message * (TLS: contents of the Client/ServerKeyExchange). * * \param ctx The ECJPAKE context to use. This must be initialized, * set up, and already have performed round one. * \param buf The buffer to write the round two contents to. * This must be a writable buffer of length \p len Bytes. * \param len The size of \p buf in Bytes. * \param olen The address at which to store the total number of Bytes * written to \p buf. This must not be \c NULL. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. This * may be \c NULL if \p f_rng doesn't use a context. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Read and process the second round message * (TLS: contents of the Client/ServerKeyExchange). * * \param ctx The ECJPAKE context to use. This must be initialized * and set up and already have performed round one. * \param buf The buffer holding the second round message. This must * be a readable buffer of length \p len Bytes. * \param len The length in Bytes of \p buf. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx, const unsigned char *buf, size_t len ); /** * \brief Derive the shared secret * (TLS: Pre-Master Secret). * * \param ctx The ECJPAKE context to use. This must be initialized, * set up and have performed both round one and two. * \param buf The buffer to write the derived secret to. This must * be a writable buffer of length \p len Bytes. * \param len The length of \p buf in Bytes. * \param olen The address at which to store the total number of Bytes * written to \p buf. This must not be \c NULL. * \param f_rng The RNG function to use. This must not be \c NULL. * \param p_rng The RNG parameter to be passed to \p f_rng. This * may be \c NULL if \p f_rng doesn't use a context. * * \return \c 0 if successful. * \return A negative error code on failure. */ int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief This clears an ECJPAKE context and frees any * embedded data structure. * * \param ctx The ECJPAKE context to free. This may be \c NULL, * in which case this function does nothing. If it is not * \c NULL, it must point to an initialized ECJPAKE context. */ void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx ); #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine * * \return 0 if successful, or 1 if a test failed */ int mbedtls_ecjpake_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif #endif /* ecjpake.h */
11,397
C++
.h
250
41.46
80
0.604873
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,546
ssl_cookie.h
w1hkj_fldigi/src/include/mbedtls/ssl_cookie.h
/** * \file ssl_cookie.h * * \brief DTLS cookie callbacks implementation */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_SSL_COOKIE_H #define MBEDTLS_SSL_COOKIE_H #include "ssl.h" #if defined(MBEDTLS_THREADING_C) #include "threading.h" #endif /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. * Either change them in config.h or define them on the compiler command line. * \{ */ #ifndef MBEDTLS_SSL_COOKIE_TIMEOUT #define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ #endif /* \} name SECTION: Module settings */ #ifdef __cplusplus extern "C" { #endif /** * \brief Context for the default cookie functions. */ typedef struct mbedtls_ssl_cookie_ctx { mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */ #if !defined(MBEDTLS_HAVE_TIME) unsigned long serial; /*!< serial number for expiration */ #endif unsigned long timeout; /*!< timeout delay, in seconds if HAVE_TIME, or in number of tickets issued */ #if defined(MBEDTLS_THREADING_C) mbedtls_threading_mutex_t mutex; #endif } mbedtls_ssl_cookie_ctx; /** * \brief Initialize cookie context */ void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx ); /** * \brief Setup cookie context (generate keys) */ int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** * \brief Set expiration delay for cookies * (Default MBEDTLS_SSL_COOKIE_TIMEOUT) * * \param ctx Cookie contex * \param delay Delay, in seconds if HAVE_TIME, or in number of cookies * issued in the meantime. * 0 to disable expiration (NOT recommended) */ void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay ); /** * \brief Free cookie context */ void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ); /** * \brief Generate cookie, see \c mbedtls_ssl_cookie_write_t */ mbedtls_ssl_cookie_write_t mbedtls_ssl_cookie_write; /** * \brief Verify cookie, see \c mbedtls_ssl_cookie_write_t */ mbedtls_ssl_cookie_check_t mbedtls_ssl_cookie_check; #ifdef __cplusplus } #endif #endif /* ssl_cookie.h */
3,340
C++
.h
96
32.114583
147
0.687519
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,548
havege.h
w1hkj_fldigi/src/include/mbedtls/havege.h
/** * \file havege.h * * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_HAVEGE_H #define MBEDTLS_HAVEGE_H #include <stddef.h> #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 #ifdef __cplusplus extern "C" { #endif /** * \brief HAVEGE state structure */ typedef struct mbedtls_havege_state { int PT1, PT2, offset[2]; int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; int WALK[8192]; } mbedtls_havege_state; /** * \brief HAVEGE initialization * * \param hs HAVEGE state to be initialized */ void mbedtls_havege_init( mbedtls_havege_state *hs ); /** * \brief Clear HAVEGE state * * \param hs HAVEGE state to be cleared */ void mbedtls_havege_free( mbedtls_havege_state *hs ); /** * \brief HAVEGE rand function * * \param p_rng A HAVEGE state * \param output Buffer to fill * \param len Length of buffer * * \return 0 */ int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); #ifdef __cplusplus } #endif #endif /* havege.h */
1,968
C++
.h
68
27.029412
76
0.707033
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
true
false
false
false
false
false
false
751,549
chacha20.h
w1hkj_fldigi/src/include/mbedtls/chacha20.h
/** * \file chacha20.h * * \brief This file contains ChaCha20 definitions and functions. * * ChaCha20 is a stream cipher that can encrypt and decrypt * information. ChaCha was created by Daniel Bernstein as a variant of * its Salsa cipher https://cr.yp.to/chacha/chacha-20080128.pdf * ChaCha20 is the variant with 20 rounds, that was also standardized * in RFC 7539. * * \author Daniel King <damaki.gh@gmail.com> */ /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CHACHA20_H #define MBEDTLS_CHACHA20_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stdint.h> #include <stddef.h> #define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051 /**< Invalid input parameter(s). */ /* MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE is deprecated and should not be * used. */ #define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0053 /**< Feature not available. For example, s part of the API is not implemented. */ /* MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED -0x0055 /**< Chacha20 hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_CHACHA20_ALT) typedef struct mbedtls_chacha20_context { uint32_t state[16]; /*! The state (before round operations). */ uint8_t keystream8[64]; /*! Leftover keystream bytes. */ size_t keystream_bytes_used; /*! Number of keystream bytes already used. */ } mbedtls_chacha20_context; #else /* MBEDTLS_CHACHA20_ALT */ #include "chacha20_alt.h" #endif /* MBEDTLS_CHACHA20_ALT */ /** * \brief This function initializes the specified ChaCha20 context. * * It must be the first API called before using * the context. * * It is usually followed by calls to * \c mbedtls_chacha20_setkey() and * \c mbedtls_chacha20_starts(), then one or more calls to * to \c mbedtls_chacha20_update(), and finally to * \c mbedtls_chacha20_free(). * * \param ctx The ChaCha20 context to initialize. * This must not be \c NULL. */ void mbedtls_chacha20_init( mbedtls_chacha20_context *ctx ); /** * \brief This function releases and clears the specified * ChaCha20 context. * * \param ctx The ChaCha20 context to clear. This may be \c NULL, * in which case this function is a no-op. If it is not * \c NULL, it must point to an initialized context. * */ void mbedtls_chacha20_free( mbedtls_chacha20_context *ctx ); /** * \brief This function sets the encryption/decryption key. * * \note After using this function, you must also call * \c mbedtls_chacha20_starts() to set a nonce before you * start encrypting/decrypting data with * \c mbedtls_chacha_update(). * * \param ctx The ChaCha20 context to which the key should be bound. * It must be initialized. * \param key The encryption/decryption key. This must be \c 32 Bytes * in length. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA if ctx or key is NULL. */ int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx, const unsigned char key[32] ); /** * \brief This function sets the nonce and initial counter value. * * \note A ChaCha20 context can be re-used with the same key by * calling this function to change the nonce. * * \warning You must never use the same nonce twice with the same key. * This would void any confidentiality guarantees for the * messages encrypted with the same nonce and key. * * \param ctx The ChaCha20 context to which the nonce should be bound. * It must be initialized and bound to a key. * \param nonce The nonce. This must be \c 12 Bytes in size. * \param counter The initial counter value. This is usually \c 0. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA if ctx or nonce is * NULL. */ int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx, const unsigned char nonce[12], uint32_t counter ); /** * \brief This function encrypts or decrypts data. * * Since ChaCha20 is a stream cipher, the same operation is * used for encrypting and decrypting data. * * \note The \p input and \p output pointers must either be equal or * point to non-overlapping buffers. * * \note \c mbedtls_chacha20_setkey() and * \c mbedtls_chacha20_starts() must be called at least once * to setup the context before this function can be called. * * \note This function can be called multiple times in a row in * order to encrypt of decrypt data piecewise with the same * key and nonce. * * \param ctx The ChaCha20 context to use for encryption or decryption. * It must be initialized and bound to a key and nonce. * \param size The length of the input data in Bytes. * \param input The buffer holding the input data. * This pointer can be \c NULL if `size == 0`. * \param output The buffer holding the output data. * This must be able to hold \p size Bytes. * This pointer can be \c NULL if `size == 0`. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_chacha20_update( mbedtls_chacha20_context *ctx, size_t size, const unsigned char *input, unsigned char *output ); /** * \brief This function encrypts or decrypts data with ChaCha20 and * the given key and nonce. * * Since ChaCha20 is a stream cipher, the same operation is * used for encrypting and decrypting data. * * \warning You must never use the same (key, nonce) pair more than * once. This would void any confidentiality guarantees for * the messages encrypted with the same nonce and key. * * \note The \p input and \p output pointers must either be equal or * point to non-overlapping buffers. * * \param key The encryption/decryption key. * This must be \c 32 Bytes in length. * \param nonce The nonce. This must be \c 12 Bytes in size. * \param counter The initial counter value. This is usually \c 0. * \param size The length of the input data in Bytes. * \param input The buffer holding the input data. * This pointer can be \c NULL if `size == 0`. * \param output The buffer holding the output data. * This must be able to hold \p size Bytes. * This pointer can be \c NULL if `size == 0`. * * \return \c 0 on success. * \return A negative error code on failure. */ int mbedtls_chacha20_crypt( const unsigned char key[32], const unsigned char nonce[12], uint32_t counter, size_t size, const unsigned char* input, unsigned char* output ); #if defined(MBEDTLS_SELF_TEST) /** * \brief The ChaCha20 checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_chacha20_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_CHACHA20_H */
8,981
C++
.h
208
39.807692
141
0.619445
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,550
des.h
w1hkj_fldigi/src/include/mbedtls/des.h
/** * \file des.h * * \brief DES block cipher * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) * */ #ifndef MBEDTLS_DES_H #define MBEDTLS_DES_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> #include <stdint.h> #define MBEDTLS_DES_ENCRYPT 1 #define MBEDTLS_DES_DECRYPT 0 #define MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH -0x0032 /**< The data input has an invalid length. */ /* MBEDTLS_ERR_DES_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_DES_HW_ACCEL_FAILED -0x0033 /**< DES hardware accelerator failed. */ #define MBEDTLS_DES_KEY_SIZE 8 #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_DES_ALT) // Regular implementation // /** * \brief DES context structure * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ typedef struct mbedtls_des_context { uint32_t sk[32]; /*!< DES subkeys */ } mbedtls_des_context; /** * \brief Triple-DES context structure */ typedef struct mbedtls_des3_context { uint32_t sk[96]; /*!< 3DES subkeys */ } mbedtls_des3_context; #else /* MBEDTLS_DES_ALT */ #include "des_alt.h" #endif /* MBEDTLS_DES_ALT */ /** * \brief Initialize DES context * * \param ctx DES context to be initialized * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ void mbedtls_des_init( mbedtls_des_context *ctx ); /** * \brief Clear DES context * * \param ctx DES context to be cleared * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ void mbedtls_des_free( mbedtls_des_context *ctx ); /** * \brief Initialize Triple-DES context * * \param ctx DES3 context to be initialized */ void mbedtls_des3_init( mbedtls_des3_context *ctx ); /** * \brief Clear Triple-DES context * * \param ctx DES3 context to be cleared */ void mbedtls_des3_free( mbedtls_des3_context *ctx ); /** * \brief Set key parity on the given key to odd. * * DES keys are 56 bits long, but each byte is padded with * a parity bit to allow verification. * * \param key 8-byte secret key * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** * \brief Check that key parity on the given key is odd. * * DES keys are 56 bits long, but each byte is padded with * a parity bit to allow verification. * * \param key 8-byte secret key * * \return 0 is parity was ok, 1 if parity was not correct. * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** * \brief Check that key is not a weak or semi-weak DES key * * \param key 8-byte secret key * * \return 0 if no weak key was found, 1 if a weak key was identified. * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** * \brief DES key schedule (56-bit, encryption) * * \param ctx DES context to be initialized * \param key 8-byte secret key * * \return 0 * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** * \brief DES key schedule (56-bit, decryption) * * \param ctx DES context to be initialized * \param key 8-byte secret key * * \return 0 * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** * \brief Triple-DES key schedule (112-bit, encryption) * * \param ctx 3DES context to be initialized * \param key 16-byte secret key * * \return 0 */ int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); /** * \brief Triple-DES key schedule (112-bit, decryption) * * \param ctx 3DES context to be initialized * \param key 16-byte secret key * * \return 0 */ int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2] ); /** * \brief Triple-DES key schedule (168-bit, encryption) * * \param ctx 3DES context to be initialized * \param key 24-byte secret key * * \return 0 */ int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); /** * \brief Triple-DES key schedule (168-bit, decryption) * * \param ctx 3DES context to be initialized * \param key 24-byte secret key * * \return 0 */ int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3] ); /** * \brief DES-ECB block encryption/decryption * * \param ctx DES context * \param input 64-bit input block * \param output 64-bit output block * * \return 0 if successful * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx, const unsigned char input[8], unsigned char output[8] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief DES-CBC buffer encryption/decryption * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If on the other hand you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * \param ctx DES context * \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ /** * \brief 3DES-ECB block encryption/decryption * * \param ctx 3DES context * \param input 64-bit input block * \param output 64-bit output block * * \return 0 if successful */ int mbedtls_des3_crypt_ecb( mbedtls_des3_context *ctx, const unsigned char input[8], unsigned char output[8] ); #if defined(MBEDTLS_CIPHER_MODE_CBC) /** * \brief 3DES-CBC buffer encryption/decryption * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following * block(s) of data and get the same result as if it was * encrypted in one call. This allows a "streaming" usage. * If on the other hand you need to retain the contents of the * IV, you should either save it manually or use the cipher * module instead. * * \param ctx 3DES context * \param mode MBEDTLS_DES_ENCRYPT or MBEDTLS_DES_DECRYPT * \param length length of the input data * \param iv initialization vector (updated after use) * \param input buffer holding the input data * \param output buffer holding the output data * * \return 0 if successful, or MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH */ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, int mode, size_t length, unsigned char iv[8], const unsigned char *input, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ /** * \brief Internal function for key expansion. * (Only exposed to allow overriding it, * see MBEDTLS_DES_SETKEY_ALT) * * \param SK Round keys * \param key Base key * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. */ void mbedtls_des_setkey( uint32_t SK[32], const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed */ int mbedtls_des_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* des.h */
11,462
C++
.h
322
32.549689
112
0.628196
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,551
pkcs11.h
w1hkj_fldigi/src/include/mbedtls/pkcs11.h
/** * \file pkcs11.h * * \brief Wrapper for PKCS#11 library libpkcs11-helper * * \author Adriaan de Jong <dejong@fox-it.com> */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_PKCS11_H #define MBEDTLS_PKCS11_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #if defined(MBEDTLS_PKCS11_C) #include "x509_crt.h" #include <pkcs11-helper-1.0/pkcs11h-certificate.h> #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline #endif #ifdef __cplusplus extern "C" { #endif /** * Context for PKCS #11 private keys. */ typedef struct mbedtls_pkcs11_context { pkcs11h_certificate_t pkcs11h_cert; int len; } mbedtls_pkcs11_context; /** * Initialize a mbedtls_pkcs11_context. * (Just making memory references valid.) */ void mbedtls_pkcs11_init( mbedtls_pkcs11_context *ctx ); /** * Fill in a mbed TLS certificate, based on the given PKCS11 helper certificate. * * \param cert X.509 certificate to fill * \param pkcs11h_cert PKCS #11 helper certificate * * \return 0 on success. */ int mbedtls_pkcs11_x509_cert_bind( mbedtls_x509_crt *cert, pkcs11h_certificate_t pkcs11h_cert ); /** * Set up a mbedtls_pkcs11_context storing the given certificate. Note that the * mbedtls_pkcs11_context will take over control of the certificate, freeing it when * done. * * \param priv_key Private key structure to fill. * \param pkcs11_cert PKCS #11 helper certificate * * \return 0 on success */ int mbedtls_pkcs11_priv_key_bind( mbedtls_pkcs11_context *priv_key, pkcs11h_certificate_t pkcs11_cert ); /** * Free the contents of the given private key context. Note that the structure * itself is not freed. * * \param priv_key Private key structure to cleanup */ void mbedtls_pkcs11_priv_key_free( mbedtls_pkcs11_context *priv_key ); /** * \brief Do an RSA private key decrypt, then remove the message * padding * * \param ctx PKCS #11 context * \param mode must be MBEDTLS_RSA_PRIVATE, for compatibility with rsa.c's signature * \param input buffer holding the encrypted data * \param output buffer that will hold the plaintext * \param olen will contain the plaintext length * \param output_max_len maximum length of the output buffer * * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code * * \note The output buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise * an error is thrown. */ int mbedtls_pkcs11_decrypt( mbedtls_pkcs11_context *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ); /** * \brief Do a private RSA to sign a message digest * * \param ctx PKCS #11 context * \param mode must be MBEDTLS_RSA_PRIVATE, for compatibility with rsa.c's signature * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data) * \param hashlen message digest length (for MBEDTLS_MD_NONE only) * \param hash buffer holding the message digest * \param sig buffer that will hold the ciphertext * * \return 0 if the signing operation was successful, * or an MBEDTLS_ERR_RSA_XXX error code * * \note The "sig" buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int mbedtls_pkcs11_sign( mbedtls_pkcs11_context *ctx, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ); /** * SSL/TLS wrappers for PKCS#11 functions */ static inline int mbedtls_ssl_pkcs11_decrypt( void *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len ) { return mbedtls_pkcs11_decrypt( (mbedtls_pkcs11_context *) ctx, mode, olen, input, output, output_max_len ); } static inline int mbedtls_ssl_pkcs11_sign( void *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig ) { ((void) f_rng); ((void) p_rng); return mbedtls_pkcs11_sign( (mbedtls_pkcs11_context *) ctx, mode, md_alg, hashlen, hash, sig ); } static inline size_t mbedtls_ssl_pkcs11_key_len( void *ctx ) { return ( (mbedtls_pkcs11_context *) ctx )->len; } #ifdef __cplusplus } #endif #endif /* MBEDTLS_PKCS11_C */ #endif /* MBEDTLS_PKCS11_H */
5,805
C++
.h
158
32.544304
96
0.660981
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,552
arc4.h
w1hkj_fldigi/src/include/mbedtls/arc4.h
/** * \file arc4.h * * \brief The ARCFOUR stream cipher * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) * */ #ifndef MBEDTLS_ARC4_H #define MBEDTLS_ARC4_H #if !defined(MBEDTLS_CONFIG_FILE) #include "config.h" #else #include MBEDTLS_CONFIG_FILE #endif #include <stddef.h> /* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_ARC4_ALT) // Regular implementation // /** * \brief ARC4 context structure * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. * */ typedef struct mbedtls_arc4_context { int x; /*!< permutation index */ int y; /*!< permutation index */ unsigned char m[256]; /*!< permutation table */ } mbedtls_arc4_context; #else /* MBEDTLS_ARC4_ALT */ #include "arc4_alt.h" #endif /* MBEDTLS_ARC4_ALT */ /** * \brief Initialize ARC4 context * * \param ctx ARC4 context to be initialized * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. * */ void mbedtls_arc4_init( mbedtls_arc4_context *ctx ); /** * \brief Clear ARC4 context * * \param ctx ARC4 context to be cleared * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. * */ void mbedtls_arc4_free( mbedtls_arc4_context *ctx ); /** * \brief ARC4 key schedule * * \param ctx ARC4 context to be setup * \param key the secret key * \param keylen length of the key, in bytes * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. * */ void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, unsigned int keylen ); /** * \brief ARC4 cipher function * * \param ctx ARC4 context * \param length length of the input data * \param input buffer holding the input data * \param output buffer for the output data * * \return 0 if successful * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. * */ int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output ); /** * \brief Checkup routine * * \return 0 if successful, or 1 if the test failed * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers * instead. * */ int mbedtls_arc4_self_test( int verbose ); #ifdef __cplusplus } #endif #endif /* arc4.h */
4,230
C++
.h
130
30.430769
108
0.665198
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,554
ccm.h
w1hkj_fldigi/src/include/mbedtls/ccm.h
/** * \file ccm.h * * \brief This file provides an API for the CCM authenticated encryption * mode for block ciphers. * * CCM combines Counter mode encryption with CBC-MAC authentication * for 128-bit block ciphers. * * Input to CCM includes the following elements: * <ul><li>Payload - data that is both authenticated and encrypted.</li> * <li>Associated data (Adata) - data that is authenticated but not * encrypted, For example, a header.</li> * <li>Nonce - A unique value that is assigned to the payload and the * associated data.</li></ul> * * Definition of CCM: * http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf * RFC 3610 "Counter with CBC-MAC (CCM)" * * Related: * RFC 5116 "An Interface and Algorithms for Authenticated Encryption" * * Definition of CCM*: * IEEE 802.15.4 - IEEE Standard for Local and metropolitan area networks * Integer representation is fixed most-significant-octet-first order and * the representation of octets is most-significant-bit-first order. This is * consistent with RFC 3610. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of Mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CCM_H #define MBEDTLS_CCM_H #include "cipher.h" #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to the function. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */ /* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011 /**< CCM hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif #if !defined(MBEDTLS_CCM_ALT) // Regular implementation // /** * \brief The CCM context-type definition. The CCM context is passed * to the APIs called. */ typedef struct mbedtls_ccm_context { mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */ } mbedtls_ccm_context; #else /* MBEDTLS_CCM_ALT */ #include "ccm_alt.h" #endif /* MBEDTLS_CCM_ALT */ /** * \brief This function initializes the specified CCM context, * to make references valid, and prepare the context * for mbedtls_ccm_setkey() or mbedtls_ccm_free(). * * \param ctx The CCM context to initialize. This must not be \c NULL. */ void mbedtls_ccm_init( mbedtls_ccm_context *ctx ); /** * \brief This function initializes the CCM context set in the * \p ctx parameter and sets the encryption key. * * \param ctx The CCM context to initialize. This must be an initialized * context. * \param cipher The 128-bit block cipher to use. * \param key The encryption key. This must not be \c NULL. * \param keybits The key size in bits. This must be acceptable by the cipher. * * \return \c 0 on success. * \return A CCM or cipher-specific error code on failure. */ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits ); /** * \brief This function releases and clears the specified CCM context * and underlying cipher sub-context. * * \param ctx The CCM context to clear. If this is \c NULL, the function * has no effect. Otherwise, this must be initialized. */ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ); /** * \brief This function encrypts a buffer using CCM. * * \note The tag is written to a separate buffer. To concatenate * the \p tag with the \p output, as done in <em>RFC-3610: * Counter with CBC-MAC (CCM)</em>, use * \p tag = \p output + \p length, and make sure that the * output buffer is at least \p length + \p tag_len wide. * * \param ctx The CCM context to use for encryption. This must be * initialized and bound to a key. * \param length The length of the input data in Bytes. * \param iv The initialization vector (nonce). This must be a readable * buffer of at least \p iv_len Bytes. * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, * or 13. The length L of the message length field is * 15 - \p iv_len. * \param add The additional data field. If \p add_len is greater than * zero, \p add must be a readable buffer of at least that * length. * \param add_len The length of additional data in Bytes. * This must be less than `2^16 - 2^8`. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. * \param output The buffer holding the output data. If \p length is greater * than zero, \p output must be a writable buffer of at least * that length. * \param tag The buffer holding the authentication field. This must be a * readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the authentication field to generate in Bytes: * 4, 6, 8, 10, 12, 14 or 16. * * \return \c 0 on success. * \return A CCM or cipher-specific error code on failure. */ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len ); /** * \brief This function encrypts a buffer using CCM*. * * \note The tag is written to a separate buffer. To concatenate * the \p tag with the \p output, as done in <em>RFC-3610: * Counter with CBC-MAC (CCM)</em>, use * \p tag = \p output + \p length, and make sure that the * output buffer is at least \p length + \p tag_len wide. * * \note When using this function in a variable tag length context, * the tag length has to be encoded into the \p iv passed to * this function. * * \param ctx The CCM context to use for encryption. This must be * initialized and bound to a key. * \param length The length of the input data in Bytes. * \param iv The initialization vector (nonce). This must be a readable * buffer of at least \p iv_len Bytes. * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, * or 13. The length L of the message length field is * 15 - \p iv_len. * \param add The additional data field. This must be a readable buffer of * at least \p add_len Bytes. * \param add_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. * \param output The buffer holding the output data. If \p length is greater * than zero, \p output must be a writable buffer of at least * that length. * \param tag The buffer holding the authentication field. This must be a * readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the authentication field to generate in Bytes: * 0, 4, 6, 8, 10, 12, 14 or 16. * * \warning Passing \c 0 as \p tag_len means that the message is no * longer authenticated. * * \return \c 0 on success. * \return A CCM or cipher-specific error code on failure. */ int mbedtls_ccm_star_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len ); /** * \brief This function performs a CCM authenticated decryption of a * buffer. * * \param ctx The CCM context to use for decryption. This must be * initialized and bound to a key. * \param length The length of the input data in Bytes. * \param iv The initialization vector (nonce). This must be a readable * buffer of at least \p iv_len Bytes. * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, * or 13. The length L of the message length field is * 15 - \p iv_len. * \param add The additional data field. This must be a readable buffer * of at least that \p add_len Bytes.. * \param add_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. * \param output The buffer holding the output data. If \p length is greater * than zero, \p output must be a writable buffer of at least * that length. * \param tag The buffer holding the authentication field. This must be a * readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the authentication field to generate in Bytes: * 4, 6, 8, 10, 12, 14 or 16. * * \return \c 0 on success. This indicates that the message is authentic. * \return #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match. * \return A cipher-specific error code on calculation failure. */ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len ); /** * \brief This function performs a CCM* authenticated decryption of a * buffer. * * \note When using this function in a variable tag length context, * the tag length has to be decoded from \p iv and passed to * this function as \p tag_len. (\p tag needs to be adjusted * accordingly.) * * \param ctx The CCM context to use for decryption. This must be * initialized and bound to a key. * \param length The length of the input data in Bytes. * \param iv The initialization vector (nonce). This must be a readable * buffer of at least \p iv_len Bytes. * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, * or 13. The length L of the message length field is * 15 - \p iv_len. * \param add The additional data field. This must be a readable buffer of * at least that \p add_len Bytes. * \param add_len The length of additional data in Bytes. * This must be less than 2^16 - 2^8. * \param input The buffer holding the input data. If \p length is greater * than zero, \p input must be a readable buffer of at least * that length. * \param output The buffer holding the output data. If \p length is greater * than zero, \p output must be a writable buffer of at least * that length. * \param tag The buffer holding the authentication field. This must be a * readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the authentication field in Bytes. * 0, 4, 6, 8, 10, 12, 14 or 16. * * \warning Passing \c 0 as \p tag_len means that the message is nos * longer authenticated. * * \return \c 0 on success. * \return #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match. * \return A cipher-specific error code on calculation failure. */ int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len ); #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) /** * \brief The CCM checkup routine. * * \return \c 0 on success. * \return \c 1 on failure. */ int mbedtls_ccm_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ #ifdef __cplusplus } #endif #endif /* MBEDTLS_CCM_H */
14,128
C++
.h
288
45.649306
93
0.615902
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,555
config.h
w1hkj_fldigi/src/include/mbedtls/config.h
/** * \file config.h * * \brief Configuration options (set of defines) * * This set of compile-time options may be used to enable * or disable features selectively, and reduce the global * memory footprint. */ /* * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: GPL-2.0 * * 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; either version 2 of the License, or * (at your option) any later version. * * 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. * * This file is part of mbed TLS (https://tls.mbed.org) */ #ifndef MBEDTLS_CONFIG_H #define MBEDTLS_CONFIG_H #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) #define _CRT_SECURE_NO_DEPRECATE 1 #endif /** * \name SECTION: System support * * This section sets system specific settings. * \{ */ /** * \def MBEDTLS_HAVE_ASM * * The compiler has support for asm(). * * Requires support for asm() in compiler. * * Used in: * library/aria.c * library/timing.c * include/mbedtls/bn_mul.h * * Required by: * MBEDTLS_AESNI_C * MBEDTLS_PADLOCK_C * * Comment to disable the use of assembly code. */ #define MBEDTLS_HAVE_ASM /** * \def MBEDTLS_NO_UDBL_DIVISION * * The platform lacks support for double-width integer division (64-bit * division on a 32-bit platform, 128-bit division on a 64-bit platform). * * Used in: * include/mbedtls/bignum.h * library/bignum.c * * The bignum code uses double-width division to speed up some operations. * Double-width division is often implemented in software that needs to * be linked with the program. The presence of a double-width integer * type is usually detected automatically through preprocessor macros, * but the automatic detection cannot know whether the code needs to * and can be linked with an implementation of division for that type. * By default division is assumed to be usable if the type is present. * Uncomment this option to prevent the use of double-width division. * * Note that division for the native integer type is always required. * Furthermore, a 64-bit type is always required even on a 32-bit * platform, but it need not support multiplication or division. In some * cases it is also desirable to disable some double-width operations. For * example, if double-width division is implemented in software, disabling * it can reduce code size in some embedded targets. */ //#define MBEDTLS_NO_UDBL_DIVISION /** * \def MBEDTLS_NO_64BIT_MULTIPLICATION * * The platform lacks support for 32x32 -> 64-bit multiplication. * * Used in: * library/poly1305.c * * Some parts of the library may use multiplication of two unsigned 32-bit * operands with a 64-bit result in order to speed up computations. On some * platforms, this is not available in hardware and has to be implemented in * software, usually in a library provided by the toolchain. * * Sometimes it is not desirable to have to link to that library. This option * removes the dependency of that library on platforms that lack a hardware * 64-bit multiplier by embedding a software implementation in Mbed TLS. * * Note that depending on the compiler, this may decrease performance compared * to using the library function provided by the toolchain. */ //#define MBEDTLS_NO_64BIT_MULTIPLICATION /** * \def MBEDTLS_HAVE_SSE2 * * CPU supports SSE2 instruction set. * * Uncomment if the CPU supports SSE2 (IA-32 specific). */ //#define MBEDTLS_HAVE_SSE2 /** * \def MBEDTLS_HAVE_TIME * * System has time.h and time(). * The time does not need to be correct, only time differences are used, * by contrast with MBEDTLS_HAVE_TIME_DATE * * Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT, * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and * MBEDTLS_PLATFORM_STD_TIME. * * Comment if your system does not support time functions */ #define MBEDTLS_HAVE_TIME /** * \def MBEDTLS_HAVE_TIME_DATE * * System has time.h, time(), and an implementation for * mbedtls_platform_gmtime_r() (see below). * The time needs to be correct (not necesarily very accurate, but at least * the date should be correct). This is used to verify the validity period of * X.509 certificates. * * Comment if your system does not have a correct clock. * * \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that * behaves similarly to the gmtime_r() function from the C standard. Refer to * the documentation for mbedtls_platform_gmtime_r() for more information. * * \note It is possible to configure an implementation for * mbedtls_platform_gmtime_r() at compile-time by using the macro * MBEDTLS_PLATFORM_GMTIME_R_ALT. */ #define MBEDTLS_HAVE_TIME_DATE /** * \def MBEDTLS_PLATFORM_MEMORY * * Enable the memory allocation layer. * * By default mbed TLS uses the system-provided calloc() and free(). * This allows different allocators (self-implemented or provided) to be * provided to the platform abstraction layer. * * Enabling MBEDTLS_PLATFORM_MEMORY without the * MBEDTLS_PLATFORM_{FREE,CALLOC}_MACROs will provide * "mbedtls_platform_set_calloc_free()" allowing you to set an alternative calloc() and * free() function pointer at runtime. * * Enabling MBEDTLS_PLATFORM_MEMORY and specifying * MBEDTLS_PLATFORM_{CALLOC,FREE}_MACROs will allow you to specify the * alternate function at compile time. * * Requires: MBEDTLS_PLATFORM_C * * Enable this layer to allow use of alternative memory allocators. */ //#define MBEDTLS_PLATFORM_MEMORY /** * \def MBEDTLS_PLATFORM_NO_STD_FUNCTIONS * * Do not assign standard functions in the platform layer (e.g. calloc() to * MBEDTLS_PLATFORM_STD_CALLOC and printf() to MBEDTLS_PLATFORM_STD_PRINTF) * * This makes sure there are no linking errors on platforms that do not support * these functions. You will HAVE to provide alternatives, either at runtime * via the platform_set_xxx() functions or at compile time by setting * the MBEDTLS_PLATFORM_STD_XXX defines, or enabling a * MBEDTLS_PLATFORM_XXX_MACRO. * * Requires: MBEDTLS_PLATFORM_C * * Uncomment to prevent default assignment of standard functions in the * platform layer. */ //#define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS /** * \def MBEDTLS_PLATFORM_EXIT_ALT * * MBEDTLS_PLATFORM_XXX_ALT: Uncomment a macro to let mbed TLS support the * function in the platform abstraction layer. * * Example: In case you uncomment MBEDTLS_PLATFORM_PRINTF_ALT, mbed TLS will * provide a function "mbedtls_platform_set_printf()" that allows you to set an * alternative printf function pointer. * * All these define require MBEDTLS_PLATFORM_C to be defined! * * \note MBEDTLS_PLATFORM_SNPRINTF_ALT is required on Windows; * it will be enabled automatically by check_config.h * * \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as * MBEDTLS_PLATFORM_XXX_MACRO! * * Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME * * Uncomment a macro to enable alternate implementation of specific base * platform function */ //#define MBEDTLS_PLATFORM_EXIT_ALT //#define MBEDTLS_PLATFORM_TIME_ALT //#define MBEDTLS_PLATFORM_FPRINTF_ALT //#define MBEDTLS_PLATFORM_PRINTF_ALT //#define MBEDTLS_PLATFORM_SNPRINTF_ALT //#define MBEDTLS_PLATFORM_NV_SEED_ALT //#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT /** * \def MBEDTLS_DEPRECATED_WARNING * * Mark deprecated functions so that they generate a warning if used. * Functions deprecated in one version will usually be removed in the next * version. You can enable this to help you prepare the transition to a new * major version by making sure your code is not using these functions. * * This only works with GCC and Clang. With other compilers, you may want to * use MBEDTLS_DEPRECATED_REMOVED * * Uncomment to get warnings on using deprecated functions. */ //#define MBEDTLS_DEPRECATED_WARNING /** * \def MBEDTLS_DEPRECATED_REMOVED * * Remove deprecated functions so that they generate an error if used. * Functions deprecated in one version will usually be removed in the next * version. You can enable this to help you prepare the transition to a new * major version by making sure your code is not using these functions. * * Uncomment to get errors on using deprecated functions. */ //#define MBEDTLS_DEPRECATED_REMOVED /** * \def MBEDTLS_CHECK_PARAMS * * This configuration option controls whether the library validates more of * the parameters passed to it. * * When this flag is not defined, the library only attempts to validate an * input parameter if: (1) they may come from the outside world (such as the * network, the filesystem, etc.) or (2) not validating them could result in * internal memory errors such as overflowing a buffer controlled by the * library. On the other hand, it doesn't attempt to validate parameters whose * values are fully controlled by the application (such as pointers). * * When this flag is defined, the library additionally attempts to validate * parameters that are fully controlled by the application, and should always * be valid if the application code is fully correct and trusted. * * For example, when a function accepts as input a pointer to a buffer that may * contain untrusted data, and its documentation mentions that this pointer * must not be NULL: * - the pointer is checked to be non-NULL only if this option is enabled * - the content of the buffer is always validated * * When this flag is defined, if a library function receives a parameter that * is invalid, it will: * - invoke the macro MBEDTLS_PARAM_FAILED() which by default expands to a * call to the function mbedtls_param_failed() * - immediately return (with a specific error code unless the function * returns void and can't communicate an error). * * When defining this flag, you also need to: * - either provide a definition of the function mbedtls_param_failed() in * your application (see platform_util.h for its prototype) as the library * calls that function, but does not provide a default definition for it, * - or provide a different definition of the macro MBEDTLS_PARAM_FAILED() * below if the above mechanism is not flexible enough to suit your needs. * See the documentation of this macro later in this file. * * Uncomment to enable validation of application-controlled parameters. */ //#define MBEDTLS_CHECK_PARAMS /* \} name SECTION: System support */ /** * \name SECTION: mbed TLS feature support * * This section sets support for features that are or are not needed * within the modules that are enabled. * \{ */ /** * \def MBEDTLS_TIMING_ALT * * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() * * Only works if you have MBEDTLS_TIMING_C enabled. * * You will need to provide a header "timing_alt.h" and an implementation at * compile time. */ //#define MBEDTLS_TIMING_ALT /** * \def MBEDTLS_AES_ALT * * MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your * alternate core implementation of a symmetric crypto, an arithmetic or hash * module (e.g. platform specific assembly optimized implementations). Keep * in mind that the function prototypes should remain the same. * * This replaces the whole module. If you only want to replace one of the * functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags. * * Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer * provide the "struct mbedtls_aes_context" definition and omit the base * function declarations and implementations. "aes_alt.h" will be included from * "aes.h" to include the new function definitions. * * Uncomment a macro to enable alternate implementation of the corresponding * module. * * \warning MD2, MD4, MD5, ARC4, DES and SHA-1 are considered weak and their * use constitutes a security risk. If possible, we recommend * avoiding dependencies on them, and considering stronger message * digests and ciphers instead. * */ //#define MBEDTLS_AES_ALT //#define MBEDTLS_ARC4_ALT //#define MBEDTLS_ARIA_ALT //#define MBEDTLS_BLOWFISH_ALT //#define MBEDTLS_CAMELLIA_ALT //#define MBEDTLS_CCM_ALT //#define MBEDTLS_CHACHA20_ALT //#define MBEDTLS_CHACHAPOLY_ALT //#define MBEDTLS_CMAC_ALT //#define MBEDTLS_DES_ALT //#define MBEDTLS_DHM_ALT //#define MBEDTLS_ECJPAKE_ALT //#define MBEDTLS_GCM_ALT //#define MBEDTLS_NIST_KW_ALT //#define MBEDTLS_MD2_ALT //#define MBEDTLS_MD4_ALT //#define MBEDTLS_MD5_ALT //#define MBEDTLS_POLY1305_ALT //#define MBEDTLS_RIPEMD160_ALT //#define MBEDTLS_RSA_ALT //#define MBEDTLS_SHA1_ALT //#define MBEDTLS_SHA256_ALT //#define MBEDTLS_SHA512_ALT //#define MBEDTLS_XTEA_ALT /* * When replacing the elliptic curve module, pleace consider, that it is * implemented with two .c files: * - ecp.c * - ecp_curves.c * You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT * macros as described above. The only difference is that you have to make sure * that you provide functionality for both .c files. */ //#define MBEDTLS_ECP_ALT /** * \def MBEDTLS_MD2_PROCESS_ALT * * MBEDTLS__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use you * alternate core implementation of symmetric crypto or hash function. Keep in * mind that function prototypes should remain the same. * * This replaces only one function. The header file from mbed TLS is still * used, in contrast to the MBEDTLS__MODULE_NAME__ALT flags. * * Example: In case you uncomment MBEDTLS_SHA256_PROCESS_ALT, mbed TLS will * no longer provide the mbedtls_sha1_process() function, but it will still provide * the other function (using your mbedtls_sha1_process() function) and the definition * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible * with this definition. * * \note Because of a signature change, the core AES encryption and decryption routines are * currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt, * respectively. When setting up alternative implementations, these functions should * be overriden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt * must stay untouched. * * \note If you use the AES_xxx_ALT macros, then is is recommended to also set * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES * tables. * * Uncomment a macro to enable alternate implementation of the corresponding * function. * * \warning MD2, MD4, MD5, DES and SHA-1 are considered weak and their use * constitutes a security risk. If possible, we recommend avoiding * dependencies on them, and considering stronger message digests * and ciphers instead. * */ //#define MBEDTLS_MD2_PROCESS_ALT //#define MBEDTLS_MD4_PROCESS_ALT //#define MBEDTLS_MD5_PROCESS_ALT //#define MBEDTLS_RIPEMD160_PROCESS_ALT //#define MBEDTLS_SHA1_PROCESS_ALT //#define MBEDTLS_SHA256_PROCESS_ALT //#define MBEDTLS_SHA512_PROCESS_ALT //#define MBEDTLS_DES_SETKEY_ALT //#define MBEDTLS_DES_CRYPT_ECB_ALT //#define MBEDTLS_DES3_CRYPT_ECB_ALT //#define MBEDTLS_AES_SETKEY_ENC_ALT //#define MBEDTLS_AES_SETKEY_DEC_ALT //#define MBEDTLS_AES_ENCRYPT_ALT //#define MBEDTLS_AES_DECRYPT_ALT //#define MBEDTLS_ECDH_GEN_PUBLIC_ALT //#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT //#define MBEDTLS_ECDSA_VERIFY_ALT //#define MBEDTLS_ECDSA_SIGN_ALT //#define MBEDTLS_ECDSA_GENKEY_ALT /** * \def MBEDTLS_ECP_INTERNAL_ALT * * Expose a part of the internal interface of the Elliptic Curve Point module. * * MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your * alternative core implementation of elliptic curve arithmetic. Keep in mind * that function prototypes should remain the same. * * This partially replaces one function. The header file from mbed TLS is still * used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation * is still present and it is used for group structures not supported by the * alternative. * * Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT * and implementing the following functions: * unsigned char mbedtls_internal_ecp_grp_capable( * const mbedtls_ecp_group *grp ) * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ) * void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ) * The mbedtls_internal_ecp_grp_capable function should return 1 if the * replacement functions implement arithmetic for the given group and 0 * otherwise. * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_free are * called before and after each point operation and provide an opportunity to * implement optimized set up and tear down instructions. * * Example: In case you uncomment MBEDTLS_ECP_INTERNAL_ALT and * MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac * function, but will use your mbedtls_internal_ecp_double_jac if the group is * supported (your mbedtls_internal_ecp_grp_capable function returns 1 when * receives it as an argument). If the group is not supported then the original * implementation is used. The other functions and the definition of * mbedtls_ecp_group and mbedtls_ecp_point will not change, so your * implementation of mbedtls_internal_ecp_double_jac and * mbedtls_internal_ecp_grp_capable must be compatible with this definition. * * Uncomment a macro to enable alternate implementation of the corresponding * function. */ /* Required for all the functions in this section */ //#define MBEDTLS_ECP_INTERNAL_ALT /* Support for Weierstrass curves with Jacobi representation */ //#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT //#define MBEDTLS_ECP_ADD_MIXED_ALT //#define MBEDTLS_ECP_DOUBLE_JAC_ALT //#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT //#define MBEDTLS_ECP_NORMALIZE_JAC_ALT /* Support for curves with Montgomery arithmetic */ //#define MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT //#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT //#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT /** * \def MBEDTLS_TEST_NULL_ENTROPY * * Enables testing and use of mbed TLS without any configured entropy sources. * This permits use of the library on platforms before an entropy source has * been integrated (see for example the MBEDTLS_ENTROPY_HARDWARE_ALT or the * MBEDTLS_ENTROPY_NV_SEED switches). * * WARNING! This switch MUST be disabled in production builds, and is suitable * only for development. * Enabling the switch negates any security provided by the library. * * Requires MBEDTLS_ENTROPY_C, MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES * */ //#define MBEDTLS_TEST_NULL_ENTROPY /** * \def MBEDTLS_ENTROPY_HARDWARE_ALT * * Uncomment this macro to let mbed TLS use your own implementation of a * hardware entropy collector. * * Your function must be called \c mbedtls_hardware_poll(), have the same * prototype as declared in entropy_poll.h, and accept NULL as first argument. * * Uncomment to use your own hardware entropy collector. */ //#define MBEDTLS_ENTROPY_HARDWARE_ALT /** * \def MBEDTLS_AES_ROM_TABLES * * Use precomputed AES tables stored in ROM. * * Uncomment this macro to use precomputed AES tables stored in ROM. * Comment this macro to generate AES tables in RAM at runtime. * * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the * initialization time before the first AES operation can be performed. * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded * performance if ROM access is slower than RAM access. * * This option is independent of \c MBEDTLS_AES_FEWER_TABLES. * */ //#define MBEDTLS_AES_ROM_TABLES /** * \def MBEDTLS_AES_FEWER_TABLES * * Use less ROM/RAM for AES tables. * * Uncommenting this macro omits 75% of the AES tables from * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES) * by computing their values on the fly during operations * (the tables are entry-wise rotations of one another). * * Tradeoff: Uncommenting this reduces the RAM / ROM footprint * by ~6kb but at the cost of more arithmetic operations during * runtime. Specifically, one has to compare 4 accesses within * different tables to 4 accesses with additional arithmetic * operations within the same table. The performance gain/loss * depends on the system and memory details. * * This option is independent of \c MBEDTLS_AES_ROM_TABLES. * */ //#define MBEDTLS_AES_FEWER_TABLES /** * \def MBEDTLS_CAMELLIA_SMALL_MEMORY * * Use less ROM for the Camellia implementation (saves about 768 bytes). * * Uncomment this macro to use less memory for Camellia. */ //#define MBEDTLS_CAMELLIA_SMALL_MEMORY /** * \def MBEDTLS_CIPHER_MODE_CBC * * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers. */ #define MBEDTLS_CIPHER_MODE_CBC /** * \def MBEDTLS_CIPHER_MODE_CFB * * Enable Cipher Feedback mode (CFB) for symmetric ciphers. */ #define MBEDTLS_CIPHER_MODE_CFB /** * \def MBEDTLS_CIPHER_MODE_CTR * * Enable Counter Block Cipher mode (CTR) for symmetric ciphers. */ #define MBEDTLS_CIPHER_MODE_CTR /** * \def MBEDTLS_CIPHER_MODE_OFB * * Enable Output Feedback mode (OFB) for symmetric ciphers. */ #define MBEDTLS_CIPHER_MODE_OFB /** * \def MBEDTLS_CIPHER_MODE_XTS * * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. */ #define MBEDTLS_CIPHER_MODE_XTS /** * \def MBEDTLS_CIPHER_NULL_CIPHER * * Enable NULL cipher. * Warning: Only do so when you know what you are doing. This allows for * encryption or channels without any security! * * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable * the following ciphersuites: * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA * MBEDTLS_TLS_RSA_WITH_NULL_SHA256 * MBEDTLS_TLS_RSA_WITH_NULL_SHA * MBEDTLS_TLS_RSA_WITH_NULL_MD5 * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA * MBEDTLS_TLS_PSK_WITH_NULL_SHA384 * MBEDTLS_TLS_PSK_WITH_NULL_SHA256 * MBEDTLS_TLS_PSK_WITH_NULL_SHA * * Uncomment this macro to enable the NULL cipher and ciphersuites */ //#define MBEDTLS_CIPHER_NULL_CIPHER /** * \def MBEDTLS_CIPHER_PADDING_PKCS7 * * MBEDTLS_CIPHER_PADDING_XXX: Uncomment or comment macros to add support for * specific padding modes in the cipher layer with cipher modes that support * padding (e.g. CBC) * * If you disable all padding modes, only full blocks can be used with CBC. * * Enable padding modes in the cipher layer. */ #define MBEDTLS_CIPHER_PADDING_PKCS7 #define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS #define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN #define MBEDTLS_CIPHER_PADDING_ZEROS /** * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES * * Enable weak ciphersuites in SSL / TLS. * Warning: Only do so when you know what you are doing. This allows for * channels with virtually no security at all! * * This enables the following ciphersuites: * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA * * Uncomment this macro to enable weak ciphersuites * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. */ //#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES /** * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES * * Remove RC4 ciphersuites by default in SSL / TLS. * This flag removes the ciphersuites based on RC4 from the default list as * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them * explicitly. * * Uncomment this macro to remove RC4 ciphersuites by default. */ #define MBEDTLS_REMOVE_ARC4_CIPHERSUITES /** * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED * * MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve * module. By default all supported curves are enabled. * * Comment macros to disable the curve and functions for it */ #define MBEDTLS_ECP_DP_SECP192R1_ENABLED #define MBEDTLS_ECP_DP_SECP224R1_ENABLED #define MBEDTLS_ECP_DP_SECP256R1_ENABLED #define MBEDTLS_ECP_DP_SECP384R1_ENABLED #define MBEDTLS_ECP_DP_SECP521R1_ENABLED #define MBEDTLS_ECP_DP_SECP192K1_ENABLED #define MBEDTLS_ECP_DP_SECP224K1_ENABLED #define MBEDTLS_ECP_DP_SECP256K1_ENABLED #define MBEDTLS_ECP_DP_BP256R1_ENABLED #define MBEDTLS_ECP_DP_BP384R1_ENABLED #define MBEDTLS_ECP_DP_BP512R1_ENABLED #define MBEDTLS_ECP_DP_CURVE25519_ENABLED #define MBEDTLS_ECP_DP_CURVE448_ENABLED /** * \def MBEDTLS_ECP_NIST_OPTIM * * Enable specific 'modulo p' routines for each NIST prime. * Depending on the prime and architecture, makes operations 4 to 8 times * faster on the corresponding curve. * * Comment this macro to disable NIST curves optimisation. */ #define MBEDTLS_ECP_NIST_OPTIM /** * \def MBEDTLS_ECP_RESTARTABLE * * Enable "non-blocking" ECC operations that can return early and be resumed. * * This allows various functions to pause by returning * #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module, * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in * order to further progress and eventually complete their operation. This is * controlled through mbedtls_ecp_set_max_ops() which limits the maximum * number of ECC operations a function may perform before pausing; see * mbedtls_ecp_set_max_ops() for more information. * * This is useful in non-threaded environments if you want to avoid blocking * for too long on ECC (and, hence, X.509 or SSL/TLS) operations. * * Uncomment this macro to enable restartable ECC computations. * * \note This option only works with the default software implementation of * elliptic curve functionality. It is incompatible with * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT and MBEDTLS_ECDSA_XXX_ALT. */ //#define MBEDTLS_ECP_RESTARTABLE /** * \def MBEDTLS_ECDSA_DETERMINISTIC * * Enable deterministic ECDSA (RFC 6979). * Standard ECDSA is "fragile" in the sense that lack of entropy when signing * may result in a compromise of the long-term signing key. This is avoided by * the deterministic variant. * * Requires: MBEDTLS_HMAC_DRBG_C * * Comment this macro to disable deterministic ECDSA. */ #define MBEDTLS_ECDSA_DETERMINISTIC /** * \def MBEDTLS_KEY_EXCHANGE_PSK_ENABLED * * Enable the PSK based ciphersuite modes in SSL / TLS. * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED * * Enable the DHE-PSK based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_DHM_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA * * \warning Using DHE constitutes a security risk as it * is not possible to validate custom DH parameters. * If possible, it is recommended users should consider * preferring other methods of key exchange. * See dhm.h for more details. * */ #define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED * * Enable the ECDHE-PSK based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_ECDH_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED * * Enable the RSA-PSK based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, * MBEDTLS_X509_CRT_PARSE_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED * * Enable the RSA-only based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, * MBEDTLS_X509_CRT_PARSE_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 */ #define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED * * Enable the DHE-RSA based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, * MBEDTLS_X509_CRT_PARSE_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA * * \warning Using DHE constitutes a security risk as it * is not possible to validate custom DH parameters. * If possible, it is recommended users should consider * preferring other methods of key exchange. * See dhm.h for more details. * */ #define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED * * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15, * MBEDTLS_X509_CRT_PARSE_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED * * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C, * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED * * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 */ #define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED * * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS. * * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 */ #define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED * * Enable the ECJPAKE based ciphersuite modes in SSL / TLS. * * \warning This is currently experimental. EC J-PAKE support is based on the * Thread v1.0.0 specification; incompatible changes to the specification * might still happen. For this reason, this is disabled by default. * * Requires: MBEDTLS_ECJPAKE_C * MBEDTLS_SHA256_C * MBEDTLS_ECP_DP_SECP256R1_ENABLED * * This enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 */ //#define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED /** * \def MBEDTLS_PK_PARSE_EC_EXTENDED * * Enhance support for reading EC keys using variants of SEC1 not allowed by * RFC 5915 and RFC 5480. * * Currently this means parsing the SpecifiedECDomain choice of EC * parameters (only known groups are supported, not arbitrary domains, to * avoid validation issues). * * Disable if you only need to support RFC 5915 + 5480 key formats. */ #define MBEDTLS_PK_PARSE_EC_EXTENDED /** * \def MBEDTLS_ERROR_STRERROR_DUMMY * * Enable a dummy error function to make use of mbedtls_strerror() in * third party libraries easier when MBEDTLS_ERROR_C is disabled * (no effect when MBEDTLS_ERROR_C is enabled). * * You can safely disable this if MBEDTLS_ERROR_C is enabled, or if you're * not using mbedtls_strerror() or error_strerror() in your application. * * Disable if you run into name conflicts and want to really remove the * mbedtls_strerror() */ #define MBEDTLS_ERROR_STRERROR_DUMMY /** * \def MBEDTLS_GENPRIME * * Enable the prime-number generation code. * * Requires: MBEDTLS_BIGNUM_C */ #define MBEDTLS_GENPRIME /** * \def MBEDTLS_FS_IO * * Enable functions that use the filesystem. */ #define MBEDTLS_FS_IO /** * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES * * Do not add default entropy sources. These are the platform specific, * mbedtls_timing_hardclock and HAVEGE based poll functions. * * This is useful to have more control over the added entropy sources in an * application. * * Uncomment this macro to prevent loading of default entropy functions. */ //#define MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES /** * \def MBEDTLS_NO_PLATFORM_ENTROPY * * Do not use built-in platform entropy functions. * This is useful if your platform does not support * standards like the /dev/urandom or Windows CryptoAPI. * * Uncomment this macro to disable the built-in platform entropy functions. */ //#define MBEDTLS_NO_PLATFORM_ENTROPY /** * \def MBEDTLS_ENTROPY_FORCE_SHA256 * * Force the entropy accumulator to use a SHA-256 accumulator instead of the * default SHA-512 based one (if both are available). * * Requires: MBEDTLS_SHA256_C * * On 32-bit systems SHA-256 can be much faster than SHA-512. Use this option * if you have performance concerns. * * This option is only useful if both MBEDTLS_SHA256_C and * MBEDTLS_SHA512_C are defined. Otherwise the available hash module is used. */ //#define MBEDTLS_ENTROPY_FORCE_SHA256 /** * \def MBEDTLS_ENTROPY_NV_SEED * * Enable the non-volatile (NV) seed file-based entropy source. * (Also enables the NV seed read/write functions in the platform layer) * * This is crucial (if not required) on systems that do not have a * cryptographic entropy source (in hardware or kernel) available. * * Requires: MBEDTLS_ENTROPY_C, MBEDTLS_PLATFORM_C * * \note The read/write functions that are used by the entropy source are * determined in the platform layer, and can be modified at runtime and/or * compile-time depending on the flags (MBEDTLS_PLATFORM_NV_SEED_*) used. * * \note If you use the default implementation functions that read a seedfile * with regular fopen(), please make sure you make a seedfile with the * proper name (defined in MBEDTLS_PLATFORM_STD_NV_SEED_FILE) and at * least MBEDTLS_ENTROPY_BLOCK_SIZE bytes in size that can be read from * and written to or you will get an entropy source error! The default * implementation will only use the first MBEDTLS_ENTROPY_BLOCK_SIZE * bytes from the file. * * \note The entropy collector will write to the seed file before entropy is * given to an external source, to update it. */ //#define MBEDTLS_ENTROPY_NV_SEED /** * \def MBEDTLS_MEMORY_DEBUG * * Enable debugging of buffer allocator memory issues. Automatically prints * (to stderr) all (fatal) messages on memory allocation issues. Enables * function for 'debug output' of allocated memory. * * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C * * Uncomment this macro to let the buffer allocator print out error messages. */ //#define MBEDTLS_MEMORY_DEBUG /** * \def MBEDTLS_MEMORY_BACKTRACE * * Include backtrace information with each allocated block. * * Requires: MBEDTLS_MEMORY_BUFFER_ALLOC_C * GLIBC-compatible backtrace() an backtrace_symbols() support * * Uncomment this macro to include backtrace information */ //#define MBEDTLS_MEMORY_BACKTRACE /** * \def MBEDTLS_PK_RSA_ALT_SUPPORT * * Support external private RSA keys (eg from a HSM) in the PK layer. * * Comment this macro to disable support for external private RSA keys. */ #define MBEDTLS_PK_RSA_ALT_SUPPORT /** * \def MBEDTLS_PKCS1_V15 * * Enable support for PKCS#1 v1.5 encoding. * * Requires: MBEDTLS_RSA_C * * This enables support for PKCS#1 v1.5 operations. */ #define MBEDTLS_PKCS1_V15 /** * \def MBEDTLS_PKCS1_V21 * * Enable support for PKCS#1 v2.1 encoding. * * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C * * This enables support for RSAES-OAEP and RSASSA-PSS operations. */ #define MBEDTLS_PKCS1_V21 /** * \def MBEDTLS_RSA_NO_CRT * * Do not use the Chinese Remainder Theorem * for the RSA private operation. * * Uncomment this macro to disable the use of CRT in RSA. * */ //#define MBEDTLS_RSA_NO_CRT /** * \def MBEDTLS_SELF_TEST * * Enable the checkup functions (*_self_test). */ #define MBEDTLS_SELF_TEST /** * \def MBEDTLS_SHA256_SMALLER * * Enable an implementation of SHA-256 that has lower ROM footprint but also * lower performance. * * The default implementation is meant to be a reasonnable compromise between * performance and size. This version optimizes more aggressively for size at * the expense of performance. Eg on Cortex-M4 it reduces the size of * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about * 30%. * * Uncomment to enable the smaller implementation of SHA256. */ //#define MBEDTLS_SHA256_SMALLER /** * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES * * Enable sending of alert messages in case of encountered errors as per RFC. * If you choose not to send the alert messages, mbed TLS can still communicate * with other servers, only debugging of failures is harder. * * The advantage of not sending alert messages, is that no information is given * about reasons for failures thus preventing adversaries of gaining intel. * * Enable sending of all alert messages */ #define MBEDTLS_SSL_ALL_ALERT_MESSAGES /** * \def MBEDTLS_SSL_ASYNC_PRIVATE * * Enable asynchronous external private key operations in SSL. This allows * you to configure an SSL connection to call an external cryptographic * module to perform private key operations instead of performing the * operation inside the library. * */ //#define MBEDTLS_SSL_ASYNC_PRIVATE /** * \def MBEDTLS_SSL_DEBUG_ALL * * Enable the debug messages in SSL module for all issues. * Debug messages have been disabled in some places to prevent timing * attacks due to (unbalanced) debugging function calls. * * If you need all error reporting you should enable this during debugging, * but remove this for production servers that should log as well. * * Uncomment this macro to report all debug messages on errors introducing * a timing side-channel. * */ //#define MBEDTLS_SSL_DEBUG_ALL /** \def MBEDTLS_SSL_ENCRYPT_THEN_MAC * * Enable support for Encrypt-then-MAC, RFC 7366. * * This allows peers that both support it to use a more robust protection for * ciphersuites using CBC, providing deep resistance against timing attacks * on the padding or underlying cipher. * * This only affects CBC ciphersuites, and is useless if none is defined. * * Requires: MBEDTLS_SSL_PROTO_TLS1 or * MBEDTLS_SSL_PROTO_TLS1_1 or * MBEDTLS_SSL_PROTO_TLS1_2 * * Comment this macro to disable support for Encrypt-then-MAC */ #define MBEDTLS_SSL_ENCRYPT_THEN_MAC /** \def MBEDTLS_SSL_EXTENDED_MASTER_SECRET * * Enable support for Extended Master Secret, aka Session Hash * (draft-ietf-tls-session-hash-02). * * This was introduced as "the proper fix" to the Triple Handshake familiy of * attacks, but it is recommended to always use it (even if you disable * renegotiation), since it actually fixes a more fundamental issue in the * original SSL/TLS design, and has implications beyond Triple Handshake. * * Requires: MBEDTLS_SSL_PROTO_TLS1 or * MBEDTLS_SSL_PROTO_TLS1_1 or * MBEDTLS_SSL_PROTO_TLS1_2 * * Comment this macro to disable support for Extended Master Secret. */ #define MBEDTLS_SSL_EXTENDED_MASTER_SECRET /** * \def MBEDTLS_SSL_FALLBACK_SCSV * * Enable support for FALLBACK_SCSV (draft-ietf-tls-downgrade-scsv-00). * * For servers, it is recommended to always enable this, unless you support * only one version of TLS, or know for sure that none of your clients * implements a fallback strategy. * * For clients, you only need this if you're using a fallback strategy, which * is not recommended in the first place, unless you absolutely need it to * interoperate with buggy (version-intolerant) servers. * * Comment this macro to disable support for FALLBACK_SCSV */ #define MBEDTLS_SSL_FALLBACK_SCSV /** * \def MBEDTLS_SSL_HW_RECORD_ACCEL * * Enable hooking functions in SSL module for hardware acceleration of * individual records. * * Uncomment this macro to enable hooking functions. */ //#define MBEDTLS_SSL_HW_RECORD_ACCEL /** * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING * * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. * * This is a countermeasure to the BEAST attack, which also minimizes the risk * of interoperability issues compared to sending 0-length records. * * Comment this macro to disable 1/n-1 record splitting. */ #define MBEDTLS_SSL_CBC_RECORD_SPLITTING /** * \def MBEDTLS_SSL_RENEGOTIATION * * Enable support for TLS renegotiation. * * The two main uses of renegotiation are (1) refresh keys on long-lived * connections and (2) client authentication after the initial handshake. * If you don't need renegotiation, it's probably better to disable it, since * it has been associated with security issues in the past and is easy to * misuse/misunderstand. * * Comment this to disable support for renegotiation. * * \note Even if this option is disabled, both client and server are aware * of the Renegotiation Indication Extension (RFC 5746) used to * prevent the SSL renegotiation attack (see RFC 5746 Sect. 1). * (See \c mbedtls_ssl_conf_legacy_renegotiation for the * configuration of this extension). * */ #define MBEDTLS_SSL_RENEGOTIATION /** * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO * * Enable support for receiving and parsing SSLv2 Client Hello messages for the * SSL Server module (MBEDTLS_SSL_SRV_C). * * Uncomment this macro to enable support for SSLv2 Client Hello messages. */ //#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO /** * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE * * Pick the ciphersuite according to the client's preferences rather than ours * in the SSL Server module (MBEDTLS_SSL_SRV_C). * * Uncomment this macro to respect client's ciphersuite order */ //#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE /** * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH * * Enable support for RFC 6066 max_fragment_length extension in SSL. * * Comment this macro to disable support for the max_fragment_length extension */ #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH /** * \def MBEDTLS_SSL_PROTO_SSL3 * * Enable support for SSL 3.0. * * Requires: MBEDTLS_MD5_C * MBEDTLS_SHA1_C * * Comment this macro to disable support for SSL 3.0 */ //#define MBEDTLS_SSL_PROTO_SSL3 /** * \def MBEDTLS_SSL_PROTO_TLS1 * * Enable support for TLS 1.0. * * Requires: MBEDTLS_MD5_C * MBEDTLS_SHA1_C * * Comment this macro to disable support for TLS 1.0 */ #define MBEDTLS_SSL_PROTO_TLS1 /** * \def MBEDTLS_SSL_PROTO_TLS1_1 * * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). * * Requires: MBEDTLS_MD5_C * MBEDTLS_SHA1_C * * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 */ #define MBEDTLS_SSL_PROTO_TLS1_1 /** * \def MBEDTLS_SSL_PROTO_TLS1_2 * * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). * * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C * (Depends on ciphersuites) * * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 */ #define MBEDTLS_SSL_PROTO_TLS1_2 /** * \def MBEDTLS_SSL_PROTO_DTLS * * Enable support for DTLS (all available versions). * * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. * * Requires: MBEDTLS_SSL_PROTO_TLS1_1 * or MBEDTLS_SSL_PROTO_TLS1_2 * * Comment this macro to disable support for DTLS */ #define MBEDTLS_SSL_PROTO_DTLS /** * \def MBEDTLS_SSL_ALPN * * Enable support for RFC 7301 Application Layer Protocol Negotiation. * * Comment this macro to disable support for ALPN. */ #define MBEDTLS_SSL_ALPN /** * \def MBEDTLS_SSL_DTLS_ANTI_REPLAY * * Enable support for the anti-replay mechanism in DTLS. * * Requires: MBEDTLS_SSL_TLS_C * MBEDTLS_SSL_PROTO_DTLS * * \warning Disabling this is often a security risk! * See mbedtls_ssl_conf_dtls_anti_replay() for details. * * Comment this to disable anti-replay in DTLS. */ #define MBEDTLS_SSL_DTLS_ANTI_REPLAY /** * \def MBEDTLS_SSL_DTLS_HELLO_VERIFY * * Enable support for HelloVerifyRequest on DTLS servers. * * This feature is highly recommended to prevent DTLS servers being used as * amplifiers in DoS attacks against other hosts. It should always be enabled * unless you know for sure amplification cannot be a problem in the * environment in which your server operates. * * \warning Disabling this can ba a security risk! (see above) * * Requires: MBEDTLS_SSL_PROTO_DTLS * * Comment this to disable support for HelloVerifyRequest. */ #define MBEDTLS_SSL_DTLS_HELLO_VERIFY /** * \def MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE * * Enable server-side support for clients that reconnect from the same port. * * Some clients unexpectedly close the connection and try to reconnect using the * same source port. This needs special support from the server to handle the * new connection securely, as described in section 4.2.8 of RFC 6347. This * flag enables that support. * * Requires: MBEDTLS_SSL_DTLS_HELLO_VERIFY * * Comment this to disable support for clients reusing the source port. */ #define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE /** * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT * * Enable support for a limit of records with bad MAC. * * See mbedtls_ssl_conf_dtls_badmac_limit(). * * Requires: MBEDTLS_SSL_PROTO_DTLS */ #define MBEDTLS_SSL_DTLS_BADMAC_LIMIT /** * \def MBEDTLS_SSL_SESSION_TICKETS * * Enable support for RFC 5077 session tickets in SSL. * Client-side, provides full support for session tickets (maintainance of a * session store remains the responsibility of the application, though). * Server-side, you also need to provide callbacks for writing and parsing * tickets, including authenticated encryption and key management. Example * callbacks are provided by MBEDTLS_SSL_TICKET_C. * * Comment this macro to disable support for SSL session tickets */ #define MBEDTLS_SSL_SESSION_TICKETS /** * \def MBEDTLS_SSL_EXPORT_KEYS * * Enable support for exporting key block and master secret. * This is required for certain users of TLS, e.g. EAP-TLS. * * Comment this macro to disable support for key export */ #define MBEDTLS_SSL_EXPORT_KEYS /** * \def MBEDTLS_SSL_SERVER_NAME_INDICATION * * Enable support for RFC 6066 server name indication (SNI) in SSL. * * Requires: MBEDTLS_X509_CRT_PARSE_C * * Comment this macro to disable support for server name indication in SSL */ #define MBEDTLS_SSL_SERVER_NAME_INDICATION /** * \def MBEDTLS_SSL_TRUNCATED_HMAC * * Enable support for RFC 6066 truncated HMAC in SSL. * * Comment this macro to disable support for truncated HMAC in SSL */ #define MBEDTLS_SSL_TRUNCATED_HMAC /** * \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT * * Fallback to old (pre-2.7), non-conforming implementation of the truncated * HMAC extension which also truncates the HMAC key. Note that this option is * only meant for a transitory upgrade period and is likely to be removed in * a future version of the library. * * \warning The old implementation is non-compliant and has a security weakness * (2^80 brute force attack on the HMAC key used for a single, * uninterrupted connection). This should only be enabled temporarily * when (1) the use of truncated HMAC is essential in order to save * bandwidth, and (2) the peer is an Mbed TLS stack that doesn't use * the fixed implementation yet (pre-2.7). * * \deprecated This option is deprecated and will likely be removed in a * future version of Mbed TLS. * * Uncomment to fallback to old, non-compliant truncated HMAC implementation. * * Requires: MBEDTLS_SSL_TRUNCATED_HMAC */ //#define MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT /** * \def MBEDTLS_THREADING_ALT * * Provide your own alternate threading implementation. * * Requires: MBEDTLS_THREADING_C * * Uncomment this to allow your own alternate threading implementation. */ //#define MBEDTLS_THREADING_ALT /** * \def MBEDTLS_THREADING_PTHREAD * * Enable the pthread wrapper layer for the threading layer. * * Requires: MBEDTLS_THREADING_C * * Uncomment this to enable pthread mutexes. */ //#define MBEDTLS_THREADING_PTHREAD /** * \def MBEDTLS_VERSION_FEATURES * * Allow run-time checking of compile-time enabled features. Thus allowing users * to check at run-time if the library is for instance compiled with threading * support via mbedtls_version_check_feature(). * * Requires: MBEDTLS_VERSION_C * * Comment this to disable run-time checking and save ROM space */ #define MBEDTLS_VERSION_FEATURES /** * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 * * If set, the X509 parser will not break-off when parsing an X509 certificate * and encountering an extension in a v1 or v2 certificate. * * Uncomment to prevent an error. */ //#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 /** * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION * * If set, the X509 parser will not break-off when parsing an X509 certificate * and encountering an unknown critical extension. * * \warning Depending on your PKI use, enabling this can be a security risk! * * Uncomment to prevent an error. */ //#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION /** * \def MBEDTLS_X509_CHECK_KEY_USAGE * * Enable verification of the keyUsage extension (CA and leaf certificates). * * Disabling this avoids problems with mis-issued and/or misused * (intermediate) CA and leaf certificates. * * \warning Depending on your PKI use, disabling this can be a security risk! * * Comment to skip keyUsage checking for both CA and leaf certificates. */ #define MBEDTLS_X509_CHECK_KEY_USAGE /** * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE * * Enable verification of the extendedKeyUsage extension (leaf certificates). * * Disabling this avoids problems with mis-issued and/or misused certificates. * * \warning Depending on your PKI use, disabling this can be a security risk! * * Comment to skip extendedKeyUsage checking for certificates. */ #define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE /** * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT * * Enable parsing and verification of X.509 certificates, CRLs and CSRS * signed with RSASSA-PSS (aka PKCS#1 v2.1). * * Comment this macro to disallow using RSASSA-PSS in certificates. */ #define MBEDTLS_X509_RSASSA_PSS_SUPPORT /** * \def MBEDTLS_ZLIB_SUPPORT * * If set, the SSL/TLS module uses ZLIB to support compression and * decompression of packet data. * * \warning TLS-level compression MAY REDUCE SECURITY! See for example the * CRIME attack. Before enabling this option, you should examine with care if * CRIME or similar exploits may be a applicable to your use case. * * \note Currently compression can't be used with DTLS. * * \deprecated This feature is deprecated and will be removed * in the next major revision of the library. * * Used in: library/ssl_tls.c * library/ssl_cli.c * library/ssl_srv.c * * This feature requires zlib library and headers to be present. * * Uncomment to enable use of ZLIB */ //#define MBEDTLS_ZLIB_SUPPORT /* \} name SECTION: mbed TLS feature support */ /** * \name SECTION: mbed TLS modules * * This section enables or disables entire modules in mbed TLS * \{ */ /** * \def MBEDTLS_AESNI_C * * Enable AES-NI support on x86-64. * * Module: library/aesni.c * Caller: library/aes.c * * Requires: MBEDTLS_HAVE_ASM * * This modules adds support for the AES-NI instructions on x86-64 */ #define MBEDTLS_AESNI_C /** * \def MBEDTLS_AES_C * * Enable the AES block cipher. * * Module: library/aes.c * Caller: library/cipher.c * library/pem.c * library/ctr_drbg.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384 * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384 * MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA * * PEM_PARSE uses AES for decrypting encrypted keys. */ #define MBEDTLS_AES_C /** * \def MBEDTLS_ARC4_C * * Enable the ARCFOUR stream cipher. * * Module: library/arc4.c * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA * * \warning ARC4 is considered a weak cipher and its use constitutes a * security risk. If possible, we recommend avoidng dependencies on * it, and considering stronger ciphers instead. * */ #define MBEDTLS_ARC4_C /** * \def MBEDTLS_ASN1_PARSE_C * * Enable the generic ASN1 parser. * * Module: library/asn1.c * Caller: library/x509.c * library/dhm.c * library/pkcs12.c * library/pkcs5.c * library/pkparse.c */ #define MBEDTLS_ASN1_PARSE_C /** * \def MBEDTLS_ASN1_WRITE_C * * Enable the generic ASN1 writer. * * Module: library/asn1write.c * Caller: library/ecdsa.c * library/pkwrite.c * library/x509_create.c * library/x509write_crt.c * library/x509write_csr.c */ #define MBEDTLS_ASN1_WRITE_C /** * \def MBEDTLS_BASE64_C * * Enable the Base64 module. * * Module: library/base64.c * Caller: library/pem.c * * This module is required for PEM support (required by X.509). */ #define MBEDTLS_BASE64_C /** * \def MBEDTLS_BIGNUM_C * * Enable the multi-precision integer library. * * Module: library/bignum.c * Caller: library/dhm.c * library/ecp.c * library/ecdsa.c * library/rsa.c * library/rsa_internal.c * library/ssl_tls.c * * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. */ #define MBEDTLS_BIGNUM_C /** * \def MBEDTLS_BLOWFISH_C * * Enable the Blowfish block cipher. * * Module: library/blowfish.c */ #define MBEDTLS_BLOWFISH_C /** * \def MBEDTLS_CAMELLIA_C * * Enable the Camellia block cipher. * * Module: library/camellia.c * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 */ #define MBEDTLS_CAMELLIA_C /** * \def MBEDTLS_ARIA_C * * Enable the ARIA block cipher. * * Module: library/aria.c * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): * * MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 * MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 */ //#define MBEDTLS_ARIA_C /** * \def MBEDTLS_CCM_C * * Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher. * * Module: library/ccm.c * * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C * * This module enables the AES-CCM ciphersuites, if other requisites are * enabled as well. */ #define MBEDTLS_CCM_C /** * \def MBEDTLS_CERTS_C * * Enable the test certificates. * * Module: library/certs.c * Caller: * * This module is used for testing (ssl_client/server). */ #define MBEDTLS_CERTS_C /** * \def MBEDTLS_CHACHA20_C * * Enable the ChaCha20 stream cipher. * * Module: library/chacha20.c */ #define MBEDTLS_CHACHA20_C /** * \def MBEDTLS_CHACHAPOLY_C * * Enable the ChaCha20-Poly1305 AEAD algorithm. * * Module: library/chachapoly.c * * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C */ #define MBEDTLS_CHACHAPOLY_C /** * \def MBEDTLS_CIPHER_C * * Enable the generic cipher layer. * * Module: library/cipher.c * Caller: library/ssl_tls.c * * Uncomment to enable generic cipher wrappers. */ #define MBEDTLS_CIPHER_C /** * \def MBEDTLS_CMAC_C * * Enable the CMAC (Cipher-based Message Authentication Code) mode for block * ciphers. * * Module: library/cmac.c * * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C * */ //#define MBEDTLS_CMAC_C /** * \def MBEDTLS_CTR_DRBG_C * * Enable the CTR_DRBG AES-based random generator. * The CTR_DRBG generator uses AES-256 by default. * To use AES-128 instead, enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY below. * * Module: library/ctr_drbg.c * Caller: * * Requires: MBEDTLS_AES_C * * This module provides the CTR_DRBG AES random number generator. */ #define MBEDTLS_CTR_DRBG_C /** * \def MBEDTLS_DEBUG_C * * Enable the debug functions. * * Module: library/debug.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * * This module provides debugging functions. */ #define MBEDTLS_DEBUG_C /** * \def MBEDTLS_DES_C * * Enable the DES block cipher. * * Module: library/des.c * Caller: library/pem.c * library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA * * PEM_PARSE uses DES/3DES for decrypting encrypted keys. * * \warning DES is considered a weak cipher and its use constitutes a * security risk. We recommend considering stronger ciphers instead. */ #define MBEDTLS_DES_C /** * \def MBEDTLS_DHM_C * * Enable the Diffie-Hellman-Merkle module. * * Module: library/dhm.c * Caller: library/ssl_cli.c * library/ssl_srv.c * * This module is used by the following key exchanges: * DHE-RSA, DHE-PSK * * \warning Using DHE constitutes a security risk as it * is not possible to validate custom DH parameters. * If possible, it is recommended users should consider * preferring other methods of key exchange. * See dhm.h for more details. * */ #define MBEDTLS_DHM_C /** * \def MBEDTLS_ECDH_C * * Enable the elliptic curve Diffie-Hellman library. * * Module: library/ecdh.c * Caller: library/ssl_cli.c * library/ssl_srv.c * * This module is used by the following key exchanges: * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK * * Requires: MBEDTLS_ECP_C */ #define MBEDTLS_ECDH_C /** * \def MBEDTLS_ECDSA_C * * Enable the elliptic curve DSA library. * * Module: library/ecdsa.c * Caller: * * This module is used by the following key exchanges: * ECDHE-ECDSA * * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C */ #define MBEDTLS_ECDSA_C /** * \def MBEDTLS_ECJPAKE_C * * Enable the elliptic curve J-PAKE library. * * \warning This is currently experimental. EC J-PAKE support is based on the * Thread v1.0.0 specification; incompatible changes to the specification * might still happen. For this reason, this is disabled by default. * * Module: library/ecjpake.c * Caller: * * This module is used by the following key exchanges: * ECJPAKE * * Requires: MBEDTLS_ECP_C, MBEDTLS_MD_C */ //#define MBEDTLS_ECJPAKE_C /** * \def MBEDTLS_ECP_C * * Enable the elliptic curve over GF(p) library. * * Module: library/ecp.c * Caller: library/ecdh.c * library/ecdsa.c * library/ecjpake.c * * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED */ #define MBEDTLS_ECP_C /** * \def MBEDTLS_ENTROPY_C * * Enable the platform-specific entropy code. * * Module: library/entropy.c * Caller: * * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C * * This module provides a generic entropy pool */ #define MBEDTLS_ENTROPY_C /** * \def MBEDTLS_ERROR_C * * Enable error code to error string conversion. * * Module: library/error.c * Caller: * * This module enables mbedtls_strerror(). */ #define MBEDTLS_ERROR_C /** * \def MBEDTLS_GCM_C * * Enable the Galois/Counter Mode (GCM) for AES. * * Module: library/gcm.c * * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C * * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other * requisites are enabled as well. */ #define MBEDTLS_GCM_C /** * \def MBEDTLS_HAVEGE_C * * Enable the HAVEGE random generator. * * Warning: the HAVEGE random generator is not suitable for virtualized * environments * * Warning: the HAVEGE random generator is dependent on timing and specific * processor traits. It is therefore not advised to use HAVEGE as * your applications primary random generator or primary entropy pool * input. As a secondary input to your entropy pool, it IS able add * the (limited) extra entropy it provides. * * Module: library/havege.c * Caller: * * Requires: MBEDTLS_TIMING_C * * Uncomment to enable the HAVEGE random generator. */ //#define MBEDTLS_HAVEGE_C /** * \def MBEDTLS_HKDF_C * * Enable the HKDF algorithm (RFC 5869). * * Module: library/hkdf.c * Caller: * * Requires: MBEDTLS_MD_C * * This module adds support for the Hashed Message Authentication Code * (HMAC)-based key derivation function (HKDF). */ #define MBEDTLS_HKDF_C /** * \def MBEDTLS_HMAC_DRBG_C * * Enable the HMAC_DRBG random generator. * * Module: library/hmac_drbg.c * Caller: * * Requires: MBEDTLS_MD_C * * Uncomment to enable the HMAC_DRBG random number geerator. */ #define MBEDTLS_HMAC_DRBG_C /** * \def MBEDTLS_NIST_KW_C * * Enable the Key Wrapping mode for 128-bit block ciphers, * as defined in NIST SP 800-38F. Only KW and KWP modes * are supported. At the moment, only AES is approved by NIST. * * Module: library/nist_kw.c * * Requires: MBEDTLS_AES_C and MBEDTLS_CIPHER_C */ //#define MBEDTLS_NIST_KW_C /** * \def MBEDTLS_MD_C * * Enable the generic message digest layer. * * Module: library/md.c * Caller: * * Uncomment to enable generic message digest wrappers. */ #define MBEDTLS_MD_C /** * \def MBEDTLS_MD2_C * * Enable the MD2 hash algorithm. * * Module: library/md2.c * Caller: * * Uncomment to enable support for (rare) MD2-signed X.509 certs. * * \warning MD2 is considered a weak message digest and its use constitutes a * security risk. If possible, we recommend avoiding dependencies on * it, and considering stronger message digests instead. * */ //#define MBEDTLS_MD2_C /** * \def MBEDTLS_MD4_C * * Enable the MD4 hash algorithm. * * Module: library/md4.c * Caller: * * Uncomment to enable support for (rare) MD4-signed X.509 certs. * * \warning MD4 is considered a weak message digest and its use constitutes a * security risk. If possible, we recommend avoiding dependencies on * it, and considering stronger message digests instead. * */ //#define MBEDTLS_MD4_C /** * \def MBEDTLS_MD5_C * * Enable the MD5 hash algorithm. * * Module: library/md5.c * Caller: library/md.c * library/pem.c * library/ssl_tls.c * * This module is required for SSL/TLS up to version 1.1, and for TLS 1.2 * depending on the handshake parameters. Further, it is used for checking * MD5-signed certificates, and for PBKDF1 when decrypting PEM-encoded * encrypted keys. * * \warning MD5 is considered a weak message digest and its use constitutes a * security risk. If possible, we recommend avoiding dependencies on * it, and considering stronger message digests instead. * */ #define MBEDTLS_MD5_C /** * \def MBEDTLS_MEMORY_BUFFER_ALLOC_C * * Enable the buffer allocator implementation that makes use of a (stack) * based buffer to 'allocate' dynamic memory. (replaces calloc() and free() * calls) * * Module: library/memory_buffer_alloc.c * * Requires: MBEDTLS_PLATFORM_C * MBEDTLS_PLATFORM_MEMORY (to use it within mbed TLS) * * Enable this module to enable the buffer memory allocator. */ //#define MBEDTLS_MEMORY_BUFFER_ALLOC_C /** * \def MBEDTLS_NET_C * * Enable the TCP and UDP over IPv6/IPv4 networking routines. * * \note This module only works on POSIX/Unix (including Linux, BSD and OS X) * and Windows. For other platforms, you'll want to disable it, and write your * own networking callbacks to be passed to \c mbedtls_ssl_set_bio(). * * \note See also our Knowledge Base article about porting to a new * environment: * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS * * Module: library/net_sockets.c * * This module provides networking routines. */ #define MBEDTLS_NET_C /** * \def MBEDTLS_OID_C * * Enable the OID database. * * Module: library/oid.c * Caller: library/asn1write.c * library/pkcs5.c * library/pkparse.c * library/pkwrite.c * library/rsa.c * library/x509.c * library/x509_create.c * library/x509_crl.c * library/x509_crt.c * library/x509_csr.c * library/x509write_crt.c * library/x509write_csr.c * * This modules translates between OIDs and internal values. */ #define MBEDTLS_OID_C /** * \def MBEDTLS_PADLOCK_C * * Enable VIA Padlock support on x86. * * Module: library/padlock.c * Caller: library/aes.c * * Requires: MBEDTLS_HAVE_ASM * * This modules adds support for the VIA PadLock on x86. */ #define MBEDTLS_PADLOCK_C /** * \def MBEDTLS_PEM_PARSE_C * * Enable PEM decoding / parsing. * * Module: library/pem.c * Caller: library/dhm.c * library/pkparse.c * library/x509_crl.c * library/x509_crt.c * library/x509_csr.c * * Requires: MBEDTLS_BASE64_C * * This modules adds support for decoding / parsing PEM files. */ #define MBEDTLS_PEM_PARSE_C /** * \def MBEDTLS_PEM_WRITE_C * * Enable PEM encoding / writing. * * Module: library/pem.c * Caller: library/pkwrite.c * library/x509write_crt.c * library/x509write_csr.c * * Requires: MBEDTLS_BASE64_C * * This modules adds support for encoding / writing PEM files. */ #define MBEDTLS_PEM_WRITE_C /** * \def MBEDTLS_PK_C * * Enable the generic public (asymetric) key layer. * * Module: library/pk.c * Caller: library/ssl_tls.c * library/ssl_cli.c * library/ssl_srv.c * * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C * * Uncomment to enable generic public key wrappers. */ #define MBEDTLS_PK_C /** * \def MBEDTLS_PK_PARSE_C * * Enable the generic public (asymetric) key parser. * * Module: library/pkparse.c * Caller: library/x509_crt.c * library/x509_csr.c * * Requires: MBEDTLS_PK_C * * Uncomment to enable generic public key parse functions. */ #define MBEDTLS_PK_PARSE_C /** * \def MBEDTLS_PK_WRITE_C * * Enable the generic public (asymetric) key writer. * * Module: library/pkwrite.c * Caller: library/x509write.c * * Requires: MBEDTLS_PK_C * * Uncomment to enable generic public key write functions. */ #define MBEDTLS_PK_WRITE_C /** * \def MBEDTLS_PKCS5_C * * Enable PKCS#5 functions. * * Module: library/pkcs5.c * * Requires: MBEDTLS_MD_C * * This module adds support for the PKCS#5 functions. */ #define MBEDTLS_PKCS5_C /** * \def MBEDTLS_PKCS11_C * * Enable wrapper for PKCS#11 smartcard support. * * Module: library/pkcs11.c * Caller: library/pk.c * * Requires: MBEDTLS_PK_C * * This module enables SSL/TLS PKCS #11 smartcard support. * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) */ //#define MBEDTLS_PKCS11_C /** * \def MBEDTLS_PKCS12_C * * Enable PKCS#12 PBE functions. * Adds algorithms for parsing PKCS#8 encrypted private keys * * Module: library/pkcs12.c * Caller: library/pkparse.c * * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C * Can use: MBEDTLS_ARC4_C * * This module enables PKCS#12 functions. */ #define MBEDTLS_PKCS12_C /** * \def MBEDTLS_PLATFORM_C * * Enable the platform abstraction layer that allows you to re-assign * functions like calloc(), free(), snprintf(), printf(), fprintf(), exit(). * * Enabling MBEDTLS_PLATFORM_C enables to use of MBEDTLS_PLATFORM_XXX_ALT * or MBEDTLS_PLATFORM_XXX_MACRO directives, allowing the functions mentioned * above to be specified at runtime or compile time respectively. * * \note This abstraction layer must be enabled on Windows (including MSYS2) * as other module rely on it for a fixed snprintf implementation. * * Module: library/platform.c * Caller: Most other .c files * * This module enables abstraction of common (libc) functions. */ #define MBEDTLS_PLATFORM_C /** * \def MBEDTLS_POLY1305_C * * Enable the Poly1305 MAC algorithm. * * Module: library/poly1305.c * Caller: library/chachapoly.c */ #define MBEDTLS_POLY1305_C /** * \def MBEDTLS_RIPEMD160_C * * Enable the RIPEMD-160 hash algorithm. * * Module: library/ripemd160.c * Caller: library/md.c * */ #define MBEDTLS_RIPEMD160_C /** * \def MBEDTLS_RSA_C * * Enable the RSA public-key cryptosystem. * * Module: library/rsa.c * library/rsa_internal.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * library/x509.c * * This module is used by the following key exchanges: * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK * * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C */ #define MBEDTLS_RSA_C /** * \def MBEDTLS_SHA1_C * * Enable the SHA1 cryptographic hash algorithm. * * Module: library/sha1.c * Caller: library/md.c * library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * library/x509write_crt.c * * This module is required for SSL/TLS up to version 1.1, for TLS 1.2 * depending on the handshake parameters, and for SHA1-signed certificates. * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. If possible, we recommend avoiding dependencies * on it, and considering stronger message digests instead. * */ #define MBEDTLS_SHA1_C /** * \def MBEDTLS_SHA256_C * * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. * * Module: library/sha256.c * Caller: library/entropy.c * library/md.c * library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * * This module adds support for SHA-224 and SHA-256. * This module is required for the SSL/TLS 1.2 PRF function. */ #define MBEDTLS_SHA256_C /** * \def MBEDTLS_SHA512_C * * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. * * Module: library/sha512.c * Caller: library/entropy.c * library/md.c * library/ssl_cli.c * library/ssl_srv.c * * This module adds support for SHA-384 and SHA-512. */ #define MBEDTLS_SHA512_C /** * \def MBEDTLS_SSL_CACHE_C * * Enable simple SSL cache implementation. * * Module: library/ssl_cache.c * Caller: * * Requires: MBEDTLS_SSL_CACHE_C */ #define MBEDTLS_SSL_CACHE_C /** * \def MBEDTLS_SSL_COOKIE_C * * Enable basic implementation of DTLS cookies for hello verification. * * Module: library/ssl_cookie.c * Caller: */ #define MBEDTLS_SSL_COOKIE_C /** * \def MBEDTLS_SSL_TICKET_C * * Enable an implementation of TLS server-side callbacks for session tickets. * * Module: library/ssl_ticket.c * Caller: * * Requires: MBEDTLS_CIPHER_C */ #define MBEDTLS_SSL_TICKET_C /** * \def MBEDTLS_SSL_CLI_C * * Enable the SSL/TLS client code. * * Module: library/ssl_cli.c * Caller: * * Requires: MBEDTLS_SSL_TLS_C * * This module is required for SSL/TLS client support. */ #define MBEDTLS_SSL_CLI_C /** * \def MBEDTLS_SSL_SRV_C * * Enable the SSL/TLS server code. * * Module: library/ssl_srv.c * Caller: * * Requires: MBEDTLS_SSL_TLS_C * * This module is required for SSL/TLS server support. */ #define MBEDTLS_SSL_SRV_C /** * \def MBEDTLS_SSL_TLS_C * * Enable the generic SSL/TLS code. * * Module: library/ssl_tls.c * Caller: library/ssl_cli.c * library/ssl_srv.c * * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C * and at least one of the MBEDTLS_SSL_PROTO_XXX defines * * This module is required for SSL/TLS. */ #define MBEDTLS_SSL_TLS_C /** * \def MBEDTLS_THREADING_C * * Enable the threading abstraction layer. * By default mbed TLS assumes it is used in a non-threaded environment or that * contexts are not shared between threads. If you do intend to use contexts * between threads, you will need to enable this layer to prevent race * conditions. See also our Knowledge Base article about threading: * https://tls.mbed.org/kb/development/thread-safety-and-multi-threading * * Module: library/threading.c * * This allows different threading implementations (self-implemented or * provided). * * You will have to enable either MBEDTLS_THREADING_ALT or * MBEDTLS_THREADING_PTHREAD. * * Enable this layer to allow use of mutexes within mbed TLS */ //#define MBEDTLS_THREADING_C /** * \def MBEDTLS_TIMING_C * * Enable the semi-portable timing interface. * * \note The provided implementation only works on POSIX/Unix (including Linux, * BSD and OS X) and Windows. On other platforms, you can either disable that * module and provide your own implementations of the callbacks needed by * \c mbedtls_ssl_set_timer_cb() for DTLS, or leave it enabled and provide * your own implementation of the whole module by setting * \c MBEDTLS_TIMING_ALT in the current file. * * \note See also our Knowledge Base article about porting to a new * environment: * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS * * Module: library/timing.c * Caller: library/havege.c * * This module is used by the HAVEGE random number generator. */ #define MBEDTLS_TIMING_C /** * \def MBEDTLS_VERSION_C * * Enable run-time version information. * * Module: library/version.c * * This module provides run-time version information. */ #define MBEDTLS_VERSION_C /** * \def MBEDTLS_X509_USE_C * * Enable X.509 core for using certificates. * * Module: library/x509.c * Caller: library/x509_crl.c * library/x509_crt.c * library/x509_csr.c * * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, * MBEDTLS_PK_PARSE_C * * This module is required for the X.509 parsing modules. */ #define MBEDTLS_X509_USE_C /** * \def MBEDTLS_X509_CRT_PARSE_C * * Enable X.509 certificate parsing. * * Module: library/x509_crt.c * Caller: library/ssl_cli.c * library/ssl_srv.c * library/ssl_tls.c * * Requires: MBEDTLS_X509_USE_C * * This module is required for X.509 certificate parsing. */ #define MBEDTLS_X509_CRT_PARSE_C /** * \def MBEDTLS_X509_CRL_PARSE_C * * Enable X.509 CRL parsing. * * Module: library/x509_crl.c * Caller: library/x509_crt.c * * Requires: MBEDTLS_X509_USE_C * * This module is required for X.509 CRL parsing. */ #define MBEDTLS_X509_CRL_PARSE_C /** * \def MBEDTLS_X509_CSR_PARSE_C * * Enable X.509 Certificate Signing Request (CSR) parsing. * * Module: library/x509_csr.c * Caller: library/x509_crt_write.c * * Requires: MBEDTLS_X509_USE_C * * This module is used for reading X.509 certificate request. */ #define MBEDTLS_X509_CSR_PARSE_C /** * \def MBEDTLS_X509_CREATE_C * * Enable X.509 core for creating certificates. * * Module: library/x509_create.c * * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C, MBEDTLS_PK_WRITE_C * * This module is the basis for creating X.509 certificates and CSRs. */ #define MBEDTLS_X509_CREATE_C /** * \def MBEDTLS_X509_CRT_WRITE_C * * Enable creating X.509 certificates. * * Module: library/x509_crt_write.c * * Requires: MBEDTLS_X509_CREATE_C * * This module is required for X.509 certificate creation. */ #define MBEDTLS_X509_CRT_WRITE_C /** * \def MBEDTLS_X509_CSR_WRITE_C * * Enable creating X.509 Certificate Signing Requests (CSR). * * Module: library/x509_csr_write.c * * Requires: MBEDTLS_X509_CREATE_C * * This module is required for X.509 certificate request writing. */ #define MBEDTLS_X509_CSR_WRITE_C /** * \def MBEDTLS_XTEA_C * * Enable the XTEA block cipher. * * Module: library/xtea.c * Caller: */ #define MBEDTLS_XTEA_C /* \} name SECTION: mbed TLS modules */ /** * \name SECTION: Module configuration options * * This section allows for the setting of module specific sizes and * configuration options. The default values are already present in the * relevant header files and should suffice for the regular use cases. * * Our advice is to enable options and change their values here * only if you have a good reason and know the consequences. * * Please check the respective header file for documentation on these * parameters (to prevent duplicate documentation). * \{ */ /* MPI / BIGNUM options */ //#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum windows size used. */ //#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ /* CTR_DRBG options */ //#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */ //#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ //#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ //#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ //#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ //#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY /**< Use 128-bit key for CTR_DRBG - may reduce security (see ctr_drbg.h) */ /* HMAC_DRBG options */ //#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ //#define MBEDTLS_HMAC_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ //#define MBEDTLS_HMAC_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ //#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ /* ECP options */ //#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ //#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ //#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ /* Entropy options */ //#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ //#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ //#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */ /* Memory buffer allocator options */ //#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ /* Platform options */ //#define MBEDTLS_PLATFORM_STD_MEM_HDR <stdlib.h> /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ //#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ /* Note: your snprintf must correclty zero-terminate the buffer! */ //#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" /**< Seed file to read/write with default implementation */ /* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ /* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ //#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ /* Note: your snprintf must correclty zero-terminate the buffer! */ //#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ //#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ /** * \brief This macro is invoked by the library when an invalid parameter * is detected that is only checked with MBEDTLS_CHECK_PARAMS * (see the documentation of that option for context). * * When you leave this undefined here, a default definition is * provided that invokes the function mbedtls_param_failed(), * which is declared in platform_util.h for the benefit of the * library, but that you need to define in your application. * * When you define this here, this replaces the default * definition in platform_util.h (which no longer declares the * function mbedtls_param_failed()) and it is your responsibility * to make sure this macro expands to something suitable (in * particular, that all the necessary declarations are visible * from within the library - you can ensure that by providing * them in this file next to the macro definition). * * Note that you may define this macro to expand to nothing, in * which case you don't have to worry about declarations or * definitions. However, you will then be notified about invalid * parameters only in non-void functions, and void function will * just silently return early on invalid parameters, which * partially negates the benefits of enabling * #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged. * * \param cond The expression that should evaluate to true, but doesn't. */ //#define MBEDTLS_PARAM_FAILED( cond ) assert( cond ) /* SSL Cache options */ //#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ //#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ /* SSL options */ /** \def MBEDTLS_SSL_MAX_CONTENT_LEN * * Maximum length (in bytes) of incoming and outgoing plaintext fragments. * * This determines the size of both the incoming and outgoing TLS I/O buffers * in such a way that both are capable of holding the specified amount of * plaintext data, regardless of the protection mechanism used. * * To configure incoming and outgoing I/O buffers separately, use * #MBEDTLS_SSL_IN_CONTENT_LEN and #MBEDTLS_SSL_OUT_CONTENT_LEN, * which overwrite the value set by this option. * * \note When using a value less than the default of 16KB on the client, it is * recommended to use the Maximum Fragment Length (MFL) extension to * inform the server about this limitation. On the server, there * is no supported, standardized way of informing the client about * restriction on the maximum size of incoming messages, and unless * the limitation has been communicated by other means, it is recommended * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN * while keeping the default value of 16KB for the incoming buffer. * * Uncomment to set the maximum plaintext size of both * incoming and outgoing I/O buffers. */ //#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /** \def MBEDTLS_SSL_IN_CONTENT_LEN * * Maximum length (in bytes) of incoming plaintext fragments. * * This determines the size of the incoming TLS I/O buffer in such a way * that it is capable of holding the specified amount of plaintext data, * regardless of the protection mechanism used. * * If this option is undefined, it inherits its value from * #MBEDTLS_SSL_MAX_CONTENT_LEN. * * \note When using a value less than the default of 16KB on the client, it is * recommended to use the Maximum Fragment Length (MFL) extension to * inform the server about this limitation. On the server, there * is no supported, standardized way of informing the client about * restriction on the maximum size of incoming messages, and unless * the limitation has been communicated by other means, it is recommended * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN * while keeping the default value of 16KB for the incoming buffer. * * Uncomment to set the maximum plaintext size of the incoming I/O buffer * independently of the outgoing I/O buffer. */ //#define MBEDTLS_SSL_IN_CONTENT_LEN 16384 /** \def MBEDTLS_SSL_OUT_CONTENT_LEN * * Maximum length (in bytes) of outgoing plaintext fragments. * * This determines the size of the outgoing TLS I/O buffer in such a way * that it is capable of holding the specified amount of plaintext data, * regardless of the protection mechanism used. * * If this option undefined, it inherits its value from * #MBEDTLS_SSL_MAX_CONTENT_LEN. * * It is possible to save RAM by setting a smaller outward buffer, while keeping * the default inward 16384 byte buffer to conform to the TLS specification. * * The minimum required outward buffer size is determined by the handshake * protocol's usage. Handshaking will fail if the outward buffer is too small. * The specific size requirement depends on the configured ciphers and any * certificate data which is sent during the handshake. * * Uncomment to set the maximum plaintext size of the outgoing I/O buffer * independently of the incoming I/O buffer. */ //#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384 /** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING * * Maximum number of heap-allocated bytes for the purpose of * DTLS handshake message reassembly and future message buffering. * * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN * to account for a reassembled handshake message of maximum size, * together with its reassembly bitmap. * * A value of 2 * MBEDTLS_SSL_IN_CONTENT_LEN (32768 by default) * should be sufficient for all practical situations as it allows * to reassembly a large handshake message (such as a certificate) * while buffering multiple smaller handshake messages. * */ //#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 //#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ //#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ //#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ /** * Complete list of ciphersuites to use, in order of preference. * * \warning No dependency checking is done on that field! This option can only * be used to restrict the set of available ciphersuites. It is your * responsibility to make sure the needed modules are active. * * Use this to save a few hundred bytes of ROM (default ordering of all * available ciphersuites) and a few to a few hundred bytes of RAM. * * The value below is only an example, not the default. */ //#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 /* X509 options */ //#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ //#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */ /** * Allow SHA-1 in the default TLS configuration for certificate signing. * Without this build-time option, SHA-1 support must be activated explicitly * through mbedtls_ssl_conf_cert_profile. Turning on this option is not * recommended because of it is possible to generate SHA-1 collisions, however * this may be safe for legacy infrastructure where additional controls apply. * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. If possible, we recommend avoiding dependencies * on it, and considering stronger message digests instead. * */ // #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES /** * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake * signature and ciphersuite selection. Without this build-time option, SHA-1 * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes. * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by * default. At the time of writing, there is no practical attack on the use * of SHA-1 in handshake signatures, hence this option is turned on by default * to preserve compatibility with existing peers, but the general * warning applies nonetheless: * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. If possible, we recommend avoiding dependencies * on it, and considering stronger message digests instead. * */ #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE /** * Uncomment the macro to let mbed TLS use your alternate implementation of * mbedtls_platform_zeroize(). This replaces the default implementation in * platform_util.c. * * mbedtls_platform_zeroize() is a widely used function across the library to * zero a block of memory. The implementation is expected to be secure in the * sense that it has been written to prevent the compiler from removing calls * to mbedtls_platform_zeroize() as part of redundant code elimination * optimizations. However, it is difficult to guarantee that calls to * mbedtls_platform_zeroize() will not be optimized by the compiler as older * versions of the C language standards do not provide a secure implementation * of memset(). Therefore, MBEDTLS_PLATFORM_ZEROIZE_ALT enables users to * configure their own implementation of mbedtls_platform_zeroize(), for * example by using directives specific to their compiler, features from newer * C standards (e.g using memset_s() in C11) or calling a secure memset() from * their system (e.g explicit_bzero() in BSD). */ //#define MBEDTLS_PLATFORM_ZEROIZE_ALT /** * Uncomment the macro to let Mbed TLS use your alternate implementation of * mbedtls_platform_gmtime_r(). This replaces the default implementation in * platform_util.c. * * gmtime() is not a thread-safe function as defined in the C standard. The * library will try to use safer implementations of this function, such as * gmtime_r() when available. However, if Mbed TLS cannot identify the target * system, the implementation of mbedtls_platform_gmtime_r() will default to * using the standard gmtime(). In this case, calls from the library to * gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex * if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the * library are also guarded with this mutex to avoid race conditions. However, * if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will * unconditionally use the implementation for mbedtls_platform_gmtime_r() * supplied at compile time. */ //#define MBEDTLS_PLATFORM_GMTIME_R_ALT /* \} name SECTION: Customisation configuration options */ /* Target and application specific configurations * * Allow user to override any previous default. * */ #if defined(MBEDTLS_USER_CONFIG_FILE) #include MBEDTLS_USER_CONFIG_FILE #endif #include "check_config.h" #endif /* MBEDTLS_CONFIG_H */
108,699
C++
.h
3,073
33.473804
187
0.728361
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
true
true
false
false
false
false
false
false
751,556
tiniconv_int.h
w1hkj_fldigi/src/libtiniconv/tiniconv_int.h
/* * This file is part of the TINICONV Library. * * The TINICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License version 3 as published by the Free Software Foundation. */ // ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi 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, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef TINICONV_INT_H_ #define TINICONV_INT_H_ #include "tiniconv.h" #define RET_ILSEQ -1 #define RET_TOOFEW(n) (-2-(n)) #define RET_ILUNI -1 #define RET_TOOSMALL -2 extern const struct tiniconv_charset_map_entry_s { xxx_mb2wc_t mb2wc; xxx_flushwc_t flushwc; xxx_wc2mb_t wc2mb; xxx_reset_t reset; } tiniconv_charset_map[]; typedef struct { unsigned short indx; /* index into big table */ unsigned short used; /* bitmask of used entries */ } Summary16; #define TINICONV_OPTION_GET_OUT_ILSEQ_CHAR(options) ((options >> 8) & 0xFF) #endif /*TINICONV_INT_H_*/
1,488
C++
.h
40
35.55
79
0.649306
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,557
tiniconv.h
w1hkj_fldigi/src/libtiniconv/tiniconv.h
/* * This file is part of the TINICONV Library. * * The TINICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License version 2 as published by the Free Software Foundation. */ // ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi 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, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef TINICONV_H_ #define TINICONV_H_ /* For exporting functions under WIN32 */ #ifdef WIN32 #ifdef DLL #define EXPORT(type) __declspec(dllexport) type #else #define EXPORT(type) /*__declspec(dllimport)*/ type #endif/*DLL*/ #else #define EXPORT(type) type #endif /*WIN32*/ typedef unsigned int ucs4_t; typedef struct tiniconv_ctx_s * conv_t; /* * int xxx_mb2wc (conv_t conv, ucs4_t *pwc, unsigned char const *s, int n) * converts the byte sequence starting at s to a wide character. Up to n bytes * are available at s. n is >= 1. * Result is number of bytes consumed (if a wide character was read), * or -1 if invalid, or -2 if n too small, or -2-(number of bytes consumed) * if only a shift sequence was read. */ typedef int (*xxx_mb2wc_t) (conv_t conv, ucs4_t *pwc, unsigned char const *s, int n); /* * int xxx_flushwc (conv_t conv, ucs4_t *pwc) * returns to the initial state and stores the pending wide character, if any. * Result is 1 (if a wide character was read) or 0 if none was pending. */ typedef int (*xxx_flushwc_t) (conv_t conv, ucs4_t *pwc); /* * int xxx_wc2mb (conv_t conv, unsigned char *r, ucs4_t wc, int n) * converts the wide character wc to the character set xxx, and stores the * result beginning at r. Up to n bytes may be written at r. n is >= 1. * Result is number of bytes written, or -1 if invalid, or -2 if n too small. */ typedef int (*xxx_wc2mb_t) (conv_t conv, unsigned char *r, ucs4_t wc, int n); /* * int xxx_reset (conv_t conv, unsigned char *r, int n) * stores a shift sequences returning to the initial state beginning at r. * Up to n bytes may be written at r. n is >= 0. * Result is number of bytes written, or -2 if n too small. */ typedef int (*xxx_reset_t) (conv_t conv, unsigned char *r, int n); typedef unsigned int conv_state_t; struct tiniconv_ctx_s { conv_state_t istate; conv_state_t ostate; xxx_mb2wc_t mb2wc; xxx_flushwc_t flushwc; xxx_wc2mb_t wc2mb; xxx_reset_t reset; int options; }; /* * tiniconv_init */ #define TINICONV_CHARSET_ASCII 0 #define TINICONV_CHARSET_CP1250 1 #define TINICONV_CHARSET_CP1251 2 #define TINICONV_CHARSET_CP1252 3 #define TINICONV_CHARSET_CP1253 4 #define TINICONV_CHARSET_CP1254 5 #define TINICONV_CHARSET_CP1255 6 #define TINICONV_CHARSET_CP1256 7 #define TINICONV_CHARSET_CP1257 8 #define TINICONV_CHARSET_CP1258 9 #define TINICONV_CHARSET_CP936 10 #define TINICONV_CHARSET_GB2312 11 #define TINICONV_CHARSET_GBK 12 #define TINICONV_CHARSET_ISO_2022_JP 13 #define TINICONV_CHARSET_ISO_8859_1 14 #define TINICONV_CHARSET_ISO_8859_2 15 #define TINICONV_CHARSET_ISO_8859_3 16 #define TINICONV_CHARSET_ISO_8859_4 17 #define TINICONV_CHARSET_ISO_8859_5 18 #define TINICONV_CHARSET_ISO_8859_6 19 #define TINICONV_CHARSET_ISO_8859_7 20 #define TINICONV_CHARSET_ISO_8859_8 21 #define TINICONV_CHARSET_ISO_8859_9 22 #define TINICONV_CHARSET_ISO_8859_10 23 #define TINICONV_CHARSET_ISO_8859_11 24 #define TINICONV_CHARSET_ISO_8859_13 25 #define TINICONV_CHARSET_ISO_8859_14 26 #define TINICONV_CHARSET_ISO_8859_15 27 #define TINICONV_CHARSET_ISO_8859_16 28 #define TINICONV_CHARSET_CP866 29 #define TINICONV_CHARSET_KOI8_R 30 #define TINICONV_CHARSET_KOI8_RU 31 #define TINICONV_CHARSET_KOI8_U 32 #define TINICONV_CHARSET_MACCYRILLIC 33 #define TINICONV_CHARSET_UCS_2 34 #define TINICONV_CHARSET_UTF_7 35 #define TINICONV_CHARSET_UTF_8 36 #define TINICONV_CHARSET_CHINESE 37 #define TINICONV_CHARSET_BIG5 38 #define TINICONV_CHARSETSIZE 39 #define TINICONV_OPTION_IGNORE_IN_ILSEQ 1 /*< ignore incorrect input sequences */ #define TINICONV_OPTION_IGNORE_OUT_ILSEQ 2 /*< replace sequence which can't be converted to OUT charset with OUTIL_CHAR */ /* #define TINICONV_OPTION_TRANSLIT 4 */ #define TINICONV_OPTION_OUT_ILSEQ_CHAR(ch) (ch << 8) #define TINICONV_INIT_OK 0 #define TINICONV_INIT_IN_CHARSET_NA -1 #define TINICONV_INIT_OUT_CHARSET_NA -1 #ifdef __cplusplus extern "C" { #endif EXPORT(int) tiniconv_init(int in_charset_id, int out_charset_id, int options, struct tiniconv_ctx_s *ctx); /* * tiniconv_convert */ #define TINICONV_CONVERT_OK 0 #define TINICONV_CONVERT_IN_TOO_SMALL -1 #define TINICONV_CONVERT_OUT_TOO_SMALL -2 #define TINICONV_CONVERT_IN_ILSEQ -3 #define TINICONV_CONVERT_OUT_ILSEQ -4 EXPORT(int) tiniconv_convert(struct tiniconv_ctx_s *ctx, unsigned char const *in_buf, int in_size, int *p_in_size_consumed, unsigned char *out_buf, int out_size, int *p_out_size_consumed); #ifdef __cplusplus } #endif #endif /*TINICONV_H_*/
5,515
C++
.h
144
36.819444
122
0.716741
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,558
jisx0208.h
w1hkj_fldigi/src/libtiniconv/encdec/jisx0208.h
/* * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * The GNU LIBICONV Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with the GNU LIBICONV Library; see the file COPYING.LIB. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301, USA. */ /* * JISX0208.1990-0 */ static const unsigned short jisx0208_2uni_page21[690] = { /* 0x21 */ 0x3000, 0x3001, 0x3002, 0xff0c, 0xff0e, 0x30fb, 0xff1a, 0xff1b, 0xff1f, 0xff01, 0x309b, 0x309c, 0x00b4, 0xff40, 0x00a8, 0xff3e, 0xffe3, 0xff3f, 0x30fd, 0x30fe, 0x309d, 0x309e, 0x3003, 0x4edd, 0x3005, 0x3006, 0x3007, 0x30fc, 0x2015, 0x2010, 0xff0f, 0xff3c, 0x301c, 0x2016, 0xff5c, 0x2026, 0x2025, 0x2018, 0x2019, 0x201c, 0x201d, 0xff08, 0xff09, 0x3014, 0x3015, 0xff3b, 0xff3d, 0xff5b, 0xff5d, 0x3008, 0x3009, 0x300a, 0x300b, 0x300c, 0x300d, 0x300e, 0x300f, 0x3010, 0x3011, 0xff0b, 0x2212, 0x00b1, 0x00d7, 0x00f7, 0xff1d, 0x2260, 0xff1c, 0xff1e, 0x2266, 0x2267, 0x221e, 0x2234, 0x2642, 0x2640, 0x00b0, 0x2032, 0x2033, 0x2103, 0xffe5, 0xff04, 0x00a2, 0x00a3, 0xff05, 0xff03, 0xff06, 0xff0a, 0xff20, 0x00a7, 0x2606, 0x2605, 0x25cb, 0x25cf, 0x25ce, 0x25c7, /* 0x22 */ 0x25c6, 0x25a1, 0x25a0, 0x25b3, 0x25b2, 0x25bd, 0x25bc, 0x203b, 0x3012, 0x2192, 0x2190, 0x2191, 0x2193, 0x3013, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x2208, 0x220b, 0x2286, 0x2287, 0x2282, 0x2283, 0x222a, 0x2229, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x2227, 0x2228, 0x00ac, 0x21d2, 0x21d4, 0x2200, 0x2203, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x2220, 0x22a5, 0x2312, 0x2202, 0x2207, 0x2261, 0x2252, 0x226a, 0x226b, 0x221a, 0x223d, 0x221d, 0x2235, 0x222b, 0x222c, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x212b, 0x2030, 0x266f, 0x266d, 0x266a, 0x2020, 0x2021, 0x00b6, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x25ef, /* 0x23 */ 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xff10, 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16, 0xff17, 0xff18, 0xff19, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a, 0xff2b, 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, 0xff34, 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48, 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, 0xff52, 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58, 0xff59, 0xff5a, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x24 */ 0x3041, 0x3042, 0x3043, 0x3044, 0x3045, 0x3046, 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e, 0x304f, 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058, 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e, 0x305f, 0x3060, 0x3061, 0x3062, 0x3063, 0x3064, 0x3065, 0x3066, 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c, 0x306d, 0x306e, 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076, 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, 0x3080, 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088, 0x3089, 0x308a, 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090, 0x3091, 0x3092, 0x3093, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x25 */ 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8, 0x30a9, 0x30aa, 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af, 0x30b0, 0x30b1, 0x30b2, 0x30b3, 0x30b4, 0x30b5, 0x30b6, 0x30b7, 0x30b8, 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be, 0x30bf, 0x30c0, 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8, 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0, 0x30d1, 0x30d2, 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8, 0x30d9, 0x30da, 0x30db, 0x30dc, 0x30dd, 0x30de, 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7, 0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef, 0x30f0, 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x26 */ 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x27 */ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0401, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x28 */ 0x2500, 0x2502, 0x250c, 0x2510, 0x2518, 0x2514, 0x251c, 0x252c, 0x2524, 0x2534, 0x253c, 0x2501, 0x2503, 0x250f, 0x2513, 0x251b, 0x2517, 0x2523, 0x2533, 0x252b, 0x253b, 0x254b, 0x2520, 0x252f, 0x2528, 0x2537, 0x253f, 0x251d, 0x2530, 0x2525, 0x2538, 0x2542, }; static const unsigned short jisx0208_2uni_page30[6398] = { /* 0x30 */ 0x4e9c, 0x5516, 0x5a03, 0x963f, 0x54c0, 0x611b, 0x6328, 0x59f6, 0x9022, 0x8475, 0x831c, 0x7a50, 0x60aa, 0x63e1, 0x6e25, 0x65ed, 0x8466, 0x82a6, 0x9bf5, 0x6893, 0x5727, 0x65a1, 0x6271, 0x5b9b, 0x59d0, 0x867b, 0x98f4, 0x7d62, 0x7dbe, 0x9b8e, 0x6216, 0x7c9f, 0x88b7, 0x5b89, 0x5eb5, 0x6309, 0x6697, 0x6848, 0x95c7, 0x978d, 0x674f, 0x4ee5, 0x4f0a, 0x4f4d, 0x4f9d, 0x5049, 0x56f2, 0x5937, 0x59d4, 0x5a01, 0x5c09, 0x60df, 0x610f, 0x6170, 0x6613, 0x6905, 0x70ba, 0x754f, 0x7570, 0x79fb, 0x7dad, 0x7def, 0x80c3, 0x840e, 0x8863, 0x8b02, 0x9055, 0x907a, 0x533b, 0x4e95, 0x4ea5, 0x57df, 0x80b2, 0x90c1, 0x78ef, 0x4e00, 0x58f1, 0x6ea2, 0x9038, 0x7a32, 0x8328, 0x828b, 0x9c2f, 0x5141, 0x5370, 0x54bd, 0x54e1, 0x56e0, 0x59fb, 0x5f15, 0x98f2, 0x6deb, 0x80e4, 0x852d, /* 0x31 */ 0x9662, 0x9670, 0x96a0, 0x97fb, 0x540b, 0x53f3, 0x5b87, 0x70cf, 0x7fbd, 0x8fc2, 0x96e8, 0x536f, 0x9d5c, 0x7aba, 0x4e11, 0x7893, 0x81fc, 0x6e26, 0x5618, 0x5504, 0x6b1d, 0x851a, 0x9c3b, 0x59e5, 0x53a9, 0x6d66, 0x74dc, 0x958f, 0x5642, 0x4e91, 0x904b, 0x96f2, 0x834f, 0x990c, 0x53e1, 0x55b6, 0x5b30, 0x5f71, 0x6620, 0x66f3, 0x6804, 0x6c38, 0x6cf3, 0x6d29, 0x745b, 0x76c8, 0x7a4e, 0x9834, 0x82f1, 0x885b, 0x8a60, 0x92ed, 0x6db2, 0x75ab, 0x76ca, 0x99c5, 0x60a6, 0x8b01, 0x8d8a, 0x95b2, 0x698e, 0x53ad, 0x5186, 0x5712, 0x5830, 0x5944, 0x5bb4, 0x5ef6, 0x6028, 0x63a9, 0x63f4, 0x6cbf, 0x6f14, 0x708e, 0x7114, 0x7159, 0x71d5, 0x733f, 0x7e01, 0x8276, 0x82d1, 0x8597, 0x9060, 0x925b, 0x9d1b, 0x5869, 0x65bc, 0x6c5a, 0x7525, 0x51f9, 0x592e, 0x5965, 0x5f80, 0x5fdc, /* 0x32 */ 0x62bc, 0x65fa, 0x6a2a, 0x6b27, 0x6bb4, 0x738b, 0x7fc1, 0x8956, 0x9d2c, 0x9d0e, 0x9ec4, 0x5ca1, 0x6c96, 0x837b, 0x5104, 0x5c4b, 0x61b6, 0x81c6, 0x6876, 0x7261, 0x4e59, 0x4ffa, 0x5378, 0x6069, 0x6e29, 0x7a4f, 0x97f3, 0x4e0b, 0x5316, 0x4eee, 0x4f55, 0x4f3d, 0x4fa1, 0x4f73, 0x52a0, 0x53ef, 0x5609, 0x590f, 0x5ac1, 0x5bb6, 0x5be1, 0x79d1, 0x6687, 0x679c, 0x67b6, 0x6b4c, 0x6cb3, 0x706b, 0x73c2, 0x798d, 0x79be, 0x7a3c, 0x7b87, 0x82b1, 0x82db, 0x8304, 0x8377, 0x83ef, 0x83d3, 0x8766, 0x8ab2, 0x5629, 0x8ca8, 0x8fe6, 0x904e, 0x971e, 0x868a, 0x4fc4, 0x5ce8, 0x6211, 0x7259, 0x753b, 0x81e5, 0x82bd, 0x86fe, 0x8cc0, 0x96c5, 0x9913, 0x99d5, 0x4ecb, 0x4f1a, 0x89e3, 0x56de, 0x584a, 0x58ca, 0x5efb, 0x5feb, 0x602a, 0x6094, 0x6062, 0x61d0, 0x6212, 0x62d0, 0x6539, /* 0x33 */ 0x9b41, 0x6666, 0x68b0, 0x6d77, 0x7070, 0x754c, 0x7686, 0x7d75, 0x82a5, 0x87f9, 0x958b, 0x968e, 0x8c9d, 0x51f1, 0x52be, 0x5916, 0x54b3, 0x5bb3, 0x5d16, 0x6168, 0x6982, 0x6daf, 0x788d, 0x84cb, 0x8857, 0x8a72, 0x93a7, 0x9ab8, 0x6d6c, 0x99a8, 0x86d9, 0x57a3, 0x67ff, 0x86ce, 0x920e, 0x5283, 0x5687, 0x5404, 0x5ed3, 0x62e1, 0x64b9, 0x683c, 0x6838, 0x6bbb, 0x7372, 0x78ba, 0x7a6b, 0x899a, 0x89d2, 0x8d6b, 0x8f03, 0x90ed, 0x95a3, 0x9694, 0x9769, 0x5b66, 0x5cb3, 0x697d, 0x984d, 0x984e, 0x639b, 0x7b20, 0x6a2b, 0x6a7f, 0x68b6, 0x9c0d, 0x6f5f, 0x5272, 0x559d, 0x6070, 0x62ec, 0x6d3b, 0x6e07, 0x6ed1, 0x845b, 0x8910, 0x8f44, 0x4e14, 0x9c39, 0x53f6, 0x691b, 0x6a3a, 0x9784, 0x682a, 0x515c, 0x7ac3, 0x84b2, 0x91dc, 0x938c, 0x565b, 0x9d28, 0x6822, 0x8305, 0x8431, /* 0x34 */ 0x7ca5, 0x5208, 0x82c5, 0x74e6, 0x4e7e, 0x4f83, 0x51a0, 0x5bd2, 0x520a, 0x52d8, 0x52e7, 0x5dfb, 0x559a, 0x582a, 0x59e6, 0x5b8c, 0x5b98, 0x5bdb, 0x5e72, 0x5e79, 0x60a3, 0x611f, 0x6163, 0x61be, 0x63db, 0x6562, 0x67d1, 0x6853, 0x68fa, 0x6b3e, 0x6b53, 0x6c57, 0x6f22, 0x6f97, 0x6f45, 0x74b0, 0x7518, 0x76e3, 0x770b, 0x7aff, 0x7ba1, 0x7c21, 0x7de9, 0x7f36, 0x7ff0, 0x809d, 0x8266, 0x839e, 0x89b3, 0x8acc, 0x8cab, 0x9084, 0x9451, 0x9593, 0x9591, 0x95a2, 0x9665, 0x97d3, 0x9928, 0x8218, 0x4e38, 0x542b, 0x5cb8, 0x5dcc, 0x73a9, 0x764c, 0x773c, 0x5ca9, 0x7feb, 0x8d0b, 0x96c1, 0x9811, 0x9854, 0x9858, 0x4f01, 0x4f0e, 0x5371, 0x559c, 0x5668, 0x57fa, 0x5947, 0x5b09, 0x5bc4, 0x5c90, 0x5e0c, 0x5e7e, 0x5fcc, 0x63ee, 0x673a, 0x65d7, 0x65e2, 0x671f, 0x68cb, 0x68c4, /* 0x35 */ 0x6a5f, 0x5e30, 0x6bc5, 0x6c17, 0x6c7d, 0x757f, 0x7948, 0x5b63, 0x7a00, 0x7d00, 0x5fbd, 0x898f, 0x8a18, 0x8cb4, 0x8d77, 0x8ecc, 0x8f1d, 0x98e2, 0x9a0e, 0x9b3c, 0x4e80, 0x507d, 0x5100, 0x5993, 0x5b9c, 0x622f, 0x6280, 0x64ec, 0x6b3a, 0x72a0, 0x7591, 0x7947, 0x7fa9, 0x87fb, 0x8abc, 0x8b70, 0x63ac, 0x83ca, 0x97a0, 0x5409, 0x5403, 0x55ab, 0x6854, 0x6a58, 0x8a70, 0x7827, 0x6775, 0x9ecd, 0x5374, 0x5ba2, 0x811a, 0x8650, 0x9006, 0x4e18, 0x4e45, 0x4ec7, 0x4f11, 0x53ca, 0x5438, 0x5bae, 0x5f13, 0x6025, 0x6551, 0x673d, 0x6c42, 0x6c72, 0x6ce3, 0x7078, 0x7403, 0x7a76, 0x7aae, 0x7b08, 0x7d1a, 0x7cfe, 0x7d66, 0x65e7, 0x725b, 0x53bb, 0x5c45, 0x5de8, 0x62d2, 0x62e0, 0x6319, 0x6e20, 0x865a, 0x8a31, 0x8ddd, 0x92f8, 0x6f01, 0x79a6, 0x9b5a, 0x4ea8, 0x4eab, 0x4eac, /* 0x36 */ 0x4f9b, 0x4fa0, 0x50d1, 0x5147, 0x7af6, 0x5171, 0x51f6, 0x5354, 0x5321, 0x537f, 0x53eb, 0x55ac, 0x5883, 0x5ce1, 0x5f37, 0x5f4a, 0x602f, 0x6050, 0x606d, 0x631f, 0x6559, 0x6a4b, 0x6cc1, 0x72c2, 0x72ed, 0x77ef, 0x80f8, 0x8105, 0x8208, 0x854e, 0x90f7, 0x93e1, 0x97ff, 0x9957, 0x9a5a, 0x4ef0, 0x51dd, 0x5c2d, 0x6681, 0x696d, 0x5c40, 0x66f2, 0x6975, 0x7389, 0x6850, 0x7c81, 0x50c5, 0x52e4, 0x5747, 0x5dfe, 0x9326, 0x65a4, 0x6b23, 0x6b3d, 0x7434, 0x7981, 0x79bd, 0x7b4b, 0x7dca, 0x82b9, 0x83cc, 0x887f, 0x895f, 0x8b39, 0x8fd1, 0x91d1, 0x541f, 0x9280, 0x4e5d, 0x5036, 0x53e5, 0x533a, 0x72d7, 0x7396, 0x77e9, 0x82e6, 0x8eaf, 0x99c6, 0x99c8, 0x99d2, 0x5177, 0x611a, 0x865e, 0x55b0, 0x7a7a, 0x5076, 0x5bd3, 0x9047, 0x9685, 0x4e32, 0x6adb, 0x91e7, 0x5c51, 0x5c48, /* 0x37 */ 0x6398, 0x7a9f, 0x6c93, 0x9774, 0x8f61, 0x7aaa, 0x718a, 0x9688, 0x7c82, 0x6817, 0x7e70, 0x6851, 0x936c, 0x52f2, 0x541b, 0x85ab, 0x8a13, 0x7fa4, 0x8ecd, 0x90e1, 0x5366, 0x8888, 0x7941, 0x4fc2, 0x50be, 0x5211, 0x5144, 0x5553, 0x572d, 0x73ea, 0x578b, 0x5951, 0x5f62, 0x5f84, 0x6075, 0x6176, 0x6167, 0x61a9, 0x63b2, 0x643a, 0x656c, 0x666f, 0x6842, 0x6e13, 0x7566, 0x7a3d, 0x7cfb, 0x7d4c, 0x7d99, 0x7e4b, 0x7f6b, 0x830e, 0x834a, 0x86cd, 0x8a08, 0x8a63, 0x8b66, 0x8efd, 0x981a, 0x9d8f, 0x82b8, 0x8fce, 0x9be8, 0x5287, 0x621f, 0x6483, 0x6fc0, 0x9699, 0x6841, 0x5091, 0x6b20, 0x6c7a, 0x6f54, 0x7a74, 0x7d50, 0x8840, 0x8a23, 0x6708, 0x4ef6, 0x5039, 0x5026, 0x5065, 0x517c, 0x5238, 0x5263, 0x55a7, 0x570f, 0x5805, 0x5acc, 0x5efa, 0x61b2, 0x61f8, 0x62f3, 0x6372, /* 0x38 */ 0x691c, 0x6a29, 0x727d, 0x72ac, 0x732e, 0x7814, 0x786f, 0x7d79, 0x770c, 0x80a9, 0x898b, 0x8b19, 0x8ce2, 0x8ed2, 0x9063, 0x9375, 0x967a, 0x9855, 0x9a13, 0x9e78, 0x5143, 0x539f, 0x53b3, 0x5e7b, 0x5f26, 0x6e1b, 0x6e90, 0x7384, 0x73fe, 0x7d43, 0x8237, 0x8a00, 0x8afa, 0x9650, 0x4e4e, 0x500b, 0x53e4, 0x547c, 0x56fa, 0x59d1, 0x5b64, 0x5df1, 0x5eab, 0x5f27, 0x6238, 0x6545, 0x67af, 0x6e56, 0x72d0, 0x7cca, 0x88b4, 0x80a1, 0x80e1, 0x83f0, 0x864e, 0x8a87, 0x8de8, 0x9237, 0x96c7, 0x9867, 0x9f13, 0x4e94, 0x4e92, 0x4f0d, 0x5348, 0x5449, 0x543e, 0x5a2f, 0x5f8c, 0x5fa1, 0x609f, 0x68a7, 0x6a8e, 0x745a, 0x7881, 0x8a9e, 0x8aa4, 0x8b77, 0x9190, 0x4e5e, 0x9bc9, 0x4ea4, 0x4f7c, 0x4faf, 0x5019, 0x5016, 0x5149, 0x516c, 0x529f, 0x52b9, 0x52fe, 0x539a, 0x53e3, 0x5411, /* 0x39 */ 0x540e, 0x5589, 0x5751, 0x57a2, 0x597d, 0x5b54, 0x5b5d, 0x5b8f, 0x5de5, 0x5de7, 0x5df7, 0x5e78, 0x5e83, 0x5e9a, 0x5eb7, 0x5f18, 0x6052, 0x614c, 0x6297, 0x62d8, 0x63a7, 0x653b, 0x6602, 0x6643, 0x66f4, 0x676d, 0x6821, 0x6897, 0x69cb, 0x6c5f, 0x6d2a, 0x6d69, 0x6e2f, 0x6e9d, 0x7532, 0x7687, 0x786c, 0x7a3f, 0x7ce0, 0x7d05, 0x7d18, 0x7d5e, 0x7db1, 0x8015, 0x8003, 0x80af, 0x80b1, 0x8154, 0x818f, 0x822a, 0x8352, 0x884c, 0x8861, 0x8b1b, 0x8ca2, 0x8cfc, 0x90ca, 0x9175, 0x9271, 0x783f, 0x92fc, 0x95a4, 0x964d, 0x9805, 0x9999, 0x9ad8, 0x9d3b, 0x525b, 0x52ab, 0x53f7, 0x5408, 0x58d5, 0x62f7, 0x6fe0, 0x8c6a, 0x8f5f, 0x9eb9, 0x514b, 0x523b, 0x544a, 0x56fd, 0x7a40, 0x9177, 0x9d60, 0x9ed2, 0x7344, 0x6f09, 0x8170, 0x7511, 0x5ffd, 0x60da, 0x9aa8, 0x72db, 0x8fbc, /* 0x3a */ 0x6b64, 0x9803, 0x4eca, 0x56f0, 0x5764, 0x58be, 0x5a5a, 0x6068, 0x61c7, 0x660f, 0x6606, 0x6839, 0x68b1, 0x6df7, 0x75d5, 0x7d3a, 0x826e, 0x9b42, 0x4e9b, 0x4f50, 0x53c9, 0x5506, 0x5d6f, 0x5de6, 0x5dee, 0x67fb, 0x6c99, 0x7473, 0x7802, 0x8a50, 0x9396, 0x88df, 0x5750, 0x5ea7, 0x632b, 0x50b5, 0x50ac, 0x518d, 0x6700, 0x54c9, 0x585e, 0x59bb, 0x5bb0, 0x5f69, 0x624d, 0x63a1, 0x683d, 0x6b73, 0x6e08, 0x707d, 0x91c7, 0x7280, 0x7815, 0x7826, 0x796d, 0x658e, 0x7d30, 0x83dc, 0x88c1, 0x8f09, 0x969b, 0x5264, 0x5728, 0x6750, 0x7f6a, 0x8ca1, 0x51b4, 0x5742, 0x962a, 0x583a, 0x698a, 0x80b4, 0x54b2, 0x5d0e, 0x57fc, 0x7895, 0x9dfa, 0x4f5c, 0x524a, 0x548b, 0x643e, 0x6628, 0x6714, 0x67f5, 0x7a84, 0x7b56, 0x7d22, 0x932f, 0x685c, 0x9bad, 0x7b39, 0x5319, 0x518a, 0x5237, /* 0x3b */ 0x5bdf, 0x62f6, 0x64ae, 0x64e6, 0x672d, 0x6bba, 0x85a9, 0x96d1, 0x7690, 0x9bd6, 0x634c, 0x9306, 0x9bab, 0x76bf, 0x6652, 0x4e09, 0x5098, 0x53c2, 0x5c71, 0x60e8, 0x6492, 0x6563, 0x685f, 0x71e6, 0x73ca, 0x7523, 0x7b97, 0x7e82, 0x8695, 0x8b83, 0x8cdb, 0x9178, 0x9910, 0x65ac, 0x66ab, 0x6b8b, 0x4ed5, 0x4ed4, 0x4f3a, 0x4f7f, 0x523a, 0x53f8, 0x53f2, 0x55e3, 0x56db, 0x58eb, 0x59cb, 0x59c9, 0x59ff, 0x5b50, 0x5c4d, 0x5e02, 0x5e2b, 0x5fd7, 0x601d, 0x6307, 0x652f, 0x5b5c, 0x65af, 0x65bd, 0x65e8, 0x679d, 0x6b62, 0x6b7b, 0x6c0f, 0x7345, 0x7949, 0x79c1, 0x7cf8, 0x7d19, 0x7d2b, 0x80a2, 0x8102, 0x81f3, 0x8996, 0x8a5e, 0x8a69, 0x8a66, 0x8a8c, 0x8aee, 0x8cc7, 0x8cdc, 0x96cc, 0x98fc, 0x6b6f, 0x4e8b, 0x4f3c, 0x4f8d, 0x5150, 0x5b57, 0x5bfa, 0x6148, 0x6301, 0x6642, /* 0x3c */ 0x6b21, 0x6ecb, 0x6cbb, 0x723e, 0x74bd, 0x75d4, 0x78c1, 0x793a, 0x800c, 0x8033, 0x81ea, 0x8494, 0x8f9e, 0x6c50, 0x9e7f, 0x5f0f, 0x8b58, 0x9d2b, 0x7afa, 0x8ef8, 0x5b8d, 0x96eb, 0x4e03, 0x53f1, 0x57f7, 0x5931, 0x5ac9, 0x5ba4, 0x6089, 0x6e7f, 0x6f06, 0x75be, 0x8cea, 0x5b9f, 0x8500, 0x7be0, 0x5072, 0x67f4, 0x829d, 0x5c61, 0x854a, 0x7e1e, 0x820e, 0x5199, 0x5c04, 0x6368, 0x8d66, 0x659c, 0x716e, 0x793e, 0x7d17, 0x8005, 0x8b1d, 0x8eca, 0x906e, 0x86c7, 0x90aa, 0x501f, 0x52fa, 0x5c3a, 0x6753, 0x707c, 0x7235, 0x914c, 0x91c8, 0x932b, 0x82e5, 0x5bc2, 0x5f31, 0x60f9, 0x4e3b, 0x53d6, 0x5b88, 0x624b, 0x6731, 0x6b8a, 0x72e9, 0x73e0, 0x7a2e, 0x816b, 0x8da3, 0x9152, 0x9996, 0x5112, 0x53d7, 0x546a, 0x5bff, 0x6388, 0x6a39, 0x7dac, 0x9700, 0x56da, 0x53ce, 0x5468, /* 0x3d */ 0x5b97, 0x5c31, 0x5dde, 0x4fee, 0x6101, 0x62fe, 0x6d32, 0x79c0, 0x79cb, 0x7d42, 0x7e4d, 0x7fd2, 0x81ed, 0x821f, 0x8490, 0x8846, 0x8972, 0x8b90, 0x8e74, 0x8f2f, 0x9031, 0x914b, 0x916c, 0x96c6, 0x919c, 0x4ec0, 0x4f4f, 0x5145, 0x5341, 0x5f93, 0x620e, 0x67d4, 0x6c41, 0x6e0b, 0x7363, 0x7e26, 0x91cd, 0x9283, 0x53d4, 0x5919, 0x5bbf, 0x6dd1, 0x795d, 0x7e2e, 0x7c9b, 0x587e, 0x719f, 0x51fa, 0x8853, 0x8ff0, 0x4fca, 0x5cfb, 0x6625, 0x77ac, 0x7ae3, 0x821c, 0x99ff, 0x51c6, 0x5faa, 0x65ec, 0x696f, 0x6b89, 0x6df3, 0x6e96, 0x6f64, 0x76fe, 0x7d14, 0x5de1, 0x9075, 0x9187, 0x9806, 0x51e6, 0x521d, 0x6240, 0x6691, 0x66d9, 0x6e1a, 0x5eb6, 0x7dd2, 0x7f72, 0x66f8, 0x85af, 0x85f7, 0x8af8, 0x52a9, 0x53d9, 0x5973, 0x5e8f, 0x5f90, 0x6055, 0x92e4, 0x9664, 0x50b7, 0x511f, /* 0x3e */ 0x52dd, 0x5320, 0x5347, 0x53ec, 0x54e8, 0x5546, 0x5531, 0x5617, 0x5968, 0x59be, 0x5a3c, 0x5bb5, 0x5c06, 0x5c0f, 0x5c11, 0x5c1a, 0x5e84, 0x5e8a, 0x5ee0, 0x5f70, 0x627f, 0x6284, 0x62db, 0x638c, 0x6377, 0x6607, 0x660c, 0x662d, 0x6676, 0x677e, 0x68a2, 0x6a1f, 0x6a35, 0x6cbc, 0x6d88, 0x6e09, 0x6e58, 0x713c, 0x7126, 0x7167, 0x75c7, 0x7701, 0x785d, 0x7901, 0x7965, 0x79f0, 0x7ae0, 0x7b11, 0x7ca7, 0x7d39, 0x8096, 0x83d6, 0x848b, 0x8549, 0x885d, 0x88f3, 0x8a1f, 0x8a3c, 0x8a54, 0x8a73, 0x8c61, 0x8cde, 0x91a4, 0x9266, 0x937e, 0x9418, 0x969c, 0x9798, 0x4e0a, 0x4e08, 0x4e1e, 0x4e57, 0x5197, 0x5270, 0x57ce, 0x5834, 0x58cc, 0x5b22, 0x5e38, 0x60c5, 0x64fe, 0x6761, 0x6756, 0x6d44, 0x72b6, 0x7573, 0x7a63, 0x84b8, 0x8b72, 0x91b8, 0x9320, 0x5631, 0x57f4, 0x98fe, /* 0x3f */ 0x62ed, 0x690d, 0x6b96, 0x71ed, 0x7e54, 0x8077, 0x8272, 0x89e6, 0x98df, 0x8755, 0x8fb1, 0x5c3b, 0x4f38, 0x4fe1, 0x4fb5, 0x5507, 0x5a20, 0x5bdd, 0x5be9, 0x5fc3, 0x614e, 0x632f, 0x65b0, 0x664b, 0x68ee, 0x699b, 0x6d78, 0x6df1, 0x7533, 0x75b9, 0x771f, 0x795e, 0x79e6, 0x7d33, 0x81e3, 0x82af, 0x85aa, 0x89aa, 0x8a3a, 0x8eab, 0x8f9b, 0x9032, 0x91dd, 0x9707, 0x4eba, 0x4ec1, 0x5203, 0x5875, 0x58ec, 0x5c0b, 0x751a, 0x5c3d, 0x814e, 0x8a0a, 0x8fc5, 0x9663, 0x976d, 0x7b25, 0x8acf, 0x9808, 0x9162, 0x56f3, 0x53a8, 0x9017, 0x5439, 0x5782, 0x5e25, 0x63a8, 0x6c34, 0x708a, 0x7761, 0x7c8b, 0x7fe0, 0x8870, 0x9042, 0x9154, 0x9310, 0x9318, 0x968f, 0x745e, 0x9ac4, 0x5d07, 0x5d69, 0x6570, 0x67a2, 0x8da8, 0x96db, 0x636e, 0x6749, 0x6919, 0x83c5, 0x9817, 0x96c0, 0x88fe, /* 0x40 */ 0x6f84, 0x647a, 0x5bf8, 0x4e16, 0x702c, 0x755d, 0x662f, 0x51c4, 0x5236, 0x52e2, 0x59d3, 0x5f81, 0x6027, 0x6210, 0x653f, 0x6574, 0x661f, 0x6674, 0x68f2, 0x6816, 0x6b63, 0x6e05, 0x7272, 0x751f, 0x76db, 0x7cbe, 0x8056, 0x58f0, 0x88fd, 0x897f, 0x8aa0, 0x8a93, 0x8acb, 0x901d, 0x9192, 0x9752, 0x9759, 0x6589, 0x7a0e, 0x8106, 0x96bb, 0x5e2d, 0x60dc, 0x621a, 0x65a5, 0x6614, 0x6790, 0x77f3, 0x7a4d, 0x7c4d, 0x7e3e, 0x810a, 0x8cac, 0x8d64, 0x8de1, 0x8e5f, 0x78a9, 0x5207, 0x62d9, 0x63a5, 0x6442, 0x6298, 0x8a2d, 0x7a83, 0x7bc0, 0x8aac, 0x96ea, 0x7d76, 0x820c, 0x8749, 0x4ed9, 0x5148, 0x5343, 0x5360, 0x5ba3, 0x5c02, 0x5c16, 0x5ddd, 0x6226, 0x6247, 0x64b0, 0x6813, 0x6834, 0x6cc9, 0x6d45, 0x6d17, 0x67d3, 0x6f5c, 0x714e, 0x717d, 0x65cb, 0x7a7f, 0x7bad, 0x7dda, /* 0x41 */ 0x7e4a, 0x7fa8, 0x817a, 0x821b, 0x8239, 0x85a6, 0x8a6e, 0x8cce, 0x8df5, 0x9078, 0x9077, 0x92ad, 0x9291, 0x9583, 0x9bae, 0x524d, 0x5584, 0x6f38, 0x7136, 0x5168, 0x7985, 0x7e55, 0x81b3, 0x7cce, 0x564c, 0x5851, 0x5ca8, 0x63aa, 0x66fe, 0x66fd, 0x695a, 0x72d9, 0x758f, 0x758e, 0x790e, 0x7956, 0x79df, 0x7c97, 0x7d20, 0x7d44, 0x8607, 0x8a34, 0x963b, 0x9061, 0x9f20, 0x50e7, 0x5275, 0x53cc, 0x53e2, 0x5009, 0x55aa, 0x58ee, 0x594f, 0x723d, 0x5b8b, 0x5c64, 0x531d, 0x60e3, 0x60f3, 0x635c, 0x6383, 0x633f, 0x63bb, 0x64cd, 0x65e9, 0x66f9, 0x5de3, 0x69cd, 0x69fd, 0x6f15, 0x71e5, 0x4e89, 0x75e9, 0x76f8, 0x7a93, 0x7cdf, 0x7dcf, 0x7d9c, 0x8061, 0x8349, 0x8358, 0x846c, 0x84bc, 0x85fb, 0x88c5, 0x8d70, 0x9001, 0x906d, 0x9397, 0x971c, 0x9a12, 0x50cf, 0x5897, 0x618e, /* 0x42 */ 0x81d3, 0x8535, 0x8d08, 0x9020, 0x4fc3, 0x5074, 0x5247, 0x5373, 0x606f, 0x6349, 0x675f, 0x6e2c, 0x8db3, 0x901f, 0x4fd7, 0x5c5e, 0x8cca, 0x65cf, 0x7d9a, 0x5352, 0x8896, 0x5176, 0x63c3, 0x5b58, 0x5b6b, 0x5c0a, 0x640d, 0x6751, 0x905c, 0x4ed6, 0x591a, 0x592a, 0x6c70, 0x8a51, 0x553e, 0x5815, 0x59a5, 0x60f0, 0x6253, 0x67c1, 0x8235, 0x6955, 0x9640, 0x99c4, 0x9a28, 0x4f53, 0x5806, 0x5bfe, 0x8010, 0x5cb1, 0x5e2f, 0x5f85, 0x6020, 0x614b, 0x6234, 0x66ff, 0x6cf0, 0x6ede, 0x80ce, 0x817f, 0x82d4, 0x888b, 0x8cb8, 0x9000, 0x902e, 0x968a, 0x9edb, 0x9bdb, 0x4ee3, 0x53f0, 0x5927, 0x7b2c, 0x918d, 0x984c, 0x9df9, 0x6edd, 0x7027, 0x5353, 0x5544, 0x5b85, 0x6258, 0x629e, 0x62d3, 0x6ca2, 0x6fef, 0x7422, 0x8a17, 0x9438, 0x6fc1, 0x8afe, 0x8338, 0x51e7, 0x86f8, 0x53ea, /* 0x43 */ 0x53e9, 0x4f46, 0x9054, 0x8fb0, 0x596a, 0x8131, 0x5dfd, 0x7aea, 0x8fbf, 0x68da, 0x8c37, 0x72f8, 0x9c48, 0x6a3d, 0x8ab0, 0x4e39, 0x5358, 0x5606, 0x5766, 0x62c5, 0x63a2, 0x65e6, 0x6b4e, 0x6de1, 0x6e5b, 0x70ad, 0x77ed, 0x7aef, 0x7baa, 0x7dbb, 0x803d, 0x80c6, 0x86cb, 0x8a95, 0x935b, 0x56e3, 0x58c7, 0x5f3e, 0x65ad, 0x6696, 0x6a80, 0x6bb5, 0x7537, 0x8ac7, 0x5024, 0x77e5, 0x5730, 0x5f1b, 0x6065, 0x667a, 0x6c60, 0x75f4, 0x7a1a, 0x7f6e, 0x81f4, 0x8718, 0x9045, 0x99b3, 0x7bc9, 0x755c, 0x7af9, 0x7b51, 0x84c4, 0x9010, 0x79e9, 0x7a92, 0x8336, 0x5ae1, 0x7740, 0x4e2d, 0x4ef2, 0x5b99, 0x5fe0, 0x62bd, 0x663c, 0x67f1, 0x6ce8, 0x866b, 0x8877, 0x8a3b, 0x914e, 0x92f3, 0x99d0, 0x6a17, 0x7026, 0x732a, 0x82e7, 0x8457, 0x8caf, 0x4e01, 0x5146, 0x51cb, 0x558b, 0x5bf5, /* 0x44 */ 0x5e16, 0x5e33, 0x5e81, 0x5f14, 0x5f35, 0x5f6b, 0x5fb4, 0x61f2, 0x6311, 0x66a2, 0x671d, 0x6f6e, 0x7252, 0x753a, 0x773a, 0x8074, 0x8139, 0x8178, 0x8776, 0x8abf, 0x8adc, 0x8d85, 0x8df3, 0x929a, 0x9577, 0x9802, 0x9ce5, 0x52c5, 0x6357, 0x76f4, 0x6715, 0x6c88, 0x73cd, 0x8cc3, 0x93ae, 0x9673, 0x6d25, 0x589c, 0x690e, 0x69cc, 0x8ffd, 0x939a, 0x75db, 0x901a, 0x585a, 0x6802, 0x63b4, 0x69fb, 0x4f43, 0x6f2c, 0x67d8, 0x8fbb, 0x8526, 0x7db4, 0x9354, 0x693f, 0x6f70, 0x576a, 0x58f7, 0x5b2c, 0x7d2c, 0x722a, 0x540a, 0x91e3, 0x9db4, 0x4ead, 0x4f4e, 0x505c, 0x5075, 0x5243, 0x8c9e, 0x5448, 0x5824, 0x5b9a, 0x5e1d, 0x5e95, 0x5ead, 0x5ef7, 0x5f1f, 0x608c, 0x62b5, 0x633a, 0x63d0, 0x68af, 0x6c40, 0x7887, 0x798e, 0x7a0b, 0x7de0, 0x8247, 0x8a02, 0x8ae6, 0x8e44, 0x9013, /* 0x45 */ 0x90b8, 0x912d, 0x91d8, 0x9f0e, 0x6ce5, 0x6458, 0x64e2, 0x6575, 0x6ef4, 0x7684, 0x7b1b, 0x9069, 0x93d1, 0x6eba, 0x54f2, 0x5fb9, 0x64a4, 0x8f4d, 0x8fed, 0x9244, 0x5178, 0x586b, 0x5929, 0x5c55, 0x5e97, 0x6dfb, 0x7e8f, 0x751c, 0x8cbc, 0x8ee2, 0x985b, 0x70b9, 0x4f1d, 0x6bbf, 0x6fb1, 0x7530, 0x96fb, 0x514e, 0x5410, 0x5835, 0x5857, 0x59ac, 0x5c60, 0x5f92, 0x6597, 0x675c, 0x6e21, 0x767b, 0x83df, 0x8ced, 0x9014, 0x90fd, 0x934d, 0x7825, 0x783a, 0x52aa, 0x5ea6, 0x571f, 0x5974, 0x6012, 0x5012, 0x515a, 0x51ac, 0x51cd, 0x5200, 0x5510, 0x5854, 0x5858, 0x5957, 0x5b95, 0x5cf6, 0x5d8b, 0x60bc, 0x6295, 0x642d, 0x6771, 0x6843, 0x68bc, 0x68df, 0x76d7, 0x6dd8, 0x6e6f, 0x6d9b, 0x706f, 0x71c8, 0x5f53, 0x75d8, 0x7977, 0x7b49, 0x7b54, 0x7b52, 0x7cd6, 0x7d71, 0x5230, /* 0x46 */ 0x8463, 0x8569, 0x85e4, 0x8a0e, 0x8b04, 0x8c46, 0x8e0f, 0x9003, 0x900f, 0x9419, 0x9676, 0x982d, 0x9a30, 0x95d8, 0x50cd, 0x52d5, 0x540c, 0x5802, 0x5c0e, 0x61a7, 0x649e, 0x6d1e, 0x77b3, 0x7ae5, 0x80f4, 0x8404, 0x9053, 0x9285, 0x5ce0, 0x9d07, 0x533f, 0x5f97, 0x5fb3, 0x6d9c, 0x7279, 0x7763, 0x79bf, 0x7be4, 0x6bd2, 0x72ec, 0x8aad, 0x6803, 0x6a61, 0x51f8, 0x7a81, 0x6934, 0x5c4a, 0x9cf6, 0x82eb, 0x5bc5, 0x9149, 0x701e, 0x5678, 0x5c6f, 0x60c7, 0x6566, 0x6c8c, 0x8c5a, 0x9041, 0x9813, 0x5451, 0x66c7, 0x920d, 0x5948, 0x90a3, 0x5185, 0x4e4d, 0x51ea, 0x8599, 0x8b0e, 0x7058, 0x637a, 0x934b, 0x6962, 0x99b4, 0x7e04, 0x7577, 0x5357, 0x6960, 0x8edf, 0x96e3, 0x6c5d, 0x4e8c, 0x5c3c, 0x5f10, 0x8fe9, 0x5302, 0x8cd1, 0x8089, 0x8679, 0x5eff, 0x65e5, 0x4e73, 0x5165, /* 0x47 */ 0x5982, 0x5c3f, 0x97ee, 0x4efb, 0x598a, 0x5fcd, 0x8a8d, 0x6fe1, 0x79b0, 0x7962, 0x5be7, 0x8471, 0x732b, 0x71b1, 0x5e74, 0x5ff5, 0x637b, 0x649a, 0x71c3, 0x7c98, 0x4e43, 0x5efc, 0x4e4b, 0x57dc, 0x56a2, 0x60a9, 0x6fc3, 0x7d0d, 0x80fd, 0x8133, 0x81bf, 0x8fb2, 0x8997, 0x86a4, 0x5df4, 0x628a, 0x64ad, 0x8987, 0x6777, 0x6ce2, 0x6d3e, 0x7436, 0x7834, 0x5a46, 0x7f75, 0x82ad, 0x99ac, 0x4ff3, 0x5ec3, 0x62dd, 0x6392, 0x6557, 0x676f, 0x76c3, 0x724c, 0x80cc, 0x80ba, 0x8f29, 0x914d, 0x500d, 0x57f9, 0x5a92, 0x6885, 0x6973, 0x7164, 0x72fd, 0x8cb7, 0x58f2, 0x8ce0, 0x966a, 0x9019, 0x877f, 0x79e4, 0x77e7, 0x8429, 0x4f2f, 0x5265, 0x535a, 0x62cd, 0x67cf, 0x6cca, 0x767d, 0x7b94, 0x7c95, 0x8236, 0x8584, 0x8feb, 0x66dd, 0x6f20, 0x7206, 0x7e1b, 0x83ab, 0x99c1, 0x9ea6, /* 0x48 */ 0x51fd, 0x7bb1, 0x7872, 0x7bb8, 0x8087, 0x7b48, 0x6ae8, 0x5e61, 0x808c, 0x7551, 0x7560, 0x516b, 0x9262, 0x6e8c, 0x767a, 0x9197, 0x9aea, 0x4f10, 0x7f70, 0x629c, 0x7b4f, 0x95a5, 0x9ce9, 0x567a, 0x5859, 0x86e4, 0x96bc, 0x4f34, 0x5224, 0x534a, 0x53cd, 0x53db, 0x5e06, 0x642c, 0x6591, 0x677f, 0x6c3e, 0x6c4e, 0x7248, 0x72af, 0x73ed, 0x7554, 0x7e41, 0x822c, 0x85e9, 0x8ca9, 0x7bc4, 0x91c6, 0x7169, 0x9812, 0x98ef, 0x633d, 0x6669, 0x756a, 0x76e4, 0x78d0, 0x8543, 0x86ee, 0x532a, 0x5351, 0x5426, 0x5983, 0x5e87, 0x5f7c, 0x60b2, 0x6249, 0x6279, 0x62ab, 0x6590, 0x6bd4, 0x6ccc, 0x75b2, 0x76ae, 0x7891, 0x79d8, 0x7dcb, 0x7f77, 0x80a5, 0x88ab, 0x8ab9, 0x8cbb, 0x907f, 0x975e, 0x98db, 0x6a0b, 0x7c38, 0x5099, 0x5c3e, 0x5fae, 0x6787, 0x6bd8, 0x7435, 0x7709, 0x7f8e, /* 0x49 */ 0x9f3b, 0x67ca, 0x7a17, 0x5339, 0x758b, 0x9aed, 0x5f66, 0x819d, 0x83f1, 0x8098, 0x5f3c, 0x5fc5, 0x7562, 0x7b46, 0x903c, 0x6867, 0x59eb, 0x5a9b, 0x7d10, 0x767e, 0x8b2c, 0x4ff5, 0x5f6a, 0x6a19, 0x6c37, 0x6f02, 0x74e2, 0x7968, 0x8868, 0x8a55, 0x8c79, 0x5edf, 0x63cf, 0x75c5, 0x79d2, 0x82d7, 0x9328, 0x92f2, 0x849c, 0x86ed, 0x9c2d, 0x54c1, 0x5f6c, 0x658c, 0x6d5c, 0x7015, 0x8ca7, 0x8cd3, 0x983b, 0x654f, 0x74f6, 0x4e0d, 0x4ed8, 0x57e0, 0x592b, 0x5a66, 0x5bcc, 0x51a8, 0x5e03, 0x5e9c, 0x6016, 0x6276, 0x6577, 0x65a7, 0x666e, 0x6d6e, 0x7236, 0x7b26, 0x8150, 0x819a, 0x8299, 0x8b5c, 0x8ca0, 0x8ce6, 0x8d74, 0x961c, 0x9644, 0x4fae, 0x64ab, 0x6b66, 0x821e, 0x8461, 0x856a, 0x90e8, 0x5c01, 0x6953, 0x98a8, 0x847a, 0x8557, 0x4f0f, 0x526f, 0x5fa9, 0x5e45, 0x670d, /* 0x4a */ 0x798f, 0x8179, 0x8907, 0x8986, 0x6df5, 0x5f17, 0x6255, 0x6cb8, 0x4ecf, 0x7269, 0x9b92, 0x5206, 0x543b, 0x5674, 0x58b3, 0x61a4, 0x626e, 0x711a, 0x596e, 0x7c89, 0x7cde, 0x7d1b, 0x96f0, 0x6587, 0x805e, 0x4e19, 0x4f75, 0x5175, 0x5840, 0x5e63, 0x5e73, 0x5f0a, 0x67c4, 0x4e26, 0x853d, 0x9589, 0x965b, 0x7c73, 0x9801, 0x50fb, 0x58c1, 0x7656, 0x78a7, 0x5225, 0x77a5, 0x8511, 0x7b86, 0x504f, 0x5909, 0x7247, 0x7bc7, 0x7de8, 0x8fba, 0x8fd4, 0x904d, 0x4fbf, 0x52c9, 0x5a29, 0x5f01, 0x97ad, 0x4fdd, 0x8217, 0x92ea, 0x5703, 0x6355, 0x6b69, 0x752b, 0x88dc, 0x8f14, 0x7a42, 0x52df, 0x5893, 0x6155, 0x620a, 0x66ae, 0x6bcd, 0x7c3f, 0x83e9, 0x5023, 0x4ff8, 0x5305, 0x5446, 0x5831, 0x5949, 0x5b9d, 0x5cf0, 0x5cef, 0x5d29, 0x5e96, 0x62b1, 0x6367, 0x653e, 0x65b9, 0x670b, /* 0x4b */ 0x6cd5, 0x6ce1, 0x70f9, 0x7832, 0x7e2b, 0x80de, 0x82b3, 0x840c, 0x84ec, 0x8702, 0x8912, 0x8a2a, 0x8c4a, 0x90a6, 0x92d2, 0x98fd, 0x9cf3, 0x9d6c, 0x4e4f, 0x4ea1, 0x508d, 0x5256, 0x574a, 0x59a8, 0x5e3d, 0x5fd8, 0x5fd9, 0x623f, 0x66b4, 0x671b, 0x67d0, 0x68d2, 0x5192, 0x7d21, 0x80aa, 0x81a8, 0x8b00, 0x8c8c, 0x8cbf, 0x927e, 0x9632, 0x5420, 0x982c, 0x5317, 0x50d5, 0x535c, 0x58a8, 0x64b2, 0x6734, 0x7267, 0x7766, 0x7a46, 0x91e6, 0x52c3, 0x6ca1, 0x6b86, 0x5800, 0x5e4c, 0x5954, 0x672c, 0x7ffb, 0x51e1, 0x76c6, 0x6469, 0x78e8, 0x9b54, 0x9ebb, 0x57cb, 0x59b9, 0x6627, 0x679a, 0x6bce, 0x54e9, 0x69d9, 0x5e55, 0x819c, 0x6795, 0x9baa, 0x67fe, 0x9c52, 0x685d, 0x4ea6, 0x4fe3, 0x53c8, 0x62b9, 0x672b, 0x6cab, 0x8fc4, 0x4fad, 0x7e6d, 0x9ebf, 0x4e07, 0x6162, 0x6e80, /* 0x4c */ 0x6f2b, 0x8513, 0x5473, 0x672a, 0x9b45, 0x5df3, 0x7b95, 0x5cac, 0x5bc6, 0x871c, 0x6e4a, 0x84d1, 0x7a14, 0x8108, 0x5999, 0x7c8d, 0x6c11, 0x7720, 0x52d9, 0x5922, 0x7121, 0x725f, 0x77db, 0x9727, 0x9d61, 0x690b, 0x5a7f, 0x5a18, 0x51a5, 0x540d, 0x547d, 0x660e, 0x76df, 0x8ff7, 0x9298, 0x9cf4, 0x59ea, 0x725d, 0x6ec5, 0x514d, 0x68c9, 0x7dbf, 0x7dec, 0x9762, 0x9eba, 0x6478, 0x6a21, 0x8302, 0x5984, 0x5b5f, 0x6bdb, 0x731b, 0x76f2, 0x7db2, 0x8017, 0x8499, 0x5132, 0x6728, 0x9ed9, 0x76ee, 0x6762, 0x52ff, 0x9905, 0x5c24, 0x623b, 0x7c7e, 0x8cb0, 0x554f, 0x60b6, 0x7d0b, 0x9580, 0x5301, 0x4e5f, 0x51b6, 0x591c, 0x723a, 0x8036, 0x91ce, 0x5f25, 0x77e2, 0x5384, 0x5f79, 0x7d04, 0x85ac, 0x8a33, 0x8e8d, 0x9756, 0x67f3, 0x85ae, 0x9453, 0x6109, 0x6108, 0x6cb9, 0x7652, /* 0x4d */ 0x8aed, 0x8f38, 0x552f, 0x4f51, 0x512a, 0x52c7, 0x53cb, 0x5ba5, 0x5e7d, 0x60a0, 0x6182, 0x63d6, 0x6709, 0x67da, 0x6e67, 0x6d8c, 0x7336, 0x7337, 0x7531, 0x7950, 0x88d5, 0x8a98, 0x904a, 0x9091, 0x90f5, 0x96c4, 0x878d, 0x5915, 0x4e88, 0x4f59, 0x4e0e, 0x8a89, 0x8f3f, 0x9810, 0x50ad, 0x5e7c, 0x5996, 0x5bb9, 0x5eb8, 0x63da, 0x63fa, 0x64c1, 0x66dc, 0x694a, 0x69d8, 0x6d0b, 0x6eb6, 0x7194, 0x7528, 0x7aaf, 0x7f8a, 0x8000, 0x8449, 0x84c9, 0x8981, 0x8b21, 0x8e0a, 0x9065, 0x967d, 0x990a, 0x617e, 0x6291, 0x6b32, 0x6c83, 0x6d74, 0x7fcc, 0x7ffc, 0x6dc0, 0x7f85, 0x87ba, 0x88f8, 0x6765, 0x83b1, 0x983c, 0x96f7, 0x6d1b, 0x7d61, 0x843d, 0x916a, 0x4e71, 0x5375, 0x5d50, 0x6b04, 0x6feb, 0x85cd, 0x862d, 0x89a7, 0x5229, 0x540f, 0x5c65, 0x674e, 0x68a8, 0x7406, 0x7483, /* 0x4e */ 0x75e2, 0x88cf, 0x88e1, 0x91cc, 0x96e2, 0x9678, 0x5f8b, 0x7387, 0x7acb, 0x844e, 0x63a0, 0x7565, 0x5289, 0x6d41, 0x6e9c, 0x7409, 0x7559, 0x786b, 0x7c92, 0x9686, 0x7adc, 0x9f8d, 0x4fb6, 0x616e, 0x65c5, 0x865c, 0x4e86, 0x4eae, 0x50da, 0x4e21, 0x51cc, 0x5bee, 0x6599, 0x6881, 0x6dbc, 0x731f, 0x7642, 0x77ad, 0x7a1c, 0x7ce7, 0x826f, 0x8ad2, 0x907c, 0x91cf, 0x9675, 0x9818, 0x529b, 0x7dd1, 0x502b, 0x5398, 0x6797, 0x6dcb, 0x71d0, 0x7433, 0x81e8, 0x8f2a, 0x96a3, 0x9c57, 0x9e9f, 0x7460, 0x5841, 0x6d99, 0x7d2f, 0x985e, 0x4ee4, 0x4f36, 0x4f8b, 0x51b7, 0x52b1, 0x5dba, 0x601c, 0x73b2, 0x793c, 0x82d3, 0x9234, 0x96b7, 0x96f6, 0x970a, 0x9e97, 0x9f62, 0x66a6, 0x6b74, 0x5217, 0x52a3, 0x70c8, 0x88c2, 0x5ec9, 0x604b, 0x6190, 0x6f23, 0x7149, 0x7c3e, 0x7df4, 0x806f, /* 0x4f */ 0x84ee, 0x9023, 0x932c, 0x5442, 0x9b6f, 0x6ad3, 0x7089, 0x8cc2, 0x8def, 0x9732, 0x52b4, 0x5a41, 0x5eca, 0x5f04, 0x6717, 0x697c, 0x6994, 0x6d6a, 0x6f0f, 0x7262, 0x72fc, 0x7bed, 0x8001, 0x807e, 0x874b, 0x90ce, 0x516d, 0x9e93, 0x7984, 0x808b, 0x9332, 0x8ad6, 0x502d, 0x548c, 0x8a71, 0x6b6a, 0x8cc4, 0x8107, 0x60d1, 0x67a0, 0x9df2, 0x4e99, 0x4e98, 0x9c10, 0x8a6b, 0x85c1, 0x8568, 0x6900, 0x6e7e, 0x7897, 0x8155, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, 0xfffd, /* 0x50 */ 0x5f0c, 0x4e10, 0x4e15, 0x4e2a, 0x4e31, 0x4e36, 0x4e3c, 0x4e3f, 0x4e42, 0x4e56, 0x4e58, 0x4e82, 0x4e85, 0x8c6b, 0x4e8a, 0x8212, 0x5f0d, 0x4e8e, 0x4e9e, 0x4e9f, 0x4ea0, 0x4ea2, 0x4eb0, 0x4eb3, 0x4eb6, 0x4ece, 0x4ecd, 0x4ec4, 0x4ec6, 0x4ec2, 0x4ed7, 0x4ede, 0x4eed, 0x4edf, 0x4ef7, 0x4f09, 0x4f5a, 0x4f30, 0x4f5b, 0x4f5d, 0x4f57, 0x4f47, 0x4f76, 0x4f88, 0x4f8f, 0x4f98, 0x4f7b, 0x4f69, 0x4f70, 0x4f91, 0x4f6f, 0x4f86, 0x4f96, 0x5118, 0x4fd4, 0x4fdf, 0x4fce, 0x4fd8, 0x4fdb, 0x4fd1, 0x4fda, 0x4fd0, 0x4fe4, 0x4fe5, 0x501a, 0x5028, 0x5014, 0x502a, 0x5025, 0x5005, 0x4f1c, 0x4ff6, 0x5021, 0x5029, 0x502c, 0x4ffe, 0x4fef, 0x5011, 0x5006, 0x5043, 0x5047, 0x6703, 0x5055, 0x5050, 0x5048, 0x505a, 0x5056, 0x506c, 0x5078, 0x5080, 0x509a, 0x5085, 0x50b4, 0x50b2, /* 0x51 */ 0x50c9, 0x50ca, 0x50b3, 0x50c2, 0x50d6, 0x50de, 0x50e5, 0x50ed, 0x50e3, 0x50ee, 0x50f9, 0x50f5, 0x5109, 0x5101, 0x5102, 0x5116, 0x5115, 0x5114, 0x511a, 0x5121, 0x513a, 0x5137, 0x513c, 0x513b, 0x513f, 0x5140, 0x5152, 0x514c, 0x5154, 0x5162, 0x7af8, 0x5169, 0x516a, 0x516e, 0x5180, 0x5182, 0x56d8, 0x518c, 0x5189, 0x518f, 0x5191, 0x5193, 0x5195, 0x5196, 0x51a4, 0x51a6, 0x51a2, 0x51a9, 0x51aa, 0x51ab, 0x51b3, 0x51b1, 0x51b2, 0x51b0, 0x51b5, 0x51bd, 0x51c5, 0x51c9, 0x51db, 0x51e0, 0x8655, 0x51e9, 0x51ed, 0x51f0, 0x51f5, 0x51fe, 0x5204, 0x520b, 0x5214, 0x520e, 0x5227, 0x522a, 0x522e, 0x5233, 0x5239, 0x524f, 0x5244, 0x524b, 0x524c, 0x525e, 0x5254, 0x526a, 0x5274, 0x5269, 0x5273, 0x527f, 0x527d, 0x528d, 0x5294, 0x5292, 0x5271, 0x5288, 0x5291, 0x8fa8, /* 0x52 */ 0x8fa7, 0x52ac, 0x52ad, 0x52bc, 0x52b5, 0x52c1, 0x52cd, 0x52d7, 0x52de, 0x52e3, 0x52e6, 0x98ed, 0x52e0, 0x52f3, 0x52f5, 0x52f8, 0x52f9, 0x5306, 0x5308, 0x7538, 0x530d, 0x5310, 0x530f, 0x5315, 0x531a, 0x5323, 0x532f, 0x5331, 0x5333, 0x5338, 0x5340, 0x5346, 0x5345, 0x4e17, 0x5349, 0x534d, 0x51d6, 0x535e, 0x5369, 0x536e, 0x5918, 0x537b, 0x5377, 0x5382, 0x5396, 0x53a0, 0x53a6, 0x53a5, 0x53ae, 0x53b0, 0x53b6, 0x53c3, 0x7c12, 0x96d9, 0x53df, 0x66fc, 0x71ee, 0x53ee, 0x53e8, 0x53ed, 0x53fa, 0x5401, 0x543d, 0x5440, 0x542c, 0x542d, 0x543c, 0x542e, 0x5436, 0x5429, 0x541d, 0x544e, 0x548f, 0x5475, 0x548e, 0x545f, 0x5471, 0x5477, 0x5470, 0x5492, 0x547b, 0x5480, 0x5476, 0x5484, 0x5490, 0x5486, 0x54c7, 0x54a2, 0x54b8, 0x54a5, 0x54ac, 0x54c4, 0x54c8, 0x54a8, /* 0x53 */ 0x54ab, 0x54c2, 0x54a4, 0x54be, 0x54bc, 0x54d8, 0x54e5, 0x54e6, 0x550f, 0x5514, 0x54fd, 0x54ee, 0x54ed, 0x54fa, 0x54e2, 0x5539, 0x5540, 0x5563, 0x554c, 0x552e, 0x555c, 0x5545, 0x5556, 0x5557, 0x5538, 0x5533, 0x555d, 0x5599, 0x5580, 0x54af, 0x558a, 0x559f, 0x557b, 0x557e, 0x5598, 0x559e, 0x55ae, 0x557c, 0x5583, 0x55a9, 0x5587, 0x55a8, 0x55da, 0x55c5, 0x55df, 0x55c4, 0x55dc, 0x55e4, 0x55d4, 0x5614, 0x55f7, 0x5616, 0x55fe, 0x55fd, 0x561b, 0x55f9, 0x564e, 0x5650, 0x71df, 0x5634, 0x5636, 0x5632, 0x5638, 0x566b, 0x5664, 0x562f, 0x566c, 0x566a, 0x5686, 0x5680, 0x568a, 0x56a0, 0x5694, 0x568f, 0x56a5, 0x56ae, 0x56b6, 0x56b4, 0x56c2, 0x56bc, 0x56c1, 0x56c3, 0x56c0, 0x56c8, 0x56ce, 0x56d1, 0x56d3, 0x56d7, 0x56ee, 0x56f9, 0x5700, 0x56ff, 0x5704, 0x5709, /* 0x54 */ 0x5708, 0x570b, 0x570d, 0x5713, 0x5718, 0x5716, 0x55c7, 0x571c, 0x5726, 0x5737, 0x5738, 0x574e, 0x573b, 0x5740, 0x574f, 0x5769, 0x57c0, 0x5788, 0x5761, 0x577f, 0x5789, 0x5793, 0x57a0, 0x57b3, 0x57a4, 0x57aa, 0x57b0, 0x57c3, 0x57c6, 0x57d4, 0x57d2, 0x57d3, 0x580a, 0x57d6, 0x57e3, 0x580b, 0x5819, 0x581d, 0x5872, 0x5821, 0x5862, 0x584b, 0x5870, 0x6bc0, 0x5852, 0x583d, 0x5879, 0x5885, 0x58b9, 0x589f, 0x58ab, 0x58ba, 0x58de, 0x58bb, 0x58b8, 0x58ae, 0x58c5, 0x58d3, 0x58d1, 0x58d7, 0x58d9, 0x58d8, 0x58e5, 0x58dc, 0x58e4, 0x58df, 0x58ef, 0x58fa, 0x58f9, 0x58fb, 0x58fc, 0x58fd, 0x5902, 0x590a, 0x5910, 0x591b, 0x68a6, 0x5925, 0x592c, 0x592d, 0x5932, 0x5938, 0x593e, 0x7ad2, 0x5955, 0x5950, 0x594e, 0x595a, 0x5958, 0x5962, 0x5960, 0x5967, 0x596c, 0x5969, /* 0x55 */ 0x5978, 0x5981, 0x599d, 0x4f5e, 0x4fab, 0x59a3, 0x59b2, 0x59c6, 0x59e8, 0x59dc, 0x598d, 0x59d9, 0x59da, 0x5a25, 0x5a1f, 0x5a11, 0x5a1c, 0x5a09, 0x5a1a, 0x5a40, 0x5a6c, 0x5a49, 0x5a35, 0x5a36, 0x5a62, 0x5a6a, 0x5a9a, 0x5abc, 0x5abe, 0x5acb, 0x5ac2, 0x5abd, 0x5ae3, 0x5ad7, 0x5ae6, 0x5ae9, 0x5ad6, 0x5afa, 0x5afb, 0x5b0c, 0x5b0b, 0x5b16, 0x5b32, 0x5ad0, 0x5b2a, 0x5b36, 0x5b3e, 0x5b43, 0x5b45, 0x5b40, 0x5b51, 0x5b55, 0x5b5a, 0x5b5b, 0x5b65, 0x5b69, 0x5b70, 0x5b73, 0x5b75, 0x5b78, 0x6588, 0x5b7a, 0x5b80, 0x5b83, 0x5ba6, 0x5bb8, 0x5bc3, 0x5bc7, 0x5bc9, 0x5bd4, 0x5bd0, 0x5be4, 0x5be6, 0x5be2, 0x5bde, 0x5be5, 0x5beb, 0x5bf0, 0x5bf6, 0x5bf3, 0x5c05, 0x5c07, 0x5c08, 0x5c0d, 0x5c13, 0x5c20, 0x5c22, 0x5c28, 0x5c38, 0x5c39, 0x5c41, 0x5c46, 0x5c4e, 0x5c53, /* 0x56 */ 0x5c50, 0x5c4f, 0x5b71, 0x5c6c, 0x5c6e, 0x4e62, 0x5c76, 0x5c79, 0x5c8c, 0x5c91, 0x5c94, 0x599b, 0x5cab, 0x5cbb, 0x5cb6, 0x5cbc, 0x5cb7, 0x5cc5, 0x5cbe, 0x5cc7, 0x5cd9, 0x5ce9, 0x5cfd, 0x5cfa, 0x5ced, 0x5d8c, 0x5cea, 0x5d0b, 0x5d15, 0x5d17, 0x5d5c, 0x5d1f, 0x5d1b, 0x5d11, 0x5d14, 0x5d22, 0x5d1a, 0x5d19, 0x5d18, 0x5d4c, 0x5d52, 0x5d4e, 0x5d4b, 0x5d6c, 0x5d73, 0x5d76, 0x5d87, 0x5d84, 0x5d82, 0x5da2, 0x5d9d, 0x5dac, 0x5dae, 0x5dbd, 0x5d90, 0x5db7, 0x5dbc, 0x5dc9, 0x5dcd, 0x5dd3, 0x5dd2, 0x5dd6, 0x5ddb, 0x5deb, 0x5df2, 0x5df5, 0x5e0b, 0x5e1a, 0x5e19, 0x5e11, 0x5e1b, 0x5e36, 0x5e37, 0x5e44, 0x5e43, 0x5e40, 0x5e4e, 0x5e57, 0x5e54, 0x5e5f, 0x5e62, 0x5e64, 0x5e47, 0x5e75, 0x5e76, 0x5e7a, 0x9ebc, 0x5e7f, 0x5ea0, 0x5ec1, 0x5ec2, 0x5ec8, 0x5ed0, 0x5ecf, /* 0x57 */ 0x5ed6, 0x5ee3, 0x5edd, 0x5eda, 0x5edb, 0x5ee2, 0x5ee1, 0x5ee8, 0x5ee9, 0x5eec, 0x5ef1, 0x5ef3, 0x5ef0, 0x5ef4, 0x5ef8, 0x5efe, 0x5f03, 0x5f09, 0x5f5d, 0x5f5c, 0x5f0b, 0x5f11, 0x5f16, 0x5f29, 0x5f2d, 0x5f38, 0x5f41, 0x5f48, 0x5f4c, 0x5f4e, 0x5f2f, 0x5f51, 0x5f56, 0x5f57, 0x5f59, 0x5f61, 0x5f6d, 0x5f73, 0x5f77, 0x5f83, 0x5f82, 0x5f7f, 0x5f8a, 0x5f88, 0x5f91, 0x5f87, 0x5f9e, 0x5f99, 0x5f98, 0x5fa0, 0x5fa8, 0x5fad, 0x5fbc, 0x5fd6, 0x5ffb, 0x5fe4, 0x5ff8, 0x5ff1, 0x5fdd, 0x60b3, 0x5fff, 0x6021, 0x6060, 0x6019, 0x6010, 0x6029, 0x600e, 0x6031, 0x601b, 0x6015, 0x602b, 0x6026, 0x600f, 0x603a, 0x605a, 0x6041, 0x606a, 0x6077, 0x605f, 0x604a, 0x6046, 0x604d, 0x6063, 0x6043, 0x6064, 0x6042, 0x606c, 0x606b, 0x6059, 0x6081, 0x608d, 0x60e7, 0x6083, 0x609a, /* 0x58 */ 0x6084, 0x609b, 0x6096, 0x6097, 0x6092, 0x60a7, 0x608b, 0x60e1, 0x60b8, 0x60e0, 0x60d3, 0x60b4, 0x5ff0, 0x60bd, 0x60c6, 0x60b5, 0x60d8, 0x614d, 0x6115, 0x6106, 0x60f6, 0x60f7, 0x6100, 0x60f4, 0x60fa, 0x6103, 0x6121, 0x60fb, 0x60f1, 0x610d, 0x610e, 0x6147, 0x613e, 0x6128, 0x6127, 0x614a, 0x613f, 0x613c, 0x612c, 0x6134, 0x613d, 0x6142, 0x6144, 0x6173, 0x6177, 0x6158, 0x6159, 0x615a, 0x616b, 0x6174, 0x616f, 0x6165, 0x6171, 0x615f, 0x615d, 0x6153, 0x6175, 0x6199, 0x6196, 0x6187, 0x61ac, 0x6194, 0x619a, 0x618a, 0x6191, 0x61ab, 0x61ae, 0x61cc, 0x61ca, 0x61c9, 0x61f7, 0x61c8, 0x61c3, 0x61c6, 0x61ba, 0x61cb, 0x7f79, 0x61cd, 0x61e6, 0x61e3, 0x61f6, 0x61fa, 0x61f4, 0x61ff, 0x61fd, 0x61fc, 0x61fe, 0x6200, 0x6208, 0x6209, 0x620d, 0x620c, 0x6214, 0x621b, /* 0x59 */ 0x621e, 0x6221, 0x622a, 0x622e, 0x6230, 0x6232, 0x6233, 0x6241, 0x624e, 0x625e, 0x6263, 0x625b, 0x6260, 0x6268, 0x627c, 0x6282, 0x6289, 0x627e, 0x6292, 0x6293, 0x6296, 0x62d4, 0x6283, 0x6294, 0x62d7, 0x62d1, 0x62bb, 0x62cf, 0x62ff, 0x62c6, 0x64d4, 0x62c8, 0x62dc, 0x62cc, 0x62ca, 0x62c2, 0x62c7, 0x629b, 0x62c9, 0x630c, 0x62ee, 0x62f1, 0x6327, 0x6302, 0x6308, 0x62ef, 0x62f5, 0x6350, 0x633e, 0x634d, 0x641c, 0x634f, 0x6396, 0x638e, 0x6380, 0x63ab, 0x6376, 0x63a3, 0x638f, 0x6389, 0x639f, 0x63b5, 0x636b, 0x6369, 0x63be, 0x63e9, 0x63c0, 0x63c6, 0x63e3, 0x63c9, 0x63d2, 0x63f6, 0x63c4, 0x6416, 0x6434, 0x6406, 0x6413, 0x6426, 0x6436, 0x651d, 0x6417, 0x6428, 0x640f, 0x6467, 0x646f, 0x6476, 0x644e, 0x652a, 0x6495, 0x6493, 0x64a5, 0x64a9, 0x6488, 0x64bc, /* 0x5a */ 0x64da, 0x64d2, 0x64c5, 0x64c7, 0x64bb, 0x64d8, 0x64c2, 0x64f1, 0x64e7, 0x8209, 0x64e0, 0x64e1, 0x62ac, 0x64e3, 0x64ef, 0x652c, 0x64f6, 0x64f4, 0x64f2, 0x64fa, 0x6500, 0x64fd, 0x6518, 0x651c, 0x6505, 0x6524, 0x6523, 0x652b, 0x6534, 0x6535, 0x6537, 0x6536, 0x6538, 0x754b, 0x6548, 0x6556, 0x6555, 0x654d, 0x6558, 0x655e, 0x655d, 0x6572, 0x6578, 0x6582, 0x6583, 0x8b8a, 0x659b, 0x659f, 0x65ab, 0x65b7, 0x65c3, 0x65c6, 0x65c1, 0x65c4, 0x65cc, 0x65d2, 0x65db, 0x65d9, 0x65e0, 0x65e1, 0x65f1, 0x6772, 0x660a, 0x6603, 0x65fb, 0x6773, 0x6635, 0x6636, 0x6634, 0x661c, 0x664f, 0x6644, 0x6649, 0x6641, 0x665e, 0x665d, 0x6664, 0x6667, 0x6668, 0x665f, 0x6662, 0x6670, 0x6683, 0x6688, 0x668e, 0x6689, 0x6684, 0x6698, 0x669d, 0x66c1, 0x66b9, 0x66c9, 0x66be, 0x66bc, /* 0x5b */ 0x66c4, 0x66b8, 0x66d6, 0x66da, 0x66e0, 0x663f, 0x66e6, 0x66e9, 0x66f0, 0x66f5, 0x66f7, 0x670f, 0x6716, 0x671e, 0x6726, 0x6727, 0x9738, 0x672e, 0x673f, 0x6736, 0x6741, 0x6738, 0x6737, 0x6746, 0x675e, 0x6760, 0x6759, 0x6763, 0x6764, 0x6789, 0x6770, 0x67a9, 0x677c, 0x676a, 0x678c, 0x678b, 0x67a6, 0x67a1, 0x6785, 0x67b7, 0x67ef, 0x67b4, 0x67ec, 0x67b3, 0x67e9, 0x67b8, 0x67e4, 0x67de, 0x67dd, 0x67e2, 0x67ee, 0x67b9, 0x67ce, 0x67c6, 0x67e7, 0x6a9c, 0x681e, 0x6846, 0x6829, 0x6840, 0x684d, 0x6832, 0x684e, 0x68b3, 0x682b, 0x6859, 0x6863, 0x6877, 0x687f, 0x689f, 0x688f, 0x68ad, 0x6894, 0x689d, 0x689b, 0x6883, 0x6aae, 0x68b9, 0x6874, 0x68b5, 0x68a0, 0x68ba, 0x690f, 0x688d, 0x687e, 0x6901, 0x68ca, 0x6908, 0x68d8, 0x6922, 0x6926, 0x68e1, 0x690c, 0x68cd, /* 0x5c */ 0x68d4, 0x68e7, 0x68d5, 0x6936, 0x6912, 0x6904, 0x68d7, 0x68e3, 0x6925, 0x68f9, 0x68e0, 0x68ef, 0x6928, 0x692a, 0x691a, 0x6923, 0x6921, 0x68c6, 0x6979, 0x6977, 0x695c, 0x6978, 0x696b, 0x6954, 0x697e, 0x696e, 0x6939, 0x6974, 0x693d, 0x6959, 0x6930, 0x6961, 0x695e, 0x695d, 0x6981, 0x696a, 0x69b2, 0x69ae, 0x69d0, 0x69bf, 0x69c1, 0x69d3, 0x69be, 0x69ce, 0x5be8, 0x69ca, 0x69dd, 0x69bb, 0x69c3, 0x69a7, 0x6a2e, 0x6991, 0x69a0, 0x699c, 0x6995, 0x69b4, 0x69de, 0x69e8, 0x6a02, 0x6a1b, 0x69ff, 0x6b0a, 0x69f9, 0x69f2, 0x69e7, 0x6a05, 0x69b1, 0x6a1e, 0x69ed, 0x6a14, 0x69eb, 0x6a0a, 0x6a12, 0x6ac1, 0x6a23, 0x6a13, 0x6a44, 0x6a0c, 0x6a72, 0x6a36, 0x6a78, 0x6a47, 0x6a62, 0x6a59, 0x6a66, 0x6a48, 0x6a38, 0x6a22, 0x6a90, 0x6a8d, 0x6aa0, 0x6a84, 0x6aa2, 0x6aa3, /* 0x5d */ 0x6a97, 0x8617, 0x6abb, 0x6ac3, 0x6ac2, 0x6ab8, 0x6ab3, 0x6aac, 0x6ade, 0x6ad1, 0x6adf, 0x6aaa, 0x6ada, 0x6aea, 0x6afb, 0x6b05, 0x8616, 0x6afa, 0x6b12, 0x6b16, 0x9b31, 0x6b1f, 0x6b38, 0x6b37, 0x76dc, 0x6b39, 0x98ee, 0x6b47, 0x6b43, 0x6b49, 0x6b50, 0x6b59, 0x6b54, 0x6b5b, 0x6b5f, 0x6b61, 0x6b78, 0x6b79, 0x6b7f, 0x6b80, 0x6b84, 0x6b83, 0x6b8d, 0x6b98, 0x6b95, 0x6b9e, 0x6ba4, 0x6baa, 0x6bab, 0x6baf, 0x6bb2, 0x6bb1, 0x6bb3, 0x6bb7, 0x6bbc, 0x6bc6, 0x6bcb, 0x6bd3, 0x6bdf, 0x6bec, 0x6beb, 0x6bf3, 0x6bef, 0x9ebe, 0x6c08, 0x6c13, 0x6c14, 0x6c1b, 0x6c24, 0x6c23, 0x6c5e, 0x6c55, 0x6c62, 0x6c6a, 0x6c82, 0x6c8d, 0x6c9a, 0x6c81, 0x6c9b, 0x6c7e, 0x6c68, 0x6c73, 0x6c92, 0x6c90, 0x6cc4, 0x6cf1, 0x6cd3, 0x6cbd, 0x6cd7, 0x6cc5, 0x6cdd, 0x6cae, 0x6cb1, 0x6cbe, /* 0x5e */ 0x6cba, 0x6cdb, 0x6cef, 0x6cd9, 0x6cea, 0x6d1f, 0x884d, 0x6d36, 0x6d2b, 0x6d3d, 0x6d38, 0x6d19, 0x6d35, 0x6d33, 0x6d12, 0x6d0c, 0x6d63, 0x6d93, 0x6d64, 0x6d5a, 0x6d79, 0x6d59, 0x6d8e, 0x6d95, 0x6fe4, 0x6d85, 0x6df9, 0x6e15, 0x6e0a, 0x6db5, 0x6dc7, 0x6de6, 0x6db8, 0x6dc6, 0x6dec, 0x6dde, 0x6dcc, 0x6de8, 0x6dd2, 0x6dc5, 0x6dfa, 0x6dd9, 0x6de4, 0x6dd5, 0x6dea, 0x6dee, 0x6e2d, 0x6e6e, 0x6e2e, 0x6e19, 0x6e72, 0x6e5f, 0x6e3e, 0x6e23, 0x6e6b, 0x6e2b, 0x6e76, 0x6e4d, 0x6e1f, 0x6e43, 0x6e3a, 0x6e4e, 0x6e24, 0x6eff, 0x6e1d, 0x6e38, 0x6e82, 0x6eaa, 0x6e98, 0x6ec9, 0x6eb7, 0x6ed3, 0x6ebd, 0x6eaf, 0x6ec4, 0x6eb2, 0x6ed4, 0x6ed5, 0x6e8f, 0x6ea5, 0x6ec2, 0x6e9f, 0x6f41, 0x6f11, 0x704c, 0x6eec, 0x6ef8, 0x6efe, 0x6f3f, 0x6ef2, 0x6f31, 0x6eef, 0x6f32, 0x6ecc, /* 0x5f */ 0x6f3e, 0x6f13, 0x6ef7, 0x6f86, 0x6f7a, 0x6f78, 0x6f81, 0x6f80, 0x6f6f, 0x6f5b, 0x6ff3, 0x6f6d, 0x6f82, 0x6f7c, 0x6f58, 0x6f8e, 0x6f91, 0x6fc2, 0x6f66, 0x6fb3, 0x6fa3, 0x6fa1, 0x6fa4, 0x6fb9, 0x6fc6, 0x6faa, 0x6fdf, 0x6fd5, 0x6fec, 0x6fd4, 0x6fd8, 0x6ff1, 0x6fee, 0x6fdb, 0x7009, 0x700b, 0x6ffa, 0x7011, 0x7001, 0x700f, 0x6ffe, 0x701b, 0x701a, 0x6f74, 0x701d, 0x7018, 0x701f, 0x7030, 0x703e, 0x7032, 0x7051, 0x7063, 0x7099, 0x7092, 0x70af, 0x70f1, 0x70ac, 0x70b8, 0x70b3, 0x70ae, 0x70df, 0x70cb, 0x70dd, 0x70d9, 0x7109, 0x70fd, 0x711c, 0x7119, 0x7165, 0x7155, 0x7188, 0x7166, 0x7162, 0x714c, 0x7156, 0x716c, 0x718f, 0x71fb, 0x7184, 0x7195, 0x71a8, 0x71ac, 0x71d7, 0x71b9, 0x71be, 0x71d2, 0x71c9, 0x71d4, 0x71ce, 0x71e0, 0x71ec, 0x71e7, 0x71f5, 0x71fc, /* 0x60 */ 0x71f9, 0x71ff, 0x720d, 0x7210, 0x721b, 0x7228, 0x722d, 0x722c, 0x7230, 0x7232, 0x723b, 0x723c, 0x723f, 0x7240, 0x7246, 0x724b, 0x7258, 0x7274, 0x727e, 0x7282, 0x7281, 0x7287, 0x7292, 0x7296, 0x72a2, 0x72a7, 0x72b9, 0x72b2, 0x72c3, 0x72c6, 0x72c4, 0x72ce, 0x72d2, 0x72e2, 0x72e0, 0x72e1, 0x72f9, 0x72f7, 0x500f, 0x7317, 0x730a, 0x731c, 0x7316, 0x731d, 0x7334, 0x732f, 0x7329, 0x7325, 0x733e, 0x734e, 0x734f, 0x9ed8, 0x7357, 0x736a, 0x7368, 0x7370, 0x7378, 0x7375, 0x737b, 0x737a, 0x73c8, 0x73b3, 0x73ce, 0x73bb, 0x73c0, 0x73e5, 0x73ee, 0x73de, 0x74a2, 0x7405, 0x746f, 0x7425, 0x73f8, 0x7432, 0x743a, 0x7455, 0x743f, 0x745f, 0x7459, 0x7441, 0x745c, 0x7469, 0x7470, 0x7463, 0x746a, 0x7476, 0x747e, 0x748b, 0x749e, 0x74a7, 0x74ca, 0x74cf, 0x74d4, 0x73f1, /* 0x61 */ 0x74e0, 0x74e3, 0x74e7, 0x74e9, 0x74ee, 0x74f2, 0x74f0, 0x74f1, 0x74f8, 0x74f7, 0x7504, 0x7503, 0x7505, 0x750c, 0x750e, 0x750d, 0x7515, 0x7513, 0x751e, 0x7526, 0x752c, 0x753c, 0x7544, 0x754d, 0x754a, 0x7549, 0x755b, 0x7546, 0x755a, 0x7569, 0x7564, 0x7567, 0x756b, 0x756d, 0x7578, 0x7576, 0x7586, 0x7587, 0x7574, 0x758a, 0x7589, 0x7582, 0x7594, 0x759a, 0x759d, 0x75a5, 0x75a3, 0x75c2, 0x75b3, 0x75c3, 0x75b5, 0x75bd, 0x75b8, 0x75bc, 0x75b1, 0x75cd, 0x75ca, 0x75d2, 0x75d9, 0x75e3, 0x75de, 0x75fe, 0x75ff, 0x75fc, 0x7601, 0x75f0, 0x75fa, 0x75f2, 0x75f3, 0x760b, 0x760d, 0x7609, 0x761f, 0x7627, 0x7620, 0x7621, 0x7622, 0x7624, 0x7634, 0x7630, 0x763b, 0x7647, 0x7648, 0x7646, 0x765c, 0x7658, 0x7661, 0x7662, 0x7668, 0x7669, 0x766a, 0x7667, 0x766c, 0x7670, /* 0x62 */ 0x7672, 0x7676, 0x7678, 0x767c, 0x7680, 0x7683, 0x7688, 0x768b, 0x768e, 0x7696, 0x7693, 0x7699, 0x769a, 0x76b0, 0x76b4, 0x76b8, 0x76b9, 0x76ba, 0x76c2, 0x76cd, 0x76d6, 0x76d2, 0x76de, 0x76e1, 0x76e5, 0x76e7, 0x76ea, 0x862f, 0x76fb, 0x7708, 0x7707, 0x7704, 0x7729, 0x7724, 0x771e, 0x7725, 0x7726, 0x771b, 0x7737, 0x7738, 0x7747, 0x775a, 0x7768, 0x776b, 0x775b, 0x7765, 0x777f, 0x777e, 0x7779, 0x778e, 0x778b, 0x7791, 0x77a0, 0x779e, 0x77b0, 0x77b6, 0x77b9, 0x77bf, 0x77bc, 0x77bd, 0x77bb, 0x77c7, 0x77cd, 0x77d7, 0x77da, 0x77dc, 0x77e3, 0x77ee, 0x77fc, 0x780c, 0x7812, 0x7926, 0x7820, 0x792a, 0x7845, 0x788e, 0x7874, 0x7886, 0x787c, 0x789a, 0x788c, 0x78a3, 0x78b5, 0x78aa, 0x78af, 0x78d1, 0x78c6, 0x78cb, 0x78d4, 0x78be, 0x78bc, 0x78c5, 0x78ca, 0x78ec, /* 0x63 */ 0x78e7, 0x78da, 0x78fd, 0x78f4, 0x7907, 0x7912, 0x7911, 0x7919, 0x792c, 0x792b, 0x7940, 0x7960, 0x7957, 0x795f, 0x795a, 0x7955, 0x7953, 0x797a, 0x797f, 0x798a, 0x799d, 0x79a7, 0x9f4b, 0x79aa, 0x79ae, 0x79b3, 0x79b9, 0x79ba, 0x79c9, 0x79d5, 0x79e7, 0x79ec, 0x79e1, 0x79e3, 0x7a08, 0x7a0d, 0x7a18, 0x7a19, 0x7a20, 0x7a1f, 0x7980, 0x7a31, 0x7a3b, 0x7a3e, 0x7a37, 0x7a43, 0x7a57, 0x7a49, 0x7a61, 0x7a62, 0x7a69, 0x9f9d, 0x7a70, 0x7a79, 0x7a7d, 0x7a88, 0x7a97, 0x7a95, 0x7a98, 0x7a96, 0x7aa9, 0x7ac8, 0x7ab0, 0x7ab6, 0x7ac5, 0x7ac4, 0x7abf, 0x9083, 0x7ac7, 0x7aca, 0x7acd, 0x7acf, 0x7ad5, 0x7ad3, 0x7ad9, 0x7ada, 0x7add, 0x7ae1, 0x7ae2, 0x7ae6, 0x7aed, 0x7af0, 0x7b02, 0x7b0f, 0x7b0a, 0x7b06, 0x7b33, 0x7b18, 0x7b19, 0x7b1e, 0x7b35, 0x7b28, 0x7b36, 0x7b50, /* 0x64 */ 0x7b7a, 0x7b04, 0x7b4d, 0x7b0b, 0x7b4c, 0x7b45, 0x7b75, 0x7b65, 0x7b74, 0x7b67, 0x7b70, 0x7b71, 0x7b6c, 0x7b6e, 0x7b9d, 0x7b98, 0x7b9f, 0x7b8d, 0x7b9c, 0x7b9a, 0x7b8b, 0x7b92, 0x7b8f, 0x7b5d, 0x7b99, 0x7bcb, 0x7bc1, 0x7bcc, 0x7bcf, 0x7bb4, 0x7bc6, 0x7bdd, 0x7be9, 0x7c11, 0x7c14, 0x7be6, 0x7be5, 0x7c60, 0x7c00, 0x7c07, 0x7c13, 0x7bf3, 0x7bf7, 0x7c17, 0x7c0d, 0x7bf6, 0x7c23, 0x7c27, 0x7c2a, 0x7c1f, 0x7c37, 0x7c2b, 0x7c3d, 0x7c4c, 0x7c43, 0x7c54, 0x7c4f, 0x7c40, 0x7c50, 0x7c58, 0x7c5f, 0x7c64, 0x7c56, 0x7c65, 0x7c6c, 0x7c75, 0x7c83, 0x7c90, 0x7ca4, 0x7cad, 0x7ca2, 0x7cab, 0x7ca1, 0x7ca8, 0x7cb3, 0x7cb2, 0x7cb1, 0x7cae, 0x7cb9, 0x7cbd, 0x7cc0, 0x7cc5, 0x7cc2, 0x7cd8, 0x7cd2, 0x7cdc, 0x7ce2, 0x9b3b, 0x7cef, 0x7cf2, 0x7cf4, 0x7cf6, 0x7cfa, 0x7d06, /* 0x65 */ 0x7d02, 0x7d1c, 0x7d15, 0x7d0a, 0x7d45, 0x7d4b, 0x7d2e, 0x7d32, 0x7d3f, 0x7d35, 0x7d46, 0x7d73, 0x7d56, 0x7d4e, 0x7d72, 0x7d68, 0x7d6e, 0x7d4f, 0x7d63, 0x7d93, 0x7d89, 0x7d5b, 0x7d8f, 0x7d7d, 0x7d9b, 0x7dba, 0x7dae, 0x7da3, 0x7db5, 0x7dc7, 0x7dbd, 0x7dab, 0x7e3d, 0x7da2, 0x7daf, 0x7ddc, 0x7db8, 0x7d9f, 0x7db0, 0x7dd8, 0x7ddd, 0x7de4, 0x7dde, 0x7dfb, 0x7df2, 0x7de1, 0x7e05, 0x7e0a, 0x7e23, 0x7e21, 0x7e12, 0x7e31, 0x7e1f, 0x7e09, 0x7e0b, 0x7e22, 0x7e46, 0x7e66, 0x7e3b, 0x7e35, 0x7e39, 0x7e43, 0x7e37, 0x7e32, 0x7e3a, 0x7e67, 0x7e5d, 0x7e56, 0x7e5e, 0x7e59, 0x7e5a, 0x7e79, 0x7e6a, 0x7e69, 0x7e7c, 0x7e7b, 0x7e83, 0x7dd5, 0x7e7d, 0x8fae, 0x7e7f, 0x7e88, 0x7e89, 0x7e8c, 0x7e92, 0x7e90, 0x7e93, 0x7e94, 0x7e96, 0x7e8e, 0x7e9b, 0x7e9c, 0x7f38, 0x7f3a, /* 0x66 */ 0x7f45, 0x7f4c, 0x7f4d, 0x7f4e, 0x7f50, 0x7f51, 0x7f55, 0x7f54, 0x7f58, 0x7f5f, 0x7f60, 0x7f68, 0x7f69, 0x7f67, 0x7f78, 0x7f82, 0x7f86, 0x7f83, 0x7f88, 0x7f87, 0x7f8c, 0x7f94, 0x7f9e, 0x7f9d, 0x7f9a, 0x7fa3, 0x7faf, 0x7fb2, 0x7fb9, 0x7fae, 0x7fb6, 0x7fb8, 0x8b71, 0x7fc5, 0x7fc6, 0x7fca, 0x7fd5, 0x7fd4, 0x7fe1, 0x7fe6, 0x7fe9, 0x7ff3, 0x7ff9, 0x98dc, 0x8006, 0x8004, 0x800b, 0x8012, 0x8018, 0x8019, 0x801c, 0x8021, 0x8028, 0x803f, 0x803b, 0x804a, 0x8046, 0x8052, 0x8058, 0x805a, 0x805f, 0x8062, 0x8068, 0x8073, 0x8072, 0x8070, 0x8076, 0x8079, 0x807d, 0x807f, 0x8084, 0x8086, 0x8085, 0x809b, 0x8093, 0x809a, 0x80ad, 0x5190, 0x80ac, 0x80db, 0x80e5, 0x80d9, 0x80dd, 0x80c4, 0x80da, 0x80d6, 0x8109, 0x80ef, 0x80f1, 0x811b, 0x8129, 0x8123, 0x812f, 0x814b, /* 0x67 */ 0x968b, 0x8146, 0x813e, 0x8153, 0x8151, 0x80fc, 0x8171, 0x816e, 0x8165, 0x8166, 0x8174, 0x8183, 0x8188, 0x818a, 0x8180, 0x8182, 0x81a0, 0x8195, 0x81a4, 0x81a3, 0x815f, 0x8193, 0x81a9, 0x81b0, 0x81b5, 0x81be, 0x81b8, 0x81bd, 0x81c0, 0x81c2, 0x81ba, 0x81c9, 0x81cd, 0x81d1, 0x81d9, 0x81d8, 0x81c8, 0x81da, 0x81df, 0x81e0, 0x81e7, 0x81fa, 0x81fb, 0x81fe, 0x8201, 0x8202, 0x8205, 0x8207, 0x820a, 0x820d, 0x8210, 0x8216, 0x8229, 0x822b, 0x8238, 0x8233, 0x8240, 0x8259, 0x8258, 0x825d, 0x825a, 0x825f, 0x8264, 0x8262, 0x8268, 0x826a, 0x826b, 0x822e, 0x8271, 0x8277, 0x8278, 0x827e, 0x828d, 0x8292, 0x82ab, 0x829f, 0x82bb, 0x82ac, 0x82e1, 0x82e3, 0x82df, 0x82d2, 0x82f4, 0x82f3, 0x82fa, 0x8393, 0x8303, 0x82fb, 0x82f9, 0x82de, 0x8306, 0x82dc, 0x8309, 0x82d9, /* 0x68 */ 0x8335, 0x8334, 0x8316, 0x8332, 0x8331, 0x8340, 0x8339, 0x8350, 0x8345, 0x832f, 0x832b, 0x8317, 0x8318, 0x8385, 0x839a, 0x83aa, 0x839f, 0x83a2, 0x8396, 0x8323, 0x838e, 0x8387, 0x838a, 0x837c, 0x83b5, 0x8373, 0x8375, 0x83a0, 0x8389, 0x83a8, 0x83f4, 0x8413, 0x83eb, 0x83ce, 0x83fd, 0x8403, 0x83d8, 0x840b, 0x83c1, 0x83f7, 0x8407, 0x83e0, 0x83f2, 0x840d, 0x8422, 0x8420, 0x83bd, 0x8438, 0x8506, 0x83fb, 0x846d, 0x842a, 0x843c, 0x855a, 0x8484, 0x8477, 0x846b, 0x84ad, 0x846e, 0x8482, 0x8469, 0x8446, 0x842c, 0x846f, 0x8479, 0x8435, 0x84ca, 0x8462, 0x84b9, 0x84bf, 0x849f, 0x84d9, 0x84cd, 0x84bb, 0x84da, 0x84d0, 0x84c1, 0x84c6, 0x84d6, 0x84a1, 0x8521, 0x84ff, 0x84f4, 0x8517, 0x8518, 0x852c, 0x851f, 0x8515, 0x8514, 0x84fc, 0x8540, 0x8563, 0x8558, 0x8548, /* 0x69 */ 0x8541, 0x8602, 0x854b, 0x8555, 0x8580, 0x85a4, 0x8588, 0x8591, 0x858a, 0x85a8, 0x856d, 0x8594, 0x859b, 0x85ea, 0x8587, 0x859c, 0x8577, 0x857e, 0x8590, 0x85c9, 0x85ba, 0x85cf, 0x85b9, 0x85d0, 0x85d5, 0x85dd, 0x85e5, 0x85dc, 0x85f9, 0x860a, 0x8613, 0x860b, 0x85fe, 0x85fa, 0x8606, 0x8622, 0x861a, 0x8630, 0x863f, 0x864d, 0x4e55, 0x8654, 0x865f, 0x8667, 0x8671, 0x8693, 0x86a3, 0x86a9, 0x86aa, 0x868b, 0x868c, 0x86b6, 0x86af, 0x86c4, 0x86c6, 0x86b0, 0x86c9, 0x8823, 0x86ab, 0x86d4, 0x86de, 0x86e9, 0x86ec, 0x86df, 0x86db, 0x86ef, 0x8712, 0x8706, 0x8708, 0x8700, 0x8703, 0x86fb, 0x8711, 0x8709, 0x870d, 0x86f9, 0x870a, 0x8734, 0x873f, 0x8737, 0x873b, 0x8725, 0x8729, 0x871a, 0x8760, 0x875f, 0x8778, 0x874c, 0x874e, 0x8774, 0x8757, 0x8768, 0x876e, 0x8759, /* 0x6a */ 0x8753, 0x8763, 0x876a, 0x8805, 0x87a2, 0x879f, 0x8782, 0x87af, 0x87cb, 0x87bd, 0x87c0, 0x87d0, 0x96d6, 0x87ab, 0x87c4, 0x87b3, 0x87c7, 0x87c6, 0x87bb, 0x87ef, 0x87f2, 0x87e0, 0x880f, 0x880d, 0x87fe, 0x87f6, 0x87f7, 0x880e, 0x87d2, 0x8811, 0x8816, 0x8815, 0x8822, 0x8821, 0x8831, 0x8836, 0x8839, 0x8827, 0x883b, 0x8844, 0x8842, 0x8852, 0x8859, 0x885e, 0x8862, 0x886b, 0x8881, 0x887e, 0x889e, 0x8875, 0x887d, 0x88b5, 0x8872, 0x8882, 0x8897, 0x8892, 0x88ae, 0x8899, 0x88a2, 0x888d, 0x88a4, 0x88b0, 0x88bf, 0x88b1, 0x88c3, 0x88c4, 0x88d4, 0x88d8, 0x88d9, 0x88dd, 0x88f9, 0x8902, 0x88fc, 0x88f4, 0x88e8, 0x88f2, 0x8904, 0x890c, 0x890a, 0x8913, 0x8943, 0x891e, 0x8925, 0x892a, 0x892b, 0x8941, 0x8944, 0x893b, 0x8936, 0x8938, 0x894c, 0x891d, 0x8960, 0x895e, /* 0x6b */ 0x8966, 0x8964, 0x896d, 0x896a, 0x896f, 0x8974, 0x8977, 0x897e, 0x8983, 0x8988, 0x898a, 0x8993, 0x8998, 0x89a1, 0x89a9, 0x89a6, 0x89ac, 0x89af, 0x89b2, 0x89ba, 0x89bd, 0x89bf, 0x89c0, 0x89da, 0x89dc, 0x89dd, 0x89e7, 0x89f4, 0x89f8, 0x8a03, 0x8a16, 0x8a10, 0x8a0c, 0x8a1b, 0x8a1d, 0x8a25, 0x8a36, 0x8a41, 0x8a5b, 0x8a52, 0x8a46, 0x8a48, 0x8a7c, 0x8a6d, 0x8a6c, 0x8a62, 0x8a85, 0x8a82, 0x8a84, 0x8aa8, 0x8aa1, 0x8a91, 0x8aa5, 0x8aa6, 0x8a9a, 0x8aa3, 0x8ac4, 0x8acd, 0x8ac2, 0x8ada, 0x8aeb, 0x8af3, 0x8ae7, 0x8ae4, 0x8af1, 0x8b14, 0x8ae0, 0x8ae2, 0x8af7, 0x8ade, 0x8adb, 0x8b0c, 0x8b07, 0x8b1a, 0x8ae1, 0x8b16, 0x8b10, 0x8b17, 0x8b20, 0x8b33, 0x97ab, 0x8b26, 0x8b2b, 0x8b3e, 0x8b28, 0x8b41, 0x8b4c, 0x8b4f, 0x8b4e, 0x8b49, 0x8b56, 0x8b5b, 0x8b5a, 0x8b6b, /* 0x6c */ 0x8b5f, 0x8b6c, 0x8b6f, 0x8b74, 0x8b7d, 0x8b80, 0x8b8c, 0x8b8e, 0x8b92, 0x8b93, 0x8b96, 0x8b99, 0x8b9a, 0x8c3a, 0x8c41, 0x8c3f, 0x8c48, 0x8c4c, 0x8c4e, 0x8c50, 0x8c55, 0x8c62, 0x8c6c, 0x8c78, 0x8c7a, 0x8c82, 0x8c89, 0x8c85, 0x8c8a, 0x8c8d, 0x8c8e, 0x8c94, 0x8c7c, 0x8c98, 0x621d, 0x8cad, 0x8caa, 0x8cbd, 0x8cb2, 0x8cb3, 0x8cae, 0x8cb6, 0x8cc8, 0x8cc1, 0x8ce4, 0x8ce3, 0x8cda, 0x8cfd, 0x8cfa, 0x8cfb, 0x8d04, 0x8d05, 0x8d0a, 0x8d07, 0x8d0f, 0x8d0d, 0x8d10, 0x9f4e, 0x8d13, 0x8ccd, 0x8d14, 0x8d16, 0x8d67, 0x8d6d, 0x8d71, 0x8d73, 0x8d81, 0x8d99, 0x8dc2, 0x8dbe, 0x8dba, 0x8dcf, 0x8dda, 0x8dd6, 0x8dcc, 0x8ddb, 0x8dcb, 0x8dea, 0x8deb, 0x8ddf, 0x8de3, 0x8dfc, 0x8e08, 0x8e09, 0x8dff, 0x8e1d, 0x8e1e, 0x8e10, 0x8e1f, 0x8e42, 0x8e35, 0x8e30, 0x8e34, 0x8e4a, /* 0x6d */ 0x8e47, 0x8e49, 0x8e4c, 0x8e50, 0x8e48, 0x8e59, 0x8e64, 0x8e60, 0x8e2a, 0x8e63, 0x8e55, 0x8e76, 0x8e72, 0x8e7c, 0x8e81, 0x8e87, 0x8e85, 0x8e84, 0x8e8b, 0x8e8a, 0x8e93, 0x8e91, 0x8e94, 0x8e99, 0x8eaa, 0x8ea1, 0x8eac, 0x8eb0, 0x8ec6, 0x8eb1, 0x8ebe, 0x8ec5, 0x8ec8, 0x8ecb, 0x8edb, 0x8ee3, 0x8efc, 0x8efb, 0x8eeb, 0x8efe, 0x8f0a, 0x8f05, 0x8f15, 0x8f12, 0x8f19, 0x8f13, 0x8f1c, 0x8f1f, 0x8f1b, 0x8f0c, 0x8f26, 0x8f33, 0x8f3b, 0x8f39, 0x8f45, 0x8f42, 0x8f3e, 0x8f4c, 0x8f49, 0x8f46, 0x8f4e, 0x8f57, 0x8f5c, 0x8f62, 0x8f63, 0x8f64, 0x8f9c, 0x8f9f, 0x8fa3, 0x8fad, 0x8faf, 0x8fb7, 0x8fda, 0x8fe5, 0x8fe2, 0x8fea, 0x8fef, 0x9087, 0x8ff4, 0x9005, 0x8ff9, 0x8ffa, 0x9011, 0x9015, 0x9021, 0x900d, 0x901e, 0x9016, 0x900b, 0x9027, 0x9036, 0x9035, 0x9039, 0x8ff8, /* 0x6e */ 0x904f, 0x9050, 0x9051, 0x9052, 0x900e, 0x9049, 0x903e, 0x9056, 0x9058, 0x905e, 0x9068, 0x906f, 0x9076, 0x96a8, 0x9072, 0x9082, 0x907d, 0x9081, 0x9080, 0x908a, 0x9089, 0x908f, 0x90a8, 0x90af, 0x90b1, 0x90b5, 0x90e2, 0x90e4, 0x6248, 0x90db, 0x9102, 0x9112, 0x9119, 0x9132, 0x9130, 0x914a, 0x9156, 0x9158, 0x9163, 0x9165, 0x9169, 0x9173, 0x9172, 0x918b, 0x9189, 0x9182, 0x91a2, 0x91ab, 0x91af, 0x91aa, 0x91b5, 0x91b4, 0x91ba, 0x91c0, 0x91c1, 0x91c9, 0x91cb, 0x91d0, 0x91d6, 0x91df, 0x91e1, 0x91db, 0x91fc, 0x91f5, 0x91f6, 0x921e, 0x91ff, 0x9214, 0x922c, 0x9215, 0x9211, 0x925e, 0x9257, 0x9245, 0x9249, 0x9264, 0x9248, 0x9295, 0x923f, 0x924b, 0x9250, 0x929c, 0x9296, 0x9293, 0x929b, 0x925a, 0x92cf, 0x92b9, 0x92b7, 0x92e9, 0x930f, 0x92fa, 0x9344, 0x932e, /* 0x6f */ 0x9319, 0x9322, 0x931a, 0x9323, 0x933a, 0x9335, 0x933b, 0x935c, 0x9360, 0x937c, 0x936e, 0x9356, 0x93b0, 0x93ac, 0x93ad, 0x9394, 0x93b9, 0x93d6, 0x93d7, 0x93e8, 0x93e5, 0x93d8, 0x93c3, 0x93dd, 0x93d0, 0x93c8, 0x93e4, 0x941a, 0x9414, 0x9413, 0x9403, 0x9407, 0x9410, 0x9436, 0x942b, 0x9435, 0x9421, 0x943a, 0x9441, 0x9452, 0x9444, 0x945b, 0x9460, 0x9462, 0x945e, 0x946a, 0x9229, 0x9470, 0x9475, 0x9477, 0x947d, 0x945a, 0x947c, 0x947e, 0x9481, 0x947f, 0x9582, 0x9587, 0x958a, 0x9594, 0x9596, 0x9598, 0x9599, 0x95a0, 0x95a8, 0x95a7, 0x95ad, 0x95bc, 0x95bb, 0x95b9, 0x95be, 0x95ca, 0x6ff6, 0x95c3, 0x95cd, 0x95cc, 0x95d5, 0x95d4, 0x95d6, 0x95dc, 0x95e1, 0x95e5, 0x95e2, 0x9621, 0x9628, 0x962e, 0x962f, 0x9642, 0x964c, 0x964f, 0x964b, 0x9677, 0x965c, 0x965e, /* 0x70 */ 0x965d, 0x965f, 0x9666, 0x9672, 0x966c, 0x968d, 0x9698, 0x9695, 0x9697, 0x96aa, 0x96a7, 0x96b1, 0x96b2, 0x96b0, 0x96b4, 0x96b6, 0x96b8, 0x96b9, 0x96ce, 0x96cb, 0x96c9, 0x96cd, 0x894d, 0x96dc, 0x970d, 0x96d5, 0x96f9, 0x9704, 0x9706, 0x9708, 0x9713, 0x970e, 0x9711, 0x970f, 0x9716, 0x9719, 0x9724, 0x972a, 0x9730, 0x9739, 0x973d, 0x973e, 0x9744, 0x9746, 0x9748, 0x9742, 0x9749, 0x975c, 0x9760, 0x9764, 0x9766, 0x9768, 0x52d2, 0x976b, 0x9771, 0x9779, 0x9785, 0x977c, 0x9781, 0x977a, 0x9786, 0x978b, 0x978f, 0x9790, 0x979c, 0x97a8, 0x97a6, 0x97a3, 0x97b3, 0x97b4, 0x97c3, 0x97c6, 0x97c8, 0x97cb, 0x97dc, 0x97ed, 0x9f4f, 0x97f2, 0x7adf, 0x97f6, 0x97f5, 0x980f, 0x980c, 0x9838, 0x9824, 0x9821, 0x9837, 0x983d, 0x9846, 0x984f, 0x984b, 0x986b, 0x986f, 0x9870, /* 0x71 */ 0x9871, 0x9874, 0x9873, 0x98aa, 0x98af, 0x98b1, 0x98b6, 0x98c4, 0x98c3, 0x98c6, 0x98e9, 0x98eb, 0x9903, 0x9909, 0x9912, 0x9914, 0x9918, 0x9921, 0x991d, 0x991e, 0x9924, 0x9920, 0x992c, 0x992e, 0x993d, 0x993e, 0x9942, 0x9949, 0x9945, 0x9950, 0x994b, 0x9951, 0x9952, 0x994c, 0x9955, 0x9997, 0x9998, 0x99a5, 0x99ad, 0x99ae, 0x99bc, 0x99df, 0x99db, 0x99dd, 0x99d8, 0x99d1, 0x99ed, 0x99ee, 0x99f1, 0x99f2, 0x99fb, 0x99f8, 0x9a01, 0x9a0f, 0x9a05, 0x99e2, 0x9a19, 0x9a2b, 0x9a37, 0x9a45, 0x9a42, 0x9a40, 0x9a43, 0x9a3e, 0x9a55, 0x9a4d, 0x9a5b, 0x9a57, 0x9a5f, 0x9a62, 0x9a65, 0x9a64, 0x9a69, 0x9a6b, 0x9a6a, 0x9aad, 0x9ab0, 0x9abc, 0x9ac0, 0x9acf, 0x9ad1, 0x9ad3, 0x9ad4, 0x9ade, 0x9adf, 0x9ae2, 0x9ae3, 0x9ae6, 0x9aef, 0x9aeb, 0x9aee, 0x9af4, 0x9af1, 0x9af7, /* 0x72 */ 0x9afb, 0x9b06, 0x9b18, 0x9b1a, 0x9b1f, 0x9b22, 0x9b23, 0x9b25, 0x9b27, 0x9b28, 0x9b29, 0x9b2a, 0x9b2e, 0x9b2f, 0x9b32, 0x9b44, 0x9b43, 0x9b4f, 0x9b4d, 0x9b4e, 0x9b51, 0x9b58, 0x9b74, 0x9b93, 0x9b83, 0x9b91, 0x9b96, 0x9b97, 0x9b9f, 0x9ba0, 0x9ba8, 0x9bb4, 0x9bc0, 0x9bca, 0x9bb9, 0x9bc6, 0x9bcf, 0x9bd1, 0x9bd2, 0x9be3, 0x9be2, 0x9be4, 0x9bd4, 0x9be1, 0x9c3a, 0x9bf2, 0x9bf1, 0x9bf0, 0x9c15, 0x9c14, 0x9c09, 0x9c13, 0x9c0c, 0x9c06, 0x9c08, 0x9c12, 0x9c0a, 0x9c04, 0x9c2e, 0x9c1b, 0x9c25, 0x9c24, 0x9c21, 0x9c30, 0x9c47, 0x9c32, 0x9c46, 0x9c3e, 0x9c5a, 0x9c60, 0x9c67, 0x9c76, 0x9c78, 0x9ce7, 0x9cec, 0x9cf0, 0x9d09, 0x9d08, 0x9ceb, 0x9d03, 0x9d06, 0x9d2a, 0x9d26, 0x9daf, 0x9d23, 0x9d1f, 0x9d44, 0x9d15, 0x9d12, 0x9d41, 0x9d3f, 0x9d3e, 0x9d46, 0x9d48, /* 0x73 */ 0x9d5d, 0x9d5e, 0x9d64, 0x9d51, 0x9d50, 0x9d59, 0x9d72, 0x9d89, 0x9d87, 0x9dab, 0x9d6f, 0x9d7a, 0x9d9a, 0x9da4, 0x9da9, 0x9db2, 0x9dc4, 0x9dc1, 0x9dbb, 0x9db8, 0x9dba, 0x9dc6, 0x9dcf, 0x9dc2, 0x9dd9, 0x9dd3, 0x9df8, 0x9de6, 0x9ded, 0x9def, 0x9dfd, 0x9e1a, 0x9e1b, 0x9e1e, 0x9e75, 0x9e79, 0x9e7d, 0x9e81, 0x9e88, 0x9e8b, 0x9e8c, 0x9e92, 0x9e95, 0x9e91, 0x9e9d, 0x9ea5, 0x9ea9, 0x9eb8, 0x9eaa, 0x9ead, 0x9761, 0x9ecc, 0x9ece, 0x9ecf, 0x9ed0, 0x9ed4, 0x9edc, 0x9ede, 0x9edd, 0x9ee0, 0x9ee5, 0x9ee8, 0x9eef, 0x9ef4, 0x9ef6, 0x9ef7, 0x9ef9, 0x9efb, 0x9efc, 0x9efd, 0x9f07, 0x9f08, 0x76b7, 0x9f15, 0x9f21, 0x9f2c, 0x9f3e, 0x9f4a, 0x9f52, 0x9f54, 0x9f63, 0x9f5f, 0x9f60, 0x9f61, 0x9f66, 0x9f67, 0x9f6c, 0x9f6a, 0x9f77, 0x9f72, 0x9f76, 0x9f95, 0x9f9c, 0x9fa0, /* 0x74 */ 0x582f, 0x69c7, 0x9059, 0x7464, 0x51dc, 0x7199, }; static int jisx0208_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) { unsigned char c1 = s[0]; if ((c1 >= 0x21 && c1 <= 0x28) || (c1 >= 0x30 && c1 <= 0x74)) { if (n >= 2) { unsigned char c2 = s[1]; if (c2 >= 0x21 && c2 < 0x7f) { unsigned int i = 94 * (c1 - 0x21) + (c2 - 0x21); unsigned short wc = 0xfffd; if (i < 1410) { if (i < 690) wc = jisx0208_2uni_page21[i]; } else { if (i < 7808) wc = jisx0208_2uni_page30[i-1410]; } if (wc != 0xfffd) { *pwc = (ucs4_t) wc; return 2; } } return RET_ILSEQ; } return RET_TOOFEW(0); } return RET_ILSEQ; } static const unsigned short jisx0208_2charset[6879] = { 0x2171, 0x2172, 0x2178, 0x212f, 0x224c, 0x216b, 0x215e, 0x212d, 0x2279, 0x215f, 0x2160, 0x2621, 0x2622, 0x2623, 0x2624, 0x2625, 0x2626, 0x2627, 0x2628, 0x2629, 0x262a, 0x262b, 0x262c, 0x262d, 0x262e, 0x262f, 0x2630, 0x2631, 0x2632, 0x2633, 0x2634, 0x2635, 0x2636, 0x2637, 0x2638, 0x2641, 0x2642, 0x2643, 0x2644, 0x2645, 0x2646, 0x2647, 0x2648, 0x2649, 0x264a, 0x264b, 0x264c, 0x264d, 0x264e, 0x264f, 0x2650, 0x2651, 0x2652, 0x2653, 0x2654, 0x2655, 0x2656, 0x2657, 0x2658, 0x2727, 0x2721, 0x2722, 0x2723, 0x2724, 0x2725, 0x2726, 0x2728, 0x2729, 0x272a, 0x272b, 0x272c, 0x272d, 0x272e, 0x272f, 0x2730, 0x2731, 0x2732, 0x2733, 0x2734, 0x2735, 0x2736, 0x2737, 0x2738, 0x2739, 0x273a, 0x273b, 0x273c, 0x273d, 0x273e, 0x273f, 0x2740, 0x2741, 0x2751, 0x2752, 0x2753, 0x2754, 0x2755, 0x2756, 0x2758, 0x2759, 0x275a, 0x275b, 0x275c, 0x275d, 0x275e, 0x275f, 0x2760, 0x2761, 0x2762, 0x2763, 0x2764, 0x2765, 0x2766, 0x2767, 0x2768, 0x2769, 0x276a, 0x276b, 0x276c, 0x276d, 0x276e, 0x276f, 0x2770, 0x2771, 0x2757, 0x213e, 0x213d, 0x2142, 0x2146, 0x2147, 0x2148, 0x2149, 0x2277, 0x2278, 0x2145, 0x2144, 0x2273, 0x216c, 0x216d, 0x2228, 0x216e, 0x2272, 0x222b, 0x222c, 0x222a, 0x222d, 0x224d, 0x224e, 0x224f, 0x225f, 0x2250, 0x2260, 0x223a, 0x223b, 0x215d, 0x2265, 0x2267, 0x2167, 0x225c, 0x224a, 0x224b, 0x2241, 0x2240, 0x2269, 0x226a, 0x2168, 0x2268, 0x2266, 0x2262, 0x2162, 0x2261, 0x2165, 0x2166, 0x2263, 0x2264, 0x223e, 0x223f, 0x223c, 0x223d, 0x225d, 0x225e, 0x2821, 0x282c, 0x2822, 0x282d, 0x2823, 0x282e, 0x2824, 0x282f, 0x2826, 0x2831, 0x2825, 0x2830, 0x2827, 0x283c, 0x2837, 0x2832, 0x2829, 0x283e, 0x2839, 0x2834, 0x2828, 0x2838, 0x283d, 0x2833, 0x282a, 0x283a, 0x283f, 0x2835, 0x282b, 0x283b, 0x2840, 0x2836, 0x2223, 0x2222, 0x2225, 0x2224, 0x2227, 0x2226, 0x2221, 0x217e, 0x217b, 0x217d, 0x217c, 0x227e, 0x217a, 0x2179, 0x216a, 0x2169, 0x2276, 0x2275, 0x2274, 0x2121, 0x2122, 0x2123, 0x2137, 0x2139, 0x213a, 0x213b, 0x2152, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, 0x215b, 0x2229, 0x222e, 0x214c, 0x214d, 0x2141, 0x2421, 0x2422, 0x2423, 0x2424, 0x2425, 0x2426, 0x2427, 0x2428, 0x2429, 0x242a, 0x242b, 0x242c, 0x242d, 0x242e, 0x242f, 0x2430, 0x2431, 0x2432, 0x2433, 0x2434, 0x2435, 0x2436, 0x2437, 0x2438, 0x2439, 0x243a, 0x243b, 0x243c, 0x243d, 0x243e, 0x243f, 0x2440, 0x2441, 0x2442, 0x2443, 0x2444, 0x2445, 0x2446, 0x2447, 0x2448, 0x2449, 0x244a, 0x244b, 0x244c, 0x244d, 0x244e, 0x244f, 0x2450, 0x2451, 0x2452, 0x2453, 0x2454, 0x2455, 0x2456, 0x2457, 0x2458, 0x2459, 0x245a, 0x245b, 0x245c, 0x245d, 0x245e, 0x245f, 0x2460, 0x2461, 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x246a, 0x246b, 0x246c, 0x246d, 0x246e, 0x246f, 0x2470, 0x2471, 0x2472, 0x2473, 0x212b, 0x212c, 0x2135, 0x2136, 0x2521, 0x2522, 0x2523, 0x2524, 0x2525, 0x2526, 0x2527, 0x2528, 0x2529, 0x252a, 0x252b, 0x252c, 0x252d, 0x252e, 0x252f, 0x2530, 0x2531, 0x2532, 0x2533, 0x2534, 0x2535, 0x2536, 0x2537, 0x2538, 0x2539, 0x253a, 0x253b, 0x253c, 0x253d, 0x253e, 0x253f, 0x2540, 0x2541, 0x2542, 0x2543, 0x2544, 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, 0x254b, 0x254c, 0x254d, 0x254e, 0x254f, 0x2550, 0x2551, 0x2552, 0x2553, 0x2554, 0x2555, 0x2556, 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e, 0x255f, 0x2560, 0x2561, 0x2562, 0x2563, 0x2564, 0x2565, 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x256d, 0x256e, 0x256f, 0x2570, 0x2571, 0x2572, 0x2573, 0x2574, 0x2575, 0x2576, 0x2126, 0x213c, 0x2133, 0x2134, 0x306c, 0x437a, 0x3c37, 0x4b7c, 0x3e66, 0x3b30, 0x3e65, 0x323c, 0x4954, 0x4d3f, 0x5022, 0x312f, 0x336e, 0x5023, 0x4024, 0x5242, 0x3556, 0x4a3a, 0x3e67, 0x4e3e, 0x4a42, 0x5024, 0x4366, 0x5025, 0x367a, 0x5026, 0x345d, 0x4330, 0x3c67, 0x5027, 0x5028, 0x5029, 0x4735, 0x3557, 0x4737, 0x4663, 0x3843, 0x4b33, 0x6949, 0x502a, 0x3e68, 0x502b, 0x3235, 0x3665, 0x3870, 0x4c69, 0x5626, 0x4d70, 0x467d, 0x3425, 0x3535, 0x502c, 0x502d, 0x4e3b, 0x4d3d, 0x4168, 0x502f, 0x3b76, 0x4673, 0x5032, 0x313e, 0x385f, 0x385e, 0x3066, 0x4f4b, 0x4f4a, 0x3a33, 0x3021, 0x5033, 0x5034, 0x5035, 0x4b34, 0x5036, 0x3872, 0x3067, 0x4b72, 0x357c, 0x357d, 0x357e, 0x4462, 0x4e3c, 0x5037, 0x5038, 0x5039, 0x3f4d, 0x3d3a, 0x3f4e, 0x503e, 0x503c, 0x503d, 0x3558, 0x3a23, 0x3270, 0x503b, 0x503a, 0x4a29, 0x3b46, 0x3b45, 0x423e, 0x503f, 0x4955, 0x4067, 0x2138, 0x5040, 0x5042, 0x4265, 0x4e61, 0x304a, 0x5041, 0x323e, 0x3644, 0x4367, 0x376f, 0x5043, 0x4724, 0x346b, 0x5044, 0x304b, 0x3860, 0x346c, 0x497a, 0x4832, 0x3559, 0x3271, 0x5067, 0x4541, 0x476c, 0x5046, 0x483c, 0x4e62, 0x3f2d, 0x3b47, 0x3b77, 0x3240, 0x4451, 0x4322, 0x504a, 0x304c, 0x4463, 0x3d3b, 0x3a34, 0x4d24, 0x424e, 0x323f, 0x5049, 0x4d3e, 0x5045, 0x5047, 0x3a6e, 0x5048, 0x5524, 0x5050, 0x5053, 0x5051, 0x3242, 0x4a3b, 0x504b, 0x504f, 0x3873, 0x3b48, 0x3426, 0x5054, 0x504c, 0x4e63, 0x3b78, 0x504d, 0x5052, 0x5055, 0x504e, 0x3621, 0x304d, 0x3622, 0x3241, 0x5525, 0x4b79, 0x496e, 0x3874, 0x3f2f, 0x4e37, 0x4a58, 0x3738, 0x4225, 0x3264, 0x3d53, 0x5059, 0x505e, 0x505c, 0x5057, 0x422f, 0x505a, 0x505d, 0x505b, 0x4a5d, 0x5058, 0x3f2e, 0x4b73, 0x505f, 0x5060, 0x3d24, 0x506d, 0x4750, 0x4936, 0x5068, 0x4a70, 0x3236, 0x506c, 0x5066, 0x506f, 0x4152, 0x3844, 0x475c, 0x6047, 0x506e, 0x455d, 0x5063, 0x3876, 0x3875, 0x5061, 0x3c5a, 0x5069, 0x4a6f, 0x434d, 0x5065, 0x3771, 0x5062, 0x506a, 0x5064, 0x4e51, 0x506b, 0x4f41, 0x3666, 0x3770, 0x5070, 0x5071, 0x5075, 0x304e, 0x4a50, 0x5074, 0x5073, 0x5077, 0x5076, 0x4464, 0x3772, 0x5078, 0x3c45, 0x4226, 0x4465, 0x3676, 0x5079, 0x3536, 0x507a, 0x507c, 0x4b35, 0x3766, 0x3b31, 0x4877, 0x507b, 0x3a45, 0x4d43, 0x507e, 0x5123, 0x507d, 0x3a44, 0x3d7d, 0x3739, 0x5124, 0x364f, 0x5121, 0x5122, 0x462f, 0x417c, 0x3623, 0x4b4d, 0x5125, 0x4e3d, 0x5126, 0x5129, 0x5127, 0x414e, 0x5128, 0x512a, 0x512c, 0x512b, 0x4a48, 0x3537, 0x512e, 0x512f, 0x322f, 0x512d, 0x3c74, 0x5132, 0x5131, 0x5130, 0x5056, 0x5133, 0x3d7e, 0x5134, 0x4d25, 0x4c59, 0x5136, 0x5135, 0x5138, 0x5137, 0x5139, 0x513a, 0x3074, 0x3835, 0x373b, 0x3d3c, 0x437b, 0x3624, 0x4068, 0x3877, 0x396e, 0x513c, 0x4c48, 0x4546, 0x3b79, 0x513b, 0x513d, 0x455e, 0x3375, 0x513e, 0x467e, 0x4134, 0x5140, 0x5141, 0x482c, 0x3878, 0x4f3b, 0x5142, 0x3626, 0x4a3c, 0x4236, 0x3671, 0x4535, 0x3773, 0x5143, 0x5144, 0x4662, 0x315f, 0x5147, 0x3a7d, 0x5146, 0x3a46, 0x5148, 0x666e, 0x5149, 0x4b41, 0x514a, 0x514b, 0x514c, 0x3e69, 0x3c4c, 0x3427, 0x514f, 0x514d, 0x4c3d, 0x514e, 0x495a, 0x5150, 0x5151, 0x5152, 0x455f, 0x5156, 0x5154, 0x5155, 0x5153, 0x3a63, 0x5157, 0x4c6a, 0x4e64, 0x5158, 0x4028, 0x5159, 0x3d5a, 0x515a, 0x437c, 0x4e3f, 0x4560, 0x5245, 0x515b, 0x7425, 0x3645, 0x515c, 0x4b5e, 0x3d68, 0x427c, 0x515e, 0x4664, 0x515f, 0x5160, 0x332e, 0x5161, 0x3627, 0x464c, 0x317a, 0x3d50, 0x4821, 0x5162, 0x4561, 0x3f4f, 0x5163, 0x4a2c, 0x405a, 0x3422, 0x3429, 0x5164, 0x5166, 0x373a, 0x5165, 0x4e73, 0x3d69, 0x483d, 0x4a4c, 0x5167, 0x4d78, 0x5168, 0x5169, 0x457e, 0x516a, 0x4029, 0x3a7e, 0x3774, 0x516b, 0x3b49, 0x396f, 0x4466, 0x516d, 0x4227, 0x3a6f, 0x516e, 0x516f, 0x4130, 0x516c, 0x5171, 0x4b36, 0x3964, 0x5170, 0x3775, 0x3a5e, 0x476d, 0x5174, 0x5172, 0x497b, 0x3e6a, 0x517b, 0x3364, 0x5175, 0x5173, 0x414f, 0x5177, 0x5176, 0x3344, 0x3760, 0x517c, 0x4e2d, 0x5178, 0x517d, 0x517a, 0x5179, 0x4e4f, 0x3879, 0x3243, 0x4e74, 0x3d75, 0x4558, 0x3965, 0x5222, 0x5223, 0x4e65, 0x4f2b, 0x5225, 0x387a, 0x5224, 0x332f, 0x5226, 0x4b56, 0x443c, 0x4d26, 0x4a59, 0x5227, 0x7055, 0x4630, 0x5228, 0x342a, 0x4c33, 0x3e21, 0x5229, 0x4a67, 0x522d, 0x402a, 0x522a, 0x3650, 0x522b, 0x342b, 0x372e, 0x522e, 0x522f, 0x5230, 0x5231, 0x3c5b, 0x387b, 0x4c5e, 0x4c68, 0x4677, 0x4a71, 0x5232, 0x5233, 0x5235, 0x5237, 0x5236, 0x5238, 0x323d, 0x4b4c, 0x3a7c, 0x5239, 0x4159, 0x3e22, 0x3629, 0x523a, 0x485b, 0x523b, 0x523c, 0x523d, 0x523e, 0x4924, 0x3668, 0x3065, 0x463f, 0x523f, 0x3d3d, 0x4069, 0x5241, 0x5240, 0x3e23, 0x3861, 0x5243, 0x483e, 0x5244, 0x485c, 0x4234, 0x426e, 0x3628, 0x466e, 0x4331, 0x476e, 0x4b4e, 0x5246, 0x406a, 0x3735, 0x5247, 0x5248, 0x312c, 0x3075, 0x346d, 0x4228, 0x3551, 0x4d71, 0x524b, 0x3237, 0x524a, 0x362a, 0x524c, 0x4c71, 0x524d, 0x4e52, 0x387c, 0x3836, 0x524e, 0x5250, 0x524f, 0x3f5f, 0x3139, 0x315e, 0x5251, 0x5252, 0x3837, 0x5253, 0x356e, 0x3b32, 0x5254, 0x4b74, 0x3a35, 0x355a, 0x4d27, 0x4150, 0x483f, 0x3c7d, 0x3d47, 0x3c68, 0x3c75, 0x3d76, 0x4840, 0x5257, 0x3143, 0x4151, 0x387d, 0x3845, 0x3667, 0x525b, 0x4321, 0x427e, 0x362b, 0x3e24, 0x525c, 0x525a, 0x3244, 0x4266, 0x3c38, 0x3b4b, 0x3126, 0x3370, 0x3966, 0x3b4a, 0x525d, 0x525e, 0x3549, 0x3346, 0x3967, 0x3548, 0x445f, 0x3125, 0x4631, 0x4c3e, 0x3921, 0x4d79, 0x4547, 0x387e, 0x372f, 0x5267, 0x3663, 0x4b4a, 0x485d, 0x5266, 0x345e, 0x5261, 0x5262, 0x5264, 0x5265, 0x355b, 0x3f61, 0x4a2d, 0x5263, 0x525f, 0x3863, 0x5260, 0x4f24, 0x4a72, 0x4468, 0x3862, 0x3970, 0x5268, 0x465d, 0x526c, 0x3c7e, 0x3c76, 0x526f, 0x526d, 0x4c23, 0x526a, 0x5273, 0x526e, 0x5271, 0x3846, 0x4c3f, 0x5272, 0x5274, 0x5276, 0x3a70, 0x4f42, 0x526b, 0x5269, 0x5275, 0x5270, 0x5278, 0x5323, 0x527a, 0x527e, 0x5321, 0x527b, 0x533e, 0x3a69, 0x3331, 0x5279, 0x5325, 0x3076, 0x5324, 0x3025, 0x494a, 0x5322, 0x527c, 0x5277, 0x527d, 0x3a48, 0x5326, 0x3077, 0x532f, 0x5327, 0x5328, 0x3e25, 0x4b69, 0x532d, 0x532c, 0x452f, 0x532e, 0x532b, 0x3134, 0x3a36, 0x3f30, 0x5329, 0x4562, 0x532a, 0x3022, 0x5334, 0x4d23, 0x3e27, 0x533a, 0x5339, 0x5330, 0x4243, 0x5331, 0x426f, 0x5336, 0x3e26, 0x5333, 0x4c64, 0x373c, 0x5337, 0x5338, 0x5335, 0x533b, 0x5332, 0x5341, 0x5346, 0x5342, 0x533d, 0x5347, 0x4131, 0x5349, 0x3922, 0x533f, 0x437d, 0x5343, 0x533c, 0x342d, 0x346e, 0x3365, 0x5344, 0x5340, 0x3776, 0x534a, 0x5348, 0x4153, 0x354a, 0x362c, 0x5345, 0x3674, 0x3144, 0x534e, 0x534c, 0x5427, 0x5351, 0x534b, 0x534f, 0x534d, 0x3b4c, 0x5350, 0x5353, 0x5358, 0x5356, 0x5355, 0x4332, 0x3245, 0x5352, 0x5354, 0x3e28, 0x3133, 0x5357, 0x325e, 0x5362, 0x3e7c, 0x535e, 0x535c, 0x535d, 0x535f, 0x313d, 0x4139, 0x5359, 0x535a, 0x337a, 0x5361, 0x346f, 0x5364, 0x5360, 0x5363, 0x4a2e, 0x4655, 0x4838, 0x5366, 0x5365, 0x3345, 0x5367, 0x536a, 0x5369, 0x5368, 0x4739, 0x536b, 0x536c, 0x536e, 0x536d, 0x5370, 0x5373, 0x5371, 0x536f, 0x5372, 0x5374, 0x5375, 0x5376, 0x5377, 0x5378, 0x5145, 0x3c7c, 0x3b4d, 0x3273, 0x3078, 0x4344, 0x5379, 0x3a24, 0x304f, 0x3f5e, 0x537a, 0x3847, 0x3971, 0x537c, 0x537b, 0x4a60, 0x537d, 0x5421, 0x537e, 0x5422, 0x5423, 0x3777, 0x3160, 0x5424, 0x5426, 0x5425, 0x5428, 0x455a, 0x5429, 0x3035, 0x3a5f, 0x373d, 0x434f, 0x542a, 0x542b, 0x542d, 0x542e, 0x3a64, 0x3651, 0x4b37, 0x542c, 0x542f, 0x3a41, 0x3923, 0x5433, 0x3a25, 0x4333, 0x5430, 0x445a, 0x5434, 0x3f62, 0x5432, 0x5435, 0x373f, 0x5436, 0x5437, 0x3924, 0x3340, 0x5439, 0x543a, 0x543b, 0x5438, 0x5431, 0x543c, 0x543d, 0x4b64, 0x3e6b, 0x543f, 0x5440, 0x543e, 0x5442, 0x4738, 0x3068, 0x4956, 0x5443, 0x3e7d, 0x3c39, 0x475d, 0x3470, 0x3a6b, 0x4b59, 0x4632, 0x3778, 0x424f, 0x5441, 0x5444, 0x4244, 0x5445, 0x5446, 0x5448, 0x4469, 0x342e, 0x7421, 0x3161, 0x4a73, 0x3e6c, 0x4548, 0x3a66, 0x544e, 0x4a3d, 0x4e5d, 0x3274, 0x544a, 0x413a, 0x544d, 0x4563, 0x4549, 0x4564, 0x4839, 0x444d, 0x3a49, 0x5449, 0x3176, 0x4536, 0x544b, 0x5447, 0x3f50, 0x544f, 0x3d4e, 0x362d, 0x5450, 0x4a68, 0x417d, 0x4446, 0x5452, 0x4b4f, 0x5453, 0x5458, 0x4a2f, 0x5457, 0x5451, 0x5454, 0x5456, 0x3a26, 0x4a49, 0x5459, 0x4345, 0x3275, 0x3e6d, 0x545b, 0x545a, 0x3968, 0x545c, 0x545e, 0x545d, 0x5460, 0x5455, 0x5462, 0x5461, 0x545f, 0x3b4e, 0x3f51, 0x4154, 0x5463, 0x403c, 0x306d, 0x4764, 0x445b, 0x5465, 0x5464, 0x5466, 0x5467, 0x5468, 0x5469, 0x4a51, 0x546a, 0x3246, 0x546b, 0x4d3c, 0x3330, 0x5249, 0x3d48, 0x423f, 0x546c, 0x4c6b, 0x4c34, 0x546e, 0x4267, 0x4537, 0x4240, 0x4957, 0x546f, 0x5470, 0x317b, 0x3c3a, 0x5471, 0x3050, 0x5472, 0x5473, 0x3162, 0x3471, 0x4660, 0x4a74, 0x5477, 0x4155, 0x5476, 0x3740, 0x4b5b, 0x5475, 0x4565, 0x5479, 0x5478, 0x547b, 0x547a, 0x317c, 0x547c, 0x3e29, 0x547e, 0x4325, 0x547d, 0x4a33, 0x3d77, 0x455b, 0x5521, 0x3925, 0x5522, 0x4721, 0x485e, 0x4c51, 0x4725, 0x552b, 0x3538, 0x4d45, 0x4c2f, 0x562c, 0x5523, 0x5526, 0x4245, 0x4b38, 0x454a, 0x5527, 0x4b65, 0x3a4a, 0x3e2a, 0x5528, 0x3b50, 0x3b4f, 0x3039, 0x3848, 0x402b, 0x3051, 0x552c, 0x552d, 0x552a, 0x3138, 0x342f, 0x5529, 0x4c45, 0x4931, 0x3028, 0x3079, 0x3b51, 0x3052, 0x3023, 0x5532, 0x5530, 0x4c3c, 0x5533, 0x5531, 0x552f, 0x3f31, 0x552e, 0x4a5a, 0x3864, 0x5537, 0x5538, 0x3e2b, 0x5534, 0x4f2c, 0x474c, 0x5536, 0x3a27, 0x5539, 0x4958, 0x553a, 0x5535, 0x4c3b, 0x475e, 0x553b, 0x4932, 0x553c, 0x5540, 0x553d, 0x3247, 0x553f, 0x3c3b, 0x553e, 0x3779, 0x554c, 0x5545, 0x5542, 0x4364, 0x5541, 0x5543, 0x5544, 0x5546, 0x5547, 0x3472, 0x5549, 0x5548, 0x554a, 0x3e6e, 0x554d, 0x445c, 0x3145, 0x554b, 0x554e, 0x554f, 0x5552, 0x5550, 0x5551, 0x3b52, 0x5553, 0x3926, 0x5554, 0x3b7a, 0x4238, 0x5555, 0x5556, 0x3b5a, 0x3927, 0x4c52, 0x3528, 0x3849, 0x5557, 0x3358, 0x5558, 0x4239, 0x5559, 0x5623, 0x555a, 0x555b, 0x555c, 0x555e, 0x555f, 0x5560, 0x4270, 0x3127, 0x3c69, 0x3042, 0x4157, 0x3430, 0x3c35, 0x3928, 0x4566, 0x3d21, 0x3431, 0x4368, 0x446a, 0x3038, 0x3539, 0x4a75, 0x3c42, 0x3552, 0x406b, 0x3c3c, 0x4d28, 0x5561, 0x355c, 0x3a4b, 0x3332, 0x3163, 0x3e2c, 0x3248, 0x5562, 0x4d46, 0x3d49, 0x3c64, 0x5563, 0x3473, 0x4652, 0x4c29, 0x5564, 0x5565, 0x4959, 0x5567, 0x3428, 0x3677, 0x5566, 0x3432, 0x3f32, 0x556b, 0x3b21, 0x3249, 0x556a, 0x5568, 0x556c, 0x5569, 0x472b, 0x5c4d, 0x3f33, 0x556d, 0x4e40, 0x556e, 0x5570, 0x437e, 0x556f, 0x4023, 0x3b7b, 0x4250, 0x3c77, 0x4975, 0x406c, 0x3c4d, 0x5571, 0x3e2d, 0x5572, 0x5573, 0x3053, 0x423a, 0x3f52, 0x5574, 0x4633, 0x3e2e, 0x3e2f, 0x5575, 0x406d, 0x3e30, 0x5576, 0x5577, 0x4c60, 0x5578, 0x3646, 0x3d22, 0x5579, 0x557a, 0x3c5c, 0x3f2c, 0x4674, 0x3f54, 0x4878, 0x4722, 0x3649, 0x557b, 0x356f, 0x557c, 0x367e, 0x464f, 0x3230, 0x3b53, 0x557d, 0x5622, 0x5621, 0x367d, 0x557e, 0x4538, 0x4230, 0x454b, 0x3c48, 0x4158, 0x4d7a, 0x5624, 0x5625, 0x4656, 0x3b33, 0x5627, 0x5628, 0x5629, 0x3474, 0x562a, 0x562b, 0x322c, 0x413b, 0x3464, 0x562d, 0x4c28, 0x4252, 0x3359, 0x562f, 0x5631, 0x345f, 0x562e, 0x5630, 0x5633, 0x5632, 0x5634, 0x5635, 0x463d, 0x362e, 0x3265, 0x5636, 0x563b, 0x5639, 0x4a77, 0x4a76, 0x4567, 0x5638, 0x3d54, 0x5637, 0x3f72, 0x563c, 0x3a6a, 0x5642, 0x5643, 0x563d, 0x3333, 0x563e, 0x5647, 0x5646, 0x5645, 0x5641, 0x5640, 0x5644, 0x4a78, 0x564b, 0x5648, 0x564a, 0x4d72, 0x5649, 0x563f, 0x3f73, 0x564c, 0x3a37, 0x564d, 0x564e, 0x5651, 0x5650, 0x564f, 0x4568, 0x563a, 0x5657, 0x5653, 0x5652, 0x5654, 0x5655, 0x5658, 0x4e66, 0x5659, 0x5656, 0x565a, 0x3460, 0x565b, 0x565d, 0x565c, 0x565e, 0x565f, 0x406e, 0x3d23, 0x3d64, 0x4163, 0x3929, 0x3a38, 0x392a, 0x3570, 0x5660, 0x3a39, 0x384a, 0x5661, 0x4c26, 0x4743, 0x5662, 0x392b, 0x342c, 0x4327, 0x3652, 0x3b54, 0x495b, 0x4841, 0x5663, 0x3475, 0x5666, 0x4421, 0x5665, 0x5664, 0x5667, 0x446b, 0x3f63, 0x3b55, 0x404a, 0x4253, 0x3522, 0x4422, 0x5668, 0x5669, 0x3e6f, 0x4b39, 0x566c, 0x566b, 0x566a, 0x497d, 0x5673, 0x4b5a, 0x566d, 0x566f, 0x4b6b, 0x566e, 0x5670, 0x4828, 0x5671, 0x4a3e, 0x5672, 0x3433, 0x4a3f, 0x472f, 0x5674, 0x5675, 0x392c, 0x3434, 0x5676, 0x3838, 0x4d44, 0x4d29, 0x3476, 0x5678, 0x4423, 0x392d, 0x3e31, 0x485f, 0x3e32, 0x3d78, 0x446c, 0x4a79, 0x4539, 0x392e, 0x495c, 0x5679, 0x4559, 0x3a42, 0x384b, 0x446d, 0x3043, 0x3d6e, 0x392f, 0x4d47, 0x567a, 0x567b, 0x4751, 0x567c, 0x4e77, 0x4f2d, 0x567e, 0x567d, 0x3347, 0x5721, 0x5724, 0x5725, 0x5723, 0x4940, 0x3e33, 0x5727, 0x5726, 0x5722, 0x5728, 0x5729, 0x572a, 0x572d, 0x572b, 0x572c, 0x572e, 0x3164, 0x446e, 0x572f, 0x377a, 0x3276, 0x4736, 0x5730, 0x467b, 0x4a5b, 0x5731, 0x4f2e, 0x5732, 0x4a40, 0x5735, 0x5021, 0x5031, 0x3c30, 0x4675, 0x5736, 0x355d, 0x4424, 0x307a, 0x5737, 0x4a26, 0x3930, 0x4350, 0x446f, 0x4c6f, 0x3839, 0x384c, 0x5738, 0x5739, 0x573f, 0x3c65, 0x4425, 0x362f, 0x573a, 0x492b, 0x4346, 0x573b, 0x573c, 0x3630, 0x573d, 0x573e, 0x5740, 0x4576, 0x5741, 0x5742, 0x5743, 0x5734, 0x5733, 0x5744, 0x3741, 0x4927, 0x3a4c, 0x4937, 0x4426, 0x494b, 0x5745, 0x3e34, 0x3146, 0x5746, 0x5747, 0x4c72, 0x4860, 0x574a, 0x317d, 0x402c, 0x5749, 0x5748, 0x3742, 0x4254, 0x574e, 0x574c, 0x574b, 0x4e27, 0x3865, 0x3d79, 0x574d, 0x454c, 0x3d3e, 0x4640, 0x5751, 0x5750, 0x574f, 0x5752, 0x3866, 0x5753, 0x497c, 0x3d5b, 0x5754, 0x4879, 0x4641, 0x4427, 0x4530, 0x5755, 0x352b, 0x3f34, 0x492c, 0x3477, 0x4726, 0x5756, 0x3b56, 0x4b3a, 0x4b3b, 0x317e, 0x575b, 0x4369, 0x5758, 0x3277, 0x582d, 0x575a, 0x4730, 0x5759, 0x5757, 0x397a, 0x575d, 0x5763, 0x5769, 0x5761, 0x455c, 0x5766, 0x495d, 0x5760, 0x5765, 0x4e67, 0x3b57, 0x4255, 0x575e, 0x355e, 0x5768, 0x402d, 0x3165, 0x5762, 0x3278, 0x5767, 0x3631, 0x5764, 0x576a, 0x576c, 0x5776, 0x5774, 0x5771, 0x5770, 0x4e78, 0x5772, 0x3632, 0x3931, 0x3d7a, 0x5779, 0x576b, 0x576f, 0x575f, 0x327a, 0x5773, 0x5775, 0x4351, 0x3a28, 0x3238, 0x576d, 0x5778, 0x5777, 0x3633, 0x4229, 0x3366, 0x3743, 0x576e, 0x577a, 0x577d, 0x5821, 0x3c3d, 0x5827, 0x4470, 0x577b, 0x5825, 0x3279, 0x5823, 0x5824, 0x577e, 0x5822, 0x3867, 0x4d2a, 0x3435, 0x3159, 0x5826, 0x473a, 0x302d, 0x4861, 0x575c, 0x582c, 0x5830, 0x4c65, 0x5829, 0x4569, 0x582e, 0x3e70, 0x582f, 0x4657, 0x4f47, 0x582b, 0x5831, 0x397b, 0x404b, 0x3054, 0x582a, 0x5828, 0x415a, 0x577c, 0x3b34, 0x4246, 0x583d, 0x415b, 0x5838, 0x5835, 0x5836, 0x3c66, 0x5839, 0x583c, 0x5837, 0x3d25, 0x583a, 0x5834, 0x4c7c, 0x4c7b, 0x583e, 0x583f, 0x3055, 0x5833, 0x3672, 0x3026, 0x3436, 0x583b, 0x5843, 0x5842, 0x5847, 0x5848, 0x5846, 0x5849, 0x5841, 0x5845, 0x584a, 0x584b, 0x5840, 0x3b7c, 0x5844, 0x4256, 0x3932, 0x5832, 0x3f35, 0x5858, 0x4a69, 0x584e, 0x584f, 0x5850, 0x5857, 0x5856, 0x4b7d, 0x3437, 0x5854, 0x3745, 0x3334, 0x5851, 0x4e38, 0x5853, 0x3056, 0x5855, 0x584c, 0x5852, 0x5859, 0x3744, 0x584d, 0x4d5d, 0x4d2b, 0x585c, 0x5860, 0x417e, 0x4e79, 0x5861, 0x585e, 0x585b, 0x585a, 0x585f, 0x4a30, 0x4634, 0x3746, 0x5862, 0x585d, 0x5863, 0x377b, 0x3231, 0x586b, 0x3438, 0x5869, 0x586a, 0x3a29, 0x5868, 0x5866, 0x5865, 0x586c, 0x5864, 0x586e, 0x327b, 0x5870, 0x586f, 0x4428, 0x5873, 0x5871, 0x5867, 0x377c, 0x5872, 0x5876, 0x5875, 0x5877, 0x5874, 0x5878, 0x5879, 0x587a, 0x4a6a, 0x587c, 0x587b, 0x3d3f, 0x402e, 0x3266, 0x327c, 0x587d, 0x303f, 0x404c, 0x587e, 0x6c43, 0x5921, 0x3761, 0x5922, 0x406f, 0x5923, 0x5924, 0x353a, 0x5925, 0x5926, 0x5927, 0x4257, 0x384d, 0x4c61, 0x4b3c, 0x3d6a, 0x5928, 0x4070, 0x6e3d, 0x4862, 0x3c6a, 0x3a4d, 0x5929, 0x4247, 0x4a27, 0x4271, 0x592c, 0x592a, 0x592d, 0x592b, 0x592e, 0x4a31, 0x3037, 0x495e, 0x4863, 0x592f, 0x5932, 0x3e35, 0x353b, 0x5930, 0x5937, 0x3e36, 0x5931, 0x4744, 0x4d5e, 0x5933, 0x5934, 0x5938, 0x456a, 0x5935, 0x3933, 0x405e, 0x5946, 0x4834, 0x4272, 0x4864, 0x5a2d, 0x4a7a, 0x4471, 0x4b75, 0x593b, 0x3221, 0x436a, 0x5944, 0x4334, 0x593e, 0x5945, 0x5940, 0x5947, 0x5943, 0x5942, 0x476f, 0x593c, 0x327d, 0x593a, 0x3571, 0x4273, 0x5936, 0x5939, 0x3934, 0x405b, 0x3e37, 0x5941, 0x4752, 0x3572, 0x3348, 0x3367, 0x3f21, 0x5949, 0x594e, 0x594a, 0x377d, 0x594f, 0x3b22, 0x3969, 0x3d26, 0x593d, 0x3b7d, 0x594c, 0x3b58, 0x594d, 0x3044, 0x5948, 0x4429, 0x3573, 0x3634, 0x594b, 0x3027, 0x3a43, 0x3f36, 0x4472, 0x4854, 0x5951, 0x415e, 0x422a, 0x3b2b, 0x5952, 0x5954, 0x5950, 0x4a61, 0x443d, 0x415c, 0x4a7b, 0x3c4e, 0x5960, 0x595f, 0x3f78, 0x377e, 0x5959, 0x3e39, 0x4668, 0x4731, 0x5957, 0x415d, 0x3c78, 0x595c, 0x3e38, 0x5956, 0x595b, 0x4753, 0x5955, 0x3721, 0x335d, 0x595d, 0x4e2b, 0x3a4e, 0x4335, 0x595a, 0x405c, 0x3935, 0x3f64, 0x3166, 0x413c, 0x5958, 0x3545, 0x3747, 0x444f, 0x595e, 0x415f, 0x5961, 0x5963, 0x4237, 0x5969, 0x5964, 0x5966, 0x4941, 0x4473, 0x5967, 0x4d2c, 0x4d48, 0x3439, 0x302e, 0x5965, 0x5962, 0x3478, 0x3167, 0x5968, 0x4d49, 0x596c, 0x423b, 0x5973, 0x596d, 0x596a, 0x5971, 0x5953, 0x596e, 0x5972, 0x4842, 0x456b, 0x596b, 0x596f, 0x3748, 0x3a71, 0x405d, 0x5977, 0x4526, 0x5974, 0x4b60, 0x5975, 0x5976, 0x4c4e, 0x4022, 0x3762, 0x597d, 0x3b35, 0x597a, 0x5979, 0x4732, 0x4635, 0x4531, 0x597b, 0x597c, 0x496f, 0x4745, 0x3b23, 0x4071, 0x4b50, 0x3349, 0x5a25, 0x597e, 0x4d4a, 0x5a27, 0x5a23, 0x5a24, 0x4160, 0x5a22, 0x593f, 0x5a26, 0x5a21, 0x5a2b, 0x5a2c, 0x4527, 0x5a2e, 0x3b24, 0x5a29, 0x353c, 0x5a2f, 0x5a28, 0x5a33, 0x5a32, 0x5a31, 0x5a34, 0x5a36, 0x3e71, 0x5a35, 0x5a39, 0x5a37, 0x5a38, 0x5970, 0x5a3b, 0x5a3a, 0x5978, 0x5a3c, 0x5a30, 0x3b59, 0x5a3d, 0x5a3e, 0x5a40, 0x5a3f, 0x5a41, 0x327e, 0x3936, 0x4a7c, 0x402f, 0x384e, 0x5a43, 0x5a46, 0x4952, 0x355f, 0x5a45, 0x5a44, 0x4754, 0x5a47, 0x3635, 0x5a49, 0x5a48, 0x343a, 0x3b36, 0x4658, 0x3749, 0x3f74, 0x5a4a, 0x4030, 0x4528, 0x495f, 0x5a4b, 0x5a4c, 0x5a4d, 0x4a38, 0x555d, 0x4046, 0x494c, 0x3a58, 0x4865, 0x4843, 0x454d, 0x4e41, 0x5a4f, 0x3c50, 0x5a50, 0x3036, 0x3654, 0x404d, 0x4960, 0x5a51, 0x3b42, 0x4347, 0x3b5b, 0x3f37, 0x5a52, 0x4a7d, 0x3177, 0x3b5c, 0x5a55, 0x5a53, 0x5a56, 0x4e39, 0x5a54, 0x407b, 0x5a57, 0x4232, 0x5a58, 0x347a, 0x5a5a, 0x5a59, 0x5a5b, 0x5a5c, 0x347b, 0x467c, 0x4336, 0x356c, 0x3b5d, 0x4161, 0x3d5c, 0x3030, 0x5a5d, 0x3222, 0x5a61, 0x3937, 0x5a60, 0x3a2b, 0x3e3a, 0x5a5f, 0x3e3b, 0x4c40, 0x3a2a, 0x3057, 0x404e, 0x5a66, 0x4031, 0x3147, 0x3d55, 0x4b66, 0x3a72, 0x3e3c, 0x4027, 0x5a65, 0x5a63, 0x5a64, 0x436b, 0x5b26, 0x5a6a, 0x3b7e, 0x3938, 0x5a68, 0x5a69, 0x3f38, 0x5a67, 0x3b2f, 0x5a6c, 0x5a6b, 0x5a70, 0x5a71, 0x5a6d, 0x3322, 0x5a6e, 0x5a6f, 0x4855, 0x4961, 0x374a, 0x5a72, 0x4032, 0x3e3d, 0x4352, 0x3647, 0x5a73, 0x5a77, 0x324b, 0x5a74, 0x5a76, 0x5a75, 0x3d6b, 0x4348, 0x3045, 0x5a78, 0x5a79, 0x442a, 0x4e71, 0x3b43, 0x4a6b, 0x4b3d, 0x5b22, 0x5a7b, 0x5a7e, 0x5a7d, 0x5a7a, 0x5b21, 0x465e, 0x5a7c, 0x5b23, 0x3d6c, 0x5b24, 0x4d4b, 0x4778, 0x5b25, 0x5b27, 0x5b28, 0x5b29, 0x364a, 0x3148, 0x3939, 0x5b2a, 0x5b2b, 0x3d71, 0x4162, 0x5258, 0x413e, 0x413d, 0x4258, 0x3a47, 0x5072, 0x376e, 0x4d2d, 0x4a7e, 0x497e, 0x5b2c, 0x3a73, 0x443f, 0x5b2d, 0x4f2f, 0x4b3e, 0x442b, 0x5b2e, 0x347c, 0x5b2f, 0x5b30, 0x4c5a, 0x4c24, 0x4b76, 0x4b5c, 0x3b25, 0x5b32, 0x3c6b, 0x4b51, 0x5b34, 0x5b37, 0x5b36, 0x3479, 0x3560, 0x5b33, 0x5b35, 0x5b38, 0x3f79, 0x4d7b, 0x3049, 0x3a60, 0x423c, 0x3c5d, 0x3e73, 0x5b3b, 0x454e, 0x5b39, 0x422b, 0x5b3a, 0x3e72, 0x4c5d, 0x5b3c, 0x5b3d, 0x4d68, 0x5b42, 0x393a, 0x4755, 0x5b3f, 0x456c, 0x5a5e, 0x5a62, 0x354f, 0x4747, 0x5b41, 0x3e3e, 0x4844, 0x5b47, 0x487a, 0x5b3e, 0x5b44, 0x5b43, 0x404f, 0x4b6d, 0x4e53, 0x4b67, 0x324c, 0x3b5e, 0x4f48, 0x5b46, 0x3f75, 0x5b45, 0x5b40, 0x384f, 0x5b4c, 0x5b4a, 0x324d, 0x5b48, 0x5b4e, 0x5b54, 0x4248, 0x4a41, 0x5b56, 0x4922, 0x5b55, 0x4770, 0x4b3f, 0x343b, 0x4077, 0x3d40, 0x4453, 0x4d2e, 0x5b51, 0x5b50, 0x5b52, 0x5b4f, 0x5b57, 0x5b4d, 0x5b4b, 0x5b53, 0x5b49, 0x436c, 0x4c78, 0x3c46, 0x3a74, 0x3a3a, 0x4b6f, 0x3341, 0x444e, 0x464a, 0x3149, 0x4072, 0x4034, 0x372a, 0x5b59, 0x393b, 0x337c, 0x5b5b, 0x3374, 0x5b61, 0x5b5e, 0x4073, 0x334b, 0x3a2c, 0x334a, 0x3a4f, 0x5b5c, 0x3765, 0x374b, 0x456d, 0x5b5a, 0x3046, 0x5b5d, 0x5b5f, 0x364d, 0x372c, 0x343c, 0x354b, 0x5b62, 0x3a79, 0x4b71, 0x3b37, 0x5b63, 0x4930, 0x5b6f, 0x3233, 0x5b64, 0x5b75, 0x5b65, 0x4e42, 0x5b6c, 0x475f, 0x5b74, 0x5b67, 0x3034, 0x5b69, 0x393c, 0x5b6b, 0x5b6a, 0x5b66, 0x5b71, 0x3e3f, 0x546d, 0x3868, 0x4d7c, 0x5b68, 0x4474, 0x3323, 0x3a2d, 0x5b60, 0x5b70, 0x3361, 0x5b6e, 0x5b72, 0x456e, 0x347e, 0x5c32, 0x4c49, 0x5b77, 0x347d, 0x5b7e, 0x4b40, 0x5c21, 0x5c23, 0x5c27, 0x5b79, 0x432a, 0x456f, 0x5c2b, 0x5b7c, 0x5c28, 0x5c22, 0x3f39, 0x5c2c, 0x4033, 0x5c2a, 0x343d, 0x4f50, 0x5b76, 0x5c26, 0x3058, 0x5b78, 0x4c3a, 0x5b7d, 0x3f22, 0x4447, 0x5b73, 0x5c25, 0x3f7a, 0x5c2f, 0x3371, 0x3821, 0x5c31, 0x5b7a, 0x5c30, 0x5c29, 0x5b7b, 0x5c2d, 0x5c2e, 0x5c3f, 0x464e, 0x5c24, 0x5c3b, 0x5c3d, 0x4458, 0x4d4c, 0x4976, 0x5c38, 0x424a, 0x5c3e, 0x413f, 0x5c35, 0x5c42, 0x5c41, 0x466f, 0x5c40, 0x466a, 0x5c44, 0x5c37, 0x3648, 0x5c3a, 0x3d5d, 0x4760, 0x5c3c, 0x364b, 0x5c34, 0x5c36, 0x5c33, 0x4f30, 0x335a, 0x5c39, 0x5c43, 0x3335, 0x3a67, 0x315d, 0x5c54, 0x4f31, 0x5c57, 0x3f3a, 0x5c56, 0x5c55, 0x5c52, 0x5c46, 0x5c63, 0x5c45, 0x5c58, 0x5c50, 0x5c4b, 0x5c48, 0x5c49, 0x5c51, 0x7422, 0x5c4e, 0x393d, 0x4448, 0x4164, 0x5c4c, 0x5c47, 0x5c4a, 0x4d4d, 0x4b6a, 0x5c4f, 0x5c59, 0x5c61, 0x5c5a, 0x5c67, 0x5c65, 0x5c60, 0x5c5f, 0x4450, 0x4165, 0x5c5d, 0x5c5b, 0x5c62, 0x5c68, 0x4875, 0x5c6e, 0x5c69, 0x5c6c, 0x5c66, 0x4374, 0x4938, 0x5c5c, 0x5c64, 0x3e40, 0x4c4f, 0x5c78, 0x5c6b, 0x3822, 0x3223, 0x335f, 0x5c53, 0x3e41, 0x5c70, 0x5c77, 0x3c79, 0x3372, 0x432e, 0x5c6d, 0x5c72, 0x5c76, 0x3636, 0x354c, 0x5c74, 0x3521, 0x464b, 0x5c73, 0x5c75, 0x5c6f, 0x5c71, 0x3360, 0x4349, 0x5c7c, 0x5c7a, 0x3869, 0x5c79, 0x5d21, 0x5b58, 0x5c7b, 0x5c7d, 0x5c7e, 0x5d2c, 0x5d28, 0x5b6d, 0x5d27, 0x5d26, 0x5d23, 0x5c6a, 0x5d25, 0x5d24, 0x5d2a, 0x4f26, 0x5d2d, 0x367b, 0x5d29, 0x5d2b, 0x4827, 0x5d2e, 0x5d32, 0x5d2f, 0x4d73, 0x5d30, 0x5c5e, 0x5d33, 0x5d34, 0x3135, 0x5d36, 0x3767, 0x3c21, 0x3655, 0x3224, 0x4d5f, 0x5d38, 0x5d37, 0x5d3a, 0x353d, 0x3656, 0x343e, 0x5d3d, 0x5d3c, 0x5d3e, 0x324e, 0x4337, 0x5d3f, 0x343f, 0x5d41, 0x5d40, 0x5d42, 0x5d43, 0x5d44, 0x3b5f, 0x4035, 0x3a21, 0x4970, 0x4a62, 0x4f44, 0x3b75, 0x3a50, 0x4e72, 0x5d45, 0x5d46, 0x3b60, 0x5d47, 0x5d48, 0x5d4a, 0x5d49, 0x4b58, 0x3d5e, 0x3c6c, 0x3b44, 0x5d4b, 0x5d4d, 0x3f23, 0x5d4c, 0x5d4e, 0x5d4f, 0x5d50, 0x5d51, 0x5d52, 0x5d54, 0x5d53, 0x5d55, 0x3225, 0x434a, 0x5d56, 0x3b26, 0x334c, 0x5d57, 0x4542, 0x544c, 0x3523, 0x5d58, 0x5d59, 0x4a6c, 0x4b68, 0x4647, 0x5d5a, 0x4866, 0x487b, 0x4c53, 0x5d5b, 0x5d5d, 0x5d5c, 0x5d5f, 0x5d5e, 0x5d61, 0x3b61, 0x4c31, 0x5d62, 0x5d63, 0x3524, 0x5d64, 0x5d66, 0x5d65, 0x3f65, 0x4939, 0x314a, 0x4845, 0x4475, 0x3d41, 0x3561, 0x4846, 0x3c2e, 0x5d68, 0x3440, 0x3178, 0x4672, 0x5d67, 0x393e, 0x4353, 0x5d69, 0x5d71, 0x5d6a, 0x4241, 0x3562, 0x5d72, 0x3768, 0x3525, 0x5d70, 0x5d6e, 0x5d6b, 0x4d60, 0x4440, 0x4659, 0x5d6c, 0x5d74, 0x5d73, 0x3723, 0x322d, 0x3a3b, 0x5d6d, 0x5d6f, 0x4b57, 0x4274, 0x4b77, 0x5d7c, 0x5d7d, 0x324f, 0x4a28, 0x4c7d, 0x5e21, 0x3c23, 0x3e42, 0x5d78, 0x5d7e, 0x3168, 0x3637, 0x5d75, 0x5d7a, 0x4074, 0x4771, 0x4867, 0x5d77, 0x4b21, 0x5d79, 0x5e24, 0x5e22, 0x5d7b, 0x4b22, 0x4748, 0x3563, 0x4525, 0x436d, 0x5e25, 0x5e23, 0x4259, 0x5d76, 0x314b, 0x4d4e, 0x5e30, 0x5e2f, 0x4076, 0x5e2c, 0x4d6c, 0x4636, 0x5e26, 0x4445, 0x314c, 0x393f, 0x5e29, 0x3d27, 0x5e2e, 0x5e2d, 0x5e28, 0x5e2b, 0x3368, 0x5e2a, 0x4749, 0x4e2e, 0x3e74, 0x4075, 0x5e36, 0x5e34, 0x494d, 0x5e31, 0x5e33, 0x313a, 0x3940, 0x4f32, 0x333d, 0x4962, 0x4d61, 0x3324, 0x3f3b, 0x5e35, 0x5e3a, 0x3e43, 0x4d30, 0x5e37, 0x5e32, 0x5e38, 0x4e5e, 0x4573, 0x4642, 0x3336, 0x3155, 0x5e3e, 0x5e41, 0x4e43, 0x4d64, 0x5e48, 0x5e42, 0x5e3f, 0x4e54, 0x5e45, 0x3d4a, 0x5e47, 0x5e4c, 0x4571, 0x5e4a, 0x5e44, 0x4338, 0x5e4b, 0x5e40, 0x5e46, 0x5e4d, 0x307c, 0x5e43, 0x5e4e, 0x3f3c, 0x3d5f, 0x4a25, 0x3a2e, 0x5e3b, 0x5e49, 0x453a, 0x4036, 0x3369, 0x3a51, 0x3e44, 0x5e3d, 0x3d42, 0x374c, 0x5e3c, 0x5e52, 0x3d6d, 0x383a, 0x5e61, 0x5e5b, 0x3574, 0x454f, 0x5e56, 0x5e5f, 0x302f, 0x3132, 0x3239, 0x5e58, 0x422c, 0x5e4f, 0x5e51, 0x3941, 0x5e62, 0x5e5d, 0x5e55, 0x5e5c, 0x4c2b, 0x5e5a, 0x5e5e, 0x3850, 0x3e45, 0x4339, 0x5e54, 0x4d2f, 0x5e57, 0x5e50, 0x4572, 0x5e53, 0x5e59, 0x4f51, 0x3c3e, 0x4b7e, 0x5e63, 0x482e, 0x5e6f, 0x383b, 0x3d60, 0x5e65, 0x4e2f, 0x3942, 0x5e72, 0x306e, 0x5e70, 0x5e64, 0x5e6a, 0x5e6c, 0x4d4f, 0x5e67, 0x452e, 0x5e69, 0x5e71, 0x5e6b, 0x4c47, 0x5e66, 0x3c22, 0x5e7e, 0x336a, 0x5e68, 0x5e6d, 0x5e6e, 0x426c, 0x425a, 0x5e76, 0x5e7c, 0x5e7a, 0x4529, 0x5f23, 0x5e77, 0x5e78, 0x5e60, 0x3579, 0x493a, 0x3c3f, 0x3977, 0x4f33, 0x5e74, 0x5f22, 0x3169, 0x4166, 0x4779, 0x3441, 0x4e7a, 0x4c21, 0x4452, 0x5e7b, 0x5e7d, 0x4132, 0x5f21, 0x5e79, 0x5e73, 0x3443, 0x3769, 0x5f2f, 0x5f2a, 0x4078, 0x3363, 0x3d61, 0x5f33, 0x5f2c, 0x442c, 0x5f29, 0x4459, 0x5f4c, 0x5f26, 0x5f25, 0x5f2e, 0x5f28, 0x5f27, 0x5f2d, 0x4021, 0x5f24, 0x5f30, 0x5f31, 0x3442, 0x5f36, 0x5f35, 0x5f37, 0x5f3a, 0x4543, 0x5f34, 0x5f38, 0x3763, 0x4279, 0x5f32, 0x473b, 0x5f39, 0x5f3e, 0x5f3c, 0x5f3f, 0x5f42, 0x5f3b, 0x396a, 0x4728, 0x5e39, 0x4d74, 0x5f3d, 0x5f41, 0x4275, 0x5f40, 0x5f2b, 0x6f69, 0x5f45, 0x5f49, 0x5f47, 0x5f43, 0x5f44, 0x5f48, 0x5f46, 0x494e, 0x5f4e, 0x5f4b, 0x5f4a, 0x5f4d, 0x4654, 0x5f4f, 0x4375, 0x426d, 0x4025, 0x5f50, 0x5f52, 0x5f51, 0x5e75, 0x5f53, 0x4667, 0x5f54, 0x3250, 0x4574, 0x3325, 0x3564, 0x3c5e, 0x3a52, 0x4f27, 0x3f66, 0x316a, 0x5f56, 0x5f55, 0x5f59, 0x433a, 0x5f5c, 0x5f57, 0x5f5b, 0x5f5a, 0x4540, 0x3059, 0x4e75, 0x5f5e, 0x3128, 0x5f60, 0x5f5f, 0x5f5d, 0x5f58, 0x4b23, 0x5f62, 0x5f61, 0x316b, 0x5f64, 0x4a32, 0x5f63, 0x4c35, 0x3e47, 0x4133, 0x3e46, 0x4e7b, 0x5f6a, 0x4079, 0x5f66, 0x5f6b, 0x316c, 0x5f69, 0x4761, 0x5f65, 0x5f68, 0x3e48, 0x4851, 0x5f6c, 0x3c51, 0x407a, 0x5f6f, 0x5f67, 0x3727, 0x5f6d, 0x4d50, 0x5f70, 0x7426, 0x3d4f, 0x5f71, 0x5f72, 0x472e, 0x5f74, 0x5f75, 0x4733, 0x4575, 0x5f77, 0x5f79, 0x4e55, 0x5f76, 0x5f78, 0x316d, 0x5f73, 0x535b, 0x5f7a, 0x4167, 0x3b38, 0x5f7c, 0x5f7b, 0x3f24, 0x5259, 0x5f7d, 0x6021, 0x5f6e, 0x5f7e, 0x6022, 0x477a, 0x6023, 0x6024, 0x6025, 0x6026, 0x445e, 0x6028, 0x6027, 0x6029, 0x602a, 0x3c5f, 0x4963, 0x4c6c, 0x602b, 0x602c, 0x4156, 0x3c24, 0x602d, 0x602e, 0x602f, 0x4a52, 0x4847, 0x6030, 0x4757, 0x442d, 0x6031, 0x3267, 0x356d, 0x4c46, 0x4c36, 0x3234, 0x4f34, 0x4b52, 0x4a2a, 0x4037, 0x6032, 0x4643, 0x3823, 0x6033, 0x3a54, 0x6035, 0x6034, 0x6036, 0x6037, 0x6038, 0x353e, 0x6039, 0x603a, 0x3824, 0x4848, 0x603c, 0x3e75, 0x603b, 0x3638, 0x603d, 0x603f, 0x603e, 0x6040, 0x3851, 0x6041, 0x3669, 0x4140, 0x397d, 0x6043, 0x6044, 0x6042, 0x3c6d, 0x4648, 0x3639, 0x6046, 0x432c, 0x6045, 0x4f35, 0x4762, 0x6049, 0x604b, 0x6048, 0x4c54, 0x604a, 0x604c, 0x4e44, 0x6050, 0x604f, 0x4376, 0x472d, 0x3825, 0x604e, 0x604d, 0x4d31, 0x4d32, 0x6051, 0x316e, 0x3976, 0x3b62, 0x6052, 0x6053, 0x6055, 0x3d43, 0x6057, 0x6056, 0x6058, 0x334d, 0x605a, 0x6059, 0x605c, 0x605b, 0x383c, 0x4e28, 0x364c, 0x3226, 0x366a, 0x3461, 0x4e68, 0x605e, 0x6060, 0x6061, 0x3251, 0x605d, 0x3b39, 0x4441, 0x605f, 0x6064, 0x3c6e, 0x6062, 0x373e, 0x4849, 0x6063, 0x607e, 0x6069, 0x383d, 0x3565, 0x6066, 0x4d7d, 0x4e30, 0x4276, 0x6068, 0x606a, 0x4e56, 0x3657, 0x487c, 0x474a, 0x606b, 0x606d, 0x6070, 0x606c, 0x606f, 0x386a, 0x314d, 0x6071, 0x3f70, 0x606e, 0x4e5c, 0x6074, 0x7424, 0x6072, 0x6075, 0x6067, 0x6073, 0x3a3c, 0x6076, 0x6077, 0x4d7e, 0x6078, 0x6079, 0x6065, 0x607a, 0x3444, 0x3c25, 0x607b, 0x607c, 0x607d, 0x313b, 0x6121, 0x493b, 0x6122, 0x3424, 0x6123, 0x6124, 0x6125, 0x6127, 0x6128, 0x6126, 0x4953, 0x612a, 0x6129, 0x612c, 0x612b, 0x612d, 0x612e, 0x6130, 0x612f, 0x3979, 0x6132, 0x6131, 0x3445, 0x3f53, 0x453c, 0x6133, 0x4038, 0x3b3a, 0x3179, 0x6134, 0x4d51, 0x4a63, 0x6135, 0x4544, 0x4d33, 0x3943, 0x3f3d, 0x434b, 0x5234, 0x442e, 0x3268, 0x6136, 0x6137, 0x613c, 0x613a, 0x6139, 0x5a42, 0x3326, 0x6138, 0x305a, 0x482a, 0x484a, 0x4e31, 0x613d, 0x613b, 0x435c, 0x4026, 0x482b, 0x492d, 0x613f, 0x4e2c, 0x374d, 0x6140, 0x613e, 0x4856, 0x6141, 0x6142, 0x305b, 0x3e76, 0x6147, 0x6144, 0x466d, 0x6143, 0x3526, 0x614a, 0x6145, 0x6146, 0x6149, 0x6148, 0x4925, 0x4142, 0x4141, 0x353f, 0x614b, 0x614c, 0x614d, 0x614f, 0x614e, 0x3156, 0x6157, 0x4868, 0x6151, 0x6153, 0x6155, 0x3f3e, 0x6156, 0x6154, 0x3c40, 0x6150, 0x6152, 0x4942, 0x3e49, 0x6159, 0x6158, 0x615a, 0x3c26, 0x3a2f, 0x4577, 0x615b, 0x444b, 0x615d, 0x4e21, 0x615c, 0x4169, 0x6162, 0x6164, 0x6165, 0x4354, 0x6163, 0x6160, 0x615e, 0x615f, 0x6161, 0x6168, 0x6166, 0x6167, 0x6169, 0x616b, 0x616c, 0x616d, 0x616e, 0x616a, 0x6170, 0x616f, 0x6171, 0x4e45, 0x6174, 0x6172, 0x6173, 0x3462, 0x4c7e, 0x4a4a, 0x6176, 0x6175, 0x6177, 0x6178, 0x617c, 0x6179, 0x617a, 0x617b, 0x617d, 0x617e, 0x6221, 0x6222, 0x6223, 0x482f, 0x4550, 0x6224, 0x4772, 0x4934, 0x6225, 0x6226, 0x452a, 0x3327, 0x3944, 0x6227, 0x6228, 0x6229, 0x3b29, 0x622b, 0x622a, 0x622c, 0x622d, 0x4869, 0x622e, 0x622f, 0x7369, 0x6230, 0x6231, 0x6232, 0x3b2e, 0x6233, 0x4756, 0x4b5f, 0x314e, 0x3157, 0x6234, 0x6236, 0x6235, 0x4570, 0x4039, 0x5d39, 0x6237, 0x4c41, 0x6238, 0x3446, 0x4857, 0x6239, 0x623a, 0x623b, 0x4c5c, 0x4c55, 0x443e, 0x416a, 0x623d, 0x3d62, 0x3e4a, 0x6240, 0x623f, 0x623e, 0x487d, 0x3447, 0x3829, 0x6246, 0x6243, 0x3f3f, 0x4c32, 0x6242, 0x6244, 0x6245, 0x6241, 0x6247, 0x6248, 0x442f, 0x3463, 0x4365, 0x6249, 0x624a, 0x624d, 0x3f67, 0x4644, 0x624e, 0x4b53, 0x624b, 0x624c, 0x6251, 0x6250, 0x624f, 0x6253, 0x6252, 0x6254, 0x6256, 0x6255, 0x4a4d, 0x3d56, 0x4e46, 0x6257, 0x4637, 0x6258, 0x6259, 0x625d, 0x625b, 0x625c, 0x625a, 0x625e, 0x625f, 0x6260, 0x6261, 0x4c37, 0x6262, 0x4c70, 0x6263, 0x434e, 0x476a, 0x366b, 0x433b, 0x6264, 0x363a, 0x4050, 0x6265, 0x3a3d, 0x6266, 0x6267, 0x3826, 0x3a55, 0x6269, 0x4556, 0x3a56, 0x354e, 0x4b24, 0x474b, 0x4557, 0x395c, 0x626b, 0x3e4b, 0x4e32, 0x3945, 0x3827, 0x4823, 0x626d, 0x626f, 0x386b, 0x626e, 0x4476, 0x6271, 0x3337, 0x626c, 0x486a, 0x3130, 0x3a6c, 0x4f52, 0x6270, 0x6272, 0x4a4b, 0x4059, 0x6274, 0x6275, 0x6273, 0x334e, 0x627b, 0x627a, 0x3c27, 0x627c, 0x6277, 0x627d, 0x6278, 0x4858, 0x6276, 0x6279, 0x6322, 0x6321, 0x4b61, 0x627e, 0x306b, 0x6324, 0x6323, 0x3e4c, 0x6325, 0x4143, 0x6327, 0x6326, 0x6328, 0x6268, 0x626a, 0x632a, 0x6329, 0x3c28, 0x4e69, 0x3c52, 0x632b, 0x3737, 0x3540, 0x3527, 0x3b63, 0x4d34, 0x6331, 0x6330, 0x4144, 0x632d, 0x632f, 0x3d4b, 0x3f40, 0x632e, 0x632c, 0x472a, 0x3e4d, 0x493c, 0x3a57, 0x4578, 0x6332, 0x6333, 0x6349, 0x3658, 0x4f3d, 0x4135, 0x6334, 0x3252, 0x4477, 0x4a21, 0x6335, 0x357a, 0x6336, 0x6338, 0x6339, 0x4729, 0x633a, 0x633b, 0x633c, 0x3659, 0x3253, 0x4645, 0x3d28, 0x3b64, 0x633d, 0x3d29, 0x324a, 0x4943, 0x633e, 0x486b, 0x4145, 0x6341, 0x6342, 0x4769, 0x3f41, 0x633f, 0x4361, 0x6340, 0x3e4e, 0x305c, 0x3529, 0x6343, 0x4478, 0x6344, 0x4047, 0x4c2d, 0x4923, 0x6345, 0x6346, 0x4355, 0x4e47, 0x6348, 0x6347, 0x3c6f, 0x634a, 0x3070, 0x634d, 0x634b, 0x3254, 0x374e, 0x634c, 0x3946, 0x3972, 0x4a66, 0x634e, 0x4b54, 0x6350, 0x4051, 0x314f, 0x323a, 0x302c, 0x634f, 0x6351, 0x6352, 0x3e77, 0x6353, 0x334f, 0x6355, 0x376a, 0x3566, 0x6356, 0x3675, 0x6357, 0x407c, 0x464d, 0x4060, 0x3a75, 0x6358, 0x4362, 0x416b, 0x635a, 0x635c, 0x6359, 0x635b, 0x3722, 0x635d, 0x3726, 0x3567, 0x4d52, 0x635f, 0x6360, 0x312e, 0x6363, 0x3376, 0x6362, 0x6361, 0x6365, 0x635e, 0x6366, 0x4e29, 0x6367, 0x6368, 0x5474, 0x636a, 0x6369, 0x636b, 0x636c, 0x4e35, 0x636d, 0x706f, 0x3e4f, 0x636e, 0x636f, 0x3d57, 0x4638, 0x6370, 0x4328, 0x6371, 0x433c, 0x6372, 0x3625, 0x513f, 0x435d, 0x3c33, 0x3448, 0x6373, 0x6422, 0x6376, 0x3568, 0x6375, 0x6424, 0x6374, 0x3e50, 0x6378, 0x6379, 0x452b, 0x637a, 0x335e, 0x3f5a, 0x4964, 0x637c, 0x4268, 0x6377, 0x637b, 0x637d, 0x3a7b, 0x6426, 0x492e, 0x4826, 0x4579, 0x365a, 0x6425, 0x6423, 0x4835, 0x637e, 0x435e, 0x457b, 0x457a, 0x3a76, 0x6438, 0x6428, 0x642a, 0x642d, 0x642e, 0x642b, 0x642c, 0x6429, 0x6427, 0x6421, 0x4a4f, 0x3255, 0x6435, 0x6432, 0x6437, 0x6436, 0x4773, 0x4c27, 0x3b3b, 0x6430, 0x6439, 0x6434, 0x6433, 0x642f, 0x6431, 0x3449, 0x433d, 0x407d, 0x4822, 0x643e, 0x4824, 0x4061, 0x643b, 0x484f, 0x643f, 0x4a53, 0x435b, 0x643a, 0x643c, 0x643d, 0x6440, 0x3c44, 0x4646, 0x6445, 0x6444, 0x6441, 0x4f36, 0x644a, 0x644e, 0x644b, 0x6447, 0x6448, 0x644d, 0x6442, 0x5255, 0x6449, 0x6443, 0x644c, 0x6452, 0x344a, 0x644f, 0x6450, 0x6451, 0x6454, 0x6453, 0x4876, 0x6455, 0x4e7c, 0x4a6d, 0x645a, 0x6457, 0x6456, 0x4052, 0x6459, 0x645b, 0x6458, 0x645f, 0x645c, 0x645d, 0x6446, 0x645e, 0x6460, 0x6461, 0x4a46, 0x6462, 0x4c62, 0x364e, 0x3729, 0x6463, 0x4a34, 0x3f68, 0x4c30, 0x6464, 0x4e33, 0x4774, 0x4146, 0x4734, 0x3d4d, 0x3040, 0x6469, 0x6467, 0x6465, 0x3421, 0x3e51, 0x646a, 0x6468, 0x6466, 0x646e, 0x646d, 0x646c, 0x646b, 0x646f, 0x6470, 0x403a, 0x6471, 0x6473, 0x6472, 0x3852, 0x4138, 0x6475, 0x457c, 0x6474, 0x6476, 0x4a35, 0x416c, 0x3947, 0x6477, 0x4e48, 0x6479, 0x647a, 0x647b, 0x647c, 0x3b65, 0x647d, 0x374f, 0x356a, 0x352a, 0x6521, 0x4c73, 0x3948, 0x647e, 0x6524, 0x4c66, 0x473c, 0x4933, 0x3d63, 0x6523, 0x3c53, 0x3949, 0x3b66, 0x3569, 0x4a36, 0x6522, 0x4147, 0x4b42, 0x3a77, 0x3b67, 0x445d, 0x6527, 0x4e5f, 0x3a59, 0x6528, 0x3f42, 0x652a, 0x3e52, 0x3a30, 0x6529, 0x3d2a, 0x383e, 0x4148, 0x6525, 0x652b, 0x6526, 0x3750, 0x652e, 0x6532, 0x376b, 0x652d, 0x6536, 0x394a, 0x4d6d, 0x303c, 0x6533, 0x356b, 0x6530, 0x6531, 0x457d, 0x652f, 0x652c, 0x3328, 0x4064, 0x3828, 0x6538, 0x6535, 0x6537, 0x6534, 0x3751, 0x4233, 0x6539, 0x416e, 0x6546, 0x6542, 0x653c, 0x6540, 0x3c7a, 0x305d, 0x653b, 0x6543, 0x6547, 0x394b, 0x4c56, 0x4456, 0x653d, 0x6545, 0x653a, 0x433e, 0x653f, 0x303d, 0x4c4a, 0x653e, 0x365b, 0x486c, 0x416d, 0x4e50, 0x3d6f, 0x656e, 0x6548, 0x407e, 0x6544, 0x6549, 0x654b, 0x4479, 0x654e, 0x654a, 0x4a54, 0x344b, 0x4c4b, 0x305e, 0x654d, 0x4e7d, 0x654c, 0x316f, 0x466c, 0x654f, 0x6556, 0x6550, 0x6557, 0x6553, 0x477b, 0x3c4a, 0x6555, 0x6552, 0x6558, 0x6551, 0x3d44, 0x4b25, 0x3d4c, 0x6554, 0x6560, 0x655c, 0x655f, 0x655d, 0x6561, 0x655b, 0x6541, 0x4053, 0x484b, 0x655e, 0x6559, 0x4121, 0x3752, 0x3d2b, 0x3f25, 0x4136, 0x6564, 0x6566, 0x6567, 0x6563, 0x6565, 0x655a, 0x6562, 0x656a, 0x6569, 0x4b7a, 0x372b, 0x6568, 0x656c, 0x656b, 0x656f, 0x6571, 0x3b3c, 0x656d, 0x6572, 0x6573, 0x6574, 0x657a, 0x453b, 0x6576, 0x6575, 0x6577, 0x6578, 0x6579, 0x657b, 0x657c, 0x344c, 0x657d, 0x657e, 0x6621, 0x6622, 0x6623, 0x6624, 0x6625, 0x6626, 0x6628, 0x6627, 0x6629, 0x662a, 0x662b, 0x662e, 0x662c, 0x662d, 0x3a61, 0x3753, 0x4356, 0x4833, 0x3d70, 0x474d, 0x486d, 0x662f, 0x586d, 0x6630, 0x6632, 0x4d65, 0x6631, 0x6634, 0x6633, 0x4d53, 0x6635, 0x487e, 0x6636, 0x6639, 0x6638, 0x6637, 0x663a, 0x3732, 0x4122, 0x3541, 0x663e, 0x663b, 0x663c, 0x663f, 0x6640, 0x663d, 0x3129, 0x3227, 0x6642, 0x6643, 0x6644, 0x4d62, 0x3d2c, 0x6646, 0x6645, 0x3f69, 0x6647, 0x6648, 0x6649, 0x3465, 0x344d, 0x664a, 0x664b, 0x4b5d, 0x4d63, 0x4d54, 0x4f37, 0x394d, 0x664e, 0x3c54, 0x664d, 0x664f, 0x3c29, 0x4251, 0x6650, 0x394c, 0x4c57, 0x6651, 0x6652, 0x6653, 0x6654, 0x6655, 0x3c2a, 0x4c6d, 0x6657, 0x433f, 0x6656, 0x6659, 0x6658, 0x665a, 0x403b, 0x665b, 0x665c, 0x4a39, 0x665d, 0x416f, 0x665e, 0x665f, 0x4e7e, 0x6662, 0x6661, 0x6660, 0x4430, 0x6663, 0x3f26, 0x6664, 0x6665, 0x4f38, 0x6666, 0x6667, 0x6669, 0x6668, 0x4825, 0x4679, 0x4f3e, 0x4829, 0x666b, 0x3e53, 0x492a, 0x666c, 0x666a, 0x344e, 0x3854, 0x3b68, 0x486e, 0x382a, 0x4b43, 0x666f, 0x666d, 0x394e, 0x394f, 0x3069, 0x3a68, 0x4759, 0x305f, 0x6674, 0x4340, 0x4758, 0x425b, 0x6676, 0x6672, 0x6675, 0x6670, 0x6673, 0x4b26, 0x3855, 0x307d, 0x6671, 0x6678, 0x6679, 0x4639, 0x363b, 0x6726, 0x473d, 0x3b69, 0x363c, 0x4048, 0x4f46, 0x4c2e, 0x6677, 0x4054, 0x3553, 0x667a, 0x667c, 0x667b, 0x667d, 0x4326, 0x473e, 0x4431, 0x6723, 0x6722, 0x667e, 0x3f55, 0x4965, 0x6725, 0x6724, 0x3950, 0x4f53, 0x6735, 0x6729, 0x672a, 0x3c70, 0x6728, 0x3978, 0x6727, 0x672b, 0x4432, 0x4a22, 0x4123, 0x425c, 0x672f, 0x6730, 0x672c, 0x672d, 0x672e, 0x3951, 0x6736, 0x6732, 0x4966, 0x4b6c, 0x4928, 0x6731, 0x6734, 0x6733, 0x4b44, 0x6737, 0x6738, 0x4137, 0x6739, 0x673b, 0x673f, 0x673c, 0x673a, 0x473f, 0x673d, 0x673e, 0x3232, 0x6745, 0x6740, 0x6741, 0x6742, 0x4221, 0x6744, 0x6743, 0x6746, 0x6747, 0x6748, 0x3f43, 0x3269, 0x6749, 0x4e57, 0x3c2b, 0x3d2d, 0x3b6a, 0x4357, 0x674a, 0x674b, 0x3131, 0x674c, 0x674d, 0x674e, 0x674f, 0x6750, 0x363d, 0x5a2a, 0x6751, 0x4065, 0x6752, 0x3c4b, 0x6753, 0x5030, 0x6754, 0x4a5e, 0x345c, 0x4124, 0x3d58, 0x4971, 0x3d2e, 0x6755, 0x3952, 0x6756, 0x484c, 0x6764, 0x6758, 0x4249, 0x4775, 0x383f, 0x6757, 0x4125, 0x6759, 0x447a, 0x675b, 0x675a, 0x675d, 0x675c, 0x675e, 0x6760, 0x675f, 0x344f, 0x6761, 0x6762, 0x6763, 0x3a31, 0x4e49, 0x6765, 0x3f27, 0x3170, 0x6766, 0x6767, 0x6768, 0x3072, 0x6769, 0x676a, 0x4967, 0x3c47, 0x676c, 0x3329, 0x3032, 0x676b, 0x676e, 0x474e, 0x3f44, 0x3256, 0x4b27, 0x375d, 0x365c, 0x676d, 0x326a, 0x3423, 0x3171, 0x6772, 0x4e6a, 0x425d, 0x4944, 0x677e, 0x3257, 0x677c, 0x677a, 0x6771, 0x676f, 0x6770, 0x3c63, 0x366c, 0x4377, 0x4651, 0x3151, 0x6774, 0x6773, 0x6779, 0x6775, 0x6778, 0x4c50, 0x6777, 0x3258, 0x337d, 0x677b, 0x677d, 0x3754, 0x6823, 0x682c, 0x682d, 0x302b, 0x6834, 0x3071, 0x682b, 0x682a, 0x6825, 0x6824, 0x6822, 0x6821, 0x4363, 0x427b, 0x6827, 0x6826, 0x6829, 0x4170, 0x3755, 0x3141, 0x6828, 0x3953, 0x4171, 0x683a, 0x683b, 0x3259, 0x322e, 0x6838, 0x682e, 0x6836, 0x683d, 0x6837, 0x6835, 0x6776, 0x6833, 0x682f, 0x3450, 0x6831, 0x683c, 0x6832, 0x683e, 0x6830, 0x477c, 0x4d69, 0x6839, 0x684f, 0x6847, 0x3f7b, 0x3546, 0x365d, 0x6842, 0x325b, 0x3e54, 0x6845, 0x3a5a, 0x4551, 0x684a, 0x4a6e, 0x6841, 0x325a, 0x3856, 0x4929, 0x684b, 0x683f, 0x6848, 0x6852, 0x6843, 0x6844, 0x463a, 0x6849, 0x6846, 0x4b28, 0x684c, 0x3060, 0x6840, 0x684e, 0x684d, 0x476b, 0x6854, 0x685f, 0x337e, 0x6862, 0x6850, 0x6855, 0x4d6e, 0x685e, 0x4d55, 0x4e2a, 0x4378, 0x336b, 0x4972, 0x6864, 0x4621, 0x3031, 0x685d, 0x6859, 0x4172, 0x6853, 0x685b, 0x6860, 0x472c, 0x302a, 0x6858, 0x6861, 0x4978, 0x685c, 0x6857, 0x3e55, 0x3d2f, 0x3c2c, 0x4c58, 0x4947, 0x6867, 0x6870, 0x685a, 0x3377, 0x3e78, 0x6865, 0x686a, 0x4173, 0x6866, 0x686d, 0x435f, 0x686e, 0x4d56, 0x6863, 0x3338, 0x6869, 0x686c, 0x4c2c, 0x686f, 0x6868, 0x686b, 0x4b29, 0x4f21, 0x6873, 0x687a, 0x6872, 0x3c43, 0x6851, 0x4a4e, 0x4c22, 0x6879, 0x6878, 0x6874, 0x6875, 0x3136, 0x6877, 0x6871, 0x4455, 0x6876, 0x307e, 0x4222, 0x4a43, 0x687b, 0x6921, 0x4859, 0x687e, 0x3e56, 0x3c49, 0x6923, 0x363e, 0x6924, 0x4979, 0x687d, 0x6856, 0x687c, 0x4f4f, 0x4622, 0x4973, 0x692b, 0x6931, 0x6932, 0x6925, 0x4776, 0x692f, 0x6927, 0x6929, 0x6933, 0x6928, 0x692c, 0x3172, 0x4665, 0x692d, 0x6930, 0x6926, 0x4126, 0x692a, 0x3b27, 0x3f45, 0x3730, 0x4c74, 0x4c79, 0x3d72, 0x6937, 0x6935, 0x4f4e, 0x6934, 0x4d75, 0x6936, 0x6938, 0x6939, 0x693c, 0x693a, 0x4623, 0x693b, 0x484d, 0x692e, 0x3d73, 0x693d, 0x6942, 0x4174, 0x6941, 0x6922, 0x6943, 0x4149, 0x693e, 0x6940, 0x693f, 0x5d31, 0x5d22, 0x6945, 0x6944, 0x4d76, 0x623c, 0x6946, 0x6947, 0x6948, 0x3857, 0x3554, 0x694a, 0x515d, 0x3575, 0x4e3a, 0x3673, 0x694b, 0x694c, 0x436e, 0x694d, 0x467a, 0x303a, 0x3263, 0x6952, 0x6953, 0x694e, 0x3b3d, 0x694f, 0x4742, 0x6950, 0x6951, 0x695b, 0x6955, 0x6958, 0x6954, 0x6956, 0x6957, 0x3c58, 0x6959, 0x4341, 0x3756, 0x3342, 0x695c, 0x333f, 0x6961, 0x695d, 0x6960, 0x483a, 0x695e, 0x695f, 0x4948, 0x485a, 0x6962, 0x427d, 0x696c, 0x6968, 0x326b, 0x6966, 0x4b2a, 0x6967, 0x6964, 0x6965, 0x696a, 0x696d, 0x696b, 0x6969, 0x6963, 0x4358, 0x6974, 0x4c2a, 0x6972, 0x6973, 0x696e, 0x6970, 0x6971, 0x696f, 0x4066, 0x4f39, 0x6978, 0x6979, 0x6a21, 0x3f2a, 0x697b, 0x697e, 0x6976, 0x6975, 0x6a22, 0x325c, 0x697c, 0x6a23, 0x697d, 0x697a, 0x4433, 0x6977, 0x4768, 0x6a27, 0x4d3b, 0x6a26, 0x6a25, 0x6a2e, 0x6a28, 0x6a30, 0x4d66, 0x6a33, 0x6a2a, 0x6a2b, 0x6a2f, 0x6a32, 0x6a31, 0x6a29, 0x6a2c, 0x6a3d, 0x6a36, 0x6a34, 0x6a35, 0x6a3a, 0x6a3b, 0x332a, 0x3542, 0x6a39, 0x6a24, 0x6a38, 0x6a3c, 0x6a37, 0x6a3e, 0x6a40, 0x6a3f, 0x6a42, 0x6a41, 0x695a, 0x6a46, 0x6a43, 0x6a44, 0x6a45, 0x6a47, 0x376c, 0x6a49, 0x6a48, 0x3d30, 0x3954, 0x5e27, 0x6a4a, 0x3d51, 0x3339, 0x6a4b, 0x3152, 0x3e57, 0x6a4c, 0x3955, 0x6a4d, 0x3061, 0x493d, 0x6a4e, 0x3f6a, 0x6a55, 0x6a52, 0x436f, 0x6a53, 0x6a50, 0x365e, 0x6a4f, 0x6a56, 0x3736, 0x425e, 0x6a5c, 0x6a58, 0x4235, 0x6a57, 0x6a5a, 0x6a51, 0x6a5b, 0x6a5d, 0x486f, 0x6a59, 0x6a5e, 0x6a60, 0x3853, 0x6a54, 0x3041, 0x6a5f, 0x3a5b, 0x4e76, 0x6a61, 0x6a62, 0x4175, 0x4e22, 0x6a63, 0x4d35, 0x6a64, 0x6a65, 0x4a64, 0x6a66, 0x3a40, 0x4e23, 0x6a6b, 0x6a6c, 0x3e58, 0x6a6a, 0x4d67, 0x6a67, 0x6a69, 0x403d, 0x3f7e, 0x6a68, 0x6a6d, 0x4a23, 0x6a6f, 0x6a6e, 0x336c, 0x4b2b, 0x6a70, 0x6a7c, 0x6a72, 0x6a73, 0x6a74, 0x6a75, 0x6a79, 0x6a7a, 0x6a78, 0x6a76, 0x6a71, 0x6a77, 0x6a7b, 0x7037, 0x3228, 0x6a7e, 0x365f, 0x6a7d, 0x6b22, 0x6b21, 0x6b24, 0x6b23, 0x6b25, 0x3d31, 0x6b26, 0x6b27, 0x6b28, 0x403e, 0x4d57, 0x6b29, 0x4a24, 0x4746, 0x6b2a, 0x6b2b, 0x382b, 0x352c, 0x6b2c, 0x3b6b, 0x4741, 0x6b2d, 0x3350, 0x6b2e, 0x6b30, 0x4d77, 0x6b2f, 0x3f46, 0x6b31, 0x6b32, 0x6b33, 0x3451, 0x6b34, 0x6b35, 0x6b36, 0x6b37, 0x3351, 0x6b38, 0x6b39, 0x6b3a, 0x3272, 0x3f28, 0x6b3b, 0x6b3c, 0x6b3d, 0x3840, 0x447b, 0x6b3e, 0x3757, 0x3f56, 0x6b41, 0x4624, 0x6b40, 0x3731, 0x6b3f, 0x4277, 0x352d, 0x6b42, 0x6b43, 0x3e59, 0x376d, 0x6b44, 0x4b2c, 0x405f, 0x3576, 0x4c75, 0x414a, 0x6b45, 0x3f47, 0x4370, 0x3e5a, 0x6b46, 0x6b49, 0x6b4a, 0x3a3e, 0x4242, 0x6b48, 0x3e5b, 0x493e, 0x6b47, 0x3b6c, 0x3153, 0x6b4e, 0x3758, 0x3b6e, 0x3b6d, 0x4f4d, 0x6b4d, 0x6b4c, 0x4127, 0x354d, 0x4f43, 0x333a, 0x3e5c, 0x6b4b, 0x6b50, 0x6b51, 0x6b4f, 0x3858, 0x4d40, 0x3b6f, 0x4727, 0x6b54, 0x4040, 0x4342, 0x4d36, 0x6b57, 0x386c, 0x403f, 0x6b53, 0x6b58, 0x386d, 0x6b55, 0x6b56, 0x6b52, 0x4062, 0x4649, 0x432f, 0x325d, 0x4870, 0x3543, 0x4434, 0x6b5b, 0x6b59, 0x434c, 0x4041, 0x3452, 0x6b5a, 0x3f5b, 0x4e4a, 0x4f40, 0x6b5c, 0x6b67, 0x4435, 0x6b66, 0x6b63, 0x6b6b, 0x6b64, 0x6b60, 0x447c, 0x6b5f, 0x6b5d, 0x4d21, 0x3b70, 0x6b61, 0x6b5e, 0x6b65, 0x3d74, 0x3841, 0x427a, 0x4b45, 0x315a, 0x3062, 0x4625, 0x6b69, 0x6b68, 0x4666, 0x6b6d, 0x6b62, 0x6b6c, 0x6b6e, 0x382c, 0x6b6a, 0x3956, 0x3c55, 0x6b6f, 0x4d58, 0x6b72, 0x6b75, 0x6b73, 0x4935, 0x6b70, 0x3660, 0x6b74, 0x6b76, 0x6b7a, 0x6b77, 0x6b79, 0x6b78, 0x6b7b, 0x3c31, 0x6b7d, 0x6b7c, 0x4968, 0x6c21, 0x3759, 0x6b7e, 0x6c22, 0x6c23, 0x3544, 0x6641, 0x3e79, 0x6c24, 0x386e, 0x6c25, 0x6c26, 0x3b3e, 0x5a4e, 0x6c27, 0x6c28, 0x3d32, 0x6c29, 0x6c2a, 0x6c2b, 0x6c2c, 0x6c2d, 0x432b, 0x6c2e, 0x6c30, 0x6c2f, 0x4626, 0x6c31, 0x4b2d, 0x6c32, 0x6c33, 0x6c34, 0x6c35, 0x465a, 0x3e5d, 0x6c36, 0x396b, 0x502e, 0x6c37, 0x6c38, 0x493f, 0x6c39, 0x6c41, 0x6c3a, 0x6c3c, 0x6c3b, 0x6c3d, 0x4b46, 0x6c3e, 0x6c3f, 0x6c40, 0x6c42, 0x332d, 0x4467, 0x4969, 0x3a62, 0x3957, 0x494f, 0x325f, 0x484e, 0x6c45, 0x3453, 0x4055, 0x6c44, 0x6c49, 0x4379, 0x4c63, 0x6c47, 0x6c48, 0x352e, 0x6c4a, 0x4763, 0x425f, 0x4871, 0x453d, 0x6c46, 0x4b47, 0x326c, 0x6c4c, 0x4f28, 0x4442, 0x4f45, 0x3b71, 0x6c4b, 0x4231, 0x6c5c, 0x4128, 0x4678, 0x4950, 0x6c4f, 0x3b3f, 0x3b72, 0x3e5e, 0x4765, 0x382d, 0x6c4e, 0x6c4d, 0x496a, 0x3c41, 0x4552, 0x6c51, 0x6c52, 0x3958, 0x6c50, 0x6c53, 0x6c54, 0x6c56, 0x4223, 0x6c55, 0x3466, 0x6c58, 0x6c57, 0x6c59, 0x6c5b, 0x6c5d, 0x6c5e, 0x4056, 0x3c4f, 0x6c5f, 0x3352, 0x6c60, 0x4176, 0x6c61, 0x6c62, 0x496b, 0x352f, 0x6c63, 0x4436, 0x315b, 0x6c64, 0x3c71, 0x3f76, 0x422d, 0x6c67, 0x6c66, 0x6c65, 0x6c6d, 0x6c6b, 0x6c68, 0x6c6a, 0x6c69, 0x6c6c, 0x3577, 0x6c70, 0x4057, 0x6c71, 0x3859, 0x6c6e, 0x6c6f, 0x4f29, 0x4437, 0x4129, 0x6c72, 0x6c75, 0x6c73, 0x6c74, 0x4d59, 0x4627, 0x6c78, 0x6c76, 0x6c77, 0x6c79, 0x6d29, 0x6c7c, 0x6c7d, 0x6c7b, 0x6c7a, 0x447d, 0x6d21, 0x6d25, 0x6d22, 0x6c7e, 0x6d23, 0x6d24, 0x6d2b, 0x6d26, 0x4058, 0x6d28, 0x6d2a, 0x6d27, 0x6d2d, 0x3d33, 0x6d2c, 0x6d2e, 0x6d2f, 0x6d32, 0x6d31, 0x6d30, 0x6d34, 0x6d33, 0x4c76, 0x6d36, 0x6d35, 0x6d37, 0x6d38, 0x6d3a, 0x6d39, 0x3f48, 0x6d3b, 0x366d, 0x6d3c, 0x6d3e, 0x6d3f, 0x6d40, 0x6d3d, 0x6d41, 0x3c56, 0x6d42, 0x3530, 0x3733, 0x382e, 0x6d43, 0x4670, 0x453e, 0x6d44, 0x6d47, 0x3c34, 0x6d46, 0x6d45, 0x375a, 0x6d48, 0x3353, 0x6d4a, 0x3a5c, 0x6d49, 0x6d52, 0x6d4c, 0x6d4e, 0x4a65, 0x6d4b, 0x6d4d, 0x6d51, 0x6d4f, 0x3531, 0x6d50, 0x6d53, 0x475a, 0x4e58, 0x3d34, 0x6d54, 0x4d22, 0x6d56, 0x6d55, 0x6d59, 0x4d41, 0x6d58, 0x336d, 0x6d57, 0x6d5c, 0x6d5b, 0x6d5a, 0x4532, 0x6d5d, 0x6d5e, 0x6d5f, 0x396c, 0x3725, 0x6d60, 0x6d61, 0x6d62, 0x3f49, 0x6d63, 0x3c2d, 0x6d64, 0x6d65, 0x5221, 0x517e, 0x6d66, 0x6570, 0x6d67, 0x4324, 0x3f2b, 0x4740, 0x6d68, 0x4a55, 0x4454, 0x397e, 0x4329, 0x312a, 0x4b78, 0x3f57, 0x375e, 0x3661, 0x4a56, 0x6d69, 0x6d6b, 0x6d6a, 0x3260, 0x4676, 0x6d6c, 0x4777, 0x4533, 0x6d6d, 0x3d52, 0x6d6f, 0x4c42, 0x6d7e, 0x6d71, 0x6d72, 0x4449, 0x4260, 0x4177, 0x4628, 0x6d70, 0x3555, 0x6d79, 0x6d76, 0x6e25, 0x4629, 0x4360, 0x6d73, 0x447e, 0x4553, 0x6d74, 0x6d78, 0x3f60, 0x4767, 0x444c, 0x4042, 0x6d77, 0x422e, 0x4224, 0x6d75, 0x3029, 0x4f22, 0x6d7a, 0x4261, 0x3d35, 0x3f4a, 0x6d7c, 0x6d7b, 0x306f, 0x6d7d, 0x492f, 0x6e27, 0x465b, 0x3f6b, 0x4359, 0x3678, 0x6e26, 0x4d37, 0x313f, 0x4a57, 0x3261, 0x6e21, 0x6e22, 0x6e23, 0x6e24, 0x463b, 0x4323, 0x3063, 0x6e28, 0x6e29, 0x7423, 0x423d, 0x6e2a, 0x3173, 0x414c, 0x382f, 0x4d5a, 0x6e2b, 0x452c, 0x4178, 0x3c57, 0x6e2c, 0x6e2f, 0x3d65, 0x6e2d, 0x412b, 0x412a, 0x3064, 0x4e4b, 0x6e31, 0x4872, 0x6e33, 0x6e32, 0x6e30, 0x6364, 0x3454, 0x6d6e, 0x6e35, 0x6e34, 0x6e36, 0x4d38, 0x4661, 0x4b2e, 0x6e37, 0x3c59, 0x6e38, 0x6e39, 0x6e3a, 0x4521, 0x306a, 0x3959, 0x4f3a, 0x6e3e, 0x3734, 0x6e3b, 0x6e3c, 0x4974, 0x3354, 0x4d39, 0x363f, 0x4554, 0x6e3f, 0x6e40, 0x6e41, 0x4522, 0x6e43, 0x6e42, 0x4653, 0x6e44, 0x3d36, 0x3c60, 0x475b, 0x4371, 0x3c72, 0x3f6c, 0x6e45, 0x6e46, 0x3f5d, 0x6e47, 0x6e48, 0x6e49, 0x4d6f, 0x3d37, 0x6e4b, 0x6e4a, 0x395a, 0x3973, 0x3b40, 0x6e4e, 0x3d66, 0x6e4d, 0x6e4c, 0x4269, 0x386f, 0x4043, 0x4830, 0x3d39, 0x6e4f, 0x3e5f, 0x6e52, 0x6e50, 0x6e51, 0x6e54, 0x6e53, 0x3e7a, 0x6e55, 0x6e56, 0x6e57, 0x4850, 0x3a53, 0x3c61, 0x6e58, 0x6e59, 0x4e24, 0x3d45, 0x4c6e, 0x4e4c, 0x6e5a, 0x3662, 0x6e5b, 0x4523, 0x6e5e, 0x3378, 0x3f4b, 0x6e5c, 0x6e5d, 0x4460, 0x4b55, 0x367c, 0x6e60, 0x6e61, 0x6e5f, 0x6e63, 0x465f, 0x3343, 0x6e67, 0x6e64, 0x6e66, 0x6e62, 0x6f4f, 0x6e65, 0x4e6b, 0x385a, 0x6e6f, 0x4534, 0x6e6a, 0x6e6d, 0x6e6b, 0x6e70, 0x6e71, 0x6e69, 0x6e76, 0x3174, 0x6e68, 0x482d, 0x6e6c, 0x3e60, 0x395b, 0x4b48, 0x3664, 0x3d46, 0x463c, 0x412d, 0x6e74, 0x6e6e, 0x6e73, 0x4c43, 0x4438, 0x6e75, 0x6e72, 0x412c, 0x6e79, 0x6e78, 0x6e77, 0x4b2f, 0x3d7b, 0x6e7a, 0x4a5f, 0x3154, 0x4946, 0x4372, 0x3578, 0x6e7c, 0x395d, 0x3b2c, 0x6e7b, 0x3f6d, 0x3f6e, 0x6f21, 0x6f23, 0x3e7b, 0x6f22, 0x6f24, 0x3653, 0x4945, 0x3c62, 0x4f23, 0x6e7e, 0x3a78, 0x4f3f, 0x6f26, 0x6f25, 0x6f27, 0x6e7d, 0x4669, 0x4555, 0x4457, 0x6f2c, 0x4343, 0x6f28, 0x6f29, 0x372d, 0x6f2b, 0x3830, 0x6f2a, 0x3e61, 0x3379, 0x6f30, 0x3a3f, 0x4179, 0x444a, 0x333b, 0x6f2e, 0x6f2f, 0x4443, 0x6f2d, 0x6f31, 0x6f37, 0x6f3a, 0x6f39, 0x452d, 0x6f32, 0x6f33, 0x6f36, 0x6f38, 0x3640, 0x6f3b, 0x6f35, 0x6f34, 0x6f3f, 0x6f40, 0x6f41, 0x6f3e, 0x6f3d, 0x3e62, 0x462a, 0x6f3c, 0x6f45, 0x6f43, 0x6f44, 0x6f42, 0x4278, 0x6f46, 0x6f47, 0x6f49, 0x3455, 0x6f48, 0x4c7a, 0x6f54, 0x6f4a, 0x6f4d, 0x6f4b, 0x6f4c, 0x6f4e, 0x6f50, 0x6f51, 0x6f52, 0x6f55, 0x6f53, 0x6f56, 0x6f58, 0x6f57, 0x4439, 0x4c67, 0x6f59, 0x412e, 0x6f5a, 0x4a44, 0x6f5b, 0x332b, 0x313c, 0x3457, 0x3456, 0x6f5c, 0x6f5d, 0x6f5e, 0x6f5f, 0x6f60, 0x3458, 0x3355, 0x395e, 0x4836, 0x6f62, 0x6f61, 0x6f63, 0x315c, 0x6f66, 0x6f65, 0x6f64, 0x6f67, 0x6f6a, 0x3047, 0x6f68, 0x6f6c, 0x6f6b, 0x6f6e, 0x6f6d, 0x6f6f, 0x462e, 0x6f70, 0x6f71, 0x6f73, 0x6f72, 0x496c, 0x6f74, 0x6f75, 0x3a65, 0x6f76, 0x6f77, 0x4b49, 0x414b, 0x3024, 0x424b, 0x6f78, 0x496d, 0x6f7b, 0x6f79, 0x395f, 0x6f7a, 0x3842, 0x4a45, 0x6f7d, 0x7021, 0x6f7e, 0x7022, 0x3121, 0x3f58, 0x3d7c, 0x3459, 0x7023, 0x4766, 0x7025, 0x3122, 0x7024, 0x4444, 0x4e4d, 0x462b, 0x6f7c, 0x4e26, 0x3831, 0x4d5b, 0x3679, 0x4e34, 0x3728, 0x4262, 0x6721, 0x7026, 0x332c, 0x3f6f, 0x3356, 0x7028, 0x7029, 0x7027, 0x3764, 0x3a5d, 0x3e63, 0x3123, 0x4e59, 0x702b, 0x6e2e, 0x702a, 0x702e, 0x702c, 0x702d, 0x702f, 0x7030, 0x4e6c, 0x7031, 0x7032, 0x4049, 0x483b, 0x3f7d, 0x3467, 0x4d3a, 0x326d, 0x3d38, 0x385b, 0x7035, 0x7034, 0x3b73, 0x7036, 0x7033, 0x3b28, 0x703a, 0x6a2d, 0x5256, 0x3f77, 0x7038, 0x4e25, 0x4671, 0x312b, 0x4063, 0x3c36, 0x4a37, 0x3140, 0x4e6d, 0x4d6b, 0x703b, 0x4545, 0x3c7b, 0x703c, 0x703d, 0x3f4c, 0x703e, 0x4e6e, 0x7039, 0x7040, 0x7042, 0x7041, 0x703f, 0x7043, 0x7044, 0x417a, 0x3262, 0x7045, 0x4c38, 0x7046, 0x7047, 0x4f2a, 0x5b31, 0x7048, 0x7049, 0x704a, 0x704e, 0x704b, 0x704c, 0x704d, 0x704f, 0x4044, 0x4c77, 0x4045, 0x7050, 0x4873, 0x7051, 0x7353, 0x4c4c, 0x7052, 0x7053, 0x7054, 0x3357, 0x7056, 0x3f59, 0x7057, 0x3724, 0x7058, 0x705c, 0x705a, 0x705b, 0x3373, 0x7059, 0x705d, 0x705e, 0x3048, 0x705f, 0x7060, 0x3e64, 0x7061, 0x3547, 0x7064, 0x7063, 0x7062, 0x6b71, 0x4a5c, 0x7065, 0x7066, 0x7067, 0x7068, 0x7069, 0x706a, 0x345a, 0x706b, 0x706c, 0x4723, 0x706e, 0x323b, 0x7071, 0x7070, 0x3124, 0x3641, 0x4a47, 0x443a, 0x3a22, 0x3960, 0x3d67, 0x3f5c, 0x7073, 0x7072, 0x4d42, 0x3468, 0x4852, 0x465c, 0x3f7c, 0x4e4e, 0x375b, 0x7076, 0x7075, 0x4b4b, 0x462c, 0x3150, 0x7077, 0x7074, 0x4951, 0x4d6a, 0x7078, 0x7079, 0x707b, 0x426a, 0x335b, 0x335c, 0x707a, 0x3469, 0x3832, 0x346a, 0x453f, 0x4e60, 0x385c, 0x707c, 0x707d, 0x707e, 0x7121, 0x7123, 0x7122, 0x4977, 0x7124, 0x7125, 0x7126, 0x7127, 0x7129, 0x7128, 0x712a, 0x4874, 0x664c, 0x3f29, 0x3532, 0x712b, 0x712c, 0x522c, 0x5d3b, 0x4853, 0x307b, 0x303b, 0x3b74, 0x4b30, 0x3e7e, 0x712d, 0x4c5f, 0x712e, 0x4d5c, 0x3142, 0x3b41, 0x712f, 0x326e, 0x7130, 0x7131, 0x7133, 0x7134, 0x7136, 0x7132, 0x7135, 0x345b, 0x7137, 0x7138, 0x7139, 0x713a, 0x713b, 0x713d, 0x713c, 0x713f, 0x7142, 0x713e, 0x7140, 0x7141, 0x7143, 0x3642, 0x3c73, 0x7144, 0x7145, 0x3961, 0x7146, 0x333e, 0x474f, 0x7147, 0x7148, 0x435a, 0x466b, 0x7149, 0x477d, 0x424c, 0x3158, 0x366e, 0x366f, 0x4373, 0x714e, 0x3670, 0x326f, 0x714d, 0x714b, 0x714c, 0x714a, 0x7158, 0x714f, 0x7150, 0x7151, 0x7152, 0x7154, 0x7153, 0x3d59, 0x7155, 0x7157, 0x3533, 0x7156, 0x417b, 0x3833, 0x7159, 0x424d, 0x715a, 0x462d, 0x715b, 0x7160, 0x715e, 0x715d, 0x715f, 0x715c, 0x7162, 0x7161, 0x7164, 0x3643, 0x7163, 0x7165, 0x7166, 0x7168, 0x7167, 0x7169, 0x716b, 0x716a, 0x397c, 0x716c, 0x716d, 0x333c, 0x716e, 0x716f, 0x3f71, 0x7170, 0x7171, 0x7172, 0x7173, 0x3962, 0x7174, 0x7175, 0x7176, 0x7177, 0x7178, 0x4831, 0x717a, 0x4926, 0x717b, 0x7179, 0x717d, 0x717c, 0x717e, 0x7221, 0x7222, 0x7223, 0x7224, 0x7225, 0x7226, 0x7227, 0x7228, 0x7229, 0x722a, 0x722b, 0x722c, 0x722d, 0x722e, 0x5d35, 0x722f, 0x6478, 0x3534, 0x3321, 0x3a32, 0x7231, 0x7230, 0x4c25, 0x7233, 0x7234, 0x7232, 0x7235, 0x4b62, 0x7236, 0x357b, 0x4f25, 0x7237, 0x7239, 0x303e, 0x723a, 0x4a2b, 0x7238, 0x723b, 0x723c, 0x723d, 0x723e, 0x723f, 0x4b6e, 0x3b2d, 0x3a7a, 0x412f, 0x7240, 0x7243, 0x7241, 0x7244, 0x3871, 0x7242, 0x7245, 0x7246, 0x7247, 0x724b, 0x3b2a, 0x4264, 0x724c, 0x7249, 0x7248, 0x724a, 0x375f, 0x7250, 0x724f, 0x724e, 0x3033, 0x725a, 0x7256, 0x7257, 0x7253, 0x7259, 0x7255, 0x3362, 0x4f4c, 0x7258, 0x7254, 0x7252, 0x7251, 0x725c, 0x725f, 0x725e, 0x725d, 0x4949, 0x725b, 0x3073, 0x7260, 0x7262, 0x336f, 0x724d, 0x3137, 0x7264, 0x7263, 0x7261, 0x432d, 0x4b70, 0x4e5a, 0x7265, 0x7266, 0x7267, 0x7268, 0x7269, 0x443b, 0x726a, 0x4837, 0x726f, 0x726b, 0x726c, 0x4b31, 0x4c44, 0x4650, 0x7270, 0x7271, 0x463e, 0x726e, 0x726d, 0x322a, 0x7279, 0x7278, 0x3175, 0x7276, 0x7275, 0x7273, 0x337b, 0x7272, 0x3c32, 0x3229, 0x3963, 0x727c, 0x727b, 0x727a, 0x7277, 0x727d, 0x727e, 0x7325, 0x7324, 0x7326, 0x312d, 0x7321, 0x7322, 0x3974, 0x4c39, 0x7323, 0x4b32, 0x732b, 0x7327, 0x732c, 0x7329, 0x7328, 0x375c, 0x732d, 0x732e, 0x732f, 0x732a, 0x7274, 0x7330, 0x4461, 0x7334, 0x7335, 0x7333, 0x7332, 0x7338, 0x7331, 0x7336, 0x7337, 0x733a, 0x7339, 0x733c, 0x733d, 0x733e, 0x4f49, 0x733b, 0x426b, 0x3a6d, 0x733f, 0x7340, 0x7341, 0x7342, 0x7343, 0x3834, 0x7344, 0x7345, 0x3c2f, 0x7346, 0x7347, 0x7348, 0x7349, 0x734c, 0x734a, 0x4f3c, 0x734b, 0x4e6f, 0x734d, 0x4e5b, 0x734e, 0x477e, 0x734f, 0x7351, 0x7352, 0x7350, 0x396d, 0x4c4d, 0x4b63, 0x5677, 0x5d60, 0x4b7b, 0x322b, 0x7354, 0x3550, 0x7355, 0x7356, 0x7357, 0x3975, 0x7358, 0x6054, 0x4c5b, 0x4263, 0x7359, 0x735b, 0x735a, 0x735c, 0x735d, 0x735e, 0x735f, 0x7360, 0x7361, 0x7362, 0x7363, 0x7364, 0x7365, 0x7366, 0x7367, 0x7368, 0x4524, 0x385d, 0x736a, 0x414d, 0x736b, 0x736c, 0x4921, 0x736d, 0x736e, 0x6337, 0x6c5a, 0x706d, 0x736f, 0x7370, 0x7372, 0x7373, 0x7374, 0x4e70, 0x7371, 0x7375, 0x7376, 0x7378, 0x7377, 0x737a, 0x737b, 0x7379, 0x4e36, 0x737c, 0x737d, 0x6354, 0x737e, 0x212a, 0x2174, 0x2170, 0x2173, 0x2175, 0x214a, 0x214b, 0x2176, 0x215c, 0x2124, 0x2125, 0x213f, 0x2330, 0x2331, 0x2332, 0x2333, 0x2334, 0x2335, 0x2336, 0x2337, 0x2338, 0x2339, 0x2127, 0x2128, 0x2163, 0x2161, 0x2164, 0x2129, 0x2177, 0x2341, 0x2342, 0x2343, 0x2344, 0x2345, 0x2346, 0x2347, 0x2348, 0x2349, 0x234a, 0x234b, 0x234c, 0x234d, 0x234e, 0x234f, 0x2350, 0x2351, 0x2352, 0x2353, 0x2354, 0x2355, 0x2356, 0x2357, 0x2358, 0x2359, 0x235a, 0x214e, 0x2140, 0x214f, 0x2130, 0x2132, 0x212e, 0x2361, 0x2362, 0x2363, 0x2364, 0x2365, 0x2366, 0x2367, 0x2368, 0x2369, 0x236a, 0x236b, 0x236c, 0x236d, 0x236e, 0x236f, 0x2370, 0x2371, 0x2372, 0x2373, 0x2374, 0x2375, 0x2376, 0x2377, 0x2378, 0x2379, 0x237a, 0x2150, 0x2143, 0x2151, 0x2131, 0x216f, }; static const Summary16 jisx0208_uni2indx_page00[16] = { /* 0x0000 */ { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x0000 }, { 0, 0x118c }, { 5, 0x0053 }, { 9, 0x0000 }, { 9, 0x0080 }, { 10, 0x0000 }, { 10, 0x0080 }, }; static const Summary16 jisx0208_uni2indx_page03[22] = { /* 0x0300 */ { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0x0000 }, { 11, 0xfffe }, { 26, 0x03fb }, { 35, 0xfffe }, { 50, 0x03fb }, { 59, 0x0000 }, { 59, 0x0000 }, { 59, 0x0000 }, /* 0x0400 */ { 59, 0x0002 }, { 60, 0xffff }, { 76, 0xffff }, { 92, 0xffff }, { 108, 0xffff }, { 124, 0x0002 }, }; static const Summary16 jisx0208_uni2indx_page20[50] = { /* 0x2000 */ { 125, 0x0000 }, { 125, 0x3361 }, { 132, 0x0063 }, { 136, 0x080d }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, { 140, 0x0000 }, /* 0x2100 */ { 140, 0x0008 }, { 141, 0x0000 }, { 141, 0x0800 }, { 142, 0x0000 }, { 142, 0x0000 }, { 142, 0x0000 }, { 142, 0x0000 }, { 142, 0x0000 }, { 142, 0x0000 }, { 142, 0x000f }, { 146, 0x0000 }, { 146, 0x0000 }, { 146, 0x0000 }, { 146, 0x0014 }, { 148, 0x0000 }, { 148, 0x0000 }, /* 0x2200 */ { 148, 0x098d }, { 154, 0x6404 }, { 158, 0x1f81 }, { 165, 0x2030 }, { 168, 0x0000 }, { 168, 0x0004 }, { 169, 0x0cc3 }, { 175, 0x0000 }, { 175, 0x00cc }, { 179, 0x0000 }, { 179, 0x0020 }, { 180, 0x0000 }, { 180, 0x0000 }, { 180, 0x0000 }, { 180, 0x0000 }, { 180, 0x0000 }, /* 0x2300 */ { 180, 0x0000 }, { 180, 0x0004 }, }; static const Summary16 jisx0208_uni2indx_page25[23] = { /* 0x2500 */ { 181, 0x900f }, { 187, 0x3999 }, { 195, 0x9939 }, { 203, 0x9999 }, { 211, 0x0804 }, { 213, 0x0000 }, { 213, 0x0000 }, { 213, 0x0000 }, { 213, 0x0000 }, { 213, 0x0000 }, { 213, 0x0003 }, { 215, 0x300c }, { 219, 0xc8c0 }, { 224, 0x0000 }, { 224, 0x8000 }, { 225, 0x0000 }, /* 0x2600 */ { 225, 0x0060 }, { 227, 0x0000 }, { 227, 0x0000 }, { 227, 0x0000 }, { 227, 0x0005 }, { 229, 0x0000 }, { 229, 0xa400 }, }; static const Summary16 jisx0208_uni2indx_page30[16] = { /* 0x3000 */ { 232, 0xffef }, { 247, 0x103f }, { 254, 0x0000 }, { 254, 0x0000 }, { 254, 0xfffe }, { 269, 0xffff }, { 285, 0xffff }, { 301, 0xffff }, { 317, 0xffff }, { 333, 0x780f }, { 341, 0xfffe }, { 356, 0xffff }, { 372, 0xffff }, { 388, 0xffff }, { 404, 0xffff }, { 420, 0x787f }, }; static const Summary16 jisx0208_uni2indx_page4e[1307] = { /* 0x4e00 */ { 431, 0x6f8b }, { 441, 0x43f3 }, { 450, 0x2442 }, { 454, 0x9b46 }, { 462, 0xe82c }, { 469, 0xe3e0 }, { 477, 0x0004 }, { 478, 0x400a }, { 481, 0x5f65 }, { 491, 0xdb36 }, { 501, 0x7977 }, { 512, 0x0449 }, { 516, 0xecd7 }, { 527, 0xe3f0 }, { 536, 0x6038 }, { 541, 0x08c5 }, /* 0x4f00 */ { 546, 0xe602 }, { 552, 0x3403 }, { 557, 0x8000 }, { 558, 0x3551 }, { 565, 0xe0c8 }, { 571, 0x7eab }, { 582, 0x8200 }, { 584, 0x9869 }, { 591, 0xa948 }, { 597, 0x2942 }, { 602, 0xe803 }, { 608, 0x8060 }, { 611, 0x441c }, { 616, 0xad93 }, { 625, 0xc03a }, { 631, 0x4568 }, /* 0x5000 */ { 637, 0xaa60 }, { 643, 0x8656 }, { 650, 0x3f7a }, { 661, 0x0240 }, { 663, 0x8388 }, { 668, 0x1461 }, { 673, 0x1020 }, { 675, 0x2174 }, { 681, 0x2021 }, { 684, 0x0702 }, { 688, 0x3000 }, { 690, 0x40bc }, { 696, 0xa624 }, { 702, 0x4462 }, { 707, 0x60a8 }, { 712, 0x0a20 }, /* 0x5100 */ { 715, 0x0217 }, { 720, 0x8574 }, { 727, 0x0402 }, { 729, 0x9c84 }, { 735, 0x7bfb }, { 748, 0x1415 }, { 753, 0x7f24 }, { 762, 0x11e2 }, { 768, 0xb665 }, { 777, 0x02ef }, { 785, 0x1f75 }, { 795, 0x20ff }, { 804, 0x3a70 }, { 811, 0x3840 }, { 815, 0x26c3 }, { 822, 0x6763 }, /* 0x5200 */ { 831, 0x4dd9 }, { 840, 0x2092 }, { 844, 0x46b0 }, { 850, 0x0fc9 }, { 858, 0xbc98 }, { 866, 0x4850 }, { 870, 0x8638 }, { 876, 0xa03f }, { 884, 0x2388 }, { 889, 0x8816 }, { 894, 0x3e09 }, { 901, 0x5232 }, { 907, 0x22aa }, { 913, 0xe3a4 }, { 921, 0x00dd }, { 927, 0xc72c }, /* 0x5300 */ { 935, 0xa166 }, { 942, 0x26e1 }, { 949, 0x840b }, { 954, 0x8f0a }, { 961, 0x27eb }, { 971, 0x559e }, { 980, 0xc241 }, { 985, 0x89bb }, { 994, 0x0014 }, { 996, 0x8540 }, { 1000, 0x6361 }, { 1007, 0x0849 }, { 1011, 0x7f0c }, { 1020, 0x8ad0 }, { 1026, 0xff3e }, { 1039, 0x05cf }, /* 0x5400 */ { 1047, 0xff1a }, { 1058, 0xa803 }, { 1063, 0x7a41 }, { 1070, 0x7b40 }, { 1077, 0x4745 }, { 1084, 0x8002 }, { 1086, 0x0500 }, { 1088, 0x38eb }, { 1097, 0xd851 }, { 1104, 0x0005 }, { 1106, 0x9934 }, { 1113, 0x710c }, { 1119, 0x0397 }, { 1126, 0x0100 }, { 1127, 0x6366 }, { 1135, 0x2404 }, /* 0x5500 */ { 1138, 0x80d0 }, { 1142, 0x0051 }, { 1145, 0xc000 }, { 1147, 0x430a }, { 1152, 0x9071 }, { 1158, 0x30c8 }, { 1163, 0x0008 }, { 1164, 0x5800 }, { 1167, 0x0e99 }, { 1174, 0xf700 }, { 1181, 0x5f80 }, { 1188, 0x0041 }, { 1190, 0x00b0 }, { 1193, 0x9410 }, { 1197, 0x0018 }, { 1199, 0x6280 }, /* 0x5600 */ { 1203, 0x0240 }, { 1205, 0x09d0 }, { 1210, 0x8200 }, { 1212, 0x0156 }, { 1217, 0x5004 }, { 1220, 0x0801 }, { 1222, 0x1d10 }, { 1227, 0x0510 }, { 1230, 0x84c1 }, { 1235, 0x0010 }, { 1236, 0x4025 }, { 1240, 0x1050 }, { 1243, 0x410f }, { 1249, 0x4d8a }, { 1256, 0x4009 }, { 1259, 0xa60d }, /* 0x5700 */ { 1266, 0xab19 }, { 1274, 0x914c }, { 1280, 0x21c0 }, { 1284, 0x0981 }, { 1288, 0xc485 }, { 1294, 0x0003 }, { 1296, 0x0652 }, { 1301, 0x8000 }, { 1302, 0x0b04 }, { 1306, 0x0008 }, { 1307, 0x041d }, { 1312, 0x0009 }, { 1314, 0x4849 }, { 1319, 0x905c }, { 1325, 0x0009 }, { 1327, 0x1690 }, /* 0x5800 */ { 1332, 0x0c65 }, { 1338, 0x2220 }, { 1341, 0x8412 }, { 1345, 0x2433 }, { 1351, 0x0c03 }, { 1355, 0x4796 }, { 1363, 0x0a04 }, { 1366, 0x4225 }, { 1371, 0x0028 }, { 1373, 0x9088 }, { 1377, 0x4900 }, { 1380, 0x4f08 }, { 1386, 0x14a2 }, { 1391, 0xd3aa }, { 1400, 0xd830 }, { 1406, 0x3e87 }, /* 0x5900 */ { 1415, 0x8604 }, { 1419, 0x1f61 }, { 1427, 0x7ea4 }, { 1436, 0x4186 }, { 1441, 0xc390 }, { 1447, 0x05b3 }, { 1454, 0x57a5 }, { 1463, 0x2118 }, { 1467, 0x241e }, { 1473, 0x2a48 }, { 1478, 0x1128 }, { 1482, 0x4a04 }, { 1486, 0x0a40 }, { 1489, 0x161b }, { 1496, 0x0d60 }, { 1501, 0x8840 }, /* 0x5a00 */ { 1504, 0x020a }, { 1507, 0x9502 }, { 1512, 0x8221 }, { 1516, 0x1060 }, { 1519, 0x0243 }, { 1523, 0x0400 }, { 1524, 0x1444 }, { 1528, 0x8000 }, { 1529, 0x0000 }, { 1529, 0x0c04 }, { 1532, 0x0000 }, { 1532, 0x7000 }, { 1535, 0x1a06 }, { 1540, 0x00c1 }, { 1543, 0x024a }, { 1547, 0x0c00 }, /* 0x5b00 */ { 1549, 0x1a00 }, { 1552, 0x0040 }, { 1553, 0x1404 }, { 1556, 0x4045 }, { 1560, 0x0029 }, { 1563, 0xbdb3 }, { 1574, 0x0a78 }, { 1580, 0x052b }, { 1586, 0xbba9 }, { 1596, 0xbfa0 }, { 1605, 0x407c }, { 1611, 0x8379 }, { 1619, 0x12fc }, { 1627, 0xe81d }, { 1635, 0x4bf6 }, { 1645, 0xc569 }, /* 0x5c00 */ { 1653, 0xeff6 }, { 1666, 0x044a }, { 1670, 0x2115 }, { 1675, 0xff02 }, { 1684, 0xed63 }, { 1694, 0x402b }, { 1699, 0xd033 }, { 1706, 0x0242 }, { 1709, 0x1000 }, { 1710, 0x0013 }, { 1713, 0x1b02 }, { 1718, 0x59ca }, { 1726, 0x00a0 }, { 1728, 0x0200 }, { 1729, 0xa703 }, { 1736, 0x2c41 }, /* 0x5d00 */ { 1741, 0x4880 }, { 1744, 0x8ff2 }, { 1754, 0x0204 }, { 1756, 0x0000 }, { 1756, 0x5800 }, { 1759, 0x1005 }, { 1762, 0x9200 }, { 1765, 0x0048 }, { 1767, 0x1894 }, { 1772, 0x2001 }, { 1774, 0x5004 }, { 1777, 0x3480 }, { 1781, 0x3200 }, { 1784, 0x684c }, { 1790, 0x49ea }, { 1798, 0x68be }, /* 0x5e00 */ { 1807, 0x184c }, { 1812, 0x2e42 }, { 1818, 0xa820 }, { 1822, 0x21c9 }, { 1828, 0x50b9 }, { 1835, 0x80b0 }, { 1839, 0x001e }, { 1843, 0xff7c }, { 1856, 0x849a }, { 1862, 0x14e0 }, { 1867, 0x28c1 }, { 1872, 0x01e0 }, { 1876, 0x870e }, { 1883, 0xac49 }, { 1890, 0x130f }, { 1897, 0xdddb }, /* 0x5f00 */ { 1909, 0xbe1a }, { 1918, 0x89fb }, { 1928, 0xa2e0 }, { 1934, 0x51a2 }, { 1940, 0x5502 }, { 1945, 0x32ca }, { 1952, 0x3e46 }, { 1960, 0x928b }, { 1967, 0x1dbf }, { 1978, 0x438f }, { 1986, 0x6703 }, { 1993, 0x3218 }, { 1998, 0x3028 }, { 2002, 0x33c0 }, { 2008, 0x0811 }, { 2011, 0xa923 }, /* 0x6000 */ { 2018, 0xc000 }, { 2020, 0x3a65 }, { 2028, 0x8fe3 }, { 2038, 0x0402 }, { 2040, 0x2c4e }, { 2047, 0x8625 }, { 2053, 0xbf3d }, { 2065, 0x00a1 }, { 2068, 0x3a1a }, { 2075, 0x8cd4 }, { 2082, 0x06c9 }, { 2088, 0x317c }, { 2096, 0x00e0 }, { 2099, 0x950a }, { 2105, 0x018b }, { 2110, 0x0edb }, /* 0x6100 */ { 2119, 0xe34b }, { 2128, 0x8c20 }, { 2132, 0x1182 }, { 2136, 0xf010 }, { 2141, 0x7d94 }, { 2150, 0xa728 }, { 2157, 0xc9ac }, { 2165, 0x40fb }, { 2173, 0x4484 }, { 2177, 0x0653 }, { 2183, 0x5a90 }, { 2189, 0x4444 }, { 2193, 0x3fc8 }, { 2202, 0x0001 }, { 2203, 0x0048 }, { 2205, 0xf5d4 }, /* 0x6200 */ { 2215, 0x7701 }, { 2222, 0xec57 }, { 2232, 0xc442 }, { 2237, 0x891d }, { 2244, 0x6b83 }, { 2252, 0x4928 }, { 2257, 0x4109 }, { 2261, 0xd242 }, { 2267, 0x061d }, { 2273, 0x59fe }, { 2284, 0x1800 }, { 2286, 0x3a22 }, { 2292, 0xb7e4 }, { 2302, 0x3b9f }, { 2313, 0xf003 }, { 2319, 0xc0ea }, /* 0x6300 */ { 2326, 0x1386 }, { 2332, 0x8202 }, { 2335, 0x8980 }, { 2339, 0xe400 }, { 2343, 0xb200 }, { 2347, 0x10a1 }, { 2351, 0x4b80 }, { 2356, 0x0cc4 }, { 2361, 0xd309 }, { 2368, 0x8944 }, { 2373, 0x1faf }, { 2384, 0x4834 }, { 2389, 0x8259 }, { 2395, 0x0c45 }, { 2400, 0x420a }, { 2404, 0x0450 }, /* 0x6400 */ { 2407, 0xa040 }, { 2410, 0x10c8 }, { 2414, 0x3140 }, { 2418, 0x4450 }, { 2422, 0x4004 }, { 2424, 0x0100 }, { 2425, 0x8280 }, { 2428, 0x0540 }, { 2431, 0x0108 }, { 2433, 0x442c }, { 2438, 0x6a30 }, { 2444, 0x1a05 }, { 2449, 0x20a6 }, { 2454, 0x0514 }, { 2458, 0x90cf }, { 2466, 0x6456 }, /* 0x6500 */ { 2473, 0x0021 }, { 2475, 0x3100 }, { 2478, 0x9c18 }, { 2484, 0xcbf0 }, { 2493, 0xa120 }, { 2497, 0x63e2 }, { 2505, 0x104c }, { 2509, 0x01b5 }, { 2515, 0x538c }, { 2522, 0x9a83 }, { 2529, 0xb8b2 }, { 2537, 0x3281 }, { 2542, 0x987a }, { 2550, 0x0a84 }, { 2554, 0x33e7 }, { 2564, 0x0c02 }, /* 0x6600 */ { 2567, 0xd4cc }, { 2575, 0x9018 }, { 2579, 0xa1a1 }, { 2585, 0x9070 }, { 2590, 0x8a1e }, { 2597, 0xe004 }, { 2601, 0xc3d4 }, { 2609, 0x0451 }, { 2613, 0x439a }, { 2620, 0x21c2 }, { 2625, 0x4844 }, { 2629, 0x5310 }, { 2634, 0x0292 }, { 2638, 0x3640 }, { 2643, 0x0241 }, { 2646, 0xf3bd }, /* 0x6700 */ { 2658, 0xab09 }, { 2665, 0xe8f0 }, { 2673, 0x7dc0 }, { 2681, 0xa5d2 }, { 2689, 0xc242 }, { 2694, 0xd24b }, { 2702, 0xa43f }, { 2711, 0xd0af }, { 2720, 0x1aa0 }, { 2725, 0x34a1 }, { 2731, 0x8247 }, { 2737, 0x03d8 }, { 2743, 0xc452 }, { 2749, 0x651b }, { 2757, 0xd294 }, { 2764, 0xc83a }, /* 0x6800 */ { 2771, 0x001c }, { 2774, 0x40c8 }, { 2778, 0x0e06 }, { 2783, 0x3314 }, { 2789, 0x614f }, { 2797, 0xb21b }, { 2805, 0x0088 }, { 2807, 0xc0d0 }, { 2812, 0xa02a }, { 2817, 0xa898 }, { 2823, 0xa1c5 }, { 2830, 0x166b }, { 2838, 0x2e50 }, { 2844, 0x85b4 }, { 2851, 0xc08b }, { 2857, 0x0604 }, /* 0x6900 */ { 2860, 0xf933 }, { 2870, 0x1e04 }, { 2875, 0x056e }, { 2882, 0xa251 }, { 2888, 0x0400 }, { 2889, 0x7638 }, { 2897, 0xec07 }, { 2905, 0x73b8 }, { 2914, 0x4406 }, { 2918, 0x1832 }, { 2923, 0x4081 }, { 2926, 0xc816 }, { 2932, 0x7c8a }, { 2940, 0x6309 }, { 2946, 0x2980 }, { 2950, 0xaa04 }, /* 0x6a00 */ { 2955, 0x1c24 }, { 2960, 0xca9c }, { 2968, 0x4e0e }, { 2975, 0x2760 }, { 2981, 0x0990 }, { 2985, 0x8300 }, { 2988, 0x0046 }, { 2991, 0x8104 }, { 2994, 0x6011 }, { 2998, 0x1081 }, { 3001, 0x540d }, { 3007, 0x0908 }, { 3010, 0x000e }, { 3013, 0xcc0a }, { 3019, 0x0500 }, { 3021, 0x0c00 }, /* 0x6b00 */ { 3023, 0x0430 }, { 3026, 0xa044 }, { 3030, 0x008b }, { 3034, 0x6784 }, { 3041, 0x5288 }, { 3046, 0x8a19 }, { 3052, 0x865e }, { 3060, 0x8b18 }, { 3066, 0x2e59 }, { 3074, 0x4160 }, { 3078, 0x8c10 }, { 3082, 0x9cbe }, { 3092, 0x6861 }, { 3098, 0x891c }, { 3104, 0x9800 }, { 3107, 0x0008 }, /* 0x6c00 */ { 3108, 0x8100 }, { 3110, 0x089a }, { 3115, 0x0018 }, { 3117, 0x4190 }, { 3121, 0x4007 }, { 3125, 0xe4a1 }, { 3132, 0x0505 }, { 3136, 0x640d }, { 3142, 0x310e }, { 3148, 0x0e4d }, { 3155, 0x4806 }, { 3159, 0xff0a }, { 3169, 0x1632 }, { 3175, 0x2aa8 }, { 3181, 0x852e }, { 3188, 0x000b }, /* 0x6d00 */ { 3191, 0x1800 }, { 3193, 0xca84 }, { 3199, 0x0e20 }, { 3203, 0x696c }, { 3211, 0x0032 }, { 3214, 0x1600 }, { 3217, 0x5658 }, { 3224, 0x0390 }, { 3228, 0x5120 }, { 3232, 0x1a28 }, { 3237, 0x8000 }, { 3238, 0x1124 }, { 3242, 0x18e1 }, { 3248, 0x4326 }, { 3254, 0x5d52 }, { 3262, 0x0eaa }, /* 0x6e00 */ { 3269, 0x0fa0 }, { 3275, 0xae28 }, { 3282, 0xfa7b }, { 3294, 0x4500 }, { 3297, 0x6408 }, { 3301, 0x8940 }, { 3305, 0xc880 }, { 3309, 0xc044 }, { 3313, 0x9005 }, { 3317, 0xb141 }, { 3323, 0x8424 }, { 3327, 0x24c4 }, { 3332, 0x1a34 }, { 3338, 0x603a }, { 3344, 0x9000 }, { 3346, 0xc194 }, /* 0x6f00 */ { 3352, 0x8246 }, { 3357, 0x003a }, { 3361, 0x180d }, { 3366, 0xc106 }, { 3371, 0x0022 }, { 3373, 0x9910 }, { 3378, 0xe050 }, { 3383, 0x1511 }, { 3388, 0x4057 }, { 3394, 0x0082 }, { 3396, 0x041a }, { 3400, 0x020a }, { 3403, 0x004f }, { 3408, 0x8930 }, { 3413, 0xd813 }, { 3420, 0x444a }, /* 0x7000 */ { 3425, 0x8a02 }, { 3429, 0xed22 }, { 3437, 0x10c0 }, { 3440, 0x4005 }, { 3443, 0x1000 }, { 3444, 0x0102 }, { 3446, 0x8808 }, { 3449, 0x3101 }, { 3453, 0x4600 }, { 3456, 0x0204 }, { 3458, 0xf000 }, { 3462, 0x0708 }, { 3466, 0x8900 }, { 3469, 0xa200 }, { 3472, 0x0000 }, { 3472, 0x2202 }, /* 0x7100 */ { 3475, 0x0200 }, { 3476, 0x1610 }, { 3480, 0x0042 }, { 3482, 0x1040 }, { 3484, 0x5200 }, { 3487, 0x0260 }, { 3490, 0x52f4 }, { 3498, 0x2000 }, { 3499, 0x8510 }, { 3503, 0x8230 }, { 3507, 0x1100 }, { 3509, 0x4202 }, { 3512, 0x4308 }, { 3516, 0x80b5 }, { 3522, 0x70e1 }, { 3529, 0x9a20 }, /* 0x7200 */ { 3534, 0x2040 }, { 3536, 0x0801 }, { 3538, 0x3500 }, { 3542, 0xfc65 }, { 3552, 0x19c1 }, { 3558, 0xab04 }, { 3564, 0x0286 }, { 3568, 0x6214 }, { 3573, 0x0087 }, { 3577, 0x0044 }, { 3579, 0x9085 }, { 3584, 0x0244 }, { 3587, 0x405c }, { 3592, 0x0a85 }, { 3597, 0x3207 }, { 3603, 0x3380 }, /* 0x7300 */ { 3608, 0x0400 }, { 3609, 0xb8c0 }, { 3615, 0xce20 }, { 3621, 0xc0d0 }, { 3626, 0xc030 }, { 3630, 0x0080 }, { 3631, 0x0508 }, { 3634, 0x0d25 }, { 3640, 0x0a90 }, { 3644, 0x0040 }, { 3645, 0x0200 }, { 3646, 0x080c }, { 3649, 0x6505 }, { 3655, 0x4000 }, { 3656, 0x6421 }, { 3661, 0x4102 }, /* 0x7400 */ { 3664, 0x0268 }, { 3668, 0x0000 }, { 3668, 0x0024 }, { 3670, 0x847c }, { 3677, 0x0002 }, { 3678, 0xde20 }, { 3685, 0x8619 }, { 3691, 0x4049 }, { 3695, 0x0808 }, { 3697, 0x4000 }, { 3698, 0x0084 }, { 3700, 0x2001 }, { 3702, 0x8400 }, { 3704, 0x1010 }, { 3706, 0x42cd }, { 3713, 0x01c7 }, /* 0x7500 */ { 3719, 0x7038 }, { 3725, 0xd52a }, { 3733, 0x1968 }, { 3739, 0x1d8f }, { 3748, 0xbe50 }, { 3756, 0x3e12 }, { 3763, 0x2ef5 }, { 3773, 0x81d9 }, { 3780, 0xcec4 }, { 3788, 0x2412 }, { 3792, 0x0828 }, { 3795, 0x732e }, { 3804, 0x24ac }, { 3810, 0x4b34 }, { 3817, 0x020c }, { 3820, 0xd41d }, /* 0x7600 */ { 3828, 0x2a02 }, { 3832, 0x8000 }, { 3833, 0x0097 }, { 3838, 0x0811 }, { 3841, 0x11c4 }, { 3846, 0x1144 }, { 3850, 0x1786 }, { 3857, 0x7d45 }, { 3866, 0x49d9 }, { 3874, 0x0649 }, { 3879, 0x4000 }, { 3880, 0x8791 }, { 3887, 0x254c }, { 3893, 0xd8c4 }, { 3900, 0x44ba }, { 3907, 0x4914 }, /* 0x7700 */ { 3912, 0x1b92 }, { 3919, 0xc800 }, { 3922, 0x0271 }, { 3927, 0x1580 }, { 3931, 0x0081 }, { 3933, 0x0c00 }, { 3935, 0x096a }, { 3941, 0xc200 }, { 3944, 0x4800 }, { 3946, 0x4002 }, { 3948, 0x3021 }, { 3952, 0xba49 }, { 3960, 0x2080 }, { 3962, 0x1c80 }, { 3966, 0xe2ac }, { 3974, 0x1008 }, /* 0x7800 */ { 3976, 0x1004 }, { 3978, 0x0034 }, { 3981, 0x00e1 }, { 3985, 0x8414 }, { 3989, 0x0020 }, { 3990, 0x2000 }, { 3991, 0x9800 }, { 3994, 0x1014 }, { 3997, 0x70c2 }, { 4003, 0x04aa }, { 4008, 0x8688 }, { 4013, 0x5420 }, { 4017, 0x0c62 }, { 4022, 0x0413 }, { 4026, 0x9180 }, { 4030, 0x2010 }, /* 0x7900 */ { 4032, 0x4082 }, { 4035, 0x0206 }, { 4038, 0x1c40 }, { 4042, 0x5400 }, { 4045, 0x0383 }, { 4050, 0xe4e9 }, { 4059, 0x2125 }, { 4064, 0x8480 }, { 4067, 0xe433 }, { 4075, 0x2000 }, { 4076, 0x44c0 }, { 4080, 0xe609 }, { 4087, 0x0a03 }, { 4091, 0x8126 }, { 4096, 0x12da }, { 4103, 0x0801 }, /* 0x7a00 */ { 4105, 0x6901 }, { 4110, 0x9790 }, { 4117, 0x4001 }, { 4119, 0xf886 }, { 4127, 0xe24d }, { 4135, 0x0081 }, { 4137, 0x0a0e }, { 4142, 0xa651 }, { 4149, 0x011a }, { 4153, 0x81ec }, { 4160, 0xc600 }, { 4164, 0x8441 }, { 4168, 0xadb8 }, { 4177, 0xb62c }, { 4185, 0xa46f }, { 4194, 0x8741 }, /* 0x7b00 */ { 4200, 0x8d54 }, { 4207, 0x4b02 }, { 4212, 0x1161 }, { 4217, 0x0268 }, { 4221, 0xbb60 }, { 4229, 0x2057 }, { 4235, 0x50a0 }, { 4239, 0x0433 }, { 4244, 0xa8c0 }, { 4249, 0xb7b4 }, { 4259, 0x2402 }, { 4262, 0x0112 }, { 4265, 0x9ad3 }, { 4274, 0x2000 }, { 4275, 0x2271 }, { 4281, 0x00c8 }, /* 0x7c00 */ { 4284, 0x2081 }, { 4287, 0x809e }, { 4293, 0x0c8a }, { 4298, 0xe180 }, { 4303, 0xb009 }, { 4308, 0x8151 }, { 4313, 0x1031 }, { 4317, 0x4028 }, { 4320, 0x2a0e }, { 4326, 0x89a5 }, { 4333, 0x69b6 }, { 4342, 0x620e }, { 4348, 0x4425 }, { 4353, 0xd144 }, { 4359, 0x8085 }, { 4363, 0x4d54 }, /* 0x7d00 */ { 4370, 0x2c75 }, { 4378, 0x1fb1 }, { 4387, 0xd807 }, { 4394, 0x862d }, { 4401, 0xd87c }, { 4410, 0x4841 }, { 4414, 0x414e }, { 4420, 0x226e }, { 4427, 0x8200 }, { 4429, 0x9e08 }, { 4435, 0xf80c }, { 4442, 0xed37 }, { 4453, 0x8c80 }, { 4457, 0x7526 }, { 4465, 0x9313 }, { 4472, 0x0814 }, /* 0x7e00 */ { 4475, 0x0e32 }, { 4481, 0xc804 }, { 4485, 0x484e }, { 4491, 0x6ea6 }, { 4500, 0x2c4a }, { 4506, 0x6670 }, { 4513, 0x26c0 }, { 4518, 0xba01 }, { 4524, 0xd30c }, { 4531, 0x185d }, { 4538, 0x0000 }, { 4538, 0x0000 }, { 4538, 0x0000 }, { 4538, 0x0000 }, { 4538, 0x0000 }, { 4538, 0x0000 }, /* 0x7f00 */ { 4538, 0x0000 }, { 4538, 0x0000 }, { 4538, 0x0000 }, { 4538, 0x0540 }, { 4541, 0x7020 }, { 4545, 0x8133 }, { 4551, 0x4f81 }, { 4558, 0x03a5 }, { 4564, 0x55ec }, { 4573, 0x6410 }, { 4577, 0xc318 }, { 4583, 0x2344 }, { 4588, 0x1462 }, { 4593, 0x0034 }, { 4596, 0x0a43 }, { 4601, 0x1a09 }, /* 0x8000 */ { 4606, 0x187b }, { 4614, 0x13a5 }, { 4621, 0x0102 }, { 4623, 0xa848 }, { 4628, 0x0440 }, { 4630, 0xc544 }, { 4636, 0x8106 }, { 4640, 0xe2dd }, { 4650, 0x1af0 }, { 4657, 0x2d48 }, { 4663, 0xb626 }, { 4671, 0x0416 }, { 4675, 0x5058 }, { 4680, 0x6e40 }, { 4686, 0x8032 }, { 4690, 0x3112 }, /* 0x8100 */ { 4695, 0x07e4 }, { 4702, 0x0c00 }, { 4704, 0x8208 }, { 4707, 0x420a }, { 4711, 0x4840 }, { 4714, 0x803b }, { 4720, 0x4860 }, { 4724, 0x8713 }, { 4731, 0x850d }, { 4737, 0x3428 }, { 4742, 0x0319 }, { 4747, 0xe529 }, { 4755, 0x2345 }, { 4761, 0x870a }, { 4767, 0x25a9 }, { 4774, 0x5c18 }, /* 0x8200 */ { 4780, 0x77a6 }, { 4790, 0xd9c5 }, { 4799, 0x5e00 }, { 4804, 0x03e8 }, { 4810, 0x0081 }, { 4812, 0xa700 }, { 4817, 0xcd54 }, { 4825, 0x41c6 }, { 4831, 0x2800 }, { 4833, 0xa204 }, { 4837, 0xb860 }, { 4843, 0x2b0a }, { 4849, 0x0020 }, { 4850, 0xda9e }, { 4860, 0x08ea }, { 4866, 0x0e1a }, /* 0x8300 */ { 4872, 0x427c }, { 4879, 0x11c0 }, { 4883, 0x8908 }, { 4887, 0x0376 }, { 4894, 0x8621 }, { 4899, 0x0105 }, { 4902, 0x0000 }, { 4902, 0x18a8 }, { 4907, 0x46a0 }, { 4912, 0xc448 }, { 4917, 0x0d05 }, { 4922, 0x2022 }, { 4925, 0x5422 }, { 4930, 0x9148 }, { 4935, 0x8a01 }, { 4939, 0x2897 }, /* 0x8400 */ { 4946, 0x7898 }, { 4953, 0x0008 }, { 4954, 0x1605 }, { 4959, 0x3122 }, { 4964, 0x4240 }, { 4967, 0x0880 }, { 4969, 0xfa4e }, { 4979, 0x06a2 }, { 4984, 0x0814 }, { 4987, 0x9211 }, { 4992, 0x2002 }, { 4994, 0x9b04 }, { 5000, 0x2e52 }, { 5007, 0x0643 }, { 5012, 0x5000 }, { 5014, 0x9010 }, /* 0x8500 */ { 5017, 0x0041 }, { 5019, 0x85ba }, { 5027, 0x3042 }, { 5031, 0x2020 }, { 5033, 0x4f0b }, { 5041, 0x05a0 }, { 5045, 0x2708 }, { 5050, 0x4080 }, { 5052, 0x0591 }, { 5057, 0x1a93 }, { 5064, 0xdf50 }, { 5073, 0x0600 }, { 5075, 0xa202 }, { 5079, 0x3021 }, { 5083, 0x0630 }, { 5087, 0x4e80 }, /* 0x8600 */ { 5092, 0x0cc4 }, { 5097, 0x04c8 }, { 5101, 0xa004 }, { 5104, 0x8001 }, { 5106, 0x6000 }, { 5108, 0xd431 }, { 5115, 0x0880 }, { 5117, 0x0a02 }, { 5120, 0x1c00 }, { 5123, 0x0028 }, { 5125, 0x8e18 }, { 5131, 0x0041 }, { 5133, 0x6ad0 }, { 5140, 0xca10 }, { 5145, 0xf210 }, { 5151, 0x4b00 }, /* 0x8700 */ { 5155, 0x274d }, { 5163, 0x1506 }, { 5168, 0x0220 }, { 5170, 0x8890 }, { 5174, 0x5a00 }, { 5178, 0x82a8 }, { 5183, 0x4549 }, { 5189, 0x8150 }, { 5193, 0x2004 }, { 5195, 0x8000 }, { 5196, 0x8804 }, { 5199, 0x2c08 }, { 5203, 0x08d1 }, { 5208, 0x0005 }, { 5210, 0x8001 }, { 5212, 0x4ac4 }, /* 0x8800 */ { 5218, 0xe020 }, { 5222, 0x0062 }, { 5225, 0x008e }, { 5229, 0x0a42 }, { 5233, 0x3055 }, { 5239, 0x6a8c }, { 5246, 0x090e }, { 5251, 0xe0a5 }, { 5258, 0x2906 }, { 5263, 0x42c4 }, { 5268, 0x4814 }, { 5272, 0x80b3 }, { 5278, 0x803e }, { 5284, 0xb330 }, { 5291, 0x0102 }, { 5293, 0x731c }, /* 0x8900 */ { 5301, 0x1494 }, { 5306, 0x600d }, { 5311, 0x0c20 }, { 5314, 0x0940 }, { 5317, 0x301a }, { 5322, 0xc040 }, { 5325, 0xa451 }, { 5331, 0xc094 }, { 5336, 0x8dca }, { 5344, 0x05c8 }, { 5349, 0x96c2 }, { 5356, 0xa40c }, { 5361, 0x0001 }, { 5362, 0x3404 }, { 5366, 0x00c8 }, { 5369, 0x0110 }, /* 0x8a00 */ { 5371, 0x550d }, { 5378, 0xa9c9 }, { 5386, 0x2428 }, { 5390, 0x1c5a }, { 5397, 0x0142 }, { 5400, 0x4837 }, { 5407, 0x7a4d }, { 5416, 0x100f }, { 5421, 0x32b4 }, { 5428, 0x452a }, { 5434, 0x317b }, { 5443, 0x9205 }, { 5448, 0xb894 }, { 5455, 0x5c44 }, { 5461, 0x68d7 }, { 5470, 0x458a }, /* 0x8b00 */ { 5476, 0x5097 }, { 5483, 0x2ed1 }, { 5491, 0x1943 }, { 5497, 0x4208 }, { 5500, 0xd202 }, { 5505, 0x9d40 }, { 5511, 0x9840 }, { 5515, 0x2097 }, { 5521, 0x5409 }, { 5526, 0x064d }, { 5532, 0x0000 }, { 5532, 0x0000 }, { 5532, 0x0000 }, { 5532, 0x0000 }, { 5532, 0x0000 }, { 5532, 0x0000 }, /* 0x8c00 */ { 5532, 0x0000 }, { 5532, 0x0000 }, { 5532, 0x0000 }, { 5532, 0x8480 }, { 5535, 0x5542 }, { 5541, 0x0421 }, { 5544, 0x1c06 }, { 5549, 0x1700 }, { 5553, 0x7624 }, { 5560, 0x6110 }, { 5564, 0xff87 }, { 5576, 0xb9dd }, { 5587, 0x659f }, { 5597, 0x5c0a }, { 5603, 0x245d }, { 5610, 0x3c00 }, /* 0x8d00 */ { 5614, 0xadb0 }, { 5622, 0x0059 }, { 5626, 0x0000 }, { 5626, 0x0000 }, { 5626, 0x0000 }, { 5626, 0x0000 }, { 5626, 0x28d0 }, { 5631, 0x009b }, { 5636, 0x0422 }, { 5639, 0x0200 }, { 5640, 0x0108 }, { 5642, 0x4408 }, { 5645, 0x9804 }, { 5649, 0xac40 }, { 5654, 0x8d0a }, { 5660, 0x9028 }, /* 0x8e00 */ { 5664, 0x8700 }, { 5668, 0xe001 }, { 5672, 0x0400 }, { 5673, 0x0031 }, { 5676, 0x1794 }, { 5683, 0x8221 }, { 5687, 0x0019 }, { 5690, 0x1054 }, { 5694, 0x2cb2 }, { 5701, 0x021a }, { 5705, 0x9c02 }, { 5710, 0x4003 }, { 5713, 0x3d60 }, { 5720, 0x8804 }, { 5723, 0x080c }, { 5726, 0x7900 }, /* 0x8f00 */ { 5731, 0x1628 }, { 5736, 0xba3c }, { 5745, 0x8640 }, { 5749, 0xcb08 }, { 5755, 0x7274 }, { 5763, 0x9080 }, { 5766, 0x001e }, { 5770, 0x0000 }, { 5770, 0x0000 }, { 5770, 0xd800 }, { 5774, 0xe188 }, { 5780, 0x9c87 }, { 5788, 0x4034 }, { 5792, 0x0412 }, { 5795, 0xae64 }, { 5803, 0x2791 }, /* 0x9000 */ { 5810, 0xe86b }, { 5819, 0xe6fb }, { 5831, 0x408f }, { 5837, 0x5366 }, { 5845, 0xeea6 }, { 5855, 0x537f }, { 5866, 0xe32b }, { 5875, 0xb5e4 }, { 5884, 0x869f }, { 5893, 0x0002 }, { 5894, 0x8548 }, { 5899, 0x0122 }, { 5902, 0x4402 }, { 5905, 0x0800 }, { 5906, 0x2116 }, { 5911, 0x20a0 }, /* 0x9100 */ { 5914, 0x0004 }, { 5915, 0x0204 }, { 5917, 0x2000 }, { 5918, 0x0005 }, { 5920, 0x7e00 }, { 5926, 0x0154 }, { 5930, 0x162c }, { 5936, 0x01ac }, { 5941, 0x2a84 }, { 5946, 0x1085 }, { 5950, 0x8c14 }, { 5955, 0x0530 }, { 5959, 0xfbc3 }, { 5970, 0xb943 }, { 5978, 0x00ca }, { 5982, 0x9060 }, /* 0x9200 */ { 5986, 0x6000 }, { 5988, 0x4032 }, { 5992, 0x1200 }, { 5994, 0x8090 }, { 5997, 0x0b30 }, { 6002, 0x4c81 }, { 6007, 0x0054 }, { 6010, 0x4002 }, { 6012, 0x0029 }, { 6015, 0x1d6a }, { 6023, 0x2000 }, { 6024, 0x0280 }, { 6026, 0x8000 }, { 6027, 0x0004 }, { 6028, 0x2610 }, { 6032, 0x150c }, /* 0x9300 */ { 6037, 0x8040 }, { 6039, 0x0701 }, { 6043, 0xd94d }, { 6052, 0x0c24 }, { 6056, 0x2810 }, { 6059, 0x1850 }, { 6063, 0x5001 }, { 6066, 0x5020 }, { 6069, 0x1000 }, { 6070, 0x04d0 }, { 6074, 0x7080 }, { 6078, 0x0201 }, { 6080, 0x0108 }, { 6082, 0x21c3 }, { 6088, 0x0132 }, { 6092, 0x0000 }, /* 0x9400 */ { 6092, 0x0088 }, { 6094, 0x0719 }, { 6100, 0x0802 }, { 6102, 0x0560 }, { 6106, 0x0012 }, { 6108, 0x4c0e }, { 6114, 0x0405 }, { 6117, 0xf0a1 }, { 6124, 0x0002 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, /* 0x9500 */ { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0000 }, { 6125, 0x0080 }, { 6126, 0x8e8d }, { 6134, 0x035a }, { 6140, 0x21bd }, { 6148, 0x5a04 }, { 6153, 0x3488 }, { 6158, 0x1170 }, { 6163, 0x0026 }, { 6166, 0x0000 }, /* 0x9600 */ { 6166, 0x0000 }, { 6166, 0x1000 }, { 6167, 0xc502 }, { 6172, 0x8804 }, { 6175, 0xb815 }, { 6182, 0xf801 }, { 6188, 0x147c }, { 6195, 0x25ed }, { 6204, 0xed60 }, { 6212, 0x1bb0 }, { 6219, 0x0589 }, { 6224, 0x1bd7 }, { 6234, 0x7af3 }, { 6245, 0x1a62 }, { 6251, 0x0d0c }, { 6256, 0x0ac5 }, /* 0x9700 */ { 6262, 0xe5d1 }, { 6271, 0x524a }, { 6277, 0x0490 }, { 6280, 0x6305 }, { 6286, 0x0354 }, { 6291, 0x5244 }, { 6296, 0x2b57 }, { 6305, 0x1612 }, { 6310, 0xa872 }, { 6317, 0x1101 }, { 6320, 0x2949 }, { 6326, 0x0018 }, { 6328, 0x0948 }, { 6332, 0x1008 }, { 6334, 0x6000 }, { 6336, 0x886c }, /* 0x9800 */ { 6342, 0x916e }, { 6350, 0x058f }, { 6357, 0x3012 }, { 6361, 0x3990 }, { 6367, 0xf840 }, { 6373, 0x4930 }, { 6378, 0x8880 }, { 6381, 0x001b }, { 6385, 0x0000 }, { 6385, 0x0000 }, { 6385, 0x8500 }, { 6388, 0x0042 }, { 6390, 0x0058 }, { 6393, 0x9800 }, { 6396, 0xea04 }, { 6402, 0x7014 }, /* 0x9900 */ { 6407, 0x1628 }, { 6412, 0x611d }, { 6419, 0x5113 }, { 6425, 0x6000 }, { 6427, 0x1a24 }, { 6432, 0x00a7 }, { 6437, 0x0000 }, { 6437, 0x0000 }, { 6437, 0x0000 }, { 6437, 0x03c0 }, { 6441, 0x7120 }, { 6446, 0x1018 }, { 6449, 0x0172 }, { 6454, 0xa927 }, { 6462, 0x6004 }, { 6465, 0x8906 }, /* 0x9a00 */ { 6470, 0xc022 }, { 6474, 0x020c }, { 6477, 0x0900 }, { 6479, 0x4081 }, { 6482, 0x202d }, { 6487, 0x8ca0 }, { 6492, 0x0e34 }, { 6498, 0x0000 }, { 6498, 0x0000 }, { 6498, 0x0000 }, { 6498, 0x2100 }, { 6500, 0x1101 }, { 6503, 0x8011 }, { 6506, 0xc11a }, { 6512, 0xec4c }, { 6520, 0x0892 }, /* 0x9b00 */ { 6524, 0x0040 }, { 6525, 0x8500 }, { 6528, 0xc7ac }, { 6537, 0x1806 }, { 6541, 0xe03e }, { 6549, 0x0512 }, { 6553, 0x8000 }, { 6554, 0x0010 }, { 6555, 0x4008 }, { 6557, 0x80ce }, { 6563, 0x6d01 }, { 6569, 0x0210 }, { 6571, 0x8641 }, { 6576, 0x0856 }, { 6581, 0x011e }, { 6586, 0x0027 }, /* 0x9c00 */ { 6590, 0x3750 }, { 6597, 0x083d }, { 6603, 0xe032 }, { 6609, 0x4e05 }, { 6615, 0x01c0 }, { 6618, 0x0484 }, { 6621, 0x0081 }, { 6623, 0x0140 }, { 6625, 0x0000 }, { 6625, 0x0000 }, { 6625, 0x0000 }, { 6625, 0x0000 }, { 6625, 0x0000 }, { 6625, 0x0000 }, { 6625, 0x1aa0 }, { 6630, 0x0059 }, /* 0x9d00 */ { 6634, 0x43c8 }, { 6640, 0x8824 }, { 6644, 0x1d48 }, { 6650, 0xc800 }, { 6653, 0x0152 }, { 6657, 0x7203 }, { 6663, 0x9013 }, { 6668, 0x0404 }, { 6670, 0x8280 }, { 6673, 0x0400 }, { 6674, 0x8a10 }, { 6678, 0x0d14 }, { 6683, 0x8056 }, { 6688, 0x0208 }, { 6690, 0xa040 }, { 6693, 0x2704 }, /* 0x9e00 */ { 6698, 0x0000 }, { 6698, 0x4c00 }, { 6701, 0x0000 }, { 6701, 0x0000 }, { 6701, 0x0000 }, { 6701, 0x0000 }, { 6701, 0x0000 }, { 6701, 0xa320 }, { 6706, 0x1902 }, { 6710, 0xa0ae }, { 6717, 0x2660 }, { 6722, 0xdf00 }, { 6729, 0xf010 }, { 6734, 0x7b15 }, { 6743, 0x8121 }, { 6747, 0x3ad0 }, /* 0x9f00 */ { 6754, 0x4180 }, { 6757, 0x0028 }, { 6759, 0x1003 }, { 6762, 0x4800 }, { 6764, 0xcc00 }, { 6768, 0x8014 }, { 6771, 0x14cf }, { 6779, 0x00c4 }, { 6782, 0x2000 }, { 6783, 0x3020 }, { 6786, 0x0001 }, }; static const Summary16 jisx0208_uni2indx_pageff[15] = { /* 0xff00 */ { 6787, 0xdf7a }, { 6799, 0xffff }, { 6815, 0xffff }, { 6831, 0xffff }, { 6847, 0xffff }, { 6863, 0x3fff }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0000 }, { 6877, 0x0028 }, }; static int jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) { if (n >= 2) { const Summary16 *summary = NULL; if (wc > 0x0000 && wc < 0x0100) summary = &jisx0208_uni2indx_page00[(wc>>4)]; else if (wc >= 0x0300 && wc < 0x0460) summary = &jisx0208_uni2indx_page03[(wc>>4)-0x030]; else if (wc >= 0x2000 && wc < 0x2320) summary = &jisx0208_uni2indx_page20[(wc>>4)-0x200]; else if (wc >= 0x2500 && wc < 0x2670) summary = &jisx0208_uni2indx_page25[(wc>>4)-0x250]; else if (wc >= 0x3000 && wc < 0x3100) summary = &jisx0208_uni2indx_page30[(wc>>4)-0x300]; else if (wc >= 0x4e00 && wc < 0x9fb0) summary = &jisx0208_uni2indx_page4e[(wc>>4)-0x4e0]; else if (wc >= 0xff00 && wc < 0xfff0) summary = &jisx0208_uni2indx_pageff[(wc>>4)-0xff0]; if (summary) { unsigned short used = summary->used; unsigned int i = wc & 0x0f; if (used & ((unsigned short) 1 << i)) { unsigned short c; /* Keep in `used' only the bits 0..i-1. */ used &= ((unsigned short) 1 << i) - 1; /* Add `summary->indx' and the number of bits set in `used'. */ used = (used & 0x5555) + ((used & 0xaaaa) >> 1); used = (used & 0x3333) + ((used & 0xcccc) >> 2); used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4); used = (used & 0x00ff) + (used >> 8); c = jisx0208_2charset[summary->indx + used]; r[0] = (c >> 8); r[1] = (c & 0xff); return 2; } } return RET_ILUNI; } return RET_TOOSMALL; }
148,305
C++
.h
2,409
58.49066
75
0.693728
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,559
utf7.h
w1hkj_fldigi/src/libtiniconv/encdec/utf7.h
/* * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * The GNU LIBICONV Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with the GNU LIBICONV Library; see the file COPYING.LIB. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301, USA. */ /* * UTF-7 */ /* Specification: RFC 2152 (and old RFC 1641, RFC 1642) */ /* The original Base64 encoding is defined in RFC 2045. */ /* Set of direct characters: * A-Z a-z 0-9 ' ( ) , - . / : ? space tab lf cr */ static const unsigned char direct_tab[128/8] = { 0x00, 0x26, 0x00, 0x00, 0x81, 0xf3, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07, 0xfe, 0xff, 0xff, 0x07, }; #define isdirect(ch) ((ch) < 128 && ((direct_tab[(ch)>>3] >> (ch & 7)) & 1)) /* Set of direct and optional direct characters: * A-Z a-z 0-9 ' ( ) , - . / : ? space tab lf cr * ! " # $ % & * ; < = > @ [ ] ^ _ ` { | } */ static const unsigned char xdirect_tab[128/8] = { 0x00, 0x26, 0x00, 0x00, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0x3f, }; #define isxdirect(ch) ((ch) < 128 && ((xdirect_tab[(ch)>>3] >> (ch & 7)) & 1)) /* Set of base64 characters, extended: * A-Z a-z 0-9 + / - */ static const unsigned char xbase64_tab[128/8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xff, 0x03, 0xfe, 0xff, 0xff, 0x07, 0xfe, 0xff, 0xff, 0x07, }; #define isxbase64(ch) ((ch) < 128 && ((xbase64_tab[(ch)>>3] >> (ch & 7)) & 1)) /* * The state is structured as follows: * bit 1..0: shift * bit 7..2: data * Precise meaning: * shift data * 0 0 not inside base64 encoding * 1 0 inside base64, no pending bits * 2 XXXX00 inside base64, 4 bits remain from 2nd byte * 3 XX0000 inside base64, 2 bits remain from 3rd byte */ static int utf7_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) { conv_state_t state = conv->istate; int count = 0; /* number of input bytes already read */ if (state & 3) goto active; else goto inactive; inactive: { /* Here (state & 3) == 0 */ if (n < count+1) goto none; { unsigned char c = *s; if (isxdirect(c)) { *pwc = (ucs4_t) c; conv->istate = state; return count+1; } if (c == '+') { if (n < count+2) goto none; if (s[1] == '-') { *pwc = (ucs4_t) '+'; conv->istate = state; return count+2; } s++; count++; state = 1; goto active; } return RET_ILSEQ; } } active: { /* base64 encoding active */ unsigned int wc = 0; conv_state_t base64state = state; unsigned int kmax = 2; /* number of payload bytes to read */ unsigned int k = 0; /* number of payload bytes already read */ unsigned int base64count = 0; /* number of base64 bytes already read */ for (;;) { unsigned char c = *s; unsigned int i; if (c >= 'A' && c <= 'Z') i = c-'A'; else if (c >= 'a' && c <= 'z') i = c-'a'+26; else if (c >= '0' && c <= '9') i = c-'0'+52; else if (c == '+') i = 62; else if (c == '/') i = 63; else { /* c terminates base64 encoding */ if (base64state & -4) return RET_ILSEQ; /* data must be 0, otherwise illegal */ if (base64count) return RET_ILSEQ; /* partial UTF-16 characters are invalid */ if (c == '-') { s++; count++; } state = 0; goto inactive; } s++; base64count++; /* read 6 bits: 0 <= i < 64 */ switch (base64state & 3) { case 1: /* inside base64, no pending bits */ base64state = (i << 2) | 0; break; case 0: /* inside base64, 6 bits remain from 1st byte */ wc = (wc << 8) | (base64state & -4) | (i >> 4); k++; base64state = ((i & 15) << 4) | 2; break; case 2: /* inside base64, 4 bits remain from 2nd byte */ wc = (wc << 8) | (base64state & -4) | (i >> 2); k++; base64state = ((i & 3) << 6) | 3; break; case 3: /* inside base64, 2 bits remain from 3rd byte */ wc = (wc << 8) | (base64state & -4) | i; k++; base64state = 1; break; } if (k == kmax) { /* UTF-16: When we see a High Surrogate, we must also decode the following Low Surrogate. */ if (kmax == 2 && (wc >= 0xd800 && wc < 0xdc00)) kmax = 4; else break; } if (n < count+(int)base64count+1) { if (*(s-base64count-count) == '+') { /* Begin of base64 sequence. * Not changing state and not reporting RET_TOOFEW(>0). * Next time will do the things again. */ return RET_TOOSMALL; } goto none; } } /* Here k = kmax > 0, hence base64count > 0. */ if ((base64state & 3) == 0) abort(); if (kmax == 4) { ucs4_t wc1 = wc >> 16; ucs4_t wc2 = wc & 0xffff; if (!(wc1 >= 0xd800 && wc1 < 0xdc00)) abort(); if (!(wc2 >= 0xdc00 && wc2 < 0xe000)) return RET_ILSEQ; *pwc = 0x10000 + ((wc1 - 0xd800) << 10) + (wc2 - 0xdc00); } else { *pwc = wc; } conv->istate = base64state; return count+base64count; } none: conv->istate = state; return RET_TOOFEW(count); } /* * The state is structured as follows: * bit 1..0: shift * bit 7..2: data * Precise meaning: * shift data * 0 0 not inside base64 encoding * 1 0 inside base64, no pending bits * 2 XX00 inside base64, 2 bits known for 2nd byte * 3 XXXX inside base64, 4 bits known for 3rd byte */ /* Define this to 1 if you want the so-called "optional direct" characters ! " # $ % & * ; < = > @ [ ] ^ _ ` { | } to be encoded. Define to 0 if you want them to be passed straight through, like the so-called "direct" characters. We set this to 1 because it's safer. */ #define UTF7_ENCODE_OPTIONAL_CHARS 1 static int utf7_wctomb (conv_t conv, unsigned char *r, ucs4_t iwc, int n) { conv_state_t state = conv->ostate; unsigned int wc = iwc; int count = 0; if (state & 3) goto active; /*inactive:*/ { if (UTF7_ENCODE_OPTIONAL_CHARS ? isdirect(wc) : isxdirect(wc)) { r[0] = (unsigned char) wc; /*conv->ostate = state;*/ return 1; } else { *r++ = '+'; if (wc == '+') { if (n < 2) return RET_TOOSMALL; *r = '-'; /*conv->ostate = state;*/ return 2; } count = 1; state = 1; goto active; } } active: { /* base64 encoding active */ if (UTF7_ENCODE_OPTIONAL_CHARS ? isdirect(wc) : isxdirect(wc)) { /* deactivate base64 encoding */ count += ((state & 3) >= 2 ? 1 : 0) + (isxbase64(wc) ? 1 : 0) + 1; if (n < count) return RET_TOOSMALL; if ((state & 3) >= 2) { unsigned int i = state & -4; unsigned char c = 0; if (i < 26) c = i+'A'; else if (i < 52) c = i-26+'a'; else if (i < 62) c = i-52+'0'; else if (i == 62) c = '+'; else if (i == 63) c = '/'; else abort(); *r++ = c; } if (isxbase64(wc)) *r++ = '-'; state = 0; *r++ = (unsigned char) wc; conv->ostate = state; return count; } else { unsigned int k; /* number of payload bytes to write */ if (wc < 0x10000) { k = 2; count += ((state & 3) >= 2 ? 3 : 2); } else if (wc < 0x110000) { unsigned int wc1 = 0xd800 + ((wc - 0x10000) >> 10); unsigned int wc2 = 0xdc00 + ((wc - 0x10000) & 0x3ff); wc = (wc1 << 16) | wc2; k = 4; count += ((state & 3) >= 3 ? 6 : 5); } else return RET_ILUNI; if (n < count) return RET_TOOSMALL; for (;;) { unsigned int i; unsigned char c = 0; switch (state & 3) { case 0: /* inside base64, 6 bits known for 4th byte */ c = (state & -4) >> 2; state = 1; break; case 1: /* inside base64, no pending bits */ i = (wc >> (8 * --k)) & 0xff; c = i >> 2; state = ((i & 3) << 4) | 2; break; case 2: /* inside base64, 2 bits known for 2nd byte */ i = (wc >> (8 * --k)) & 0xff; c = (state & -4) | (i >> 4); state = ((i & 15) << 2) | 3; break; case 3: /* inside base64, 4 bits known for 3rd byte */ i = (wc >> (8 * --k)) & 0xff; c = (state & -4) | (i >> 6); state = ((i & 63) << 2) | 0; break; default: abort(); /* stupid gcc */ } if (c < 26) c = c+'A'; else if (c < 52) c = c-26+'a'; else if (c < 62) c = c-52+'0'; else if (c == 62) c = '+'; else if (c == 63) c = '/'; else abort(); *r++ = c; if ((state & 3) && (k == 0)) break; } conv->ostate = state; return count; } } } static int utf7_reset (conv_t conv, unsigned char *r, int n) { conv_state_t state = conv->ostate; if (state & 3) { /* deactivate base64 encoding */ int count = ((state & 3) >= 2 ? 1 : 0) + 1; if (n < count) return RET_TOOSMALL; if ((state & 3) >= 2) { unsigned int i = state & -4; unsigned char c = 0; if (i < 26) c = i+'A'; else if (i < 52) c = i-26+'a'; else if (i < 62) c = i-52+'0'; else if (i == 62) c = '+'; else if (i == 63) c = '/'; else abort(); *r++ = c; } *r++ = '-'; /* conv->ostate = 0; will be done by the caller */ return count; } else return 0; }
10,534
C++
.h
344
24.465116
78
0.506782
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,561
ucs2.h
w1hkj_fldigi/src/libtiniconv/encdec/ucs2.h
/* * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * The GNU LIBICONV Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with the GNU LIBICONV Library; see the file COPYING.LIB. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301, USA. */ /* * UCS-2 */ /* Here we accept FFFE/FEFF marks as endianness indicators everywhere in the stream, not just at the beginning. The default is big-endian. */ /* The state is 0 if big-endian, 1 if little-endian. */ static int ucs2_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) { conv_state_t state = conv->istate; int count = 0; for (; n >= 2;) { ucs4_t wc = (state ? s[0] + (s[1] << 8) : (s[0] << 8) + s[1]); s += 2; n -= 2; count += 2; if (wc == 0xfeff) { } else if (wc == 0xfffe) { state ^= 1; } else if (wc >= 0xd800 && wc < 0xe000) { return RET_ILSEQ; } else { *pwc = wc; conv->istate = state; return count; } } conv->istate = state; return RET_TOOFEW(count); } /* But we output UCS-2 in big-endian order, without byte-order mark. */ /* RFC 2152 says: "ISO/IEC 10646-1:1993(E) specifies that when characters the UCS-2 form are serialized as octets, that the most significant octet appear first." */ static int ucs2_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) { if (wc < 0x10000 && wc != 0xfffe && !(wc >= 0xd800 && wc < 0xe000)) { if (n >= 2) { r[0] = (unsigned char) (wc >> 8); r[1] = (unsigned char) wc; return 2; } else return RET_TOOSMALL; } else return RET_ILUNI; }
2,255
C++
.h
64
32
77
0.665448
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,563
cp1258.h
w1hkj_fldigi/src/libtiniconv/encdec/cp1258.h
/* * Copyright (C) 1999-2001, 2004 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * The GNU LIBICONV Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with the GNU LIBICONV Library; see the file COPYING.LIB. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301, USA. */ /* * CP1258 */ #include "flushwc.h" #include "vietcomb.h" static const unsigned char cp1258_comb_table[] = { 0xcc, 0xec, 0xde, 0xd2, 0xf2, }; /* The possible bases in viet_comp_table_data: 0x0041..0x0045, 0x0047..0x0049, 0x004B..0x0050, 0x0052..0x0057, 0x0059..0x005A, 0x0061..0x0065, 0x0067..0x0069, 0x006B..0x0070, 0x0072..0x0077, 0x0079..0x007A, 0x00A5, 0x00A8, 0x00C2, 0x00C5..0x00C7, 0x00CA, 0x00CF, 0x00D3..0x00D4, 0x00D6, 0x00D8, 0x00DA, 0x00DC, 0x00E2, 0x00E5..0x00E7, 0x00EA, 0x00EF, 0x00F3..0x00F4, 0x00F6, 0x00F8, 0x00FA, 0x00FC, 0x0102..0x0103, 0x01A0..0x01A1, 0x01AF..0x01B0. */ static const unsigned int cp1258_comp_bases[] = { 0x06fdfbbe, 0x06fdfbbe, 0x00000000, 0x00000120, 0x155884e4, 0x155884e4, 0x0000000c, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00018003 }; static const unsigned short cp1258_2uni[128] = { /* 0x80 */ 0x20ac, 0xfffd, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0xfffd, 0x2039, 0x0152, 0xfffd, 0xfffd, 0xfffd, /* 0x90 */ 0xfffd, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0xfffd, 0x203a, 0x0153, 0xfffd, 0xfffd, 0x0178, /* 0xa0 */ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, /* 0xb0 */ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, /* 0xc0 */ 0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x00c5, 0x00c6, 0x00c7, 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x0300, 0x00cd, 0x00ce, 0x00cf, /* 0xd0 */ 0x0110, 0x00d1, 0x0309, 0x00d3, 0x00d4, 0x01a0, 0x00d6, 0x00d7, 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x01af, 0x0303, 0x00df, /* 0xe0 */ 0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0301, 0x00ed, 0x00ee, 0x00ef, /* 0xf0 */ 0x0111, 0x00f1, 0x0323, 0x00f3, 0x00f4, 0x01a1, 0x00f6, 0x00f7, 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x01b0, 0x20ab, 0x00ff, }; /* In the CP1258 to Unicode direction, the state contains a buffered character, or 0 if none. */ static int cp1258_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) { unsigned char c = *s; unsigned short wc; unsigned short last_wc; if (c < 0x80) { wc = c; } else { wc = cp1258_2uni[c-0x80]; if (wc == 0xfffd) return RET_ILSEQ; } last_wc = conv->istate; if (last_wc) { if (wc >= 0x0300 && wc < 0x0340) { /* See whether last_wc and wc can be combined. */ unsigned int k = 0; unsigned int i1, i2; switch (wc) { case 0x0300: k = 0; break; case 0x0301: k = 1; break; case 0x0303: k = 2; break; case 0x0309: k = 3; break; case 0x0323: k = 4; break; default: abort(); } i1 = viet_comp_table[k].idx; i2 = i1 + viet_comp_table[k].len-1; if (last_wc >= viet_comp_table_data[i1].base && last_wc <= viet_comp_table_data[i2].base) { unsigned int i; for (;;) { i = (i1+i2)>>1; if (last_wc == viet_comp_table_data[i].base) break; if (last_wc < viet_comp_table_data[i].base) { if (i1 == i) goto not_combining; i2 = i; } else { if (i1 != i) i1 = i; else { i = i2; if (last_wc == viet_comp_table_data[i].base) break; goto not_combining; } } } last_wc = viet_comp_table_data[i].composed; /* Output the combined character. */ conv->istate = 0; *pwc = (ucs4_t) last_wc; return 1; } } not_combining: /* Output the buffered character. */ conv->istate = 0; *pwc = (ucs4_t) last_wc; return 0; /* Don't advance the input pointer. */ } if (wc >= 0x0041 && wc <= 0x01b0 && ((cp1258_comp_bases[(wc - 0x0040) >> 5] >> (wc & 0x1f)) & 1)) { /* wc is a possible match in viet_comp_table_data. Buffer it. */ conv->istate = wc; return RET_TOOFEW(1); } else { /* Output wc immediately. */ *pwc = (ucs4_t) wc; return 1; } } #define cp1258_flushwc normal_flushwc static const unsigned char cp1258_page00[88] = { 0xc0, 0xc1, 0xc2, 0x00, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0-0xc7 */ 0xc8, 0xc9, 0xca, 0xcb, 0x00, 0xcd, 0xce, 0xcf, /* 0xc8-0xcf */ 0x00, 0xd1, 0x00, 0xd3, 0xd4, 0x00, 0xd6, 0xd7, /* 0xd0-0xd7 */ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x00, 0x00, 0xdf, /* 0xd8-0xdf */ 0xe0, 0xe1, 0xe2, 0x00, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0-0xe7 */ 0xe8, 0xe9, 0xea, 0xeb, 0x00, 0xed, 0xee, 0xef, /* 0xe8-0xef */ 0x00, 0xf1, 0x00, 0xf3, 0xf4, 0x00, 0xf6, 0xf7, /* 0xf0-0xf7 */ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0x00, 0xff, /* 0xf8-0xff */ /* 0x0100 */ 0x00, 0x00, 0xc3, 0xe3, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0xd0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ }; static const unsigned char cp1258_page01[104] = { 0x00, 0x00, 0x8c, 0x9c, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ 0xd5, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd, /* 0xa8-0xaf */ 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0-0xb7 */ }; static const unsigned char cp1258_page02[32] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, /* 0xc0-0xc7 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0-0xd7 */ 0x00, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, /* 0xd8-0xdf */ }; static const unsigned char cp1258_page03[40] = { 0xcc, 0xec, 0x00, 0xde, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ 0x00, 0xd2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ 0x00, 0x00, 0x00, 0xf2, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ }; static const unsigned char cp1258_page20[48] = { 0x00, 0x00, 0x00, 0x96, 0x97, 0x00, 0x00, 0x00, /* 0x10-0x17 */ 0x91, 0x92, 0x82, 0x00, 0x93, 0x94, 0x84, 0x00, /* 0x18-0x1f */ 0x86, 0x87, 0x95, 0x00, 0x00, 0x00, 0x85, 0x00, /* 0x20-0x27 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ 0x00, 0x8b, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ }; static int cp1258_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) { unsigned char c = 0; if (wc < 0x0080) { *r = wc; return 1; } else if (wc >= 0x00a0 && wc < 0x00c0) c = wc; else if (wc >= 0x00c0 && wc < 0x0118) c = cp1258_page00[wc-0x00c0]; else if (wc >= 0x0150 && wc < 0x01b8) c = cp1258_page01[wc-0x0150]; else if (wc >= 0x02c0 && wc < 0x02e0) c = cp1258_page02[wc-0x02c0]; else if (wc >= 0x0300 && wc < 0x0328) c = cp1258_page03[wc-0x0300]; else if (wc >= 0x0340 && wc < 0x0342) /* deprecated Vietnamese tone marks */ c = cp1258_page03[wc-0x0340]; else if (wc >= 0x2010 && wc < 0x2040) c = cp1258_page20[wc-0x2010]; else if (wc == 0x20ab) c = 0xfe; else if (wc == 0x20ac) c = 0x80; else if (wc == 0x2122) c = 0x99; if (c != 0) { *r = c; return 1; } /* Try canonical decomposition. */ { /* Binary search through viet_decomp_table. */ unsigned int i1 = 0; unsigned int i2 = sizeof(viet_decomp_table)/sizeof(viet_decomp_table[0])-1; if (wc >= viet_decomp_table[i1].composed && wc <= viet_decomp_table[i2].composed) { unsigned int i; for (;;) { /* Here i2 - i1 > 0. */ i = (i1+i2)>>1; if (wc == viet_decomp_table[i].composed) break; if (wc < viet_decomp_table[i].composed) { if (i1 == i) return RET_ILUNI; /* Here i1 < i < i2. */ i2 = i; } else { /* Here i1 <= i < i2. */ if (i1 != i) i1 = i; else { /* Here i2 - i1 = 1. */ i = i2; if (wc == viet_decomp_table[i].composed) break; else return RET_ILUNI; } } } /* Found a canonical decomposition. */ wc = viet_decomp_table[i].base; /* wc is one of 0x0020, 0x0041..0x005a, 0x0061..0x007a, 0x00a5, 0x00a8, 0x00c2, 0x00c5..0x00c7, 0x00ca, 0x00cf, 0x00d3, 0x00d4, 0x00d6, 0x00d8, 0x00da, 0x00dc, 0x00e2, 0x00e5..0x00e7, 0x00ea, 0x00ef, 0x00f3, 0x00f4, 0x00f6, 0x00f8, 0x00fc, 0x0102, 0x0103, 0x01a0, 0x01a1, 0x01af, 0x01b0. */ if (wc < 0x0100) c = wc; else if (wc < 0x0118) c = cp1258_page00[wc-0x00c0]; else c = cp1258_page01[wc-0x0150]; if (n < 2) return RET_TOOSMALL; r[0] = c; r[1] = cp1258_comb_table[viet_decomp_table[i].comb1]; return 2; } } return RET_ILUNI; }
10,562
C++
.h
278
32.809353
79
0.609694
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,564
iso2022_jp.h
w1hkj_fldigi/src/libtiniconv/encdec/iso2022_jp.h
/* * Copyright (C) 1999-2001 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * The GNU LIBICONV Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with the GNU LIBICONV Library; see the file COPYING.LIB. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301, USA. */ /* * ISO-2022-JP */ /* Specification: RFC 1468 */ #define ESC 0x1b /* * The state can be one of the following values. */ #define STATE_ASCII 0 #define STATE_JISX0201ROMAN 1 #define STATE_JISX0208 2 static int iso2022_jp_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n) { conv_state_t state = conv->istate; int count = 0; unsigned char c; for (;;) { c = *s; if (c == ESC) { if (n < count+3) goto none; if (s[1] == '(') { if (s[2] == 'B') { state = STATE_ASCII; s += 3; count += 3; if (n < count+1) goto none; continue; } if (s[2] == 'J') { state = STATE_JISX0201ROMAN; s += 3; count += 3; if (n < count+1) goto none; continue; } return RET_ILSEQ; } if (s[1] == '$') { if (s[2] == '@' || s[2] == 'B') { /* We don't distinguish JIS X 0208-1978 and JIS X 0208-1983. */ state = STATE_JISX0208; s += 3; count += 3; if (n < count+1) goto none; continue; } return RET_ILSEQ; } return RET_ILSEQ; } break; } switch (state) { case STATE_ASCII: if (c < 0x80) { int ret = ascii_mbtowc(conv,pwc,s,1); if (ret == RET_ILSEQ) return RET_ILSEQ; if (ret != 1) abort(); conv->istate = state; return count+1; } else return RET_ILSEQ; case STATE_JISX0201ROMAN: if (c < 0x80) { int ret = jisx0201_mbtowc(conv,pwc,s,1); if (ret == RET_ILSEQ) return RET_ILSEQ; if (ret != 1) abort(); conv->istate = state; return count+1; } else return RET_ILSEQ; case STATE_JISX0208: if (n < count+2) goto none; if (s[0] < 0x80 && s[1] < 0x80) { int ret = jisx0208_mbtowc(conv,pwc,s,2); if (ret == RET_ILSEQ) return RET_ILSEQ; if (ret != 2) abort(); conv->istate = state; return count+2; } else return RET_ILSEQ; default: abort(); } none: conv->istate = state; return RET_TOOFEW(count); } static int iso2022_jp_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n) { conv_state_t state = conv->ostate; unsigned char buf[2]; int ret; /* Try ASCII. */ ret = ascii_wctomb(conv,buf,wc,1); if (ret != RET_ILUNI) { if (ret != 1) abort(); if (buf[0] < 0x80) { int count = (state == STATE_ASCII ? 1 : 4); if (n < count) return RET_TOOSMALL; if (state != STATE_ASCII) { r[0] = ESC; r[1] = '('; r[2] = 'B'; r += 3; state = STATE_ASCII; } r[0] = buf[0]; conv->ostate = state; return count; } } /* Try JIS X 0201-1976 Roman. */ ret = jisx0201_wctomb(conv,buf,wc,1); if (ret != RET_ILUNI) { if (ret != 1) abort(); if (buf[0] < 0x80) { int count = (state == STATE_JISX0201ROMAN ? 1 : 4); if (n < count) return RET_TOOSMALL; if (state != STATE_JISX0201ROMAN) { r[0] = ESC; r[1] = '('; r[2] = 'J'; r += 3; state = STATE_JISX0201ROMAN; } r[0] = buf[0]; conv->ostate = state; return count; } } /* Try JIS X 0208-1990 in place of JIS X 0208-1978 and JIS X 0208-1983. */ ret = jisx0208_wctomb(conv,buf,wc,2); if (ret != RET_ILUNI) { if (ret != 2) abort(); if (buf[0] < 0x80 && buf[1] < 0x80) { int count = (state == STATE_JISX0208 ? 2 : 5); if (n < count) return RET_TOOSMALL; if (state != STATE_JISX0208) { r[0] = ESC; r[1] = '$'; r[2] = 'B'; r += 3; state = STATE_JISX0208; } r[0] = buf[0]; r[1] = buf[1]; conv->ostate = state; return count; } } return RET_ILUNI; } static int iso2022_jp_reset (conv_t conv, unsigned char *r, int n) { conv_state_t state = conv->ostate; if (state != STATE_ASCII) { if (n < 3) return RET_TOOSMALL; r[0] = ESC; r[1] = '('; r[2] = 'B'; /* conv->ostate = 0; will be done by the caller */ return 3; } else return 0; } #undef STATE_JISX0208 #undef STATE_JISX0201ROMAN #undef STATE_ASCII
5,264
C++
.h
199
20.592965
76
0.547506
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,565
vietcomb.h
w1hkj_fldigi/src/libtiniconv/encdec/vietcomb.h
/* * Copyright (C) 2001, 2004 Free Software Foundation, Inc. * This file is part of the GNU LIBICONV Library. * * The GNU LIBICONV Library is free software; you can redistribute it * and/or modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * The GNU LIBICONV Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with the GNU LIBICONV Library; see the file COPYING.LIB. * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * Fifth Floor, Boston, MA 02110-1301, USA. */ /* Combining characters used in Vietnamese encodings CP1258, TCVN. */ #ifndef _VIETCOMB_H #define _VIETCOMB_H /* Relevant combining characters: 0x0300, 0x0301, 0x0303, 0x0309, 0x0323. */ /* Composition tables for each of the relevant combining characters. */ static const struct { unsigned short base; unsigned short composed; } viet_comp_table_data[] = { #define viet_comp_table0300_idx 0 #define viet_comp_table0300_len 31 { 0x0041, 0x00C0 }, { 0x0045, 0x00C8 }, { 0x0049, 0x00CC }, { 0x004E, 0x01F8 }, { 0x004F, 0x00D2 }, { 0x0055, 0x00D9 }, { 0x0057, 0x1E80 }, { 0x0059, 0x1EF2 }, { 0x0061, 0x00E0 }, { 0x0065, 0x00E8 }, { 0x0069, 0x00EC }, { 0x006E, 0x01F9 }, { 0x006F, 0x00F2 }, { 0x0075, 0x00F9 }, { 0x0077, 0x1E81 }, { 0x0079, 0x1EF3 }, { 0x00A8, 0x1FED }, { 0x00C2, 0x1EA6 }, { 0x00CA, 0x1EC0 }, { 0x00D4, 0x1ED2 }, { 0x00DC, 0x01DB }, { 0x00E2, 0x1EA7 }, { 0x00EA, 0x1EC1 }, { 0x00F4, 0x1ED3 }, { 0x00FC, 0x01DC }, { 0x0102, 0x1EB0 }, { 0x0103, 0x1EB1 }, /*{ 0x0112, 0x1E14 },*/ /*{ 0x0113, 0x1E15 },*/ /*{ 0x014C, 0x1E50 },*/ /*{ 0x014D, 0x1E51 },*/ { 0x01A0, 0x1EDC }, { 0x01A1, 0x1EDD }, { 0x01AF, 0x1EEA }, { 0x01B0, 0x1EEB }, #define viet_comp_table0301_idx (viet_comp_table0300_idx+viet_comp_table0300_len) #define viet_comp_table0301_len 64 { 0x0041, 0x00C1 }, { 0x0043, 0x0106 }, { 0x0045, 0x00C9 }, { 0x0047, 0x01F4 }, { 0x0049, 0x00CD }, { 0x004B, 0x1E30 }, { 0x004C, 0x0139 }, { 0x004D, 0x1E3E }, { 0x004E, 0x0143 }, { 0x004F, 0x00D3 }, { 0x0050, 0x1E54 }, { 0x0052, 0x0154 }, { 0x0053, 0x015A }, { 0x0055, 0x00DA }, { 0x0057, 0x1E82 }, { 0x0059, 0x00DD }, { 0x005A, 0x0179 }, { 0x0061, 0x00E1 }, { 0x0063, 0x0107 }, { 0x0065, 0x00E9 }, { 0x0067, 0x01F5 }, { 0x0069, 0x00ED }, { 0x006B, 0x1E31 }, { 0x006C, 0x013A }, { 0x006D, 0x1E3F }, { 0x006E, 0x0144 }, { 0x006F, 0x00F3 }, { 0x0070, 0x1E55 }, { 0x0072, 0x0155 }, { 0x0073, 0x015B }, { 0x0075, 0x00FA }, { 0x0077, 0x1E83 }, { 0x0079, 0x00FD }, { 0x007A, 0x017A }, { 0x00A5, 0x0385 }, { 0x00A8, 0x1FEE }, { 0x00C2, 0x1EA4 }, { 0x00C5, 0x01FA }, { 0x00C6, 0x01FC }, { 0x00C7, 0x1E08 }, { 0x00CA, 0x1EBE }, { 0x00CF, 0x1E2E }, { 0x00D4, 0x1ED0 }, { 0x00D5, 0x1E4C }, { 0x00D8, 0x01FE }, { 0x00DC, 0x01D7 }, { 0x00E2, 0x1EA5 }, { 0x00E5, 0x01FB }, { 0x00E6, 0x01FD }, { 0x00E7, 0x1E09 }, { 0x00EA, 0x1EBF }, { 0x00EF, 0x1E2F }, { 0x00F4, 0x1ED1 }, { 0x00F5, 0x1E4D }, { 0x00F8, 0x01FF }, { 0x00FC, 0x01D8 }, { 0x0102, 0x1EAE }, { 0x0103, 0x1EAF }, /*{ 0x0112, 0x1E16 },*/ /*{ 0x0113, 0x1E17 },*/ /*{ 0x014C, 0x1E52 },*/ /*{ 0x014D, 0x1E53 },*/ { 0x0168, 0x1E78 }, { 0x0169, 0x1E79 }, { 0x01A0, 0x1EDA }, { 0x01A1, 0x1EDB }, { 0x01AF, 0x1EE8 }, { 0x01B0, 0x1EE9 }, #define viet_comp_table0303_idx (viet_comp_table0301_idx+viet_comp_table0301_len) #define viet_comp_table0303_len 34 { 0x0041, 0x00C3 }, { 0x0045, 0x1EBC }, { 0x0049, 0x0128 }, { 0x004E, 0x00D1 }, { 0x004F, 0x00D5 }, { 0x0055, 0x0168 }, { 0x0056, 0x1E7C }, { 0x0059, 0x1EF8 }, { 0x0061, 0x00E3 }, { 0x0065, 0x1EBD }, { 0x0069, 0x0129 }, { 0x006E, 0x00F1 }, { 0x006F, 0x00F5 }, { 0x0075, 0x0169 }, { 0x0076, 0x1E7D }, { 0x0079, 0x1EF9 }, { 0x00C2, 0x1EAA }, { 0x00CA, 0x1EC4 }, { 0x00D3, 0x1E4C }, { 0x00D4, 0x1ED6 }, { 0x00D6, 0x1E4E }, { 0x00DA, 0x1E78 }, { 0x00E2, 0x1EAB }, { 0x00EA, 0x1EC5 }, { 0x00F3, 0x1E4D }, { 0x00F4, 0x1ED7 }, { 0x00F6, 0x1E4F }, { 0x00FA, 0x1E79 }, { 0x0102, 0x1EB4 }, { 0x0103, 0x1EB5 }, { 0x01A0, 0x1EE0 }, { 0x01A1, 0x1EE1 }, { 0x01AF, 0x1EEE }, { 0x01B0, 0x1EEF }, #define viet_comp_table0309_idx (viet_comp_table0303_idx+viet_comp_table0303_len) #define viet_comp_table0309_len 24 { 0x0041, 0x1EA2 }, { 0x0045, 0x1EBA }, { 0x0049, 0x1EC8 }, { 0x004F, 0x1ECE }, { 0x0055, 0x1EE6 }, { 0x0059, 0x1EF6 }, { 0x0061, 0x1EA3 }, { 0x0065, 0x1EBB }, { 0x0069, 0x1EC9 }, { 0x006F, 0x1ECF }, { 0x0075, 0x1EE7 }, { 0x0079, 0x1EF7 }, { 0x00C2, 0x1EA8 }, { 0x00CA, 0x1EC2 }, { 0x00D4, 0x1ED4 }, { 0x00E2, 0x1EA9 }, { 0x00EA, 0x1EC3 }, { 0x00F4, 0x1ED5 }, { 0x0102, 0x1EB2 }, { 0x0103, 0x1EB3 }, { 0x01A0, 0x1EDE }, { 0x01A1, 0x1EDF }, { 0x01AF, 0x1EEC }, { 0x01B0, 0x1EED }, #define viet_comp_table0323_idx (viet_comp_table0309_idx+viet_comp_table0309_len) #define viet_comp_table0323_len 50 { 0x0041, 0x1EA0 }, { 0x0042, 0x1E04 }, { 0x0044, 0x1E0C }, { 0x0045, 0x1EB8 }, { 0x0048, 0x1E24 }, { 0x0049, 0x1ECA }, { 0x004B, 0x1E32 }, { 0x004C, 0x1E36 }, { 0x004D, 0x1E42 }, { 0x004E, 0x1E46 }, { 0x004F, 0x1ECC }, { 0x0052, 0x1E5A }, { 0x0053, 0x1E62 }, { 0x0054, 0x1E6C }, { 0x0055, 0x1EE4 }, { 0x0056, 0x1E7E }, { 0x0057, 0x1E88 }, { 0x0059, 0x1EF4 }, { 0x005A, 0x1E92 }, { 0x0061, 0x1EA1 }, { 0x0062, 0x1E05 }, { 0x0064, 0x1E0D }, { 0x0065, 0x1EB9 }, { 0x0068, 0x1E25 }, { 0x0069, 0x1ECB }, { 0x006B, 0x1E33 }, { 0x006C, 0x1E37 }, { 0x006D, 0x1E43 }, { 0x006E, 0x1E47 }, { 0x006F, 0x1ECD }, { 0x0072, 0x1E5B }, { 0x0073, 0x1E63 }, { 0x0074, 0x1E6D }, { 0x0075, 0x1EE5 }, { 0x0076, 0x1E7F }, { 0x0077, 0x1E89 }, { 0x0079, 0x1EF5 }, { 0x007A, 0x1E93 }, { 0x00C2, 0x1EAC }, { 0x00CA, 0x1EC6 }, { 0x00D4, 0x1ED8 }, { 0x00E2, 0x1EAD }, { 0x00EA, 0x1EC7 }, { 0x00F4, 0x1ED9 }, { 0x0102, 0x1EB6 }, { 0x0103, 0x1EB7 }, { 0x01A0, 0x1EE2 }, { 0x01A1, 0x1EE3 }, { 0x01AF, 0x1EF0 }, { 0x01B0, 0x1EF1 }, }; static const struct { unsigned int len; unsigned int idx; } viet_comp_table[] = { { viet_comp_table0300_len, viet_comp_table0300_idx }, { viet_comp_table0301_len, viet_comp_table0301_idx }, { viet_comp_table0303_len, viet_comp_table0303_idx }, { viet_comp_table0309_len, viet_comp_table0309_idx }, { viet_comp_table0323_len, viet_comp_table0323_idx }, }; /* Decomposition table for the relevant Unicode characters. */ struct viet_decomp { unsigned short composed; unsigned int base : 12; int comb1 : 4; }; static const struct viet_decomp viet_decomp_table[] = { { 0x00B4, 0x0020, 1 }, /* compatibility decomposition - for TCVN only */ { 0x00C0, 0x0041, 0 }, { 0x00C1, 0x0041, 1 }, { 0x00C3, 0x0041, 2 }, { 0x00C8, 0x0045, 0 }, { 0x00C9, 0x0045, 1 }, { 0x00CC, 0x0049, 0 }, { 0x00CD, 0x0049, 1 }, { 0x00D1, 0x004E, 2 }, { 0x00D2, 0x004F, 0 }, { 0x00D3, 0x004F, 1 }, { 0x00D5, 0x004F, 2 }, { 0x00D9, 0x0055, 0 }, { 0x00DA, 0x0055, 1 }, { 0x00DD, 0x0059, 1 }, { 0x00E0, 0x0061, 0 }, { 0x00E1, 0x0061, 1 }, { 0x00E3, 0x0061, 2 }, { 0x00E8, 0x0065, 0 }, { 0x00E9, 0x0065, 1 }, { 0x00EC, 0x0069, 0 }, { 0x00ED, 0x0069, 1 }, { 0x00F1, 0x006E, 2 }, { 0x00F2, 0x006F, 0 }, { 0x00F3, 0x006F, 1 }, { 0x00F5, 0x006F, 2 }, { 0x00F9, 0x0075, 0 }, { 0x00FA, 0x0075, 1 }, { 0x00FD, 0x0079, 1 }, { 0x0106, 0x0043, 1 }, { 0x0107, 0x0063, 1 }, { 0x0128, 0x0049, 2 }, { 0x0129, 0x0069, 2 }, { 0x0139, 0x004C, 1 }, { 0x013A, 0x006C, 1 }, { 0x0143, 0x004E, 1 }, { 0x0144, 0x006E, 1 }, { 0x0154, 0x0052, 1 }, { 0x0155, 0x0072, 1 }, { 0x015A, 0x0053, 1 }, { 0x015B, 0x0073, 1 }, { 0x0168, 0x0055, 2 }, { 0x0169, 0x0075, 2 }, { 0x0179, 0x005A, 1 }, { 0x017A, 0x007A, 1 }, { 0x01D7, 0x00DC, 1 }, { 0x01D8, 0x00FC, 1 }, { 0x01DB, 0x00DC, 0 }, { 0x01DC, 0x00FC, 0 }, { 0x01F4, 0x0047, 1 }, { 0x01F5, 0x0067, 1 }, { 0x01F8, 0x004E, 0 }, { 0x01F9, 0x006E, 0 }, { 0x01FA, 0x00C5, 1 }, { 0x01FB, 0x00E5, 1 }, { 0x01FC, 0x00C6, 1 }, { 0x01FD, 0x00E6, 1 }, { 0x01FE, 0x00D8, 1 }, { 0x01FF, 0x00F8, 1 }, { 0x02DC, 0x0020, 2 }, /* compatibility decomposition - for TCVN only */ { 0x0385, 0x00A5, 1 }, { 0x1E04, 0x0042, 4 }, { 0x1E05, 0x0062, 4 }, { 0x1E08, 0x00C7, 1 }, { 0x1E09, 0x00E7, 1 }, { 0x1E0C, 0x0044, 4 }, { 0x1E0D, 0x0064, 4 }, { 0x1E24, 0x0048, 4 }, { 0x1E25, 0x0068, 4 }, { 0x1E2E, 0x00CF, 1 }, { 0x1E2F, 0x00EF, 1 }, { 0x1E30, 0x004B, 1 }, { 0x1E31, 0x006B, 1 }, { 0x1E32, 0x004B, 4 }, { 0x1E33, 0x006B, 4 }, { 0x1E36, 0x004C, 4 }, { 0x1E37, 0x006C, 4 }, { 0x1E3E, 0x004D, 1 }, { 0x1E3F, 0x006D, 1 }, { 0x1E42, 0x004D, 4 }, { 0x1E43, 0x006D, 4 }, { 0x1E46, 0x004E, 4 }, { 0x1E47, 0x006E, 4 }, { 0x1E4C, 0x00D3, 2 }, /*{ 0x1E4C, 0x00D5, 1 },*/ /*{ 0x1E4C, 0x004F, 1, 2 },*/ { 0x1E4D, 0x00F3, 2 }, /*{ 0x1E4D, 0x00F5, 1 },*/ /*{ 0x1E4D, 0x006F, 1, 2 },*/ { 0x1E4E, 0x00D6, 2 }, { 0x1E4F, 0x00F6, 2 }, { 0x1E54, 0x0050, 1 }, { 0x1E55, 0x0070, 1 }, { 0x1E5A, 0x0052, 4 }, { 0x1E5B, 0x0072, 4 }, { 0x1E62, 0x0053, 4 }, { 0x1E63, 0x0073, 4 }, { 0x1E6C, 0x0054, 4 }, { 0x1E6D, 0x0074, 4 }, { 0x1E78, 0x00DA, 2 }, /*{ 0x1E78, 0x0168, 1 },*/ /*{ 0x1E78, 0x0055, 1, 2 },*/ { 0x1E79, 0x00FA, 2 }, /*{ 0x1E79, 0x0169, 1 },*/ /*{ 0x1E79, 0x0075, 1, 2 },*/ { 0x1E7C, 0x0056, 2 }, { 0x1E7D, 0x0076, 2 }, { 0x1E7E, 0x0056, 4 }, { 0x1E7F, 0x0076, 4 }, { 0x1E80, 0x0057, 0 }, { 0x1E81, 0x0077, 0 }, { 0x1E82, 0x0057, 1 }, { 0x1E83, 0x0077, 1 }, { 0x1E88, 0x0057, 4 }, { 0x1E89, 0x0077, 4 }, { 0x1E92, 0x005A, 4 }, { 0x1E93, 0x007A, 4 }, { 0x1EA0, 0x0041, 4 }, { 0x1EA1, 0x0061, 4 }, { 0x1EA2, 0x0041, 3 }, { 0x1EA3, 0x0061, 3 }, { 0x1EA4, 0x00C2, 1 }, { 0x1EA5, 0x00E2, 1 }, { 0x1EA6, 0x00C2, 0 }, { 0x1EA7, 0x00E2, 0 }, { 0x1EA8, 0x00C2, 3 }, { 0x1EA9, 0x00E2, 3 }, { 0x1EAA, 0x00C2, 2 }, { 0x1EAB, 0x00E2, 2 }, { 0x1EAC, 0x00C2, 4 }, { 0x1EAD, 0x00E2, 4 }, { 0x1EAE, 0x0102, 1 }, { 0x1EAF, 0x0103, 1 }, { 0x1EB0, 0x0102, 0 }, { 0x1EB1, 0x0103, 0 }, { 0x1EB2, 0x0102, 3 }, { 0x1EB3, 0x0103, 3 }, { 0x1EB4, 0x0102, 2 }, { 0x1EB5, 0x0103, 2 }, { 0x1EB6, 0x0102, 4 }, { 0x1EB7, 0x0103, 4 }, { 0x1EB8, 0x0045, 4 }, { 0x1EB9, 0x0065, 4 }, { 0x1EBA, 0x0045, 3 }, { 0x1EBB, 0x0065, 3 }, { 0x1EBC, 0x0045, 2 }, { 0x1EBD, 0x0065, 2 }, { 0x1EBE, 0x00CA, 1 }, { 0x1EBF, 0x00EA, 1 }, { 0x1EC0, 0x00CA, 0 }, { 0x1EC1, 0x00EA, 0 }, { 0x1EC2, 0x00CA, 3 }, { 0x1EC3, 0x00EA, 3 }, { 0x1EC4, 0x00CA, 2 }, { 0x1EC5, 0x00EA, 2 }, { 0x1EC6, 0x00CA, 4 }, { 0x1EC7, 0x00EA, 4 }, { 0x1EC8, 0x0049, 3 }, { 0x1EC9, 0x0069, 3 }, { 0x1ECA, 0x0049, 4 }, { 0x1ECB, 0x0069, 4 }, { 0x1ECC, 0x004F, 4 }, { 0x1ECD, 0x006F, 4 }, { 0x1ECE, 0x004F, 3 }, { 0x1ECF, 0x006F, 3 }, { 0x1ED0, 0x00D4, 1 }, { 0x1ED1, 0x00F4, 1 }, { 0x1ED2, 0x00D4, 0 }, { 0x1ED3, 0x00F4, 0 }, { 0x1ED4, 0x00D4, 3 }, { 0x1ED5, 0x00F4, 3 }, { 0x1ED6, 0x00D4, 2 }, { 0x1ED7, 0x00F4, 2 }, { 0x1ED8, 0x00D4, 4 }, { 0x1ED9, 0x00F4, 4 }, { 0x1EDA, 0x01A0, 1 }, { 0x1EDB, 0x01A1, 1 }, { 0x1EDC, 0x01A0, 0 }, { 0x1EDD, 0x01A1, 0 }, { 0x1EDE, 0x01A0, 3 }, { 0x1EDF, 0x01A1, 3 }, { 0x1EE0, 0x01A0, 2 }, { 0x1EE1, 0x01A1, 2 }, { 0x1EE2, 0x01A0, 4 }, { 0x1EE3, 0x01A1, 4 }, { 0x1EE4, 0x0055, 4 }, { 0x1EE5, 0x0075, 4 }, { 0x1EE6, 0x0055, 3 }, { 0x1EE7, 0x0075, 3 }, { 0x1EE8, 0x01AF, 1 }, { 0x1EE9, 0x01B0, 1 }, { 0x1EEA, 0x01AF, 0 }, { 0x1EEB, 0x01B0, 0 }, { 0x1EEC, 0x01AF, 3 }, { 0x1EED, 0x01B0, 3 }, { 0x1EEE, 0x01AF, 2 }, { 0x1EEF, 0x01B0, 2 }, { 0x1EF0, 0x01AF, 4 }, { 0x1EF1, 0x01B0, 4 }, { 0x1EF2, 0x0059, 0 }, { 0x1EF3, 0x0079, 0 }, { 0x1EF4, 0x0059, 4 }, { 0x1EF5, 0x0079, 4 }, { 0x1EF6, 0x0059, 3 }, { 0x1EF7, 0x0079, 3 }, { 0x1EF8, 0x0059, 2 }, { 0x1EF9, 0x0079, 2 }, { 0x1FED, 0x00A8, 0 }, { 0x1FEE, 0x00A8, 1 }, }; #endif /* _VIETCOMB_H */
12,442
C++
.h
461
24.156182
96
0.596827
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,568
mingw.h
w1hkj_fldigi/src/compat/mingw.h
// ---------------------------------------------------------------------------- // Copyright (C) 2014 // David Freese, W1HKJ // // This file is part of fldigi // // fldigi 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; either version 3 of the License, or // (at your option) any later version. // // fldigi 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, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef MINGW_H_ #define MINGW_H_ #include "config.h" #include <sys/types.h> #include <pthread.h> #undef _WINSOCKAPI_ #include <winsock2.h> #undef EADDRINUSE #define EADDRINUSE WSAEADDRINUSE #undef EISCONN #define EISCONN WSAEISCONN #undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK #undef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS #undef EALREADY #define EALREADY WSAEALREADY //====================================================================== #ifdef __cplusplus extern "C" { #endif typedef long suseconds_t; #define hstrerror strerror #ifndef SIGUSR2 # define SIGUSR2 100 #endif extern void was_init(void); extern int was_init_state(void); extern WSADATA * was_data(void); /* * simple adaptors */ static inline int mingw_mkdir(const char *path, int mode) { return mkdir(path); } #define mkdir mingw_mkdir static inline int mingw_unlink(const char *pathname) { /* read-only files cannot be removed */ chmod(pathname, 0666); return unlink(pathname); } #define unlink mingw_unlink /* * implementations of missing functions */ unsigned int sleep (unsigned int seconds); char *mingw_getcwd(char *pointer, int len); #define getcwd mingw_getcwd char *mingw_getenv(const char *name); #define getenv mingw_getenv int mingw_rename(const char*, const char*); #define rename mingw_rename #ifndef SHUT_WR # define SHUT_WR SD_SEND #endif #ifndef SHUT_RD # define SHUT_RD SD_RECEIVE #endif #ifndef SHUT_RDWR # define SHUT_RDWR SD_BOTH #endif int nanosleep (const struct timespec *req, struct timespec *rem); int socketpair(int family, int type, int protocol, SOCKET *sv); /* uname */ #define UTSNAME_MAX_ 257 struct utsname { char sysname[UTSNAME_MAX_]; char nodename[UTSNAME_MAX_]; char release[UTSNAME_MAX_]; char version[UTSNAME_MAX_]; char machine[UTSNAME_MAX_]; }; int uname(struct utsname *name); /* getrusage */ #define RUSAGE_SELF 0 #define RUSAGE_CHILDREN (-1) struct rusage { struct timeval ru_utime; struct timeval ru_stime; }; int getrusage(int who, struct rusage *usage); /* fsync, fdatasync */ #include <io.h> #define fsync _commit #define fdatasync fsync #ifdef __cplusplus } #endif #endif
3,044
C++
.h
112
25.8125
79
0.710599
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,569
run_script.h
w1hkj_fldigi/src/config_script/run_script.h
// ---------------------------------------------------------------------------- // Copyright (C) 2015 // Robert Stiles // // This file is part of fldigi // // fldigi 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; either version 3 of the License, or // (at your option) any later version. // // fldigi 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, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef _run_script_h #define _run_script_h extern int process_callsign_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_name_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_qth_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_locator_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_antenna_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_use_oss_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_oss_audio_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_use_port_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_capture_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_playback_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_use_pulse_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_pulse_audio_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_audio_device_sample_rate_capture(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_audio_device_sample_rate_playback(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_audio_device_converter(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rx_ppm(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_tx_ppm(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_tx_offset(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_modem_signal_left_right(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_reverse_left_right(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_ptt_tone_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_cw_qsk_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_pseudo_fsk_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_wave_file_sample_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_right_audio_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_sep_serial_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_sep_serial_port_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_sep_serial_port_rts(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_sep_serial_port_dtr(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_sep_serial_port_rts_v(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_sep_serial_port_dtr_v(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_start_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_end_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_uhrouter(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hrdw_ptt_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_cmedia_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_cmedia_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_cmedia_gpio_line(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_use_rigcat(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_desc_file(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_retries(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_retry_interval(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_init_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_baud_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_stop_bits(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_commands_echoed(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_toggle_rts_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_restore_on_close(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_cat_command_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_dtr_12v(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_rts_12v(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_hrdwr_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_vsp_enable(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rigcat_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_use_hamlib(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_rig(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_retries(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_retry_interval(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_post_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_baud_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_stop_bits(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_sideband(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_ptt_hl_command(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_dtr_12(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_rts_12(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_rts_cts_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_xon_xoff_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_advanced_config(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_hamlib_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_o_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_dual_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_busy_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_continue_after(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_kiss_kpsql_atten(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_arq_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_arq_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_xmlrpc_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_xmlrpc_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_active_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_ax25_decode(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_io_csma(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_misc_nbems_state(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_misc_nbems_open_flmsg(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_misc_nbems_open_msg(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_misc_nbems_open_brwsr(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_misc_nbems_flmsg_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_misc_nbems_timeout(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_notify(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_search_bp(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_mark_prev(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_detector(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_alert_dialog(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_tx_freq_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_freq_change(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_allow_errors(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_sql_open(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_pretone(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_end_xmt_id(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_video_tx_id_mode(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_video_tx_vid_txt(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_video_txt_input(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_video_small_font(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_video_500hz(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_video_width_limit(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rsid_char_per_row(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_cw_callsign(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_cw_speed(ScriptParsing *sp, SCRIPT_COMMANDS *sc); // FLDIGI main windows widgets extern int process_rig_freq(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rig_mode(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_wf_hz_offset(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rx_rsid(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_tx_rsid(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_spot(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_rev(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_afc(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_sql(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_kpsql(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_modem(ScriptParsing *sp, SCRIPT_COMMANDS *sc); extern int process_load_macro(ScriptParsing *sp, SCRIPT_COMMANDS *sc); #endif
10,788
C++
.h
150
70.806667
93
0.785048
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,570
script_parsing.h
w1hkj_fldigi/src/config_script/script_parsing.h
//====================================================================== // script_parsing.h (FLDIGI) // // Author(s): // // Robert Stiles, KK5VD, Copyright (C) 2014 // // This 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; either version 3 of the License, or // (at your option) any later version. // // This software 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, see <http://www.gnu.org/licenses/>. // ===================================================================== #ifndef __script_parsing__ #define __script_parsing__ #include <string> #include <stdio.h> #ifdef __WIN32__ #define PATH_SEPERATOR "\\" #define PATH_CHAR_SEPERATOR '\\' #include <direct.h> #define get_current_dir _getcwd #else #define PATH_SEPERATOR "/" #define PATH_CHAR_SEPERATOR '/' #include <unistd.h> #define get_current_dir getcwd #endif #define MAX_CMD_PARAMETERS 5 #define MAX_COMMAND_LENGTH 128 #define MAX_PARAMETER_LENGTH FILENAME_MAX #define MAX_READLINE_LENGTH (FILENAME_MAX+FILENAME_MAX) #define MAX_SUB_SCRIPTS 5 #define SCRIPT_FILE_TAG ((char *)"FLDIGI_CONFIG") #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) #define RESET_ALL 0x01 #define RESET_PARTIAL 0X02 #undef __LOCALIZED_SCRIPT_COMMANDS #ifdef __LOCALIZED_SCRIPT_COMMANDS #pragma message ( \ "\n" \ "************************************************************************\n" \ "* Defining __LOCALIZED_SCRIPT_COMMANDS breaks script compatibility. In *\n" \ "* doing so, FLDIGI development team does not assume responsibility for *\n" \ "* maintaining the code sections that are altered/effected as a result. *\n" \ "************************************************************************\n" ) #define F_LOC(a) _(a) #else #define F_LOC(a) a #endif #define CMD_OPERATOR F_LOC("OPERATOR") #define CMD_CALLSIGN F_LOC("CALLSIGN") #define CMD_NAME F_LOC("NAME") #define CMD_QTH F_LOC("QTH") #define CMD_LOCATOR F_LOC("LOC") #define CMD_ANTENNA F_LOC("ANT") #define CMD_AUDIO_DEVICE F_LOC("AUDIO DEVICE") #define CMD_OSS_AUDIO F_LOC("OSS") #define CMD_OSS_AUDIO_DEV_PATH F_LOC("OSS DEV") #define CMD_PORT_AUDIO F_LOC("PA") #define CMD_PORTA_CAP F_LOC("PA CAPTURE") #define CMD_PORTA_PLAY F_LOC("PA PLAYBACK") #define CMD_PULSEA F_LOC("PUA") #define CMD_PULSEA_SERVER F_LOC("PUA SERVER") #define CMD_AUDIO_SETTINGS F_LOC("AUDIO SETTINGS") #define CMD_CAPTURE_SAMPLE_RATE F_LOC("CAPTURE") #define CMD_PLAYBACK_SAMPLE_RATE F_LOC("PLAYBACK") #define CMD_AUDIO_CONVERTER F_LOC("CONVERTER") #define CMD_RX_PPM F_LOC("RX PPM") #define CMD_TX_PPM F_LOC("TX PPM") #define CMD_TX_OFFSET F_LOC("TX OFFSET") #define CMD_AUDIO_RT_CHANNEL F_LOC("AUDIO RT CHANNEL") #define CMD_MONO_AUDIO F_LOC("MONO AUDIO") #define CMD_AUDIO_L_R F_LOC("MODEM LR") #define CMD_AUDIO_REV_L_R F_LOC("REV LR") #define CMD_PTT_RIGHT_CHAN F_LOC("PTT RT CHAN") #define CMD_CW_QSK_RT_CHAN F_LOC("QSK RT CHAN") #define CMD_PSEUDO_FSK_RT_CHAN F_LOC("FSK RT CHAN") #define CMD_AUDIO_WAVE F_LOC("AUDIO WAVE") #define CMD_WAVE_SR F_LOC("SRATE") #define CMD_HRDWR_PTT F_LOC("RIG HRDWR PTT") #define CMD_HPPT_PTT_RT F_LOC("PTT RT CHAN") #define CMD_HPTT_SP2 F_LOC("SERIAL PORT") #define CMD_HPTT_SP2_PATH F_LOC("DEVICE") #define CMD_HPTT_SP2_RTS F_LOC("RTS") #define CMD_HPTT_SP2_DTR F_LOC("DTR") #define CMD_HPTT_SP2_RTS_V F_LOC("RTSV") #define CMD_HPTT_SP2_DTR_V F_LOC("DTRV") #define CMD_HPTT_SP2_START_DELAY F_LOC("START PTT DELAY") #define CMD_HPTT_SP2_END_DELAY F_LOC("END PTT DELAY") #define CMD_HPTT_UHROUTER F_LOC("UHROUTER") #define CMD_HPTT_PARALLEL F_LOC("PARALLEL") #define CMD_HPTT_SP2_INITIALIZE F_LOC("INIT") #define CMD_CMEDIA_PTT F_LOC("CMEDIA PTT") #define CMD_USE_CMEDIA_PTT F_LOC("CMEDIA_PTT") #define CMD_CMEDIA_DEV F_LOC("CMEDIA_DEVICE") #define CMD_CMEDIA_GPIO_LINE F_LOC("CMEDIA_GPIO_LINE") #define CMD_RIGCAT F_LOC("RIGCAT") #define CMD_RIGCAT_STATE F_LOC("STATE") #define CMD_RIGCAT_DESC_FILE F_LOC("DESC FILE") #define CMD_RIGCAT_DEV_PATH F_LOC("DEV PATH") #define CMD_RIGCAT_RETRIES F_LOC("RETRIES") #define CMD_RIGCAT_RETRY_INTERVAL F_LOC("RETRY INT") #define CMD_RIGCAT_WRITE_DELAY F_LOC("WDELAY") #define CMD_RIGCAT_INTIAL_DELAY F_LOC("IDELAY") #define CMD_RIGCAT_BAUD_RATE F_LOC("BRATE") #define CMD_RIGCAT_STOP_BITS F_LOC("SBITS") #define CMD_RIGCAT_ECHO F_LOC("ECHO") #define CMD_RIGCAT_TOGGLE_RTS_PTT F_LOC("TOGGLE RTS PTT") #define CMD_RIGCAT_TOGGLE_DTR_PTT F_LOC("TOGGLE DTR PTT") #define CMD_RIGCAT_RESTORE F_LOC("RESTORE") #define CMD_RIGCAT_PTT_COMMAND F_LOC("PTT COMMAND") #define CMD_RIGCAT_RTS_12V F_LOC("RTS 12V") #define CMD_RIGCAT_DTR_12V F_LOC("DTR 12V") #define CMD_RIGCAT_HRDWR_FLOW F_LOC("HRDWR FC") #define CMD_RIGCAT_VSP F_LOC("VSP") #define CMD_RIGCAT_INITIALIZE F_LOC("INIT") #define CMD_HAMLIB F_LOC("HAMLIB") #define CMD_HAMLIB_STATE F_LOC("STATE") #define CMD_HAMLIB_RIG F_LOC("RIG") #define CMD_HAMLIB_DEV_PATH F_LOC("DEV PATH") #define CMD_HAMLIB_RETRIES F_LOC("RETRIES") #define CMD_HAMLIB_RETRY_INTERVAL F_LOC("RETRY INT") #define CMD_HAMLIB_WRITE_DELAY F_LOC("WDELAY") #define CMD_HAMLIB_POST_WRITE_DELAY F_LOC("PWDELAY") #define CMD_HAMLIB_BAUD_RATE F_LOC("BRATE") #define CMD_HAMLIB_STOP_BITS F_LOC("SBITS") #define CMD_HAMLIB_POLL_RATE F_LOC("POLL_RATE") #define CMD_HAMLIB_SIDE_BAND F_LOC("SBAND") #define CMD_HAMLIB_PTT_COMMAND F_LOC("PTT COMMAND") #define CMD_HAMLIB_DTR_12V F_LOC("DTR 12V") #define CMD_HAMLIB_RTS_12V F_LOC("RTS 12V") #define CMD_HAMLIB_HRDWR_FLOW F_LOC("HRDWR FC") #define CMD_HAMLIB_SFTWR_FLOW F_LOC("SFTWR FC") #define CMD_HAMLIB_ADV_CONFIG F_LOC("ADV CONF") #define CMD_HAMLIB_INITIALIZE F_LOC("INIT") #define CMD_RC_XMLRPC F_LOC("XMLRPC RC") #define CMD_RC_XMLRPC_STATE F_LOC("STATE") #define CMD_RC_XMLRPC_BW_DELAY F_LOC("BWDELAY") #define CMD_RC_XMLRPC_INITIALIZE F_LOC("INIT") #define CMD_FLDIGI F_LOC("FLDIGI") #define CMD_FLDIGI_FREQ F_LOC("FREQ") #define CMD_FLDIGI_MODE F_LOC("MODE") #define CMD_FLDIGI_WFHZ F_LOC("WFHZ") #define CMD_FLDIGI_RXID F_LOC("RXID") #define CMD_FLDIGI_TXID F_LOC("TXID") #define CMD_FLDIGI_SPOT F_LOC("SPOT") #define CMD_FLDIGI_REV F_LOC("REV") #define CMD_FLDIGI_LOCK F_LOC("LOCK") #define CMD_FLDIGI_AFC F_LOC("AFC") #define CMD_FLDIGI_SQL F_LOC("SQL") #define CMD_FLDIGI_KPSQL F_LOC("KPSQL") #define CMD_FLDIGI_KPSM F_LOC("KPSM") #define CMD_FLDIGI_MODEM F_LOC("MODEM") #define CMD_IO F_LOC("IO") #define CMD_IO_LOCK F_LOC("LOCK") #define CMD_IO_ACT_PORT F_LOC("PORT") #define CMD_IO_AX25_DECODE F_LOC("AX25D") #define CMD_IO_CSMA F_LOC("CSMA") #define CMD_IO_KISS F_LOC("KISS") #define CMD_IO_KISS_IPA F_LOC("IPA") #define CMD_IO_KISS_IOPN F_LOC("IOPN") #define CMD_IO_KISS_OPN F_LOC("OPN") #define CMD_IO_KISS_DP F_LOC("DP") #define CMD_IO_KISS_BUSY F_LOC("BUSY") #define CMD_IO_KISS_CONT F_LOC("CONT") #define CMD_IO_KISS_ATTEN F_LOC("ATTEN") #define CMD_IO_ARQ F_LOC("ARQ") #define CMD_IO_ARQ_IPA F_LOC("IPA") #define CMD_IO_ARQ_IOPN F_LOC("IOPN") #define CMD_IO_XMLRPC F_LOC("XMLRPC") #define CMD_IO_XMLRPC_IPA F_LOC("IPA") #define CMD_IO_XMLRPC_IOPN F_LOC("IOPN") #define CMD_NBEMS F_LOC("MISC NBEMS") #define CMD_NBEMS_STATE F_LOC("STATE") #define CMD_NBEMS_MSG F_LOC("OPEN MSG") #define CMD_NBEMS_FLMSG F_LOC("OPEN FLMSG") #define CMD_NBEMS_FLMSG_PATH F_LOC("PATH") #define CMD_NBEMS_BRWSR F_LOC("OPEN BRWSR") #define CMD_NBEMS_TIMEOUT F_LOC("TIMEOUT") #define CMD_ID F_LOC("ID") #define CMD_ID_RSID F_LOC("RSID") #define CMD_ID_RSID_NOTIFY F_LOC("NOTIFY") #define CMD_ID_RSID_SRCH_BP F_LOC("SRCH BP") #define CMD_ID_RSID_MARK_PREV F_LOC("MARK PREV") #define CMD_ID_RSID_DETECTOR F_LOC("DETECTOR") #define CMD_ID_RSID_ALRT_DIALOG F_LOC("ALRT DIALOG") #define CMD_ID_RSID_TX_FREQ_LOCK F_LOC("TX FREQ LOCK") #define CMD_ID_RSID_FREQ_CHANGE F_LOC("FREQ CHANGE") #define CMD_ID_RSID_ALLOW_ERRORS F_LOC("ALLOW ERRORS") #define CMD_ID_RSID_SQL_OPEN F_LOC("SQL OPEN") #define CMD_ID_RSID_PRETONE F_LOC("PRETONE") #define CMD_ID_RSID_END_XMT_ID F_LOC("END XMT ID") #define CMD_ID_VIDEO F_LOC("VIDEO") #define CMD_ID_VIDEO_TX_ID_MODE F_LOC("ID MODE") #define CMD_ID_VIDEO_TX_VIDEO_TXT F_LOC("VIDEO TXT") #define CMD_ID_VIDEO_TX_TXT_INP F_LOC("TEXT INPUT") #define CMD_ID_VIDEO_SMALL_FONT F_LOC("SMALL FONT") #define CMD_ID_VIDEO_500_HZ F_LOC("500HZ") #define CMD_ID_VIDEO_WIDTH_LIMIT F_LOC("WIDTH LIMIT") #define CMD_ID_VIDEO_CHAR_ROW F_LOC("CHAR ROW") #define CMD_ID_CW F_LOC("CW") #define CMD_ID_CW_TX_CALLSIGN F_LOC("TX CALL") #define CMD_ID_CW_SPEED F_LOC("SPEED") #define CMD_LOAD_MACRO F_LOC("MACRO") #define CMD_END_CMD F_LOC("END") // Parameters localized - no restrictions. #define PARM_ENABLE _("ENABLE") #define PARM_YES _("YES") #define PARM_DISABLE _("DISABLE") #define PARM_NO _("NO") #define PARM_KISS _("KISS") #define PARM_ARQ _("ARQ") #define SCRIPT_COMMAND 0x0001 #define SCRIPT_DOT_NOTATION_ONLY 0x0002 #define SCRIPT_STRUCTURED_ONLY 0x0004 #define RECURSIVE_LIMIT 3 #define MAX_DELETE_LIST_COUNT 100 //! @enum script_codes //! Error codes. //! @typedef SCRIPT_CODES //! @see script_codes typedef enum script_codes { script_recursive_limit_reached = -100, //!< Reached command recursive limit. script_command_not_found = -100, //!< Script command not found. script_unexpected_eof, //!< Unexspected end of file reached. script_file_read_error, //!< File read error script_errors_reported, //!< Script Errors found during parsing of file. script_file_not_found, //!< Script file not found. script_path_not_found, //!< Script directory path not found. script_device_path_not_found, //!< Script device path not found. script_non_script_file, //!< Opened file not a Script file. script_max_sub_script_reached, //!< Maximum open subscripts reached. script_subscript_exec_fail, //!< Subscript execution fail (internal). script_incorrectly_assigned_value, //!< Incorrect parameter type. script_invalid_parameter, //!< Parameter is not valid. script_parameter_error, //!< Script parameter invalid. script_function_parameter_error, //!< Function parameter error (internal, non script error). script_mismatched_quotes, //!< Opening or closing quotes missing prior to reaching end if line. script_command_seperator_missing, //!< Command missing ':' script_args_eol, //!< Reached end of args list sooner then expected script_param_check_eol, //!< Reached end of parameter check list sooner then expected script_paramter_exceeds_length, //!< Data length exceeds expectations script_memory_allocation_error, //!< Memory Allocation Error (Non-Script internal Error). script_general_error = -1, //!< General purpose error (undefined erros). script_no_errors, //!< No Errors script_char_match_not_found, //!< Search char not found (Warning) script_end_of_line_reached, //!< End of line reached (Warning) script_end_of_list_reached, //!< End of list reached (Info) script_list, //!< List command (Info) script_command_handled, //!< Command was procedded and handled (Info) } SCRIPT_CODES; //! @enum paramter_types //! Parameter type flags. Used to validate the informarion. //! @typedef PARAM_TYPES //! @see paramter_types typedef enum paramter_types { p_null = 0, p_void, p_bool, p_char, p_int, p_unsigned_int, p_long, p_unsigned_long, p_float, p_double, p_string, p_path, p_filename, p_dev_path, p_dev_name, p_list, p_list_end } PARAM_TYPES; class ScriptParsing; //! @struct script_cmds //! Vector table of script command string and executing function member. //! @typedef SCRIPT_COMMANDS //! @see script_cmds typedef struct script_cmds { char command[MAX_COMMAND_LENGTH]; //!< Command matching string. int flags; //!< General purpose flags size_t command_length; //!< Number of chacters in the command string. int argc; //!< Number of required prarmeters for the command char *args[MAX_CMD_PARAMETERS+1]; //!< String vector table of parameters enum paramter_types param_check[MAX_CMD_PARAMETERS+1]; //!< Flags to determine type of parameter. const char **valid_values; //!< A list of valid paramters. int valid_value_count; //!< The number of valid paramters. SCRIPT_CODES (ScriptParsing::*func)(struct script_cmds *); //!< The function (member) to execute on positive match int (*cb)(ScriptParsing *sp, struct script_cmds *sd); //!< Call back function for script command struct script_cmds * sub_commands; //!< List of sub commands size_t sub_command_count; //!< Number of table entires in the sub table. } SCRIPT_COMMANDS; //! @class script_parsing_class class ScriptParsing { public: private: pthread_mutex_t ac; //<! Thread safe data access int recursive_count; bool _script_error_detected; bool _restart_flag; FILE *fd; int line_number; // Storage for each parameter // Special processing data storage. std::string _macro_command; // Internal Class Variables. std::string _path; int _file_type; SCRIPT_COMMANDS *_script_commands; //!< Table of commands and vector functions @see script_cmds size_t _script_command_count; //!< Number of assigned positions in the table. ScriptParsing *_parent; //!< Calling ScriptParsing pointer. Primarly used for the reset command on the local 'this' pointer. // Keep track of what needs to be deleted on exit (deallocation). SCRIPT_COMMANDS * memory_delete_list[MAX_DELETE_LIST_COUNT]; int delete_list_count; // Number of entries in the table. char line_buffer[MAX_READLINE_LENGTH + 1]; //!< Line buffer for script read operations. char error_cmd_buffer[MAX_COMMAND_LENGTH]; char error_string[MAX_COMMAND_LENGTH]; char error_buffer[MAX_COMMAND_LENGTH + MAX_COMMAND_LENGTH + 1]; SCRIPT_COMMANDS *top_cache; public: // Aceess methods for special processing data std::string macro_command(void) { return _macro_command; } void macro_command(std::string str) { _macro_command.assign(str); } bool restart_flag(void) { return _restart_flag; } void restart_flag(bool value) { _restart_flag = value; } bool script_errors(void) { return _script_error_detected; } // Parsing/varification routine for each of the commands. SCRIPT_CODES check_parameters(struct script_cmds *); SCRIPT_CODES check_filename(char *filename); SCRIPT_CODES check_path(const char *); SCRIPT_CODES check_numbers(char *, paramter_types p); SCRIPT_CODES check_dev_path(const char *path); SCRIPT_CODES check_bool(const char *value, bool &flag); void to_uppercase(char *str, int limit); void to_uppercase(std::string &str); void trim(char *buffer, size_t size); std::string &trim(std::string &s); // Script handling code. inline SCRIPT_CODES test_on_off_state(bool &state, char *string, char *true_state); SCRIPT_COMMANDS * script_commands(void) { return _script_commands; } void script_commands(SCRIPT_COMMANDS *ptr) { if(ptr) _script_commands = ptr; } size_t script_command_count(void) { return _script_command_count; } void script_command_count(size_t value) { _script_command_count = value; } // Internal script fuctions SCRIPT_CODES parse_commands(char *file_name_path); //!< The calling function to parse a script file. SCRIPT_CODES read_file(FILE *fd, SCRIPT_COMMANDS *cur_list, size_t limit); ScriptParsing *parent(void) { return _parent; } void parent(ScriptParsing *value) { _parent = value; } int assign_callback(const char *scriptCommand, int (*cb)(ScriptParsing *sp, SCRIPT_COMMANDS *sc)); int assign_valid_parameters(const char *command, const char **array, const int array_count); void defaults(bool all); ScriptParsing(); ~ScriptParsing(); private: // Special processing member. SCRIPT_CODES sc_macros(struct script_cmds *cmd); // Internal class routines void add_to_delete_list(SCRIPT_COMMANDS *); SCRIPT_CODES sc_dummy(struct script_cmds *); SCRIPT_CODES remove_crlf_comments(char *data, char *limit, size_t &count); SCRIPT_CODES parse_single_command(FILE *fd, SCRIPT_COMMANDS *cur_list, size_t limit, char *data, size_t buffer_size); SCRIPT_CODES parse_hierarchy_command(char *data, size_t buffer_size); int copy_tables(struct script_cmds * subcmds, size_t count); std::string path(void) { return _path; } int file_type(void) { return _file_type; } void file_type(int value) { _file_type = value; } SCRIPT_COMMANDS * search_command(SCRIPT_COMMANDS * table, size_t limit, const char *command); SCRIPT_CODES copy_string_uppercase(char *buffer, char *cPtr, char *ePtr, size_t limit); SCRIPT_CODES parse_parameters(char *s, char *d, SCRIPT_COMMANDS *matching_command); int call_callback(SCRIPT_COMMANDS *cb_data); int check_parameters_from_list(SCRIPT_COMMANDS *sc); int CopyScriptParsingEnv(ScriptParsing *src); void clear_script_parameters(bool all); SCRIPT_CODES assign_member_func(char *cmd, SCRIPT_CODES (ScriptParsing::*func)(struct script_cmds *)); void initialize_function_members(void); int str_cnt(char * str, int count_limit); char * script_error_string(SCRIPT_CODES error_no, int ln, char *cmd); char * skip_alpha_numbers(char * data, char *limit, SCRIPT_CODES &error); char * skip_characters(char * data, char *limit, SCRIPT_CODES &error); char * skip_numbers(char * data, char *limit, SCRIPT_CODES &error); char * skip_spaces(char * data, char *limit, SCRIPT_CODES &error); char * skip_to_character(char c, char * data, char *limit, SCRIPT_CODES &error); char * skip_white_spaces(char * data, char *limit, SCRIPT_CODES &error); }; int callback_dummy(ScriptParsing *sp, struct script_cmds *sc); #endif /* defined(__script_parsing__) */
20,471
C++
.h
395
50.243038
131
0.626088
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,571
psm.h
w1hkj_fldigi/src/psm/psm.h
// ---------------------------------------------------------------------------- // psm/psm.h // // Support for Signal Montoring, CSMA, Transmit Inhibit (Busy Detection) // Effect all transmission types, Keybord, ARQ and KISS interface. // // Copyright (c) 2016 // Robert Stiles, KK5VD // // This file is part of fldigi. // // Fldigi 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, either version 3 of the License, or // (at your option) any later version. // // Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>. // ---------------------------------------------------------------------------- #ifndef __psm_h__ #define __psm_h__ enum { CSMA_PERSISTANCE = 0x01, CSMA_SLOT_TIME = 0x02, CSMA_TX_DELAY = 0x04, CSMA_ALL = (CSMA_PERSISTANCE|CSMA_SLOT_TIME|CSMA_TX_DELAY) }; enum { PSM_STOP = 1, PSM_ABORT }; extern bool psm_thread_running; extern void psm_reset_histogram(void); extern void psm_transmit(void); extern void psm_transmit_ended(int flag); extern void start_psm_thread(void); extern void stop_psm_thread(void); extern void signal_psm(void); extern void update_kpsql_fractional_gain(int value); extern void update_csma_io_config(int update_this); #endif /* __psm_h__ */
1,640
C++
.h
46
34.391304
79
0.670655
w1hkj/fldigi
109
27
38
GPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,582
fix_fluid_drag.cpp
xiaoh_sediFoam/interfaceToLammps/fix_fluid_drag.cpp
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #include "math.h" #include "stdlib.h" #include "string.h" #include "fix_fluid_drag.h" #include "atom.h" #include "update.h" #include "respa.h" #include "domain.h" #include "error.h" #include "memory.h" #include "force.h" using namespace LAMMPS_NS; using namespace FixConst; /* ---------------------------------------------------------------------- */ FixFluidDrag::FixFluidDrag(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { if (narg < 3) error->all(FLERR, "Illegal fix fdrag command"); // int myrank; // MPI_Comm_rank(MPI_COMM_WORLD, &myrank); // printf("++++=A> fluid_drag created! %5d\n", myrank); ffluiddrag = NULL; DuDt = NULL; foamCpuId = NULL; vOld = NULL; grow_arrays(atom->nmax); atom->add_callback(0); force_reneighbor = 0; // when adding particles, set this value to 1. if (narg == 3) { carrier_rho = 0; } else if (narg == 4) { carrier_rho = atoi(arg[3]); } } /* ---------------------------------------------------------------------- */ FixFluidDrag::~FixFluidDrag() { // unregister callbacks to this fix from Atom class atom->delete_callback(id,0); delete [] foamCpuId; delete [] vOld; delete [] DuDt; memory->destroy(ffluiddrag); } /* ---------------------------------------------------------------------- */ int FixFluidDrag::setmask() { int mask = 0; mask |= POST_FORCE; return mask; } /* ---------------------------------------------------------------------- */ void FixFluidDrag::init() { int nlocal = atom->nlocal; int *mask = atom->mask; for (int i = 0; i < nlocal; i++){ if (mask[i] & groupbit) { ffluiddrag[i][0] = 0.; ffluiddrag[i][1] = 0.; ffluiddrag[i][2] = 0.; DuDt[i][0] = 0.; DuDt[i][1] = 0.; DuDt[i][2] = 0.; foamCpuId[i] = 0; vOld[i][0] = 0.; vOld[i][1] = 0.; vOld[i][2] = 0.; } } } /* ---------------------------------------------------------------------- */ void FixFluidDrag::setup(int vflag) { if (strcmp(update->integrate_style,"verlet") == 0) post_force(vflag); } /* ---------------------------------------------------------------------- */ void FixFluidDrag::post_force(int vflag) { // apply drag force to atoms in group double **f = atom->f; int *mask = atom->mask; int nlocal = atom->nlocal; double timeStep = update->dt; double rho = 0.; double accX = 0.; double accY = 0.; double accZ = 0.; double **v = atom->v; // get the mass of particles double *rmass = atom->rmass; double *r = atom->radius; // printf("++++=A> deltaT is: %10f, Vx = %10f, Vy = %10f, Vz = %10f\n", timeStep, v[0][0], v[0][1], v[0][2]); // printf("++++=A> deltaT is: %10f, VxOld = %10f, VyOld = %10f, VzOld = %10f\n", timeStep, vOld[0][0], vOld[0][1], vOld[0][2]); // printf("++++=A> deltaT is: %10f, Ax = %10f, Ay = %10f, Az = %10f\n", timeStep, // ((v[0][0] - vOld[0][0])/timeStep), // ((v[0][1] - vOld[0][1])/timeStep), // ((v[0][2] - vOld[0][2])/timeStep)); // int myrank; // MPI_Comm_rank(MPI_COMM_WORLD, &myrank); // printf("++++=A> myrank = %5d, nlocal = %5d, nghost = %5d, // ndrag = %5d\n", myrank, nlocal, nghost, ndrag); for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { rho = 3.0*rmass[i]/(4.0*3.14159265358917323846*r[i]*r[i]*r[i]); accX = ((v[i][0] - vOld[i][0])/timeStep), accY = ((v[i][1] - vOld[i][1])/timeStep), accZ = ((v[i][2] - vOld[i][2])/timeStep), f[i][0] += ffluiddrag[i][0] + carrier_rho/rho*0.5*rmass[i]*(DuDt[i][0] - accX); f[i][1] += ffluiddrag[i][1] + carrier_rho/rho*0.5*rmass[i]*(DuDt[i][1] - accY); f[i][2] += ffluiddrag[i][2] + carrier_rho/rho*0.5*rmass[i]*(DuDt[i][2] - accZ); vOld[i][0] = v[i][0]; vOld[i][1] = v[i][1]; vOld[i][2] = v[i][2]; } } } /* ---------------------------------------------------------------------- memory usage of local atom-based array ------------------------------------------------------------------------- */ double FixFluidDrag::memory_usage() { double bytes = 3*atom->nmax * sizeof(double); bytes += atom->nmax * sizeof(int); return bytes; } /* ---------------------------------------------------------------------- allocate atom-based array ------------------------------------------------------------------------- */ void FixFluidDrag::grow_arrays(int nmax) { memory->grow(ffluiddrag,nmax,3,"fluid_drag:ffluiddrag"); memory->grow(DuDt,nmax,3,"fluid_drag:DuDt"); memory->grow(foamCpuId,nmax,"fluid_drag:foamCpuId"); memory->grow(vOld,nmax,3,"fluid_drag:vOld"); } /* ---------------------------------------------------------------------- copy values within local atom-based array ------------------------------------------------------------------------- */ void FixFluidDrag::copy_arrays(int i, int j, int delflag) { ffluiddrag[j][0] = ffluiddrag[i][0]; ffluiddrag[j][1] = ffluiddrag[i][1]; ffluiddrag[j][2] = ffluiddrag[i][2]; DuDt[j][0] = DuDt[i][0]; DuDt[j][1] = DuDt[i][1]; DuDt[j][2] = DuDt[i][2]; foamCpuId[j] = foamCpuId[i]; vOld[j][0] = vOld[i][0]; vOld[j][1] = vOld[i][1]; vOld[j][2] = vOld[i][2]; } /* ---------------------------------------------------------------------- pack values in local atom-based array for exchange with another proc ------------------------------------------------------------------------- */ int FixFluidDrag::pack_exchange(int i, double *buf) { buf[0] = ffluiddrag[i][0]; buf[1] = ffluiddrag[i][1]; buf[2] = ffluiddrag[i][2]; buf[3] = DuDt[i][0]; buf[4] = DuDt[i][1]; buf[5] = DuDt[i][2]; buf[6] = foamCpuId[i]; buf[7] = vOld[i][0]; buf[8] = vOld[i][1]; buf[9] = vOld[i][2]; return 10; } /* ---------------------------------------------------------------------- unpack values in local atom-based array from exchange with another proc ------------------------------------------------------------------------- */ int FixFluidDrag::unpack_exchange(int nlocal, double *buf) { ffluiddrag[nlocal][0] = buf[0]; ffluiddrag[nlocal][1] = buf[1]; ffluiddrag[nlocal][2] = buf[2]; DuDt[nlocal][0] = buf[3]; DuDt[nlocal][1] = buf[4]; DuDt[nlocal][2] = buf[5]; foamCpuId[nlocal] = buf[6]; vOld[nlocal][0] = buf[7]; vOld[nlocal][1] = buf[8]; vOld[nlocal][2] = buf[9]; return 10; }
7,009
C++
.cpp
201
31.462687
129
0.488472
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,583
library.cpp
xiaoh_sediFoam/interfaceToLammps/library.cpp
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ // C or Fortran style library interface to LAMMPS // new LAMMPS-specific functions can be added #include "mpi.h" #include "library.h" #include "lammps.h" #include "update.h" #include "input.h" #include "atom.h" #include "atom_vec.h" #include "fix_fluid_drag.h" // added JS #include "modify.h" #include "string.h" #include "stdio.h" #include "math.h" #include "math_const.h" #include "random_park.h" #include "memory.h" #include "group.h" #include "domain.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- create an instance of LAMMPS and return pointer to it pass in command-line args and MPI communicator to run on ------------------------------------------------------------------------- */ void lammps_open(int argc, char **argv, MPI_Comm communicator, void **ptr) { LAMMPS *lammps = new LAMMPS(argc,argv,communicator); *ptr = (void *) lammps; } /* ---------------------------------------------------------------------- destruct an instance of LAMMPS ------------------------------------------------------------------------- */ void lammps_close(void *ptr) { LAMMPS *lammps = (LAMMPS *) ptr; delete lammps; } /* ---------------------------------------------------------------------- process an input script in filename str ------------------------------------------------------------------------- */ void lammps_file(void *ptr, char *str) { LAMMPS *lammps = (LAMMPS *) ptr; lammps->input->file(str); } /* ---------------------------------------------------------------------- process a single input command in str ------------------------------------------------------------------------- */ char *lammps_command(void *ptr, char *str) { LAMMPS *lammps = (LAMMPS *) ptr; return lammps->input->one(str); } // This is for use with gdb debugging only; void lammps_sync(void *ptr) { LAMMPS *lammps = (LAMMPS *) ptr; int idb=0; while(idb); MPI_Barrier(lammps->world); } /* ---------------------------------------------------------------------- add LAMMPS-specific library functions all must receive LAMMPS pointer as argument ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ int lammps_get_global_n(void *ptr) { LAMMPS *lammps = (LAMMPS *) ptr; int natoms = static_cast<int> (lammps->atom->natoms); return natoms; } /* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ // Originaly designed to provide coordinate and velocity information to Foam // Not extened to provide particle diameter, density, and type as well. // The name will, however, not be updated. void lammps_get_initial_np(void* ptr, int* np_) { printf("start getting info.."); int myrank; int mysize; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); MPI_Comm_size(MPI_COMM_WORLD, &mysize); LAMMPS *lammps = (LAMMPS *) ptr; int natoms = static_cast<int> (lammps->atom->natoms); printf("creating array of the number of particle.."); int *copyNp = new int[mysize]; printf("initializing the number of particles in each processor"); for (int i = 0; i < mysize; i++) { copyNp[i] = 0; } int nlocal = lammps->atom->nlocal; copyNp[myrank] = nlocal; printf("calling MPI_Allreduce"); MPI_Allreduce(copyNp, np_, mysize, MPI_INT, MPI_SUM, lammps->world); delete [] copyNp; } /* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ // Originaly designed to provide coordinate and velocity information to Foam // Not extened to provide particle diameter, density, and type as well. // The name will, however, not be updated. void lammps_get_initial_info(void* ptr, double* coords, double* velos, double* diam, double* rho_, int* tag_, int* lmpCpuId_, int* type_) { printf("start getting info.."); int myrank; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); LAMMPS *lammps = (LAMMPS *) ptr; int natoms = static_cast<int> (lammps->atom->natoms); int nlocal = lammps->atom->nlocal; printf("initializing position and velocity"); for (int i = 0; i < 3*nlocal; i++) { coords[i] = 0.0; velos[i] = 0.0; } printf("initializing other values"); for (int i = 0; i < nlocal; i++) { diam[i] = 0.0; rho_[i] = 0.0; type_[i] = 0; tag_[i] = 0; lmpCpuId_[i] = 0; } printf("find the pointers"); //Info provided to Foam Cloud. double **x = lammps->atom->x; double **v = lammps->atom->v; double *r = lammps->atom->radius; // double *rho = lammps->atom->density; // commented by rui // lammps cannot access density but rmass; double *rho = lammps->atom->rmass; int *type = lammps->atom->type; // Other info used in this function int *tag = lammps->atom->tag; int id,offset; printf("start the loop!"); for (int i = 0; i < nlocal; i++) { offset = 3*i; // Get coordinates coords[offset+0] = x[i][0]; coords[offset+1] = x[i][1]; coords[offset+2] = x[i][2]; // Copy velocities velos[offset+0] = v[i][0]; velos[offset+1] = v[i][1]; velos[offset+2] = v[i][2]; // Copy diameters diam[i] = r[i] * 2.0; // Copy density // commented by rui // modify the density rho_[i] = 3.0*rho[i]/(4.0*3.14159265358917323846*r[i]*r[i]*r[i]); // Copy type type_[i] = type[i]; tag_[i] = tag[i]; lmpCpuId_[i] = myrank; } } /* ---------------------------------------------------------------------- */ // Provide particle number. int lammps_get_local_n(void* ptr) { LAMMPS *lammps = (LAMMPS *) ptr; int nlocal = lammps->atom->nlocal; return nlocal; } /* ---------------------------------------------------------------------- */ // Provide the local domain of each processor void lammps_get_local_domain(void* ptr, double* domain_) { int myrank; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); LAMMPS *lammps = (LAMMPS *) ptr; double *sublo = lammps->domain->sublo; double *subhi = lammps->domain->subhi; domain_[0] = sublo[0]; domain_[1] = subhi[0]; domain_[2] = sublo[1]; domain_[3] = subhi[1]; domain_[4] = sublo[2]; domain_[5] = subhi[2]; printf("++++=A> domain in processor %5d\n is: x0 %f, x1 %f, y0 %f; y1 %f z0 %f, z1 %f.", myrank, domain_[0], domain_[1], domain_[2], domain_[3], domain_[4], domain_[5]); } /* ---------------------------------------------------------------------- */ // Provide particle info (incl. coordinate, velocity etc.) to Foam // Note: No MPI communication occurs! Info is sent to the same processor. void lammps_get_local_info(void* ptr, double* coords_, double* velos_, int* foamCpuId_, int* lmpCpuId_, int* tag_) { int myrank; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); LAMMPS *lammps = (LAMMPS *) ptr; // the pointer to the fix_fluid_drag class class FixFluidDrag *drag_ptr = NULL; int i; for (i = 0; i < (lammps->modify->nfix); i++) if (strcmp(lammps->modify->fix[i]->style,"fdrag") == 0) break; if (i < lammps->modify->nfix) //initialize the pointer drag_ptr = (FixFluidDrag *) lammps->modify->fix[i]; // Coordinate, velocity etc. on Lammps *local* processor double **x = lammps->atom->x; double **v = lammps->atom->v; int *tag = lammps->atom->tag; int *type = lammps->atom->type; int nlocal = lammps->atom->nlocal; double *copyx = new double[3*nlocal]; double *copyv = new double[3*nlocal]; int *copyfoamCpuId = new int[nlocal]; int *copytag = new int[nlocal]; for (int i = 0; i < 3*nlocal; i++) { copyx[i] = 0.0; copyv[i] = 0.0; } for (int i = 0; i < nlocal; i++) { copyfoamCpuId[i] = 0; copytag[i] = 0; } for (int i = 0; i < nlocal; i++) { coords_[3*i+0] = x[i][0]; coords_[3*i+1] = x[i][1]; coords_[3*i+2] = x[i][2]; velos_[3*i+0] = v[i][0]; velos_[3*i+1] = v[i][1]; velos_[3*i+2] = v[i][2]; foamCpuId_[i] = drag_ptr->foamCpuId[i]; lmpCpuId_[i] = myrank; tag_[i] = tag[i]; } delete [] copyx; delete [] copyv; delete [] copyfoamCpuId; delete [] copytag; } /* ---------------------------------------------------------------------- */ // Provide particle info (incl. coordinate, velocity etc.) to Foam // Note: MPI communication occurs! void lammps_put_local_info(void* ptr, int nLocalIn, double* fdrag, double* DuDt, int* foamCpuIdIn, int* tagIn) { LAMMPS *lammps = (LAMMPS *) ptr; // the pointer to the fix_fluid_drag class class FixFluidDrag *drag_ptr = NULL; int i; for (i = 0; i < (lammps->modify->nfix); i++) if (strcmp(lammps->modify->fix[i]->style,"fdrag") == 0) break; int *tag = lammps->atom->tag; int *type = lammps->atom->type; int nlocal = lammps->atom->nlocal; if (i < lammps->modify->nfix) //initialize the pointer drag_ptr = (FixFluidDrag *) lammps->modify->fix[i]; if (nLocalIn != nlocal) { int myrank; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); printf("Incoming drag not consistent with local particle number.\n"); printf("Incoming drag is: %5d, local particle number is: %5d.", nLocalIn, nlocal); } //initialize the tag pair to sort std::vector<tagpair> lmptagpair (nlocal); std::vector<tagpair> intagpair (nlocal); for (int i = 0; i < nlocal; i++) { lmptagpair[i].tag = tag[i]; lmptagpair[i].index = i; intagpair[i].tag = tagIn[i]; intagpair[i].index = i; } std::sort(lmptagpair.begin(), lmptagpair.end(), by_number()); std::sort(intagpair.begin(), intagpair.end(), by_number()); for (int j = 0; j < nlocal; j++) { int fromfoamid = intagpair[j].index; int tolmpid = lmptagpair[j].index; drag_ptr->foamCpuId[tolmpid] = foamCpuIdIn[fromfoamid]; drag_ptr->ffluiddrag[tolmpid][0] = fdrag[3*fromfoamid+0]; drag_ptr->ffluiddrag[tolmpid][1] = fdrag[3*fromfoamid+1]; drag_ptr->ffluiddrag[tolmpid][2] = fdrag[3*fromfoamid+2]; } } /* ---------------------------------------------------------------------- */ // Evolve n steps forward without overhead void lammps_step(void *ptr, int n) { LAMMPS *lammps = (LAMMPS *) ptr; // lammps -> Run -> command(5, n, "pre", "no", "post", "no"); char cmd[50]; int nc; nc = sprintf(cmd, "run %d pre no post no", n); if(nc <= 0) { printf("lammps_step: Command print failure."); MPI_Abort(MPI_COMM_WORLD, 1); } lammps->input->one(cmd); } /* ---------------------------------------------------------------------- */ double lammps_get_timestep(void *ptr) { LAMMPS *lammps = (LAMMPS *) ptr; return lammps->update->dt; } /* ---------------------------------------------------------------------- */ void lammps_set_timestep(void *ptr, double dt_i) { LAMMPS *lammps = (LAMMPS *) ptr; lammps->update->dt = dt_i; } /* ---------------------------------------------------------------------- */ void lammps_create_particle(void* ptr, int npAdd, double* position, double* tag, double diameter, double rho, int type, double* vel) { int myrank; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); LAMMPS *lammps = (LAMMPS *) ptr; int natom = static_cast<int> (lammps->atom->natoms); double **x = lammps->atom->x; int ntype = type; double *xNew = new double[2]; tagint max = 0; tagint maxtag_all = 0; tagint *tagOld = lammps->atom->tag; for (int i = 0; i < lammps->atom->nlocal; i++) max = MAX(max,tagOld[i]); // MPI_Allreduce(&max,&maxtag_all,1,MPI_LMP_TAGINT,MPI_MAX,lammps->world); for (int m = 0; m < npAdd; m++) { xNew[0] = position[0+m*3]; xNew[1] = position[1+m*3]; xNew[2] = position[2+m*3]; lammps->atom->avec->create_atom(ntype,xNew); int nlocal = lammps->atom->nlocal; int n = lammps->atom->nlocal - 1; // lammps->atom->tag[n] = maxtag_all + 1; lammps->atom->tag[n] = tag[m]; // // Setting PBC? // for (int i = 0; i < nlocal; i++) { // double delx = xNew[0] - x[i][0]; // double dely = xNew[1] - x[i][1]; // double delz = xNew[2] - x[i][2]; // lammps->domain->minimum_image(delx,dely,delz); // } // TODO: may have problem here int igroup = lammps->group->find("active"); int groupbit = lammps->group->bitmask[igroup]; lammps->atom->mask[n] = 1 | groupbit; lammps->atom->image[n] = ((imageint) IMGMAX << IMG2BITS) | ((imageint) IMGMAX << IMGBITS) | IMGMAX; lammps->atom->v[n][0] = vel[0]; lammps->atom->v[n][1] = vel[1]; lammps->atom->v[n][2] = vel[2]; double radtmp = 0.5*diameter; lammps->atom->radius[n] = radtmp; lammps->atom->rmass[n] = 4.0*3.14159265358917323846/3.0 * radtmp*radtmp*radtmp * rho; for (int j = 0; j < lammps->modify->nfix; j++) { if (lammps->modify->fix[j]->create_attribute) { lammps->modify->fix[j]->set_arrays(n); } } } int nGlobal = 0; int nlocal = lammps->atom->nlocal; MPI_Allreduce(&nlocal,&nGlobal,1,MPI_INT,MPI_SUM,lammps->world); lammps->atom->natoms = nGlobal; if (lammps->atom->map_style) { lammps->atom->nghost = 0; lammps->atom->map_init(); lammps->atom->map_set(); } for (int j = 0; j < lammps->modify->nfix; j++) { bigint nt = lammps->update->ntimestep; lammps->modify->fix[j]->next_reneighbor = nt + 1; } delete [] xNew; } void lammps_delete_particle(void *ptr, int* deleteList, int nDelete) { int myrank; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); LAMMPS *lammps = (LAMMPS *) ptr; class RanPark *random = new RanPark(lammps,100); int i,j,m,iwhichglobal,iwhichlocal; int ndel,ndeltopo[4]; int *list,*mark; int del_flag = 0; // grow list and mark arrays if necessary int nmax = 0; if (lammps->atom->nlocal > nmax) { lammps->memory->destroy(list); lammps->memory->destroy(mark); nmax = lammps->atom->nmax; lammps->memory->create(list,nmax,"evaporate:list"); lammps->memory->create(mark,nmax,"evaporate:mark"); del_flag = 1; } // ncount = # of deletable atoms in region that I own // nall = # on all procs // nbefore = # on procs before me // list[ncount] = list of local indices of atoms I can delete double **x = lammps->atom->x; int *mask = lammps->atom->mask; tagint *tag = lammps->atom->tag; int nlocal = lammps->atom->nlocal; int ncount = 0; for (i = 0; i < nlocal; i++) { for (j = 0; j < nDelete; j++) { if (deleteList[j] == tag[i]) // delete the particle when assigned in openfoam { list[ncount++] = i; } } } int nall,nbefore; MPI_Allreduce(&ncount,&nall,1,MPI_INT,MPI_SUM,lammps->world); MPI_Scan(&ncount,&nbefore,1,MPI_INT,MPI_SUM,lammps->world); nbefore -= ncount; // ndel = total # of atom deletions, in or out of region // ndeltopo[1,2,3,4] = ditto for bonds, angles, dihedrals, impropers // mark[] = 1 if deleted ndel = 0; for (i = 0; i < nlocal; i++) mark[i] = 0; double flux = nDelete; double totalFlux = 0; MPI_Allreduce(&flux,&totalFlux,1,MPI_DOUBLE,MPI_SUM,lammps->world); totalFlux -= 0.5; while (nall && ndel < totalFlux) { iwhichglobal = static_cast<int> (nall*random->uniform()); if (iwhichglobal < nbefore) { nbefore--; } else if (iwhichglobal < nbefore + ncount) { iwhichlocal = iwhichglobal - nbefore; mark[list[iwhichlocal]] = 1; list[iwhichlocal] = list[ncount-1]; ncount--; } ndel++; nall--; } // atomic deletions // choose atoms randomly across all procs and mark them for deletion // shrink eligible list as my atoms get marked // keep ndel,ncount,nall,nbefore current after each atom deletion // delete my marked atoms // loop in reverse order to avoid copying marked atoms AtomVec *avec = lammps->atom->avec; for (i = nlocal-1; i >= 0; i--) { if (mark[i]) { avec->copy(lammps->atom->nlocal-1,i,1); lammps->atom->nlocal--; } } // reset global natoms and bonds, angles, etc // if global map exists, reset it now instead of waiting for comm // since deleting atoms messes up ghosts lammps->atom->natoms -= ndel; if (ndel && lammps->atom->map_style) { lammps->atom->nghost = 0; lammps->atom->map_init(); lammps->atom->map_set(); } // // statistics for (int j = 0; j < lammps->modify->nfix; j++) { bigint nt = lammps->update->ntimestep; lammps->modify->fix[j]->next_reneighbor = nt + 1; // lammps->modify->fix[j]->force_reneighbor = 1; } // ndeleted += ndel; // next_reneighbor = update->ntimestep + nevery; delete random; if (del_flag) { lammps->memory->destroy(list); lammps->memory->destroy(mark); } }
17,437
C++
.cpp
491
31.710794
91
0.569177
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,586
fix_cohesive.cpp
xiaoh_sediFoam/interfaceToLammps/fix_cohesive.cpp
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #include "string.h" #include "stdlib.h" #include "fix_cohesive.h" #include "atom.h" #include "update.h" #include "domain.h" #include "respa.h" #include "error.h" #include "force.h" #include "math.h" #include "neighbor.h" #include "neigh_list.h" #include "neigh_request.h" #include "mpi.h" #include "comm.h" #include "memory.h" using namespace LAMMPS_NS; using namespace FixConst; #define DELTA 10000; /* ---------------------------------------------------------------------- */ FixCohe::FixCohe(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { if (narg != 8) error->all(FLERR,"Illegal fix cohesive command"); ah = atof(arg[3]); lam = atof(arg[4]); smin = atof(arg[5]); smax = atof(arg[6]); opt = atoi(arg[7]); printf("ah lam smin opt %g %g %g %i \n", ah, lam, smin,opt); nmax = 0; nvalues = 7; // Number of output columns : PID FX FY FZ NX NY NZ laststep = -1; size_local_cols = nvalues; local_flag = 1; laststep_local = -1; // last time step for compute_local() // compute_local_flag = 1; // Calling compute_local flag } /* ---------------------------------------------------------------------- */ int FixCohe::setmask() { int mask = 0; mask |= POST_FORCE; mask |= POST_FORCE_RESPA; mask |= MIN_POST_FORCE; return mask; } /* ---------------------------------------------------------------------- */ void FixCohe::init() { int irequest = neighbor->request((void *) this); neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->fix = 1; if (strcmp(update->integrate_style,"respa") == 0) nlevels_respa = ((Respa *) update->integrate)->nlevels; } /* ---------------------------------------------------------------------- */ void FixCohe::init_list(int id, NeighList *ptr) { list = ptr; } /* ---------------------------------------------------------------------- */ void FixCohe::compute_local() { if(laststep_local == update->ntimestep) return; int npairs = count_pairs(0); //nmax = nconts if (npairs > nmax) reallocate(npairs); size_local_rows = npairs; size_local_cols = nvalues; if(npairs) calc_pairs(); laststep_local = update->ntimestep; } /* ---------------------------------------------------------------------- */ void FixCohe::setup() { if (strcmp(update->integrate_style,"verlet") == 0) post_force(1); else { ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); post_force_respa(1,nlevels_respa-1,0); ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); } } /* ---------------------------------------------------------------------- */ void FixCohe::min_setup() { post_force(1); } /* ---------------------------------------------------------------------- */ void FixCohe::post_force(int vflag) { int i,ii=0,j=0,jj=0,k,*numneigh,inum,**firstneigh; int jnum; double xtmp,ytmp,ztmp,delx,dely,delz; double radi,radj,radsum,rsq,r, rinv; double ccel,ccelx,ccely,ccelz; int *jlist,*ilist; double del; double **f = atom->f; double **x = atom->x; double *radius = atom->radius; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; int *mask = atom->mask; double PInv = 0.25/atan(1.0); inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; // loop over neighbors of my atoms if (opt == 0){ printf(" inum %i", inum); for (ii = 0; ii < nlocal; ii++){ i = ilist[ii]; if (!(mask[i] & groupbit)) continue; xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; jlist = firstneigh[i]; jnum = numneigh[i]; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; radj = radius[j]; radsum = radi + radj; if (rsq < (radsum + smax)*(radsum + smax)) { r = sqrt(rsq); del = r - radsum; if (del > lam*PInv) ccel = - ah*radsum*lam* (6.4988e-3 - 4.5316e-4*lam/del + 1.1326e-5*lam*lam/del/del)/del/del/del; else if (del > smin) ccel = - ah * (lam + 22.242*del)*radsum*lam/24.0/(lam + 11.121*del) /(lam + 11.121*del)/del/del; else ccel = - ah * (lam + 22.242*smin)*radsum*lam/24.0/(lam + 11.121*smin) /(lam + 11.121*smin)/smin/smin; rinv = 1/r; ccelx = delx*ccel*rinv ; ccely = dely*ccel*rinv ; ccelz = delz*ccel*rinv ; f[i][0] += ccelx; f[i][1] += ccely; f[i][2] += ccelz; if (newton_pair || j < nlocal) { f[j][0] -= ccelx; f[j][1] -= ccely; f[j][2] -= ccelz; } } } } }else if (opt ==1){ for (ii = 0; ii < nlocal; ii++){ i = ilist[ii]; if (!(mask[i] & groupbit)) continue; xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; jlist = firstneigh[i]; jnum = numneigh[i]; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; radj = radius[j]; radsum = radi + radj; if (rsq < (radsum + smax)*(radsum + smax)){ r = sqrt(rsq); del = r - radsum; if (del > smin) ccel = - ah*pow(radsum,6)/6.0/del/del/(r + radsum)/(r + radsum) /r/r/r; else ccel = - ah*pow(radsum,6)/6.0/smin/smin/(smin+ 2.0*radsum)/(smin + 2.0*radsum) /(smin + radsum)/(smin + radsum)/(smin + radsum); rinv = 1/r; ccelx = delx*ccel*rinv; ccely = dely*ccel*rinv; ccelz = delz*ccel*rinv; f[i][0] += ccelx; f[i][1] += ccely; f[i][2] += ccelz; if (newton_pair || j < nlocal){ f[j][0] -= ccelx; f[j][1] -= ccely; f[j][2] -= ccelz; } } } } }else error->all(FLERR,"invalid option for cohesive force model"); } /* ---------------------------------------------------------------------- */ void FixCohe::post_force_respa(int vflag, int ilevel, int iloop) { if (ilevel == nlevels_respa-1) post_force(vflag); } /* ---------------------------------------------------------------------- */ void FixCohe::min_post_force(int vflag) { post_force(vflag); } void FixCohe::extract_cohe(int *p_opt, double *p_ah, double *p_lam, double *p_smin,double *p_smax) { *p_opt = opt; *p_ah = ah; *p_lam = lam; *p_smin = smin; *p_smax = smax; } /*---------------------------------------------------------------------------------------------*/ /* Count the number of pairs of the contact first. */ int FixCohe::count_pairs(int flag) { int i,j,m,ii,jj,inum,jnum,itype; double xtmp,ytmp,ztmp,delx,dely,delz,radi,radsum; int *ilist,*jlist,*numneigh,**firstneigh; double rsq,factor_lj,factor_coul; double **x = atom->x; double *radius = atom->radius; int *type = atom->type; int *mask = atom->mask; int nlocal = atom->nlocal; int newton_pair = force->newton_pair; // double *special_coul = force->special_coul; // double *special_lj = force->special_lj; // Invoke half neighbor list (will copy or build if necessary) if (flag == 0) neighbor->build_one(list->index); inum = list->inum; ilist = list->ilist; numneigh = list->numneigh; firstneigh = list->firstneigh; // Loop over neighbours of my atoms // Skip if I or J are not in group // for flag = 0 just count the pair interactions within force cutoff // for flag = 1, calculate requested output fields. m = 0; for (ii = 0; ii<inum; ii++) {i = ilist[ii]; if(!(mask[i] & groupbit)) continue; xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; itype = type[i]; jlist = firstneigh[i]; jnum = numneigh[i]; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; // factor_lj = special_lj[sbmask(j)]; // factor_coul = special_coul[sbmask(j)]; j &= NEIGHMASK; if (!(mask[j] & groupbit)) continue; if (newton_pair == 0 && j >= nlocal) continue; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; radsum = radi + radius[j]; if( rsq < (radsum+smax)*(radsum+smax)) m++; } } m = 2*m ; // Counting each contact twice for outputting it as a single particle contact return m; } void FixCohe::calc_pairs() { int i,j=0,m,n,ii=0,jj=0,k,inum,*numneigh,**firstneigh; int jnum; double xtmp,ytmp,ztmp,delx,dely,delz,radi,radj,radsum; double facti,factj; double rsq,rinv,r,del; int *jlist, *ilist; double ccel,ccelx,ccely,ccelz; double **x = atom->x; double **v = atom->v; double f[3]; int *tag = atom->tag; double **omega = atom->omega; double torque[3]; double *radius = atom->radius; double *rmass = atom->rmass; int *mask = atom->mask; int nlocal = atom->nlocal; double PInv = 0.25/atan(1.0); inum = list->inum; ilist = list->ilist; numneigh=list->numneigh; firstneigh=list->firstneigh; n = 0; nmax = size_local_rows; if (opt == 0) { for ( ii = 0; ii < nlocal; i++) { i = ilist[ii]; xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; jlist = firstneigh[i]; jnum = numneigh[i]; for (jj = 0; jj < jnum; jj++) { j = jlist[jj]; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; radj = radius[j]; radsum = radi + radj; if (rsq < (radsum + smax)*(radsum + smax)) { f[0] = 0.0 ; f[1] = 0.0 ; f[2] = 0.0; r = sqrt(rsq); del = r - radsum; if (del > lam*PInv) ccel = - ah*radsum*lam*(6.4988e-3 - 4.5316e-4*lam/del + 1.1326e-5*lam*lam/del/del)/del/del/del; else if (del > smin) ccel = - ah * (lam + 22.242*del)*radsum*lam/24.0/(lam + 11.121*del)/(lam + 11.121*del)/del/del; else ccel = - ah * (lam + 22.242*smin)*radsum*lam/24.0/(lam + 11.121*smin)/(lam + 11.121*smin)/smin/smin; rinv = 1/r; ccelx = delx*ccel*rinv ; ccely = dely*ccel*rinv ; ccelz = delz*ccel*rinv ; f[0] += ccelx; f[1] += ccely; f[2] += ccelz; // facti = (radi + (del*0.5))/2 ; // factj = (radj + (del*0.5))/2 ; array_local[n][0] = tag[i]; array_local[n][1] = f[0]; array_local[n][2] = f[1]; array_local[n][3] = f[2]; array_local[n][4] = delx; array_local[n][5] = dely; array_local[n][6] = delz; n++; array_local[n][0] = tag[j]; array_local[n][1] = -f[0]; array_local[n][2] = -f[1]; array_local[n][3] = -f[2]; array_local[n][4] = -delx; array_local[n][5] = -dely; array_local[n][6] = -delz; n++; } } } } else if (opt ==1){ for (ii = 0; ii < nlocal; ii++){ i = ilist[ii]; if (!(mask[i] & groupbit)) continue; xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; radi = radius[i]; jlist = firstneigh[i]; jnum = numneigh[i]; for (jj = 0; jj < jnum ; jj++) { j = jlist[jj]; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; radj = radius[j]; radsum = radi + radj; if (rsq < (radsum + smax)*(radsum + smax)){ r = sqrt(rsq); del = r - radsum; f[0] = 0.0 ; f[1]= 0.0; f[2]= 0.0; if (del > smin) ccel = - ah*pow(radsum,6)/6.0/del/del/(r + radsum)/(r + radsum) /r/r/r; else ccel = - ah*pow(radsum,6)/6.0/smin/smin/(smin+ 2.0*radsum)/(smin + 2.0*radsum) /(smin + radsum)/(smin + radsum)/(smin + radsum); rinv = 1/r; ccelx = delx*ccel*rinv; ccely = dely*ccel*rinv; ccelz = delz*ccel*rinv; f[0] += ccelx; f[1] += ccely; f[2] += ccelz; array_local[n][0] = tag[i]; array_local[n][1] = f[0]; array_local[n][2] = f[1]; array_local[n][3] = f[2]; array_local[n][4] = delx; array_local[n][5] = dely; array_local[n][6] = delz; n++; array_local[n][0] = tag[j]; array_local[n][1] = -f[0]; array_local[n][2] = -f[1]; array_local[n][3] = -f[2]; array_local[n][4] = -delx; array_local[n][5] = -dely; array_local[n][6] = -delz; n++; } } } }else error->all(FLERR,"invalid compute option for this fix cohesion"); } /*-------------------------------------------------------------------------------------------*/ void FixCohe::reallocate(int n) { // grow vector or array and indices array while (nmax < n) nmax += DELTA ; memory->destroy(array_local); memory->create(array_local,nmax,nvalues,"Cohe:array"); size_local_rows = n; size_local_cols = nvalues; }
14,285
C++
.cpp
441
25.886621
113
0.499816
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,587
fix_fluid_drag.h
xiaoh_sediFoam/interfaceToLammps/fix_fluid_drag.h
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ // added by Rui Sun #ifdef FIX_CLASS FixStyle(fdrag,FixFluidDrag) #else #ifndef LMP_FIX_FLUID_DRAG_H #define LMP_FIX_FlUID_DRAG_H #include "fix.h" namespace LAMMPS_NS { class FixFluidDrag : public Fix { public: double **ffluiddrag; double **DuDt; double **vOld; int *foamCpuId; FixFluidDrag(class LAMMPS *, int, char **); ~FixFluidDrag(); int setmask(); void init(); void setup(int); virtual void post_force(int); double memory_usage(); void grow_arrays(int); void copy_arrays(int, int, int); int pack_exchange(int, double *); int unpack_exchange(int, double *); private: double carrier_rho; }; } #endif #endif
1,286
C++
.h
41
28.560976
76
0.659886
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,588
fix_cohesive.h
xiaoh_sediFoam/interfaceToLammps/fix_cohesive.h
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #ifdef FIX_CLASS FixStyle(cohesive,FixCohe) #else #ifndef LMP_FIX_COHESIVE_H #define LMP_FIX_COHESIVE_H #include "fix.h" namespace LAMMPS_NS { class FixCohe : public Fix { public: FixCohe(class LAMMPS *, int, char **); // ~FixCohe(); int setmask(); void init(); void init_list(int, class NeighList *); void setup(); void min_setup(); virtual void post_force(int); virtual void post_force_respa(int, int, int); virtual void min_post_force(int); void extract_cohe(int *, double *, double *, double *, double *); double smax; //maximum seperatioin for force cutoff void compute_local(); double ah; //Hammaker constant double lam; // London retardation wavelength double smin; //minimum separation private: int opt; //option for cohesive force model int nlevels_respa; int nmax, nvalues; int npairs; bigint laststep; bigint laststep_local; class NeighList *list; int count_pairs(int flag); // Count number of cohesive interactions for a particle void reallocate(int n); void calc_pairs(); }; } #endif #endif
1,705
C++
.h
50
31.14
86
0.678681
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,589
style_user.h
xiaoh_sediFoam/interfaceToLammps/style_user.h
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ // add a style class to LAMMPS by adding 2 lines to this file // add new include files in appropriate Include ifdef // add new style keywords and class names in appropriate Class ifdef // see style.h for examples #ifdef AngleInclude #endif #ifdef AngleClass #endif #ifdef AtomInclude #endif #ifdef AtomClass #endif #ifdef BondInclude #endif #ifdef BondClass #endif #ifdef CommandInclude #endif #ifdef CommandClass #endif #ifdef ComputeInclude #include "compute_gran_local.h" #include "compute_cohe_local.h" #endif #ifdef ComputeClass FixStyle(gran/local, ComputeGranLocal) FixStyle(cohe/local, ComputeCoheLocal) #endif #ifdef DihedralInclude #endif #ifdef DihedralClass #endif #ifdef DumpInclude #endif #ifdef DumpClass #endif #ifdef FixInclude #include "fix_fluid_drag.h" #include "fix_cohesive.h" #include "fix_wall_granFix.h" #endif #ifdef FixClass FixStyle(fdrag, FixFluidDrag) FixStyle(cohesive,FixCohe) FixStyle(wall/granFix,FixWallGranFix) #endif #ifdef ImproperInclude #endif #ifdef ImproperClass #endif #ifdef IntegrateInclude #endif #ifdef IntegrateClass # endif #ifdef KSpaceInclude #endif #ifdef KSpaceClass #endif #ifdef MinimizeInclude #endif #ifdef MinimizeClass #endif #ifdef PairInclude #include "pair_gran_hertzFix_history.h" #endif #ifdef PairClass PairStyle(gran/hertzFix/history,PairGranHertzFixHistory) #endif #ifdef RegionInclude #endif #ifdef RegionClass #endif
2,043
C++
.h
82
23.231707
76
0.76943
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,590
library.h
xiaoh_sediFoam/interfaceToLammps/library.h
/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ /* C or Fortran style library interface to LAMMPS new LAMMPS-specific functions can be added */ #include "mpi.h" #include "stdio.h" #include <vector> #include <algorithm> /* ifdef allow this file to be included in a C program */ #ifdef __cplusplus extern "C" { #endif void lammps_open(int, char **, MPI_Comm, void **); /* start-up LAMMPS */ void lammps_close(void *); /* shut-down LAMMPS */ void lammps_file(void *, char *); /* run input script */ char *lammps_command(void *, char *); /* execute a command */ void lammps_sync(void* ptr); int lammps_get_global_n(void *); /* return # of atoms */ /* get atom x&v&d & rho & type */ void lammps_get_initial_np(void* ptr, int* np_); void lammps_get_initial_info(void* ptr, double* coords, double* velos, double* diam, double* rho_, int* tag_, int* lmpCpuId_, int* type_); /* get atom number in each lmp cpu */ int lammps_get_local_n(void* ptr); /* get local domain in each lmp cpu */ void lammps_get_local_domain(void* ptr, double* domain_); /* get atom x&v&foamCpuId&lmpCpuId */ void lammps_get_local_info(void* ptr, double* coords, double* velos_, int* foamCpuId_, int* lmpCpuId_, int* tag_); /* set atom x&v&foamCpuId for all procs */ void lammps_put_local_info(void* ptr, int nLocalIn, double* fdrag, double* DuDt, int* foamCpuIdIn, int* tagIn); void lammps_step(void* ptr, int n); void lammps_set_timestep(void* ptr, double dt_i); double lammps_get_timestep(void* ptr); void lammps_create_particle(void* ptr, int npAdd, double* position, double* tag, double diameter, double rho, int type, double* vel); void lammps_delete_particle(void* ptr, int* deleteList, int nDelete); /* used in the sorting part when assigning data from OpenFOAM*/ struct tagpair { int tag; int index; }; struct by_number { bool operator() (tagpair const &left, tagpair const &right) { return left.tag < right.tag; } }; #ifdef __cplusplus } #endif
2,815
C++
.h
62
39.967742
83
0.615132
xiaoh/sediFoam
103
51
10
GPL-2.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,595
GridPawn.cpp
larsjsol_NavGrid/Source/Navgrid/Private/GridPawn.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" #if WITH_EDITORONLY_DATA #include "Editor.h" #endif // Sets default values AGridPawn::AGridPawn() : Super() { // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; SceneRoot = CreateDefaultSubobject<USceneComponent>("Root"); SetRootComponent(SceneRoot); BoundsCapsule = CreateDefaultSubobject<UCapsuleComponent>("Capsule"); BoundsCapsule->SetCollisionProfileName("Pawn"); BoundsCapsule->SetCollisionEnabled(ECollisionEnabled::QueryOnly); BoundsCapsule->ShapeColor = FColor::Magenta; BoundsCapsule->SetupAttachment(SceneRoot); MovementComponent = CreateDefaultSubobject<UGridMovementComponent>("MovementComponent"); MovementComponent->OnMovementEnd().AddUObject(this, &AGridPawn::OnMoveEnd); MovementComponent->SetUpdatedComponent(BoundsCapsule); TurnComponent = CreateDefaultSubobject<UTurnComponent>("TurnComponent"); MovementCollisionCapsule = CreateDefaultSubobject<UCapsuleComponent>("MovementCollisionCapsule"); MovementCollisionCapsule->SetupAttachment(SceneRoot); MovementCollisionCapsule->SetRelativeLocation(FVector(0, 0, 100)); MovementCollisionCapsule->SetCapsuleHalfHeight(50); MovementCollisionCapsule->SetCapsuleRadius(30); MovementCollisionCapsule->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); SelectedHighlight = CreateDefaultSubobject<UStaticMeshComponent>("SelectedHighlight"); SelectedHighlight->SetupAttachment(SceneRoot); UStaticMesh *Selected = ConstructorHelpers::FObjectFinder<UStaticMesh>( TEXT("StaticMesh'/NavGrid/SMesh/NavGrid_Cursor.NavGrid_Cursor'")).Object; SelectedHighlight->SetStaticMesh(Selected); SelectedHighlight->SetCollisionEnabled(ECollisionEnabled::NoCollision); SelectedHighlight->SetVisibility(false); Arrow = CreateDefaultSubobject<UArrowComponent>("Arrow"); Arrow->SetupAttachment(MovementCollisionCapsule); Arrow->SetCollisionEnabled(ECollisionEnabled::NoCollision); bHumanControlled = true; /* bind mouse events*/ OnClicked.AddDynamic(this, &AGridPawn::Clicked); #if WITH_EDITORONLY_DATA USelection::SelectObjectEvent.AddUObject(this, &AGridPawn::OnObjectSelectedInEditor); #endif // dont place tiles on top of pawns Tags.AddUnique(ANavGrid::DisableVirtualTilesTag); } void AGridPawn::BeginPlay() { Super::BeginPlay(); ATurnManager *TurnManager =TurnComponent->GetTurnManager(); if (IsValid(TurnManager)) { TurnManager->OnRoundStart().AddDynamic(this, &AGridPawn::OnRoundStart); TurnManager->OnTurnStart().AddDynamic(this, &AGridPawn::OnAnyTurnStart); TurnManager->OnTurnEnd().AddDynamic(this, &AGridPawn::OnAnyTurnEnd); TurnManager->OnTeamTurnStart().AddDynamic(this, &AGridPawn::OnAnyTeamTurnStart); TurnManager->OnTeamTurnEnd().AddDynamic(this, &AGridPawn::OnAnyTeamTurnEnd); TurnManager->OnReadyForInput().AddDynamic(this, &AGridPawn::OnAnyPawnReadyForInput); } SetGenericTeamId(TeamId); #if WITH_EDITORONLY_DATA GEditor->GetTimerManager()->ClearTimer(PreviewTimerHandle); #endif //WITH_EDITORONLY_DATA } void AGridPawn::OnConstruction(const FTransform & Transform) { Super::OnConstruction(Transform); #if WITH_EDITORONLY_DATA if (bPreviewTiles && IsSelectedInEditor()) { GEditor->GetTimerManager()->SetTimer(PreviewTimerHandle, this, &AGridPawn::UpdatePreviewTiles, 1, true); } else { GEditor->GetTimerManager()->ClearTimer(PreviewTimerHandle); } #endif //WITH_EDITORONLY_DATA } void AGridPawn::SetGenericTeamId(const FGenericTeamId & InTeamId) { // we must unregister before we change the team id TurnComponent->UnregisterWithTurnManager(); TeamId = InTeamId; TurnComponent->RegisterWithTurnManager(); } void AGridPawn::OnAnyTurnStart(UTurnComponent *InTurnComponent) { if (InTurnComponent == TurnComponent) { OnTurnStart(); } } void AGridPawn::OnTurnStart() { if (SnapToGrid) { MovementComponent->SnapToGrid(); } SelectedHighlight->SetVisibility(true); TurnComponent->OwnerReadyForInput(); if (!bHumanControlled) { PlayAITurn(); } } void AGridPawn::OnAnyTurnEnd(UTurnComponent *InTurnComponent) { if (InTurnComponent == TurnComponent) { OnTurnEnd(); } } void AGridPawn::OnTurnEnd() { SelectedHighlight->SetVisibility(false); MovementComponent->HidePath(); } void AGridPawn::OnAnyTeamTurnStart(const FGenericTeamId & InTeamId) { if (InTeamId == GetGenericTeamId()) { OnTeamTurnStart(); } } void AGridPawn::OnAnyTeamTurnEnd(const FGenericTeamId & InTeamId) { if (InTeamId == GetGenericTeamId()) { OnTeamTurnEnd(); } } void AGridPawn::OnMoveEnd() { //Moving costs one action point TurnComponent->RemainingActionPoints--; TurnComponent->EndTurn(); } void AGridPawn::OnAnyPawnReadyForInput(UTurnComponent * InTurnComponent) { if (InTurnComponent == TurnComponent) { OnPawnReadyForInput(); } } void AGridPawn::PlayAITurn() { //default implementation is simply to end turn TurnComponent->RemainingActionPoints = 0; TurnComponent->EndTurn(); } EGridPawnState AGridPawn::GetState() const { if (!TurnComponent->MyTurn()) { return EGridPawnState::WaitingForTurn; } else if (MovementComponent->Velocity.Size() > 0) { return EGridPawnState::Busy; } else { return EGridPawnState::Ready; } } /** Can this pawn start its turn right now? * 1) It must be the pawns teams turn * 2) It must be in the WaitingForTurn state * 3) The pawn currently in its turn must be idle * 4) It must not have used all its action points */ bool AGridPawn::CanBeSelected() { ANavGridGameState *GameState = Cast<ANavGridGameState>(GetWorld()->GetGameState()); if (IsValid(GameState)) { ATurnManager *TurnManager = GameState->GetTurnManager(); if (IsValid(TurnManager)) { // 1) It must be the pawns teams turn if (TurnManager->GetCurrentTeam() != TeamId) { return false; } // 2) It must be in the WaitingForTurn state if (GetState() != EGridPawnState::WaitingForTurn) { return false; } // 3) The pawn currently in its turn must be idle AGridPawn* CurrentPawn = Cast<AGridPawn>(TurnManager->GetCurrentComponent()->GetOwner()); if (!IsValid(CurrentPawn) || CurrentPawn->GetState() == EGridPawnState::Busy) { return false; } // 4) It must action points remaining return TurnComponent->RemainingActionPoints > 0; } } return false; } bool AGridPawn::CanMoveTo(const UNavTileComponent & Tile) { if (MovementComponent->GetTile() != &Tile && Tile.LegalPositionAtEndOfTurn(MovementComponent->AvailableMovementModes)) { TArray<UNavTileComponent *> InRange; MovementComponent->GetNavGrid()->GetTilesInRange(this, InRange); if (Tile.Distance <= MovementComponent->MovementRange) { return true; } } return false; } void AGridPawn::MoveTo(const UNavTileComponent & Tile) { MovementComponent->MoveTo(Tile); MovementComponent->HidePath(); } void AGridPawn::Clicked(AActor *ClickedActor, FKey PressedKey) { if (CanBeSelected()) { TurnComponent->RequestStartTurn(); } } #if WITH_EDITORONLY_DATA void AGridPawn::OnObjectSelectedInEditor(UObject * SelectedObject) { AGridPawn *SelectedPawn = Cast<AGridPawn>(SelectedObject); if (SelectedPawn && SelectedPawn->bPreviewTiles) { if (SelectedPawn == this) { GEditor->GetTimerManager()->SetTimer(PreviewTimerHandle, this, &AGridPawn::UpdatePreviewTiles, 1, true); } else { GEditor->GetTimerManager()->ClearTimer(PreviewTimerHandle); } } } void AGridPawn::UpdatePreviewTiles() { // check if a previewgrid already exist if (!IsValid(PreviewGrid)) { for (TActorIterator<ANavGrid> Itr(GetWorld()); Itr; ++Itr) { if (Itr->Tags.Contains(FName("PreviewGrid"))) { PreviewGrid = *Itr; break; } } } // create a preview grid if no grid already exists in the level if (!IsValid(PreviewGrid)) { FActorSpawnParameters SpawnParams; SpawnParams.bAllowDuringConstructionScript = true; SpawnParams.bTemporaryEditorActor = true; SpawnParams.Name = FName(*FString::Printf(TEXT("PreviewNavGrid_%s"), *GetName())); PreviewGrid = GetWorld()->SpawnActor<ANavGrid>(SpawnParams); PreviewGrid->TileSize = PreviewTileSize; PreviewGrid->Tags.Add(FName("PreviewGrid")); TArray<UNavTileComponent *> Tiles; ANavGrid::GetEveryTile(Tiles, GetWorld()); for (UNavTileComponent *Tile : Tiles) { Tile->SetGrid(PreviewGrid); } } TArray<UNavTileComponent *> Tiles; PreviewGrid->GetTilesInRange(this, Tiles); for (UNavTileComponent *Tile : Tiles) { Tile->SetHighlight("Movable"); } } #endif //WITH_EDITORONLY_DATA
8,932
C++
.cpp
283
28.137809
115
0.758081
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,596
GridMovementComponent.cpp
larsjsol_NavGrid/Source/Navgrid/Private/GridMovementComponent.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" #include "Components/SplineComponent.h" #include "Components/SplineMeshComponent.h" #include "Animation/AnimInstance.h" FPathSegment::FPathSegment(TSet<EGridMovementMode> InMovementModes, float InStart, float InEnd) { MovementModes = InMovementModes; Start = InStart; End = InEnd; } UGridMovementComponent::UGridMovementComponent(const FObjectInitializer &ObjectInitializer) :Super(ObjectInitializer) { PathMesh = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/NavGrid/SMesh/NavGrid_Path.NavGrid_Path'")).Object; AvailableMovementModes.Add(EGridMovementMode::ClimbingDown); AvailableMovementModes.Add(EGridMovementMode::ClimbingUp); AvailableMovementModes.Add(EGridMovementMode::Stationary); AvailableMovementModes.Add(EGridMovementMode::Walking); AvailableMovementModes.Add(EGridMovementMode::InPlaceTurn); Distance = 0; MovementMode = EGridMovementMode::Stationary; } void UGridMovementComponent::BeginPlay() { Super::BeginPlay(); /* I dont know why, but if we use createdefaultsubobject in the constructor this is sometimes reset to NULL*/ if (!IsValid(Spline)) { Spline = NewObject<USplineComponent>(this, "PathSpline"); check(Spline); } Spline->ClearSplinePoints(); ANavGrid* Grid = GetNavGrid(); if (!Grid) { UE_LOG(NavGrid, Error, TEXT("%s was unable to find a NavGrid in level"), *this->GetName()); } /* Grab a reference to the first AnimInstace we find */ TArray<USkeletalMeshComponent*> SkeletalMeshComponents; GetOwner()->GetComponents(SkeletalMeshComponents); for (USkeletalMeshComponent* Comp : SkeletalMeshComponents) { MeshRotation = Comp->GetRelativeTransform().Rotator(); AnimInstance = Comp->GetAnimInstance(); if (AnimInstance) { break; } } if (!AnimInstance && (bUseRootMotion || bAlwaysUseRootMotion)) { UE_LOG(NavGrid, Error, TEXT("%s: Unable to get reference to AnimInstance. Root motion extraction disabled"), *GetName()); bUseRootMotion = false; bAlwaysUseRootMotion = false; } } void UGridMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // if we are moving, find the current path segment if (MovementMode == EGridMovementMode::Walking || MovementMode == EGridMovementMode::ClimbingDown || MovementMode == EGridMovementMode::ClimbingUp) { CurrentPathSegment = FPathSegment({ EGridMovementMode::Walking }, 0, Spline->GetSplineLength()); for (FPathSegment &Segment : PathSegments) { if (Distance >= Segment.Start && Distance <= Segment.End) { CurrentPathSegment = Segment; break; } } } AActor *Owner = GetOwner(); FTransform NewTransform = Owner->GetActorTransform(); FRotator ActorRotation = Owner->GetActorRotation(); ConsiderUpdateMovementMode(); switch (MovementMode) { default: case EGridMovementMode::Stationary: if (bAlwaysUseRootMotion) { FTransform RootMotion = ConsumeRootMotion(); NewTransform.SetRotation(NewTransform.GetRotation() * RootMotion.GetRotation()); FRotator AnimToWorld = Owner->GetActorRotation() + MeshRotation; NewTransform.SetLocation(NewTransform.GetLocation() + AnimToWorld.RotateVector(RootMotion.GetLocation())); } break; //nothing to do case EGridMovementMode::InPlaceTurn: NewTransform = TransformFromRotation(DeltaTime); break; case EGridMovementMode::Walking: case EGridMovementMode::ClimbingDown: case EGridMovementMode::ClimbingUp: NewTransform = TransformFromPath(DeltaTime); ConsiderUpdateCurrentTile(); break; } /* reset rotation if we have any rotation locks */ FRotator NewRotation = ApplyRotationLocks(NewTransform.GetRotation().Rotator()); NewTransform.SetRotation(NewRotation.Quaternion()); /* never change the scale */ NewTransform.SetScale3D(Owner->GetActorScale3D()); // update velocity so it can be fetched by the pawn Velocity = (NewTransform.GetLocation() - Owner->GetActorLocation()) * (1 / DeltaTime); UpdateComponentVelocity(); // actually move the the actor Owner->SetActorTransform(NewTransform); } void UGridMovementComponent::StopMovementImmediately() { FinishMovement(); } FTransform UGridMovementComponent::TransformFromPath(float DeltaTime) { /* Check if we can get the speed from root motion */ float CurrentSpeed = 0; if (bUseRootMotion) { FTransform RootMotion = ConsumeRootMotion(); CurrentSpeed = RootMotion.GetLocation().Size(); } if (CurrentSpeed < 25 * DeltaTime) { if (MovementMode == EGridMovementMode::ClimbingDown || MovementMode == EGridMovementMode::ClimbingUp) { CurrentSpeed = MaxClimbSpeed * DeltaTime; } else { CurrentSpeed = MaxWalkSpeed * DeltaTime; } } Distance = FMath::Min(Spline->GetSplineLength(), Distance + CurrentSpeed); /* Grab our current transform so we can find the velocity if we need it later */ AActor *Owner = GetOwner(); FTransform OldTransform = Owner->GetTransform(); /* Find the next location and rotation from the spline*/ FTransform NewTransform = Spline->GetTransformAtDistanceAlongSpline(Distance, ESplineCoordinateSpace::Local); FRotator DesiredRotation; /* Restrain rotation axis if we're walking */ if (MovementMode == EGridMovementMode::Walking) { DesiredRotation = NewTransform.Rotator(); } /* Use the rotation from the ladder if we're climbing */ else if (MovementMode == EGridMovementMode::ClimbingUp || MovementMode == EGridMovementMode::ClimbingDown) { DesiredRotation = CurrentPathSegment.PawnRotationHint; } /* Find the new rotation by limiting DesiredRotation by MaxRotationSpeed */ FRotator NewRotation = LimitRotation(OldTransform.GetRotation().Rotator(), DesiredRotation, DeltaTime); NewTransform.SetRotation(NewRotation.Quaternion()); // check if we are done if (Distance >= Spline->GetSplineLength()) { FinishMovement(); } return NewTransform; } FTransform UGridMovementComponent::TransformFromRotation(float DeltaTime) { AActor *Owner = GetOwner(); FTransform NewTransform = Owner->GetActorTransform(); if (Owner->GetActorRotation().Equals(DesiredForwardRotation)) { Owner->SetActorRotation(DesiredForwardRotation); ChangeMovementMode(EGridMovementMode::Stationary); } else { FRotator NewRotation = LimitRotation(Owner->GetActorRotation(), DesiredForwardRotation, DeltaTime); NewTransform.SetRotation(NewRotation.Quaternion()); } return NewTransform; } void UGridMovementComponent::ConsiderUpdateCurrentTile() { // try to grab the tile we're on and store it in CurrentTile. Take care to not overwrite a pointer to an // actual tile with NULL as that would mean we have moved off the grid ANavGrid* Grid = GetNavGrid(); if (IsValid(Grid)) { UNavTileComponent *Tile = Grid->GetTile(GetOwner()->GetActorLocation(), true); if (!Tile && (AvailableMovementModes.Contains(EGridMovementMode::ClimbingDown) || AvailableMovementModes.Contains(EGridMovementMode::ClimbingUp))) { Tile = Grid->GetTile(GetOwner()->GetActorLocation(), false); } if (IsValid(Tile) && Tile != CurrentTile) { CurrentTile = Tile; ANavGridGameState *GameState = Cast<ANavGridGameState>(UGameplayStatics::GetGameState(GetOwner())); if (IsValid(GameState)) { AGridPawn *GridPawn = Cast<AGridPawn>(GetOwner()); GameState->OnPawnEnterTile().Broadcast(GridPawn, CurrentTile); } } } } void UGridMovementComponent::GetTilesInRange(TArray<UNavTileComponent *> &OutTiles) { ANavGrid *Grid = GetNavGrid(); if (IsValid(Grid)) { ConsiderUpdateCurrentTile(); Grid->GetTilesInRange(Cast<AGridPawn>(GetOwner()), OutTiles); } } UNavTileComponent *UGridMovementComponent::GetTile() { if (!IsValid(CurrentTile)) { ConsiderUpdateCurrentTile(); } return CurrentTile; } ANavGrid * UGridMovementComponent::GetNavGrid() { if (!IsValid(CachedNavGrid)) { CachedNavGrid = ANavGrid::GetNavGrid(GetOwner()); } return CachedNavGrid; } void UGridMovementComponent::StringPull(TArray<const UNavTileComponent*>& InPath, TArray<const UNavTileComponent*>& OutPath) { QUICK_SCOPE_CYCLE_COUNTER(STAT_UGridMovementComponent_StringPull); if (InPath.Num() > 2) { AGridPawn *GridPawnOwner = Cast<AGridPawn>(GetOwner()); OutPath.Empty(); const UCapsuleComponent &Capsule = *GridPawnOwner->MovementCollisionCapsule; int32 CurrentIdx = 0; OutPath.Add(InPath[0]); for (int32 Idx = 1; Idx < InPath.Num() - 1; Idx++) { // keep points needed to get around chasms and obstacles FVector Delta = InPath[Idx]->GetPawnLocation() - InPath[CurrentIdx]->GetPawnLocation(); if (FMath::Abs(Delta.Z) > Capsule.GetRelativeLocation().Z - Capsule.GetScaledCapsuleHalfHeight() || InPath[Idx]->Obstructed(InPath[CurrentIdx]->GetPawnLocation(), Capsule)) { OutPath.AddUnique(InPath[Idx - 1]); CurrentIdx = Idx - 1; } // dont stringpull ladders else if (Cast<const UNavLadderComponent>(InPath[Idx])) { OutPath.AddUnique(InPath[Idx - 1]); OutPath.AddUnique(InPath[Idx]); if (Idx + 1 < InPath.Num()) { OutPath.AddUnique(InPath[Idx + 1]); } CurrentIdx = Idx + 1; Idx = Idx + 1; } } OutPath.AddUnique(InPath[InPath.Num() - 2]); OutPath.AddUnique(InPath[InPath.Num() - 1]); } else { OutPath = InPath; } } bool UGridMovementComponent::CreatePath(const UNavTileComponent &Target) { QUICK_SCOPE_CYCLE_COUNTER(STAT_UGridMovementComponent_CreatePath); AGridPawn *Owner = Cast<AGridPawn>(GetOwner()); if (!IsValid(CurrentTile)) { UE_LOG(NavGrid, Error, TEXT("%s: Not on grid"), *Owner->GetName()); return false; } ANavGrid* Grid = GetNavGrid(); TArray<UNavTileComponent *> InRange; Grid->GetTilesInRange(Cast<AGridPawn>(GetOwner()), InRange); if (InRange.Contains(&Target)) { // create a list of tiles from the destination to the starting point and reverse it TArray<const UNavTileComponent *> Path; const UNavTileComponent *Current = &Target; while (Current) { Path.Add(Current); Current = Current->Backpointer; } if (bStringPullPath) { TArray<const UNavTileComponent *> StringPulledPath; StringPull(Path, StringPulledPath); Path = StringPulledPath; } Algo::Reverse(Path); // Build the path spline and path segments Spline->ClearSplinePoints(); PathSegments.Empty(); if (Path.Num() > 1) { FVector ActorLocation = GetOwner()->GetActorLocation(); // use the actor location inststead of the tile location for the first spline point Spline->AddSplinePoint(ActorLocation, ESplineCoordinateSpace::Local); Spline->SetSplinePointType(0, ESplinePointType::Linear, false); for (int32 Idx = 1; Idx < Path.Num(); Idx++) { if (Grid->GetTile(ActorLocation) != Path[Idx] && CurrentTile != Path[Idx]) { Path[Idx]->AddPathSegments(*Spline, PathSegments, Idx == Path.Num() - 1); } } return true; // success! } } return false; // no path to TargetTile } bool UGridMovementComponent::MoveTo(const UNavTileComponent &Target) { bool PathExists = CreatePath(Target); if (PathExists) { ChangeMovementMode(EGridMovementMode::Walking); } return PathExists; } void UGridMovementComponent::TurnTo(const FRotator & Forward) { if (AvailableMovementModes.Contains(EGridMovementMode::InPlaceTurn)) { DesiredForwardRotation = Forward; ChangeMovementMode(EGridMovementMode::InPlaceTurn); } } void UGridMovementComponent::SnapToGrid() { AGridPawn *GridPawnOwner = Cast<AGridPawn>(GetOwner()); check(GridPawnOwner); ConsiderUpdateCurrentTile(); // move owner to the tile's pawn location if (IsValid(CurrentTile)) { GridPawnOwner->SetActorLocation(CurrentTile->GetPawnLocation()); } } void UGridMovementComponent::AdvanceAlongPath(float InDistance) { if (Spline->GetNumberOfSplinePoints() > 0) { Distance = FMath::Min(Spline->GetSplineLength(), Distance + InDistance); FTransform NewTransform = Spline->GetTransformAtDistanceAlongSpline(Distance, ESplineCoordinateSpace::Local); FRotator DesiredRotation; /* Restrain rotation axis if we're walking */ if (MovementMode == EGridMovementMode::Walking) { DesiredRotation = NewTransform.Rotator(); } /* Use the rotation from the ladder if we're climbing */ else if (MovementMode == EGridMovementMode::ClimbingUp || MovementMode == EGridMovementMode::ClimbingDown) { DesiredRotation = CurrentPathSegment.PawnRotationHint; } DesiredRotation = ApplyRotationLocks(DesiredRotation); NewTransform.SetRotation(DesiredForwardRotation.Quaternion()); /* never change the scale */ NewTransform.SetScale3D(GetOwner()->GetActorScale3D()); GetOwner()->SetActorTransform(NewTransform); ConsiderUpdateCurrentTile(); } } float UGridMovementComponent::GetRemainingDistance() { return FMath::Max(Spline->GetSplineLength() - Distance, 0.0f); } FRotator UGridMovementComponent::ApplyRotationLocks(const FRotator & InRotation) { FRotator OwnerRot = GetOwner()->GetActorRotation(); FRotator Ret; Ret.Pitch = LockPitch ? OwnerRot.Pitch : InRotation.Pitch; Ret.Roll = LockRoll ? OwnerRot.Roll : InRotation.Roll; Ret.Yaw = LockYaw ? OwnerRot.Yaw : InRotation.Yaw; return Ret; } void UGridMovementComponent::ShowPath() { if (PathMesh) { float PathDistance = HorizontalOffset; // Get some distance between the actor and the path FBoxSphereBounds Bounds = PathMesh->GetBounds(); float MeshLength = FMath::Abs(Bounds.BoxExtent.X) * 2; float SplineLength = Spline->GetSplineLength(); SplineLength -= HorizontalOffset; // Get some distance between the cursor and the path while (PathDistance < SplineLength) { AddSplineMesh(PathDistance, FMath::Min(PathDistance + MeshLength, SplineLength)); PathDistance += FMath::Min(MeshLength, SplineLength - PathDistance); } } } void UGridMovementComponent::HidePath() { for (USplineMeshComponent *SMesh : SplineMeshes) { SMesh->DestroyComponent(); } SplineMeshes.Empty(); } FTransform UGridMovementComponent::ConsumeRootMotion() { if (!AnimInstance) { return FTransform(); } FRootMotionMovementParams RootMotionParams = AnimInstance->ConsumeExtractedRootMotion(1); return RootMotionParams.GetRootMotionTransform(); } void UGridMovementComponent::ConsiderUpdateMovementMode() { // only consider changing mode when we are moving if (MovementMode == EGridMovementMode::Walking || MovementMode == EGridMovementMode::ClimbingDown || MovementMode == EGridMovementMode::ClimbingUp) { // if the maching segment is not walkable, transtion to the a climbing mode if (!CurrentPathSegment.MovementModes.Contains(EGridMovementMode::Walking)) { // try to get the tile the pawn will occupy when it moves a bit further FVector ForwardPoint = GetForwardLocation(50); FVector ActorLocation = GetOwner()->GetActorLocation(); if (ForwardPoint.Z > ActorLocation.Z) { ChangeMovementMode(EGridMovementMode::ClimbingUp); } else { ChangeMovementMode(EGridMovementMode::ClimbingDown); } } // default movement mode is walking else { ChangeMovementMode(EGridMovementMode::Walking); } } } void UGridMovementComponent::ChangeMovementMode(EGridMovementMode NewMode) { if (NewMode != MovementMode) { OnMovementModeChangedEvent.Broadcast(MovementMode, NewMode); MovementMode = NewMode; } } void UGridMovementComponent::FinishMovement() { Distance = 0; if (IsValid(Spline)) { Spline->ClearSplinePoints(); } ChangeMovementMode(EGridMovementMode::Stationary); OnMovementEndEvent.Broadcast(); } FVector UGridMovementComponent::GetForwardLocation(float ForwardDistance) { float D = FMath::Min(Spline->GetSplineLength(), Distance + ForwardDistance); return Spline->GetLocationAtDistanceAlongSpline(D, ESplineCoordinateSpace::Local); } void UGridMovementComponent::AddSplineMesh(float From, float To) { ANavGrid* Grid = GetNavGrid(); float TanScale = 25; FVector StartPos = Spline->GetLocationAtDistanceAlongSpline(From, ESplineCoordinateSpace::Local); StartPos.Z += Grid->UIOffset; FVector StartTan = Spline->GetDirectionAtDistanceAlongSpline(From, ESplineCoordinateSpace::Local) * TanScale; FVector EndPos = Spline->GetLocationAtDistanceAlongSpline(To, ESplineCoordinateSpace::Local); EndPos.Z += Grid->UIOffset; FVector EndTan = Spline->GetDirectionAtDistanceAlongSpline(To, ESplineCoordinateSpace::Local) * TanScale; FVector UpVector = EndPos - StartPos; UpVector = FVector(UpVector.Y, UpVector.Z, UpVector.X); UPROPERTY() USplineMeshComponent *SplineMesh = NewObject<USplineMeshComponent>(this); SplineMesh->SetMobility(EComponentMobility::Movable); SplineMesh->SetStartAndEnd(StartPos, StartTan, EndPos, EndTan); SplineMesh->SetStaticMesh(PathMesh); SplineMesh->RegisterComponentWithWorld(GetWorld()); SplineMesh->SetSplineUpDir(UpVector); SplineMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision); SplineMeshes.Add(SplineMesh); } FRotator UGridMovementComponent::LimitRotation(const FRotator &OldRotation, const FRotator &NewRotation, float DeltaTime) { FRotator Result = OldRotation.GetNormalized(); FRotator DeltaRotation = NewRotation - OldRotation; DeltaRotation.Normalize(); Result.Pitch += DeltaRotation.Pitch > 0 ? FMath::Min<float>(DeltaRotation.Pitch, MaxRotationSpeed * DeltaTime) : FMath::Max<float>(DeltaRotation.Pitch, MaxRotationSpeed * -DeltaTime); Result.Roll += DeltaRotation.Roll > 0 ? FMath::Min<float>(DeltaRotation.Roll, MaxRotationSpeed * DeltaTime) : FMath::Max<float>(DeltaRotation.Roll, MaxRotationSpeed * -DeltaTime); Result.Yaw += DeltaRotation.Yaw > 0 ? FMath::Min<float>(DeltaRotation.Yaw, MaxRotationSpeed * DeltaTime) : FMath::Max<float>(DeltaRotation.Yaw, MaxRotationSpeed * -DeltaTime); return Result; }
18,288
C++
.cpp
506
32.452569
133
0.753599
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,597
NavGridGameMode.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavGridGameMode.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" ANavGridGameMode::ANavGridGameMode() :Super() { PlayerControllerClass = ANavGridPC::StaticClass(); GameStateClass = ANavGridGameState::StaticClass(); } void ANavGridGameMode::BeginPlay() { Super::BeginPlay(); // Uncomment for trace debug lines //GetWorld()->DebugDrawTraceTag = "NavGridMovement"; //GetWorld()->DebugDrawTraceTag = "NavGridTile"; //GetWorld()->DebugDrawTraceTag = "NavGridTilePlacement"; }
548
C++
.cpp
16
31.25
79
0.763359
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,598
NavLadderActor.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavLadderActor.cpp
#include "NavGridPrivatePCH.h" #include "NavLadderActor.h" ANavLadderActor::ANavLadderActor(const FObjectInitializer &ObjectInitializer) : Super(ObjectInitializer) { SceneComponent = CreateDefaultSubobject<USceneComponent>("RootComponent"); RootComponent = SceneComponent; NavLadderComponent = CreateDefaultSubobject<UNavLadderComponent>("NavLadderComponent"); NavLadderComponent->SetRelativeLocation(FVector(0, 0, 150)); NavLadderComponent->SetBoxExtent(FVector(5, 100, 150)); NavLadderComponent->SetupAttachment(SceneComponent); Mesh = CreateDefaultSubobject<UStaticMeshComponent>("StaticMesh"); Mesh->SetupAttachment(SceneComponent); const TCHAR* AssRef = TEXT("StaticMesh'/NavGrid/SMesh/NavGrid_Ladder.NavGrid_Ladder'"); auto OF = ConstructorHelpers::FObjectFinder<UStaticMesh>(AssRef); if (OF.Succeeded()) { Mesh->SetStaticMesh(OF.Object); } else { UE_LOG(NavGrid, Error, TEXT("Error loading %s"), AssRef); } }
940
C++
.cpp
24
37.166667
88
0.810515
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,599
NavTileActor.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavTileActor.cpp
#include "NavGridPrivatePCH.h" #include "NavTileActor.h" ANavTileActor::ANavTileActor(const FObjectInitializer &ObjectInitializer) :Super(ObjectInitializer) { SceneComponent = CreateDefaultSubobject<USceneComponent>("RootComponent"); RootComponent = SceneComponent; Mesh = CreateDefaultSubobject<UStaticMeshComponent>("StaticMesh"); Mesh->SetupAttachment(SceneComponent); NavTileComponent = CreateDefaultSubobject<UNavTileComponent>("NavTileComponent"); NavTileComponent->SetupAttachment(SceneComponent); NavTileComponent->SetBoxExtent(FVector(100, 100, 5)); const TCHAR* AssRef = TEXT("StaticMesh'/NavGrid/SMesh/NavGrid_Tile.NavGrid_Tile'"); auto OF = ConstructorHelpers::FObjectFinder<UStaticMesh>(AssRef); if (OF.Succeeded()) { Mesh->SetStaticMesh(OF.Object); } else { UE_LOG(NavGrid, Error, TEXT("Error loading %s"), AssRef); } SetActorTickEnabled(false); }
886
C++
.cpp
24
34.916667
84
0.80908
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,600
NavGrid.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavGrid.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" #include "AssetRegistryModule.h" #include <limits> DEFINE_LOG_CATEGORY(NavGrid); TEnumAsByte<ECollisionChannel> ANavGrid::ECC_NavGridWalkable = ECollisionChannel::ECC_GameTraceChannel1; FName ANavGrid::DisableVirtualTilesTag = "NavGrid:DisableVirtualTiles"; // Sets default values ANavGrid::ANavGrid() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = false; TileClass = UNavTileComponent::StaticClass(); SceneComponent = CreateDefaultSubobject<USceneComponent>("RootComponent"); RootComponent = SceneComponent; Cursor = CreateDefaultSubobject<UStaticMeshComponent>(FName("Cursor")); Cursor->SetupAttachment(GetRootComponent()); Cursor->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); Cursor->ToggleVisibility(false); auto HCRef = TEXT("StaticMesh'/NavGrid/SMesh/NavGrid_Cursor.NavGrid_Cursor'"); auto HCFinder = ConstructorHelpers::FObjectFinder<UStaticMesh>(HCRef); if (HCFinder.Succeeded()) { Cursor->SetStaticMesh(HCFinder.Object); } else { UE_LOG(NavGrid, Error, TEXT("Error loading %s"), HCRef); } AddHighlightType("Movable", TEXT("Material'/NavGrid/Materials/Movable_Mat.Movable_Mat'")); AddHighlightType("Dangerous", TEXT("Material'/NavGrid/Materials/Dangerous_Mat.Dangerous_Mat'")); AddHighlightType("Special", TEXT("Material'/NavGrid/Materials/Special_Mat.Special_Mat'")); CurrentPawn = NULL; CurrentTile = NULL; } void ANavGrid::SetTileHighlight(UNavTileComponent & Tile, FName Type) { Tile.SetHighlight(Type); } void ANavGrid::ClearTileHighlights() { for (auto &H : TileHighlights) { H.Value->ClearInstances(); } } void ANavGrid::AddHighlightType(const FName &Type, const TCHAR *FileName) { TileHighLightPaths.Add(Type, FileName); } UInstancedStaticMeshComponent * ANavGrid::GetHighlightComponent(FName Type) { /* build the instanced mesh component if we have not already done so */ if (!TileHighlights.Contains(Type) && TileHighLightPaths.Contains(Type)) { FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry"); UStaticMesh *Mesh = LoadObject<UStaticMesh>(this, TEXT("StaticMesh'/NavGrid/SMesh/NavGrid_TileHighlight.NavGrid_TileHighlight'")); check(Mesh); UMaterial *Material = LoadObject<UMaterial>(this, TileHighLightPaths[Type]); check(Material); auto *Comp = NewObject<UInstancedStaticMeshComponent>(this); Comp->SetupAttachment(GetRootComponent()); Comp->SetStaticMesh(Mesh); Comp->SetMaterial(0, Material); Comp->SetCollisionEnabled(ECollisionEnabled::NoCollision); Comp->RegisterComponent(); Comp->bOnlyOwnerSee = true; TileHighlights.Add(Type, Comp); } /* we *should* now have the object we need*/ if (TileHighlights.Contains(Type)) { return TileHighlights[Type]; } else { return NULL; } } ANavGrid *ANavGrid::GetNavGrid(AActor *ActorInWorld) { return GetNavGrid(ActorInWorld->GetWorld()); } ANavGrid * ANavGrid::GetNavGrid(UWorld *World) { ANavGridGameState* GameState = World->GetGameState<ANavGridGameState>(); if (IsValid(GameState)) { return GameState->GetNavGrid(); } else { return nullptr; } } UNavTileComponent *ANavGrid::GetTile(const FVector &WorldLocation, bool FindFloor/*= true*/, float UpwardTraceLength/* = 100*/, float DownwardTraceLength/* = 100*/) { return LineTraceTile(WorldLocation, FindFloor, UpwardTraceLength, DownwardTraceLength); } UNavTileComponent * ANavGrid::LineTraceTile(const FVector & WorldLocation, bool FindFloor, float UpwardTraceLength, float DownwardTraceLength) { UNavTileComponent *Result = nullptr; if (FindFloor) { Result = LineTraceTile(WorldLocation + FVector(0, 0, UpwardTraceLength), WorldLocation - FVector(0, 0, DownwardTraceLength)); } else { /* Do a bunch of horizontal line traces and pick the closest tile component*/ UNavTileComponent *Closest = nullptr; static FVector EndPoints[8] = { FVector(0, 200, 0), FVector(200, 200, 0), FVector(200, 0, 0), FVector(200, -200, 0), FVector(0, -200, 0), FVector(-200, -200, 0), FVector(-200, 0, 0), FVector(-200, 200, 0) }; for (FVector EndPoint : EndPoints) { UNavTileComponent *Candidate = LineTraceTile(WorldLocation - EndPoint, WorldLocation + EndPoint); if (Candidate) { if (!Closest) { Closest = Candidate; } else if (FVector::Dist(Candidate->GetComponentLocation(), WorldLocation) < FVector::Dist(Closest->GetComponentLocation(), WorldLocation)) { Closest = Candidate; } } } Result = Closest; } return Result; } UNavTileComponent *ANavGrid::LineTraceTile(const FVector &Start, const FVector &End) { TArray<FHitResult> HitResults; FCollisionQueryParams CQP; CQP.TraceTag = "NavGridTile"; GetWorld()->LineTraceMultiByChannel(HitResults, Start, End, ECC_NavGridWalkable, CQP); if (HitResults.Num()) { UPrimitiveComponent *Comp = HitResults[0].GetComponent(); return Cast<UNavTileComponent>(Comp); } else { return nullptr; } } void ANavGrid::TileClicked(const UNavTileComponent *Tile) { OnTileClicked.Broadcast(Tile); } void ANavGrid::TileCursorOver(const UNavTileComponent *Tile) { OnTileCursorOver.Broadcast(Tile); } void ANavGrid::EndTileCursorOver(const UNavTileComponent *Tile) { OnEndTileCursorOver.Broadcast(Tile); } void ANavGrid::CalculateTilesInRange(AGridPawn *Pawn) { QUICK_SCOPE_CYCLE_COUNTER(STAT_ANavGrid_CalculateTilesInRange); ClearTiles(); if (EnableVirtualTiles) { GenerateVirtualTiles(Pawn); } UNavTileComponent *Current = Pawn->GetTile(); /* if we're not on the grid, the number of tiles in range is zero */ if (!Current) { return; } Current->Distance = 0; TArray<UNavTileComponent *> NeighbouringTiles; Current->GetUnobstructedNeighbours(*Pawn->MovementCollisionCapsule, NeighbouringTiles); TArray<UNavTileComponent *> TentativeSet(NeighbouringTiles); while (Current) { Current->GetUnobstructedNeighbours(*Pawn->MovementCollisionCapsule, NeighbouringTiles); for (UNavTileComponent *N : NeighbouringTiles) { if (!N->Traversable(Pawn->MovementComponent->AvailableMovementModes)) { continue; } if (!N->Visited) { float TentativeDistance = N->Cost + Current->Distance; if (TentativeDistance <= N->Distance) { // Prioritize straight paths by using the world distance as a tiebreaker // when TentativeDistance is equal N->Dinstance float OldDistance = std::numeric_limits<float>::infinity(); float NewDistance = 0; if (TentativeDistance == N->Distance) { NewDistance = (Current->GetComponentLocation() - N->GetComponentLocation()).Size(); if (N->Backpointer) { OldDistance = (N->Backpointer->GetComponentLocation() - N->GetComponentLocation()).Size(); } } if (NewDistance < OldDistance) // Always true if TentativeDistance < N->Distance { N->Distance = TentativeDistance; N->Backpointer = Current; if (TentativeDistance <= Pawn->MovementComponent->MovementRange) { TentativeSet.AddUnique(N); } } } } } Current->Visited = true; TentativeSet.Remove(Current); if (Current != Pawn->GetTile()) { TilesInRange.Add(Current); } // dont include the starting tile if (TentativeSet.Num()) { Current = TentativeSet[0]; } else { Current = NULL; } } } void ANavGrid::GetTilesInRange(AGridPawn *Pawn, TArray<UNavTileComponent*>& OutTiles) { if (Pawn != CurrentPawn || Pawn->GetTile() != CurrentTile) { CalculateTilesInRange(Pawn); CurrentPawn = Pawn; CurrentTile = Pawn->GetTile(); } OutTiles = TilesInRange; } void ANavGrid::ClearTiles() { TilesInRange.Empty(); TArray<UNavTileComponent *> AllTiles; GetEveryTile(AllTiles, GetWorld()); for (auto *T : AllTiles) { T->Reset(); } ClearTileHighlights(); NumPersistentTiles = AllTiles.Num() - VirtualTiles.Num(); } bool ANavGrid::TraceTileLocation(const FVector & TraceStart, const FVector & TraceEnd, FVector & OutTilePos) { FCollisionQueryParams CQP; CQP.bFindInitialOverlaps = true; CQP.TraceTag = "NavGridTilePlacement"; FHitResult HitResult; GetWorld()->LineTraceSingleByChannel(HitResult, TraceStart, TraceEnd, ECollisionChannel::ECC_Pawn, CQP); bool bHasDisableTileTag = false; if (HitResult.Actor.IsValid()) { bHasDisableTileTag = HitResult.Actor->ActorHasTag(DisableVirtualTilesTag); } OutTilePos = HitResult.ImpactPoint; // return true if we hit the 'outside' of something that does not have the disabletile-tag return HitResult.bBlockingHit && !HitResult.bStartPenetrating && !bHasDisableTileTag; } UNavTileComponent * ANavGrid::PlaceTile(const FVector & Location, AActor * TileOwner) { if (!TileOwner) { TileOwner = this; } UNavTileComponent *TileComp = NewObject<UNavTileComponent>(TileOwner, TileClass); TileComp->SetupAttachment(TileOwner->GetRootComponent()); TileComp->SetWorldTransform(FTransform::Identity); TileComp->SetWorldLocation(Location); TileComp->SetBoxExtent(FVector(TileSize / 2, TileSize / 2, 5)); TileComp->RegisterComponentWithWorld(TileOwner->GetWorld()); TileComp->SetGrid(this); return TileComp; } UNavTileComponent * ANavGrid::ConsiderPlaceTile(const FVector &TraceStart, const FVector &TraceEnd, AActor * TileOwner /*= NULL*/) { if (!TileOwner) { TileOwner = this; } FVector TileLocation; bool FoundGoodLocation = TraceTileLocation(TraceStart, TraceEnd, TileLocation); if (FoundGoodLocation) { // check if we a new tile will overlap any existing tiles // use a mutlisweep as tiles returs overlap responses to this channel TArray<FHitResult> HitResults; FCollisionShape TileShape = FCollisionShape::MakeBox(FVector(TileSize / 3, TileSize / 3, 25)); GetWorld()->SweepMultiByChannel(HitResults, TileLocation, TileLocation - FVector(0, 0, 1), FQuat::Identity, ECC_NavGridWalkable, TileShape); UNavTileComponent* ExistingTile = nullptr; for (FHitResult& HitResult : HitResults) { if (IsValid(ExistingTile = Cast<UNavTileComponent>(HitResult.Component.Get()))) { break; } } if (!IsValid(ExistingTile)) { return PlaceTile(TileLocation, TileOwner); } } return nullptr; } FVector ANavGrid::AdjustToTileLocation(const FVector &Location) { UNavTileComponent *SnapTile = LineTraceTile(Location, true, 100, 100); if (SnapTile) { return SnapTile->GetComponentLocation(); } // try to position the pawn so that it matches a regular grid // we do not change the vertical location FVector Offset = Location - GetActorLocation(); int32 XRest = (int32)Offset.X % (int32)TileSize; int32 YRest = (int32)Offset.Y % (int32)TileSize; FVector AdjustedLocation = Location; AdjustedLocation.X += (TileSize / 2) - XRest; AdjustedLocation.Y += (TileSize / 2) - YRest; return AdjustedLocation; } void ANavGrid::GenerateVirtualTiles(const AGridPawn *Pawn) { QUICK_SCOPE_CYCLE_COUNTER(STAT_ANavGrid_GenerateVirtualTiles); // only keep a reasonable number if (VirtualTiles.Num() > MaxVirtualTiles) { UE_LOG(NavGrid, Log, TEXT("Limit reached (%i), removing all virtual tiles"), MaxVirtualTiles); DestroyVirtualTiles(); } GenerateVirtualTile(Pawn); FVector Center = AdjustToTileLocation(Pawn->GetActorLocation()); FVector Min = Center - FVector(Pawn->MovementComponent->MovementRange * TileSize); FVector Max = Center + FVector(Pawn->MovementComponent->MovementRange * TileSize); for (float X = Min.X; X <= Max.X; X += TileSize) { for (float Y = Min.Y; Y <= Max.Y; Y += TileSize) { for (float Z = Max.Z; Z >= Min.Z; Z -= TileSize) { UNavTileComponent *TileComp = ConsiderPlaceTile(FVector(X, Y, Z + TileSize), FVector(X, Y, Z - 0.1)); if (TileComp) { VirtualTiles.Add(TileComp); } } } } } void ANavGrid::GenerateVirtualTile(const AGridPawn * Pawn) { FVector Location = AdjustToTileLocation(Pawn->GetActorLocation()); UNavTileComponent *TileComp = ConsiderPlaceTile(Location + FVector(0, 0, TileSize), Location - FVector(0, 0, 0.1)); if (TileComp) { VirtualTiles.Add(TileComp); } } void ANavGrid::DestroyVirtualTiles() { for (UNavTileComponent *T : VirtualTiles) { if (IsValid(T)) { T->DestroyComponent(); } } VirtualTiles.Empty(); } void ANavGrid::Destroyed() { Super::Destroyed(); DestroyVirtualTiles(); } void ANavGrid::GetEveryTile(TArray<UNavTileComponent *> &OutTiles, UWorld * World) { for (TObjectIterator<UNavTileComponent> Itr; Itr; ++Itr) { if (Itr->GetWorld() == World) { OutTiles.Add(*Itr); } } }
13,100
C++
.cpp
399
28.984962
165
0.730271
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,601
TurnManager.cpp
larsjsol_NavGrid/Source/Navgrid/Private/TurnManager.cpp
#include "NavGridPrivatePCH.h" ATurnManager::ATurnManager() : MinNumberOfTeams(1), CurrentComponent(nullptr), NextComponent(nullptr), Round(0), bStartNewTurn(true) { PrimaryActorTick.bCanEverTick = true; } void ATurnManager::Tick(float DeltaTime) { Super::Tick(DeltaTime); TArray<FGenericTeamId> Keys; Teams.GetKeys(Keys); if (bStartNewTurn && Keys.Num() >= MinNumberOfTeams) { // broadcast TurnEnd and TeamTurnEnd if (IsValid(CurrentComponent)) { CurrentComponent->OnTurnEnd(); OnTurnEnd().Broadcast(CurrentComponent); if (!IsValid(FindNextTeamMember(CurrentComponent->TeamId()))) { OnTeamTurnEnd().Broadcast(CurrentComponent->TeamId()); } } // start a new round if no more components can act this turn if (Round == 0 || !HasComponentsThatCanAct()) { if (Round > 0) { OnRoundEnd().Broadcast(); } for (TPair<FGenericTeamId, UTurnComponent *> &Pair : Teams) { Pair.Value->RemainingActionPoints = Pair.Value->StartingActionPoints; } CurrentComponent = nullptr; NextComponent = nullptr; Round++; UE_LOG(NavGrid, Log, TEXT("Starting round %i"), Round); OnRoundStart().Broadcast(); } // figure out which component that has the next turn if (!IsValid(NextComponent) || NextComponent->RemainingActionPoints <= 0) { if (IsValid(CurrentComponent) && CurrentComponent->RemainingActionPoints > 0) { NextComponent = CurrentComponent; } else { NextComponent = FindNextComponent(); } } // broadcast TurnStart and TeamTurnStart check(IsValid(NextComponent)) UTurnComponent *PreviousComponent = CurrentComponent; CurrentComponent = NextComponent; if (!IsValid(PreviousComponent) || CurrentComponent->TeamId() != PreviousComponent->TeamId()) { UE_LOG(NavGrid, Log, TEXT("Starting team turn for team %i"), CurrentComponent->TeamId().GetId()); OnTeamTurnStart().Broadcast(CurrentComponent->TeamId()); } CurrentComponent->OnTurnStart(); OnTurnStart().Broadcast(CurrentComponent); NextComponent = nullptr; bStartNewTurn = false; } } void ATurnManager::RegisterTurnComponent(UTurnComponent *TurnComponent) { UE_LOG(NavGrid, Verbose, TEXT("%s (team %i) registering"), *TurnComponent->GetName(), TurnComponent->TeamId().GetId()); Teams.AddUnique(TurnComponent->TeamId(), TurnComponent); } void ATurnManager::UnregisterTurnComponent(UTurnComponent * TurnComponent) { UE_LOG(NavGrid, Verbose, TEXT("%s (team %i) unregistering"), *TurnComponent->GetName(), TurnComponent->TeamId().GetId()); Teams.RemoveSingle(TurnComponent->TeamId(), TurnComponent); if (CurrentComponent == TurnComponent) { CurrentComponent = nullptr; bStartNewTurn = true; } if (NextComponent == TurnComponent) { NextComponent = nullptr; } } void ATurnManager::EndTurn(UTurnComponent *Ender) { if (Ender == CurrentComponent) { bStartNewTurn = true; } else { if (IsValid(CurrentComponent)) { UE_LOG(NavGrid, Warning, TEXT("ATurnManager::EndTurn(%s): CurrentComponent: %s"), *Ender->GetOwner()->GetName(), *CurrentComponent->GetOwner()->GetName()); } else { UE_LOG(NavGrid, Warning, TEXT("ATurnManager::EndTurn(%s): CurrentComponent: null"), *Ender->GetOwner()->GetName()); } } } void ATurnManager::EndTeamTurn(FGenericTeamId InTeamId) { if (CurrentComponent->TeamId() == InTeamId) { TArray<UTurnComponent *> TeamMemebers; Teams.MultiFind(InTeamId, TeamMemebers); for (UTurnComponent *Member : TeamMemebers) { Member->RemainingActionPoints = 0; } bStartNewTurn = true; } } void ATurnManager::RequestStartTurn(UTurnComponent * CallingComponent) { if (!IsValid(CurrentComponent) || CurrentComponent->TeamId() == CallingComponent->TeamId()) { NextComponent = CallingComponent; bStartNewTurn = true; } } void ATurnManager::RequestStartNextComponent(UTurnComponent *CallingComponent) { if (IsValid(CurrentComponent) && CurrentComponent->TeamId() == CallingComponent->TeamId()) { UTurnComponent *Candidate = FindNextTeamMember(CallingComponent->TeamId()); if (IsValid(Candidate)) { NextComponent = Candidate; bStartNewTurn = true; } } } FGenericTeamId ATurnManager::GetCurrentTeam() const { return CurrentComponent ? CurrentComponent->TeamId() : FGenericTeamId::NoTeam; } AActor *ATurnManager::GetCurrentActor() const { return IsValid(CurrentComponent) ? CurrentComponent->GetOwner() : nullptr; } UTurnComponent * ATurnManager::FindNextTeamMember(const FGenericTeamId & TeamId) { TArray<UTurnComponent *> TeamMembers; Teams.MultiFind(TeamId, TeamMembers, true); int32 StartIndex; TeamMembers.Find(CurrentComponent, StartIndex); for (int32 Idx = 1; Idx <= TeamMembers.Num(); Idx++) { UTurnComponent *Candidate = TeamMembers[(StartIndex + Idx) % TeamMembers.Num()]; if (Candidate->RemainingActionPoints > 0) { return Candidate; } } return nullptr; } UTurnComponent * ATurnManager::FindNextComponent() { TArray<FGenericTeamId> TeamIds; Teams.GenerateKeyArray(TeamIds); TeamIds.Sort(); for (FGenericTeamId &TeamId : TeamIds) { UTurnComponent *Candidate = FindNextTeamMember(TeamId); if (IsValid(Candidate)) { return Candidate; } } return nullptr; } bool ATurnManager::HasComponentsThatCanAct() { for (TPair<FGenericTeamId, UTurnComponent *> &Pair : Teams) { if (Pair.Value->RemainingActionPoints > 0) { return true; } } return false; }
5,593
C++
.cpp
191
25.52356
159
0.723468
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,602
NavGridPlugin.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavGridPlugin.cpp
#include "NavGridPrivatePCH.h" #include "NavGridPlugin.h" void NavGridPluginImpl::StartupModule() { UE_LOG(NavGrid, Log, TEXT("Starting")); } void NavGridPluginImpl::ShutdownModule() { UE_LOG(NavGrid, Log, TEXT("Shutting down")); } IMPLEMENT_MODULE(NavGridPluginImpl, NavGrid)
298
C++
.cpp
11
24.181818
46
0.759857
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,603
NavGridGameState.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavGridGameState.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" ANavGrid* ANavGridGameState::GetNavGrid() { if (!IsValid(Grid)) { // if a navgrid exists in the game world, grab it TActorIterator<ANavGrid> GridItr(GetWorld()); if (GridItr) { Grid = *GridItr; } else { Grid = SpawnNavGrid(); } // make sure that every tile belongs to a grid TArray<UNavTileComponent*> AllTiles; Grid->GetEveryTile(AllTiles, GetWorld()); for (UNavTileComponent* Tile : AllTiles) { if (!Tile->GetGrid()) { Tile->SetGrid(Grid); } } } return Grid; } ATurnManager* ANavGridGameState::GetTurnManager() { if (!IsValid(TurnManager)) { TurnManager = SpawnTurnManager(); } return TurnManager; } ATurnManager * ANavGridGameState::SpawnTurnManager() { ATurnManager *Manager = GetWorld()->SpawnActor<ATurnManager>(); Manager->SetOwner(this); return Manager; } ANavGrid * ANavGridGameState::SpawnNavGrid() { ANavGrid *NewGrid = GetWorld()->SpawnActor<ANavGrid>(); NewGrid->SetOwner(this); return NewGrid; }
1,144
C++
.cpp
49
19.816327
79
0.701754
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,604
TurnComponent.cpp
larsjsol_NavGrid/Source/Navgrid/Private/TurnComponent.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" UTurnComponent::UTurnComponent() :Super(), TurnManager(nullptr), StartingActionPoints(1), RemainingActionPoints(1), TurnTimeout(30) { } void UTurnComponent::BeginPlay() { Super::BeginPlay(); RegisterWithTurnManager(); } void UTurnComponent::OnComponentDestroyed(bool bDestroyingHierarchy) { Super::OnComponentDestroyed(bDestroyingHierarchy); UnregisterWithTurnManager(); } ATurnManager * UTurnComponent::GetTurnManager() { if (!IsValid(TurnManager)) { RegisterWithTurnManager(); } return TurnManager; } void UTurnComponent::EndTurn() { if (IsValid(TurnManager)) { TurnManager->EndTurn(this); } } void UTurnComponent::EndTeamTurn() { if (IsValid(TurnManager)) { TurnManager->EndTeamTurn(FGenericTeamId::GetTeamIdentifier(GetOwner())); } } void UTurnComponent::RequestStartTurn() { if (IsValid(TurnManager)) { TurnManager->RequestStartTurn(this); } } void UTurnComponent::RequestStartNextComponent() { if (IsValid(TurnManager)) { TurnManager->RequestStartNextComponent(this); } } void UTurnComponent::OnTurnTimeout() { if (MyTurn()) { UE_LOG(NavGrid, Warning, TEXT("Turn timeout (%f sec) reached for %s"), TurnTimeout, *GetOwner()->GetName()); RemainingActionPoints = 0; EndTurn(); } } void UTurnComponent::OwnerReadyForInput() { if (IsValid(TurnManager) && TurnManager->GetCurrentComponent() == this) { TurnManager->OnReadyForInput().Broadcast(this); } } AActor *UTurnComponent::GetCurrentActor() const { if (IsValid(TurnManager)) { return TurnManager->GetCurrentActor(); } return nullptr; } void UTurnComponent::RegisterWithTurnManager() { UnregisterWithTurnManager(); ANavGridGameState *GameState = GetWorld()->GetGameState<ANavGridGameState>(); if (IsValid(GameState)) { TurnManager = GameState->GetTurnManager(); TurnManager->RegisterTurnComponent(this); } } void UTurnComponent::UnregisterWithTurnManager() { if (IsValid(TurnManager)) { TurnManager->UnregisterTurnComponent(this); } TurnManager = nullptr; } void UTurnComponent::OnTurnStart() { GetWorld()->GetTimerManager().SetTimer(TurnTimeoutHandle, this, &UTurnComponent::OnTurnTimeout, TurnTimeout); } void UTurnComponent::OnTurnEnd() { GetWorld()->GetTimerManager().ClearTimer(TurnTimeoutHandle); }
2,481
C++
.cpp
106
20.40566
111
0.753951
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,605
ExampleGridPawn.cpp
larsjsol_NavGrid/Source/Navgrid/Private/ExampleGridPawn.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" #include "ExampleGridPawn.h" #include "Components/StaticMeshComponent.h" #include "Components/ArrowComponent.h" AExampleGridPawn::AExampleGridPawn() :Super() { MovementCollisionCapsule->SetCapsuleHalfHeight(30); MovementCollisionCapsule->SetRelativeLocation(FVector(0, 0, 50)); StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>("StaticMesh"); UStaticMesh *Mesh = ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("StaticMesh'/Engine/BasicShapes/Cone.Cone'")).Object; StaticMesh->SetStaticMesh(Mesh); StaticMesh->SetRelativeLocation(-MovementCollisionCapsule->GetRelativeLocation() + FVector(0, 0, 50)); StaticMesh->SetupAttachment(GetRootComponent()); /* Show the arrow in-game so we can which way the pawn is facing */ Arrow->SetHiddenInGame(false); }
911
C++
.cpp
18
47.5
127
0.798414
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,606
NavLadderComponent.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavLadderComponent.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" UNavLadderComponent::UNavLadderComponent() :Super() { MovementModes.Empty(); MovementModes.Add(EGridMovementMode::ClimbingUp); MovementModes.Add(EGridMovementMode::ClimbingDown); } void UNavLadderComponent::SetGrid(ANavGrid *InGrid) { Super::SetGrid(InGrid); TileSize = InGrid->TileSize; } void UNavLadderComponent::GetNeighbours(const UCapsuleComponent &CollisionCapsule, TArray<UNavTileComponent *> &OutUnObstructed, TArray<UNavTileComponent *> &OutObstructed) { OutUnObstructed.Empty(); OutObstructed.Empty(); if (IsValid(Grid)) { FCollisionShape Shape = FCollisionShape::MakeBox(BoxExtent + FVector(Grid->TileSize / 2)); TArray<FHitResult> HitResults; TArray<UNavTileComponent *> AllNeighbours; Grid->GetWorld()->SweepMultiByChannel(HitResults, GetComponentLocation(), GetComponentLocation() + FVector(0, 0, 1), GetComponentQuat(), Grid->ECC_NavGridWalkable, Shape); for (FHitResult &Hit : HitResults) { UNavTileComponent *HitTile = Cast<UNavTileComponent>(Hit.GetComponent()); if (IsValid(HitTile) && HitTile != this) { AllNeighbours.AddUnique(HitTile); } } for (UNavTileComponent *N : AllNeighbours) { //Determine if we should trace from the top or bottom point float TopDistance = (GetTopPathPoint() - N->GetPawnLocation()).Size(); float BottomDistance = (GetBottomPathPoint() - N->GetPawnLocation()).Size(); FVector TracePoint = TopDistance < BottomDistance ? GetTopPathPoint() : GetBottomPathPoint(); if (N->Obstructed(TracePoint, CollisionCapsule)) { OutObstructed.Add(N); } else { OutUnObstructed.Add(N); } } } } bool UNavLadderComponent::Obstructed(const FVector & FromPos, const UCapsuleComponent & CollisionCapsule) const { //Determine if we should trace to the top or bottom point float TopDistance = (GetTopPathPoint() - FromPos).Size(); float BottomDistance = (GetBottomPathPoint() - FromPos).Size(); FVector TracePoint = TopDistance < BottomDistance ? GetTopPathPoint() : GetBottomPathPoint(); FHitResult OutHit; FCollisionShape CollisionShape = CollisionCapsule.GetCollisionShape(); FCollisionQueryParams CQP; CQP.AddIgnoredActor(CollisionCapsule.GetOwner()); CQP.TraceTag = "NavGridMovement"; return CollisionCapsule.GetWorld()->SweepSingleByChannel(OutHit, FromPos + CollisionCapsule.GetRelativeLocation(), TracePoint + CollisionCapsule.GetRelativeLocation(), GetComponentQuat(), ECollisionChannel::ECC_Pawn, CollisionShape, CQP); } void UNavLadderComponent::AddPathSegments(USplineComponent &OutSpline, TArray<FPathSegment> &OutPathSegments, bool EndTile) const { FVector EntryPoint = OutSpline.GetLocationAtSplinePoint(OutSpline.GetNumberOfSplinePoints() - 1, ESplineCoordinateSpace::Local); float TopDistance = (GetTopPathPoint() - EntryPoint).Size(); float BottomDistance = (GetBottomPathPoint() - EntryPoint).Size(); FPathSegment NewSegment; NewSegment.MovementModes = MovementModes; NewSegment.PawnRotationHint = GetComponentRotation(); NewSegment.PawnRotationHint.Yaw -= 180; // add spline points and segments if (TopDistance > BottomDistance) { OutSpline.AddSplinePoint(GetBottomPathPoint(), ESplineCoordinateSpace::Local); NewSegment.Start = OutSpline.GetSplineLength(); OutSpline.AddSplinePoint(GetTopPathPoint(), ESplineCoordinateSpace::Local); NewSegment.End = OutSpline.GetSplineLength(); } else { OutSpline.AddSplinePoint(GetTopPathPoint(), ESplineCoordinateSpace::Local); NewSegment.Start = OutSpline.GetSplineLength(); OutSpline.AddSplinePoint(GetBottomPathPoint(), ESplineCoordinateSpace::Local); NewSegment.End = OutSpline.GetSplineLength(); } // unlike regular tiles, we do not want the pawn to change movement mode untill it reaches the first path point // we therefore extend the previous segment to that point if (OutPathSegments.Num()) { OutPathSegments.Last().End = NewSegment.Start; } // add the new segment OutPathSegments.Add(NewSegment); if (EndTile) { OutSpline.RemoveSplinePoint(OutSpline.GetNumberOfSplinePoints() - 1); OutSpline.AddSplinePoint(PawnLocationOffset + GetComponentLocation(), ESplineCoordinateSpace::Local); } } FVector UNavLadderComponent::GetSplineMeshUpVector() { FRotator Rot = GetComponentRotation(); FVector UpVector = Rot.RotateVector(FVector(0, -1, 0)); return UpVector; }
4,445
C++
.cpp
107
38.785047
174
0.786623
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,607
NavTileComponent.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavTileComponent.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" #include <limits> #include "Components/CapsuleComponent.h" #include "DrawDebugHelpers.h" UNavTileComponent::UNavTileComponent() :Super() { PawnLocationOffset = FVector::ZeroVector; SetComponentTickEnabled(false); /* Bind mouse events */ OnBeginCursorOver.AddDynamic(this, &UNavTileComponent::CursorOver); OnEndCursorOver.AddDynamic(this, &UNavTileComponent::EndCursorOver); OnClicked.AddDynamic(this, &UNavTileComponent::Clicked); /* Bind touch events */ OnInputTouchEnter.AddDynamic(this, &UNavTileComponent::TouchEnter); OnInputTouchLeave.AddDynamic(this, &UNavTileComponent::TouchLeave); OnInputTouchEnd.AddDynamic(this, &UNavTileComponent::TouchEnd); SetCollisionEnabled(ECollisionEnabled::QueryOnly); SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore); SetCollisionResponseToChannel(ECollisionChannel::ECC_Visibility, ECollisionResponse::ECR_Block); // So we get mouse over events SetCollisionResponseToChannel(ECollisionChannel::ECC_Camera, ECollisionResponse::ECR_Block); // So we get mouse over events SetCollisionResponseToChannel(ANavGrid::ECC_NavGridWalkable, ECollisionResponse::ECR_Overlap); // So we can find the floor with a line trace MovementModes.Add(EGridMovementMode::Stationary); MovementModes.Add(EGridMovementMode::Walking); MovementModes.Add(EGridMovementMode::InPlaceTurn); ShapeColor = FColor::Magenta; Reset(); } bool UNavTileComponent::Traversable(const TSet<EGridMovementMode>& PawnMovementModes) const { return MovementModes.Intersect(PawnMovementModes).Num() > 0; } bool UNavTileComponent::LegalPositionAtEndOfTurn(const TSet<EGridMovementMode> &PawnMovementModes) const { return MovementModes.Contains(EGridMovementMode::Stationary); } FVector UNavTileComponent::GetPawnLocation() const { return GetComponentLocation() + GetComponentRotation().RotateVector(PawnLocationOffset); } void UNavTileComponent::SetPawnLocationOffset(const FVector &Offset) { PawnLocationOffset = Offset; } void UNavTileComponent::SetGrid(ANavGrid * InGrid) { Grid = InGrid; } ANavGrid * UNavTileComponent::GetGrid() const { return Grid; } void UNavTileComponent::Reset() { Distance = std::numeric_limits<float>::infinity(); Backpointer = NULL; Visited = false; } bool UNavTileComponent::Obstructed(const FVector &FromPos, const UCapsuleComponent &CollisionCapsule) const { return Obstructed(FromPos + CollisionCapsule.GetRelativeLocation(), GetPawnLocation() + CollisionCapsule.GetRelativeLocation(), CollisionCapsule); } bool UNavTileComponent::Obstructed(const FVector &From, const FVector &To, const UCapsuleComponent &CollisionCapsule) const { FHitResult OutHit; FQuat Rot = FQuat::Identity; FCollisionShape CollisionShape = CollisionCapsule.GetCollisionShape(); FCollisionQueryParams CQP; CQP.AddIgnoredActor(CollisionCapsule.GetOwner()); CQP.TraceTag = "NavGridMovement"; return CollisionCapsule.GetWorld()->SweepSingleByChannel(OutHit, From, To, Rot, ECollisionChannel::ECC_Pawn, CollisionShape, CQP); } void UNavTileComponent::GetNeighbours(const UCapsuleComponent & CollisionCapsule, TArray<UNavTileComponent*>& OutUnObstructed, TArray<UNavTileComponent*>& OutObstructed) { QUICK_SCOPE_CYCLE_COUNTER(STAT_UNavTileComponent_GetNeighbours); OutUnObstructed.Empty(); OutObstructed.Empty(); if (IsValid(Grid)) { FVector MyExtent = BoxExtent + FVector(Grid->TileSize * 0.75); TArray<FHitResult> HitResults; Grid->GetWorld()->SweepMultiByChannel(HitResults, GetComponentLocation(), GetComponentLocation() + FVector(0, 0, 1), GetComponentQuat(), Grid->ECC_NavGridWalkable, FCollisionShape::MakeBox(MyExtent)); for (FHitResult &Hit : HitResults) { UNavTileComponent *HitTile = Cast<UNavTileComponent>(Hit.GetComponent()); if (IsValid(HitTile)) { if (HitTile != this && !HitTile->Obstructed(GetPawnLocation(), CollisionCapsule)) { OutUnObstructed.AddUnique(HitTile); } else { OutObstructed.AddUnique(HitTile); } } } } } void UNavTileComponent::GetUnobstructedNeighbours(const UCapsuleComponent &CollisionCapsule, TArray<UNavTileComponent *> &OutNeighbours) { TArray<UNavTileComponent *> Dummy; GetNeighbours(CollisionCapsule, OutNeighbours, Dummy); } void UNavTileComponent::Clicked(UPrimitiveComponent* TouchedComponent, FKey Key) { Grid->TileClicked(this); } void UNavTileComponent::CursorOver(UPrimitiveComponent* TouchedComponent) { Grid->TileCursorOver(this); } void UNavTileComponent::EndCursorOver(UPrimitiveComponent* TouchedComponent) { Grid->EndTileCursorOver(this); } void UNavTileComponent::TouchEnter(ETouchIndex::Type Type, UPrimitiveComponent* TouchedComponent) { CursorOver(TouchedComponent); } void UNavTileComponent::TouchLeave(ETouchIndex::Type Type, UPrimitiveComponent* TouchedComponent) { EndCursorOver(TouchedComponent); } void UNavTileComponent::TouchEnd(ETouchIndex::Type Type, UPrimitiveComponent* TouchedComponent) { Grid->TileClicked(this); } void UNavTileComponent::AddPathSegments(USplineComponent &OutSpline, TArray<FPathSegment> &OutPathSegments, bool EndTile) const { FVector EntryPoint = OutSpline.GetLocationAtSplinePoint(OutSpline.GetNumberOfSplinePoints() - 1, ESplineCoordinateSpace::Local); float SegmentStart = OutSpline.GetSplineLength(); OutSpline.AddSplinePoint(GetComponentLocation() + PawnLocationOffset, ESplineCoordinateSpace::Local); OutPathSegments.Add(FPathSegment(MovementModes, SegmentStart, OutSpline.GetSplineLength())); } FVector UNavTileComponent::GetSplineMeshUpVector() { return FVector(0, 0, 1); } void UNavTileComponent::SetHighlight(FName NewHighlightType) { auto *HighlightComponent = Grid->GetHighlightComponent(NewHighlightType); if (HighlightComponent) { FVector MeshSize = HighlightComponent->GetStaticMesh()->GetBoundingBox().GetSize(); FVector TileSize = GetScaledBoxExtent() * 2; FTransform Transform = GetComponentTransform(); Transform.SetScale3D(FVector(TileSize.X / MeshSize.X, TileSize.Y / MeshSize.Y, 1)); HighlightComponent->AddInstanceWorldSpace(Transform); } } void UNavTileComponent::DrawDebug(UCapsuleComponent *CollisionCapsule, bool bPersistentLines, float LifeTime, float Thickness) { DrawDebugCapsule(GetWorld(), GetPawnLocation() + CollisionCapsule->GetRelativeLocation(), CollisionCapsule->GetScaledCapsuleHalfHeight(), CollisionCapsule->GetScaledCapsuleRadius(), CollisionCapsule->GetComponentQuat(), FColor::Cyan, bPersistentLines, LifeTime, 0, Thickness); DrawDebugBox(GetWorld(), GetComponentLocation(), BoxExtent, GetComponentQuat(), FColor::Cyan, bPersistentLines, LifeTime, 0, Thickness); if (IsValid(Grid)) { DrawDebugBox(GetWorld(), GetComponentLocation(), BoxExtent + FVector(Grid->TileSize * 0.75), GetComponentQuat(), FColor::Blue, bPersistentLines, LifeTime, 0, Thickness); } TArray<UNavTileComponent *> UnObstructed, Obstructed; GetNeighbours(*CollisionCapsule, UnObstructed, Obstructed); for (UNavTileComponent *Tile : UnObstructed) { DrawDebugLine(GetWorld(), GetPawnLocation() + CollisionCapsule->GetRelativeLocation(), CollisionCapsule->GetRelativeLocation() + ((GetPawnLocation() + Tile->GetPawnLocation()) / 2), FColor::Green, bPersistentLines, LifeTime, 0, Thickness); } for (UNavTileComponent *Tile : Obstructed) { DrawDebugLine(GetWorld(), GetPawnLocation() + CollisionCapsule->GetRelativeLocation(), CollisionCapsule->GetRelativeLocation() + ((GetPawnLocation() + Tile->GetPawnLocation()) / 2), FColor::Red, bPersistentLines, LifeTime, 0, Thickness); } }
7,630
C++
.cpp
172
42.011628
242
0.809402
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,608
NavGridPC.cpp
larsjsol_NavGrid/Source/Navgrid/Private/NavGridPC.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "NavGridPrivatePCH.h" ANavGridPC::ANavGridPC(const FObjectInitializer& ObjectInitializer) :Super(ObjectInitializer) { bShowMouseCursor = true; /* Enable mouse events */ bEnableClickEvents = true; bEnableMouseOverEvents = true; bEnableTouchEvents = true; bEnableTouchOverEvents = true; } void ANavGridPC::BeginPlay() { // grab turn manager and grid from the game state auto *State = GetWorld()->GetGameState<ANavGridGameState>(); SetTurnManager(State->GetTurnManager()); SetGrid(State->GetNavGrid()); } void ANavGridPC::OnTileClicked(const UNavTileComponent *Tile) { /* Try to move the current pawn to the clicked tile */ if (GridPawn && GridPawn->GetState() == EGridPawnState::Ready) { if (GridPawn->CanMoveTo(*Tile)) { GridPawn->MoveTo(*Tile); } } } void ANavGridPC::OnTileCursorOver(const UNavTileComponent *Tile) { /* If the pawn is not moving, try to create a path to the hovered tile and show it */ if (GridPawn && GridPawn->GetState() == EGridPawnState::Ready) { Grid->Cursor->SetWorldLocation(Tile->GetPawnLocation() + FVector(0, 0, Grid->UIOffset)); Grid->Cursor->SetVisibility(true); UGridMovementComponent *MovementComponent = GridPawn->MovementComponent; if (GridPawn->CanMoveTo(*Tile)) { MovementComponent->CreatePath(*Tile); MovementComponent->ShowPath(); } } } void ANavGridPC::OnEndTileCursorOver(const UNavTileComponent *Tile) { Grid->Cursor->SetVisibility(false); /* Hide the previously shown path */ if (GridPawn) { UGridMovementComponent *MovementComponent = GridPawn->MovementComponent; MovementComponent->HidePath(); } } void ANavGridPC::OnTurnStart(UTurnComponent *Component) { if (Component->GetOwner()->IsA<AGridPawn>()) { GridPawn = Cast<AGridPawn>(Component->GetOwner()); } } void ANavGridPC::OnTurnEnd(UTurnComponent * Component) { GridPawn = NULL; } void ANavGridPC::SetTurnManager(ATurnManager * InTurnManager) { check(InTurnManager); // unregister any delegates from the previous manager if (TurnManager) { TurnManager->OnRoundStart().RemoveDynamic(this, &ANavGridPC::OnRoundStart); TurnManager->OnTurnStart().RemoveDynamic(this, &ANavGridPC::OnTurnStart); TurnManager->OnTurnEnd().RemoveDynamic(this, &ANavGridPC::OnTurnEnd); TurnManager->OnTeamTurnStart().RemoveDynamic(this, &ANavGridPC::OnTeamTurnStart); } TurnManager = InTurnManager; TurnManager->OnRoundStart().AddDynamic(this, &ANavGridPC::OnRoundStart); TurnManager->OnTurnStart().AddDynamic(this, &ANavGridPC::OnTurnStart); TurnManager->OnTurnEnd().AddDynamic(this, &ANavGridPC::OnTurnEnd); TurnManager->OnTeamTurnStart().AddDynamic(this, &ANavGridPC::OnTeamTurnStart); } void ANavGridPC::SetGrid(ANavGrid * InGrid) { check(InGrid); if (Grid) { Grid->OnTileClicked.RemoveDynamic(this, &ANavGridPC::OnTileClicked); Grid->OnTileCursorOver.RemoveDynamic(this, &ANavGridPC::OnTileCursorOver); Grid->OnEndTileCursorOver.RemoveDynamic(this, &ANavGridPC::OnEndTileCursorOver); } Grid = InGrid; Grid->OnTileClicked.AddDynamic(this, &ANavGridPC::OnTileClicked); Grid->OnTileCursorOver.AddDynamic(this, &ANavGridPC::OnTileCursorOver); Grid->OnEndTileCursorOver.AddDynamic(this, &ANavGridPC::OnEndTileCursorOver); }
3,401
C++
.cpp
97
31.814433
91
0.760379
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,610
NavGridPrivatePCH.h
larsjsol_NavGrid/Source/Navgrid/Private/NavGridPrivatePCH.h
#pragma once #include "Engine.h" #include "NavGrid.h" #include "../Classes/NavGrid.h" #include "../Classes/NavTileComponent.h" #include "../Classes/NavLadderComponent.h" #include "../Classes/GridPawn.h" #include "../Classes/GridMovementComponent.h" #include "../Classes/TurnComponent.h" #include "../Classes/TurnManager.h" #include "../Classes/NavTileActor.h" #include "../Classes/NavLadderActor.h" #include "../Classes/NavGridGameMode.h" #include "../Classes/NavGridGameState.h" #include "../Classes/NavGridPC.h"
533
C++
.h
15
33.266667
46
0.737354
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,611
GridPawn.h
larsjsol_NavGrid/Source/Navgrid/Classes/GridPawn.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/Pawn.h" #include "GenericTeamAgentInterface.h" #include "GridMovementComponent.h" #include "GridPawn.generated.h" class UTurnComponent; class UCapsuleComponent; class UArrowComponent; class UNavTileComponent; class ANavGrid; UENUM() enum class EGridPawnState : uint8 { /* it is not this pawns turn */ WaitingForTurn UMETA(DisplayName = "Waiting for turn"), /* Ready for player input */ Ready UMETA(DisplayName = "Ready"), /* Currently performing some sort of action and is not ready for player input */ Busy UMETA(DisplayName = "Busy"), /* Dead */ Dead UMETA(DisplayName = "Dead") }; /** A pawn that can move around on a NavGrid. */ UCLASS() class NAVGRID_API AGridPawn : public APawn, public IGenericTeamAgentInterface { GENERATED_BODY() public: AGridPawn(); virtual void BeginPlay() override; virtual void OnConstruction(const FTransform &Transform) override; // IGenericTeamAgentInterface start virtual void SetGenericTeamId(const FGenericTeamId& InTeamId) override; virtual FGenericTeamId GetGenericTeamId() const override { return TeamId; } // IGenericTeamAgentInterface end protected: UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "NavGrid") FGenericTeamId TeamId; public: UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") USceneComponent *SceneRoot; /** Bounding capsule. Used to check for collisions when spawning and for mouse over events. It should be adjusted so it envelops the entire mesh of the pawn. */ UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") UCapsuleComponent *BoundsCapsule; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") UGridMovementComponent *MovementComponent; UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") UTurnComponent *TurnComponent; /** Collision capsule. Used to check if a pawn will collide with the environment if it moves into a tile. It should be slightly thinner than the pawn and its location along the z-axis determines the height of the obstacles the pawn can step over. */ UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") UCapsuleComponent *MovementCollisionCapsule; /* Shown when the pawn is selected/has its turn */ UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") UStaticMeshComponent *SelectedHighlight; /* An arrow pointing forward */ UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Components") UArrowComponent *Arrow; /* Should this pawn snap to grid at the start of each turn */ UPROPERTY(EditAnyWhere) bool SnapToGrid = true; /* Callend on round start */ UFUNCTION() virtual void OnRoundStart() {} /* Called on turn start for any component */ UFUNCTION() virtual void OnAnyTurnStart(UTurnComponent *InTurnComponent); /* Called on turn start for this pawn */ virtual void OnTurnStart(); /* Called on turn end for any component */ UFUNCTION() virtual void OnAnyTurnEnd(UTurnComponent *InTurnComponent); /* Called on turn end for this pawn */ virtual void OnTurnEnd(); /* Called at turn start for any team */ UFUNCTION() virtual void OnAnyTeamTurnStart(const FGenericTeamId &InTeamId); /* Called at turn start for this pawn's team */ virtual void OnTeamTurnStart() {} /* Called at turn end for any team */ UFUNCTION() virtual void OnAnyTeamTurnEnd(const FGenericTeamId &InTeamId); /* Called at turn end for this pawn's team */ virtual void OnTeamTurnEnd() {} /* Called when done moving */ virtual void OnMoveEnd(); /* Called when any component owner is ready for player or ai input */ UFUNCTION() virtual void OnAnyPawnReadyForInput(UTurnComponent *InTurnComponent); /* Called when this pawn is ready for player or ai input */ virtual void OnPawnReadyForInput() {} /* override this class and implement your own AI here. The default implementation just ends the turn */ virtual void PlayAITurn(); /* Get the current state for this pawn */ UFUNCTION(BlueprintCallable) virtual EGridPawnState GetState() const; /* is this pawn controlled by a human player? */ UPROPERTY(EditAnyWhere, BlueprintReadWrite) bool bHumanControlled; /* can the we request to start our turn now? The turn manager may still deny our request even if this returns true */ virtual bool CanBeSelected(); virtual bool CanMoveTo(const UNavTileComponent & Tile); virtual void MoveTo(const UNavTileComponent & Tile); /* get the tile occupied at the start of this pawns turn */ UFUNCTION(BlueprintCallable) UNavTileComponent *GetTile() const { return MovementComponent->GetTile(); } template <class T> T *GetTile() const { return Cast<T>(GetTile()); } /* Called when the user clicks on this actor, default implementation is to change the the current turn taker to this */ UFUNCTION() virtual void Clicked(AActor *ClickedActor, FKey PressedKey); #if WITH_EDITORONLY_DATA void OnObjectSelectedInEditor(UObject *SelectedObject); protected: UPROPERTY(EditAnyWhere) bool bPreviewTiles = false; UPROPERTY(EditAnyWhere) float PreviewTileSize = 200; FTimerHandle PreviewTimerHandle; void UpdatePreviewTiles(); UPROPERTY(Transient) ANavGrid *PreviewGrid; #endif // WITH_EDITORONLY_DATA };
5,448
C++
.h
131
38.526718
121
0.771721
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,612
ExampleGridPawn.h
larsjsol_NavGrid/Source/Navgrid/Classes/ExampleGridPawn.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/Pawn.h" #include "GridPawn.h" #include "ExampleGridPawn.generated.h" class UStaticMeshComponent; class UArrowComponent; /* ** * A simple pawn used for demonstrating the NavGrid plugin. */ UCLASS() class NAVGRID_API AExampleGridPawn : public AGridPawn { GENERATED_BODY() public: AExampleGridPawn(); /* Just a cone so we can see the pawn */ UPROPERTY(BlueprintReadOnly, EditAnyWhere, Category = "Components") UStaticMeshComponent *StaticMesh = NULL; };
599
C++
.h
20
27.35
110
0.773684
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,614
TurnManager.h
larsjsol_NavGrid/Source/Navgrid/Classes/TurnManager.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/Actor.h" #include "GenericTeamAgentInterface.h" #include "TurnManager.generated.h" class UTurnComponent; //Declare delegates DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTurnStart, UTurnComponent *, TurnComponent); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTurnEnd, UTurnComponent *, TurnComponent); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTeamTurnStart, const FGenericTeamId &, TeamId); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTeamTurnEnd, const FGenericTeamId &, TeamId); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnReadyForInput, UTurnComponent *, TurnComponent); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnRoundStart); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnRoundEnd); /** * Coordinates a set of turn components. * * Terms: * 'Turn' is used for a singe pawn doing a single action. * 'Round' is used for all pawns managed by this turn manager having their Turn. */ UCLASS(BlueprintType, Blueprintable, NotPlaceable) class NAVGRID_API ATurnManager : public AActor { GENERATED_BODY() public: ATurnManager(); virtual void Tick(float DeltaTime) override; /* Add a turn component to be managed */ UFUNCTION(BlueprintCallable) void RegisterTurnComponent(UTurnComponent *TurnComponent); UFUNCTION(BlueprintCallable) void UnregisterTurnComponent(UTurnComponent *TurnComponent); /* minumuim number of teams needed to start a new turn */ UPROPERTY(EditAnyWhere, BlueprintReadWrite) int32 MinNumberOfTeams; /* End the turn for the current turn component */ UFUNCTION(BlueprintCallable) void EndTurn(UTurnComponent *Ender); /* End the turn for all components of the current team */ UFUNCTION(BlueprintCallable) void EndTeamTurn(FGenericTeamId InTeamId); /* request to immediatly start the turn for the supplied component. Return false if the request is denied */ UFUNCTION(BlueprintCallable) void RequestStartTurn(UTurnComponent *CallingComponent); UFUNCTION(BlueprintCallable) void RequestStartNextComponent(UTurnComponent *CallingComponent); UFUNCTION(BlueprintPure) UTurnComponent *GetCurrentComponent() const { return CurrentComponent; } UFUNCTION(BlueprintPure) FGenericTeamId GetCurrentTeam() const; AActor *GetCurrentActor() const; template <class T> T* GetCurrentActor() const { return Cast<T>(GetCurrentActor()); } UFUNCTION(BlueprintPure) int32 GetRound() const { return Round; } protected: // find the next team member that can act this turn UTurnComponent *FindNextTeamMember(const FGenericTeamId &TeamId); UTurnComponent *FindNextComponent(); bool HasComponentsThatCanAct(); private: UPROPERTY(BlueprintAssignable) FOnTurnStart OnTurnStartDelegate; UPROPERTY(BlueprintAssignable) FOnTurnEnd OnTurnEndDelegate; UPROPERTY(BlueprintAssignable) FOnTeamTurnStart OnTeamTurnStartDelegate; UPROPERTY(BlueprintAssignable) FOnTeamTurnEnd OnTeamTurnEndDelegate; UPROPERTY(BlueprintAssignable) FOnReadyForInput OnReadyForInputDelegate; UPROPERTY(BlueprintAssignable) FOnRoundStart OnRoundStartDelegate; UPROPERTY(BlueprintAssignable) FOnRoundEnd OnRoundEndDelegate; public: virtual FOnTurnStart& OnTurnStart() { return OnTurnStartDelegate; } virtual FOnTurnEnd& OnTurnEnd() { return OnTurnEndDelegate; } virtual FOnTeamTurnStart& OnTeamTurnStart() { return OnTeamTurnStartDelegate; } virtual FOnTeamTurnEnd& OnTeamTurnEnd() { return OnTeamTurnEndDelegate; } virtual FOnReadyForInput& OnReadyForInput() { return OnReadyForInputDelegate; } virtual FOnRoundStart& OnRoundStart() { return OnRoundStartDelegate; } virtual FOnRoundEnd& OnRoundEnd() { return OnRoundEndDelegate; } protected: UPROPERTY(VisibleAnyWhere) UTurnComponent *CurrentComponent; UPROPERTY() UTurnComponent *NextComponent; TMultiMap<FGenericTeamId, UTurnComponent *> Teams; UPROPERTY(VisibleAnyWhere) int32 Round; bool bStartNewTurn; };
4,016
C++
.h
94
39.765957
110
0.815404
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,615
GridMovementComponent.h
larsjsol_NavGrid/Source/Navgrid/Classes/GridMovementComponent.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/PawnMovementComponent.h" #include "GridMovementComponent.generated.h" class ANavGrid; class USplineComponent; class USplineMeshComponent; class UStaticMesh; class UNavTileComponent; UENUM(BlueprintType) enum class EGridMovementMode : uint8 { Stationary UMETA(DisplayName = "Stationary"), Walking UMETA(DisplayName = "Walking"), ClimbingUp UMETA(DisplayName = "Climbing up"), ClimbingDown UMETA(DisplayName = "Climbing down"), InPlaceTurn UMETA(DisplayName = "Turn in place"), }; USTRUCT() struct FPathSegment { GENERATED_BODY() FPathSegment() {} FPathSegment(TSet<EGridMovementMode> InMovementModes, float InStart, float InEnd); /* Legal movement modes for this segment */ TSet<EGridMovementMode> MovementModes; /* start and end distance along the path spline this segment covers */ float Start, End; FRotator PawnRotationHint; }; /** * A movement component that operates on a NavGrid */ UCLASS(ClassGroup = Movement, meta = (BlueprintSpawnableComponent)) class NAVGRID_API UGridMovementComponent : public UPawnMovementComponent { GENERATED_BODY() public: UGridMovementComponent(const FObjectInitializer &ObjectInitializer); virtual void BeginPlay() override; virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void StopMovementImmediately() override; protected: /* return an transform usable for following the spline path */ FTransform TransformFromPath(float DeltaTime); /* return an tranfrom usable for rotation in place */ FTransform TransformFromRotation(float DeltaTime); public: void ConsiderUpdateCurrentTile(); protected: /* The tile we're currently on */ UPROPERTY() UNavTileComponent *CurrentTile = NULL; FPathSegment CurrentPathSegment; public: /* Return the tiles that are in range */ void GetTilesInRange(TArray<UNavTileComponent *> &OutTiles); /* Get the tile the pawn is on, returns NULL if the pawn is not on a tile */ UNavTileComponent *GetTile(); ANavGrid *GetNavGrid(); /* How far (in tile cost) the actor can move in one go */ UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Movement") float MovementRange = 4; /* How fast can the actor move when walking*/ UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Movement") float MaxWalkSpeed = 450; /* How fast can the actor move when climbing */ UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Movement") float MaxClimbSpeed = 200; /* How fast can the actor turn */ UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Movement") float MaxRotationSpeed = 720; /* MovementModes usable for this Pawn */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Movement") TSet<EGridMovementMode> AvailableMovementModes; /* Should we ignore rotation over the X axis */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Movement") bool LockRoll = true; /* Should we ignore rotation over the Y axis */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Movement") bool LockPitch = true; /* Should we ignore rotation over the Z axis */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Movement") bool LockYaw = false; /* Should we extract root motion for speed while moving */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Movement") bool bUseRootMotion = true; /* Should we extract root motion for speed and rotation even if we are not moving*/ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Movement") bool bAlwaysUseRootMotion = false; /* Should we straighten out the path to avoid zigzaging */ UPROPERTY(BlueprintReadWrite, EditAnyWhere, Category = "Movement") bool bStringPullPath = true; void StringPull(TArray<const UNavTileComponent *> &InOutPath, TArray<const UNavTileComponent*>& OutPath); /* Spline that is used as a path. The points are in world coords. We use ESplineCoordinateSpace::Local in the getters and setters to avoid any extra coord translation */ UPROPERTY(BlueprintReadOnly, Category = "Visualization") USplineComponent *Spline = NULL; /* Mesh used to visualize the path */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Visualization") UStaticMesh *PathMesh = NULL; /* Distance between actor and where we start showing the path */ UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Visualization") float HorizontalOffset = 87.5; /* Create a path to TargetTile, return false if no path is found */ bool CreatePath(const UNavTileComponent &Target); /* Create a path and follow it if it exists */ bool MoveTo(const UNavTileComponent &Target); /* Turn in place */ void TurnTo(const FRotator &Forward); /* Snap actor the grid */ void SnapToGrid(); /* Advance a given distance along the path */ void AdvanceAlongPath(float InDistance); /* Get the remaining distance of the current path (zero if the pawn is currently not moving) */ float GetRemainingDistance(); /* Use actor rotation for components where we have an rotation locks, use InRotation for the rest */ FRotator ApplyRotationLocks(const FRotator &InRotation); protected: FRotator DesiredForwardRotation; public: /* Visualize path */ void ShowPath(); /* Hide path */ void HidePath(); FTransform ConsumeRootMotion(); EGridMovementMode GetMovementMode() { return MovementMode; } protected: EGridMovementMode MovementMode; void ConsiderUpdateMovementMode(); void ChangeMovementMode(EGridMovementMode NewMode); void FinishMovement(); public: /* Return the point the the pawn will reach if it continues moving for ForwardDistance */ FVector GetForwardLocation(float ForwardDistance); DECLARE_EVENT(UGridMovementComponent, FOnMovementDone); /* Triggered when movement ends */ FOnMovementDone& OnMovementEnd() { return OnMovementEndEvent; } private: FOnMovementDone OnMovementEndEvent; public: DECLARE_EVENT_TwoParams(UGridMovementComponent, FOnMovementModeChanged, EGridMovementMode, EGridMovementMode); /* Triggered when the movement mode changes */ FOnMovementModeChanged& OnMovementModeChanged() { return OnMovementModeChangedEvent; } private: FOnMovementModeChanged OnMovementModeChangedEvent; protected: UPROPERTY() TArray<USplineMeshComponent *> SplineMeshes; /* Helper: Puts a spline mesh in the range along the spline */ void AddSplineMesh(float From, float To); /* How far along the spline are we */ float Distance = 0; private: /* the grid we're currently on. You should get this via GetNavGrid() and avoid using it directly */ UPROPERTY() ANavGrid *CachedNavGrid = NULL; protected: UPROPERTY() UAnimInstance *AnimInstance; /* Return a delta FRotater that is within MaxRotationSpeed */ FRotator LimitRotation(const FRotator &OldRotation, const FRotator &NewRotation, float DeltaTime); /* The rotation of the skeletal mesh (if any). Used to handle root motion rotation */ FRotator MeshRotation; UPROPERTY() TArray<FPathSegment> PathSegments; };
7,211
C++
.h
169
39.60355
128
0.776809
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,616
NavLadderComponent.h
larsjsol_NavGrid/Source/Navgrid/Classes/NavLadderComponent.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "NavTileComponent.h" #include "NavLadderComponent.generated.h" UCLASS(meta = (BlueprintSpawnableComponent)) class NAVGRID_API UNavLadderComponent : public UNavTileComponent { GENERATED_BODY() public: UNavLadderComponent(); virtual void SetGrid(ANavGrid *InGrid) override; virtual FVector GetPawnLocation() const override { return ToWorldSpace(FVector(TileSize / 4, 0, 25)); } virtual void GetNeighbours(const UCapsuleComponent &CollisionCapsule, TArray<UNavTileComponent *> &OutUnObstructed, TArray<UNavTileComponent *> &OutObstructed) override; virtual bool Obstructed(const FVector &FromPos, const UCapsuleComponent &CollisionCapsule) const override; virtual void AddPathSegments(USplineComponent &OutSpline, TArray<FPathSegment> &OutPathSegments, bool EndTile) const override; virtual FVector GetSplineMeshUpVector() override; protected: // local copy of tile ANavGrid::TileSize, value is set in SetGrid() float TileSize; FVector GetTopPathPoint() const { return ToWorldSpace(FVector(TileSize / 4, 0, BoxExtent.Z - 25)); } FVector GetBottomPathPoint() const { return ToWorldSpace(FVector(TileSize / 4, 0, -100)); } FVector ToWorldSpace(const FVector &CompSpace) const { return GetComponentLocation() + GetComponentRotation().RotateVector(CompSpace); } };
1,376
C++
.h
23
58.086957
170
0.811712
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,618
TurnComponent.h
larsjsol_NavGrid/Source/Navgrid/Classes/TurnComponent.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "Components/ActorComponent.h" #include "TurnManager.h" #include "TurnComponent.generated.h" /** * Actors with a turn component can be managed by a turn manager */ UCLASS(meta = (BlueprintSpawnableComponent)) class NAVGRID_API UTurnComponent : public UActorComponent { GENERATED_BODY() public: UTurnComponent(); virtual void BeginPlay() override; virtual void OnComponentDestroyed(bool bDestroyingHierarchy) override; ATurnManager *GetTurnManager(); protected: UPROPERTY() ATurnManager *TurnManager; UFUNCTION() void OnTurnTimeout(); FTimerHandle TurnTimeoutHandle; public: /* The number of actions this pawn can perform in a single round */ UPROPERTY(EditAnyWhere, BlueprintReadWrite) int32 StartingActionPoints; /* Remaining actions that this pawn can perform this round */ UPROPERTY(VisibleAnywhere, BlueprintReadWrite) int32 RemainingActionPoints; /* end this turn after the given amount of time has passed. Set to 0 to disable */ UPROPERTY(VisibleAnyWhere, BlueprintReadWrite) float TurnTimeout; /* Tell the manager to end the turn for this component */ void EndTurn(); void EndTeamTurn(); /* request the turn manager to start a turn for this component */ void RequestStartTurn(); /* request that the turn manager starts the turn for the next component on our team */ void RequestStartNextComponent(); /* Used be the owning actor to notify that it is ready to receive input from a player or ai */ void OwnerReadyForInput(); /* is it this components turn? */ UFUNCTION(BlueprintPure) bool MyTurn() { return IsValid(TurnManager) && TurnManager->GetCurrentComponent() == this; } /* which team this component is a part of */ UFUNCTION(BlueprintPure) FGenericTeamId TeamId() const { return FGenericTeamId::GetTeamIdentifier(GetOwner()); } UFUNCTION(BlueprintPure) AActor *GetCurrentActor() const; template <class T> T *GetCurrentActor() const { return Cast<T>(GetCurrentActor()); } // register with the turn manager in order to get to take turns void RegisterWithTurnManager(); // unregister, this compnent will no longer get to take turns void UnregisterWithTurnManager(); // called by the turn manager void OnTurnStart(); void OnTurnEnd(); };
2,374
C++
.h
60
36.416667
96
0.769332
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,619
NavGridGameState.h
larsjsol_NavGrid/Source/Navgrid/Classes/NavGridGameState.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/GameStateBase.h" #include "GenericTeamAgentInterface.h" #include "TurnManager.h" #include "NavGridGameState.generated.h" class ANavGrid; /** * */ UCLASS() class NAVGRID_API ANavGridGameState : public AGameStateBase { GENERATED_BODY() public: UFUNCTION(BlueprintCallable, Category = "NavGrid") virtual ANavGrid* GetNavGrid(); template <class T> T* GetNavGrid() { return Cast<T>(GetNavGrid()); } UFUNCTION(BlueprintCallable, Category = "NavGrid") virtual ATurnManager* GetTurnManager(); template <class T> T *GetTurnManager() { return Cast<T>(GetTurnManager()); } DECLARE_MULTICAST_DELEGATE_TwoParams(FOnPawnEnterTile, class AGridPawn *, class UNavTileComponent *); FOnPawnEnterTile &OnPawnEnterTile() { return PawnEnterTileDelegate; } private: FOnPawnEnterTile PawnEnterTileDelegate; protected: /* spawn the default turn manager object, override this if you need to modify it */ virtual ATurnManager* SpawnTurnManager(); /* spawn the default navgrid object, override this if you need to modify it */ virtual ANavGrid* SpawnNavGrid(); UPROPERTY() ANavGrid* Grid; UPROPERTY() ATurnManager *TurnManager; };
1,326
C++
.h
38
31.736842
103
0.769352
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,620
NavGrid.h
larsjsol_NavGrid/Source/Navgrid/Classes/NavGrid.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "Engine.h" #include "GameFramework/Actor.h" #include "NavTileComponent.h" #include "GridMovementComponent.h" #include "NavGrid.generated.h" DECLARE_LOG_CATEGORY_EXTERN(NavGrid, Log, All); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTileClicked, const UNavTileComponent*, Tile); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnTileCursorOver, const UNavTileComponent*, Tile); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnEndTileCursorOver, const UNavTileComponent*, Tile); /** * A grid that pawns can move around on. * */ UCLASS() class NAVGRID_API ANavGrid : public AActor { GENERATED_BODY() public: ANavGrid(); /* Collision channel used when tracing for tiles */ static TEnumAsByte<ECollisionChannel> ECC_NavGridWalkable; UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "NavGrid") float TileSize = 200; /* Z-Offset for UI elements */ UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "NavGrid") float UIOffset = 30; /* Should virtual tiles be placed on empty areas */ UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "NavGrid") bool EnableVirtualTiles = false; // Do not place virtual tiles on actors with this tag static FName DisableVirtualTilesTag; // getter for blueprints UFUNCTION(BlueprintPure, Category = "NavGrid") FName GetDisableVirtualTilesTag() { return DisableVirtualTilesTag; } /* Class used for virtual tiles */ UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "NavGrid") TSubclassOf<UNavTileComponent> TileClass; /* Scene Component (root) */ UPROPERTY(EditAnyWhere, BlueprintReadWrite, Category = "Components") USceneComponent *SceneComponent = NULL; /* Cursor for highlighting tiles */ UPROPERTY(BlueprintReadOnly, EditAnyWhere, Category = "Components") UStaticMeshComponent *Cursor; protected: UPROPERTY() TMap<FName, UInstancedStaticMeshComponent *> TileHighlights; TMap<FName, const TCHAR *> TileHighLightPaths; public: void SetTileHighlight(UNavTileComponent &Tile, FName Type); void ClearTileHighlights(); void AddHighlightType(const FName &Type, const TCHAR *FileName); UInstancedStaticMeshComponent *GetHighlightComponent(FName Type); public: /* Number of tiles that exist in the current level */ UPROPERTY(VisibleAnywhere, Category = "NavGrid") int32 NumPersistentTiles = 0; UPROPERTY(EditAnyWhere) int32 MaxVirtualTiles = 10000; UFUNCTION(BlueprintCallable, Category = "NavGrid") static ANavGrid *GetNavGrid(AActor *ActorInWorld); static ANavGrid *GetNavGrid(UWorld *World); /* Get tile from world location, may return NULL */ virtual UNavTileComponent *GetTile(const FVector &WorldLocation, bool FindFloor = true, float UpwardTraceLength = 100, float DownwardTraceLength = 100); protected: UNavTileComponent *LineTraceTile(const FVector &WorldLocation, bool FindFloor, float UpwardTraceLength, float DownwardTraceLength); UNavTileComponent *LineTraceTile(const FVector &Start, const FVector &End); public: void TileClicked(const UNavTileComponent *Tile); void TileCursorOver(const UNavTileComponent *Tile); void EndTileCursorOver(const UNavTileComponent *Tile); protected: /* Do pathfinding and and store all tiles that Pawn can reach in TilesInRange */ virtual void CalculateTilesInRange(AGridPawn *Pawn); public: /* Find all tiles in range. Call CalculateTilesInRange if neccecary */ UFUNCTION(BlueprintCallable, Category = "Pathfinding") void GetTilesInRange(AGridPawn *Pawn, TArray<UNavTileComponent *> &OutTiles); /* Reset all temporary data in all tiles in the world */ UFUNCTION(BlueprintCallable, Category = "Pathfinding") void ClearTiles(); protected: /* Contains tiles found in the last call to CalculateTilesInRange() */ UPROPERTY() TArray<UNavTileComponent *> TilesInRange; /* Latest Pawn passed to CalculcateTilesInRange() */ UPROPERTY() AGridPawn *CurrentPawn; /* Starting Tile for the latest call to CalculcateTilesInRange() */ UPROPERTY() UNavTileComponent *CurrentTile; public: /* Triggered by mouse clicks on tiles*/ UPROPERTY(BlueprintAssignable, Category = "NavGrid") FOnTileClicked OnTileClicked; /* Triggered when the cursor enters a tile */ UPROPERTY(BlueprintAssignable, Category = "NavGrid") FOnTileCursorOver OnTileCursorOver; /* Triggered when the cursor leaves a tile */ UPROPERTY(BlueprintAssignable, Category = "NavGrid") FOnEndTileCursorOver OnEndTileCursorOver; UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Pathfinding") bool TraceTileLocation(const FVector & TraceStart, const FVector & TraceEnd, FVector & OutTilePos); UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Pathfinding") UNavTileComponent *PlaceTile(const FVector &Location, AActor *TileOwner = NULL); UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Pathfinding") UNavTileComponent *ConsiderPlaceTile(const FVector &TraceStart, const FVector &TraceEnd, AActor *TileOwner = NULL); /* Find a place to put a tile that is close to Location and that matches the grid layout */ FVector AdjustToTileLocation(const FVector &Location); protected: UPROPERTY(VisibleAnywhere, Category = "NavGrid") TArray<UNavTileComponent *> VirtualTiles; /* place virtual tiles within the movement range of a pawn */ UFUNCTION(BlueprintCallable, Category = "Pathfinding") void GenerateVirtualTiles(const AGridPawn *Pawn); /* place a single virtual tile under a pawn */ UFUNCTION(BlueprintCallable, Category = "Pathfinding") void GenerateVirtualTile(const AGridPawn *Pawn); void DestroyVirtualTiles(); virtual void Destroyed() override; public: /** return every tile in the supplied world */ static void GetEveryTile(TArray<UNavTileComponent* > &OutTiles, UWorld *World); };
5,893
C++
.h
125
44.016
154
0.787736
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,621
NavGridPC.h
larsjsol_NavGrid/Source/Navgrid/Classes/NavGridPC.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "GameFramework/PlayerController.h" #include "GenericTeamAgentInterface.h" #include "NavGridPC.generated.h" class ANavGrid; class ATurnManager; class UTurnComponent; class AGridPawn; class UNavTileComponent; /** * An example PlayerController that lets you move a single GridPawn by * clicking on a NavGrid */ UCLASS() class NAVGRID_API ANavGridPC : public APlayerController { GENERATED_BODY() public: ANavGridPC(const FObjectInitializer& ObjectInitializer); virtual void BeginPlay() override; UFUNCTION() virtual void OnTileClicked(const UNavTileComponent *Tile); UFUNCTION() virtual void OnTileCursorOver(const UNavTileComponent *Tile); UFUNCTION() virtual void OnEndTileCursorOver(const UNavTileComponent *Tile); /* Called when a new round starts*/ UFUNCTION() virtual void OnRoundStart() {}; /* Called when a new turn starts*/ UFUNCTION() virtual void OnTurnStart(UTurnComponent *Component); /* Called when a turn ends */ UFUNCTION() virtual void OnTurnEnd(UTurnComponent *Component); /* Called at the start of each team turn */ UFUNCTION() virtual void OnTeamTurnStart(const FGenericTeamId &TeamId) {} virtual void SetTurnManager(ATurnManager * InTurnManager); virtual void SetGrid(ANavGrid * InGrid); /* The pawn we're currently controlling */ UPROPERTY(BlueprintReadWrite) AGridPawn *GridPawn; /* The NavGrid in the current game */ UPROPERTY(BlueprintReadWrite) ANavGrid *Grid; /* The TurnManager in the current game */ UPROPERTY(BlueprintReadWrite) ATurnManager *TurnManager; };
1,688
C++
.h
51
30.098039
79
0.779766
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,623
NavTileComponent.h
larsjsol_NavGrid/Source/Navgrid/Classes/NavTileComponent.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "Components/SplineComponent.h" #include "Components/SceneComponent.h" #include "Components/BoxComponent.h" #include "GridMovementComponent.h" #include "NavTileComponent.generated.h" /** * A single tile in a navigation grid */ UCLASS(meta = (BlueprintSpawnableComponent), Blueprintable) class NAVGRID_API UNavTileComponent : public UBoxComponent { GENERATED_BODY() public: UNavTileComponent(); protected: UPROPERTY(Transient) ANavGrid *Grid; public: virtual void SetGrid(ANavGrid *InGrid); ANavGrid* GetGrid() const; // Pathing /* Cost of moving into this tile*/ UPROPERTY(BlueprintReadWrite, EditAnyWhere, Category = "Pathfinding") float Cost = 1; /* Distance from starting point of path */ float Distance; /* Previous tile in path */ UPROPERTY() UNavTileComponent *Backpointer; /* Is this node in the 'visited' set? - Helper var for pathfinding */ bool Visited; /* Rest temporary data (like distance and other vars used in pathfinding) */ virtual void Reset(); /* movement modes that are legal (or make sense) for this tile */ UPROPERTY(EditAnyWhere, BlueprintReadWrite) TSet<EGridMovementMode> MovementModes; /* is there anything blocking an actor from moving from FromPos to this tile? Uses the capsule for collision testing */ virtual bool Obstructed(const FVector &FromPos, const UCapsuleComponent &CollisionCapsule) const; /* is there anything blocking an actor from moving between From and To? Uses the capsule for collision testing */ virtual bool Obstructed(const FVector &From, const FVector &To, const UCapsuleComponent &CollisionCapsule) const; virtual void GetNeighbours(const UCapsuleComponent &CollisionCapsule, TArray<UNavTileComponent *> &OutUnObstructed, TArray<UNavTileComponent *> &OutObstructed); /* Return the neighbours that are not Obstructed() */ void GetUnobstructedNeighbours(const UCapsuleComponent &CollisionCapsule, TArray<UNavTileComponent *> &OutNeighbours); /* Can a pawn traverse this tile? * PawnMovementModes: movement modes availabe for the pawn */ virtual bool Traversable(const TSet<EGridMovementMode> &PawnMovementModes) const; /* Can a pawn end its turn on this tile?*/ virtual bool LegalPositionAtEndOfTurn(const TSet<EGridMovementMode> &PawnMovementModes) const; /* Placement for pawn occupying this tile in world space */ UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Default") virtual FVector GetPawnLocation() const; /* Set offset in local space for pawns occupynig this tile */ UFUNCTION(BlueprintCallable, Category = "Default") void SetPawnLocationOffset(const FVector &Offset); protected: /* Offset in local space for any pawn occupying this tile */ FVector PawnLocationOffset; public: // User interface UFUNCTION() void Clicked(UPrimitiveComponent* TouchedComponent, FKey Key); UFUNCTION() void CursorOver(UPrimitiveComponent* TouchedComponent); UFUNCTION() void EndCursorOver(UPrimitiveComponent* TouchedComponent); UFUNCTION() void TouchEnter(ETouchIndex::Type Type, UPrimitiveComponent* TouchedComponent); UFUNCTION() void TouchLeave(ETouchIndex::Type Type, UPrimitiveComponent* TouchedComponent); UFUNCTION() void TouchEnd(ETouchIndex::Type Type, UPrimitiveComponent* TouchedComponent); /* * Add points for moving into this tile from FromPos * * OutSpline - the spline to add the points to * OutPathSegments - the array we should add our path segment to * EndTile - true if this is the last tile in the path */ virtual void AddPathSegments(USplineComponent &OutSpline, TArray<FPathSegment> &OutPathSegments, bool EndTile) const; /* Return a suitable upvector for a splinemesh moving across this tile */ virtual FVector GetSplineMeshUpVector(); /* Set a highlight for this tile */ virtual void SetHighlight(FName NewHighlightType); /* draw debug information on the screen*/ virtual void DrawDebug(UCapsuleComponent *CollisionCapsule, bool bPersistentLines, float LifeTime, float Thickness); };
4,038
C++
.h
89
43.47191
161
0.802642
larsjsol/NavGrid
101
23
4
LGPL-3.0
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,625
winmain.cpp
savoirfairelinux_jami-daemon/bin/winmain.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <iostream> #include <thread> #include <cstring> #include <signal.h> #include <getopt.h> #include <string> #include <filesystem> #include "jami.h" #include "callmanager_interface.h" #include "configurationmanager_interface.h" #include "presencemanager_interface.h" #ifdef ENABLE_VIDEO #include "videomanager_interface.h" #endif #include "fileutils.h" #include <windows.h> using namespace std::placeholders; bool isActive = false; static int initFlags = 0; bool loop = true; static void print_title() { std::cout << "Jami Core " << libjami::version() << ", by Savoir-faire Linux Inc. Copyright (C) 2004-2024" << std::endl << "https://jami.net/" << std::endl #ifdef ENABLE_VIDEO << "[Video support enabled]" << std::endl #endif #ifdef ENABLE_PLUGIN << "[Plugins support enabled]" << std::endl #endif << std::endl; } static void print_usage() { std::cout << std::endl << "-c, --console \t- Log in console (instead of syslog)" << std::endl << "-d, --debug \t- Debug mode (more verbose)" << std::endl << "-p, --persistent \t- Stay alive after client quits" << std::endl << "--auto-answer \t- Force automatic answer to incoming calls" << std::endl << "-h, --help \t- Print help" << std::endl; } // Parse command line arguments, setting debug options or printing a help // message accordingly. // returns true if we should quit (i.e. help was printed), false otherwise static bool parse_args(int argc, char *argv[], bool& persistent) { int consoleFlag = false; int debugFlag = false; int helpFlag = false; int versionFlag = false; int autoAnswer = false; const struct option long_options[] = { /* These options set a flag. */ {"debug", no_argument, NULL, 'd'}, {"console", no_argument, NULL, 'c'}, {"persistent", no_argument, NULL, 'p'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"auto-answer", no_argument, &autoAnswer, true}, {0, 0, 0, 0} /* Sentinel */ }; while (true) { /* getopt_long stores the option index here. */ int option_index = 0; auto c = getopt_long(argc, argv, "dcphv", long_options, &option_index); // end of the options if (c == -1) break; switch (c) { case 'd': debugFlag = true; break; case 'c': consoleFlag = true; break; case 'p': persistent = true; break; case 'h': case '?': helpFlag = true; break; case 'v': versionFlag = true; break; default: break; } } if (helpFlag) { print_usage(); return true; } if (versionFlag) { // We've always print the title/version, so we can just exit return true; } if (consoleFlag) initFlags |= libjami::LIBJAMI_FLAG_CONSOLE_LOG; if (debugFlag) initFlags |= libjami::LIBJAMI_FLAG_DEBUG; if (autoAnswer) initFlags |= libjami::LIBJAMI_FLAG_AUTOANSWER; return false; } void IncomingCall(const std::string& accountId, const std::string& callId, const std::string& message) { (void) accountId; (void) message; if (not isActive) { libjami::accept(callId); isActive = true; } else libjami::refuse(callId); } static int run() { using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; libjami::init(static_cast<libjami::InitFlag>(initFlags)); std::map<std::string, SharedCallback> callHandlers; callHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCall> (std::bind(&IncomingCall, _1, _2, _3))); registerSignalHandlers(callHandlers); if (!libjami::start()) return -1; while (loop) { Sleep(1000); // milliseconds } libjami::fini(); return 0; } static void interrupt() { loop = false; } static void signal_handler(int code) { std::cerr << "Caught signal " << code << ", terminating..." << std::endl; // Unset signal handlers signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); interrupt(); } int main(int argc, char *argv []) { // Set the program's directory path as the resource directory path. std::filesystem::path programPath(argv[0]); jami::fileutils::set_resource_dir_path(programPath.parent_path()); print_title(); bool persistent = false; if (parse_args(argc, argv, persistent)) return 0; // TODO: Block signals for all threads but the main thread, decide how/if we should // handle other signals signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); return run(); }
5,646
C++
.cpp
186
24.811828
87
0.625461
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,626
osxmain.cpp
savoirfairelinux_jami-daemon/bin/osxmain.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <iostream> #include <thread> #include <cstring> #include <signal.h> #include <getopt.h> #include <string> #include <chrono> #include <filesystem> #include "jami.h" #include "callmanager_interface.h" #include "configurationmanager_interface.h" #include "presencemanager_interface.h" #ifdef ENABLE_VIDEO #include "videomanager_interface.h" #endif #include "fileutils.h" static int initFlags = 0; static void print_title() { std::cout << "Jami Core " << libjami::version() << ", by Savoir-faire Linux Inc. Copyright (C) 2004-2024" << std::endl << "https://jami.net/" << std::endl #ifdef ENABLE_VIDEO << "[Video support enabled]" << std::endl #endif #ifdef ENABLE_PLUGIN << "[Plugins support enabled]" << std::endl #endif << std::endl; } static void print_usage() { std::cout << std::endl << "-c, --console \t- Log in console (instead of syslog)" << std::endl << "-d, --debug \t- Debug mode (more verbose)" << std::endl << "-p, --persistent \t- Stay alive after client quits" << std::endl << "--auto-answer \t- Force automatic answer to incoming calls" << std::endl << "-h, --help \t- Print help" << std::endl; } // Parse command line arguments, setting debug options or printing a help // message accordingly. // returns true if we should quit (i.e. help was printed), false otherwise static bool parse_args(int argc, char *argv[], bool& persistent) { int consoleFlag = false; int debugFlag = false; int helpFlag = false; int versionFlag = false; int autoAnswer = false; const struct option long_options[] = { /* These options set a flag. */ {"debug", no_argument, NULL, 'd'}, {"console", no_argument, NULL, 'c'}, {"persistent", no_argument, NULL, 'p'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, {"auto-answer", no_argument, &autoAnswer, true}, {0, 0, 0, 0} /* Sentinel */ }; while (true) { /* getopt_long stores the option index here. */ int option_index = 0; auto c = getopt_long(argc, argv, "dcphv", long_options, &option_index); // end of the options if (c == -1) break; switch (c) { case 'd': debugFlag = true; break; case 'c': consoleFlag = true; break; case 'p': persistent = true; break; case 'h': case '?': helpFlag = true; break; case 'v': versionFlag = true; break; default: break; } } if (helpFlag) { print_usage(); return true; } if (versionFlag) { // We've always print the title/version, so we can just exit return true; } if (consoleFlag) initFlags |= libjami::LIBJAMI_FLAG_CONSOLE_LOG; if (debugFlag) initFlags |= libjami::LIBJAMI_FLAG_DEBUG; if (autoAnswer) initFlags |= libjami::LIBJAMI_FLAG_AUTOANSWER; return false; } static int osxTests() { using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>; libjami::init(static_cast<libjami::InitFlag>(initFlags)); registerSignalHandlers(std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>>()); if (!libjami::start()) return -1; while (true) { std::this_thread::sleep_for(std::chrono::seconds(1)); } libjami::fini(); } static int run() { osxTests(); return 0; } static void interrupt() {} static void signal_handler(int code) { std::cerr << "Caught signal " << strsignal(code) << ", terminating..." << std::endl; // Unset signal handlers signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); interrupt(); } int main(int argc, char *argv []) { // Set the program's directory path as the resource directory path. std::filesystem::path programPath(argv[0]); jami::fileutils::set_resource_dir_path(programPath.parent_path()); #ifdef TOP_BUILDDIR if (!getenv("CODECS_PATH")) setenv("CODECS_PATH", TOP_BUILDDIR "/src/media/audio/codecs", 1); #endif print_title(); bool persistent = false; if (parse_args(argc, argv, persistent)) return 0; // TODO: Block signals for all threads but the main thread, decide how/if we should // handle other signals signal(SIGINT, signal_handler); signal(SIGHUP, signal_handler); signal(SIGTERM, signal_handler); return run(); }
5,412
C++
.cpp
177
25.016949
99
0.622667
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,627
main.cpp
savoirfairelinux_jami-daemon/bin/dbus/main.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "dbuscallmanager.hpp" #include "dbusconfigurationmanager.hpp" #include "dbusinstance.hpp" #include "dbuspresencemanager.hpp" #ifdef ENABLE_VIDEO #include "dbusvideomanager.hpp" #endif #ifdef ENABLE_PLUGIN #include "dbuspluginmanagerinterface.hpp" #endif #include <sdbus-c++/sdbus-c++.h> #include <jami.h> #include <string.h> #include <csignal> #include <getopt.h> #include <iostream> #include <memory> bool persistent = false; std::unique_ptr<sdbus::IConnection> connection; static int initFlags = 0; static void print_title() { std::cout << "Jami Core " << libjami::version() << ", by Savoir-faire Linux Inc. Copyright (C) 2004-2024" << std::endl << "https://jami.net/" << std::endl #ifdef ENABLE_VIDEO << "[Video support enabled]" << std::endl #endif #ifdef ENABLE_PLUGIN << "[Plugins support enabled]" << std::endl #endif << std::endl; } static void print_usage() { std::cout << std::endl << "-c, --console \t- Log in console (instead of syslog)" << std::endl << "-d, --debug \t- Debug mode (more verbose)" << std::endl << "-p, --persistent \t- Stay alive after client quits" << std::endl << "--auto-answer \t- Force automatic answer to incoming calls" << std::endl << "-h, --help \t- Print help" << std::endl; } // Parse command line arguments, setting debug options or printing a help // message accordingly. // returns true if we should quit (i.e. help was printed), false otherwise static bool parse_args(int argc, char *argv[]) { int consoleFlag = false; int debugFlag = false; int helpFlag = false; int versionFlag = false; int autoAnswer = false; const struct option long_options[] = { /* These options set a flag. */ {"debug", no_argument, nullptr, 'd'}, {"console", no_argument, nullptr, 'c'}, {"persistent", no_argument, nullptr, 'p'}, {"help", no_argument, nullptr, 'h'}, {"version", no_argument, nullptr, 'v'}, {"auto-answer", no_argument, &autoAnswer, true}, {nullptr, 0, nullptr, 0} /* Sentinel */ }; while (true) { /* getopt_long stores the option index here. */ int option_index = 0; auto c = getopt_long(argc, argv, "dcphv:", long_options, &option_index); // end of the options if (c == -1) break; switch (c) { case 'd': debugFlag = true; break; case 'c': consoleFlag = true; break; case 'p': persistent = true; break; case 'h': case '?': helpFlag = true; break; case 'v': versionFlag = true; break; default: break; } } if (helpFlag) { print_usage(); return true; } if (versionFlag) { // We've always print the title/version, so we can just exit return true; } if (consoleFlag) initFlags |= libjami::LIBJAMI_FLAG_CONSOLE_LOG; if (debugFlag) initFlags |= libjami::LIBJAMI_FLAG_DEBUG; if (autoAnswer) initFlags |= libjami::LIBJAMI_FLAG_AUTOANSWER; return false; } static void signal_handler(int code) { // Unset signal handlers signal(SIGINT, SIG_DFL); signal(SIGHUP, SIG_DFL); signal(SIGTERM, SIG_DFL); std::cerr << "Caught signal " << strsignal(code) << ", terminating..." << std::endl; connection->leaveEventLoop(); } int main(int argc, char *argv []) { print_title(); if (parse_args(argc, argv)) return 0; if (!libjami::init(static_cast<libjami::InitFlag>(initFlags))) { std::cerr << "libjami::init() failed" << std::endl; return 1; } try { connection = sdbus::createSessionBusConnection("cx.ring.Ring"); DBusCallManager callManager(*connection); DBusConfigurationManager configurationManager(*connection); DBusInstance instanceManager(*connection); DBusPresenceManager presenceManager(*connection); #ifdef ENABLE_VIDEO DBusVideoManager videoManager(*connection); #endif #ifdef ENABLE_PLUGIN DBusPluginManagerInterface pluginManager(*connection); #endif if (!libjami::start()) { std::cerr << "libjami::start() failed" << std::endl; libjami::unregisterSignalHandlers(); libjami::fini(); return 2; } // TODO: Block signals for all threads but the main thread, decide how/if we should // handle other signals std::signal(SIGINT, signal_handler); std::signal(SIGHUP, signal_handler); std::signal(SIGTERM, signal_handler); std::signal(SIGPIPE, SIG_IGN); connection->enterEventLoop(); libjami::unregisterSignalHandlers(); } catch (const sdbus::Error& ex) { std::cerr << "sdbus exception: " << ex.what() << std::endl; } libjami::fini(); return 0; }
5,963
C++
.cpp
182
26.631868
91
0.608983
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,628
fuzz-msgpack.cpp
savoirfairelinux_jami-daemon/test/fuzzing/fuzz-msgpack.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include "lib/gnutls.h" #include "lib/syslog.h" /* * Reverse channel and data in packed message */ void pack_gnutls_record_recv(msgpack::sbuffer& buf, const ChanneledMessage& msg) { msgpack::packer<msgpack::sbuffer> pk(&buf); pk.pack_array(2); pk.pack_bin(msg.data.size()); pk.pack_bin_body((const char*) msg.data.data(), msg.data.size()); pk.pack(msg.channel); } bool mutate_gnutls_record_recv(ChanneledMessage& msg) { (void)msg; return true; } #include "scenarios/classic-alice-and-bob.h"
1,250
C++
.cpp
37
31.243243
75
0.729685
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,629
fuzz-spam-channel-creation.cpp
savoirfairelinux_jami-daemon/test/fuzzing/fuzz-spam-channel-creation.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include <set> #include <atomic> #include <mutex> #include <thread> #include "connectivity/connectionmanager.h" #include "lib/gnutls.h" #include "lib/utils.h" static std::thread spammer; static gnutls_session_t spamming_session = nullptr; void post_gnutls_init_hook(gnutls_session_t session) { if (not session) { return; } if (spamming_session) { return; } printf("Starting channel spammer...\n"); spamming_session = session; spammer = std::thread([&, session=session]{ std::this_thread::sleep_for(std::chrono::seconds(5)); printf("Starting spamming!\n"); jami::ChannelRequest val; val.name = "sip"; val.state = jami::ChannelRequestState::REQUEST; for (size_t i=0; i<UINT16_MAX; ++i) { if (not spamming_session) { break; } val.channel = i; msgpack::sbuffer buffer1(256); msgpack::pack(buffer1, val); msgpack::sbuffer buffer2(16 + buffer1.size()); msgpack::packer<msgpack::sbuffer> pk(&buffer2); pk.pack_array(2); pk.pack(jami::CONTROL_CHANNEL); pk.pack_bin(buffer1.size()); pk.pack_bin_body((const char*) buffer1.data(), buffer1.size()); gnutls_record_send(session, buffer2.data(), buffer2.size()); std::this_thread::sleep_for(std::chrono::microseconds(1000)); } printf("Stopping spamming!\n"); }); } void pre_gnutls_deinit_hook(gnutls_session_t session) { if (session and session == spamming_session) { spamming_session = nullptr; spammer.join(); printf("Channel spammer killed!\n"); } } #include "scenarios/classic-alice-and-bob.h"
2,828
C++
.cpp
70
29.8
87
0.575924
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,630
syslog.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/syslog.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <syslog.h> #include <stdio.h> #include <cstdlib> #include "lib/supervisor.h" #include "lib/syslog.h" /* Jami */ #include "logger.h" __weak bool syslog_handler(int priority, const char *fmt, va_list ap) { (void)priority; (void)fmt; (void)ap; fflush(NULL); fprintf(stderr, "libfuzz: stop by supervisor log\n"); return false; } BEGIN_WRAPPER(void, vsyslog, int priority, const char* format, va_list ap) { static int priority_threshold = -2; if (-2 == priority_threshold) { const char* str_to_int[] = { [LOG_EMERG] = "EMERG", [LOG_ALERT] = "ALERT", [LOG_CRIT] = "CRIT", [LOG_ERR] = "ERR", [LOG_WARNING] = "WARNING", [LOG_NOTICE] = "NOTICE", [LOG_INFO] = "INFO", [LOG_DEBUG] = "DEBUG" }; const char* supervisor_says = std::getenv(supervisor::env::log); if (nullptr == supervisor_says) { priority_threshold = 0; goto no_threshold; } for (size_t i = 0; i < array_size(str_to_int); ++i) { if (streq(str_to_int[i], supervisor_says)) { priority_threshold = i; break; } } if (priority_threshold < 0) { fprintf(stderr, "libfuzz: Invalid value of SUPERVISOR_LOG `%s`\n", supervisor_says); priority_threshold = -1; } } no_threshold: this_func(priority, format, ap); if (priority <= priority_threshold) { if (not syslog_handler(priority, format, ap)) { exit(supervisor::signal::exit::log); } } } END_WRAPPER();
2,457
C++
.cpp
73
26.726027
96
0.591811
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,631
rand.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/rand.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <stdlib.h> /* * No random! */ void srand(unsigned int seed) { (void) seed; }
811
C++
.cpp
25
30.52
73
0.737245
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,632
sip-fmt.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/sip-fmt.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cassert> #include "lib/sip-fmt.h" SIPFmt::SIPFmt(const std::vector<uint8_t>& data) : isValid_(false) { parse(data); } void SIPFmt::pushBody(char *bytes, size_t len) { for (size_t i=0; i<len; ++i) { body_.emplace_back(bytes[i]); } } void SIPFmt::setField(const std::string& field) { size_t at = field.find_first_of(':'); assert(at != std::string::npos); setFieldValue(field.substr(0, at), field.substr(at + 1)); } void SIPFmt::setFieldValue(const std::string& field, const std::string& value) { std::string fieldLow; fieldLow.reserve(field.size()); for (auto it = field.cbegin(); it != field.cend(); ++it) { fieldLow.push_back(tolower(*it)); } fields_[fieldLow] = value; } const std::string& SIPFmt::getField(const std::string& field) const { static std::string emptyString(""); std::string fieldLow; fieldLow.reserve(field.size()); for (auto it = field.cbegin(); it != field.cend(); ++it) { fieldLow.push_back(tolower(*it)); } try { return fields_.at(fieldLow); } catch (...) { return emptyString; } } const std::vector<uint8_t>& SIPFmt::getBody() { return body_; } void SIPFmt::swapBody(std::vector<uint8_t>& newBody) { body_.swap(newBody); } void SIPFmt::swap(std::vector<uint8_t>& with) { if (not isValid_) { return; } std::vector<uint8_t> data; auto push_str = [&](const std::string& str) { for (auto it = str.cbegin(); it != str.cend(); ++it) { data.emplace_back((uint8_t) *it); } }; auto push_CRLN = [&] { data.emplace_back((uint8_t) '\r'); data.emplace_back((uint8_t) '\n'); }; if (isResponse()) { push_str(version_); data.emplace_back((uint8_t) ' '); push_str(status_); data.emplace_back((uint8_t) ' '); push_str(msg_); push_CRLN(); } else { push_str(method_); data.emplace_back(' '); push_str(URI_); data.emplace_back(' '); push_str(version_); push_CRLN(); } setFieldValue("content-length", std::to_string(body_.size())); for (auto it = fields_.cbegin(); it != fields_.cend(); ++it) { push_str(it->first); data.emplace_back((uint8_t) ':'); data.emplace_back((uint8_t) ' '); push_str(it->second); push_CRLN(); } push_CRLN(); for (auto it = body_.begin(); it != body_.end(); ++it) { data.emplace_back((uint8_t) *it); } data.shrink_to_fit(); data.swap(with); }
3,342
C++
.cpp
118
23.398305
73
0.606326
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,633
gnutls.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/gnutls.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include <cinttypes> #include "lib/gnutls.h" #include "lib/supervisor.h" static FILE* redirect_to = nullptr; static std::atomic<size_t> packet_ID = 0; static void open_redirection(void) { const char* supervisor_says = std::getenv(supervisor::env::tls_out); if (nullptr == supervisor_says) { redirect_to = stderr; } else { redirect_to = fopen(supervisor_says, "w"); assert(redirect_to); } } static void print_channel_msg(const ChanneledMessage& msg, const char* direction, bool mutated, size_t packed_id) { if (nullptr == redirect_to) { open_redirection(); } fprintf(redirect_to, "\n" "================================================================================\n" "#:direction %s #:mut %d #:transport TLS #:channel %" PRIu16 " #:ID %" PRIu64 "\n" "--------------------------------------------------------------------------------\n" "%.*s\n" "================================================================================\n", direction, mutated, msg.channel, packed_id, static_cast<int>(msg.data.size()), msg.data.data()); fflush(redirect_to); } #if 0 static std::map<std::string; static void register_channel(const std::string& name, uint16_t channel) { } #endif __weak bool mutate_gnutls_record_send(ChanneledMessage& msg) { (void) msg; return false; } __weak bool mutate_gnutls_record_recv(ChanneledMessage& msg) { (void) msg; return false; } __weak void pack_gnutls_record_recv(msgpack::sbuffer& buf, const ChanneledMessage& msg) { msgpack::packer<msgpack::sbuffer> pk(&buf); pk.pack_array(2); pk.pack(msg.channel); pk.pack_bin(msg.data.size()); pk.pack_bin_body((const char*) msg.data.data(), msg.data.size()); } __weak void pack_gnutls_record_send(msgpack::sbuffer& buf, const ChanneledMessage& msg) { msgpack::packer<msgpack::sbuffer> pk(&buf); pk.pack_array(2); pk.pack(msg.channel); pk.pack_bin(msg.data.size()); pk.pack_bin_body((const char*) msg.data.data(), msg.data.size()); } BEGIN_WRAPPER(ssize_t, gnutls_record_send, gnutls_session_t session, const void* data, size_t data_size) { if (data_size > 0) { msgpack::unpacker pac {}; msgpack::object_handle oh; pac.reserve_buffer(data_size); memcpy(pac.buffer(), data, data_size); pac.buffer_consumed(data_size); if (pac.next(oh)) { try { auto msg = oh.get().as<ChanneledMessage>(); size_t ID = packet_ID++; bool mutated; print_channel_msg(msg, "TX", false, ID); mutated = mutate_gnutls_record_send(msg); if (not mutated) { goto no_mut; } print_channel_msg(msg, "TX", true, ID); msgpack::sbuffer buf(16 +msg.data.size()); pack_gnutls_record_send(buf, msg); return this_func(session, buf.data(), buf.size()); } catch (...) { } } } no_mut: return this_func(session, data, data_size); } END_WRAPPER(); BEGIN_WRAPPER(ssize_t, gnutls_record_recv, gnutls_session_t session, void* data, size_t data_size) { ssize_t ret = this_func(session, data, data_size); if (ret > 0) { msgpack::unpacker pac {}; msgpack::object_handle oh; pac.reserve_buffer(ret); memcpy(pac.buffer(), data, ret); pac.buffer_consumed(ret); if (pac.next(oh)) { auto msg = oh.get().as<ChanneledMessage>(); size_t ID = packet_ID++; bool mutated; #if 0 if (CONTROL_CHANNEL == msg.channel) { try { msgpack::unpacked result; msgpack::unpack(result, (const char*) msg.data.data(), msg.data.size(), 0); auto obj = result.get(); auto req = obj.as<ChannelRequest>(); if (ChannelRequestState::ACCEPT == req.state) { register_channel(req.name, req.channel); } } catch (...) { } } #endif print_channel_msg(msg, "RX", false, ID); mutated = mutate_gnutls_record_recv(msg); if (not mutated) { goto no_mut; } print_channel_msg(msg, "RX", true, ID); msgpack::sbuffer buf(16 + msg.data.size()); pack_gnutls_record_recv(buf, msg); memcpy(data, buf.data(), buf.size()); /* Respect GNU TLS API! */ assert(buf.size() <= data_size); ret = buf.size(); } } no_mut: return ret; } END_WRAPPER(); __weak void post_gnutls_init_hook(gnutls_session_t session) { (void)session; } __weak void pre_gnutls_deinit_hook(gnutls_session_t session) { (void)session; } BEGIN_WRAPPER(int, gnutls_init, gnutls_session_t * session, unsigned int flags) { int ret; ret = this_func(session, flags); post_gnutls_init_hook(*session); return ret; } END_WRAPPER(); BEGIN_WRAPPER(ssize_t, gnutls_record_recv_seq, gnutls_session_t session, void * data, size_t data_size, unsigned char * seq) { ssize_t ret = this_func(session, data, data_size, seq); if (ret > 0) { msgpack::unpacker pac {}; msgpack::object_handle oh; pac.reserve_buffer(ret); memcpy(pac.buffer(), data, ret); pac.buffer_consumed(ret); if (pac.next(oh)) { auto msg = oh.get().as<ChanneledMessage>(); size_t ID = packet_ID++; bool mutated; print_channel_msg(msg, "RX", false, ID); mutated = mutate_gnutls_record_recv(msg); if (not mutated) { goto no_mut; } print_channel_msg(msg, "RX", true, ID); msgpack::sbuffer buf(16 + msg.data.size()); pack_gnutls_record_recv(buf, msg); memcpy(data, buf.data(), buf.size()); /* Respect GNU TLS API! */ assert(buf.size() <= data_size); ret = buf.size(); } } no_mut: return ret; } END_WRAPPER();
7,300
C++
.cpp
220
24.890909
124
0.545129
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,634
supervisor.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/supervisor.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include "lib/supervisor.h" namespace supervisor { namespace env { const char* log = "SUPERVISOR_LOG"; const char* tls_out = "SUPERVISOR_TLS_OUT"; }; // namespace env }; // namespace supervisor
920
C++
.cpp
23
38.130435
73
0.743274
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,635
dht.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/dht.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #ifdef WIP #include <opendht/dhtrunner.h> #include <opendht/thread_pool.h> #include <opendht/default_types.h> namespace dht { __weak bool mutate_dht_encrypted_ImMessage(ImMessage& msg) { printf("message!\n"); return false; } /* TODO - Is there a way to not tod without the mangled name? Use nm(1) for that. */ BEGIN_METHOD_WRAPPER( _ZN3dht9DhtRunner12putEncryptedENS_4HashILm20EEES2_St10shared_ptrINS_5ValueEESt8functionIFvbRKSt6vectorIS3_INS_4NodeEESaIS9_EEEEb, void, DhtRunner::putEncrypted, InfoHash hash, InfoHash to, std::shared_ptr<Value> value, DoneCallback cb, bool permanent) { if (value->type == ImMessage::TYPE.id) { ImMessage uv = Value::unpack<ImMessage>(value); bool mutated = mutate_dht_encrypted_ImMessage(uv); } this_func(this, hash, to, value, cb, permanent); } END_WRAPPER(); }; #endif
1,620
C++
.cpp
41
35.804878
138
0.72247
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,636
utils.cpp
savoirfairelinux_jami-daemon/test/fuzzing/lib/utils.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <yaml-cpp/yaml.h> #include "lib/utils.h" /* Jami */ #include "jami/account_const.h" #include "jami/jami.h" #include "fileutils.h" #include "manager.h" /* Make GCC quiet about unused functions */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" void wait_for_announcement_of(const std::vector<std::string> accountIDs, std::chrono::seconds timeout) { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::mutex mtx; std::unique_lock lk {mtx}; auto cv = std::make_shared<std::condition_variable>(); auto accountsReady = std::make_shared<std::vector<std::atomic_bool>>(accountIDs.size()); size_t to_be_announced = accountIDs.size(); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [=, accountIDs = std::move(accountIDs)](const std::string& accountID, const std::map<std::string, std::string>& details) { for (size_t i = 0; i < accountIDs.size(); ++i) { if (accountIDs[i] != accountID) { continue; } try { if ("true" != details.at(libjami::Account::VolatileProperties::DEVICE_ANNOUNCED)) { continue; } } catch (const std::out_of_range&) { continue; } accountsReady->at(i) = true; cv->notify_one(); } })); JAMI_DBG("Waiting for %zu account to be announced...", to_be_announced); libjami::registerSignalHandlers(confHandlers); assert(cv->wait_for(lk, timeout, [&] { for (const auto& rdy : *accountsReady) { if (not rdy) { return false; } } return true; })); libjami::unregisterSignalHandlers(); JAMI_DBG("%zu account announced!", to_be_announced); } void wait_for_announcement_of(const std::string& accountId, std::chrono::seconds timeout) { wait_for_announcement_of(std::vector<std::string> {accountId}, timeout); } void wait_for_removal_of(const std::vector<std::string> accounts, std::chrono::seconds timeout) { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::mutex mtx; std::unique_lock lk {mtx}; auto cv = std::make_shared<std::condition_variable>(); auto accountsRemoved = std::make_shared<std::atomic_bool>(false); JAMI_INFO("Removing %zu accounts...", accounts.size()); size_t current = jami::Manager::instance().getAccountList().size(); /* Prevent overflow */ assert(current >= accounts.size()); size_t target = current - accounts.size(); confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::AccountsChanged>( [=, accounts = std::move(accounts)]() { if (jami::Manager::instance().getAccountList().size() <= target) { *accountsRemoved = true; cv->notify_one(); } })); libjami::unregisterSignalHandlers(); libjami::registerSignalHandlers(confHandlers); for (const auto& account : accounts) { jami::Manager::instance().removeAccount(account, true); } assert(cv->wait_for(lk, timeout, [&] { return accountsRemoved->load(); })); libjami::unregisterSignalHandlers(); } void wait_for_removal_of(const std::string& account, std::chrono::seconds timeout) { wait_for_removal_of(std::vector<std::string> {account}, timeout); } std::map<std::string, std::string> load_actors(const std::filesystem::path& from_yaml) { std::map<std::string, std::string> actors {}; std::map<std::string, std::string> default_details = libjami::getAccountTemplate("RING"); std::ifstream file(from_yaml); assert(file.is_open()); YAML::Node node = YAML::Load(file); assert(node.IsMap()); auto default_account = node["default-account"]; if (default_account.IsMap()) { for (const auto& kv : default_account) { default_details["Account." + kv.first.as<std::string>()] = kv.second.as<std::string>(); } } auto accounts = node["accounts"]; assert(accounts.IsMap()); for (const auto& kv : accounts) { auto account_name = kv.first.as<std::string>(); auto account = kv.second.as<YAML::Node>(); auto details = std::map<std::string, std::string>(default_details); for (const auto& detail : account) { details["Account." + detail.first.as<std::string>()] = detail.second.as<std::string>(); } actors[account_name] = jami::Manager::instance().addAccount(details); } return actors; } std::map<std::string, std::string> load_actors_and_wait_for_announcement(const std::string& from_yaml) { auto actors = load_actors(std::filesystem::path(from_yaml)); std::vector<std::string> wait_for; wait_for.reserve(actors.size()); for (auto it = actors.cbegin(); it != actors.cend(); ++it) { wait_for.emplace_back(it->second); } wait_for_announcement_of(wait_for); return actors; } #pragma GCC diagnostic pop
6,081
C++
.cpp
148
33.777027
101
0.630863
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,637
fuzz-msgpack.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-msgpack.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include "lib/gnutls.h" #include "lib/syslog.h" /* * Reverse channel and data in packed message */ void pack_gnutls_record_recv(msgpack::sbuffer& buf, const ChanneledMessage& msg) { msgpack::packer<msgpack::sbuffer> pk(&buf); #if 0 pk.pack_array(2); pk.pack_bin(msg.data.size()); pk.pack_bin_body((const char*) msg.data.data(), msg.data.size()); pk.pack(msg.channel); #else pk.pack_array(1); pk.pack(msg.channel); #endif } bool mutate_gnutls_record_recv(ChanneledMessage& msg) { (void)msg; return true; }
1,271
C++
.cpp
41
28.439024
75
0.72186
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,638
fuzz-random-over-tls.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-random-over-tls.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <atomic> #include <chrono> #include <condition_variable> #include <mutex> #include <memory> #include <thread> #include "lib/gnutls.h" static gnutls_session_t captured_session = nullptr; static std::mutex worker_lock {}; static std::condition_variable cv {}; __attribute__((constructor)) static void init(void) { std::thread([&] { std::unique_lock lock(worker_lock); cv.wait(lock); size_t max_size = gnutls_record_get_max_size(captured_session); void *payload = NULL; while (true) { size_t size = (size_t)rand() % max_size; payload = realloc(payload, size); printf("Spamming random payload of %zu bytes...\n", size); gnutls_record_send(captured_session, payload, size); std::this_thread::sleep_for(std::chrono::milliseconds(200)); } }).detach(); } void post_gnutls_init_hook(const gnutls_session_t session) { if (nullptr == captured_session) { captured_session = session; cv.notify_one(); } }
1,908
C++
.cpp
53
29.264151
80
0.636364
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,639
fuzz-channel.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-channel.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include <set> #include "connectivity/multiplexed_socket.h" #include "lib/gnutls.h" #if 0 static std::set<uint16_t> known_channel {}; static std::vector<channel __attribute__((constructor)) static void channel_spammer(void) { std::thread([&]{ std::unique_lock ulock(spammer_lock); while (true) { } }).detach(); } /* * Mangle channel */ bool mutate_gnutls_record_recv(ChanneledMessage& msg) { known_channel.emplace(msg.channel); auto it = known_channel.begin(); std::advance(it, rand() % known_channel.size()); msg.channel = *it; return true; } #endif
1,387
C++
.cpp
45
27.266667
73
0.698795
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,640
fuzz-sdp-huge-body.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-sdp-huge-body.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include "lib/gnutls.h" #include "lib/sip-fmt.h" /* * Example that will try to overflow the SDP parser. */ bool mutate_gnutls_record_send(ChanneledMessage& msg) { static size_t body_repeat = 1; SIPFmt sip(msg.data); /* Only SIP request */ if (not sip.isRequest()) { return false; } /* Skip none SDP Content-Type */ if (not sip.isApplication("media_control+xml")) { return false; } auto body = sip.getBody(); std::vector<uint8_t> newBody; newBody.reserve(body_repeat * body.size()); for (size_t i=0; i<body_repeat; ++i) { for (auto it=body.cbegin(); it!=body.cend(); ++it) { newBody.emplace_back(*it); } } sip.swapBody(newBody); body_repeat *= 2; /* Commit changes! */ sip.swap(msg.data); return true; }
1,587
C++
.cpp
49
28.061224
73
0.666885
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,641
fuzz-channel-request.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-channel-request.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include <set> #include <msgpack.hpp> #include "connectivity/multiplexed_socket.h" #include "lib/gnutls.h" enum class ChannelRequestState { REQUEST, ACCEPT, DECLINE, }; /** * That msgpack structure is used to request a new channel (id, name) * Transmitted over the TLS socket */ struct ChannelRequest { std::string name {}; uint16_t channel {0}; ChannelRequestState state {ChannelRequestState::REQUEST}; MSGPACK_DEFINE(name, channel, state) }; /* * Mangle channel */ bool mutate_gnutls_record_send(ChanneledMessage& msg) { try { msgpack::unpacked result; msgpack::unpack(result, (const char*) msg.data.data(), msg.data.size(), 0); auto object = result.get(); auto req = object.as<ChannelRequest>(); int state = rand() % 8; static_assert(sizeof(state) == sizeof(req.state)); memcpy(&req.state, &state, sizeof(state)); msgpack::sbuffer buffer(512); msgpack::pack(buffer, req); msg.data.clear(); for (size_t i=0; i<buffer.size(); ++i) { msg.data.emplace_back(buffer.data()[i]); } } catch (...) { return false; } return true; } MSGPACK_ADD_ENUM(ChannelRequestState);
2,113
C++
.cpp
63
27.31746
91
0.638957
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,642
fuzz-libfuzz.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-libfuzz.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include "lib/gnutls.h" static gnutls_session_t captured_tls_session = nullptr; void post_gnutls_init_hook(const gnutls_session_t session) { captured_tls_session = session; }
905
C++
.cpp
22
38.863636
73
0.750569
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,643
fuzz-jami-version.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-jami-version.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <atomic> #include <chrono> #include <condition_variable> #include <mutex> #include <memory> #include <thread> #include "lib/gnutls.h" /* Jami */ #include "connectivity/multiplexed_socket.h" static gnutls_session_t captured_session = nullptr; static std::mutex worker_lock {}; static std::condition_variable cv; struct VersionMsg { int v; MSGPACK_DEFINE_MAP(v) }; __attribute__((constructor)) static void init(void) { std::thread([&] { msgpack::sbuffer buffer(8); { msgpack::packer<msgpack::sbuffer> pk(&buffer); pk.pack(VersionMsg {rand()}); } msgpack::sbuffer buffer2(16 + buffer.size()); { msgpack::packer<msgpack::sbuffer> pk(&buffer2); pk.pack_array(2); pk.pack(jami::PROTOCOL_CHANNEL); pk.pack_bin(buffer2.size()); pk.pack_bin_body(buffer2.data(), buffer2.size()); } std::unique_lock lock(worker_lock); cv.wait(lock); while (true) { gnutls_record_send(captured_session, buffer2.data(), buffer2.size()); std::this_thread::sleep_for(std::chrono::milliseconds(200)); } }).detach(); } void post_gnutls_init_hook(const gnutls_session_t session) { if (nullptr == captured_session) { captured_session = session; cv.notify_one(); } }
2,287
C++
.cpp
67
26.492537
89
0.607434
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,644
fuzz-sip-huge-message.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-sip-huge-message.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include "lib/gnutls.h" #include "lib/sip-fmt.h" /* * Example that will try to overflow the SDP parser. */ bool mutate_gnutls_record_send(ChanneledMessage& msg) { static size_t body_repeat = 1; SIPFmt sip(msg.data); /* Only SIP request */ if (not sip.isRequest()) { return false; } /* Skip none SDP Content-Type */ if (std::string::npos == sip.getField("content-type").find("text/plain")) { return false; } auto body = sip.getBody(); std::vector<uint8_t> newBody; newBody.reserve(body_repeat * body.size()); for (size_t i=0; i<body_repeat; ++i) { for (auto it=body.cbegin(); it!=body.cend(); ++it) { newBody.emplace_back(*it); } } sip.swapBody(newBody); body_repeat *= 2; /* Commit changes! */ sip.swap(msg.data); return true; }
1,613
C++
.cpp
49
28.591837
79
0.664732
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,645
fuzz-sdp-bad-body.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-sdp-bad-body.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include "lib/gnutls.h" #include "lib/sip-fmt.h" /* * Example that will try to overflow the SDP parser. */ bool mutate_gnutls_record_send(ChanneledMessage& msg) { SIPFmt sip(msg.data); /* Only SIP request */ if (not sip.isRequest()) { return false; } /* Skip none SDP Content-Type */ if (not sip.isApplication("sdp")) { return false; } char payload[] = "@"; sip.pushBody(payload, 1); /* Commit changes! */ sip.swap(msg.data); return true; }
1,253
C++
.cpp
40
28.05
73
0.696844
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,646
fuzz-sip-version.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-sip-version.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include "lib/gnutls.h" #include "lib/sip-fmt.h" /* * Example fuzzing wrapper that will change the SIP version sent randomly * between 1.0 and 2.0 */ bool mutate_gnutls_record_send(ChanneledMessage& msg) { static int version_cnt = 0; SIPFmt sip(msg.data); if (not sip.isValid()) { return false; } char version[] = "SIP/2.0"; char version_fmt[] = "SIP/%d.0"; snprintf(version, array_size(version), version_fmt, (version_cnt++ % 2) + 1); sip.setVersion(version); /* Commit changes! */ sip.swap(msg.data); return true; }
1,336
C++
.cpp
40
30.075
73
0.698289
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,647
fuzz-sip-html.cpp
savoirfairelinux_jami-daemon/test/fuzzing/examples/fuzz-sip-html.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include "lib/gnutls.h" #include "lib/sip-fmt.h" /* * Insert a HTML payload in a SIP request if no content-type */ bool mutate_gnutls_record_send(ChanneledMessage& msg) { SIPFmt sip(msg.data); if (not sip.isRequest()) { return false; } if (not sip.getField("content-type").empty()) { return false; } char htmlBody[] = "<html><h1>FUZZ</h1></html>\n"; std::vector<uint8_t> body; body.reserve(array_size(htmlBody)); for (size_t i=0; i<array_size(htmlBody); ++i) { body.emplace_back(htmlBody[i]); } sip.swapBody(body); sip.setFieldValue("content-type", "text/html"); /* Commit changes! */ sip.swap(msg.data); return true; }
1,457
C++
.cpp
44
29.477273
73
0.689016
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,648
test_SIP.cpp
savoirfairelinux_jami-daemon/test/sip/test_SIP.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cstdlib> #include <cstdio> #include <iostream> #include <fstream> #include <pthread.h> #include <string> #include <thread> #include "test_SIP.h" #include "call_const.h" using namespace jami; using namespace std::literals; static pthread_mutex_t count_mutex; static pthread_cond_t count_nb_thread; static int counter = 0; CPPUNIT_TEST_SUITE_REGISTRATION(test_SIP); /* return an error if all call are not successful */ void* sippThreadWithCount(void* str) { // number of time we use the mutex. Lock the utilisation of counter pthread_mutex_lock(&count_mutex); counter++; pthread_mutex_unlock(&count_mutex); // display what is send on the parameter of the method std::string* command = (std::string*) (str); std::cout << "test_SIP: " << command << std::endl; // Set up the sipp instance in this thread in order to catch return value // 0: All calls were successful // 1: At least one call failed // 97: exit on internal command. Calls may have been processed // 99: Normal exit without calls processed // -1: Fatal error // -2: Fatal error binding a socket int i = system(command->c_str()); // c_str() retrieve the *char of the string CPPUNIT_ASSERT(i); pthread_mutex_lock(&count_mutex); counter--; // ??? if (counter == 0) pthread_cond_signal(&count_nb_thread); pthread_mutex_unlock(&count_mutex); pthread_exit(NULL); } RAIIThread sippThread(const std::string& command) { return std::thread([command] { std::cout << "test_SIP: " << command << std::endl; // Set up the sipp instance in this thread in order to catch return value // 0: All calls were successful // 1: At least one call failed // 97: exit on internal command. Calls may have been processed // 99: Normal exit without calls processed // -1: Fatal error // -2: Fatal error binding a socket auto ret = system(command.c_str()); std::cout << "test_SIP: Command executed by system returned: " << ret << std::endl; }); } void test_SIP::setUp() { std::cout << "setup test SIP" << std::endl; pthread_mutex_lock(&count_mutex); counter = 0; pthread_mutex_unlock(&count_mutex); running_ = true; eventLoop_ = RAIIThread(std::thread([this] { while (running_) { std::this_thread::sleep_for(std::chrono::milliseconds(50)); } })); } void test_SIP::tearDown() { running_ = false; eventLoop_.join(); // in order to stop any currently running threads std::cout << "test_SIP: Clean all remaining sipp instances" << std::endl; int ret = system("killall sipp"); if (ret) std::cout << "test_SIP: Error from system call, killall sipp" << ", ret=" << ret << '\n'; Manager::instance().callFactory.clear(); } void test_SIP::testSIPURI() { std::cout << ">>>> test SIPURI <<<< " << '\n'; auto foo = sip_utils::stripSipUriPrefix("<sip:17771234567@callcentric.com>"sv); CPPUNIT_ASSERT_EQUAL("17771234567"sv, foo); }
3,800
C++
.cpp
111
30.153153
91
0.669575
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,649
sip.cpp
savoirfairelinux_jami-daemon/test/sip/sip.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/ui/text/TestRunner.h> #include <cppunit/extensions/TestFactoryRegistry.h> #include <cppunit/CompilerOutputter.h> #include "jami.h" #include <stdexcept> void init_daemon() { libjami::init(libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); libjami::start("test/unitTest/jami-sample.yml"); } int main() { init_daemon(); CppUnit::TextUi::TestRunner runner; // Register all tests auto& registry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); // Use a compiler error format outputter for results and output into stderr runner.setOutputter(new CppUnit::CompilerOutputter(&runner.result(), std::cerr )); bool ret; try { // Run tests ret = !runner.run("", false); } catch (const std::exception& e) { std::cerr << "Exception catched during tests: " << e.what() << '\n'; ret = 1; } libjami::fini(); return ret; }
1,712
C++
.cpp
46
33.630435
102
0.709794
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,650
common.cpp
savoirfairelinux_jami-daemon/test/unitTest/common.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <yaml-cpp/yaml.h> #include "common.h" /* Jami */ #include "account_const.h" #include "jami.h" #include "fileutils.h" #include "manager.h" /* Make GCC quiet about unused functions */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" void wait_for_announcement_of(const std::vector<std::string> accountIDs, std::chrono::seconds timeout) { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::vector<std::atomic_bool> accountsReady(accountIDs.size()); size_t to_be_announced = accountIDs.size(); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&, accountIDs = std::move(accountIDs)](const std::string& accountID, const std::map<std::string, std::string>& details) { for (size_t i = 0; i < accountIDs.size(); ++i) { if (accountIDs[i] != accountID) { continue; } if (jami::Manager::instance().getAccount(accountID)->getAccountType() == "SIP") { auto daemonStatus = details.at(libjami::Account::ConfProperties::Registration::STATUS); if (daemonStatus != "REGISTERED") { continue; } } else { try { if ("true" != details.at(libjami::Account::VolatileProperties::DEVICE_ANNOUNCED)) { continue; } } catch (const std::out_of_range&) { continue; } } accountsReady[i] = true; cv.notify_one(); } })); JAMI_DBG("Waiting for %zu account to be announced...", to_be_announced); libjami::registerSignalHandlers(confHandlers); CPPUNIT_ASSERT(cv.wait_for(lk, timeout, [&] { for (const auto& rdy : accountsReady) { if (not rdy) { return false; } } return true; })); libjami::unregisterSignalHandlers(); JAMI_DBG("%zu account announced!", to_be_announced); } void wait_for_announcement_of(const std::string& accountId, std::chrono::seconds timeout) { wait_for_announcement_of(std::vector<std::string> {accountId}, timeout); } void wait_for_removal_of(const std::vector<std::string> accounts, std::chrono::seconds timeout) { JAMI_INFO("Removing %zu accounts...", accounts.size()); std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::atomic_bool accountsRemoved {false}; size_t current = jami::Manager::instance().getAccountList().size(); /* Prevent overflow */ CPPUNIT_ASSERT(current >= accounts.size()); size_t target = current - accounts.size(); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::AccountsChanged>([&]() { if (jami::Manager::instance().getAccountList().size() <= target) { accountsRemoved = true; cv.notify_one(); } })); libjami::unregisterSignalHandlers(); libjami::registerSignalHandlers(confHandlers); for (const auto& account : accounts) { jami::Manager::instance().removeAccount(account, true); } CPPUNIT_ASSERT(cv.wait_for(lk, timeout, [&] { return accountsRemoved.load(); })); libjami::unregisterSignalHandlers(); } void wait_for_removal_of(const std::string& account, std::chrono::seconds timeout) { wait_for_removal_of(std::vector<std::string>{account}, timeout); } std::map<std::string, std::string> load_actors(const std::filesystem::path& from_yaml) { std::map<std::string, std::string> actors {}; std::ifstream file(from_yaml); CPPUNIT_ASSERT(file.is_open()); YAML::Node node = YAML::Load(file); CPPUNIT_ASSERT(node.IsMap()); auto default_account = node["default-account"]; std::map<std::string, std::string> default_details = libjami::getAccountTemplate(default_account["type"].as<std::string>()); if (default_account.IsMap()) { for (const auto& kv : default_account) { auto key = kv.first.as<std::string>(); if (default_details.find(key) != default_details.end()) { default_details[key] = kv.second.as<std::string>(); } else { default_details["Account." + key] = kv.second.as<std::string>(); } } } auto accounts = node["accounts"]; CPPUNIT_ASSERT(accounts.IsMap()); for (const auto& kv : accounts) { auto account_name = kv.first.as<std::string>(); auto account = kv.second.as<YAML::Node>(); auto details = std::map<std::string, std::string>(default_details); for (const auto& detail : account) { auto key = detail.first.as<std::string>(); if (details.find(key) != details.end()) { details[key] = detail.second.as<std::string>(); } else { details["Account." + key] = detail.second.as<std::string>(); } } actors[account_name] = jami::Manager::instance().addAccount(details); } return actors; } std::map<std::string, std::string> load_actors_and_wait_for_announcement(const std::string& from_yaml) { auto actors = load_actors(from_yaml); std::vector<std::string> wait_for; wait_for.reserve(actors.size()); for (auto it = actors.cbegin(); it != actors.cend(); ++it) { wait_for.emplace_back(it->second); } wait_for_announcement_of(wait_for); return actors; } #pragma GCC diagnostic pop
6,991
C++
.cpp
172
31.790698
128
0.601684
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,651
scheduler.cpp
savoirfairelinux_jami-daemon/test/unitTest/scheduler.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include "test_runner.h" #include "scheduled_executor.h" #include <opendht/rng.h> namespace jami { namespace test { class SchedulerTest : public CppUnit::TestFixture { public: static std::string name() { return "scheduler"; } private: void schedulerTest(); CPPUNIT_TEST_SUITE(SchedulerTest); CPPUNIT_TEST(schedulerTest); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(SchedulerTest, SchedulerTest::name()); void SchedulerTest::schedulerTest() { jami::ScheduledExecutor executor("test"); constexpr unsigned N = 1024; std::mutex mtx; std::condition_variable cv; std::unique_lock lk(mtx); std::atomic_uint64_t taskRun {0}; std::atomic_uint64_t result {0}; auto task = [&]{ auto rng = dht::crypto::getSeededRandomEngine(); uint64_t sum {0}; for (uint64_t i=0; i<64 * N; i++) sum += rng(); result += sum; std::lock_guard l(mtx); if (++taskRun == N) cv.notify_all(); }; CPPUNIT_ASSERT(taskRun == 0); for (unsigned i=0; i<N; i++) executor.run(task); CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(30), [&]{ return taskRun == N; })); for (unsigned i=0; i<N; i++) executor.scheduleIn(task, std::chrono::microseconds(1)); CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(30), [&]{ return taskRun == 2 * N; })); for (unsigned i=0; i<N; i++) executor.scheduleIn(task, std::chrono::microseconds(1)); executor.stop(); } }} // namespace jami::test RING_TEST_RUNNER(jami::test::SchedulerTest::name());
2,464
C++
.cpp
70
30.8
76
0.674105
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,652
ice_sdp_parser.cpp
savoirfairelinux_jami-daemon/test/unitTest/ice/ice_sdp_parser.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <string> #include "manager.h" #include "sip/sipaccount.h" #include "../../test_runner.h" #include "jami.h" #include "media_const.h" #include "call_const.h" #include "account_const.h" #include "sip/sipcall.h" #include "media/audio/audio_rtp_session.h" #include "media/audio/audio_receive_thread.h" #include "media/video/video_rtp_session.h" #include "media/video/video_receive_thread.h" #include "common.h" using namespace libjami::Account; using namespace libjami::Call; namespace jami { namespace test { struct CallData { struct Signal { Signal(const std::string& name, const std::string& event = {}) : name_(std::move(name)) , event_(std::move(event)) {}; std::string name_ {}; std::string event_ {}; }; std::string accountId_ {}; std::string userName_ {}; uint16_t listeningPort_ {0}; std::string alias_ {}; std::string callId_ {}; std::vector<Signal> signals_; std::condition_variable cv_ {}; std::mutex mtx_; bool compliancyEnabled_ {false}; }; // Used to register a MediaFrame observer to RTP session in order // to validate the media stream. class MediaReceiver : public Observer<std::shared_ptr<MediaFrame>> { public: MediaReceiver(MediaType type) : mediaType_(type) , mediaTypeStr_(type == MediaType::MEDIA_AUDIO ? "AUDIO" : "VIDEO") {}; virtual ~MediaReceiver() {}; void update(Observable<std::shared_ptr<jami::MediaFrame>>* observer, const std::shared_ptr<jami::MediaFrame>& mediaframe) override; bool waitForMediaFlow(); const MediaType mediaType_ {MediaType::MEDIA_NONE}; const std::string mediaTypeStr_ {}; const std::chrono::seconds TIME_OUT {10}; const unsigned REQUIRED_FRAME_COUNT {100}; private: unsigned long frameCounter_ {0}; std::condition_variable cv_ {}; std::mutex mtx_; }; void MediaReceiver::update(Observable<std::shared_ptr<jami::MediaFrame>>*, const std::shared_ptr<jami::MediaFrame>& frame) { std::unique_lock lock {mtx_}; if (frame and frame->getFrame()) frameCounter_++; if (frameCounter_ % 10 == 1) { JAMI_INFO("[%s] Frame counter %lu", mediaTypeStr_.c_str(), frameCounter_); } if (frameCounter_ >= REQUIRED_FRAME_COUNT) cv_.notify_one(); } bool MediaReceiver::waitForMediaFlow() { std::unique_lock lock {mtx_}; return cv_.wait_for(lock, TIME_OUT, [this] { return frameCounter_ > 100; }); } class IceSdpParsingTest : public CppUnit::TestFixture { public: IceSdpParsingTest() { // Init daemon libjami::init(libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); for (size_t idx = 0; idx < MEDIA_COUNT; idx++) { mediaReceivers_.emplace_back(std::make_shared<MediaReceiver>(MediaType::MEDIA_AUDIO)); } } ~IceSdpParsingTest() { libjami::fini(); } static std::string name() { return "IceSdpParsingTest"; } void setUp(); void tearDown(); private: // Test cases. void call_with_rfc5245_compliancy_disabled(); void call_with_rfc5245_compliancy_enabled(); CPPUNIT_TEST_SUITE(IceSdpParsingTest); CPPUNIT_TEST(call_with_rfc5245_compliancy_disabled); CPPUNIT_TEST(call_with_rfc5245_compliancy_enabled); CPPUNIT_TEST_SUITE_END(); // Event/Signal handlers static void onCallStateChange(const std::string& accountId, const std::string& callId, const std::string& state, CallData& callData); static void onIncomingCallWithMedia(const std::string& accountId, const std::string& callId, const std::vector<libjami::MediaMap> mediaList, CallData& callData); static void onMediaNegotiationStatus(const std::string& callId, const std::string& event, CallData& callData); // Helpers void test_call(); static void configureTest(CallData& bob, CallData& alice); static std::string getUserAlias(const std::string& callId); // Wait for a signal from the callbacks. Some signals also report the event that // triggered the signal a like the StateChange signal. static bool waitForSignal(CallData& callData, const std::string& signal, const std::string& expectedEvent = {}); static bool attachReceiver(std::shared_ptr<MediaReceiver> receiver, std::shared_ptr<RtpSession> rtpStream); static bool detachReceiver(std::shared_ptr<MediaReceiver> receiver, std::shared_ptr<RtpSession> rtpStream); private: CallData aliceData_; CallData bobData_; const size_t MEDIA_COUNT {2}; std::vector<std::shared_ptr<MediaReceiver>> mediaReceivers_; }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(IceSdpParsingTest, IceSdpParsingTest::name()); void IceSdpParsingTest::setUp() { aliceData_.listeningPort_ = 5080; std::map<std::string, std::string> details = libjami::getAccountTemplate("SIP"); details[ConfProperties::TYPE] = "SIP"; details[ConfProperties::DISPLAYNAME] = "ALICE"; details[ConfProperties::ALIAS] = "ALICE"; details[ConfProperties::LOCAL_PORT] = std::to_string(aliceData_.listeningPort_); details[ConfProperties::UPNP_ENABLED] = "false"; aliceData_.accountId_ = Manager::instance().addAccount(details); bobData_.listeningPort_ = 5082; details = libjami::getAccountTemplate("SIP"); details[ConfProperties::TYPE] = "SIP"; details[ConfProperties::DISPLAYNAME] = "BOB"; details[ConfProperties::ALIAS] = "BOB"; details[ConfProperties::LOCAL_PORT] = std::to_string(bobData_.listeningPort_); details[ConfProperties::UPNP_ENABLED] = "false"; bobData_.accountId_ = Manager::instance().addAccount(details); JAMI_INFO("Initialize accounts ..."); auto aliceAccount = Manager::instance().getAccount<SIPAccount>(aliceData_.accountId_); auto bobAccount = Manager::instance().getAccount<SIPAccount>(bobData_.accountId_); } void IceSdpParsingTest::tearDown() { JAMI_INFO("Remove created accounts..."); wait_for_removal_of({aliceData_.accountId_, bobData_.accountId_}); } std::string IceSdpParsingTest::getUserAlias(const std::string& callId) { auto call = Manager::instance().getCallFromCallID(callId); if (not call) { JAMI_WARN("Call [%s] does not exist!", callId.c_str()); return {}; } auto const& account = call->getAccount().lock(); if (not account) { return {}; } return account->getAccountDetails()[ConfProperties::ALIAS]; } void IceSdpParsingTest::onIncomingCallWithMedia(const std::string& accountId, const std::string& callId, const std::vector<libjami::MediaMap> mediaList, CallData& callData) { CPPUNIT_ASSERT_EQUAL(callData.accountId_, accountId); JAMI_INFO("Signal [%s] - user [%s] - call [%s] - media count [%lu]", libjami::CallSignal::IncomingCallWithMedia::name, callData.alias_.c_str(), callId.c_str(), mediaList.size()); // NOTE. // We shouldn't access shared_ptr<Call> as this event is supposed to mimic // the client, and the client have no access to this type. But here, we only // needed to check if the call exists. This is the most straightforward and // reliable way to do it until we add a new API (like hasCall(id)). if (not Manager::instance().getCallFromCallID(callId)) { JAMI_WARN("Call [%s] does not exist!", callId.c_str()); callData.callId_ = {}; return; } std::unique_lock lock {callData.mtx_}; callData.callId_ = callId; callData.signals_.emplace_back(CallData::Signal(libjami::CallSignal::IncomingCallWithMedia::name)); callData.cv_.notify_one(); } void IceSdpParsingTest::onCallStateChange(const std::string&, const std::string& callId, const std::string& state, CallData& callData) { auto call = Manager::instance().getCallFromCallID(callId); if (not call) { JAMI_WARN("Call [%s] does not exist!", callId.c_str()); return; } auto account = call->getAccount().lock(); if (not account) { JAMI_WARN("Account owning the call [%s] does not exist!", callId.c_str()); return; } JAMI_INFO("Signal [%s] - user [%s] - call [%s] - state [%s]", libjami::CallSignal::StateChange::name, callData.alias_.c_str(), callId.c_str(), state.c_str()); if (account->getAccountID() != callData.accountId_) return; { std::unique_lock lock {callData.mtx_}; callData.signals_.emplace_back( CallData::Signal(libjami::CallSignal::StateChange::name, state)); } if (state == "CURRENT" or state == "OVER" or state == "HUNGUP") { callData.cv_.notify_one(); } } void IceSdpParsingTest::onMediaNegotiationStatus(const std::string& callId, const std::string& event, CallData& callData) { auto call = Manager::instance().getCallFromCallID(callId); if (not call) { JAMI_WARN("Call [%s] does not exist!", callId.c_str()); return; } auto account = call->getAccount().lock(); if (not account) { JAMI_WARN("Account owning the call [%s] does not exist!", callId.c_str()); return; } JAMI_INFO("Signal [%s] - user [%s] - call [%s] - state [%s]", libjami::CallSignal::MediaNegotiationStatus::name, account->getAccountDetails()[ConfProperties::ALIAS].c_str(), call->getCallId().c_str(), event.c_str()); if (account->getAccountID() != callData.accountId_) return; { std::unique_lock lock {callData.mtx_}; callData.signals_.emplace_back( CallData::Signal(libjami::CallSignal::MediaNegotiationStatus::name, event)); } callData.cv_.notify_one(); } bool IceSdpParsingTest::waitForSignal(CallData& callData, const std::string& expectedSignal, const std::string& expectedEvent) { const std::chrono::seconds TIME_OUT {30}; std::unique_lock lock {callData.mtx_}; // Combined signal + event (if any). std::string sigEvent(expectedSignal); if (not expectedEvent.empty()) sigEvent += "::" + expectedEvent; JAMI_INFO("[%s] is waiting for [%s] signal/event", callData.alias_.c_str(), sigEvent.c_str()); auto res = callData.cv_.wait_for(lock, TIME_OUT, [&] { // Search for the expected signal in list of received signals. for (auto it = callData.signals_.begin(); it != callData.signals_.end(); it++) { // The predicate is true if the signal names match, and if the // expectedEvent is not empty, the events must also match. if (it->name_ == expectedSignal and (expectedEvent.empty() or it->event_ == expectedEvent)) { // Done with this signal. callData.signals_.erase(it); return true; } } // Signal/event not found. return false; }); if (not res) { JAMI_ERR("[%s] waiting for signal/event [%s] timed-out!", callData.alias_.c_str(), sigEvent.c_str()); JAMI_INFO("[%s] currently has the following signals:", callData.alias_.c_str()); for (auto const& sig : callData.signals_) { JAMI_INFO() << "Signal [" << sig.name_ << (sig.event_.empty() ? "" : ("::" + sig.event_)) << "]"; } } return res; } bool IceSdpParsingTest::attachReceiver(std::shared_ptr<MediaReceiver> mediaReceiver, std::shared_ptr<RtpSession> rtpSession) { CPPUNIT_ASSERT(mediaReceiver); CPPUNIT_ASSERT(mediaReceiver->mediaType_ == MediaType::MEDIA_AUDIO or mediaReceiver->mediaType_ == MediaType::MEDIA_VIDEO); if (mediaReceiver->mediaType_ == MediaType::MEDIA_AUDIO) { auto audioRtp = std::dynamic_pointer_cast<AudioRtpSession>(rtpSession); auto receiver = audioRtp->getAudioReceive().get(); CPPUNIT_ASSERT(receiver != nullptr); if (receiver == nullptr) return false; return receiver->attach(mediaReceiver.get()); } auto videoRtp = std::dynamic_pointer_cast<video::VideoRtpSession>(rtpSession); auto receiver = videoRtp->getVideoReceive().get(); CPPUNIT_ASSERT(receiver != nullptr); return receiver->attach(mediaReceiver.get()); } bool IceSdpParsingTest::detachReceiver(std::shared_ptr<MediaReceiver> mediaReceiver, std::shared_ptr<RtpSession> rtpSession) { CPPUNIT_ASSERT(mediaReceiver); CPPUNIT_ASSERT(mediaReceiver->mediaType_ == MediaType::MEDIA_AUDIO or mediaReceiver->mediaType_ == MediaType::MEDIA_VIDEO); if (mediaReceiver->mediaType_ == MediaType::MEDIA_AUDIO) { auto audioRtp = std::dynamic_pointer_cast<AudioRtpSession>(rtpSession); auto receiver = audioRtp->getAudioReceive().get(); CPPUNIT_ASSERT(receiver != nullptr); return receiver->detach(mediaReceiver.get()); } auto videoRtp = std::dynamic_pointer_cast<video::VideoRtpSession>(rtpSession); auto receiver = videoRtp->getVideoReceive().get(); CPPUNIT_ASSERT(receiver != nullptr); return receiver->detach(mediaReceiver.get()); } void IceSdpParsingTest::configureTest(CallData& aliceData, CallData& bobData) { { CPPUNIT_ASSERT(not aliceData.accountId_.empty()); auto const& account = Manager::instance().getAccount<SIPAccount>(aliceData.accountId_); aliceData.userName_ = account->getAccountDetails()[ConfProperties::USERNAME]; aliceData.alias_ = account->getAccountDetails()[ConfProperties::ALIAS]; account->setLocalPort(aliceData.listeningPort_); account->enableIceCompIdRfc5245Compliance(aliceData.compliancyEnabled_); } { CPPUNIT_ASSERT(not bobData.accountId_.empty()); auto const& account = Manager::instance().getAccount<SIPAccount>(bobData.accountId_); bobData.userName_ = account->getAccountDetails()[ConfProperties::USERNAME]; bobData.alias_ = account->getAccountDetails()[ConfProperties::ALIAS]; account->setLocalPort(bobData.listeningPort_); account->enableIceCompIdRfc5245Compliance(bobData.compliancyEnabled_); } std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> signalHandlers; // Insert needed signal handlers. signalHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string& accountId, const std::string& callId, const std::string&, const std::vector<libjami::MediaMap> mediaList) { auto user = getUserAlias(callId); if (not user.empty()) onIncomingCallWithMedia(accountId, callId, mediaList, user == aliceData.alias_ ? aliceData : bobData); })); signalHandlers.insert( libjami::exportable_callback<libjami::CallSignal::StateChange>([&](const std::string& accountId, const std::string& callId, const std::string& state, signed) { auto user = getUserAlias(callId); if (not user.empty()) onCallStateChange(accountId, callId, state, user == aliceData.alias_ ? aliceData : bobData); })); signalHandlers.insert(libjami::exportable_callback<libjami::CallSignal::MediaNegotiationStatus>( [&](const std::string& callId, const std::string& event, const std::vector<std::map<std::string, std::string>>& /* mediaList */) { auto user = getUserAlias(callId); if (not user.empty()) onMediaNegotiationStatus(callId, event, user == aliceData.alias_ ? aliceData : bobData); })); libjami::registerSignalHandlers(signalHandlers); } void IceSdpParsingTest::test_call() { configureTest(aliceData_, bobData_); JAMI_INFO("=== Start a call and validate ==="); // NOTE: // We use two audio media instead of one audio and one video media // to be able to run the test on machines that do not have access to // camera. // For this specific UT, testing with two audio media is valid, because // the main goal is to validate that the media sockets negotiated // through ICE can correctly exchange media (RTP packets). MediaAttribute media_0(MediaType::MEDIA_AUDIO); media_0.label_ = "audio_0"; media_0.enabled_ = true; MediaAttribute media_1(MediaType::MEDIA_AUDIO); media_1.label_ = "audio_1"; media_1.enabled_ = true; std::vector<MediaAttribute> offer; offer.emplace_back(media_0); offer.emplace_back(media_1); std::vector<MediaAttribute> answer; answer.emplace_back(media_0); answer.emplace_back(media_1); CPPUNIT_ASSERT_EQUAL(MEDIA_COUNT, offer.size()); CPPUNIT_ASSERT_EQUAL(MEDIA_COUNT, answer.size()); auto bobAddr = dhtnet::ip_utils::getLocalAddr(AF_INET); bobAddr.setPort(bobData_.listeningPort_); aliceData_.callId_ = libjami::placeCallWithMedia(aliceData_.accountId_, bobAddr.toString(true), MediaAttribute::mediaAttributesToMediaMaps( offer)); CPPUNIT_ASSERT(not aliceData_.callId_.empty()); JAMI_INFO("ALICE [%s] started a call with BOB [%s] and wait for answer", aliceData_.accountId_.c_str(), bobData_.accountId_.c_str()); // Give it some time to ring std::this_thread::sleep_for(std::chrono::seconds(2)); // Wait for call to be processed. CPPUNIT_ASSERT( waitForSignal(aliceData_, libjami::CallSignal::StateChange::name, StateEvent::RINGING)); // Wait for incoming call signal. CPPUNIT_ASSERT(waitForSignal(bobData_, libjami::CallSignal::IncomingCallWithMedia::name)); // Answer the call. libjami::acceptWithMedia(bobData_.accountId_, bobData_.callId_, MediaAttribute::mediaAttributesToMediaMaps(answer)); // Wait for media negotiation complete signal. CPPUNIT_ASSERT(waitForSignal(bobData_, libjami::CallSignal::MediaNegotiationStatus::name, libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS)); // Wait for the StateChange signal. CPPUNIT_ASSERT( waitForSignal(bobData_, libjami::CallSignal::StateChange::name, StateEvent::CURRENT)); JAMI_INFO("BOB answered the call [%s]", bobData_.callId_.c_str()); // Wait for media negotiation complete signal. CPPUNIT_ASSERT(waitForSignal(aliceData_, libjami::CallSignal::MediaNegotiationStatus::name, libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS)); // Give some time to media to start. std::this_thread::sleep_for(std::chrono::seconds(2)); // Register the media observer to validate media flow. CPPUNIT_ASSERT_EQUAL(MEDIA_COUNT, mediaReceivers_.size()); auto call = std::dynamic_pointer_cast<SIPCall>( Manager::instance().getCallFromCallID(aliceData_.callId_)); CPPUNIT_ASSERT(call); auto rtpList = call->getRtpSessionList(); CPPUNIT_ASSERT(rtpList.size() == offer.size()); for (size_t i = 0; i < MEDIA_COUNT; i++) { CPPUNIT_ASSERT(rtpList[i]); CPPUNIT_ASSERT(rtpList[i]->getMediaType() == offer[i].type_); CPPUNIT_ASSERT(attachReceiver(mediaReceivers_[i], rtpList[i])); } // NOTE: // This validation step works on hosts/containers that have correctly // configured sound system. // Currenty hosts/containers used for testing are not setup to capture // and playback audio, so this validation will be disabled for now. #if 0 JAMI_INFO("Waiting for media to flow ..."); for (size_t i = 0; i < MEDIA_COUNT; i++) { CPPUNIT_ASSERT(mediaReceivers_[i]->waitForMediaFlow()); } #endif // Detach the observers. for (size_t i = 0; i < MEDIA_COUNT; i++) { CPPUNIT_ASSERT(detachReceiver(mediaReceivers_[i], rtpList[i])); } // Bob hang-up. JAMI_INFO("Hang up BOB's call and wait for ALICE to hang up"); Manager::instance().hangupCall(bobData_.accountId_, bobData_.callId_); CPPUNIT_ASSERT_EQUAL(true, waitForSignal(aliceData_, libjami::CallSignal::StateChange::name, StateEvent::HUNGUP)); CPPUNIT_ASSERT_EQUAL(true, waitForSignal(bobData_, libjami::CallSignal::StateChange::name, StateEvent::HUNGUP)); JAMI_INFO("Call terminated on both sides"); } void IceSdpParsingTest::call_with_rfc5245_compliancy_disabled() { JAMI_INFO("=== Begin test %s ===", __FUNCTION__); aliceData_.compliancyEnabled_ = bobData_.compliancyEnabled_ = false; test_call(); } void IceSdpParsingTest::call_with_rfc5245_compliancy_enabled() { JAMI_INFO("=== Begin test %s ===", __FUNCTION__); aliceData_.compliancyEnabled_ = bobData_.compliancyEnabled_ = true; test_call(); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::IceSdpParsingTest::name())
23,616
C++
.cpp
538
34.760223
106
0.622845
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,653
call.cpp
savoirfairelinux_jami-daemon/test/unitTest/call/call.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include "manager.h" #include "jamidht/jamiaccount.h" #include "sip/sipcall.h" #include "sip/siptransport.h" #include "../../test_runner.h" #include "jami.h" #include "account_const.h" #include "account_schema.h" #include "media_const.h" #include "call_const.h" #include "common.h" #include <dhtnet/connectionmanager.h> #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <filesystem> #include <string> using namespace libjami::Account; using namespace libjami::Call::Details; using namespace std::literals::chrono_literals; namespace jami { namespace test { class CallTest : public CppUnit::TestFixture { public: CallTest() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); } ~CallTest() { libjami::fini(); } static std::string name() { return "Call"; } void setUp(); void tearDown(); std::string aliceId; std::string bobId; std::string bob2Id; std::string carlaId; private: void testCall(); void testCachedCall(); void testStopSearching(); void testDeclineMultiDevice(); void testTlsInfosPeerCertificate(); void testSocketInfos(); void testInvalidTurn(); void testTransfer(); void testDhtPublicInCall(); CPPUNIT_TEST_SUITE(CallTest); CPPUNIT_TEST(testCall); CPPUNIT_TEST(testCachedCall); CPPUNIT_TEST(testStopSearching); CPPUNIT_TEST(testDeclineMultiDevice); CPPUNIT_TEST(testTlsInfosPeerCertificate); CPPUNIT_TEST(testSocketInfos); CPPUNIT_TEST(testInvalidTurn); CPPUNIT_TEST(testTransfer); CPPUNIT_TEST(testDhtPublicInCall); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(CallTest, CallTest::name()); void CallTest::setUp() { auto actors = load_actors_and_wait_for_announcement("actors/alice-bob-carla.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; carlaId = actors["carla"]; } void CallTest::tearDown() { auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); if (bob2Id.empty()) { wait_for_removal_of({aliceId, bobId, carlaId}); } else { wait_for_removal_of({aliceId, bobId, carlaId, bob2Id}); } } void CallTest::testCall() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool callReceived {false}; std::atomic<int> callStopped {0}; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string&, const std::string&, const std::string&, const std::vector<std::map<std::string, std::string>>&) { callReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callReceived.load(); })); JAMI_INFO("Stop call between alice and Bob"); callStopped = 0; Manager::instance().hangupCall(aliceId, call); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped == 2; })); } void CallTest::testCachedCall() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto bobDeviceId = DeviceId(std::string(bobAccount->currentDeviceId())); auto aliceUri = aliceAccount->getUsername(); // Pin certificate from one to another certstore (because we do not perform any DHT operation in this test) bobAccount->certStore().pinCertificate(aliceAccount->identity().second); aliceAccount->certStore().pinCertificate(bobAccount->identity().second); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool callReceived {false}, successfullyConnected {false}; std::atomic<int> callStopped {0}; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string&, const std::string&, const std::string&, const std::vector<std::map<std::string, std::string>>&) { callReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Connect Alice's device and Bob's device"); aliceAccount->connectionManager() .connectDevice(bobDeviceId, "sip", [&cv, &successfullyConnected](std::shared_ptr<dhtnet::ChannelSocket> socket, const DeviceId&) { if (socket) successfullyConnected = true; cv.notify_one(); }); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return successfullyConnected.load(); })); JAMI_INFO("Start call between alice and Bob"); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callReceived.load(); })); callStopped = 0; JAMI_INFO("Stop call between alice and Bob"); Manager::instance().hangupCall(aliceId, call); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped == 2; })); } void CallTest::testStopSearching() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); Manager::instance().sendRegister(bobId, false); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool callStopped {false}; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") { callStopped = true; cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); // Bob not there, so we should get a SEARCHING STATUS JAMI_INFO("Wait OVER state"); // Then wait for the DHT no answer. this can take some times CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(60), [&] { return callStopped.load(); })); } void CallTest::testDeclineMultiDevice() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; // Add second device for Bob std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); wait_for_announcement_of(bob2Id); std::atomic<int> callReceived {0}; std::atomic<int> callStopped {0}; std::string callIdBob; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string& accountId, const std::string& callId, const std::string&, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId) callIdBob = callId; callReceived += 1; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") callStopped++; cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); auto bobAccount2 = Manager::instance().getAccount<JamiAccount>(bob2Id); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return callReceived == 2 && !callIdBob.empty(); })); JAMI_INFO("Stop call between alice and Bob"); callStopped = 0; Manager::instance().refuseCall(bobId, callIdBob); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped.load() >= 3; /* >= because there is subcalls */ })); } void CallTest::testTlsInfosPeerCertificate() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic<int> callStopped {0}; std::string bobCallId; std::string aliceCallState; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string& accountId, const std::string& callId, const std::string&, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId) bobCallId = callId; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string& accountId, const std::string&, const std::string& state, signed) { if (accountId == aliceId) aliceCallState = state; if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return !bobCallId.empty(); })); Manager::instance().answerCall(bobId, bobCallId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return aliceCallState == "CURRENT"; })); auto call = std::dynamic_pointer_cast<SIPCall>(aliceAccount->getCall(callId)); auto* transport = call->getTransport(); CPPUNIT_ASSERT(transport); auto cert = transport->getTlsInfos().peerCert; CPPUNIT_ASSERT(cert && cert->issuer); CPPUNIT_ASSERT(cert->issuer->getId().toString() == bobAccount->getUsername()); JAMI_INFO("Stop call between alice and Bob"); callStopped = 0; Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped == 2; })); } void CallTest::testSocketInfos() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic<int> callStopped {0}; std::string bobCallId; std::string aliceCallState; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string& accountId, const std::string& callId, const std::string&, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId) bobCallId = callId; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string& accountId, const std::string&, const std::string& state, signed) { if (accountId == aliceId) aliceCallState = state; if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); auto mediaReady = false; confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::MediaNegotiationStatus>( [&](const std::string& callId, const std::string& event, const std::vector<std::map<std::string, std::string>>&) { if (event == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS) { mediaReady = true; cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return !bobCallId.empty(); })); Manager::instance().answerCall(bobId, bobCallId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return aliceCallState == "CURRENT" && mediaReady; })); JAMI_INFO("Detail debug"); auto details = libjami::getCallDetails(aliceId, callId); for (auto i = details.begin(); i != details.end(); i++) { JAMI_INFO("%s : %s", i->first.c_str(), i->second.c_str()); } auto call = std::dynamic_pointer_cast<SIPCall>(aliceAccount->getCall(callId)); auto transport = call->getIceMedia(); CPPUNIT_ASSERT(transport); CPPUNIT_ASSERT(transport->isRunning()); CPPUNIT_ASSERT(transport->link().c_str() == details[libjami::Call::Details::SOCKETS]); JAMI_INFO("Stop call between alice and Bob"); callStopped = 0; Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped == 2; })); } void CallTest::testInvalidTurn() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool callReceived {false}; std::atomic<int> callStopped {0}; bool aliceReady = false; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string&, const std::string&, const std::string&, const std::vector<std::map<std::string, std::string>>&) { callReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string& accountId, const std::map<std::string, std::string>& details) { if (accountId != aliceId) { return; } try { aliceReady |= accountId == aliceId && details.at(jami::Conf::CONFIG_ACCOUNT_REGISTRATION_STATUS) == "REGISTERED" && details.at(libjami::Account::VolatileProperties::DEVICE_ANNOUNCED) == "true"; } catch (const std::out_of_range&) {} cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); std::map<std::string, std::string> details; details[ConfProperties::TURN::SERVER] = "1.1.1.1"; aliceReady = false; libjami::setAccountDetails(aliceId, details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return aliceReady; })); JAMI_INFO("Start call between alice and Bob"); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return callReceived.load(); })); JAMI_INFO("Stop call between alice and Bob"); callStopped = 0; Manager::instance().hangupCall(aliceId, call); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped == 2; })); } void CallTest::testTransfer() { // Alice call Bob // Bob transfer to Carla auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool bobCallReceived {false}; std::atomic_bool carlaCallReceived {false}; std::atomic<int> bobCallStopped {0}; std::atomic<int> aliceCallStopped {0}; std::string bobCallId; std::string carlaCallId; std::string carlaCallPeer; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string& accountId, const std::string& callId, const std::string& peerId, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId) { bobCallReceived = true; bobCallId = callId; } else if (accountId == carlaId) { carlaCallReceived = true; carlaCallId = callId; carlaCallPeer = peerId; string_replace(carlaCallPeer, "@ring.dht", ""); } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string& accountId, const std::string&, const std::string& state, signed) { if (state == "OVER") { if (accountId == bobId) { bobCallStopped += 1; cv.notify_one(); } if (accountId == aliceId) { aliceCallStopped += 1; cv.notify_one(); } } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return bobCallReceived.load(); })); JAMI_INFO("Bob transfer to Carla"); libjami::transfer(bobId, bobCallId, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return bobCallStopped.load(); })); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return carlaCallReceived.load(); })); CPPUNIT_ASSERT(carlaCallPeer == aliceUri); JAMI_INFO("Stop call between alice and carla"); aliceCallStopped = 0; Manager::instance().hangupCall(carlaId, carlaCallId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return aliceCallStopped.load(); })); } void CallTest::testDhtPublicInCall() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool callReceived {false}; std::atomic<int> callStopped {0}; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string&, const std::string&, const std::string&, const std::vector<std::map<std::string, std::string>>&) { callReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); std::map<std::string, std::string> details; details["DHT.PublicInCalls"] = "FALSE"; libjami::setAccountDetails(bobId, details); JAMI_INFO("Start call between alice and Bob"); auto call = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(!cv.wait_for(lk, 15s, [&] { return callReceived.load(); })); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::CallTest::name())
24,125
C++
.cpp
561
35.593583
112
0.643636
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,654
conference.cpp
savoirfairelinux_jami-daemon/test/unitTest/call/conference.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <string> #include "manager.h" #include "client/videomanager.h" #include "jamidht/jamiaccount.h" #include "../../test_runner.h" #include "jami.h" #include "account_const.h" #include "common.h" #include "media_const.h" #include "media/video/sinkclient.h" #include "sip/sipcall.h" #include "sip/siptransport.h" #include <dhtnet/connectionmanager.h> using namespace libjami::Account; using namespace std::literals::chrono_literals; namespace jami { namespace test { struct CallData { std::string callId {}; std::string state {}; std::string device {}; std::string streamId {}; std::string hostState {}; std::atomic_bool moderatorMuted {false}; std::atomic_bool raisedHand {false}; std::atomic_bool active {false}; std::atomic_bool recording {false}; void reset() { callId = ""; state = ""; device = ""; streamId = ""; hostState = ""; moderatorMuted = false; active = false; raisedHand = false; recording = false; } }; class ConferenceTest : public CppUnit::TestFixture { public: ConferenceTest() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); } ~ConferenceTest() { libjami::fini(); } static std::string name() { return "Conference"; } void setUp(); void tearDown(); private: void testGetConference(); void testModeratorMuteUpdateParticipantsInfos(); void testUnauthorizedMute(); void testAudioVideoMutedStates(); void testMuteStatusAfterAdd(); void testCreateParticipantsSinks(); void testMuteStatusAfterRemove(); void testActiveStatusAfterRemove(); void testHandsUp(); void testPeerLeaveConference(); void testJoinCallFromOtherAccount(); void testDevices(); void testUnauthorizedSetActive(); void testHangup(); void testIsConferenceParticipant(); void testAudioConferenceConfInfo(); void testHostAddRmSecondVideo(); void testParticipantAddRmSecondVideo(); void testPropagateRecording(); void testBrokenParticipantAudioAndVideo(); void testBrokenParticipantAudioOnly(); void testAudioOnlyLeaveLayout(); void testRemoveConferenceInOneOne(); CPPUNIT_TEST_SUITE(ConferenceTest); CPPUNIT_TEST(testGetConference); CPPUNIT_TEST(testModeratorMuteUpdateParticipantsInfos); CPPUNIT_TEST(testUnauthorizedMute); CPPUNIT_TEST(testAudioVideoMutedStates); CPPUNIT_TEST(testMuteStatusAfterAdd); CPPUNIT_TEST(testCreateParticipantsSinks); CPPUNIT_TEST(testMuteStatusAfterRemove); CPPUNIT_TEST(testActiveStatusAfterRemove); CPPUNIT_TEST(testHandsUp); CPPUNIT_TEST(testPeerLeaveConference); CPPUNIT_TEST(testJoinCallFromOtherAccount); CPPUNIT_TEST(testDevices); CPPUNIT_TEST(testUnauthorizedSetActive); CPPUNIT_TEST(testHangup); CPPUNIT_TEST(testIsConferenceParticipant); CPPUNIT_TEST(testAudioConferenceConfInfo); CPPUNIT_TEST(testHostAddRmSecondVideo); CPPUNIT_TEST(testParticipantAddRmSecondVideo); CPPUNIT_TEST(testPropagateRecording); CPPUNIT_TEST(testBrokenParticipantAudioAndVideo); CPPUNIT_TEST(testBrokenParticipantAudioOnly); CPPUNIT_TEST(testAudioOnlyLeaveLayout); CPPUNIT_TEST(testRemoveConferenceInOneOne); CPPUNIT_TEST_SUITE_END(); // Common parts std::string aliceId; std::atomic_bool hostRecording {false}; std::string bobId; std::string carlaId; std::string daviId; std::string confId {}; std::mutex pInfosMtx_ {}; std::vector<std::map<std::string, std::string>> pInfos_ {}; bool confChanged {false}; CallData bobCall {}; CallData carlaCall {}; CallData daviCall {}; std::mutex mtx; std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; void registerSignalHandlers(); void startConference(bool audioOnly = false, bool addDavi = false); void hangupConference(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConferenceTest, ConferenceTest::name()); void ConferenceTest::setUp() { auto actors = load_actors_and_wait_for_announcement("actors/alice-bob-carla-davi.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; carlaId = actors["carla"]; daviId = actors["davi"]; bobCall.reset(); carlaCall.reset(); daviCall.reset(); confId = {}; confChanged = false; hostRecording = false; } void ConferenceTest::tearDown() { wait_for_removal_of({aliceId, bobId, carlaId, daviId}); } void ConferenceTest::registerSignalHandlers() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto aliceUri = aliceAccount->getUsername(); auto bobUri = bobAccount->getUsername(); auto carlaUri = carlaAccount->getUsername(); auto daviUri = daviAccount->getUsername(); std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [=](const std::string& accountId, const std::string& callId, const std::string&, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId) { bobCall.callId = callId; } else if (accountId == carlaId) { carlaCall.callId = callId; } else if (accountId == daviId) { daviCall.callId = callId; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [=](const std::string& accountId, const std::string& callId, const std::string& state, signed) { if (accountId == aliceId) { auto details = libjami::getCallDetails(aliceId, callId); if (details["PEER_NUMBER"].find(bobUri) != std::string::npos) bobCall.hostState = state; else if (details["PEER_NUMBER"].find(carlaUri) != std::string::npos) carlaCall.hostState = state; else if (details["PEER_NUMBER"].find(daviUri) != std::string::npos) daviCall.hostState = state; } else if (bobCall.callId == callId) bobCall.state = state; else if (carlaCall.callId == callId) carlaCall.state = state; else if (daviCall.callId == callId) daviCall.state = state; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::ConferenceCreated>( [=](const std::string&, const std::string&, const std::string& conferenceId) { confId = conferenceId; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::ConferenceRemoved>( [=](const std::string&, const std::string& conferenceId) { if (confId == conferenceId) confId = ""; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::ConferenceChanged>( [=](const std::string&, const std::string& conferenceId, const std::string&) { if (confId == conferenceId) confChanged = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::OnConferenceInfosUpdated>( [=](const std::string&, const std::vector<std::map<std::string, std::string>> participantsInfos) { std::lock_guard lock(pInfosMtx_); pInfos_ = participantsInfos; for (const auto& infos : participantsInfos) { if (infos.at("uri").find(bobUri) != std::string::npos) { bobCall.active = infos.at("active") == "true"; bobCall.recording = infos.at("recording") == "true"; bobCall.moderatorMuted = infos.at("audioModeratorMuted") == "true"; bobCall.raisedHand = infos.at("handRaised") == "true"; bobCall.device = infos.at("device"); bobCall.streamId = infos.at("sinkId"); } else if (infos.at("uri").find(carlaUri) != std::string::npos) { carlaCall.active = infos.at("active") == "true"; carlaCall.recording = infos.at("recording") == "true"; carlaCall.moderatorMuted = infos.at("audioModeratorMuted") == "true"; carlaCall.raisedHand = infos.at("handRaised") == "true"; carlaCall.device = infos.at("device"); carlaCall.streamId = infos.at("sinkId"); } else if (infos.at("uri").find(daviUri) != std::string::npos) { daviCall.active = infos.at("active") == "true"; daviCall.recording = infos.at("recording") == "true"; daviCall.moderatorMuted = infos.at("audioModeratorMuted") == "true"; daviCall.raisedHand = infos.at("handRaised") == "true"; daviCall.device = infos.at("device"); daviCall.streamId = infos.at("sinkId"); } else if (infos.at("uri").find(aliceUri) != std::string::npos) { hostRecording = infos.at("recording") == "true"; } } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); } void ConferenceTest::startConference(bool audioOnly, bool addDavi) { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto bobUri = bobAccount->getUsername(); auto carlaUri = carlaAccount->getUsername(); auto daviUri = daviAccount->getUsername(); std::vector<std::map<std::string, std::string>> mediaList; if (audioOnly) { std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); } JAMI_INFO("Start call between Alice and Bob"); auto call1 = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); Manager::instance().answerCall(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.hostState == "CURRENT"; })); JAMI_INFO("Start call between Alice and Carla"); auto call2 = libjami::placeCallWithMedia(aliceId, carlaUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !carlaCall.callId.empty(); })); Manager::instance().answerCall(carlaId, carlaCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return carlaCall.hostState == "CURRENT"; })); JAMI_INFO("Start conference"); confChanged = false; Manager::instance().joinParticipant(aliceId, call1, aliceId, call2); // ConfChanged is the signal emitted when the 2 calls will be added to the conference // Also, wait for participants to appear in conf info to get all good information CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !confId.empty() && confChanged && !carlaCall.device.empty() && !bobCall.device.empty(); })); if (addDavi) { JAMI_INFO("Start call between Alice and Davi"); auto call1 = libjami::placeCallWithMedia(aliceId, daviUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.callId.empty(); })); Manager::instance().answerCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.hostState == "CURRENT"; })); Manager::instance().addSubCall(aliceId, call1, aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.device.empty(); })); } } void ConferenceTest::hangupConference() { JAMI_INFO("Stop conference"); Manager::instance().hangupConference(aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return bobCall.state == "OVER" && carlaCall.state == "OVER" && confId.empty(); })); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return daviCall.callId.empty() ? true : daviCall.state == "OVER"; })); } void ConferenceTest::testGetConference() { registerSignalHandlers(); CPPUNIT_ASSERT(libjami::getConferenceList(aliceId).size() == 0); startConference(); CPPUNIT_ASSERT(libjami::getConferenceList(aliceId).size() == 1); CPPUNIT_ASSERT(libjami::getConferenceList(aliceId)[0] == confId); hangupConference(); CPPUNIT_ASSERT(libjami::getConferenceList(aliceId).size() == 0); libjami::unregisterSignalHandlers(); } void ConferenceTest::testModeratorMuteUpdateParticipantsInfos() { registerSignalHandlers(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); startConference(); JAMI_INFO("Play with mute from the moderator"); libjami::muteStream(aliceId, confId, bobUri, bobCall.device, bobCall.streamId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return bobCall.moderatorMuted.load(); })); libjami::muteStream(aliceId, confId, bobUri, bobCall.device, bobCall.streamId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !bobCall.moderatorMuted.load(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testUnauthorizedMute() { registerSignalHandlers(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); startConference(); JAMI_INFO("Play with mute from unauthorized"); libjami::muteStream(carlaId, confId, bobUri, bobCall.device, bobCall.streamId, true); CPPUNIT_ASSERT(!cv.wait_for(lk, 15s, [&] { return bobCall.moderatorMuted.load(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testAudioVideoMutedStates() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto bobUri = bobAccount->getUsername(); auto carlaUri = carlaAccount->getUsername(); JAMI_INFO("Start call between Alice and Bob"); auto call1Id = libjami::placeCallWithMedia(aliceId, bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); Manager::instance().answerCall(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.hostState == "CURRENT"; })); auto call1 = aliceAccount->getCall(call1Id); call1->muteMedia(libjami::Media::MediaAttributeValue::AUDIO, true); call1->muteMedia(libjami::Media::MediaAttributeValue::VIDEO, true); JAMI_INFO("Start call between Alice and Carla"); auto call2Id = libjami::placeCallWithMedia(aliceId, carlaUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !carlaCall.callId.empty(); })); Manager::instance().answerCall(carlaId, carlaCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return carlaCall.hostState == "CURRENT"; })); auto call2 = aliceAccount->getCall(call2Id); call2->muteMedia(libjami::Media::MediaAttributeValue::AUDIO, true); call2->muteMedia(libjami::Media::MediaAttributeValue::VIDEO, true); JAMI_INFO("Start conference"); Manager::instance().joinParticipant(aliceId, call1Id, aliceId, call2Id); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !confId.empty(); })); auto conf = aliceAccount->getConference(confId); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return conf->isMediaSourceMuted(jami::MediaType::MEDIA_AUDIO); })); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return conf->isMediaSourceMuted(jami::MediaType::MEDIA_VIDEO); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testMuteStatusAfterAdd() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto bobUri = bobAccount->getUsername(); auto carlaUri = carlaAccount->getUsername(); auto daviUri = daviAccount->getUsername(); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, TRUE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); JAMI_INFO("Start call between Alice and Bob"); auto call1 = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); Manager::instance().answerCall(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.hostState == "CURRENT"; })); JAMI_INFO("Start call between Alice and Carla"); auto call2 = libjami::placeCallWithMedia(aliceId, carlaUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !carlaCall.callId.empty(); })); Manager::instance().answerCall(carlaId, carlaCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return carlaCall.hostState == "CURRENT"; })); JAMI_INFO("Start conference"); Manager::instance().joinParticipant(aliceId, call1, aliceId, call2); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !confId.empty(); })); JAMI_INFO("Add Davi"); auto call3 = libjami::placeCallWithMedia(aliceId, daviUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.callId.empty(); })); Manager::instance().answerCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.hostState == "CURRENT"; })); Manager::instance().addSubCall(aliceId, call3, aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.device.empty(); })); auto aliceConf = aliceAccount->getConference(confId); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return aliceConf->isMediaSourceMuted(jami::MediaType::MEDIA_AUDIO); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testCreateParticipantsSinks() { registerSignalHandlers(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto bobUri = bobAccount->getUsername(); auto carlaUri = carlaAccount->getUsername(); startConference(); auto expectedNumberOfParticipants = 3u; // Check participants number CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return pInfos_.size() == expectedNumberOfParticipants; })); if (not jami::getVideoDeviceMonitor().getDeviceList().empty()) { JAMI_INFO() << "Check sinks if video device available."; std::lock_guard lock(pInfosMtx_); for (auto& info : pInfos_) { auto uri = string_remove_suffix(info["uri"], '@'); if (uri == bobUri) { CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return Manager::instance().getSinkClient(info["sinkId"]) != nullptr; })); } else if (uri == carlaUri) { CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return Manager::instance().getSinkClient(info["sinkId"]) != nullptr; })); } } } else { JAMI_INFO() << "Check sinks if no video device available."; std::lock_guard lock(pInfosMtx_); for (auto& info : pInfos_) { auto uri = string_remove_suffix(info["uri"], '@'); if (uri == bobUri) { CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return Manager::instance().getSinkClient(info["sinkId"]) == nullptr; })); } else if (uri == carlaUri) { CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return Manager::instance().getSinkClient(info["sinkId"]) == nullptr; })); } } } hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testMuteStatusAfterRemove() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto daviUri = daviAccount->getUsername(); startConference(false, true); libjami::muteStream(aliceId, confId, daviUri, daviCall.device, daviCall.streamId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return daviCall.moderatorMuted.load(); })); Manager::instance().hangupCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.state == "OVER"; })); daviCall.reset(); auto call2 = libjami::placeCallWithMedia(aliceId, daviUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.callId.empty(); })); Manager::instance().answerCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.hostState == "CURRENT"; })); Manager::instance().addSubCall(aliceId, call2, aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.device.empty(); })); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !daviCall.moderatorMuted.load(); })); Manager::instance().hangupCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.state == "OVER"; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testActiveStatusAfterRemove() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto daviUri = daviAccount->getUsername(); startConference(false, true); MediaAttribute defaultAudio(MediaType::MEDIA_AUDIO); defaultAudio.label_ = "audio_0"; defaultAudio.enabled_ = true; libjami::setActiveStream(aliceId, confId, daviUri, daviCall.device, daviCall.streamId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return daviCall.active.load(); })); Manager::instance().hangupCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.state == "OVER"; })); daviCall.reset(); auto call2 = libjami::placeCallWithMedia(aliceId, daviUri, MediaAttribute::mediaAttributesToMediaMaps( {defaultAudio})); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.callId.empty(); })); Manager::instance().answerCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.hostState == "CURRENT"; })); Manager::instance().addSubCall(aliceId, call2, aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.device.empty(); })); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !daviCall.active.load(); })); Manager::instance().hangupCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.state == "OVER"; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testHandsUp() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto daviUri = daviAccount->getUsername(); startConference(false, true); JAMI_INFO("Play with raise hand"); libjami::raiseHand(bobId, bobCall.callId, bobUri, bobCall.device, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return bobCall.raisedHand.load(); })); libjami::raiseHand(bobId, bobCall.callId, bobUri, bobCall.device, false); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !bobCall.raisedHand.load(); })); // Remove davi from moderators libjami::setModerator(aliceId, confId, daviUri, false); // Test to raise hand CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.device.empty(); })); libjami::raiseHand(daviId, daviCall.callId, daviUri, daviCall.device, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return daviCall.raisedHand.load(); })); // Test to raise hand for another one (should fail) libjami::raiseHand(bobId, bobCall.callId, carlaUri, carlaCall.device, true); CPPUNIT_ASSERT(!cv.wait_for(lk, 5s, [&] { return carlaCall.raisedHand.load(); })); // However, a moderator should be able to lower the hand (but not a non moderator) libjami::raiseHand(carlaId, carlaCall.callId, carlaUri, carlaCall.device, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return carlaCall.raisedHand.load(); })); libjami::raiseHand(daviId, carlaCall.callId, carlaUri, carlaCall.device, false); CPPUNIT_ASSERT(!cv.wait_for(lk, 5s, [&] { return !carlaCall.raisedHand.load(); })); libjami::raiseHand(bobId, bobCall.callId, carlaUri, carlaCall.device, false); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !carlaCall.raisedHand.load(); })); Manager::instance().hangupCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.state == "OVER"; })); daviCall.reset(); auto call2 = libjami::placeCallWithMedia(aliceId, daviUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.callId.empty(); })); Manager::instance().answerCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.hostState == "CURRENT"; })); Manager::instance().addSubCall(aliceId, call2, aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.device.empty(); })); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !daviCall.raisedHand.load(); })); Manager::instance().hangupCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.state == "OVER"; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testPeerLeaveConference() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); startConference(); Manager::instance().hangupCall(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.state == "OVER" && confId.empty(); })); libjami::unregisterSignalHandlers(); } void ConferenceTest::testJoinCallFromOtherAccount() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto daviUri = daviAccount->getUsername(); startConference(); JAMI_INFO("Play with raise hand"); libjami::raiseHand(aliceId, confId, bobUri, bobCall.device, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return bobCall.raisedHand.load(); })); libjami::raiseHand(aliceId, confId, bobUri, bobCall.device, false); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !bobCall.raisedHand.load(); })); JAMI_INFO("Start call between Alice and Davi"); auto call1 = libjami::placeCallWithMedia(aliceId, daviUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !daviCall.callId.empty(); })); Manager::instance().answerCall(daviId, daviCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return daviCall.hostState == "CURRENT"; })); CPPUNIT_ASSERT(Manager::instance().addSubCall(daviId, daviCall.callId, aliceId, confId)); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testDevices() { registerSignalHandlers(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto bobDevice = std::string(bobAccount->currentDeviceId()); auto carlaDevice = std::string(carlaAccount->currentDeviceId()); startConference(); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return bobCall.device == bobDevice && carlaDevice == carlaCall.device; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testUnauthorizedSetActive() { registerSignalHandlers(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); startConference(); libjami::setActiveStream(carlaId, confId, bobUri, bobCall.device, bobCall.streamId, true); CPPUNIT_ASSERT(!cv.wait_for(lk, 15s, [&] { return bobCall.active.load(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testHangup() { registerSignalHandlers(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto daviUri = daviAccount->getUsername(); startConference(false, true); libjami::hangupParticipant(carlaId, confId, daviUri, daviCall.device); // Unauthorized CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&] { return daviCall.state == "OVER"; })); libjami::hangupParticipant(aliceId, confId, daviUri, daviCall.device); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return daviCall.state == "OVER"; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testIsConferenceParticipant() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); startConference(); // is Conference participant should be true for Carla auto subCalls = aliceAccount->getConference(confId)->getSubCalls(); CPPUNIT_ASSERT(subCalls.size() == 2); auto call1 = *subCalls.begin(); auto call2 = *subCalls.rbegin(); CPPUNIT_ASSERT(aliceAccount->getCall(call1)->isConferenceParticipant()); CPPUNIT_ASSERT(aliceAccount->getCall(call2)->isConferenceParticipant()); // hangup bob will stop the conference Manager::instance().hangupCall(aliceId, call1); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return confId.empty(); })); CPPUNIT_ASSERT(!aliceAccount->getCall(call2)->isConferenceParticipant()); Manager::instance().hangupCall(aliceId, call2); libjami::unregisterSignalHandlers(); } void ConferenceTest::testHostAddRmSecondVideo() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); registerSignalHandlers(); startConference(); // Alice adds new media pInfos_.clear(); std::vector<std::map<std::string, std::string>> mediaList = {{{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, "true"}, {libjami::Media::MediaAttributeKey::MUTED, "false"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}, {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, "true"}, {libjami::Media::MediaAttributeKey::MUTED, "false"}, {libjami::Media::MediaAttributeKey::SOURCE, "bar"}, {libjami::Media::MediaAttributeKey::LABEL, "video_0"}}, {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, "true"}, {libjami::Media::MediaAttributeKey::MUTED, "false"}, {libjami::Media::MediaAttributeKey::SOURCE, "foo"}, {libjami::Media::MediaAttributeKey::LABEL, "video_1"}}}; libjami::requestMediaChange(aliceId, confId, mediaList); // Check that alice has two videos attached to the conference auto aliceVideos = [&]() { int result = 0; std::lock_guard lock(pInfosMtx_); for (auto i = 0u; i < pInfos_.size(); ++i) if (pInfos_[i]["uri"].find(aliceUri) != std::string::npos) result += 1; return result; }; CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return aliceVideos() == 2; })); // Alice removes her second video { std::lock_guard lock(pInfosMtx_); pInfos_.clear(); } mediaList.pop_back(); libjami::requestMediaChange(aliceId, confId, mediaList); // Check that alice has ont video attached to the conference CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return aliceVideos() == 1; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testAudioConferenceConfInfo() { registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); startConference(true); // Check that alice's video is muted auto aliceVideoMuted = [&]() { int result = 0; std::lock_guard lock(pInfosMtx_); for (auto i = 0u; i < pInfos_.size(); ++i) { if (pInfos_[i]["uri"].find(aliceUri) != std::string::npos && pInfos_[i]["videoMuted"] == "true" && pInfos_[i]["sinkId"] == "host_video_0") result += 1; } return result; }; CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return aliceVideoMuted() == 1; })); libjami::unregisterSignalHandlers(); } void ConferenceTest::testParticipantAddRmSecondVideo() { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); registerSignalHandlers(); startConference(); // Bob adds new media pInfos_.clear(); std::vector<std::map<std::string, std::string>> mediaList = {{{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, "true"}, {libjami::Media::MediaAttributeKey::MUTED, "false"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}, {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, "true"}, {libjami::Media::MediaAttributeKey::MUTED, "false"}, {libjami::Media::MediaAttributeKey::SOURCE, "bar"}, {libjami::Media::MediaAttributeKey::LABEL, "video_0"}}, {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, "true"}, {libjami::Media::MediaAttributeKey::MUTED, "false"}, {libjami::Media::MediaAttributeKey::SOURCE, "foo"}, {libjami::Media::MediaAttributeKey::LABEL, "video_1"}}}; libjami::requestMediaChange(bobId, bobCall.callId, mediaList); // Check that bob has two videos attached to the conference auto bobVideos = [&]() { std::lock_guard lock(pInfosMtx_); int result = 0; for (auto i = 0u; i < pInfos_.size(); ++i) if (pInfos_[i]["uri"].find(bobUri) != std::string::npos) result += 1; return result; }; CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return bobVideos() == 2; })); // Bob removes his second video { std::lock_guard lock(pInfosMtx_); pInfos_.clear(); } mediaList.pop_back(); libjami::requestMediaChange(bobId, bobCall.callId, mediaList); // Check that bob has ont video attached to the conference CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return bobVideos() == 1; })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testPropagateRecording() { registerSignalHandlers(); startConference(); JAMI_INFO("Play with recording state"); libjami::toggleRecording(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return bobCall.recording.load(); })); libjami::toggleRecording(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !bobCall.recording.load(); })); libjami::toggleRecording(aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return hostRecording.load(); })); libjami::toggleRecording(aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&] { return !hostRecording.load(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testBrokenParticipantAudioAndVideo() { registerSignalHandlers(); // Start conference with four participants startConference(false, true); auto expectedNumberOfParticipants = 4u; // Check participants number CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return pInfos_.size() == expectedNumberOfParticipants; })); // Crash participant auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto call2Crash = std::dynamic_pointer_cast<SIPCall>(daviAccount->getCall(daviCall.callId)); pjsip_transport_shutdown(call2Crash->getTransport()->get()); // Check participants number // It should have one less participant than in the conference start CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return expectedNumberOfParticipants - 1 == pInfos_.size(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testBrokenParticipantAudioOnly() { registerSignalHandlers(); // Start conference with four participants startConference(true, true); auto expectedNumberOfParticipants = 4u; // Check participants number CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return pInfos_.size() == expectedNumberOfParticipants; })); // Crash participant auto daviAccount = Manager::instance().getAccount<JamiAccount>(daviId); auto call2Crash = std::dynamic_pointer_cast<SIPCall>(daviAccount->getCall(daviCall.callId)); pjsip_transport_shutdown(call2Crash->getTransport()->get()); // Check participants number // It should have one less participant than in the conference start CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return expectedNumberOfParticipants - 1 == pInfos_.size(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testAudioOnlyLeaveLayout() { registerSignalHandlers(); // Start conference with four participants startConference(true, true); auto expectedNumberOfParticipants = 4u; // Check participants number CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return pInfos_.size() == expectedNumberOfParticipants; })); // Carla Leave Manager::instance().hangupCall(carlaId, carlaCall.callId); // Check participants number // It should have one less participant than in the conference start CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&] { return expectedNumberOfParticipants - 1 == pInfos_.size(); })); hangupConference(); libjami::unregisterSignalHandlers(); } void ConferenceTest::testRemoveConferenceInOneOne() { registerSignalHandlers(); startConference(); // Here it's 1:1 calls we merged, so we can close the conference JAMI_INFO("Hangup Bob"); Manager::instance().hangupCall(bobId, bobCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return confId.empty() && bobCall.state == "OVER"; })); Manager::instance().hangupCall(carlaId, carlaCall.callId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return carlaCall.state == "OVER"; })); libjami::unregisterSignalHandlers(); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::ConferenceTest::name())
43,457
C++
.cpp
929
40.194833
100
0.672942
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,655
sipcall.cpp
savoirfairelinux_jami-daemon/test/unitTest/call/sipcall.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include "manager.h" #include "sip/sipaccount.h" #include "sip/sipcall.h" #include "sip/siptransport.h" #include "../../test_runner.h" #include "jami.h" #include "account_const.h" #include "media_const.h" #include "call_const.h" #include "common.h" #include <dhtnet/connectionmanager.h> #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <filesystem> #include <string> using namespace libjami::Account; using namespace libjami::Call::Details; using namespace std::literals::chrono_literals; namespace jami { namespace test { class SIPCallTest : public CppUnit::TestFixture { public: SIPCallTest() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); } ~SIPCallTest() { libjami::fini(); } static std::string name() { return "Call"; } void setUp(); void tearDown(); std::string aliceId; std::string bobId; private: void testCall(); CPPUNIT_TEST_SUITE(SIPCallTest); CPPUNIT_TEST(testCall); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(SIPCallTest, SIPCallTest::name()); void SIPCallTest::setUp() { auto actors = load_actors_and_wait_for_announcement("actors/alice-bob_SIP.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; std::this_thread::sleep_for(10s); } void SIPCallTest::tearDown() { wait_for_removal_of({aliceId, bobId}); } void SIPCallTest::testCall() { auto aliceAccount = Manager::instance().getAccount<SIPAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<SIPAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::atomic_bool callReceived {false}; std::atomic<int> callStopped {0}; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [&](const std::string&, const std::string&, const std::string&, const std::vector<std::map<std::string, std::string>>&) { callReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string&, const std::string&, const std::string& state, signed) { if (state == "OVER") { callStopped += 1; if (callStopped == 2) cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); JAMI_INFO("Start call between alice and Bob"); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); auto call = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callReceived.load(); })); JAMI_INFO("Stop call between alice and Bob"); callStopped = 0; Manager::instance().hangupCall(aliceId, call); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return callStopped == 2; })); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::SIPCallTest::name())
4,686
C++
.cpp
126
32.31746
97
0.684292
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,656
recorder.cpp
savoirfairelinux_jami-daemon/test/unitTest/call/recorder.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <filesystem> #include <string> #include "../../test_runner.h" #include "account_const.h" #include "fileutils.h" #include "jami.h" #include "jamidht/jamiaccount.h" #include "manager.h" #include "media_const.h" #include "client/videomanager.h" #include "common.h" using namespace libjami::Account; using namespace std::literals::chrono_literals; namespace jami { namespace test { struct CallData { std::string callId {}; std::string state {}; std::string mediaStatus {}; std::string device {}; std::string hostState {}; bool changeRequested = false; void reset() { callId = ""; state = ""; mediaStatus = ""; device = ""; hostState = ""; } }; class RecorderTest : public CppUnit::TestFixture { public: RecorderTest() { // Init daemon libjami::init(libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); } ~RecorderTest() { libjami::fini(); } static std::string name() { return "Recorder"; } void setUp(); void tearDown(); std::string aliceId {}; std::string bobId {}; std::string recordDir {}; std::string recordedFile {}; std::string playerId {}; std::shared_ptr<MediaPlayer> player {}; CallData bobCall {}; std::mutex mtx; std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; std::string videoPath = "file://" + std::filesystem::absolute("media/test_video_file.mp4").string(); private: void registerSignalHandlers(); void testRecordCall(); void testRecordAudioOnlyCall(); void testRecordCallOnePersonRdv(); void testStopCallWhileRecording(); void testDaemonPreference(); CPPUNIT_TEST_SUITE(RecorderTest); CPPUNIT_TEST(testRecordCall); CPPUNIT_TEST(testRecordAudioOnlyCall); CPPUNIT_TEST(testRecordCallOnePersonRdv); CPPUNIT_TEST(testStopCallWhileRecording); CPPUNIT_TEST(testDaemonPreference); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(RecorderTest, RecorderTest::name()); void RecorderTest::setUp() { // Generate a temporary directory with a file inside recordDir = "records"; dhtnet::fileutils::recursive_mkdir(recordDir.c_str()); CPPUNIT_ASSERT(std::filesystem::is_directory(recordDir)); auto actors = load_actors_and_wait_for_announcement("actors/alice-bob.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; bobCall.reset(); playerId = jami::createMediaPlayer(videoPath); player = jami::getMediaPlayer(playerId); player->setAutoRestart(true); player->pause(false); libjami::setRecordPath(recordDir); } void RecorderTest::tearDown() { player.reset(); jami::closeMediaPlayer(playerId); libjami::setIsAlwaysRecording(false); dhtnet::fileutils::removeAll(recordDir); wait_for_removal_of({aliceId, bobId}); } void RecorderTest::registerSignalHandlers() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; // Watch signals confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::IncomingCallWithMedia>( [=](const std::string& accountId, const std::string& callId, const std::string&, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId) { bobCall.callId = callId; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::MediaChangeRequested>( [=](const std::string& accountId, const std::string& callId, const std::vector<std::map<std::string, std::string>>&) { if (accountId == bobId && bobCall.callId == callId) { bobCall.changeRequested = true; } })); confHandlers.insert( libjami::exportable_callback<libjami::CallSignal::StateChange>([=](const std::string& accountId, const std::string& callId, const std::string& state, signed) { if (accountId == aliceId) { auto details = libjami::getCallDetails(aliceId, callId); if (details["PEER_NUMBER"].find(bobUri) != std::string::npos) bobCall.hostState = state; } else if (bobCall.callId == callId) bobCall.state = state; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::MediaNegotiationStatus>( [&](const std::string& callId, const std::string& event, const std::vector<std::map<std::string, std::string>>&) { if (callId == bobCall.callId) bobCall.mediaStatus = event; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::RecordPlaybackStopped>( [&](const std::string& path) { recordedFile = path; cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); } void RecorderTest::testRecordCall() { JAMI_INFO("Start testRecordCall"); registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); JAMI_INFO("Start call between Alice and Bob"); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttributeA = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}}; std::map<std::string, std::string> mediaAttributeV = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "video_0"}, {libjami::Media::MediaAttributeKey::SOURCE, videoPath}}; mediaList.emplace_back(mediaAttributeA); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); libjami::acceptWithMedia(bobId, bobCall.callId, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.mediaStatus == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS; })); std::this_thread::sleep_for(5s); // Start recorder recordedFile.clear(); CPPUNIT_ASSERT(!libjami::getIsRecording(aliceId, callId)); libjami::toggleRecording(aliceId, callId); std::this_thread::sleep_for(5s); CPPUNIT_ASSERT(libjami::getIsRecording(aliceId, callId)); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return recordedFile.empty(); })); // add local video { auto newMediaList = mediaList; newMediaList.emplace_back(mediaAttributeV); // Request Media Change libjami::requestMediaChange(aliceId, callId, newMediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&] { return bobCall.changeRequested; })); // Answer the change request bobCall.mediaStatus = ""; libjami::answerMediaChangeRequest(bobId, bobCall.callId, newMediaList); bobCall.changeRequested = false; CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.mediaStatus == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS; })); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !recordedFile.empty() && recordedFile.find(".ogg") != std::string::npos; })); recordedFile = ""; // give time to start camera std::this_thread::sleep_for(10s); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return recordedFile.empty(); })); } // mute local video { mediaAttributeV[libjami::Media::MediaAttributeKey::MUTED] = TRUE_STR; auto newMediaList = mediaList; newMediaList.emplace_back(mediaAttributeV); // Mute Bob video libjami::requestMediaChange(aliceId, callId, newMediaList); std::this_thread::sleep_for(5s); libjami::requestMediaChange(bobId, bobCall.callId, newMediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !recordedFile.empty() && recordedFile.find(".webm") != std::string::npos; })); recordedFile = ""; std::this_thread::sleep_for(10s); } // Stop recorder after a few seconds libjami::toggleRecording(aliceId, callId); CPPUNIT_ASSERT(!libjami::getIsRecording(aliceId, callId)); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !recordedFile.empty() && recordedFile.find(".ogg") != std::string::npos; })); Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.state == "OVER"; })); JAMI_INFO("End testRecordCall"); } void RecorderTest::testRecordAudioOnlyCall() { JAMI_INFO("Start testRecordAudioOnlyCall"); registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); JAMI_INFO("Start call between Alice and Bob"); // Audio only call std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}}; mediaList.emplace_back(mediaAttribute); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); libjami::acceptWithMedia(bobId, bobCall.callId, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.mediaStatus == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS; })); // Start recorder recordedFile.clear(); libjami::toggleRecording(aliceId, callId); std::this_thread::sleep_for(5s); CPPUNIT_ASSERT(libjami::getIsRecording(aliceId, callId)); // Toggle recording libjami::toggleRecording(aliceId, callId); CPPUNIT_ASSERT(!libjami::getIsRecording(aliceId, callId)); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !recordedFile.empty() && recordedFile.find(".ogg") != std::string::npos; })); Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.state == "OVER"; })); JAMI_INFO("End testRecordAudioOnlyCall"); } void RecorderTest::testRecordCallOnePersonRdv() { JAMI_INFO("Start testRecordCallOnePersonRdv"); registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); try { bobAccount->editConfig( [&](AccountConfig& config) { config.isRendezVous = true; }); } catch (...) {} CPPUNIT_ASSERT(bobAccount->config().isRendezVous); recordedFile.clear(); JAMI_INFO("Start call between Alice and Bob"); // Audio only call std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttributeA = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}}; mediaList.emplace_back(mediaAttributeA); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.mediaStatus == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS; })); CPPUNIT_ASSERT(!libjami::getIsRecording(aliceId, callId)); libjami::toggleRecording(aliceId, callId); std::this_thread::sleep_for(5s); CPPUNIT_ASSERT(libjami::getIsRecording(aliceId, callId)); // Stop recorder libjami::toggleRecording(aliceId, callId); CPPUNIT_ASSERT(!libjami::getIsRecording(aliceId, callId)); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !recordedFile.empty() && recordedFile.find(".ogg") != std::string::npos; })); Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT( cv.wait_for(lk, 20s, [&] { return bobCall.state == "OVER"; })); JAMI_INFO("End testRecordCallOnePersonRdv"); } void RecorderTest::testStopCallWhileRecording() { JAMI_INFO("Start testStopCallWhileRecording"); registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); JAMI_INFO("Start call between Alice and Bob"); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttributeA = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}}; std::map<std::string, std::string> mediaAttributeV = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "video_0"}, {libjami::Media::MediaAttributeKey::SOURCE, videoPath}}; mediaList.emplace_back(mediaAttributeA); mediaList.emplace_back(mediaAttributeV); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); libjami::acceptWithMedia(bobId, bobCall.callId, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.mediaStatus == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS; })); // give time to start camera std::this_thread::sleep_for(5s); // Start recorder recordedFile.clear(); libjami::toggleRecording(aliceId, callId); std::this_thread::sleep_for(10s); CPPUNIT_ASSERT(libjami::getIsRecording(aliceId, callId)); // Hangup call Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT( cv.wait_for(lk, 20s, [&] { return bobCall.state == "OVER" && !recordedFile.empty() && recordedFile.find(".webm") != std::string::npos; })); JAMI_INFO("End testStopCallWhileRecording"); } void RecorderTest::testDaemonPreference() { JAMI_INFO("Start testDaemonPreference"); registerSignalHandlers(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); libjami::setIsAlwaysRecording(true); recordedFile.clear(); JAMI_INFO("Start call between Alice and Bob"); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttributeA = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}, {libjami::Media::MediaAttributeKey::SOURCE, ""}}; std::map<std::string, std::string> mediaAttributeV = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::VIDEO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::LABEL, "video_0"}, {libjami::Media::MediaAttributeKey::SOURCE, videoPath}}; mediaList.emplace_back(mediaAttributeA); mediaList.emplace_back(mediaAttributeV); auto callId = libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return !bobCall.callId.empty(); })); libjami::acceptWithMedia(bobId, bobCall.callId, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&] { return bobCall.mediaStatus == libjami::Media::MediaNegotiationStatusEvents::NEGOTIATION_SUCCESS; })); // Let record some seconds std::this_thread::sleep_for(5s); CPPUNIT_ASSERT(libjami::getIsRecording(aliceId, callId)); std::this_thread::sleep_for(10s); Manager::instance().hangupCall(aliceId, callId); CPPUNIT_ASSERT( cv.wait_for(lk, 20s, [&] { return bobCall.state == "OVER" && !recordedFile.empty() && recordedFile.find(".webm") != std::string::npos; })); JAMI_INFO("End testDaemonPreference"); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::RecorderTest::name())
19,390
C++
.cpp
425
38.978824
147
0.673969
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,657
testUtf8_utils.cpp
savoirfairelinux_jami-daemon/test/unitTest/utf8_utils/testUtf8_utils.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <string> #include "connectivity/utf8_utils.h" #include "../../test_runner.h" namespace jami { namespace test { class Utf8UtilsTest : public CppUnit::TestFixture { public: static std::string name() { return "utf8_utils"; } private: void utf8_validate_test(); void utf8_make_valid_test(); CPPUNIT_TEST_SUITE(Utf8UtilsTest); CPPUNIT_TEST(utf8_validate_test); CPPUNIT_TEST(utf8_make_valid_test); CPPUNIT_TEST_SUITE_END(); const std::string VALIDE_UTF8 = "çèềé{}()/\\*"; const std::string INVALID_UTF8 = "\xc3\x28"; }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Utf8UtilsTest, Utf8UtilsTest::name()); void Utf8UtilsTest::utf8_validate_test() { CPPUNIT_ASSERT(!utf8_validate(INVALID_UTF8)); CPPUNIT_ASSERT(utf8_validate(VALIDE_UTF8)); } void Utf8UtilsTest::utf8_make_valid_test() { // valide utf8 string in input CPPUNIT_ASSERT(utf8_make_valid(VALIDE_UTF8).compare(VALIDE_UTF8) == 0); // invalid utf8 string in input std::string str = utf8_make_valid(INVALID_UTF8); CPPUNIT_ASSERT(utf8_validate(str)); } }} // namespace jami::test RING_TEST_RUNNER(jami::test::Utf8UtilsTest::name());
1,993
C++
.cpp
54
34.074074
76
0.7358
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
true
false
false
751,658
base64.cpp
savoirfairelinux_jami-daemon/test/unitTest/base64/base64.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include "test_runner.h" #include "base64.h" namespace jami { namespace test { class Base64Test : public CppUnit::TestFixture { public: static std::string name() { return "base64"; } private: void encodingTest(); void decodingTestSuccess(); void decodingTestFail(); CPPUNIT_TEST_SUITE(Base64Test); CPPUNIT_TEST(encodingTest); CPPUNIT_TEST(decodingTestSuccess); CPPUNIT_TEST(decodingTestFail); CPPUNIT_TEST_SUITE_END(); const std::vector<uint8_t> test_bytes = { 23, 45, 67, 87, 89, 34, 2, 45, 9, 10 }; const std::string test_base64 = "Fy1DV1kiAi0JCg=="; const std::string test_invalid_base64 = "ERSAÄÖöädt4-++asd=="; }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Base64Test, Base64Test::name()); void Base64Test::encodingTest() { const std::string output = jami::base64::encode(test_bytes); CPPUNIT_ASSERT(test_base64.compare(output) == 0); } void Base64Test::decodingTestSuccess() { const std::vector<uint8_t> output = jami::base64::decode(test_base64); CPPUNIT_ASSERT(std::equal(test_bytes.begin(), test_bytes.end(), output.begin())); } void Base64Test::decodingTestFail() { // Currently, the input is not validated, i.e. the function most not throw an // exception if decoding fails to make sure calling code not expecting any // is no broken. (Some validation should be implemented sometimes later, though. jami::base64::decode(test_invalid_base64); CPPUNIT_ASSERT(true); } }} // namespace jami::test RING_TEST_RUNNER(jami::test::Base64Test::name());
2,378
C++
.cpp
62
35.467742
85
0.734987
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
true
false
false
true
false
false
751,659
conversation.cpp
savoirfairelinux_jami-daemon/test/unitTest/conversation/conversation.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <string> #include <fstream> #include <streambuf> #include <git2.h> #include <filesystem> #include <msgpack.hpp> #include "../../test_runner.h" #include "account_const.h" #include "archiver.h" #include "base64.h" #include "common.h" #include "conversation/conversationcommon.h" #include "fileutils.h" #include "jami.h" #include "manager.h" #include <dhtnet/certstore.h> using namespace std::string_literals; using namespace std::literals::chrono_literals; using namespace libjami::Account; struct ConvInfoTest { std::string id {}; time_t created {0}; time_t removed {0}; time_t erased {0}; MSGPACK_DEFINE_MAP(id, created, removed, erased) }; namespace jami { namespace test { struct UserData { std::string conversationId; bool removed {false}; bool requestReceived {false}; bool errorDetected {false}; bool registered {false}; bool stopped {false}; bool deviceAnnounced {false}; bool sending {false}; bool sent {false}; bool searchFinished {false}; std::string profilePath; std::string payloadTrustRequest; std::map<std::string, std::string> profile; std::vector<libjami::SwarmMessage> messages; std::vector<libjami::SwarmMessage> messagesUpdated; std::vector<std::map<std::string, std::string>> reactions; std::vector<std::map<std::string, std::string>> messagesFound; std::vector<std::string> reactionRemoved; std::map<std::string, std::string> preferences; }; class ConversationTest : public CppUnit::TestFixture { public: ~ConversationTest() { libjami::fini(); } static std::string name() { return "Conversation"; } void setUp(); void tearDown(); std::string createFakeConversation(std::shared_ptr<JamiAccount> account, const std::string& fakeCert = ""); std::string aliceId; UserData aliceData; std::string alice2Id; UserData alice2Data; std::string bobId; UserData bobData; std::string bob2Id; UserData bob2Data; std::string carlaId; UserData carlaData; std::mutex mtx; std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; void connectSignals(); private: void testCreateConversation(); void testOfflineConvModule(); void testCreateConversationInvalidDisplayName(); void testGetConversation(); void testGetConversationsAfterRm(); void testRemoveInvalidConversation(); void testSendMessage(); void testSendMessageWithBadDisplayName(); void testReplaceWithBadCertificate(); void testSendMessageTriggerMessageReceived(); void testMergeTwoDifferentHeads(); void testSendMessageToMultipleParticipants(); void testPingPongMessages(); void testSetMessageDisplayedTwice(); void testSetMessageDisplayedPreference(); void testSetMessageDisplayedAfterClone(); void testSendMessageWithLotOfKnownDevices(); void testVoteNonEmpty(); void testNoBadFileInInitialCommit(); void testNoBadCertInInitialCommit(); void testPlainTextNoBadFile(); void testVoteNoBadFile(); void testETooBigClone(); void testETooBigFetch(); void testUnknownModeDetected(); void testUpdateProfile(); void testGetProfileRequest(); void testCheckProfileInConversationRequest(); void testCheckProfileInTrustRequest(); void testMemberCannotUpdateProfile(); void testUpdateProfileWithBadFile(); void testFetchProfileUnauthorized(); void testSyncingWhileAccepting(); void testCountInteractions(); void testReplayConversation(); void testSyncWithoutPinnedCert(); void testImportMalformedContacts(); void testCloneFromMultipleDevice(); void testSendReply(); void testSearchInConv(); void testConversationPreferences(); void testConversationPreferencesBeforeClone(); void testConversationPreferencesMultiDevices(); void testFixContactDetails(); void testRemoveOneToOneNotInDetails(); void testMessageEdition(); void testMessageReaction(); void testMessageEditionWithReaction(); void testLoadPartiallyRemovedConversation(); void testReactionsOnEditedMessage(); void testUpdateProfileMultiDevice(); CPPUNIT_TEST_SUITE(ConversationTest); CPPUNIT_TEST(testCreateConversation); CPPUNIT_TEST(testOfflineConvModule); CPPUNIT_TEST(testCreateConversationInvalidDisplayName); CPPUNIT_TEST(testGetConversation); CPPUNIT_TEST(testGetConversationsAfterRm); CPPUNIT_TEST(testRemoveInvalidConversation); CPPUNIT_TEST(testSendMessage); CPPUNIT_TEST(testSendMessageWithBadDisplayName); CPPUNIT_TEST(testReplaceWithBadCertificate); CPPUNIT_TEST(testSendMessageTriggerMessageReceived); CPPUNIT_TEST(testMergeTwoDifferentHeads); CPPUNIT_TEST(testSendMessageToMultipleParticipants); CPPUNIT_TEST(testPingPongMessages); CPPUNIT_TEST(testSetMessageDisplayedTwice); CPPUNIT_TEST(testSetMessageDisplayedPreference); CPPUNIT_TEST(testSetMessageDisplayedAfterClone); CPPUNIT_TEST(testSendMessageWithLotOfKnownDevices); CPPUNIT_TEST(testVoteNonEmpty); CPPUNIT_TEST(testNoBadFileInInitialCommit); CPPUNIT_TEST(testNoBadCertInInitialCommit); CPPUNIT_TEST(testPlainTextNoBadFile); CPPUNIT_TEST(testVoteNoBadFile); CPPUNIT_TEST(testETooBigClone); CPPUNIT_TEST(testETooBigFetch); CPPUNIT_TEST(testUnknownModeDetected); CPPUNIT_TEST(testUpdateProfile); CPPUNIT_TEST(testGetProfileRequest); CPPUNIT_TEST(testCheckProfileInConversationRequest); CPPUNIT_TEST(testCheckProfileInTrustRequest); CPPUNIT_TEST(testMemberCannotUpdateProfile); CPPUNIT_TEST(testUpdateProfileWithBadFile); CPPUNIT_TEST(testFetchProfileUnauthorized); CPPUNIT_TEST(testSyncingWhileAccepting); CPPUNIT_TEST(testCountInteractions); CPPUNIT_TEST(testReplayConversation); CPPUNIT_TEST(testSyncWithoutPinnedCert); CPPUNIT_TEST(testImportMalformedContacts); CPPUNIT_TEST(testCloneFromMultipleDevice); CPPUNIT_TEST(testSendReply); CPPUNIT_TEST(testSearchInConv); CPPUNIT_TEST(testConversationPreferences); CPPUNIT_TEST(testConversationPreferencesBeforeClone); CPPUNIT_TEST(testConversationPreferencesMultiDevices); CPPUNIT_TEST(testFixContactDetails); CPPUNIT_TEST(testRemoveOneToOneNotInDetails); CPPUNIT_TEST(testMessageEdition); CPPUNIT_TEST(testMessageReaction); CPPUNIT_TEST(testMessageEditionWithReaction); CPPUNIT_TEST(testLoadPartiallyRemovedConversation); CPPUNIT_TEST(testReactionsOnEditedMessage); CPPUNIT_TEST(testUpdateProfileMultiDevice); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConversationTest, ConversationTest::name()); void ConversationTest::setUp() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); auto actors = load_actors("actors/alice-bob-carla.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; carlaId = actors["carla"]; aliceData = {}; alice2Data = {}; bobData = {}; bob2Data = {}; carlaData = {}; Manager::instance().sendRegister(carlaId, false); wait_for_announcement_of({aliceId, bobId}); } void ConversationTest::connectSignals() { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string& accountId, const std::map<std::string, std::string>&) { if (accountId == aliceId) { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto details = aliceAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { aliceData.registered = true; } else if (daemonStatus == "UNREGISTERED") { aliceData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; aliceData.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == bobId) { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto details = bobAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bobData.registered = true; } else if (daemonStatus == "UNREGISTERED") { bobData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; bobData.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == bob2Id) { auto bob2Account = Manager::instance().getAccount<JamiAccount>(bob2Id); auto details = bob2Account->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bob2Data.registered = true; } else if (daemonStatus == "UNREGISTERED") { bob2Data.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; bob2Data.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == carlaId) { auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto details = carlaAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { carlaData.registered = true; } else if (daemonStatus == "UNREGISTERED") { carlaData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; carlaData.deviceAnnounced = deviceAnnounced == "true"; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == aliceId) { aliceData.conversationId = conversationId; } else if (accountId == alice2Id) { alice2Data.conversationId = conversationId; } else if (accountId == bobId) { bobData.conversationId = conversationId; } else if (accountId == bob2Id) { bob2Data.conversationId = conversationId; } else if (accountId == carlaId) { carlaData.conversationId = conversationId; } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::IncomingTrustRequest>( [&](const std::string& account_id, const std::string& /*from*/, const std::string& /*conversationId*/, const std::vector<uint8_t>& payload, time_t /*received*/) { auto payloadStr = std::string(payload.data(), payload.data() + payload.size()); if (account_id == aliceId) aliceData.payloadTrustRequest = payloadStr; else if (account_id == bobId) bobData.payloadTrustRequest = payloadStr; cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, std::map<std::string, std::string> /*metadatas*/) { if (accountId == aliceId) { aliceData.requestReceived = true; } else if (accountId == bobId) { bobData.requestReceived = true; } else if (accountId == bob2Id) { bob2Data.requestReceived = true; } else if (accountId == carlaId) { carlaData.requestReceived = true; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmMessageReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, libjami::SwarmMessage message) { if (accountId == aliceId) { aliceData.messages.emplace_back(message); } else if (accountId == bobId) { bobData.messages.emplace_back(message); } else if (accountId == carlaId) { carlaData.messages.emplace_back(message); } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmMessageUpdated>( [&](const std::string& accountId, const std::string& /* conversationId */, libjami::SwarmMessage message) { if (accountId == aliceId) { aliceData.messagesUpdated.emplace_back(message); } else if (accountId == bobId) { bobData.messagesUpdated.emplace_back(message); } else if (accountId == carlaId) { carlaData.messagesUpdated.emplace_back(message); } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ReactionAdded>( [&](const std::string& accountId, const std::string& /* conversationId */, const std::string& /* messageId */, std::map<std::string, std::string> reaction) { if (accountId == aliceId) { aliceData.reactions.emplace_back(reaction); } else if (accountId == bobId) { bobData.reactions.emplace_back(reaction); } else if (accountId == carlaId) { carlaData.reactions.emplace_back(reaction); } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ReactionRemoved>( [&](const std::string& accountId, const std::string& /* conversationId */, const std::string& /* messageId */, const std::string& reactionId) { if (accountId == aliceId) { aliceData.reactionRemoved.emplace_back(reactionId); } else if (accountId == bobId) { bobData.reactionRemoved.emplace_back(reactionId); } else if (accountId == carlaId) { carlaData.reactionRemoved.emplace_back(reactionId); } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::OnConversationError>( [&](const std::string& accountId, const std::string& /* conversationId */, int /*code*/, const std::string& /* what */) { if (accountId == aliceId) aliceData.errorDetected = true; else if (accountId == bobId) bobData.errorDetected = true; else if (accountId == carlaId) carlaData.errorDetected = true; cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::AccountMessageStatusChanged>( [&](const std::string& accountId, const std::string& /*conversationId*/, const std::string& /*peer*/, const std::string& /*msgId*/, int status) { if (accountId == aliceId) { if (status == 2) aliceData.sending = true; if (status == 3) aliceData.sent = true; } else if (accountId == bobId) { if (status == 2) bobData.sending = true; if (status == 3) bobData.sent = true; } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationProfileUpdated>( [&](const auto& accountId, const auto& /* conversationId */, const auto& profile) { if (accountId == aliceId) { aliceData.profile = profile; } else if (accountId == bobId) { bobData.profile = profile; } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRemoved>( [&](const std::string& accountId, const std::string&) { if (accountId == aliceId) aliceData.removed = true; else if (accountId == bobId) bobData.removed = true; else if (accountId == bob2Id) bob2Data.removed = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::ProfileReceived>( [&](const std::string& accountId, const std::string& peerId, const std::string& path) { if (accountId == bobId) bobData.profilePath = path; cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationPreferencesUpdated>( [&](const std::string& accountId, const std::string& conversationId, std::map<std::string, std::string> preferences) { if (accountId == bobId) bobData.preferences = preferences; else if (accountId == bob2Id) bob2Data.preferences = preferences; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::MessagesFound>( [&](uint32_t, const std::string& accountId, const std::string& conversationId, std::vector<std::map<std::string, std::string>> msg) { if (accountId == aliceId) { aliceData.messagesFound.insert(aliceData.messagesFound.end(), msg.begin(), msg.end()); aliceData.searchFinished = conversationId.empty(); } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); } void ConversationTest::tearDown() { auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); auto aliceArchive = std::filesystem::current_path().string() + "/alice.gz"; std::remove(aliceArchive.c_str()); if (!alice2Id.empty()) { wait_for_removal_of(alice2Id); } if (bob2Id.empty()) { wait_for_removal_of({aliceId, bobId, carlaId}); } else { wait_for_removal_of({aliceId, bobId, carlaId, bob2Id}); } } void ConversationTest::testCreateConversation() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceDeviceId = aliceAccount->currentDeviceId(); auto uri = aliceAccount->getUsername(); // Start conversation auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); ConversationRepository repo(aliceAccount, convId); CPPUNIT_ASSERT(repo.mode() == ConversationMode::INVITES_ONLY); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); // Check created files auto adminCrt = repoPath / "admins" / (uri + ".crt"); CPPUNIT_ASSERT(std::filesystem::is_regular_file(adminCrt)); auto crt = std::ifstream(adminCrt); std::string adminCrtStr((std::istreambuf_iterator<char>(crt)), std::istreambuf_iterator<char>()); auto cert = aliceAccount->identity().second; auto deviceCert = cert->toString(false); auto parentCert = cert->issuer->toString(true); CPPUNIT_ASSERT(adminCrtStr == parentCert); auto deviceCrt = repoPath / "devices" / (aliceDeviceId + ".crt"); CPPUNIT_ASSERT(std::filesystem::is_regular_file(deviceCrt)); crt = std::ifstream(deviceCrt); std::string deviceCrtStr((std::istreambuf_iterator<char>(crt)), std::istreambuf_iterator<char>()); CPPUNIT_ASSERT(deviceCrtStr == deviceCert); } void ConversationTest::testOfflineConvModule() { std::cout << "\nRunning test: " << __func__ << std::endl; auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); CPPUNIT_ASSERT(carlaAccount->convModule() != nullptr); } void ConversationTest::testCreateConversationInvalidDisplayName() { std::cout << "\nRunning test: " << __func__ << std::endl; auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; bool conversationReady = false; confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& /* conversationId */) { if (accountId == aliceId) { conversationReady = true; cv.notify_one(); } })); bool aliceRegistered = false; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string&, const std::map<std::string, std::string>&) { auto details = aliceAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { aliceRegistered = true; cv.notify_one(); } })); auto messageAliceReceived = 0; confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::MessageReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, std::map<std::string, std::string> /*message*/) { if (accountId == aliceId) { messageAliceReceived += 1; } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); std::map<std::string, std::string> details; details[ConfProperties::DISPLAYNAME] = " "; libjami::setAccountDetails(aliceId, details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceRegistered; })); // Start conversation auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return conversationReady; })); messageAliceReceived = 0; libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return messageAliceReceived == 1; })); } void ConversationTest::testGetConversation() { std::cout << "\nRunning test: " << __func__ << std::endl; auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto uri = aliceAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto conversations = libjami::getConversations(aliceId); CPPUNIT_ASSERT(conversations.size() == 1); CPPUNIT_ASSERT(conversations.front() == convId); } void ConversationTest::testGetConversationsAfterRm() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto uri = aliceAccount->getUsername(); // Start conversation auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); auto conversations = libjami::getConversations(aliceId); CPPUNIT_ASSERT(conversations.size() == 1); CPPUNIT_ASSERT(libjami::removeConversation(aliceId, convId)); conversations = libjami::getConversations(aliceId); CPPUNIT_ASSERT(conversations.size() == 0); } void ConversationTest::testRemoveInvalidConversation() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); // Start conversation auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); auto conversations = libjami::getConversations(aliceId); CPPUNIT_ASSERT(conversations.size() == 1); CPPUNIT_ASSERT(!libjami::removeConversation(aliceId, "foo")); conversations = libjami::getConversations(aliceId); CPPUNIT_ASSERT(conversations.size() == 1); } void ConversationTest::testSendMessage() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / bobId / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); // Wait that alice sees Bob cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == 2; }); auto bobMsgSize = bobData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); cv.wait_for(lk, 30s, [&]() { return bobData.messages.size() == bobMsgSize + 1; }); } void ConversationTest::testSendMessageWithBadDisplayName() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); std::map<std::string, std::string> details; details[ConfProperties::DISPLAYNAME] = "<o>"; libjami::setAccountDetails(aliceId, details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.registered; })); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / bobId / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); // Wait that alice sees Bob CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == 2; })); auto bobMsgSize = bobData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.messages.size() == bobMsgSize + 1; })); } void ConversationTest::testReplaceWithBadCertificate() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // Wait that alice sees Bob cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == 2; }); // Replace alice's certificate with a bad one. auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / convId; auto aliceDevicePath = repoPath / "devices" / fmt::format("{}.crt", aliceAccount->currentDeviceId()); auto bobDevicePath = repoPath / "devices" / fmt::format("{}.crt", bobAccount->currentDeviceId()); std::filesystem::copy(bobDevicePath, aliceDevicePath, std::filesystem::copy_options::overwrite_existing); addAll(aliceAccount, convId); // Note: Do not use libjami::sendMessage as it will replace the invalid certificate by a valid one Json::Value root; root["type"] = "text/plain"; root["body"] = "hi"; Json::StreamWriterBuilder wbuilder; wbuilder["commentStyle"] = "None"; wbuilder["indentation"] = ""; auto message = Json::writeString(wbuilder, root); commitInRepo(repoPath, aliceAccount, message); // now we need to sync! bobData.errorDetected = false; libjami::sendMessage(aliceId, convId, "trigger sync!"s, ""); // We should detect the incorrect commit! cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; }); } void ConversationTest::testSendMessageTriggerMessageReceived() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto convId = libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&] { return !aliceData.conversationId.empty(); }); auto msgSize = aliceData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return aliceData.messages.size() == msgSize + 1; })); } void ConversationTest::testMergeTwoDifferentHeads() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto aliceUri = aliceAccount->getUsername(); auto carlaUri = carlaAccount->getUsername(); aliceAccount->trackBuddyPresence(carlaUri, true); carlaAccount->trackBuddyPresence(aliceUri, true); auto convId = libjami::startConversation(aliceId); auto msgSize = aliceData.messages.size(); aliceAccount->convModule()->addConversationMember(convId, dht::InfoHash(carlaUri), false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == msgSize + 1; })); // Cp conversations & convInfo auto repoPathAlice = fileutils::get_data_dir() / aliceId / "conversations"; auto repoPathCarla = fileutils::get_data_dir() / carlaAccount->getAccountID() / "conversations"; std::filesystem::copy(repoPathAlice, repoPathCarla, std::filesystem::copy_options::recursive); auto ciPathAlice = fileutils::get_data_dir() / aliceId / "convInfo"; auto ciPathCarla = fileutils::get_data_dir() / carlaAccount->getAccountID() / "convInfo"; std::filesystem::remove_all(ciPathCarla); std::filesystem::copy(ciPathAlice, ciPathCarla); carlaAccount->convModule()->loadConversations(); // necessary to load conversation // Accept for alice and makes different heads ConversationRepository repo(carlaAccount, convId); repo.join(); libjami::sendMessage(aliceId, convId, "hi"s, ""); libjami::sendMessage(aliceId, convId, "sup"s, ""); libjami::sendMessage(aliceId, convId, "jami"s, ""); // Start Carla, should merge and all messages should be there Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return !carlaData.messages.empty(); })); } void ConversationTest::testSendMessageToMultipleParticipants() { std::cout << "\nRunning test: " << __func__ << std::endl; auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); aliceAccount->trackBuddyPresence(carlaUri, true); // Enable carla std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; bool carlaConnected = false; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string&, const std::map<std::string, std::string>&) { auto details = carlaAccount->getVolatileAccountDetails(); auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; if (deviceAnnounced == "true") { carlaConnected = true; cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return carlaConnected; })); confHandlers.clear(); libjami::unregisterSignalHandlers(); auto messageReceivedAlice = 0; auto messageReceivedBob = 0; auto messageReceivedCarla = 0; auto requestReceived = 0; auto conversationReady = 0; confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::MessageReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, std::map<std::string, std::string> /*message*/) { if (accountId == aliceId) messageReceivedAlice += 1; if (accountId == bobId) messageReceivedBob += 1; if (accountId == carlaId) messageReceivedCarla += 1; cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestReceived>( [&](const std::string& /*accountId*/, const std::string& /* conversationId */, std::map<std::string, std::string> /*metadatas*/) { requestReceived += 1; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& /*accountId*/, const std::string& /* conversationId */) { conversationReady += 1; cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); libjami::addConversationMember(aliceId, convId, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return requestReceived == 2; })); messageReceivedAlice = 0; libjami::acceptConversationRequest(bobId, convId); libjami::acceptConversationRequest(carlaId, convId); // >= because we can have merges cause the accept commits CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return conversationReady == 3 && messageReceivedAlice >= 2; })); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / bobId / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); repoPath = fileutils::get_data_dir() / carlaAccount->getAccountID() / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return messageReceivedBob >= 1 && messageReceivedCarla >= 1; })); libjami::unregisterSignalHandlers(); } void ConversationTest::testPingPongMessages() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT( cv.wait_for(lk, 60s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / bobId / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); aliceMsgSize = aliceData.messages.size(); auto bobMsgSize = bobData.messages.size(); libjami::sendMessage(aliceId, convId, "ping"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 1 == bobData.messages.size() && aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::sendMessage(bobId, convId, "pong"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 2 == bobData.messages.size() && aliceMsgSize + 2 == aliceData.messages.size(); })); libjami::sendMessage(bobId, convId, "ping"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 3 == bobData.messages.size() && aliceMsgSize + 3 == aliceData.messages.size(); })); libjami::sendMessage(aliceId, convId, "pong"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 4 == bobData.messages.size() && aliceMsgSize + 4 == aliceData.messages.size(); })); } void ConversationTest::testSetMessageDisplayedTwice() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / convId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); // Check created files auto bobInvited = repoPath / "invited" / bobUri; CPPUNIT_ASSERT(std::filesystem::is_regular_file(bobInvited)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); bobData.sent = false; aliceAccount->setMessageDisplayed("swarm:" + convId, convId, 3); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.sent; })); bobData.sent = false; aliceAccount->setMessageDisplayed("swarm:" + convId, convId, 3); CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return bobData.sent; })); } void ConversationTest::testSetMessageDisplayedPreference() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto aliceUri = aliceAccount->getUsername(); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto details = aliceAccount->getAccountDetails(); CPPUNIT_ASSERT(details[ConfProperties::SENDREADRECEIPT] == "true"); details[ConfProperties::SENDREADRECEIPT] = "false"; libjami::setAccountDetails(aliceId, details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.registered; })); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); aliceAccount->setMessageDisplayed("swarm:" + convId, convId, 3); // Bob should not receive anything here, as sendMessageDisplayed is disabled for Alice CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return bobData.sent; })); } void ConversationTest::testSetMessageDisplayedAfterClone() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto aliceUri = aliceAccount->getUsername(); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); aliceAccount->setMessageDisplayed("swarm:" + convId, convId, 3); // Alice creates a second device auto aliceArchive = std::filesystem::current_path().string() + "/alice.gz"; std::remove(aliceArchive.c_str()); aliceAccount->exportArchive(aliceArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "alice2"; details[ConfProperties::ALIAS] = "alice2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = aliceArchive; alice2Id = Manager::instance().addAccount(details); // Disconnect alice2, to create a valid conv betwen Alice and alice1 CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !alice2Data.conversationId.empty(); })); // Assert that message is set as displayed for self (for the read status) auto membersInfos = libjami::getConversationMembers(aliceId, convId); CPPUNIT_ASSERT(std::find_if(membersInfos.begin(), membersInfos.end(), [&](auto infos) { return infos["uri"] == aliceUri && infos["lastDisplayed"] == convId; }) != membersInfos.end()); } void ConversationTest::testSendMessageWithLotOfKnownDevices() { std::cout << "\nRunning test: " << __func__ << std::endl; auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); // Alice creates a second device auto aliceArchive = std::filesystem::current_path().string() + "/alice.gz"; std::remove(aliceArchive.c_str()); aliceAccount->exportArchive(aliceArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "alice2"; details[ConfProperties::ALIAS] = "alice2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = aliceArchive; alice2Id = Manager::instance().addAccount(details); auto alice2Account = Manager::instance().getAccount<JamiAccount>(alice2Id); bool conversationAlice2Ready = false; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == alice2Id) { conversationAlice2Ready = true; } cv.notify_one(); })); bool alice2Registered = false; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string&, const std::map<std::string, std::string>&) { auto details = alice2Account->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { alice2Registered = true; cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return alice2Registered; })); // Add a lot of known devices for (auto i = 0; i < 1000; ++i) { dht::Hash<32> h = dht::Hash<32>::get(std::to_string(i)); aliceAccount->accountManager()->getInfo()->contacts->foundAccountDevice(h); alice2Account->accountManager()->getInfo()->contacts->foundAccountDevice(h); } auto bootstraped = std::make_shared<bool>(false); alice2Account->convModule()->onBootstrapStatus( [=](std::string /*convId*/, Conversation::BootstrapStatus status) { *bootstraped = status == Conversation::BootstrapStatus::SUCCESS; cv.notify_one(); }); auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return conversationAlice2Ready; })); // Should bootstrap successfully *bootstraped = false; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return *bootstraped; })); libjami::unregisterSignalHandlers(); } std::string ConversationTest::createFakeConversation(std::shared_ptr<JamiAccount> account, const std::string& fakeCert) { auto repoPath = fileutils::get_data_dir() / account->getAccountID() / "conversations" / "tmp"; git_repository* repo_ptr = nullptr; git_repository_init_options opts; git_repository_init_options_init(&opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION); opts.flags |= GIT_REPOSITORY_INIT_MKPATH; opts.initial_head = "main"; if (git_repository_init_ext(&repo_ptr, repoPath.c_str(), &opts) < 0) { JAMI_ERR("Unable to create a git repository in %s", repoPath.c_str()); } GitRepository repo {std::move(repo_ptr), git_repository_free}; // Add files auto deviceId = std::string(account->currentDeviceId()); repoPath = git_repository_workdir(repo.get()); auto adminsPath = repoPath / "admins"; auto devicesPath = repoPath / "devices"; auto crlsPath = repoPath / "CRLs" / deviceId; if (!dhtnet::fileutils::recursive_mkdir(adminsPath, 0700)) { JAMI_ERROR("Error when creating %s. Abort create conversations", adminsPath.c_str()); } auto cert = account->identity().second; auto deviceCert = cert->toString(false); auto parentCert = cert->issuer; if (!parentCert) { JAMI_ERR("Parent cert is null!"); } // /admins auto adminPath = adminsPath / fmt::format("{}.crt", parentCert->getId()); std::ofstream file(adminPath, std::ios::trunc | std::ios::binary); if (!file.is_open()) { JAMI_ERROR("Unable to write data to %s", adminPath.c_str()); } file << parentCert->toString(true); file.close(); if (!dhtnet::fileutils::recursive_mkdir(devicesPath, 0700)) { JAMI_ERR("Error when creating %s. Abort create conversations", devicesPath.c_str()); } // /devices auto devicePath = devicesPath / fmt::format("{}.crt", cert->getLongId()); file = std::ofstream(devicePath, std::ios::trunc | std::ios::binary); if (!file.is_open()) { JAMI_ERR("Unable to write data to %s", devicePath.c_str()); } file << (fakeCert.empty() ? deviceCert : fakeCert); file.close(); if (!dhtnet::fileutils::recursive_mkdir(crlsPath, 0700)) { JAMI_ERR("Error when creating %s. Abort create conversations", crlsPath.c_str()); } if (fakeCert.empty()) { // Add a unwanted file auto badFile = repoPath / "BAD"; file = std::ofstream(badFile, std::ios::trunc | std::ios::binary); } addAll(account, "tmp"); JAMI_INFO("Initial files added in %s", repoPath.c_str()); std::string name = account->getDisplayName(); if (name.empty()) name = deviceId; git_signature* sig_ptr = nullptr; git_index* index_ptr = nullptr; git_oid tree_id, commit_id; git_tree* tree_ptr = nullptr; git_buf to_sign = {}; // Sign commit's buffer if (git_signature_new(&sig_ptr, name.c_str(), deviceId.c_str(), std::time(nullptr), 0) < 0) { JAMI_ERR("Unable to create a commit signature."); } GitSignature sig {sig_ptr, git_signature_free}; if (git_repository_index(&index_ptr, repo.get()) < 0) { JAMI_ERR("Unable to open repository index"); } GitIndex index {index_ptr, git_index_free}; if (git_index_write_tree(&tree_id, index.get()) < 0) { JAMI_ERR("Unable to write initial tree from index"); } if (git_tree_lookup(&tree_ptr, repo.get(), &tree_id) < 0) { JAMI_ERR("Unable to look up initial tree"); } GitTree tree = {tree_ptr, git_tree_free}; Json::Value json; json["mode"] = 1; json["type"] = "initial"; Json::StreamWriterBuilder wbuilder; wbuilder["commentStyle"] = "None"; wbuilder["indentation"] = ""; if (git_commit_create_buffer(&to_sign, repo.get(), sig.get(), sig.get(), nullptr, Json::writeString(wbuilder, json).c_str(), tree.get(), 0, nullptr) < 0) { JAMI_ERR("Unable to create initial buffer"); return {}; } auto to_sign_vec = std::vector<uint8_t>(to_sign.ptr, to_sign.ptr + to_sign.size); auto signed_buf = account->identity().first->sign(to_sign_vec); std::string signed_str = base64::encode(signed_buf); // git commit -S if (git_commit_create_with_signature(&commit_id, repo.get(), to_sign.ptr, signed_str.c_str(), "signature") < 0) { JAMI_ERR("Unable to sign initial commit"); return {}; } // Move commit to main branch git_commit* commit = nullptr; if (git_commit_lookup(&commit, repo.get(), &commit_id) == 0) { git_reference* ref = nullptr; git_branch_create(&ref, repo.get(), "main", commit, true); git_commit_free(commit); git_reference_free(ref); } auto commit_str = git_oid_tostr_s(&commit_id); auto finalRepo = fileutils::get_data_dir() / account->getAccountID() / "conversations" / commit_str; std::rename(repoPath.c_str(), finalRepo.c_str()); file = std::ofstream(fileutils::get_data_dir() / account->getAccountID() / "convInfo", std::ios::trunc | std::ios::binary); std::vector<ConvInfoTest> test; test.emplace_back(ConvInfoTest {commit_str, std::time(nullptr), 0, 0}); msgpack::pack(file, test); account->convModule()->loadConversations(); // necessary to load fake conv return commit_str; } void ConversationTest::testVoteNonEmpty() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto aliceUri = aliceAccount->getUsername(); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); aliceAccount->trackBuddyPresence(carlaUri, true); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return carlaData.deviceAnnounced; })); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); aliceMsgSize = aliceData.messages.size(); auto bobMsgSize = bobData.messages.size(); libjami::addConversationMember(aliceId, convId, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size() && bobMsgSize + 1 == bobData.messages.size(); })); libjami::acceptConversationRequest(carlaId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size() && bobMsgSize + 2 == bobData.messages.size(); })); // Now Alice removes Carla with a non empty file addVote(aliceAccount, convId, carlaUri, "CONTENT"); simulateRemoval(aliceAccount, convId, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaData.errorDetected; })); } void ConversationTest::testNoBadFileInInitialCommit() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto aliceUri = aliceAccount->getUsername(); auto convId = createFakeConversation(carlaAccount); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return carlaData.deviceAnnounced; })); libjami::addConversationMember(carlaId, convId, aliceUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.requestReceived; })); libjami::acceptConversationRequest(aliceId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.errorDetected; })); } void ConversationTest::testNoBadCertInInitialCommit() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); auto fakeCert = aliceAccount->certStore().getCertificate( std::string(aliceAccount->currentDeviceId())); auto carlaCert = carlaAccount->certStore().getCertificate( std::string(carlaAccount->currentDeviceId())); CPPUNIT_ASSERT(fakeCert); // Create a conversation from Carla with Alice's device auto convId = createFakeConversation(carlaAccount, fakeCert->toString(false)); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return carlaData.deviceAnnounced; })); libjami::addConversationMember(carlaId, convId, aliceUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.requestReceived; })); libjami::acceptConversationRequest(aliceId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.errorDetected; })); } void ConversationTest::testPlainTextNoBadFile() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); std::string convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); addFile(aliceAccount, convId, "BADFILE"); Json::Value root; root["type"] = "text/plain"; root["body"] = "hi"; commit(aliceAccount, convId, root); libjami::sendMessage(aliceId, convId, "hi"s, ""); // Check not received due to the unwanted file CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testVoteNoBadFile() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto aliceUri = aliceAccount->getUsername(); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); aliceAccount->trackBuddyPresence(carlaUri, true); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaData.deviceAnnounced; })); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); aliceMsgSize = aliceData.messages.size(); auto bobMsgSize = bobData.messages.size(); libjami::addConversationMember(aliceId, convId, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaData.requestReceived && aliceMsgSize + 1 == aliceData.messages.size() && bobMsgSize + 1 == bobData.messages.size(); })); libjami::acceptConversationRequest(carlaId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size() && bobMsgSize + 2 == bobData.messages.size(); })); // Now Alice remove Carla without a vote. Bob will not receive the message addFile(aliceAccount, convId, "BADFILE"); aliceMsgSize = aliceData.messages.size(); libjami::removeConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); auto carlaMsgSize = carlaData.messages.size(); libjami::sendMessage(bobId, convId, "final"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaMsgSize + 1 == carlaData.messages.size(); })); } void ConversationTest::testETooBigClone() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / convId; std::ofstream bad(repoPath / "BADFILE"); CPPUNIT_ASSERT(bad.is_open()); for (int i = 0; i < 300 * 1024 * 1024; ++i) bad << "A"; bad.close(); addAll(aliceAccount, convId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testETooBigFetch() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // Wait that alice sees Bob CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / convId; std::ofstream bad(repoPath / "BADFILE"); CPPUNIT_ASSERT(bad.is_open()); for (int i = 0; i < 300 * 1024 * 1024; ++i) bad << "A"; bad.close(); addAll(aliceAccount, convId); Json::Value json; json["body"] = "o/"; json["type"] = "text/plain"; commit(aliceAccount, convId, json); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testUnknownModeDetected() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); ConversationRepository repo(aliceAccount, convId); Json::Value json; json["mode"] = 1412; json["type"] = "initial"; Json::StreamWriterBuilder wbuilder; wbuilder["commentStyle"] = "None"; wbuilder["indentation"] = ""; repo.amend(convId, Json::writeString(wbuilder, json)); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testUpdateProfile() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size() && !bobData.conversationId.empty(); })); auto bobMsgSize = bobData.messages.size(); aliceAccount->convModule()->updateConversationInfos(convId, {{"title", "My awesome swarm"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 1 == bobData.messages.size() && !aliceData.profile.empty() && !bobData.profile.empty(); })); auto infos = libjami::conversationInfos(bobId, convId); // Verify that we have the same profile everywhere CPPUNIT_ASSERT(infos["title"] == "My awesome swarm"); CPPUNIT_ASSERT(aliceData.profile["title"] == "My awesome swarm"); CPPUNIT_ASSERT(bobData.profile["title"] == "My awesome swarm"); CPPUNIT_ASSERT(infos["description"].empty()); CPPUNIT_ASSERT(aliceData.profile["description"].empty()); CPPUNIT_ASSERT(bobData.profile["description"].empty()); } void ConversationTest::testGetProfileRequest() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); aliceAccount->convModule()->updateConversationInfos(convId, {{"title", "My awesome swarm"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto infos = libjami::conversationInfos(bobId, convId); CPPUNIT_ASSERT(infos["title"] == "My awesome swarm"); CPPUNIT_ASSERT(infos["description"].empty()); } void ConversationTest::testCheckProfileInConversationRequest() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); aliceAccount->convModule()->updateConversationInfos(convId, {{"title", "My awesome swarm"}}); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 1); CPPUNIT_ASSERT(requests.front()["title"] == "My awesome swarm"); } void ConversationTest::testCheckProfileInTrustRequest() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); std::string vcard = "BEGIN:VCARD\n\ VERSION:2.1\n\ FN:TITLE\n\ DESCRIPTION:DESC\n\ END:VCARD"; aliceAccount->addContact(bobUri); std::vector<uint8_t> payload(vcard.begin(), vcard.end()); aliceAccount->sendTrustRequest(bobUri, payload); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return bobData.payloadTrustRequest == vcard; })); } void ConversationTest::testMemberCannotUpdateProfile() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size() && !bobData.conversationId.empty(); })); bobAccount->convModule()->updateConversationInfos(convId, {{"title", "My awesome swarm"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testUpdateProfileWithBadFile() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size() && !bobData.conversationId.empty(); })); // Update profile but with bad file addFile(aliceAccount, convId, "BADFILE"); std::string vcard = "BEGIN:VCARD\n\ VERSION:2.1\n\ FN:TITLE\n\ DESCRIPTION:DESC\n\ END:VCARD"; addFile(aliceAccount, convId, "profile.vcf", vcard); Json::Value root; root["type"] = "application/update-profile"; commit(aliceAccount, convId, root); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testFetchProfileUnauthorized() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); auto aliceMsgSize = aliceData.messages.size(); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size() && !bobData.conversationId.empty(); })); // Fake realist profile update std::string vcard = "BEGIN:VCARD\n\ VERSION:2.1\n\ FN:TITLE\n\ DESCRIPTION:DESC\n\ END:VCARD"; addFile(bobAccount, convId, "profile.vcf", vcard); Json::Value root; root["type"] = "application/update-profile"; commit(bobAccount, convId, root); libjami::sendMessage(bobId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.errorDetected; })); } void ConversationTest::testSyncingWhileAccepting() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); auto convInfos = libjami::conversationInfos(bobId, aliceData.conversationId); CPPUNIT_ASSERT(convInfos["syncing"] == "true"); CPPUNIT_ASSERT(convInfos.find("created") != convInfos.end()); Manager::instance().sendRegister(aliceId, true); // This avoid to sync immediately CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); convInfos = libjami::conversationInfos(bobId, bobData.conversationId); CPPUNIT_ASSERT(convInfos.find("syncing") == convInfos.end()); } void ConversationTest::testCountInteractions() { std::cout << "\nRunning test: " << __func__ << std::endl; auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto convId = libjami::startConversation(aliceId); std::string msgId1 = "", msgId2 = "", msgId3 = ""; aliceAccount->convModule() ->sendMessage(convId, "1"s, "", "text/plain", true, {}, [&](bool, std::string commitId) { msgId1 = commitId; cv.notify_one(); }); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return !msgId1.empty(); })); aliceAccount->convModule() ->sendMessage(convId, "2"s, "", "text/plain", true, {}, [&](bool, std::string commitId) { msgId2 = commitId; cv.notify_one(); }); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return !msgId2.empty(); })); aliceAccount->convModule() ->sendMessage(convId, "3"s, "", "text/plain", true, {}, [&](bool, std::string commitId) { msgId3 = commitId; cv.notify_one(); }); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return !msgId3.empty(); })); CPPUNIT_ASSERT(libjami::countInteractions(aliceId, convId, "", "", "") == 4 /* 3 + initial */); CPPUNIT_ASSERT(libjami::countInteractions(aliceId, convId, "", "", aliceAccount->getUsername()) == 0); CPPUNIT_ASSERT(libjami::countInteractions(aliceId, convId, msgId3, "", "") == 0); CPPUNIT_ASSERT(libjami::countInteractions(aliceId, convId, msgId2, "", "") == 1); } void ConversationTest::testReplayConversation() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // removeContact aliceAccount->removeContact(bobUri, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.removed; })); std::this_thread::sleep_for(5s); // re-add CPPUNIT_ASSERT(bobData.conversationId != ""); auto oldConvId = bobData.conversationId; aliceData.conversationId = ""; aliceAccount->addContact(bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); aliceMsgSize = aliceData.messages.size(); libjami::sendMessage(aliceId, aliceData.conversationId, "foo"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::sendMessage(aliceId, aliceData.conversationId, "bar"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); bobData.messages.clear(); aliceAccount->sendTrustRequest(bobUri, {}); // Should retrieve previous conversation CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.messages.size() == 2 && bobData.messages[0].body["body"] == "foo" && bobData.messages[1].body["body"] == "bar"; })); } void ConversationTest::testSyncWithoutPinnedCert() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); // Disconnect bob2, to create a valid conv betwen Alice and Bob1 CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.registered; })); Manager::instance().sendRegister(bob2Id, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.stopped; })); // Alice adds bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // Bob send a message libjami::sendMessage(bobId, bobData.conversationId, "hi"s, ""); cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); }); // Alice off, bob2 On Manager::instance().sendRegister(aliceId, false); cv.wait_for(lk, 10s, [&]() { return aliceData.stopped; }); Manager::instance().sendRegister(bob2Id, true); // Sync + validate CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bob2Data.conversationId.empty(); })); } void ConversationTest::testImportMalformedContacts() { std::cout << "\nRunning test: " << __func__ << std::endl; auto malformedContacts = fileutils::loadFile(std::filesystem::current_path().string() + "/conversation/rsc/incorrectContacts"); auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); archiver::compressGzip(malformedContacts, bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); wait_for_announcement_of({bob2Id}); auto contacts = libjami::getContacts(bob2Id); CPPUNIT_ASSERT(contacts.size() == 1); CPPUNIT_ASSERT(contacts[0][libjami::Account::TrustRequest::CONVERSATIONID] == ""); } void ConversationTest::testCloneFromMultipleDevice() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; })); // Alice adds bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && bob2Data.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && !bob2Data.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // Remove contact aliceAccount->removeContact(bobUri, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.removed; })); // wait that connections are closed. std::this_thread::sleep_for(10s); // Alice re-adds Bob auto oldConv = bobData.conversationId; aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // This should retrieve the conversation from Bob and don't show any error CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return aliceData.errorDetected; })); CPPUNIT_ASSERT(oldConv == aliceData.conversationId); // Check that convId didn't change and conversation is ready. } void ConversationTest::testSendReply() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); auto bobMsgSize = bobData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.messages.size() == bobMsgSize + 1; })); auto validId = bobData.messages.at(0).id; libjami::sendMessage(aliceId, convId, "foo"s, validId); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return bobData.messages.size() == bobMsgSize + 2; })); CPPUNIT_ASSERT(bobData.messages.rbegin()->body.at("reply-to") == validId); // Check if parent doesn't exists, no message is generated libjami::sendMessage(aliceId, convId, "foo"s, "invalid"); CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return bobData.messages.size() == bobMsgSize + 3; })); } void ConversationTest::testSearchInConv() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); auto aliceMsgSize = aliceData.messages.size(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // Add some messages auto bobMsgSize = bobData.messages.size(); libjami::sendMessage(aliceId, aliceData.conversationId, "message 1"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 1 == bobData.messages.size(); })); libjami::sendMessage(aliceId, aliceData.conversationId, "message 2"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 2 == bobData.messages.size(); })); libjami::sendMessage(aliceId, aliceData.conversationId, "Message 3"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 3 == bobData.messages.size(); })); libjami::searchConversation(aliceId, aliceData.conversationId, "", "", "message", "", 0, 0, 0, 0); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messagesFound.size() == 3 && aliceData.searchFinished; })); aliceData.messagesFound.clear(); aliceData.searchFinished = false; libjami::searchConversation(aliceId, aliceData.conversationId, "", "", "Message", "", 0, 0, 0, 1); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messagesFound.size() == 1 && aliceData.searchFinished; })); aliceData.messagesFound.clear(); aliceData.searchFinished = false; libjami::searchConversation(aliceId, aliceData.conversationId, "", "", "message 2", "", 0, 0, 0, 0); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messagesFound.size() == 1 && aliceData.searchFinished; })); aliceData.messagesFound.clear(); aliceData.searchFinished = false; libjami::searchConversation(aliceId, aliceData.conversationId, "", "", "foo", "", 0, 0, 0, 0); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messagesFound.size() == 0 && aliceData.searchFinished; })); } void ConversationTest::testConversationPreferences() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); // Start conversation and set preferences auto convId = libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); }); CPPUNIT_ASSERT(libjami::getConversationPreferences(aliceId, convId).size() == 0); libjami::setConversationPreferences(aliceId, convId, {{"foo", "bar"}}); auto preferences = libjami::getConversationPreferences(aliceId, convId); CPPUNIT_ASSERT(preferences.size() == 1); CPPUNIT_ASSERT(preferences["foo"] == "bar"); // Update libjami::setConversationPreferences(aliceId, convId, {{"foo", "bar2"}, {"bar", "foo"}}); preferences = libjami::getConversationPreferences(aliceId, convId); CPPUNIT_ASSERT(preferences.size() == 2); CPPUNIT_ASSERT(preferences["foo"] == "bar2"); CPPUNIT_ASSERT(preferences["bar"] == "foo"); // Remove conversations removes its preferences. CPPUNIT_ASSERT(libjami::removeConversation(aliceId, convId)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.removed; })); CPPUNIT_ASSERT(libjami::getConversationPreferences(aliceId, convId).size() == 0); } void ConversationTest::testConversationPreferencesBeforeClone() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); // Alice adds bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // Set preferences Manager::instance().sendRegister(aliceId, false); libjami::setConversationPreferences(bobId, bobData.conversationId, {{"foo", "bar"}, {"bar", "foo"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.preferences.size() == 2; })); CPPUNIT_ASSERT(bobData.preferences["foo"] == "bar" && bobData.preferences["bar"] == "foo"); // Bob2 should sync preferences std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced && !bob2Data.conversationId.empty() && !bob2Data.preferences.empty(); })); CPPUNIT_ASSERT(bob2Data.preferences["foo"] == "bar" && bob2Data.preferences["bar"] == "foo"); } void ConversationTest::testConversationPreferencesMultiDevices() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; })); // Alice adds bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && bob2Data.requestReceived; })); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && !bob2Data.conversationId.empty(); })); libjami::setConversationPreferences(bobId, bobData.conversationId, {{"foo", "bar"}, {"bar", "foo"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.preferences.size() == 2 && bob2Data.preferences.size() == 2; })); CPPUNIT_ASSERT(bobData.preferences["foo"] == "bar" && bobData.preferences["bar"] == "foo"); CPPUNIT_ASSERT(bob2Data.preferences["foo"] == "bar" && bob2Data.preferences["bar"] == "foo"); } void ConversationTest::testFixContactDetails() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return !aliceData.conversationId.empty(); })); auto details = aliceAccount->getContactDetails(bobUri); CPPUNIT_ASSERT(details["conversationId"] == aliceData.conversationId); // Erase convId from contact details, this should be fixed by next reload. CPPUNIT_ASSERT(aliceAccount->convModule()->updateConvForContact(bobUri, aliceData.conversationId, "")); details = aliceAccount->getContactDetails(bobUri); CPPUNIT_ASSERT(details["conversationId"].empty()); aliceAccount->convModule()->loadConversations(); std::this_thread::sleep_for(5s); // Let the daemon fix the structures details = aliceAccount->getContactDetails(bobUri); CPPUNIT_ASSERT(details["conversationId"] == aliceData.conversationId); } void ConversationTest::testRemoveOneToOneNotInDetails() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return !aliceData.conversationId.empty(); })); auto details = aliceAccount->getContactDetails(bobUri); CPPUNIT_ASSERT(details["conversationId"] == aliceData.conversationId); auto firstConv = aliceData.conversationId; // Create a duplicate std::this_thread::sleep_for(2s); // Avoid to get same id aliceAccount->convModule()->startConversation(ConversationMode::ONE_TO_ONE, dht::InfoHash(bobUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return firstConv != aliceData.conversationId; })); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / aliceData.conversationId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); aliceAccount->convModule()->loadConversations(); // Check that conv is removed CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.removed; })); } void ConversationTest::testMessageEdition() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); libjami::acceptConversationRequest(bobId, convId); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceData.messages.size() == aliceMsgSize + 1; })); auto bobMsgSize = bobData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.messages.size() == bobMsgSize + 1; })); auto editedId = bobData.messages.rbegin()->id; // Should trigger MessageUpdated bobMsgSize = bobData.messagesUpdated.size(); libjami::sendMessage(aliceId, convId, "New body"s, editedId, 1); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return bobData.messagesUpdated.size() == bobMsgSize + 1; })); CPPUNIT_ASSERT(bobData.messagesUpdated.rbegin()->body.at("body") == "New body"); // Not an existing message bobMsgSize = bobData.messagesUpdated.size(); libjami::sendMessage(aliceId, convId, "New body"s, "invalidId", 1); CPPUNIT_ASSERT( !cv.wait_for(lk, 10s, [&]() { return bobData.messagesUpdated.size() == bobMsgSize + 1; })); // Invalid author libjami::sendMessage(aliceId, convId, "New body"s, convId, 1); CPPUNIT_ASSERT( !cv.wait_for(lk, 10s, [&]() { return bobData.messagesUpdated.size() == bobMsgSize + 1; })); // Add invalid edition Json::Value root; root["type"] = "text/plain"; root["edit"] = convId; root["body"] = "new"; Json::StreamWriterBuilder wbuilder; wbuilder["commentStyle"] = "None"; wbuilder["indentation"] = ""; auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / convId; auto message = Json::writeString(wbuilder, root); commitInRepo(repoPath, aliceAccount, message); bobData.errorDetected = false; libjami::sendMessage(aliceId, convId, "trigger"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.errorDetected; })); } void ConversationTest::testMessageReaction() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); auto msgSize = aliceData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == msgSize + 1; })); msgSize = aliceData.messages.size(); // Add reaction auto reactId = aliceData.messages.rbegin()->id; libjami::sendMessage(aliceId, convId, "👋"s, reactId, 2); CPPUNIT_ASSERT( cv.wait_for(lk, 10s, [&]() { return aliceData.reactions.size() == 1; })); CPPUNIT_ASSERT(aliceData.reactions.rbegin()->at("react-to") == reactId); CPPUNIT_ASSERT(aliceData.reactions.rbegin()->at("body") == "👋"); auto emojiId = aliceData.reactions.rbegin()->at("id"); // Remove reaction libjami::sendMessage(aliceId, convId, ""s, emojiId, 1); CPPUNIT_ASSERT( cv.wait_for(lk, 10s, [&]() { return aliceData.reactionRemoved.size() == 1; })); CPPUNIT_ASSERT(emojiId == aliceData.reactionRemoved[0]); } void ConversationTest::testMessageEditionWithReaction() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); auto msgSize = aliceData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == msgSize + 1; })); msgSize = aliceData.messages.size(); // Add reaction auto reactId = aliceData.messages.rbegin()->id; libjami::sendMessage(aliceId, convId, "👋"s, reactId, 2); CPPUNIT_ASSERT( cv.wait_for(lk, 10s, [&]() { return aliceData.reactions.size() == 1; })); CPPUNIT_ASSERT(aliceData.reactions.rbegin()->at("react-to") == reactId); CPPUNIT_ASSERT(aliceData.reactions.rbegin()->at("body") == "👋"); auto emojiId = aliceData.reactions.rbegin()->at("id"); // Remove base message should remove reaction libjami::sendMessage(aliceId, convId, ""s, reactId, 1); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return aliceData.messagesUpdated.size() == 1; })); // Reaction is deleted CPPUNIT_ASSERT(aliceData.messagesUpdated[0].reactions.empty()); } void ConversationTest::testLoadPartiallyRemovedConversation() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); // Copy alice's conversation temporary auto repoPathAlice = fileutils::get_data_dir() / aliceId / "conversations" / aliceData.conversationId; std::filesystem::copy(repoPathAlice, fmt::format("./{}", aliceData.conversationId), std::filesystem::copy_options::recursive); // removeContact aliceAccount->removeContact(bobUri, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.removed; })); std::this_thread::sleep_for(10s); // Wait for connection to close and async tasks to finish // Copy back alice's conversation std::filesystem::copy(fmt::format("./{}", aliceData.conversationId), repoPathAlice, std::filesystem::copy_options::recursive); std::filesystem::remove_all(fmt::format("./{}", aliceData.conversationId)); // Reloading conversation should remove directory CPPUNIT_ASSERT(std::filesystem::is_directory(repoPathAlice)); aliceAccount->convModule()->loadConversations(); std::this_thread::sleep_for(5s); // Let the daemon the time to fix structures CPPUNIT_ASSERT(!std::filesystem::is_directory(repoPathAlice)); } void ConversationTest::testReactionsOnEditedMessage() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto convId = libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty(); })); auto msgSize = aliceData.messages.size(); libjami::sendMessage(aliceId, convId, "hi"s, ""); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == msgSize + 1; })); msgSize = aliceData.messages.size(); // Add reaction auto reactId = aliceData.messages.rbegin()->id; libjami::sendMessage(aliceId, convId, "👋"s, reactId, 2); CPPUNIT_ASSERT( cv.wait_for(lk, 10s, [&]() { return aliceData.reactions.size() == 1; })); CPPUNIT_ASSERT(aliceData.reactions.rbegin()->at("react-to") == reactId); CPPUNIT_ASSERT(aliceData.reactions.rbegin()->at("body") == "👋"); auto emojiId = aliceData.reactions.rbegin()->at("id"); // Edit message aliceData.messagesUpdated.clear(); libjami::sendMessage(aliceId, convId, "EDITED"s, reactId, 1); CPPUNIT_ASSERT( cv.wait_for(lk, 10s, [&]() { return aliceData.messagesUpdated.size() == 1; })); // Reaction is kept CPPUNIT_ASSERT(emojiId == aliceData.messagesUpdated[0].reactions[0]["id"]); } void ConversationTest::testUpdateProfileMultiDevice() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.registered; })); // Bob creates a conversation auto convId = libjami::startConversation(bobId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bob2Data.conversationId.empty(); })); auto bobMsgSize = bobData.messages.size(); auto bob2Account = Manager::instance().getAccount<JamiAccount>(bob2Id); bob2Account->convModule()->updateConversationInfos(bob2Data.conversationId, {{"title", "My awesome swarm"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobMsgSize + 1 == bobData.messages.size(); })); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::ConversationTest::name())
104,226
C++
.cpp
2,098
42.903718
180
0.66721
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,660
call.cpp
savoirfairelinux_jami-daemon/test/unitTest/conversation/call.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <filesystem> #include <string> #include "../../test_runner.h" #include "account_const.h" #include "common.h" #include "conversation/conversationcommon.h" #include "manager.h" #include "media_const.h" #include "sip/sipcall.h" using namespace std::literals::chrono_literals; namespace jami { namespace test { struct ConvData { std::string id {}; std::string callId {}; std::string confId {}; bool requestReceived {false}; bool needsHost {false}; bool conferenceChanged {false}; bool conferenceRemoved {false}; std::string hostState {}; std::string state {}; std::vector<libjami::SwarmMessage> messages {}; }; class ConversationCallTest : public CppUnit::TestFixture { public: ~ConversationCallTest() { libjami::fini(); } static std::string name() { return "ConversationCallTest"; } void setUp(); void tearDown(); std::string aliceId; std::string bobId; std::string bob2Id; std::string carlaId; ConvData aliceData_; ConvData bobData_; ConvData bob2Data_; ConvData carlaData_; std::vector<std::map<std::string, std::string>> pInfos_ {}; std::mutex mtx; std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; private: void connectSignals(); void enableCarla(); void testActiveCalls(); void testActiveCalls3Peers(); void testRejoinCall(); void testParticipantHangupConfNotRemoved(); void testJoinFinishedCall(); void testJoinFinishedCallForbidden(); void testUsePreference(); void testJoinWhileActiveCall(); void testCallSelfIfDefaultHost(); void testNeedsHost(); void testAudioOnly(); void testJoinAfterMuteHost(); void testBusy(); void testDecline(); void testNoDevice(); CPPUNIT_TEST_SUITE(ConversationCallTest); CPPUNIT_TEST(testActiveCalls); CPPUNIT_TEST(testActiveCalls3Peers); CPPUNIT_TEST(testRejoinCall); CPPUNIT_TEST(testParticipantHangupConfNotRemoved); CPPUNIT_TEST(testJoinFinishedCall); CPPUNIT_TEST(testJoinFinishedCallForbidden); CPPUNIT_TEST(testUsePreference); CPPUNIT_TEST(testJoinWhileActiveCall); CPPUNIT_TEST(testCallSelfIfDefaultHost); CPPUNIT_TEST(testNeedsHost); CPPUNIT_TEST(testAudioOnly); CPPUNIT_TEST(testJoinAfterMuteHost); CPPUNIT_TEST(testBusy); CPPUNIT_TEST(testDecline); CPPUNIT_TEST(testNoDevice); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConversationCallTest, ConversationCallTest::name()); void ConversationCallTest::setUp() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); auto actors = load_actors("actors/alice-bob-carla.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; carlaId = actors["carla"]; aliceData_ = {}; bobData_ = {}; bob2Data_ = {}; carlaData_ = {}; Manager::instance().sendRegister(carlaId, false); wait_for_announcement_of({aliceId, bobId}); } void ConversationCallTest::tearDown() { auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); if (bob2Id.empty()) { wait_for_removal_of({aliceId, bobId, carlaId}); } else { wait_for_removal_of({aliceId, bobId, carlaId, bob2Id}); } } void ConversationCallTest::connectSignals() { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == aliceId) aliceData_.id = conversationId; else if (accountId == bobId) bobData_.id = conversationId; else if (accountId == bob2Id) bob2Data_.id = conversationId; else if (accountId == carlaId) carlaData_.id = conversationId; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmMessageReceived>( [&](const std::string& accountId, const std::string& conversationId, const libjami::SwarmMessage& message) { if (accountId == aliceId && aliceData_.id == conversationId) aliceData_.messages.emplace_back(message); if (accountId == bobId && bobData_.id == conversationId) bobData_.messages.emplace_back(message); if (accountId == bob2Id && bob2Data_.id == conversationId) bob2Data_.messages.emplace_back(message); if (accountId == carlaId && carlaData_.id == conversationId) carlaData_.messages.emplace_back(message); cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestReceived>( [&](const std::string& accountId, const std::string& /*conversationId*/, std::map<std::string, std::string> /*metadatas*/) { if (accountId == aliceId) aliceData_.requestReceived = true; if (accountId == bobId) bobData_.requestReceived = true; if (accountId == bob2Id) bob2Data_.requestReceived = true; if (accountId == carlaId) carlaData_.requestReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::NeedsHost>( [&](const std::string& accountId, const std::string& /*conversationId*/) { if (accountId == aliceId) aliceData_.needsHost = true; if (accountId == bobId) bobData_.needsHost = true; if (accountId == bob2Id) bob2Data_.needsHost = true; if (accountId == carlaId) carlaData_.needsHost = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::ConferenceChanged>( [&](const std::string& accountId, const std::string&, const std::string&) { if (accountId == aliceId) aliceData_.conferenceChanged = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::ConferenceCreated>( [&](const std::string& accountId, const std::string&, const std::string& confId) { if (accountId == aliceId) aliceData_.confId = confId; else if (accountId == bobId) bobData_.confId = confId; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::ConferenceRemoved>( [&](const std::string& accountId, const std::string&) { if (accountId == aliceId) aliceData_.conferenceRemoved = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::StateChange>( [&](const std::string& accountId, const std::string& callId, const std::string& state, signed) { if (accountId == aliceId) { auto details = libjami::getCallDetails(aliceId, callId); if (details.find("PEER_NUMBER") != details.end()) { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); if (details["PEER_NUMBER"].find(bobUri) != std::string::npos) bobData_.hostState = state; else if (details["PEER_NUMBER"].find(carlaUri) != std::string::npos) carlaData_.hostState = state; } } else if (accountId == bobId) { bobData_.callId = callId; bobData_.state = state; } else if (accountId == carlaId) { carlaData_.state = state; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::CallSignal::OnConferenceInfosUpdated>( [=](const std::string&, const std::vector<std::map<std::string, std::string>> participantsInfos) { pInfos_ = participantsInfos; cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); } void ConversationCallTest::enableCarla() { auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); // Enable carla std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; bool carlaConnected = false; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string&, const std::map<std::string, std::string>&) { auto details = carlaAccount->getVolatileAccountDetails(); auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; if (deviceAnnounced == "true") { carlaConnected = true; cv.notify_one(); } })); libjami::registerSignalHandlers(confHandlers); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return carlaConnected; })); confHandlers.clear(); libjami::unregisterSignalHandlers(); } void ConversationCallTest::testActiveCalls() { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); connectSignals(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); // start call aliceData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.conferenceChanged && !aliceData_.messages.empty(); }); CPPUNIT_ASSERT(aliceData_.messages.rbegin()->type == "application/call-history+json"); // get active calls = 1 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 1); // hangup aliceData_.messages.clear(); Manager::instance().hangupConference(aliceId, aliceData_.confId); // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty(); })); CPPUNIT_ASSERT(aliceData_.messages.rbegin()->body.find("duration") != aliceData_.messages.rbegin()->body.end()); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); } void ConversationCallTest::testActiveCalls3Peers() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); libjami::addConversationMember(aliceId, aliceData_.id, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived && carlaData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); aliceData_.messages.clear(); libjami::acceptConversationRequest(carlaId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !carlaData_.id.empty() && !aliceData_.messages.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && lastCommitIsCall(carlaData_); }); auto confId = bobData_.messages.rbegin()->body.at("confId"); auto destination = fmt::format("rdv:{}/{}/{}/{}", bobData_.id, bobData_.messages.rbegin()->body.at("uri"), bobData_.messages.rbegin()->body.at("device"), confId); aliceData_.conferenceChanged = false; libjami::placeCallWithMedia(bobId, destination, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && bobData_.hostState == "CURRENT"; })); aliceData_.conferenceChanged = false; // get 2 other participants libjami::placeCallWithMedia(carlaId, destination, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && carlaData_.hostState == "CURRENT" && libjami::getParticipantList(aliceId, confId).size() == 2; })); // get active calls = 1 CPPUNIT_ASSERT(libjami::getActiveCalls(bobId, bobData_.id).size() == 1); // hangup aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); Manager::instance().hangupConference(aliceId, confId); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !bobData_.messages.empty() && !carlaData_.messages.empty(); }); CPPUNIT_ASSERT(aliceData_.messages[0].body.find("duration") != aliceData_.messages[0].body.end()); CPPUNIT_ASSERT(bobData_.messages[0].body.find("duration") != bobData_.messages[0].body.end()); CPPUNIT_ASSERT(carlaData_.messages[0].body.find("duration") != carlaData_.messages[0].body.end()); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); } void ConversationCallTest::testRejoinCall() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); libjami::addConversationMember(aliceId, aliceData_.id, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived && carlaData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); aliceData_.messages.clear(); libjami::acceptConversationRequest(carlaId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !carlaData_.id.empty() && !aliceData_.messages.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && lastCommitIsCall(carlaData_); }); auto confId = bobData_.messages.rbegin()->body.at("confId"); auto destination = fmt::format("rdv:{}/{}/{}/{}", bobData_.id, bobData_.messages.rbegin()->body.at("uri"), bobData_.messages.rbegin()->body.at("device"), confId); aliceData_.conferenceChanged = false; libjami::placeCallWithMedia(bobId, destination, {}); cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && bobData_.hostState == "CURRENT" && bobData_.state == "CURRENT"; }); aliceData_.conferenceChanged = false; libjami::placeCallWithMedia(carlaId, destination, {}); cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && carlaData_.hostState == "CURRENT" && carlaData_.state == "CURRENT"; }); CPPUNIT_ASSERT(libjami::getParticipantList(aliceId, confId).size() == 2); // hangup 1 participant and rejoin aliceData_.messages.clear(); bobData_.messages.clear(); aliceData_.conferenceChanged = false; Manager::instance().hangupCall(bobId, bobData_.callId); cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && bobData_.hostState == "OVER"; }); CPPUNIT_ASSERT(libjami::getParticipantList(aliceId, confId).size() == 1); aliceData_.conferenceChanged = false; libjami::placeCallWithMedia(bobId, destination, {}); cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && bobData_.hostState == "CURRENT"; }); CPPUNIT_ASSERT(libjami::getParticipantList(aliceId, confId).size() == 2); CPPUNIT_ASSERT(aliceData_.messages.empty()); CPPUNIT_ASSERT(bobData_.messages.empty()); // hangup aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); Manager::instance().hangupConference(aliceId, confId); // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !bobData_.messages.empty() && !carlaData_.messages.empty(); })); CPPUNIT_ASSERT(aliceData_.messages[0].body.find("duration") != aliceData_.messages[0].body.end()); CPPUNIT_ASSERT(bobData_.messages[0].body.find("duration") != bobData_.messages[0].body.end()); CPPUNIT_ASSERT(carlaData_.messages[0].body.find("duration") != carlaData_.messages[0].body.end()); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); } void ConversationCallTest::testParticipantHangupConfNotRemoved() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_); }); auto destination = fmt::format("rdv:{}/{}/{}/{}", bobData_.id, bobData_.messages.rbegin()->body.at("uri"), bobData_.messages.rbegin()->body.at("device"), bobData_.messages.rbegin()->body.at("confId")); aliceData_.conferenceChanged = false; auto bobCallId = libjami::placeCallWithMedia(bobId, destination, {}); cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && bobData_.hostState == "CURRENT"; }); // hangup bob MUST NOT stop the conference aliceData_.messages.clear(); bobData_.messages.clear(); aliceData_.conferenceChanged = false; Manager::instance().hangupCall(bobId, bobCallId); CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return aliceData_.conferenceRemoved; })); } void ConversationCallTest::testJoinFinishedCall() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); libjami::addConversationMember(aliceId, aliceData_.id, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived && carlaData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); aliceData_.messages.clear(); libjami::acceptConversationRequest(carlaId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !carlaData_.id.empty() && !aliceData_.messages.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && lastCommitIsCall(carlaData_); }); auto confId = bobData_.messages.rbegin()->body.at("confId"); auto destination = fmt::format("rdv:{}/{}/{}/{}", bobData_.id, bobData_.messages.rbegin()->body.at("uri"), bobData_.messages.rbegin()->body.at("device"), bobData_.messages.rbegin()->body.at("confId")); // hangup aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); Manager::instance().hangupConference(aliceId, aliceData_.confId); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !bobData_.messages.empty() && !carlaData_.messages.empty(); }); CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); // If bob try to join the call, it will re-host a new conference // and commit a new active call. auto bobCall = libjami::placeCallWithMedia(bobId, destination, {}); // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && lastCommitIsCall(carlaData_) && bobData_.hostState == "CURRENT"; }); confId = bobData_.messages.rbegin()->body.at("confId"); CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 1); // hangup aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); Manager::instance().hangupConference(aliceId, confId); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !bobData_.messages.empty() && !carlaData_.messages.empty(); }); CPPUNIT_ASSERT(aliceData_.messages[0].body.find("duration") != aliceData_.messages[0].body.end()); CPPUNIT_ASSERT(bobData_.messages[0].body.find("duration") != bobData_.messages[0].body.end()); CPPUNIT_ASSERT(carlaData_.messages[0].body.find("duration") != carlaData_.messages[0].body.end()); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); } void ConversationCallTest::testJoinFinishedCallForbidden() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); // Do not host conference for others libjami::setConversationPreferences(aliceId, aliceData_.id, {{"hostConference", "false"}}); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); libjami::addConversationMember(aliceId, aliceData_.id, carlaUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived && carlaData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); aliceData_.messages.clear(); libjami::acceptConversationRequest(carlaId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !carlaData_.id.empty() && !aliceData_.messages.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && lastCommitIsCall(carlaData_); }); auto confId = bobData_.messages.rbegin()->body.at("confId"); auto destination = fmt::format("rdv:{}/{}/{}/{}", bobData_.id, bobData_.messages.rbegin()->body.at("uri"), bobData_.messages.rbegin()->body.at("device"), bobData_.messages.rbegin()->body.at("confId")); // hangup aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); Manager::instance().hangupConference(aliceId, aliceData_.confId); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !bobData_.messages.empty() && !carlaData_.messages.empty(); }); CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); // If bob try to join the call, it will re-host a new conference // and commit a new active call. auto bobCall = libjami::placeCallWithMedia(bobId, destination, {}); // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && lastCommitIsCall(carlaData_) && bobData_.hostState == "CURRENT"; }); confId = bobData_.messages.rbegin()->body.at("confId"); CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 1); // hangup aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); Manager::instance().hangupConference(aliceId, confId); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !bobData_.messages.empty() && !carlaData_.messages.empty(); }); CPPUNIT_ASSERT(aliceData_.messages[0].body.find("duration") != aliceData_.messages[0].body.end()); CPPUNIT_ASSERT(bobData_.messages[0].body.find("duration") != bobData_.messages[0].body.end()); CPPUNIT_ASSERT(carlaData_.messages[0].body.find("duration") != carlaData_.messages[0].body.end()); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); } void ConversationCallTest::testUsePreference() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto aliceDevice = std::string(aliceAccount->currentDeviceId()); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); // Update preferences aliceData_.messages.clear(); bobData_.messages.clear(); auto lastCommitIsProfile = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/update-profile"; }; libjami::updateConversationInfos(aliceId, aliceData_.id, std::map<std::string, std::string> { {"rdvAccount", aliceUri}, {"rdvDevice", aliceDevice}, }); // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsProfile(aliceData_) && lastCommitIsProfile(bobData_); }); // start call aliceData_.messages.clear(); bobData_.messages.clear(); libjami::placeCallWithMedia(bobId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_); }); auto confId = bobData_.messages.rbegin()->body.at("confId"); // Alice should be the host CPPUNIT_ASSERT(aliceAccount->getConference(confId)); // Bob should be the only participant CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&]() { return pInfos_.size() == 1; })); auto uri = string_remove_suffix(pInfos_[0]["uri"], '@'); CPPUNIT_ASSERT(uri == bobUri); Manager::instance().hangupConference(bobId, bobData_.confId); } void ConversationCallTest::testJoinWhileActiveCall() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); // start call aliceData_.messages.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_); })); auto confId = aliceData_.messages.rbegin()->body.at("confId"); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); CPPUNIT_ASSERT(libjami::getActiveCalls(bobId, bobData_.id).size() == 1); aliceData_.messages.clear(); bobData_.messages.clear(); aliceData_.conferenceChanged = false; Manager::instance().hangupConference(aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return aliceData_.conferenceRemoved; })); } void ConversationCallTest::testCallSelfIfDefaultHost() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto aliceDevice = std::string(aliceAccount->currentDeviceId()); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); // Update preferences aliceData_.messages.clear(); bobData_.messages.clear(); auto lastCommitIsProfile = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/update-profile"; }; libjami::updateConversationInfos(aliceId, aliceData_.id, std::map<std::string, std::string> { {"rdvAccount", aliceUri}, {"rdvDevice", aliceDevice}, }); // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsProfile(aliceData_) && lastCommitIsProfile(bobData_); }); // start call aliceData_.messages.clear(); bobData_.messages.clear(); pInfos_.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, {}); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/call-history+json"; }; // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_); })); auto confId = aliceData_.messages.rbegin()->body.at("confId"); // Alice should be the host CPPUNIT_ASSERT(aliceAccount->getConference(confId)); Manager::instance().hangupConference(aliceId, confId); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return aliceData_.conferenceRemoved; })); } void ConversationCallTest::testNeedsHost() { enableCarla(); connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto aliceDevice = std::string(aliceAccount->currentDeviceId()); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); // Update preferences aliceData_.messages.clear(); bobData_.messages.clear(); auto lastCommitIsProfile = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->body.at("type") == "application/update-profile"; }; libjami::updateConversationInfos(aliceId, aliceData_.id, std::map<std::string, std::string> { {"rdvAccount", aliceUri}, {"rdvDevice", aliceDevice}, }); // should get message cv.wait_for(lk, 30s, [&]() { return lastCommitIsProfile(aliceData_) && lastCommitIsProfile(bobData_); }); // Disable Host Manager::instance().sendRegister(aliceId, false); // start call libjami::placeCallWithMedia(bobId, "swarm:" + aliceData_.id, {}); // Can fail after 30 seconds if it triggers a new ICE request (before No response from DHT) CPPUNIT_ASSERT(cv.wait_for(lk, 40s, [&]() { return bobData_.needsHost; })); } void ConversationCallTest::testAudioOnly() { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); connectSignals(); // Start conversation libjami::startConversation(aliceId); cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); }); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); // start call aliceData_.messages.clear(); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); pInfos_.clear(); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, mediaList); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty() && !pInfos_.empty(); }); CPPUNIT_ASSERT(aliceData_.messages[0].type == "application/call-history+json"); CPPUNIT_ASSERT(pInfos_.size() == 1); CPPUNIT_ASSERT(pInfos_[0]["videoMuted"] == "true"); // hangup aliceData_.messages.clear(); Manager::instance().hangupConference(aliceId, aliceData_.confId); // should get message cv.wait_for(lk, 30s, [&]() { return !aliceData_.messages.empty(); }); CPPUNIT_ASSERT(aliceData_.messages[0].body.find("duration") != aliceData_.messages[0].body.end()); // get active calls = 0 CPPUNIT_ASSERT(libjami::getActiveCalls(aliceId, aliceData_.id).size() == 0); } void ConversationCallTest::testJoinAfterMuteHost() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); // Start conversation libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData_.id.empty(); })); libjami::addConversationMember(aliceId, aliceData_.id, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return bobData_.requestReceived; })); aliceData_.messages.clear(); libjami::acceptConversationRequest(bobId, aliceData_.id); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty() && !aliceData_.messages.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); libjami::placeCallWithMedia(aliceId, "swarm:" + aliceData_.id, mediaList); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->type == "application/call-history+json"; }; // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return lastCommitIsCall(aliceData_) && lastCommitIsCall(bobData_) && !pInfos_.empty(); })); auto confId = bobData_.messages.rbegin()->body.at("confId"); // Mute host auto conference = aliceAccount->getConference(aliceData_.confId); auto proposedList = conference->currentMediaList(); for (auto& media : proposedList) if (media["LABEL"] == "audio_0") media["MUTED"] = "true"; libjami::requestMediaChange(aliceId, confId, proposedList); // Bob join, alice must stay muted auto destination = fmt::format("rdv:{}/{}/{}/{}", bobData_.id, bobData_.messages.rbegin()->body.at("uri"), bobData_.messages.rbegin()->body.at("device"), confId); aliceData_.conferenceChanged = false; pInfos_.clear(); auto bobCall = libjami::placeCallWithMedia(bobId, destination, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData_.conferenceChanged && bobData_.hostState == "CURRENT" && bobData_.state == "CURRENT" && pInfos_.size() == 2; })); // Audio of the host is still muted CPPUNIT_ASSERT(pInfos_[0]["audioLocalMuted"] == "true"); } void ConversationCallTest::testBusy() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData_.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); libjami::placeCallWithMedia(aliceId, bobUri, mediaList); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->type == "application/call-history+json"; }; // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return lastCommitIsCall(aliceData_); })); auto reason = aliceData_.messages.rbegin()->body.at("reason"); CPPUNIT_ASSERT(reason == "busy"); } void ConversationCallTest::testDecline() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData_.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData_.id.empty(); })); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); libjami::placeCallWithMedia(aliceId, bobUri, mediaList); CPPUNIT_ASSERT(cv.wait_for(lk, 10s, [&]() { return !bobData_.callId.empty() && bobData_.state == "INCOMING"; })); libjami::refuse(bobId, bobData_.callId); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->type == "application/call-history+json"; }; // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return lastCommitIsCall(aliceData_); })); auto reason = aliceData_.messages.rbegin()->body.at("reason"); CPPUNIT_ASSERT(reason == "declined"); } void ConversationCallTest::testNoDevice() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact("e2eb225c76be68713d4874d290200849436c6355"); aliceAccount->sendTrustRequest("e2eb225c76be68713d4874d290200849436c6355", {}); // start call aliceData_.messages.clear(); bobData_.messages.clear(); carlaData_.messages.clear(); std::vector<std::map<std::string, std::string>> mediaList; std::map<std::string, std::string> mediaAttribute = {{libjami::Media::MediaAttributeKey::MEDIA_TYPE, libjami::Media::MediaAttributeValue::AUDIO}, {libjami::Media::MediaAttributeKey::ENABLED, TRUE_STR}, {libjami::Media::MediaAttributeKey::MUTED, FALSE_STR}, {libjami::Media::MediaAttributeKey::SOURCE, ""}, {libjami::Media::MediaAttributeKey::LABEL, "audio_0"}}; mediaList.emplace_back(mediaAttribute); libjami::placeCallWithMedia(aliceId, "e2eb225c76be68713d4874d290200849436c6355", mediaList); auto lastCommitIsCall = [&](const auto& data) { return !data.messages.empty() && data.messages.rbegin()->type == "application/call-history+json"; }; // should get message CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return lastCommitIsCall(aliceData_); })); auto reason = aliceData_.messages.rbegin()->body.at("reason"); CPPUNIT_ASSERT(reason == "no_device"); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::ConversationCallTest::name())
50,435
C++
.cpp
1,105
38.145701
141
0.644112
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,661
conversationRequest.cpp
savoirfairelinux_jami-daemon/test/unitTest/conversation/conversationRequest.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <string> #include <fstream> #include <streambuf> #include <git2.h> #include <filesystem> #include <msgpack.hpp> #include "manager.h" #include "jamidht/conversation.h" #include "jamidht/conversationrepository.h" #include "jamidht/jamiaccount.h" #include "../../test_runner.h" #include "jami.h" #include "base64.h" #include "fileutils.h" #include "account_const.h" #include "common.h" using namespace std::string_literals; using namespace std::literals::chrono_literals; using namespace libjami::Account; namespace jami { namespace test { struct UserData { std::string conversationId; bool removed {false}; bool requestReceived {false}; bool requestRemoved {false}; bool registered {false}; bool stopped {false}; bool deviceAnnounced {false}; bool contactAdded {false}; bool contactRemoved {false}; std::string profilePath; std::string payloadTrustRequest; std::vector<libjami::SwarmMessage> messages; std::vector<libjami::SwarmMessage> messagesUpdated; }; class ConversationRequestTest : public CppUnit::TestFixture { public: ~ConversationRequestTest() { libjami::fini(); } static std::string name() { return "ConversationRequest"; } void setUp(); void tearDown(); void testAcceptTrustRemoveConvReq(); void acceptConvReqAlsoAddContact(); void testGetRequests(); void testDeclineRequest(); void testAddContact(); void testDeclineConversationRequestRemoveTrustRequest(); void testMalformedTrustRequest(); void testAddContactDeleteAndReAdd(); void testRemoveContact(); void testRemoveContactMultiDevice(); void testRemoveSelfDoesntRemoveConversation(); void testRemoveConversationUpdateContactDetails(); void testBanContact(); void testBanContactRestartAccount(); void testBanContactRemoveTrustRequest(); void testAddOfflineContactThenConnect(); void testDeclineTrustRequestDoNotGenerateAnother(); void testRemoveContactRemoveSyncing(); void testRemoveConversationRemoveSyncing(); void testCacheRequestFromClient(); void testNeedsSyncingWithForCloning(); void testRemoveContactRemoveTrustRequest(); void testAddConversationNoPresenceThenConnects(); void testRequestBigPayload(); void testBothRemoveReadd(); void doNotLooseMetadata(); std::string aliceId; UserData aliceData; std::string bobId; UserData bobData; std::string bob2Id; UserData bob2Data; std::string carlaId; UserData carlaData; std::mutex mtx; std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; void connectSignals(); private: CPPUNIT_TEST_SUITE(ConversationRequestTest); CPPUNIT_TEST(testAcceptTrustRemoveConvReq); CPPUNIT_TEST(acceptConvReqAlsoAddContact); CPPUNIT_TEST(testGetRequests); CPPUNIT_TEST(testDeclineRequest); CPPUNIT_TEST(testAddContact); CPPUNIT_TEST(testDeclineConversationRequestRemoveTrustRequest); CPPUNIT_TEST(testMalformedTrustRequest); CPPUNIT_TEST(testAddContactDeleteAndReAdd); CPPUNIT_TEST(testRemoveContact); CPPUNIT_TEST(testRemoveContactMultiDevice); CPPUNIT_TEST(testRemoveSelfDoesntRemoveConversation); CPPUNIT_TEST(testRemoveConversationUpdateContactDetails); CPPUNIT_TEST(testBanContact); CPPUNIT_TEST(testBanContactRestartAccount); CPPUNIT_TEST(testBanContactRemoveTrustRequest); CPPUNIT_TEST(testAddOfflineContactThenConnect); CPPUNIT_TEST(testDeclineTrustRequestDoNotGenerateAnother); CPPUNIT_TEST(testRemoveContactRemoveSyncing); CPPUNIT_TEST(testRemoveConversationRemoveSyncing); CPPUNIT_TEST(testCacheRequestFromClient); CPPUNIT_TEST(testNeedsSyncingWithForCloning); CPPUNIT_TEST(testRemoveContactRemoveTrustRequest); CPPUNIT_TEST(testAddConversationNoPresenceThenConnects); CPPUNIT_TEST(testRequestBigPayload); CPPUNIT_TEST(testBothRemoveReadd); CPPUNIT_TEST(doNotLooseMetadata); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConversationRequestTest, ConversationRequestTest::name()); void ConversationRequestTest::setUp() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); auto actors = load_actors("actors/alice-bob-carla.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; carlaId = actors["carla"]; aliceData = {}; bobData = {}; bob2Data = {}; carlaData = {}; Manager::instance().sendRegister(carlaId, false); wait_for_announcement_of({aliceId, bobId}); } void ConversationRequestTest::connectSignals() { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string& accountId, const std::map<std::string, std::string>&) { if (accountId == aliceId) { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto details = aliceAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { aliceData.registered = true; } else if (daemonStatus == "UNREGISTERED") { aliceData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; aliceData.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == bobId) { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto details = bobAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bobData.registered = true; } else if (daemonStatus == "UNREGISTERED") { bobData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; bobData.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == bob2Id) { auto bob2Account = Manager::instance().getAccount<JamiAccount>(bob2Id); auto details = bob2Account->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bob2Data.registered = true; } else if (daemonStatus == "UNREGISTERED") { bob2Data.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; bob2Data.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == carlaId) { auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto details = carlaAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { carlaData.registered = true; } else if (daemonStatus == "UNREGISTERED") { carlaData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; carlaData.deviceAnnounced = deviceAnnounced == "true"; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == aliceId) { aliceData.conversationId = conversationId; } else if (accountId == bobId) { bobData.conversationId = conversationId; } else if (accountId == bob2Id) { bob2Data.conversationId = conversationId; } else if (accountId == carlaId) { carlaData.conversationId = conversationId; } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::IncomingTrustRequest>( [&](const std::string& account_id, const std::string& /*from*/, const std::string& /*conversationId*/, const std::vector<uint8_t>& payload, time_t /*received*/) { auto payloadStr = std::string(payload.data(), payload.data() + payload.size()); if (account_id == aliceId) aliceData.payloadTrustRequest = payloadStr; else if (account_id == bobId) bobData.payloadTrustRequest = payloadStr; cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, std::map<std::string, std::string> /*metadatas*/) { if (accountId == aliceId) { aliceData.requestReceived = true; } else if (accountId == bobId) { bobData.requestReceived = true; } else if (accountId == bob2Id) { bob2Data.requestReceived = true; } else if (accountId == carlaId) { carlaData.requestReceived = true; } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestDeclined>( [&](const std::string& accountId, const std::string&) { if (accountId == bobId) { bobData.requestRemoved = true; } else if (accountId == bob2Id) { bob2Data.requestRemoved = true; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmMessageReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, libjami::SwarmMessage message) { if (accountId == aliceId) { aliceData.messages.emplace_back(message); } else if (accountId == bobId) { bobData.messages.emplace_back(message); } else if (accountId == carlaId) { carlaData.messages.emplace_back(message); } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmMessageUpdated>( [&](const std::string& accountId, const std::string& /* conversationId */, libjami::SwarmMessage message) { if (accountId == aliceId) { aliceData.messagesUpdated.emplace_back(message); } else if (accountId == bobId) { bobData.messagesUpdated.emplace_back(message); } else if (accountId == carlaId) { carlaData.messagesUpdated.emplace_back(message); } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRemoved>( [&](const std::string& accountId, const std::string&) { if (accountId == aliceId) aliceData.removed = true; else if (accountId == bobId) bobData.removed = true; else if (accountId == bob2Id) bob2Data.removed = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::ContactAdded>( [&](const std::string& accountId, const std::string&, bool) { if (accountId == bobId) { bobData.contactAdded = true; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::ContactRemoved>( [&](const std::string& accountId, const std::string&, bool) { if (accountId == bobId) { bobData.contactRemoved = true; } else if (accountId == bob2Id) { bob2Data.contactRemoved = true; } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); } void ConversationRequestTest::tearDown() { auto bobArchive = std::filesystem::current_path() / "bob.gz"; std::filesystem::remove(bobArchive); if (bob2Id.empty()) { wait_for_removal_of({aliceId, bobId, carlaId}); } else { wait_for_removal_of({aliceId, bobId, carlaId, bob2Id}); } } void ConversationRequestTest::testAcceptTrustRemoveConvReq() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 1); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 0); } void ConversationRequestTest::acceptConvReqAlsoAddContact() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); bobData.requestReceived = false; auto convId2 = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId2, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::acceptConversationRequest(bobId, convId2); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); std::this_thread::sleep_for(5s); CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 0); } void ConversationRequestTest::testGetRequests() { connectSignals(); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 1); CPPUNIT_ASSERT(requests.front()["id"] == convId); } void ConversationRequestTest::testDeclineRequest() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto convId = libjami::startConversation(aliceId); libjami::addConversationMember(aliceId, convId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); libjami::declineConversationRequest(bobId, convId); // Decline request auto requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 0); } void ConversationRequestTest::testAddContact() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&]() { return !aliceData.conversationId.empty(); })); ConversationRepository repo(aliceAccount, aliceData.conversationId); // Mode must be one to one CPPUNIT_ASSERT(repo.mode() == ConversationMode::ONE_TO_ONE); // Assert that repository exists auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / aliceData.conversationId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); auto clonedPath = fileutils::get_data_dir() / bobId / "conversations" / aliceData.conversationId; CPPUNIT_ASSERT(std::filesystem::is_directory(clonedPath)); auto bobMember = clonedPath / "members" / (bobUri + ".crt"); CPPUNIT_ASSERT(std::filesystem::is_regular_file(bobMember)); } void ConversationRequestTest::testDeclineConversationRequestRemoveTrustRequest() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); // Decline request auto requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 1); auto trustRequests = libjami::getTrustRequests(bobId); CPPUNIT_ASSERT(trustRequests.size() == 1); libjami::declineConversationRequest(bobId, aliceData.conversationId); requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 0); trustRequests = libjami::getTrustRequests(bobId); CPPUNIT_ASSERT(trustRequests.size() == 0); } void ConversationRequestTest::testMalformedTrustRequest() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); // Decline request auto requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 1); auto trustRequests = libjami::getTrustRequests(bobId); CPPUNIT_ASSERT(trustRequests.size() == 1); // This will let the trust request (not libjami::declineConversationRequest) bobAccount->convModule()->declineConversationRequest(aliceData.conversationId); requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 0); trustRequests = libjami::getTrustRequests(bobId); CPPUNIT_ASSERT(trustRequests.size() == 1); // Reload conversation will fix the state (the trustRequest is removed in another thread) bobAccount->convModule()->loadConversations(); requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 0); auto start = std::chrono::steady_clock::now(); auto requestDeclined = false; do { trustRequests = libjami::getTrustRequests(bobId); requestDeclined = trustRequests.size() == 0; if (!requestDeclined) std::this_thread::sleep_for(1s); } while (not requestDeclined and std::chrono::steady_clock::now() - start < 2s); CPPUNIT_ASSERT(requestDeclined); } void ConversationRequestTest::testAddContactDeleteAndReAdd() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // removeContact aliceAccount->removeContact(bobUri, false); std::this_thread::sleep_for(5s); // wait a bit that connections are closed // re-add CPPUNIT_ASSERT(aliceData.conversationId != ""); auto oldConvId = aliceData.conversationId; aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // Should retrieve previous conversation CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return oldConvId == aliceData.conversationId; })); } void ConversationRequestTest::testRemoveContact() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // Check created files CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); bobAccount->removeContact(aliceUri, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.removed; })); auto details = bobAccount->getContactDetails(aliceUri); CPPUNIT_ASSERT(details.find("removed") != details.end() && details["removed"] != "0"); aliceAccount->removeContact(bobUri, false); CPPUNIT_ASSERT(cv.wait_for(lk, 20s, [&]() { return aliceData.removed; })); std::this_thread::sleep_for( 10s); // There is no signal, but daemon should then erase the repository auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / aliceData.conversationId; CPPUNIT_ASSERT(!std::filesystem::is_directory(repoPath)); repoPath = fileutils::get_data_dir() / bobId / "conversations" / bobData.conversationId; CPPUNIT_ASSERT(!std::filesystem::is_directory(repoPath)); } void ConversationRequestTest::testRemoveContactMultiDevice() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); // Add second device for Bob std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; auto bobArchive = std::filesystem::current_path() / "bob.gz"; std::filesystem::remove(bobArchive); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; })); // First, Alice adds Bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && bob2Data.requestReceived; })); // Bob1 decline via removeContact, both device should remove the request bobAccount->removeContact(aliceUri, false); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return bobData.requestRemoved && bob2Data.requestRemoved; })); } void ConversationRequestTest::testRemoveSelfDoesntRemoveConversation() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // Check created files CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); aliceAccount->removeContact(aliceUri, false); CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return aliceData.removed; })); auto repoPath = fileutils::get_data_dir() / aliceId / "conversations" / aliceData.conversationId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); } void ConversationRequestTest::testRemoveConversationUpdateContactDetails() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // Check created files CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::removeConversation(bobId, bobData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.removed; })); auto details = bobAccount->getContactDetails(aliceUri); CPPUNIT_ASSERT(details[libjami::Account::TrustRequest::CONVERSATIONID] == ""); } void ConversationRequestTest::testBanContact() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // Check created files CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); bobAccount->removeContact(aliceUri, true); CPPUNIT_ASSERT(!cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 2 == aliceData.messages.size(); })); auto repoPath = fileutils::get_data_dir() / bobId / "conversations" / bobData.conversationId; CPPUNIT_ASSERT(std::filesystem::is_directory(repoPath)); } void ConversationRequestTest::testBanContactRestartAccount() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; bool conversationReady = false, requestReceived = false, memberMessageGenerated = false; std::string convId = ""; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::IncomingTrustRequest>( [&](const std::string& account_id, const std::string& /*from*/, const std::string& /*conversationId*/, const std::vector<uint8_t>& /*payload*/, time_t /*received*/) { if (account_id == bobId) requestReceived = true; cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == aliceId) { convId = conversationId; } else if (accountId == bobId) { conversationReady = true; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::MessageReceived>( [&](const std::string& accountId, const std::string& conversationId, std::map<std::string, std::string> message) { if (accountId == aliceId && conversationId == convId && message["type"] == "member") { memberMessageGenerated = true; } cv.notify_one(); })); bool contactRemoved = false; confHandlers.insert(libjami::exportable_callback<libjami::ConfigurationSignal::ContactRemoved>( [&](const std::string& accountId, const std::string& uri, bool) { if (accountId == bobId && uri == aliceUri) { contactRemoved = true; } cv.notify_one(); })); auto bobConnected = false; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string&, const std::map<std::string, std::string>&) { auto details = bobAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bobConnected = true; } else if (daemonStatus == "UNREGISTERED") { bobConnected = false; } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&]() { return !convId.empty(); })); // Check created files CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return requestReceived; })); memberMessageGenerated = false; CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return memberMessageGenerated; })); memberMessageGenerated = false; bobAccount->removeContact(aliceUri, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return contactRemoved; })); std::this_thread::sleep_for(10s); // Wait a bit to ensure that everything is updated bobConnected = true; Manager::instance().sendRegister(bobId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobConnected; })); std::this_thread::sleep_for(5s); // Wait a bit to ensure that everything is updated // Connect bob, it will trigger the bootstrap auto statusBootstrap = Conversation::BootstrapStatus::SUCCESS; // alice is banned so bootstrap MUST fail bobAccount->convModule()->onBootstrapStatus( [&](std::string /*convId*/, Conversation::BootstrapStatus status) { statusBootstrap = status; cv.notify_one(); }); Manager::instance().sendRegister(bobId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&]() { return statusBootstrap == Conversation::BootstrapStatus::FAILED; })); } void ConversationRequestTest::testBanContactRemoveTrustRequest() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); // Check created files CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); bobAccount->removeContact(aliceUri, true); CPPUNIT_ASSERT(cv.wait_for(lk, 5s, [&]() { return bobData.requestRemoved; })); auto requests = libjami::getConversationRequests(bobId); CPPUNIT_ASSERT(requests.size() == 0); } void ConversationRequestTest::testAddOfflineContactThenConnect() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->trackBuddyPresence(carlaUri, true); aliceAccount->addContact(carlaUri); aliceAccount->sendTrustRequest(carlaUri, {}); cv.wait_for(lk, 5s); // Wait 5 secs for the put to happen Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, std::chrono::seconds(60), [&]() { return carlaData.requestReceived; })); auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(carlaAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 1; })); } void ConversationRequestTest::testDeclineTrustRequestDoNotGenerateAnother() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->trackBuddyPresence(bobUri, true); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->discardTrustRequest(aliceUri)); cv.wait_for(lk, 10s); // Wait a bit Manager::instance().sendRegister(bobId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.stopped; })); // Trigger on peer online bobData.deviceAnnounced = false; bobData.requestReceived = false; Manager::instance().sendRegister(bobId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.deviceAnnounced; })); CPPUNIT_ASSERT(!cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); } void ConversationRequestTest::testRemoveContactRemoveSyncing() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.contactAdded; })); CPPUNIT_ASSERT(libjami::getConversations(bobId).size() == 1); bobAccount->removeContact(aliceUri, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.contactRemoved; })); CPPUNIT_ASSERT(libjami::getConversations(bobId).size() == 0); } void ConversationRequestTest::testRemoveConversationRemoveSyncing() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.contactAdded; })); // At this point the conversation should be there and syncing. CPPUNIT_ASSERT(libjami::getConversations(bobId).size() == 1); libjami::removeConversation(bobId, aliceData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.removed; })); CPPUNIT_ASSERT(libjami::getConversations(bobId).size() == 0); } void ConversationRequestTest::testCacheRequestFromClient() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); std::vector<uint8_t> payload = {0x64, 0x64, 0x64}; aliceAccount->sendTrustRequest(bobUri, payload); // Random payload, just care with the file CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); auto cachedPath = fileutils::get_cache_dir() / aliceId / "requests" / bobUri; CPPUNIT_ASSERT(std::filesystem::is_regular_file(cachedPath)); CPPUNIT_ASSERT(fileutils::loadFile(cachedPath) == payload); CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 1); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // cachedPath is removed on confirmation (from the DHT), so this can take a few secs to come auto removed = false; for (int i = 0; i <= 10; ++i) { if (!std::filesystem::is_regular_file(cachedPath)) { removed = true; break; } std::this_thread::sleep_for(1s); } CPPUNIT_ASSERT(removed); } void ConversationRequestTest::testNeedsSyncingWithForCloning() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); auto aliceDevice = std::string(aliceAccount->currentDeviceId()); CPPUNIT_ASSERT(!bobAccount->convModule()->needsSyncingWith(aliceUri, aliceDevice)); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.contactAdded; })); // At this point the conversation should be there and syncing. CPPUNIT_ASSERT(libjami::getConversations(bobId).size() == 1); CPPUNIT_ASSERT(bobAccount->convModule()->needsSyncingWith(aliceUri, aliceDevice)); } void ConversationRequestTest::testRemoveContactRemoveTrustRequest() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); // Add second device for Bob std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; })); auto bob2Account = Manager::instance().getAccount<JamiAccount>(bob2Id); // First, Alice adds Bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived && bob2Data.requestReceived; })); // Bob1 accepts, both device should get it auto aliceMsgSize = aliceData.messages.size(); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && !bob2Data.conversationId.empty() && aliceMsgSize + 1 == aliceData.messages.size(); })); // Bob2 remove Alice ; Bob1 should not have any trust requests bob2Account->removeContact(aliceUri, false); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return bobData.contactRemoved && bob2Data.contactRemoved; })); std::this_thread::sleep_for(10s); // Wait a bit to ensure that everything is update (via synced) CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 0); CPPUNIT_ASSERT(bob2Account->getTrustRequests().size() == 0); } void ConversationRequestTest::testAddConversationNoPresenceThenConnects() { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto carlaUri = carlaAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->trackBuddyPresence(carlaUri, true); carlaAccount->publishPresence(false); std::mutex mtx; std::unique_lock lk {mtx}; std::condition_variable cv; std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; std::string convId = ""; confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == aliceId) { convId = conversationId; } cv.notify_one(); })); auto carlaConnected = false; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string&, const std::map<std::string, std::string>&) { auto details = carlaAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { carlaConnected = true; } else if (daemonStatus == "UNREGISTERED") { carlaConnected = false; } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); aliceAccount->addContact(carlaUri); cv.wait_for(lk, 5s); // Wait 5 secs for the put to happen Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaConnected; })); carlaAccount->addContact(aliceUri); cv.wait_for(lk, 5s); // Wait 5 secs for the put to happen carlaAccount->publishPresence(true); Manager::instance().sendRegister(carlaId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !carlaConnected; })); convId.clear(); Manager::instance().sendRegister(carlaId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return carlaConnected; })); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !convId.empty(); })); auto carlaDetails = carlaAccount->getContactDetails(aliceUri); auto aliceDetails = aliceAccount->getContactDetails(carlaUri); CPPUNIT_ASSERT(carlaDetails["conversationId"] == aliceDetails["conversationId"] && carlaDetails["conversationId"] == convId); } void ConversationRequestTest::testRequestBigPayload() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); aliceAccount->addContact(bobUri); auto data = std::string(64000, 'A'); std::vector<uint8_t> payload(data.begin(), data.end()); aliceAccount->sendTrustRequest(bobUri, payload); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 1); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); CPPUNIT_ASSERT(bobAccount->getTrustRequests().size() == 0); } void ConversationRequestTest::testBothRemoveReadd() { connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT( cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); // removeContact aliceAccount->removeContact(bobUri, false); bobAccount->removeContact(aliceUri, false); std::this_thread::sleep_for(5s); // wait a bit that connections are closed // re-add aliceData.conversationId.clear(); bobData.requestReceived = false; aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); // Should retrieve previous conversation CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !aliceData.conversationId.empty() && bobData.conversationId == aliceData.conversationId; })); } void ConversationRequestTest::doNotLooseMetadata() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); libjami::startConversation(aliceId); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.conversationId != ""; })); auto aliceMsgSize = aliceData.messages.size(); aliceAccount->convModule()->updateConversationInfos(aliceData.conversationId, {{"title", "My awesome swarm"}}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); })); libjami::addConversationMember(aliceId, aliceData.conversationId, bobUri); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); Manager::instance().sendRegister(aliceId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.stopped; })); libjami::acceptConversationRequest(bobId, aliceData.conversationId); CPPUNIT_ASSERT(!cv.wait_for(lk, 10s, [&]() { return bobData.conversationId != ""; })); // Force reset bobAccount->convModule()->loadConversations(); auto infos = libjami::conversationInfos(bobId, aliceData.conversationId); CPPUNIT_ASSERT(infos["syncing"] == "true"); CPPUNIT_ASSERT(infos["title"] == "My awesome swarm"); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::ConversationRequestTest::name())
50,042
C++
.cpp
1,038
41.201349
132
0.683186
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
751,662
conversationFetchSent.cpp
savoirfairelinux_jami-daemon/test/unitTest/conversation/conversationFetchSent.cpp
/* * Copyright (C) 2004-2024 Savoir-faire Linux Inc. * * 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, either version 3 of the License, or * (at your option) any later version. * * 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, see <https://www.gnu.org/licenses/>. */ #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> #include <cppunit/extensions/HelperMacros.h> #include <condition_variable> #include <string> #include <fstream> #include <streambuf> #include <git2.h> #include <filesystem> #include <msgpack.hpp> #include "../../test_runner.h" #include "account_const.h" #include "archiver.h" #include "base64.h" #include "common.h" #include "conversation/conversationcommon.h" #include "fileutils.h" #include "jami.h" #include "manager.h" #include <dhtnet/certstore.h> using namespace std::string_literals; using namespace std::literals::chrono_literals; using namespace libjami::Account; namespace jami { namespace test { struct UserData { std::string conversationId; bool requestReceived {false}; bool registered {false}; bool stopped {false}; bool deviceAnnounced {false}; std::vector<libjami::SwarmMessage> messages; }; class ConversationFetchSentTest : public CppUnit::TestFixture { public: ~ConversationFetchSentTest() { libjami::fini(); } static std::string name() { return "Conversation"; } void setUp(); void tearDown(); std::string createFakeConversation(std::shared_ptr<JamiAccount> account, const std::string& fakeCert = ""); std::string aliceId; UserData aliceData; std::string alice2Id; UserData alice2Data; std::string bobId; UserData bobData; std::string bob2Id; UserData bob2Data; std::string carlaId; UserData carlaData; std::mutex mtx; std::unique_lock<std::mutex> lk {mtx}; std::condition_variable cv; void connectSignals(); private: void testSyncFetch(); void testSyncAfterDisconnection(); void testDisplayedOnLoad(); CPPUNIT_TEST_SUITE(ConversationFetchSentTest); CPPUNIT_TEST(testSyncFetch); CPPUNIT_TEST(testSyncAfterDisconnection); CPPUNIT_TEST(testDisplayedOnLoad); CPPUNIT_TEST_SUITE_END(); }; CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ConversationFetchSentTest, ConversationFetchSentTest::name()); void ConversationFetchSentTest::setUp() { // Init daemon libjami::init( libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG)); if (not Manager::instance().initialized) CPPUNIT_ASSERT(libjami::start("jami-sample.yml")); auto actors = load_actors("actors/alice-bob-carla.yml"); aliceId = actors["alice"]; bobId = actors["bob"]; carlaId = actors["carla"]; aliceData = {}; alice2Data = {}; bobData = {}; bob2Data = {}; carlaData = {}; Manager::instance().sendRegister(carlaId, false); wait_for_announcement_of({aliceId, bobId}); } void ConversationFetchSentTest::connectSignals() { std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers; confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::VolatileDetailsChanged>( [&](const std::string& accountId, const std::map<std::string, std::string>&) { if (accountId == aliceId) { auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto details = aliceAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { aliceData.registered = true; } else if (daemonStatus == "UNREGISTERED") { aliceData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; aliceData.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == bobId) { auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto details = bobAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bobData.registered = true; } else if (daemonStatus == "UNREGISTERED") { bobData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; bobData.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == bob2Id) { auto bob2Account = Manager::instance().getAccount<JamiAccount>(bob2Id); auto details = bob2Account->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { bob2Data.registered = true; } else if (daemonStatus == "UNREGISTERED") { bob2Data.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; bob2Data.deviceAnnounced = deviceAnnounced == "true"; } else if (accountId == carlaId) { auto carlaAccount = Manager::instance().getAccount<JamiAccount>(carlaId); auto details = carlaAccount->getVolatileAccountDetails(); auto daemonStatus = details[libjami::Account::ConfProperties::Registration::STATUS]; if (daemonStatus == "REGISTERED") { carlaData.registered = true; } else if (daemonStatus == "UNREGISTERED") { carlaData.stopped = true; } auto deviceAnnounced = details[libjami::Account::VolatileProperties::DEVICE_ANNOUNCED]; carlaData.deviceAnnounced = deviceAnnounced == "true"; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmLoaded>( [&](uint32_t, const std::string& accountId, const std::string& /* conversationId */, std::vector<libjami::SwarmMessage> messages) { if (accountId == aliceId) { aliceData.messages.insert(aliceData.messages.end(), messages.begin(), messages.end()); } else if (accountId == bobId) { bobData.messages.insert(bobData.messages.end(), messages.begin(), messages.end()); } else if (accountId == bob2Id) { bob2Data.messages.insert(bob2Data.messages.end(), messages.begin(), messages.end()); } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>( [&](const std::string& accountId, const std::string& conversationId) { if (accountId == aliceId) { aliceData.conversationId = conversationId; } else if (accountId == alice2Id) { alice2Data.conversationId = conversationId; } else if (accountId == bobId) { bobData.conversationId = conversationId; } else if (accountId == bob2Id) { bob2Data.conversationId = conversationId; } else if (accountId == carlaId) { carlaData.conversationId = conversationId; } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, std::map<std::string, std::string> /*metadatas*/) { if (accountId == aliceId) { aliceData.requestReceived = true; } else if (accountId == bobId) { bobData.requestReceived = true; } else if (accountId == bob2Id) { bob2Data.requestReceived = true; } else if (accountId == carlaId) { carlaData.requestReceived = true; } cv.notify_one(); })); confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::SwarmMessageReceived>( [&](const std::string& accountId, const std::string& /* conversationId */, libjami::SwarmMessage message) { if (accountId == aliceId) { aliceData.messages.emplace_back(message); } else if (accountId == bobId) { bobData.messages.emplace_back(message); } else if (accountId == bob2Id) { bob2Data.messages.emplace_back(message); } else if (accountId == carlaId) { carlaData.messages.emplace_back(message); } cv.notify_one(); })); confHandlers.insert( libjami::exportable_callback<libjami::ConfigurationSignal::AccountMessageStatusChanged>( [&](const std::string& accountId, const std::string& /*conversationId*/, const std::string& peer, const std::string& msgId, int status) { auto placeMessage = [&](auto& data) { for (auto& dataMsg : data.messages) { if (dataMsg.id == msgId) { dataMsg.status[peer] = status; return; } } }; if (accountId == aliceId) { placeMessage(aliceData); } else if (accountId == bobId) { placeMessage(bobData); } else if (accountId == bob2Id) { placeMessage(bob2Data); } cv.notify_one(); })); libjami::registerSignalHandlers(confHandlers); } void ConversationFetchSentTest::tearDown() { auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); auto aliceArchive = std::filesystem::current_path().string() + "/alice.gz"; std::remove(aliceArchive.c_str()); if (!alice2Id.empty()) { wait_for_removal_of(alice2Id); } if (bob2Id.empty()) { wait_for_removal_of({aliceId, bobId, carlaId}); } else { wait_for_removal_of({aliceId, bobId, carlaId, bob2Id}); } } void ConversationFetchSentTest::testSyncAfterDisconnection() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); // Disconnect bob2, to create a valid conv betwen Alice and Bob1 CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; })); // Create conversation between alice and bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && !bob2Data.conversationId.empty(); })); std::this_thread::sleep_for(5s); // Wait for all join messages to be received // bob send 4 messages auto aliceMsgSize = aliceData.messages.size(), bob2MsgSize = bob2Data.messages.size(), bobMsgSize = bobData.messages.size(); libjami::sendMessage(bobId, bobData.conversationId, "1"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 1 && bobData.messages.size() == bobMsgSize + 1 && bob2Data.messages.size() == bob2MsgSize + 1; })); auto msgId1 = aliceData.messages.rbegin()->id; auto getMsgStatus = [&](const auto& data, const auto& id, const auto& peer) { for (const auto& msg : data.messages) { if (msg.id == id && msg.status.find(peer) != msg.status.end()) { return static_cast<libjami::Account::MessageStates>(msg.status.at(peer)); } } return libjami::Account::MessageStates::UNKNOWN; }; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId1, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "2"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 2 && bobData.messages.size() == bobMsgSize + 2 && bob2Data.messages.size() == bob2MsgSize + 2;})); auto msgId2 = aliceData.messages.rbegin()->id; // Because bob2Data.status is here only on update, but msgReceived can be good directly at first CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId2, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId2, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "3"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 3 && bobData.messages.size() == bobMsgSize + 3 && bob2Data.messages.size() == bob2MsgSize + 3; })); auto msgId3 = aliceData.messages.rbegin()->id; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId3, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId3, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "4"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 4 && bobData.messages.size() == bobMsgSize + 4 && bob2Data.messages.size() == bob2MsgSize + 4; })); auto msgId4 = aliceData.messages.rbegin()->id; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId4, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId4, aliceUri) == libjami::Account::MessageStates::SENT; })); // Bob is disabled. Bob2 will get the infos Manager::instance().sendRegister(bobId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.stopped; })); // Second message is set to displayed by alice aliceAccount->setMessageDisplayed("swarm:" + aliceData.conversationId, msgId2, 3); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bob2Data, msgId1, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bob2Data, msgId2, aliceUri) == libjami::Account::MessageStates::DISPLAYED; })); CPPUNIT_ASSERT(getMsgStatus(bobData, msgId1, aliceUri) != libjami::Account::MessageStates::DISPLAYED); // Alice is disabled so she will not sync Manager::instance().sendRegister(aliceId, false); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.stopped; })); // Bob is enabled again, should sync infos with bob2 Manager::instance().sendRegister(bobId, true); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bobData, msgId2, aliceUri) == libjami::Account::MessageStates::DISPLAYED; })); } void ConversationFetchSentTest::testSyncFetch() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); // Bob creates a second device auto bobArchive = std::filesystem::current_path().string() + "/bob.gz"; std::remove(bobArchive.c_str()); bobAccount->exportArchive(bobArchive); std::map<std::string, std::string> details = libjami::getAccountTemplate("RING"); details[ConfProperties::TYPE] = "RING"; details[ConfProperties::DISPLAYNAME] = "BOB2"; details[ConfProperties::ALIAS] = "BOB2"; details[ConfProperties::UPNP_ENABLED] = "true"; details[ConfProperties::ARCHIVE_PASSWORD] = ""; details[ConfProperties::ARCHIVE_PIN] = ""; details[ConfProperties::ARCHIVE_PATH] = bobArchive; bob2Id = Manager::instance().addAccount(details); // Disconnect bob2, to create a valid conv betwen Alice and Bob1 CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; })); // Create conversation between alice and bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty() && !bob2Data.conversationId.empty(); })); std::this_thread::sleep_for(5s); // Wait for all join messages to be received // bob send 4 messages auto aliceMsgSize = aliceData.messages.size(), bob2MsgSize = bob2Data.messages.size(), bobMsgSize = bobData.messages.size(); libjami::sendMessage(bobId, bobData.conversationId, "1"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 1 && bobData.messages.size() == bobMsgSize + 1 && bob2Data.messages.size() == bob2MsgSize + 1; })); auto msgId1 = aliceData.messages.rbegin()->id; auto getMsgStatus = [&](const auto& data, const auto& id, const auto& peer) { for (const auto& msg : data.messages) { if (msg.id == id && msg.status.find(peer) != msg.status.end()) { return static_cast<libjami::Account::MessageStates>(msg.status.at(peer)); } } return libjami::Account::MessageStates::UNKNOWN; }; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId1, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "2"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 2 && bobData.messages.size() == bobMsgSize + 2 && bob2Data.messages.size() == bob2MsgSize + 2;})); auto msgId2 = aliceData.messages.rbegin()->id; // Because bob2Data.status is here only on update, but msgReceived can be good directly at first CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId2, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId2, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "3"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 3 && bobData.messages.size() == bobMsgSize + 3 && bob2Data.messages.size() == bob2MsgSize + 3; })); auto msgId3 = aliceData.messages.rbegin()->id; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId3, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId3, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "4"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 4 && bobData.messages.size() == bobMsgSize + 4 && bob2Data.messages.size() == bob2MsgSize + 4; })); auto msgId4 = aliceData.messages.rbegin()->id; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId4, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId4, aliceUri) == libjami::Account::MessageStates::SENT; })); // Second message is set to displayed by alice aliceAccount->setMessageDisplayed("swarm:" + aliceData.conversationId, msgId2, 3); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bob2Data, msgId1, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bobData, msgId2, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bob2Data, msgId2, aliceUri) == libjami::Account::MessageStates::DISPLAYED; })); // Other messages are still set to received CPPUNIT_ASSERT(getMsgStatus(bobData, msgId3, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId3, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bobData, msgId4, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bob2Data, msgId4, aliceUri) == libjami::Account::MessageStates::SENT); // Get conversation members should show the same information auto membersInfos = libjami::getConversationMembers(bobId, bobData.conversationId); CPPUNIT_ASSERT(std::find_if(membersInfos.begin(), membersInfos.end(), [&](auto infos) { return infos["uri"] == aliceUri && infos["lastDisplayed"] == msgId2; }) != membersInfos.end()); // Alice is disabled Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.stopped; })); // Bob send 2 more messages bob2MsgSize = bob2Data.messages.size(); libjami::sendMessage(bobId, bobData.conversationId, "5"s, ""); libjami::sendMessage(bobId, bobData.conversationId, "6"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.messages.size() == bob2MsgSize + 2; })); auto msgId5 = bobData.messages.rbegin()->id; auto msgId6 = (bobData.messages.rbegin()+1)->id; // No update CPPUNIT_ASSERT(!cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId5, aliceUri) == libjami::Account::MessageStates::SENT && getMsgStatus(bobData, msgId6, aliceUri) == libjami::Account::MessageStates::SENT; })); // SwarmMessage will not get any status because nobody got the message CPPUNIT_ASSERT(getMsgStatus(bobData, msgId5, aliceUri) == libjami::Account::MessageStates::UNKNOWN); CPPUNIT_ASSERT(getMsgStatus(bobData, msgId6, aliceUri) == libjami::Account::MessageStates::UNKNOWN); } void ConversationFetchSentTest::testDisplayedOnLoad() { std::cout << "\nRunning test: " << __func__ << std::endl; connectSignals(); auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId); auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId); auto bobUri = bobAccount->getUsername(); auto aliceUri = aliceAccount->getUsername(); // Create conversation between alice and bob aliceAccount->addContact(bobUri); aliceAccount->sendTrustRequest(bobUri, {}); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bobData.requestReceived; })); CPPUNIT_ASSERT(bobAccount->acceptTrustRequest(aliceUri)); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bobData.conversationId.empty(); })); std::this_thread::sleep_for(5s); // Wait for all join messages to be received // bob send 2 messages auto aliceMsgSize = aliceData.messages.size(), bobMsgSize = bobData.messages.size(); libjami::sendMessage(bobId, bobData.conversationId, "1"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 1 && bobData.messages.size() == bobMsgSize + 1; })); auto msgId1 = aliceData.messages.rbegin()->id; auto getMsgStatus = [&](const auto& data, const auto& id, const auto& peer) { for (const auto& msg : data.messages) { if (msg.id == id && msg.status.find(peer) != msg.status.end()) { return static_cast<libjami::Account::MessageStates>(msg.status.at(peer)); } } return libjami::Account::MessageStates::UNKNOWN; }; CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::SENT; })); libjami::sendMessage(bobId, bobData.conversationId, "2"s, ""); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.messages.size() == aliceMsgSize + 2 && bobData.messages.size() == bobMsgSize + 2;})); auto msgId2 = aliceData.messages.rbegin()->id; // Second message is set to displayed by alice aliceAccount->setMessageDisplayed("swarm:" + aliceData.conversationId, msgId2, 3); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bobData, msgId2, aliceUri) == libjami::Account::MessageStates::DISPLAYED; })); bobAccount->convModule()->loadConversations(); // Reset data bobData.messages.clear(); // Load messages, messages should be displayed CPPUNIT_ASSERT(getMsgStatus(bobData, msgId1, aliceUri) != libjami::Account::MessageStates::DISPLAYED); libjami::loadConversation(bobId, bobData.conversationId, "", 0); CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return getMsgStatus(bobData, msgId1, aliceUri) == libjami::Account::MessageStates::DISPLAYED && getMsgStatus(bobData, msgId2, aliceUri) == libjami::Account::MessageStates::DISPLAYED; })); } } // namespace test } // namespace jami RING_TEST_RUNNER(jami::test::ConversationFetchSentTest::name())
28,380
C++
.cpp
491
47.427699
355
0.630142
savoirfairelinux/jami-daemon
144
47
2
GPL-3.0
9/20/2024, 9:42:05 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false