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) 2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
39 // global data to/from the lexer
40 pthread_mutex_t gParserLock
;
41 fru_errno_t gParserErrno
= FRU_SUCCESS
;
42 char *gParserString
= NULL
;
43 Ancestor
*gParserAnts
= NULL
;
44 PathDef
*gParserHead
= NULL
;
45 int *gParserAbs
= NULL
;
47 // returns a NULL terminated list of PathDef objects.
48 // and a NULL terminated list of ancestor objects this path exists in
49 // NOTE: ancestors may be NULL if no tags contain a valid path.
51 fru_field_parser(const char *path
, Ancestor
**ancestors
,
52 int *absolute
, PathDef
**pathDef
)
54 // lock up the globals for the parser...
55 pthread_mutex_lock(&gParserLock
);
57 // get out a string for the parser to play with.
58 gParserString
= strdup(path
);
59 if (gParserString
== NULL
) {
60 pthread_mutex_unlock(&gParserLock
);
63 // save the head pointer for delete.
64 char *delPtr
= gParserString
;
68 // set up for return data from lexer.
71 gParserErrno
= FRU_SUCCESS
;
72 gParserAbs
= absolute
;
77 // clean up the string we used for yacc.
85 fru_errno_t err
= gParserErrno
;
86 pthread_mutex_unlock(&gParserLock
);
90 /* if ((gParserHead == NULL) || (gParserAnts == NULL)) { */
91 /* allow ancestors to be NULL */
92 /* some elements don't have tagged ancestors */
93 if (gParserHead
== NULL
) {
95 pthread_mutex_unlock(&gParserLock
);
99 *pathDef
= gParserHead
;
100 *ancestors
= gParserAnts
;
102 pthread_mutex_unlock(&gParserLock
);
103 return (FRU_SUCCESS
);