void print_name(BIO *out, const char *title, X509_NAME *nm,
                unsigned long lflags)
{
    char *buf;
    char mline = 0;
    int indent = 0;
    if (title)
        BIO_puts(out, title);
    if ((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
        mline = 1;
        indent = 4;
    }
    if (lflags == XN_FLAG_COMPAT) {
        buf = X509_NAME_oneline(nm, 0, 0);
        BIO_puts(out, buf);
        BIO_puts(out, "\n");
        OPENSSL_free(buf);
    } else {
        if (mline)
            BIO_puts(out, "\n");
        X509_NAME_print_ex(out, nm, indent, lflags);
        BIO_puts(out, "\n");
    }
}
['void print_name(BIO *out, const char *title, X509_NAME *nm,\n                unsigned long lflags)\n{\n    char *buf;\n    char mline = 0;\n    int indent = 0;\n    if (title)\n        BIO_puts(out, title);\n    if ((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {\n        mline = 1;\n        indent = 4;\n    }\n    if (lflags == XN_FLAG_COMPAT) {\n        buf = X509_NAME_oneline(nm, 0, 0);\n        BIO_puts(out, buf);\n        BIO_puts(out, "\\n");\n        OPENSSL_free(buf);\n    } else {\n        if (mline)\n            BIO_puts(out, "\\n");\n        X509_NAME_print_ex(out, nm, indent, lflags);\n        BIO_puts(out, "\\n");\n    }\n}', 'int BIO_puts(BIO *b, const char *buf)\n{\n    int ret;\n    size_t written = 0;\n    if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);\n        return -2;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL) {\n        ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);\n        if (ret <= 0)\n            return ret;\n    }\n    if (!b->init) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);\n        return -2;\n    }\n    ret = b->method->bputs(b, buf);\n    if (ret > 0) {\n        b->num_write += (uint64_t)ret;\n        written = ret;\n        ret = 1;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL)\n        ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0,\n                                     0L, ret, &written);\n    if (ret > 0) {\n        if (written > INT_MAX) {\n            BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG);\n            ret = -1;\n        } else {\n            ret = (int)written;\n        }\n    }\n    return ret;\n}', 'char *X509_NAME_oneline(const X509_NAME *a, char *buf, int len)\n{\n    const X509_NAME_ENTRY *ne;\n    int i;\n    int n, lold, l, l1, l2, num, j, type;\n    const char *s;\n    char *p;\n    unsigned char *q;\n    BUF_MEM *b = NULL;\n    static const char hex[17] = "0123456789ABCDEF";\n    int gs_doit[4];\n    char tmp_buf[80];\n#ifdef CHARSET_EBCDIC\n    unsigned char ebcdic_buf[1024];\n#endif\n    if (buf == NULL) {\n        if ((b = BUF_MEM_new()) == NULL)\n            goto err;\n        if (!BUF_MEM_grow(b, 200))\n            goto err;\n        b->data[0] = \'\\0\';\n        len = 200;\n    } else if (len == 0) {\n        return NULL;\n    }\n    if (a == NULL) {\n        if (b) {\n            buf = b->data;\n            OPENSSL_free(b);\n        }\n        strncpy(buf, "NO X509_NAME", len);\n        buf[len - 1] = \'\\0\';\n        return buf;\n    }\n    len--;\n    l = 0;\n    for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {\n        ne = sk_X509_NAME_ENTRY_value(a->entries, i);\n        n = OBJ_obj2nid(ne->object);\n        if ((n == NID_undef) || ((s = OBJ_nid2sn(n)) == NULL)) {\n            i2t_ASN1_OBJECT(tmp_buf, sizeof(tmp_buf), ne->object);\n            s = tmp_buf;\n        }\n        l1 = strlen(s);\n        type = ne->value->type;\n        num = ne->value->length;\n        if (num > NAME_ONELINE_MAX) {\n            X509err(X509_F_X509_NAME_ONELINE, X509_R_NAME_TOO_LONG);\n            goto end;\n        }\n        q = ne->value->data;\n#ifdef CHARSET_EBCDIC\n        if (type == V_ASN1_GENERALSTRING ||\n            type == V_ASN1_VISIBLESTRING ||\n            type == V_ASN1_PRINTABLESTRING ||\n            type == V_ASN1_TELETEXSTRING ||\n            type == V_ASN1_IA5STRING) {\n            if (num > (int)sizeof(ebcdic_buf))\n                num = sizeof(ebcdic_buf);\n            ascii2ebcdic(ebcdic_buf, q, num);\n            q = ebcdic_buf;\n        }\n#endif\n        if ((type == V_ASN1_GENERALSTRING) && ((num % 4) == 0)) {\n            gs_doit[0] = gs_doit[1] = gs_doit[2] = gs_doit[3] = 0;\n            for (j = 0; j < num; j++)\n                if (q[j] != 0)\n                    gs_doit[j & 3] = 1;\n            if (gs_doit[0] | gs_doit[1] | gs_doit[2])\n                gs_doit[0] = gs_doit[1] = gs_doit[2] = gs_doit[3] = 1;\n            else {\n                gs_doit[0] = gs_doit[1] = gs_doit[2] = 0;\n                gs_doit[3] = 1;\n            }\n        } else\n            gs_doit[0] = gs_doit[1] = gs_doit[2] = gs_doit[3] = 1;\n        for (l2 = j = 0; j < num; j++) {\n            if (!gs_doit[j & 3])\n                continue;\n            l2++;\n#ifndef CHARSET_EBCDIC\n            if ((q[j] < \' \') || (q[j] > \'~\'))\n                l2 += 3;\n#else\n            if ((os_toascii[q[j]] < os_toascii[\' \']) ||\n                (os_toascii[q[j]] > os_toascii[\'~\']))\n                l2 += 3;\n#endif\n        }\n        lold = l;\n        l += 1 + l1 + 1 + l2;\n        if (l > NAME_ONELINE_MAX) {\n            X509err(X509_F_X509_NAME_ONELINE, X509_R_NAME_TOO_LONG);\n            goto end;\n        }\n        if (b != NULL) {\n            if (!BUF_MEM_grow(b, l + 1))\n                goto err;\n            p = &(b->data[lold]);\n        } else if (l > len) {\n            break;\n        } else\n            p = &(buf[lold]);\n        *(p++) = \'/\';\n        memcpy(p, s, (unsigned int)l1);\n        p += l1;\n        *(p++) = \'=\';\n#ifndef CHARSET_EBCDIC\n        q = ne->value->data;\n#endif\n        for (j = 0; j < num; j++) {\n            if (!gs_doit[j & 3])\n                continue;\n#ifndef CHARSET_EBCDIC\n            n = q[j];\n            if ((n < \' \') || (n > \'~\')) {\n                *(p++) = \'\\\\\';\n                *(p++) = \'x\';\n                *(p++) = hex[(n >> 4) & 0x0f];\n                *(p++) = hex[n & 0x0f];\n            } else\n                *(p++) = n;\n#else\n            n = os_toascii[q[j]];\n            if ((n < os_toascii[\' \']) || (n > os_toascii[\'~\'])) {\n                *(p++) = \'\\\\\';\n                *(p++) = \'x\';\n                *(p++) = hex[(n >> 4) & 0x0f];\n                *(p++) = hex[n & 0x0f];\n            } else\n                *(p++) = q[j];\n#endif\n        }\n        *p = \'\\0\';\n    }\n    if (b != NULL) {\n        p = b->data;\n        OPENSSL_free(b);\n    } else\n        p = buf;\n    if (i == 0)\n        *p = \'\\0\';\n    return p;\n err:\n    X509err(X509_F_X509_NAME_ONELINE, ERR_R_MALLOC_FAILURE);\n end:\n    BUF_MEM_free(b);\n    return NULL;\n}']