e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * CDDL HEADER START
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * The contents of this file are subject to the terms of the
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Common Development and Distribution License, Version 1.0 only
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * (the "License"). You may not use this file except in compliance
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * with the License.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * See the License for the specific language governing permissions
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * and limitations under the License.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * When distributing Covered Code, include this CDDL HEADER in each
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * If applicable, add the following below this CDDL HEADER, with the
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * fields enclosed by brackets "[]" replaced with your own identifying
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * CDDL HEADER END
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Copyright 2002-2003 Sun Microsystems, Inc. All rights reserved.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Use is subject to license terms.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync#pragma ident "%Z%%M% %I% %E% SMI"
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncextract_label_info(ctf_file_t *fp, const ctf_lblent_t **ctl, uint_t *num_labels)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Labels are only supported in V2 or later
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync /* LINTED - pointer alignment */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync *ctl = (const ctf_lblent_t *)(fp->ctf_buf + h->cth_lbloff);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync *num_labels = (h->cth_objtoff - h->cth_lbloff) / sizeof (ctf_lblent_t);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (0);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Returns the topmost label, or NULL if any errors are encountered
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncconst char *
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync const char *s;
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if (extract_label_info(fp, &ctlp, &num_labels) == CTF_ERR)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if ((s = ctf_strraw(fp, (ctlp + num_labels - 1)->ctl_label)) == NULL)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (s);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Iterate over all labels. We pass the label string and the lblinfo_t struct
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * to the specified callback function.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncctf_label_iter(ctf_file_t *fp, ctf_label_f *func, void *arg)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if (extract_label_info(fp, &ctlp, &num_labels) == CTF_ERR)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if ((lname = ctf_strraw(fp, ctlp->ctl_label)) == NULL) {
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync "typeidx %u\n", ctlp->ctl_label, ctlp->ctl_typeidx);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (0);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync const char *lca_name; /* Label we want to retrieve info for */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync ctf_lblinfo_t *lca_info; /* Where to store the info about the label */
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsynclabel_info_cb(const char *lname, const ctf_lblinfo_t *linfo, void *arg)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * If lname matches the label we are looking for, copy the
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * lblinfo_t struct for the caller.
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if (strcmp(lname, ((linfo_cb_arg_t *)arg)->lca_name) == 0) {
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Allow caller not to allocate storage to test if label exists
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (0);
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync * Retrieve information about the label with name "lname"
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsyncctf_label_info(ctf_file_t *fp, const char *lname, ctf_lblinfo_t *linfo)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync if ((rc = ctf_label_iter(fp, label_info_cb, &cb_arg)) == CTF_ERR)
e083a0c2c99cea982dcf8e12ec3452cc575b5663vboxsync return (0);