Annotation of src/usr.bin/mandoc/tbl_tree.c, Revision 1.2
1.1 schwarze 1: /* $Id: tree.c,v 1.2 2009/09/11 13:24:04 kristaps Exp $ */
2: /*
3: * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the above
7: * copyright notice and this permission notice appear in all copies.
8: *
9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: */
17: #include <sys/queue.h>
18:
19: #include <assert.h>
20: #include <stdio.h>
21: #include <stdlib.h>
22: #include <string.h>
23:
1.2 ! schwarze 24: #include "out.h"
! 25: #include "term.h"
1.1 schwarze 26: #include "tbl_extern.h"
27:
28: static const char * const htypes[TBL_HEAD_MAX] = {
29: "data",
30: "vert",
31: "dvert",
32: };
33:
34: static const char * const ctypes[TBL_CELL_MAX] = {
35: "centre",
36: "right",
37: "left",
38: "number",
39: "span",
40: "long",
41: "down",
42: "horiz",
43: "dhoriz",
44: "vert",
45: "dvert",
46: };
47:
48:
49: /* ARGSUSED */
50: int
51: tbl_calc_tree(struct tbl *tbl)
52: {
53:
54: return(1);
55: }
56:
57:
58: int
59: tbl_write_tree(const struct tbl *tbl)
60: {
61: struct tbl_row *row;
62: struct tbl_cell *cell;
63: struct tbl_span *span;
64: struct tbl_data *data;
65: struct tbl_head *head;
66:
67: (void)printf("header\n");
68: TAILQ_FOREACH(head, &tbl->head, entries)
69: (void)printf("\t%s (=%p)\n", htypes[head->pos], head);
70:
71: (void)printf("layout\n");
72: TAILQ_FOREACH(row, &tbl->row, entries) {
73: (void)printf("\trow (=%p)\n", row);
74: TAILQ_FOREACH(cell, &row->cell, entries)
75: (void)printf("\t\t%s (=%p) >%p\n",
76: ctypes[cell->pos],
77: cell, cell->head);
78: }
79:
80: (void)printf("data\n");
81: TAILQ_FOREACH(span, &tbl->span, entries) {
82: (void)printf("\tspan >%p\n", span->row);
83: TAILQ_FOREACH(data, &span->data, entries)
84: (void)printf("\t\tdata >%p\n", data->cell);
85: }
86:
87: return(1);
88: }