High: core: Internal tls api improvements for reuse with future LRMD tls backend.
cib_send_tls(gnutls_session * session, xmlNode * msg)
static int
crm_send_tls(gnutls_session * session, const char *buf, size_t len)
 {
    const char *unsent = buf;
    int rc = 0;
    int total_send;
 
    if (buf == NULL) {
        return -1;
     }
 
    total_send = len;
    crm_trace("Message size: %d", len);
 
    while (TRUE) {
        rc = gnutls_record_send(*session, unsent, len);
 
        if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) {
            crm_debug("Retry");
 
        } else if (rc < 0) {
            crm_err("Connection terminated rc = %d", rc);
            break;
 
        } else if (rc < len) {
            crm_debug("Only sent %d of %d bytes", rc, len);
            len -= rc;
            unsent += rc;
        } else {
            crm_debug("Sent %d bytes", rc);
            break;
         }
     }
 
    return rc < 0 ? rc : total_send;
 }

cib_send_tls(gnutls_session * session, xmlNode * msg)
 {
    char *xml_text = NULL;
#  if 0
    const char *name = crm_element_name(msg);
 
    if (safe_str_neq(name, "cib_command")) {
        xmlNodeSetName(msg, "cib_result");
     }
#  endif
    xml_text = dump_xml_unformatted(msg);
    if (xml_text != NULL) {
        char *unsent = xml_text;
        int len = strlen(xml_text);
        int rc = 0;
 
        len++;                  /* null char */
        crm_trace("Message size: %d", len);
 
        while (TRUE) {
            rc = gnutls_record_send(*session, unsent, len);
            crm_debug("Sent %d bytes", rc);
 
            if (rc == GNUTLS_E_INTERRUPTED || rc == GNUTLS_E_AGAIN) {
                crm_debug("Retry");
 
            } else if (rc < 0) {
                crm_debug("Connection terminated");
                break;
 
            } else if (rc < len) {
                crm_debug("Only sent %d of %d bytes", rc, len);
                len -= rc;
                unsent += rc;
            } else {
                break;
            }
         }
     }
    free(xml_text);
    return NULL;
 
 }
