1 /* 2 * bibutils.h 3 * 4 * Copyright (c) Chris Putnam 2005-2021 5 * 6 * Source code released under GPL version 2 7 * 8 */ 9 #ifndef BIBUTILS_H 10 #define BIBUTILS_H 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif /* __cplusplus */ 15 16 #include <stdio.h> 17 #include "bibdefs.h" 18 #include "bibl.h" 19 #include "slist.h" 20 #include "charsets.h" 21 #include "str_conv.h" 22 23 #define BIBL_FIRSTIN (100) 24 #define BIBL_MODSIN (BIBL_FIRSTIN) 25 #define BIBL_BIBTEXIN (BIBL_FIRSTIN+1) 26 #define BIBL_RISIN (BIBL_FIRSTIN+2) 27 #define BIBL_ENDNOTEIN (BIBL_FIRSTIN+3) 28 #define BIBL_COPACIN (BIBL_FIRSTIN+4) 29 #define BIBL_ISIIN (BIBL_FIRSTIN+5) 30 #define BIBL_MEDLINEIN (BIBL_FIRSTIN+6) 31 #define BIBL_ENDNOTEXMLIN (BIBL_FIRSTIN+7) 32 #define BIBL_BIBLATEXIN (BIBL_FIRSTIN+8) 33 #define BIBL_EBIIN (BIBL_FIRSTIN+9) 34 #define BIBL_WORDIN (BIBL_FIRSTIN+10) 35 #define BIBL_NBIBIN (BIBL_FIRSTIN+11) 36 #define BIBL_LASTIN (BIBL_FIRSTIN+11) 37 38 #define BIBL_FIRSTOUT (200) 39 #define BIBL_MODSOUT (BIBL_FIRSTOUT) 40 #define BIBL_BIBTEXOUT (BIBL_FIRSTOUT+1) 41 #define BIBL_RISOUT (BIBL_FIRSTOUT+2) 42 #define BIBL_ENDNOTEOUT (BIBL_FIRSTOUT+3) 43 #define BIBL_ISIOUT (BIBL_FIRSTOUT+4) 44 #define BIBL_WORD2007OUT (BIBL_FIRSTOUT+5) 45 #define BIBL_ADSABSOUT (BIBL_FIRSTOUT+6) 46 #define BIBL_NBIBOUT (BIBL_FIRSTOUT+7) 47 #define BIBL_BIBLATEXOUT (BIBL_FIRSTOUT+8) 48 #define BIBL_LASTOUT (BIBL_FIRSTOUT+8) 49 50 #define BIBL_FORMAT_VERBOSE (1) 51 #define BIBL_FORMAT_BIBOUT_FINALCOMMA (2) 52 #define BIBL_FORMAT_BIBOUT_SINGLEDASH (4) 53 #define BIBL_FORMAT_BIBOUT_WHITESPACE (8) 54 #define BIBL_FORMAT_BIBOUT_BRACKETS (16) 55 #define BIBL_FORMAT_BIBOUT_UPPERCASE (32) 56 #define BIBL_FORMAT_BIBOUT_STRICTKEY (64) 57 #define BIBL_FORMAT_BIBOUT_SHORTTITLE (128) 58 #define BIBL_FORMAT_BIBOUT_DROPKEY (256) 59 #define BIBL_FORMAT_MODSOUT_DROPKEY (512) 60 61 #define BIBL_RAW_WITHCHARCONVERT (4) 62 #define BIBL_RAW_WITHMAKEREFID (8) 63 64 #define BIBL_CHARSET_UNKNOWN CHARSET_UNKNOWN 65 #define BIBL_CHARSET_UNICODE CHARSET_UNICODE 66 #define BIBL_CHARSET_GB18030 CHARSET_GB18030 67 #define BIBL_CHARSET_DEFAULT CHARSET_DEFAULT 68 #define BIBL_CHARSET_UTF8_DEFAULT CHARSET_UTF8_DEFAULT 69 #define BIBL_CHARSET_BOM_DEFAULT CHARSET_BOM_DEFAULT 70 71 #define BIBL_SRC_DEFAULT (0) /* value from program default */ 72 #define BIBL_SRC_FILE (1) /* value from file, priority over default */ 73 #define BIBL_SRC_USER (2) /* value from user, priority over file, default */ 74 75 #define BIBL_XMLOUT_FALSE STR_CONV_XMLOUT_FALSE 76 #define BIBL_XMLOUT_TRUE STR_CONV_XMLOUT_TRUE 77 #define BIBL_XMLOUT_ENTITIES STR_CONV_XMLOUT_ENTITIES 78 79 typedef unsigned char uchar; 80 81 typedef struct param { 82 83 int readformat; 84 int writeformat; 85 86 int charsetin; 87 uchar charsetin_src; /*BIBL_SRC_DEFAULT, BIBL_SRC_FILE, BIBL_SRC_USER*/ 88 uchar latexin; 89 uchar utf8in; 90 uchar xmlin; 91 uchar nosplittitle; 92 93 int charsetout; 94 uchar charsetout_src; /* BIBL_SRC_PROG, BIBL_SRC_USER */ 95 uchar latexout; /* If true, write Latex codes */ 96 uchar utf8out; /* If true, write characters encoded by utf8 */ 97 uchar utf8bom; /* If true, write utf8 byte-order-mark */ 98 uchar xmlout; /* If true, write characters in XML entities */ 99 100 int format_opts; /* options for specific formats */ 101 int addcount; /* add reference count to reference id */ 102 uchar output_raw; 103 uchar verbose; 104 uchar singlerefperfile; 105 106 slist asis; /* Names that shouldn't be mangled */ 107 slist corps; /* Names that shouldn't be mangled-MODS corporation type */ 108 109 char *progname; 110 111 112 int (*readf)(FILE*,char*,int,int*,str*,str*,int*); 113 int (*processf)(fields*,const char*,const char*,long,struct param*); 114 int (*cleanf)(bibl*,struct param*); 115 int (*typef) (fields*,const char*,int,struct param*); 116 int (*convertf)(fields*,fields*,int,struct param*); 117 void (*headerf)(FILE*,struct param*); 118 void (*footerf)(FILE*); 119 int (*assemblef)(fields*,fields*,struct param*,unsigned long); 120 int (*writef)(fields*,FILE*,struct param*,unsigned long); 121 variants *all; 122 int nall; 123 124 125 } param; 126 127 int bibl_initparams( param *p, int readmode, int writemode, char *progname ); 128 void bibl_freeparams( param *p ); 129 int bibl_readasis( param *p, char *filename ); 130 int bibl_addtoasis( param *p, char *entry ); 131 int bibl_readcorps( param *p, char *filename ); 132 int bibl_addtocorps( param *p, char *entry ); 133 int bibl_read( bibl *b, FILE *fp, char *filename, param *p ); 134 int bibl_write( bibl *b, FILE *fp, param *p ); 135 void bibl_reporterr( int err ); 136 137 #ifdef __cplusplus 138 } 139 #endif /* __cplusplus */ 140 141 #endif 142 143