static void run_cert(X509 *crt, const char *nameincert,
                     const struct set_name_fn *fn)
{
    const char *const *pname = names;
    while (*pname) {
        int samename = strcasecmp(nameincert, *pname) == 0;
        size_t namelen = strlen(*pname);
        char *name = malloc(namelen);
        int match, ret;
        memcpy(name, *pname, namelen);
        ret = X509_check_host(crt, name, namelen, 0, NULL);
        match = -1;
        if (ret < 0) {
            fprintf(stderr, "internal error in X509_check_host");
            ++errors;
        } else if (fn->host) {
            if (ret == 1 && !samename)
                match = 1;
            if (ret == 0 && samename)
                match = 0;
        } else if (ret == 1)
            match = 1;
        check_message(fn, "host", nameincert, match, *pname);
        ret = X509_check_host(crt, name, namelen,
                              X509_CHECK_FLAG_NO_WILDCARDS, NULL);
        match = -1;
        if (ret < 0) {
            fprintf(stderr, "internal error in X509_check_host");
            ++errors;
        } else if (fn->host) {
            if (ret == 1 && !samename)
                match = 1;
            if (ret == 0 && samename)
                match = 0;
        } else if (ret == 1)
            match = 1;
        check_message(fn, "host-no-wildcards", nameincert, match, *pname);
        ret = X509_check_email(crt, name, namelen, 0);
        match = -1;
        if (fn->email) {
            if (ret && !samename)
                match = 1;
            if (!ret && samename && strchr(nameincert, '@') != NULL)
                match = 0;
        } else if (ret)
            match = 1;
        check_message(fn, "email", nameincert, match, *pname);
        ++pname;
        free(name);
    }
}
['static void run_cert(X509 *crt, const char *nameincert,\n                     const struct set_name_fn *fn)\n{\n    const char *const *pname = names;\n    while (*pname) {\n        int samename = strcasecmp(nameincert, *pname) == 0;\n        size_t namelen = strlen(*pname);\n        char *name = malloc(namelen);\n        int match, ret;\n        memcpy(name, *pname, namelen);\n        ret = X509_check_host(crt, name, namelen, 0, NULL);\n        match = -1;\n        if (ret < 0) {\n            fprintf(stderr, "internal error in X509_check_host");\n            ++errors;\n        } else if (fn->host) {\n            if (ret == 1 && !samename)\n                match = 1;\n            if (ret == 0 && samename)\n                match = 0;\n        } else if (ret == 1)\n            match = 1;\n        check_message(fn, "host", nameincert, match, *pname);\n        ret = X509_check_host(crt, name, namelen,\n                              X509_CHECK_FLAG_NO_WILDCARDS, NULL);\n        match = -1;\n        if (ret < 0) {\n            fprintf(stderr, "internal error in X509_check_host");\n            ++errors;\n        } else if (fn->host) {\n            if (ret == 1 && !samename)\n                match = 1;\n            if (ret == 0 && samename)\n                match = 0;\n        } else if (ret == 1)\n            match = 1;\n        check_message(fn, "host-no-wildcards", nameincert, match, *pname);\n        ret = X509_check_email(crt, name, namelen, 0);\n        match = -1;\n        if (fn->email) {\n            if (ret && !samename)\n                match = 1;\n            if (!ret && samename && strchr(nameincert, \'@\') != NULL)\n                match = 0;\n        } else if (ret)\n            match = 1;\n        check_message(fn, "email", nameincert, match, *pname);\n        ++pname;\n        free(name);\n    }\n}']