version 1.2, 2010/12/28 13:46:07 |
version 1.43, 2018/12/13 02:06:07 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> |
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
|
* Copyright (c) 2014, 2017 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
* Permission to use, copy, modify, and distribute this software for any |
* Permission to use, copy, modify, and distribute this software for any |
* purpose with or without fee is hereby granted, provided that the above |
* purpose with or without fee is hereby granted, provided that the above |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
#ifndef LIBROFF_H |
|
#define LIBROFF_H |
|
|
|
__BEGIN_DECLS |
struct eqn_node { |
|
struct mparse *parse; /* main parser, for error reporting */ |
enum tbl_tok { |
struct roff_node *node; /* syntax tree of this equation */ |
TBL_TOK_OPENPAREN = 0, |
struct eqn_def *defs; /* array of definitions */ |
TBL_TOK_CLOSEPAREN, |
char *data; /* source code of this equation */ |
TBL_TOK_COMMA, |
char *start; /* first byte of the current token */ |
TBL_TOK_SEMICOLON, |
char *end; /* first byte of the next token */ |
TBL_TOK_PERIOD, |
size_t defsz; /* number of definitions */ |
TBL_TOK_SPACE, |
size_t sz; /* length of the source code */ |
TBL_TOK_TAB, |
size_t toksz; /* length of the current token */ |
TBL_TOK_NIL, |
int gsize; /* default point size */ |
TBL_TOK__MAX |
int delim; /* in-line delimiters enabled */ |
|
char odelim; /* in-line opening delimiter */ |
|
char cdelim; /* in-line closing delimiter */ |
}; |
}; |
|
|
enum tbl_part { |
struct eqn_def { |
TBL_PART_OPTS, /* in options (first line) */ |
char *key; |
TBL_PART_LAYOUT, /* describing layout */ |
size_t keysz; |
TBL_PART_DATA /* creating data rows */ |
char *val; |
|
size_t valsz; |
}; |
}; |
|
|
struct tbl { |
|
enum tbl_part part; |
|
char buf[BUFSIZ]; |
|
char tab; /* cell-separator */ |
|
char decimal; /* decimal point */ |
|
int linesize; |
|
char delims[2]; |
|
int opts; |
|
#define TBL_OPT_CENTRE (1 << 0) |
|
#define TBL_OPT_EXPAND (1 << 1) |
|
#define TBL_OPT_BOX (1 << 2) |
|
#define TBL_OPT_DBOX (1 << 3) |
|
#define TBL_OPT_ALLBOX (1 << 4) |
|
#define TBL_OPT_NOKEEP (1 << 5) |
|
#define TBL_OPT_NOSPACE (1 << 6) |
|
}; |
|
|
|
struct tbl *tbl_alloc(void); |
struct eqn_node *eqn_alloc(struct mparse *); |
void tbl_free(struct tbl *); |
void eqn_box_free(struct eqn_box *); |
void tbl_reset(struct tbl *); |
void eqn_free(struct eqn_node *); |
enum rofferr tbl_read(struct tbl *, int, const char *, int); |
void eqn_parse(struct eqn_node *); |
enum tbl_tok tbl_next(struct tbl *, const char *, int *); |
void eqn_read(struct eqn_node *, const char *); |
|
void eqn_reset(struct eqn_node *); |
__END_DECLS |
|
|
|
#endif /*LIBROFF_H*/ |
|