9 #define _(msgid) gettext (msgid)
13 struct ctl_class *class; /* Class of control structure. */
14 struct ctl_struct *down; /* Points toward the bottom of ctl_stack. */
15 void *private; /* Private data. */
18 struct ctl_struct *ctl_stack;
21 ctl_stack_clear (void)
23 while (ctl_stack != NULL)
25 struct ctl_struct *top = ctl_stack;
26 msg (SE, _("%s without %s."),
27 top->class->start_name, top->class->end_name);
28 ctl_stack_pop (top->private);
33 ctl_stack_push (struct ctl_class *class, void *private)
35 struct ctl_struct *ctl;
37 assert (private != NULL);
38 ctl = xmalloc (sizeof *ctl);
40 ctl->down = ctl_stack;
41 ctl->private = private;
46 ctl_stack_top (struct ctl_class *class)
48 struct ctl_struct *top = ctl_stack;
49 if (top != NULL && top->class == class)
53 if (ctl_stack_search (class) != NULL)
54 msg (SE, _("This command must appear inside %s...%s, "
55 "without intermediate %s...%s."),
56 class->start_name, class->end_name,
57 top->class->start_name, top->class->end_name);
63 ctl_stack_search (struct ctl_class *class)
65 struct ctl_struct *ctl;
67 for (ctl = ctl_stack; ctl != NULL; ctl = ctl->down)
68 if (ctl->class == class)
71 msg (SE, _("This command cannot appear outside %s...%s."),
72 class->start_name, class->end_name);
77 ctl_stack_pop (void *private UNUSED)
79 struct ctl_struct *top = ctl_stack;
82 assert (top->private == private);
84 top->class->close (top->private);
85 ctl_stack = top->down;
90 ctl_stack_is_empty (void)
92 return ctl_stack == NULL;