Annotation of src/usr.bin/mandoc/tbl_tree.c, Revision 1.1
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:
! 24: #include "tbl_extern.h"
! 25:
! 26: static const char * const htypes[TBL_HEAD_MAX] = {
! 27: "data",
! 28: "vert",
! 29: "dvert",
! 30: };
! 31:
! 32: static const char * const ctypes[TBL_CELL_MAX] = {
! 33: "centre",
! 34: "right",
! 35: "left",
! 36: "number",
! 37: "span",
! 38: "long",
! 39: "down",
! 40: "horiz",
! 41: "dhoriz",
! 42: "vert",
! 43: "dvert",
! 44: };
! 45:
! 46:
! 47: /* ARGSUSED */
! 48: int
! 49: tbl_calc_tree(struct tbl *tbl)
! 50: {
! 51:
! 52: return(1);
! 53: }
! 54:
! 55:
! 56: int
! 57: tbl_write_tree(const struct tbl *tbl)
! 58: {
! 59: struct tbl_row *row;
! 60: struct tbl_cell *cell;
! 61: struct tbl_span *span;
! 62: struct tbl_data *data;
! 63: struct tbl_head *head;
! 64:
! 65: (void)printf("header\n");
! 66: TAILQ_FOREACH(head, &tbl->head, entries)
! 67: (void)printf("\t%s (=%p)\n", htypes[head->pos], head);
! 68:
! 69: (void)printf("layout\n");
! 70: TAILQ_FOREACH(row, &tbl->row, entries) {
! 71: (void)printf("\trow (=%p)\n", row);
! 72: TAILQ_FOREACH(cell, &row->cell, entries)
! 73: (void)printf("\t\t%s (=%p) >%p\n",
! 74: ctypes[cell->pos],
! 75: cell, cell->head);
! 76: }
! 77:
! 78: (void)printf("data\n");
! 79: TAILQ_FOREACH(span, &tbl->span, entries) {
! 80: (void)printf("\tspan >%p\n", span->row);
! 81: TAILQ_FOREACH(data, &span->data, entries)
! 82: (void)printf("\t\tdata >%p\n", data->cell);
! 83: }
! 84:
! 85: return(1);
! 86: }