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