Esempio n. 1
0
/* Destroy -- Destroy agent */
int
ndmis_destroy (struct ndm_session *sess)
{
	if (!sess->plumb.image_stream) {
		return 0;
	}

	if (sess->plumb.image_stream->buf) {
		NDMOS_API_FREE (sess->plumb.image_stream->buf);
	}
	NDMOS_API_FREE (sess->plumb.image_stream);
	sess->plumb.image_stream = NULL;

	return 0;
}
Esempio n. 2
0
void ndmfhdb_unregister_callbacks(struct ndmlog* ixlog)
{
  if (ixlog->nfc) {
    NDMOS_API_FREE(ixlog->nfc);
    ixlog->nfc = NULL;
  }
}
Esempio n. 3
0
/*
 * Env list mgmt.
 *
 * Return a chunk of memory with all entries from the envlist as
 * one big enumeration useable for rpc to use as return value.
 * We allacate the memory and keep the pointer in the table handle
 * which gets freed on destroy of the table.
 */
ndmp9_pval *
ndma_enumerate_env_list (struct ndm_env_table *envtab)
{
	int i;
	struct ndm_env_entry *	entry;

	/*
	 * See if we need to allocate memory or can reuse the memory
	 * already allocated in an earlier call.
	 */
	if (!envtab->enumerate) {
		envtab->enumerate = NDMOS_API_MALLOC (sizeof(ndmp9_pval) * envtab->n_env);
		envtab->enumerate_length = envtab->n_env;
	} else if (envtab->enumerate_length != envtab->n_env) {
		NDMOS_API_FREE (envtab->enumerate);
		envtab->enumerate = NDMOS_API_MALLOC (sizeof(ndmp9_pval) * envtab->n_env);
		envtab->enumerate_length = envtab->n_env;
	}

	if (!envtab->enumerate) {
		return NULL;
	}
	NDMOS_API_BZERO (envtab->enumerate, sizeof(ndmp9_pval) * envtab->n_env);

	i = 0;
	for (entry = envtab->head; entry; entry = entry->next) {
		memcpy (&envtab->enumerate[i], &entry->pval, sizeof(ndmp9_pval));
		i++;
	}

	return envtab->enumerate;
}
Esempio n. 4
0
/*
 * Nlist mgmt.
 *
 * Return a chunk of memory with all entries from the nlist as
 * one big enumeration useable for rpc to use as return value.
 * We allacate the memory and keep the pointer in the table handle
 * which gets freed on destroy of the table.
 */
ndmp9_name *
ndma_enumerate_nlist (struct ndm_nlist_table *nlist)
{
	int i;
	struct ndm_nlist_entry *	entry;

	/*
	 * See if we need to allocate memory or can reuse the memory
	 * already allocated in an earlier call.
	 */
	if (!nlist->enumerate) {
		nlist->enumerate = NDMOS_API_MALLOC (sizeof(ndmp9_name) * nlist->n_nlist);
		nlist->enumerate_length = nlist->n_nlist;
	} else if (nlist->enumerate_length != nlist->n_nlist) {
		NDMOS_API_FREE (nlist->enumerate);
		nlist->enumerate = NDMOS_API_MALLOC (sizeof(ndmp9_name) * nlist->n_nlist);
		nlist->enumerate_length = nlist->n_nlist;
	}

	if (!nlist->enumerate) {
		return NULL;
	}
	NDMOS_API_BZERO (nlist->enumerate, sizeof(ndmp9_name) * nlist->n_nlist);

	i = 0;
	for (entry = nlist->head; entry; entry = entry->next) {
		memcpy (&nlist->enumerate[i], &entry->name, sizeof(ndmp9_name));
		i++;
	}

	return nlist->enumerate;
}
Esempio n. 5
0
void
ndmos_tape_unregister_callbacks (struct ndm_session *sess)
{
	if (!sess->ntsc) {
		NDMOS_API_FREE (sess->ntsc);
		sess->ntsc = NULL;
	}
}
Esempio n. 6
0
/* Destroy -- Destroy agent */
int ndmda_fh_destroy(struct ndm_session* sess)
{
  if (sess->data_acb->fhh_buf) {
    NDMOS_API_FREE(sess->data_acb->fhh_buf);
    sess->data_acb->fhh_buf = NULL;
  }

  return 0;
}
Esempio n. 7
0
/* Destroy -- Destroy agent */
int
ndmta_destroy (struct ndm_session *sess)
{
	if (!sess->tape_acb)
		return 0;

	if (sess->tape_acb->tape_buffer) {
		NDMOS_API_FREE (sess->tape_acb->tape_buffer);
	}

#ifdef NDMOS_OPTION_TAPE_SIMULATOR
	if (sess->tape_acb->drive_name) {
		NDMOS_API_FREE (sess->tape_acb->drive_name);
	}
#endif

	NDMOS_API_FREE (sess->tape_acb);
	sess->tape_acb = NULL;

	return 0;
}
Esempio n. 8
0
/*
 * Add a new entry to an environment list table.
 * Return entry if caller want to modify it.
 */
struct ndm_env_entry *
ndma_store_env_list (struct ndm_env_table *envtab, ndmp9_pval *pv)
{
	struct ndm_env_entry *	entry;

	if (envtab->n_env >= NDM_MAX_ENV)
		return NULL;

	entry = NDMOS_API_MALLOC (sizeof(struct ndm_env_entry));
	if (!entry)
		return NULL;

	entry->pval.name = NDMOS_API_STRDUP (pv->name);
	if (!entry->pval.name) {
		NDMOS_API_FREE (entry);
		return NULL;
	}

	entry->pval.value = NDMOS_API_STRDUP (pv->value);
	if (!entry->pval.value) {
		NDMOS_API_FREE (entry->pval.name);
		NDMOS_API_FREE (entry);
		return NULL;
	}

	entry->next = NULL;
	if (envtab->tail) {
		envtab->tail->next = entry;
		envtab->tail = entry;
	} else {
		envtab->head = entry;
		envtab->tail = entry;
	}

	envtab->n_env++;

	return entry;
}
Esempio n. 9
0
/* Destroy -- destroy agent */
int
ndmda_destroy (struct ndm_session *sess)
{
	if (!sess->data_acb) {
		return 0;
	}

	if (sess->data_acb->fmt_image_buf) {
		NDMOS_API_FREE (sess->data_acb->fmt_image_buf);
	}
	if (sess->data_acb->fmt_error_buf) {
		NDMOS_API_FREE (sess->data_acb->fmt_error_buf);
	}
	if (sess->data_acb->fmt_wrap_buf) {
		NDMOS_API_FREE (sess->data_acb->fmt_wrap_buf);
	}

	ndmda_fh_destroy (sess);

	NDMOS_API_FREE (sess->data_acb);
	sess->data_acb = NULL;

	return 0;
}
Esempio n. 10
0
/*
 * Destroy a Media Table.
 */
void
ndmca_destroy_media_table (struct ndm_media_table *mtab)
{
        struct ndmmedia *	me, *next;

        for (me = mtab->head; me; me = next) {
                next = me->next;

                NDMOS_API_FREE (me);
        }

        mtab->head = NULL;
        mtab->tail = NULL;
        mtab->n_media = 0;
}
Esempio n. 11
0
/*
 * Update an entry in an environment list table.
 * If it doesn't exist add a new entry.
 * Return entry if caller want to modify it.
 */
struct ndm_env_entry *
ndma_update_env_list (struct ndm_env_table *envtab, ndmp9_pval *pv)
{
	struct ndm_env_entry *	entry;

	for (entry = envtab->head; entry; entry = entry->next) {
		if (strcmp(entry->pval.name, pv->name) == 0) {
			NDMOS_API_FREE (entry->pval.value);
			entry->pval.value = NDMOS_API_STRDUP (pv->value);
			return entry;
                }
	}

	return ndma_store_env_list (envtab, pv);
}
Esempio n. 12
0
/*
 * Add a new entry to a nlist list table.
 * Return entry if caller want to modify it.
 */
struct ndm_nlist_entry *
ndma_store_nlist (struct ndm_nlist_table *nlist, ndmp9_name *nl)
{
	struct ndm_nlist_entry *	entry;

	if (nlist->n_nlist >= NDM_MAX_NLIST)
		return NULL;

	entry = NDMOS_API_MALLOC (sizeof(struct ndm_nlist_entry));
	if (!entry)
		return NULL;

	NDMOS_MACRO_ZEROFILL (entry);

	entry->name.original_path = NDMOS_API_STRDUP (nl->original_path);
	if (!entry->name.original_path)
		goto bail_out;

	entry->name.destination_path = NDMOS_API_STRDUP (nl->destination_path);
	if (!entry->name.destination_path)
		goto bail_out;

	entry->name.name = NDMOS_API_STRDUP (nl->name);
	if (!entry->name.name)
		goto bail_out;

	entry->name.other_name = NDMOS_API_STRDUP (nl->other_name);
	if (!entry->name.other_name)
		goto bail_out;

	entry->name.node = nl->node;
	entry->name.fh_info = nl->fh_info;
	entry->result_err = NDMP9_UNDEFINED_ERR;
	entry->result_count = 0;

	entry->next = NULL;
	if (nlist->tail) {
		nlist->tail->next = entry;
		nlist->tail = entry;
	} else {
		nlist->head = entry;
		nlist->tail = entry;
	}

	nlist->n_nlist++;

	return entry;

bail_out:
	if (entry->name.other_name)
		NDMOS_API_FREE (entry->name.other_name);

	if (entry->name.name)
		NDMOS_API_FREE (entry->name.name);

	if (entry->name.destination_path)
		NDMOS_API_FREE (entry->name.destination_path);

	if (entry->name.original_path)
		NDMOS_API_FREE (entry->name.original_path);

	NDMOS_API_FREE (entry);

	return NULL;
}