/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* utility for vntsd queue handling
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wait.h>
#include <time.h>
#include <thread.h>
#include <signal.h>
#include "vntsd.h"
/* alloc_que_el() allocates a queue element */
static vntsd_que_t *
{
/* allocate a queue element */
return (NULL);
}
return (el);
}
/* vntsd_que_append() appends a element to a queue */
int
{
vntsd_que_t *p;
/* allocate a queue element */
return (VNTSD_ERR_NO_MEM);
}
p = *que_hd;
if (p == NULL) {
/* first one */
} else {
/* walk to the last one */
p = p->nextp;
}
return (VNTSD_SUCCESS);
}
/* vntsd_que_insert_after() inserts element arter the handle */
int
{
q = que;
while (q != NULL) {
break;
}
q = q->nextp;
}
if (q == NULL) {
/* not in queue */
return (VNTSD_ERR_EL_NOT_FOUND);
}
return (VNTSD_ERR_NO_MEM);
}
return (VNTSD_SUCCESS);
}
/* vntsd_que_rm() removes an element from a queue */
int
{
vntsd_que_t *p = *que_hd;
while (p != NULL) {
/* match handle */
break;
}
prevp = p;
p = p->nextp;
}
if (p == NULL) {
/* not found */
return (VNTSD_ERR_EL_NOT_FOUND);
}
/* found */
if (p == *que_hd) {
/* first one */
} else {
}
}
free(p);
return (VNTSD_SUCCESS);
}
/* vntsd_que_walk() - walk queue and apply function to each element */
void *
{
vntsd_que_t *p = que_hd;
while (p != NULL) {
return (p->handle);
}
p = p->nextp;
}
return (VNTSD_SUCCESS);
}
/* vntsd_que_find() finds first match */
void *
{
vntsd_que_t *p = que_hd;
while (p != NULL) {
/* found match */
return (p->handle);
}
p = p->nextp;
}
/* not found */
return (NULL);
}
/* vntsd_free_que() frees entire queue */
void
{
vntsd_que_t *p;
while (*q != NULL) {
p = *q;
*q = p->nextp;
if (clean_func) {
/* clean func will free the handle */
(*clean_func)(p->handle);
} else {
}
free(p);
}
}
/*
* vntsd_que_pos() matches a handle and returns a handle located at "pos"
* relative to the matched handle. pos supported are 1 or -1.
*/
void *
{
vntsd_que_t *p = que_hd;
while (p != NULL) {
/* find match */
if (pos == 1) {
/* forward 1 */
}
/* last one go to first */
} else {
/* backward 1 */
}
/* first one, return last one */
p = p->nextp;
}
return (p->handle);
}
}
p = p->nextp;
}
thr_self());
return (NULL);
}