4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
48 #define PINFOALLOC 200
50 #define ERR_MEMORY "memory allocation failure, errno=%d"
55 static int pinfo_handle
= -1;
57 /* Free all allocated package info structures. */
61 bl_free(pinfo_handle
);
65 * This function manipulates the pinfo entry corresponding to the package
66 * indicated on the command line.
69 eptstat(struct cfent
*entry
, char *pkg
, char c
)
71 struct pinfo
*pinfo
, *last
, *me
, *myparent
;
74 useclass
= entry
->pkg_class
;
76 me
= myparent
= last
= (struct pinfo
*)0;
78 if (pinfo_handle
== -1) {
79 pinfo_handle
= bl_create(PINFOALLOC
, sizeof (struct pinfo
),
83 for (pinfo
= entry
->pinfo
; pinfo
; pinfo
= pinfo
->next
) {
84 if (strcmp(pkg
, pinfo
->pkg
) == 0) {
86 useclass
= pinfo
->aclass
;
96 * use a delete/add strategy to keep package list
97 * ordered by modification time
100 /* remove from list first */
102 myparent
->next
= me
->next
;
104 entry
->pinfo
= me
->next
;
108 /* leave 'me' around until later! */
110 if ((c
!= STAT_NEXT
) && (me
|| (c
!= RM_RDY
))) {
111 /* need to add onto end */
114 /* LINTED pointer cast may result in impro... */
115 me
= (struct pinfo
*)
116 bl_next_avail(pinfo_handle
);
118 progerr(gettext(ERR_MEMORY
), errno
);
122 me
->next
= (struct pinfo
*)NULL
;
123 if (entry
->npkgs
== 1) {
125 (void) strcpy(entry
->pkg_class
,
127 useclass
= entry
->pkg_class
;
129 useclass
= me
->aclass
;
131 (void) strncpy(me
->pkg
, pkg
, PKGSIZ
);
134 * Only change status for local objects. Need
135 * to maintain "shared" status for objects that
136 * are provided from a server.
138 if (me
->status
!= SERVED_FILE
)
139 me
->status
= ((c
== DUP_ENTRY
) ? '\0' : c
);
142 last
->next
= me
; /* add to end */
144 entry
->pinfo
= me
; /* only item */
146 /* just wanted to remove this package from list */
149 me
= (struct pinfo
*)0;