/******************************************************************** * FUNCTION save_aliases * * Save the aliases to the specified filespec * * INPUT: * fspec == output filespec to use (NULL == default) * * RETURNS: * status *********************************************************************/ status_t save_aliases (const xmlChar *fspec) { if (fspec == NULL) { fspec = get_aliases_file(); } status_t res = NO_ERR; xmlChar *fullspec = ncx_get_source(fspec, &res); if (res != NO_ERR) { log_error("\nError: Expand source '%s' failed (%s)\n", fspec, get_error_string(res)); return res; } res = check_for_saving_def_yangcli_file (ALIASES_FILE, fullspec); if (res != NO_ERR) { m__free(fullspec); return res; } FILE *fp = fopen((const char *)fullspec, "w"); if (fp) { /* this will truncate the file if there are no aliases */ alias_cb_t *alias; for (alias = get_first_alias(); alias != NULL; alias = get_next_alias(alias)) { write_alias(fp, alias); } /* Save mtime of this aliases file */ res = update_def_yangcli_file_mtime (ALIASES_FILE, fullspec); fclose(fp); } else { res = errno_to_status(); log_error("\nError: Open aliases file '%s' failed (%s)\n", fullspec, get_error_string(res)); } m__free(fullspec); return res; } /* save_aliases */
static bool prepare_pem_contents (p11_enumerate *ex, p11_buffer *buffer) { char message[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; unsigned char *der; node_asn *asn; size_t offset; int ret; int len; p11_buffer_add (buffer, ex->cert_der, ex->cert_len); asn = p11_asn1_create (ex->asn1_defs, "OPENSSL.CertAux"); return_val_if_fail (asn != NULL, false); if (!write_trust_and_rejects (ex, asn) || !write_alias (ex, asn) || !write_keyid (ex, asn) || !write_other (ex, asn)) return_val_if_reached (false); len = 0; offset = buffer->len; ret = asn1_der_coding (asn, "", NULL, &len, message); return_val_if_fail (ret == ASN1_MEM_ERROR, false); der = p11_buffer_append (buffer, len); return_val_if_fail (der != NULL, false); ret = asn1_der_coding (asn, "", der, &len, message); return_val_if_fail (ret == ASN1_SUCCESS, false); buffer->len = offset + len; asn1_delete_structure (&asn); return true; }