1 /* catdvi - get text from DVI files 2 Copyright (C) 2001 Bjoern Brill <brill@fs.math.uni-frankfurt.de> 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */ 18 19 #ifndef PAGEREF_H 20 #define PAGEREF_H 21 22 #include "bytesex.h" 23 24 enum pageref_flavour_t { 25 PRF_INVALID = 0, 26 PRF_PHYSICAL, 27 PRF_COUNT0, 28 PRF_COUNT0_CHAPTER, 29 PRF_COMPLETE 30 }; 31 typedef enum pageref_flavour_t pageref_flavour_t; 32 33 typedef struct pageref_t { 34 sint32 physical; 35 sint32 count0; 36 sint32 chapter; 37 enum pageref_flavour_t flavour; 38 } pageref_t; 39 40 /* Make up a pageref_t from a string (syntax documented in catdvi manpage). 41 * Return flavour (!= 0 if no error). 42 * If an error occurs, we return PRF_INVALID (== 0) and do NOT modify *this. 43 */ 44 pageref_flavour_t pageref_parse(pageref_t * this, const char * pagespec); 45 46 /* \count0 usually holds the TeX page number. Plain TeX uses negative count0 47 * values for roman-numbered frontmatter (preface, toc, etc.) so we have 48 * the integers ordered like -1 < -2 < -3 < ... < 0 < 1 < 2 < 3 < ... 49 * (0 shouldn't appear as page number though). 50 * 51 * Compare two count0 values wrt this ordering. Return value like strcmp. 52 */ 53 int pageref_count0_cmp(sint32 a, sint32 b); 54 55 /* Compare two page references, given their flavours are compatible. 56 * Return value like strcmp. 57 */ 58 int pageref_cmp(const struct pageref_t * a, const struct pageref_t * b); 59 60 void pageref_print(pageref_t * this, FILE * f); 61 62 #endif /* PAGEREF_H */ 63