1*260e9a87SYuri Pankov /* $Id: out.h,v 1.26 2014/12/01 08:05:52 schwarze Exp $ */ 295c635efSGarrett D'Amore /* 395c635efSGarrett D'Amore * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 495c635efSGarrett D'Amore * 595c635efSGarrett D'Amore * Permission to use, copy, modify, and distribute this software for any 695c635efSGarrett D'Amore * purpose with or without fee is hereby granted, provided that the above 795c635efSGarrett D'Amore * copyright notice and this permission notice appear in all copies. 895c635efSGarrett D'Amore * 995c635efSGarrett D'Amore * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1095c635efSGarrett D'Amore * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1195c635efSGarrett D'Amore * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1295c635efSGarrett D'Amore * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1395c635efSGarrett D'Amore * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1495c635efSGarrett D'Amore * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1595c635efSGarrett D'Amore * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1695c635efSGarrett D'Amore */ 1795c635efSGarrett D'Amore 1895c635efSGarrett D'Amore enum roffscale { 1995c635efSGarrett D'Amore SCALE_CM, /* centimeters (c) */ 2095c635efSGarrett D'Amore SCALE_IN, /* inches (i) */ 2195c635efSGarrett D'Amore SCALE_PC, /* pica (P) */ 2295c635efSGarrett D'Amore SCALE_PT, /* points (p) */ 2395c635efSGarrett D'Amore SCALE_EM, /* ems (m) */ 2495c635efSGarrett D'Amore SCALE_MM, /* mini-ems (M) */ 2595c635efSGarrett D'Amore SCALE_EN, /* ens (n) */ 2695c635efSGarrett D'Amore SCALE_BU, /* default horizontal (u) */ 2795c635efSGarrett D'Amore SCALE_VS, /* default vertical (v) */ 2895c635efSGarrett D'Amore SCALE_FS, /* syn. for u (f) */ 2995c635efSGarrett D'Amore SCALE_MAX 3095c635efSGarrett D'Amore }; 3195c635efSGarrett D'Amore 3295c635efSGarrett D'Amore struct roffcol { 3395c635efSGarrett D'Amore size_t width; /* width of cell */ 3495c635efSGarrett D'Amore size_t decimal; /* decimal position in cell */ 35*260e9a87SYuri Pankov int flags; /* layout flags, see tbl_cell */ 3695c635efSGarrett D'Amore }; 3795c635efSGarrett D'Amore 3895c635efSGarrett D'Amore struct roffsu { 3995c635efSGarrett D'Amore enum roffscale unit; 4095c635efSGarrett D'Amore double scale; 4195c635efSGarrett D'Amore }; 4295c635efSGarrett D'Amore 4395c635efSGarrett D'Amore typedef size_t (*tbl_strlen)(const char *, void *); 4495c635efSGarrett D'Amore typedef size_t (*tbl_len)(size_t, void *); 4595c635efSGarrett D'Amore 4695c635efSGarrett D'Amore struct rofftbl { 4795c635efSGarrett D'Amore tbl_strlen slen; /* calculate string length */ 4895c635efSGarrett D'Amore tbl_len len; /* produce width of empty space */ 4995c635efSGarrett D'Amore struct roffcol *cols; /* master column specifiers */ 5095c635efSGarrett D'Amore void *arg; /* passed to slen and len */ 5195c635efSGarrett D'Amore }; 5295c635efSGarrett D'Amore 5395c635efSGarrett D'Amore #define SCALE_VS_INIT(p, v) \ 5495c635efSGarrett D'Amore do { (p)->unit = SCALE_VS; \ 5595c635efSGarrett D'Amore (p)->scale = (v); } \ 5695c635efSGarrett D'Amore while (/* CONSTCOND */ 0) 5795c635efSGarrett D'Amore 5895c635efSGarrett D'Amore #define SCALE_HS_INIT(p, v) \ 59*260e9a87SYuri Pankov do { (p)->unit = SCALE_EN; \ 6095c635efSGarrett D'Amore (p)->scale = (v); } \ 6195c635efSGarrett D'Amore while (/* CONSTCOND */ 0) 6295c635efSGarrett D'Amore 63*260e9a87SYuri Pankov __BEGIN_DECLS 64*260e9a87SYuri Pankov 65*260e9a87SYuri Pankov struct tbl_span; 66*260e9a87SYuri Pankov 6795c635efSGarrett D'Amore int a2roffsu(const char *, struct roffsu *, enum roffscale); 68*260e9a87SYuri Pankov void tblcalc(struct rofftbl *tbl, 69*260e9a87SYuri Pankov const struct tbl_span *, size_t); 7095c635efSGarrett D'Amore 7195c635efSGarrett D'Amore __END_DECLS 72