<commit_before>#include "Http.hpp"

#include <cstdlib>
#include <functional>
#include <thread>
#include <deque>
#include <sstream>
#include <exception>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/log/trivial.hpp>

#include <curl/curl.h>

#ifdef OPENSSL_CERT_OVERRIDE
#include <openssl/x509.h>
#endif

#include <libslic3r/libslic3r.h>
#include <libslic3r/Utils.hpp>
#include <slic3r/GUI/I18N.hpp>
#include <slic3r/GUI/format.hpp>

namespace fs = boost::filesystem;


namespace Slic3r {


// Private

struct CurlGlobalInit
{
    static std::unique_ptr<CurlGlobalInit> instance;
    std::string message;
    
	CurlGlobalInit()
    {
#ifdef OPENSSL_CERT_OVERRIDE // defined if SLIC3R_STATIC=ON
        
        // Look for a set of distro specific directories. Don't change the
        // order: https://bugzilla.redhat.com/show_bug.cgi?id=1053882
        static const char * CA_BUNDLES[] = {
            "/etc/pki/tls/certs/ca-bundle.crt",   // Fedora/RHEL 6
            "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
            "/usr/share/ssl/certs/ca-bundle.crt",
            "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD
            "/etc/ssl/cert.pem",
            "/etc/ssl/ca-bundle.pem"              // OpenSUSE Tumbleweed              
        };
        
        namespace fs = boost::filesystem;
        // Env var name for the OpenSSL CA bundle (SSL_CERT_FILE nomally)
        const char *const SSL_CA_FILE = X509_get_default_cert_file_env();
        const char * ssl_cafile = ::getenv(SSL_CA_FILE);
        
        if (!ssl_cafile)
            ssl_cafile = X509_get_default_cert_file();
        
        int replace = true;
        if (!ssl_cafile || !fs::exists(fs::path(ssl_cafile))) {
            const char * bundle = nullptr;
            for (const char * b : CA_BUNDLES) {
                if (fs::exists(fs::path(b))) {
                    ::setenv(SSL_CA_FILE, bundle = b, replace);
                    break;
                }
            }

            if (!bundle)
                message = _u8L("Could not detect system SSL certificate store. "
                               "PrusaSlicer will be unable to establish secure "
                               "network connections.");
            else
                message = Slic3r::format(
					_L("PrusaSlicer detected system SSL certificate store in: %1%"),
                    bundle);

            message += "\n" + Slic3r::format(
				_L("To specify the system certificate store manually, please "
                   "set the %1% environment variable to the correct CA bundle "
                   "and restart the application."),
                SSL_CA_FILE);
        }

#endif // OPENSSL_CERT_OVERRIDE
        
        if (CURLcode ec = ::curl_global_init(CURL_GLOBAL_DEFAULT)) {
            message += _u8L("CURL init has failed. PrusaSlicer will be unable to establish "
                            "network connections. See logs for additional details.");
            
            BOOST_LOG_TRIVIAL(error) << ::curl_easy_strerror(ec);
        }
    }
    
	~CurlGlobalInit() { ::curl_global_cleanup(); }
};

std::unique_ptr<CurlGlobalInit> CurlGlobalInit::instance;
<commit_msg>Added missing namespace qualification for Slic3r::GUI::format in Http.cpp<commit_after>#include "Http.hpp"

#include <cstdlib>
#include <functional>
#include <thread>
#include <deque>
#include <sstream>
#include <exception>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <boost/log/trivial.hpp>

#include <curl/curl.h>

#ifdef OPENSSL_CERT_OVERRIDE
#include <openssl/x509.h>
#endif

#include <libslic3r/libslic3r.h>
#include <libslic3r/Utils.hpp>
#include <slic3r/GUI/I18N.hpp>
#include <slic3r/GUI/format.hpp>

namespace fs = boost::filesystem;


namespace Slic3r {


// Private

struct CurlGlobalInit
{
    static std::unique_ptr<CurlGlobalInit> instance;
    std::string message;
    
	CurlGlobalInit()
    {
#ifdef OPENSSL_CERT_OVERRIDE // defined if SLIC3R_STATIC=ON
        
        // Look for a set of distro specific directories. Don't change the
        // order: https://bugzilla.redhat.com/show_bug.cgi?id=1053882
        static const char * CA_BUNDLES[] = {
            "/etc/pki/tls/certs/ca-bundle.crt",   // Fedora/RHEL 6
            "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc.
            "/usr/share/ssl/certs/ca-bundle.crt",
            "/usr/local/share/certs/ca-root-nss.crt", // FreeBSD
            "/etc/ssl/cert.pem",
            "/etc/ssl/ca-bundle.pem"              // OpenSUSE Tumbleweed              
        };
        
        namespace fs = boost::filesystem;
        // Env var name for the OpenSSL CA bundle (SSL_CERT_FILE nomally)
        const char *const SSL_CA_FILE = X509_get_default_cert_file_env();
        const char * ssl_cafile = ::getenv(SSL_CA_FILE);
        
        if (!ssl_cafile)
            ssl_cafile = X509_get_default_cert_file();
        
        int replace = true;
        if (!ssl_cafile || !fs::exists(fs::path(ssl_cafile))) {
            const char * bundle = nullptr;
            for (const char * b : CA_BUNDLES) {
                if (fs::exists(fs::path(b))) {
                    ::setenv(SSL_CA_FILE, bundle = b, replace);
                    break;
                }
            }

            if (!bundle)
                message = _u8L("Could not detect system SSL certificate store. "
                               "PrusaSlicer will be unable to establish secure "
                               "network connections.");
            else
                message = Slic3r::GUI::format(
					_L("PrusaSlicer detected system SSL certificate store in: %1%"),
                    bundle);

            message += "\n" + Slic3r::GUI::format(
				_L("To specify the system certificate store manually, please "
                   "set the %1% environment variable to the correct CA bundle "
                   "and restart the application."),
                SSL_CA_FILE);
        }

#endif // OPENSSL_CERT_OVERRIDE
        
        if (CURLcode ec = ::curl_global_init(CURL_GLOBAL_DEFAULT)) {
            message += _u8L("CURL init has failed. PrusaSlicer will be unable to establish "
                            "network connections. See logs for additional details.");
            
            BOOST_LOG_TRIVIAL(error) << ::curl_easy_strerror(ec);
        }
    }
    
	~CurlGlobalInit() { ::curl_global_cleanup(); }
};

std::unique_ptr<CurlGlobalInit> CurlGlobalInit::instance;

{'fraction_non_alphanumeric': 0.11539615846338536, 'fraction_numerical': 0.009753901560624249, 'mean_word_length': 2.0785219399538106, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 41, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2852361', 'n_tokens_mistral': 2184, 'n_tokens_neox': 2066, 'n_words': 453}