1*0a6a1f1dSLionel Sambuc /* Id: out.h,v 1.21 2011/07/17 15:24:25 kristaps Exp */ 2d65f6f70SBen Gras /* 392395e9cSLionel Sambuc * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> 4d65f6f70SBen Gras * 5d65f6f70SBen Gras * Permission to use, copy, modify, and distribute this software for any 6d65f6f70SBen Gras * purpose with or without fee is hereby granted, provided that the above 7d65f6f70SBen Gras * copyright notice and this permission notice appear in all copies. 8d65f6f70SBen Gras * 9d65f6f70SBen Gras * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10d65f6f70SBen Gras * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11d65f6f70SBen Gras * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12d65f6f70SBen Gras * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13d65f6f70SBen Gras * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14d65f6f70SBen Gras * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15d65f6f70SBen Gras * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16d65f6f70SBen Gras */ 17d65f6f70SBen Gras #ifndef OUT_H 18d65f6f70SBen Gras #define OUT_H 19d65f6f70SBen Gras 2092395e9cSLionel Sambuc enum roffscale { 2192395e9cSLionel Sambuc SCALE_CM, /* centimeters (c) */ 2292395e9cSLionel Sambuc SCALE_IN, /* inches (i) */ 2392395e9cSLionel Sambuc SCALE_PC, /* pica (P) */ 2492395e9cSLionel Sambuc SCALE_PT, /* points (p) */ 2592395e9cSLionel Sambuc SCALE_EM, /* ems (m) */ 2692395e9cSLionel Sambuc SCALE_MM, /* mini-ems (M) */ 2792395e9cSLionel Sambuc SCALE_EN, /* ens (n) */ 2892395e9cSLionel Sambuc SCALE_BU, /* default horizontal (u) */ 2992395e9cSLionel Sambuc SCALE_VS, /* default vertical (v) */ 3092395e9cSLionel Sambuc SCALE_FS, /* syn. for u (f) */ 3192395e9cSLionel Sambuc SCALE_MAX 3292395e9cSLionel Sambuc }; 33d65f6f70SBen Gras 34d65f6f70SBen Gras struct roffcol { 35d65f6f70SBen Gras size_t width; /* width of cell */ 36d65f6f70SBen Gras size_t decimal; /* decimal position in cell */ 37d65f6f70SBen Gras }; 38d65f6f70SBen Gras 3992395e9cSLionel Sambuc struct roffsu { 4092395e9cSLionel Sambuc enum roffscale unit; 4192395e9cSLionel Sambuc double scale; 4292395e9cSLionel Sambuc }; 4392395e9cSLionel Sambuc 44d65f6f70SBen Gras typedef size_t (*tbl_strlen)(const char *, void *); 45d65f6f70SBen Gras typedef size_t (*tbl_len)(size_t, void *); 46d65f6f70SBen Gras 47d65f6f70SBen Gras struct rofftbl { 48d65f6f70SBen Gras tbl_strlen slen; /* calculate string length */ 49d65f6f70SBen Gras tbl_len len; /* produce width of empty space */ 50d65f6f70SBen Gras struct roffcol *cols; /* master column specifiers */ 51d65f6f70SBen Gras void *arg; /* passed to slen and len */ 52d65f6f70SBen Gras }; 53d65f6f70SBen Gras 5492395e9cSLionel Sambuc __BEGIN_DECLS 55d65f6f70SBen Gras 56d65f6f70SBen Gras #define SCALE_VS_INIT(p, v) \ 57d65f6f70SBen Gras do { (p)->unit = SCALE_VS; \ 58d65f6f70SBen Gras (p)->scale = (v); } \ 59d65f6f70SBen Gras while (/* CONSTCOND */ 0) 60d65f6f70SBen Gras 61d65f6f70SBen Gras #define SCALE_HS_INIT(p, v) \ 62d65f6f70SBen Gras do { (p)->unit = SCALE_BU; \ 63d65f6f70SBen Gras (p)->scale = (v); } \ 64d65f6f70SBen Gras while (/* CONSTCOND */ 0) 65d65f6f70SBen Gras 66d65f6f70SBen Gras int a2roffsu(const char *, struct roffsu *, enum roffscale); 67d65f6f70SBen Gras void tblcalc(struct rofftbl *tbl, const struct tbl_span *); 68d65f6f70SBen Gras 69d65f6f70SBen Gras __END_DECLS 70d65f6f70SBen Gras 71d65f6f70SBen Gras #endif /*!OUT_H*/ 72