Beispiel #1
0
/** Constructor */
HelpDialog::HelpDialog(QWidget *parent) :
    QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
    ui(new(Ui::HelpDialog))
{
    /* Invoke the Qt Designer generated object setup routine */
    ui->setupUi(this);

    //QFile licenseFile(QLatin1String(":/images/COPYING"));
    QFile licenseFile(QLatin1String(":/help/licence.html"));
    if (licenseFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&licenseFile);
        ui->license->setText(in.readAll());
    }

    QFile authorsFile(QLatin1String(":/help/authors.html"));
    if (authorsFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&authorsFile);
        ui->authors->setText(in.readAll());
    }

    QFile thanksFile(QLatin1String(":/help/thanks.html"));
    if (thanksFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&thanksFile);
        ui->thanks->setText(in.readAll());
    }

    QFile versionFile(QLatin1String(":/help/version.html"));
    if (versionFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&versionFile);
        QString version = in.readAll();

        ui->version->setText(version);
    }

    /* Add version numbers of libretroshare */
    std::list<RsLibraryInfo> libraries;
    RsControl::instance()->getLibraries(libraries);
    addLibraries(ui->libraryLayout, "libretroshare", libraries);

#ifdef ENABLE_WEBUI
    /* Add version numbers of RetroShare */
    // Add versions here. Find a better place.
    libraries.clear();
    libraries.push_back(RsLibraryInfo("Libmicrohttpd", MHD_get_version()));
    addLibraries(ui->libraryLayout, "RetroShare", libraries);
#endif // ENABLE_WEBUI

    /* Add version numbers of plugins */
    if (rsPlugins) {
        for (int i = 0; i < rsPlugins->nbPlugins(); ++i) {
            RsPlugin *plugin = rsPlugins->plugin(i);
            if (plugin) {
                libraries.clear();
                plugin->getLibraries(libraries);
                addLibraries(ui->libraryLayout, plugin->getPluginName(), libraries);
            }
        }
    }
}
Beispiel #2
0
void xmrig::CommonConfig::printVersions()
{
    char buf[256] = { 0 };

#   if defined(__clang__)
    snprintf(buf, sizeof buf, "clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
#   elif defined(__GNUC__)
    snprintf(buf, sizeof buf, "gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#   elif defined(_MSC_VER)
    snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
#   endif

    Log::i()->text(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s")
                              : " * %-13s%s/%s %s",
                   "ABOUT", APP_NAME, APP_VERSION, buf);

#   if defined(XMRIG_AMD_PROJECT)
#   if CL_VERSION_2_0
    const char *ocl = "2.0";
#   elif CL_VERSION_1_2
    const char *ocl = "1.2";
#   elif CL_VERSION_1_1
    const char *ocl = "1.1";
#   elif CL_VERSION_1_0
    const char *ocl = "1.0";
#   else
    const char *ocl = "0.0";
#   endif
    int length = snprintf(buf, sizeof buf, "OpenCL/%s ", ocl);
#   elif defined(XMRIG_NVIDIA_PROJECT)
    const int cudaVersion = cuda_get_runtime_version();
    int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100);
#   else
    memset(buf, 0, 16);

#   if !defined(XMRIG_NO_HTTPD) || !defined(XMRIG_NO_TLS)
    int length = 0;
#   endif
#   endif

#   if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT)
    {
        constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
        length += snprintf(buf + length, (sizeof buf) - length, "OpenSSL/%.*s ", static_cast<int>(strchr(v, ' ') - v), v);
    }
#   endif

#   ifndef XMRIG_NO_HTTPD
    length += snprintf(buf + length, (sizeof buf) - length, "microhttpd/%s ", MHD_get_version());
#   endif

    Log::i()->text(isColors() ? GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s")
                              : " * %-13slibuv/%s %s",
                   "LIBS", uv_version_string(), buf);
}
Beispiel #3
0
int main(int argc, char *argv[])
{
    int opt;
    str destination_hostname = {.length = 0, .s = NULL};
    uint16_t server_port = 8080, destination_port = COAP_DEFAULT_PORT;
    char *endptr;
    struct stat s;

    while((opt = getopt(argc, argv, "D:P:p:f:h")) != EOF) {
        switch(opt) {
            case 'D':
                destination_hostname.s = (unsigned char *)optarg;
                destination_hostname.length = strlen(optarg);
                resolve_address(&destination_hostname, (struct sockaddr *)&destination);
                break;
            case 'P':
                destination_port = (uint16_t)strtoul(optarg, &endptr, 10);
                if(*endptr != '\0') {
                    fprintf(stderr, "error: invalid port number: %s\n", optarg);
                    return EXIT_FAILURE;
                }
                break;
            case 'p':
                server_port = (uint16_t)strtoul(optarg, &endptr, 10);
                if(*endptr != '\0') {
                    fprintf(stderr, "error: invalid port number: %s\n", optarg);
                    return EXIT_FAILURE;
                }
                break;
            case 'f':
                if(stat(optarg, &s) == -1) {
                    if(ENOENT == errno) {
                        /* does not exist */
                        fprintf(stderr, "error: %s: %s\n", optarg, strerror(errno));
                        return EXIT_FAILURE;
                    }
                    else {
                        perror("stat");
                        return EXIT_FAILURE;
                    }
                } else {
                    if(S_ISDIR(s.st_mode)) {
                        /* it's a dir */
                        strncpy(static_files_path, optarg, 63);
                        static_files_path[63] = '\0';
                        fprintf(stderr, "Will serve static files of directory '%s'\n", static_files_path);
                    }
                    else {
                        /* exists but is no dir */
                        fprintf(stderr, "error: %s is not a directory\n", optarg);
                        return EXIT_FAILURE;
                    }
                }
                break;
            case 'h':
                fprintf(stderr, "usage: %s -D coap_host [-P coap_port] [-p HTTP_server_port] [-f static_files_dir]\n",
                        basename(argv[0]));
                return EXIT_SUCCESS;
            default:
                return EXIT_FAILURE;
        }
    }

    if(destination_hostname.s == NULL) {
        fprintf(stderr, "error: please specify the target coap host of the proxy with the -D option\n");
        return EXIT_FAILURE;
    }

    destination.sin_port = htons(destination_port);

    // Register the clean function for when the program exists
    if(atexit(cleanup) != 0) {
        perror("atexit");
        return EXIT_FAILURE;
    }
    // Also call it where a SIGINT is received
    struct sigaction action;
    memset(&action, 0, sizeof(action));
    action.sa_handler = &signal_handler;
    if(sigaction(SIGINT, &action, &old_action) != 0) {
        perror("sigaction");
        return EXIT_FAILURE;
    }

    start_http_server(server_port);
    if(http_daemon == NULL) {
        fprintf(stderr, "error: HTTP server failed to start: %s\n", strerror(errno));
        return EXIT_FAILURE;
    }

    fprintf(stderr, "HTTP server is listening on port %u (using libmicrohttpd %s)\n", server_port, MHD_get_version());

    // Create the CoAP context
    coap_set_log_level(LOG_DEBUG);
    coap_context = coap_create_context("0.0.0.0", NULL);
    coap_register_response_handler(coap_context, coap_response_handler);

    // Now let microhttpd accept HTTP requests and wait for a signal
    pause();

    return EXIT_SUCCESS;
}