8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / tools / ctf / stabs / common / fth_enum.c
blob47542dcbf3aafd635cbe8c4153802d55b55dd6b4
1 /*
2 * CDDL HEADER START
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
7 * with the License.
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]
20 * CDDL HEADER END
23 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * Used to dump enums in forth mode.
32 * Enums are simple - there is no member-specific mode for them. We get
33 * the header op at the start, and we save the type id for dumping later.
34 * If we get the members op, we've been invoked in member-specific mode,
35 * which is a syntax error for an enum. When we ge the trailer op, we
36 * dump all of the members and the trailer thus concluding the enum.
39 #include "forth.h"
41 static ctf_id_t fth_enum_curtid;
42 static int fth_enum_curnmems;
44 static int
45 fth_enum_header(ctf_id_t tid)
47 fth_enum_curtid = tid;
49 (void) fprintf(out, "\n");
51 return (0);
54 /*ARGSUSED*/
55 static int
56 fth_enum_members(char *memfilter, char *format)
58 return (parse_warn("Member-specific mode cannot be used for "
59 " enums"));
62 /*ARGSUSED2*/
63 static int
64 fth_enum_cb(const char *name, int value, void *arg)
66 (void) fprintf(out, "here ,\" %s\" %x\n", name, value);
67 fth_enum_curnmems++;
69 return (0);
72 static int
73 fth_enum_trailer(void)
75 if (ctf_enum_iter(ctf, fth_enum_curtid, fth_enum_cb, NULL) != 0)
76 return (-1);
78 (void) fprintf(out, "%x c-enum .%s\n", fth_enum_curnmems, fth_curtype);
80 fth_enum_curnmems = 0;
82 return (0);
85 fth_type_ops_t fth_enum_ops = {
86 fth_enum_header,
87 fth_enum_members,
88 fth_enum_trailer