4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <fcode/private.h>
34 #include <fcode/log.h>
37 find_resource(fc_resource_t
**head
, void *ptr
, int (cmp
)(void *, void *))
39 fc_resource_t
*f
, *prev
, *r
= *head
;
44 if (r
->data
== NULL
) {
56 if (cmp(ptr
, r
->data
)) {
68 add_resource(fc_resource_t
**head
, void *ptr
, int (cmp
)(void *, void *))
72 r
= find_resource(head
, ptr
, cmp
);
74 r
= MALLOC(sizeof (fc_resource_t
));
80 log_message(MSG_ERROR
, "add_resource: Duplicate entry: %p\n", ptr
);
85 free_resource(fc_resource_t
**head
, void *ptr
, int (cmp
)(void *, void *))
89 if ((r
= find_resource(head
, ptr
, cmp
)) != NULL
)
92 log_message(MSG_ERROR
, "free_resource: No such Entry: %p\n",
99 dump_print(void *s
, void *d
)
101 log_message(MSG_DEBUG
, "Buffer: %p\n", d
);
106 dump_resources(fcode_env_t
*env
)
108 fc_resource_t
**head
;
110 head
= (fc_resource_t
**) POP(DS
);
111 (void) find_resource(head
, NULL
, dump_print
);
115 propbufs(fcode_env_t
*env
)
117 PUSH(DS
, (fstack_t
) &env
->propbufs
);
125 fcode_env_t
*env
= initial_env
;
130 FORTH(0, "propbufs", propbufs
);
131 FORTH(0, "dump-resource", dump_resources
);