1 /*** macros.h ***************************************************************** 2 ** 3 ** This file is part of BibTool. 4 ** It is distributed under the GNU General Public License. 5 ** See the file COPYING for details. 6 ** 7 ** (c) 1996-2020 Gerd Neugebauer 8 ** 9 ** Net: gene@gerd-neugebauer.de 10 ** 11 ** This program is free software; you can redistribute it and/or modify 12 ** it under the terms of the GNU General Public License as published by 13 ** the Free Software Foundation; either version 2, or (at your option) 14 ** any later version. 15 ** 16 ** This program is distributed in the hope that it will be useful, 17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 ** GNU General Public License for more details. 20 ** 21 ** You should have received a copy of the GNU General Public License 22 ** along with this program; if not, write to the Free Software 23 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 ** 25 **----------------------------------------------------------------------------- 26 ** Description: 27 ** This header file contains definitions for the |Macro| 28 ** structure. |Macro| is the pointer type corresponding to the 29 ** structure |SMacro|. All C macros and functions provided 30 ** through this header file deal with the pointer type. The 31 ** structure itself is used in the allocation function only. 32 ** 33 ******************************************************************************/ 34 35 #include <bibtool/general.h> 36 #include <bibtool/symbols.h> 37 38 /*----------------------------------------------------------------------------- 39 ** Typedef: Macro 40 ** Purpose: This is a pointer type to represent a mapping from a 41 ** string to another string. This mapping is accompanied 42 ** by a counter which can be used as a reference count. 43 **___________________________________________________ */ 44 typedef struct mACRO /* */ 45 { Symbol mc_name; /* Name of the macro. */ 46 Symbol mc_value; /* Value of the macro. */ 47 int mc_used; /* Reference count. */ 48 struct mACRO *mc_next; /* Pointer the next macro.*/ 49 } SMacro, *Macro; /* */ 50 51 52 /*----------------------------------------------------------------------------- 53 ** Constant: MacroNULL() 54 ** Type: Macro 55 ** Purpose: This is the |NULL| pointer for the |Macro| type. It 56 ** can be used as a special or illlegal macro. 57 **___________________________________________________ */ 58 #define MacroNULL (Macro)0 59 60 /*----------------------------------------------------------------------------- 61 ** Macro: MacroName() 62 ** Type: String 63 ** Purpose: This is the functional representation of the name 64 ** component of a |Macro|. It can be used to extract this 65 ** information. It can also be used as a lvalue. 66 ** Arguments: 67 ** M |Macro| to consider 68 **___________________________________________________ */ 69 #define MacroName(M) ((M)->mc_name) 70 71 /*----------------------------------------------------------------------------- 72 ** Macro: MacroValue() 73 ** Type: String 74 ** Purpose: This is the functional representation of the value 75 ** component of a |Macro|. It can be used to extract this 76 ** information. It can also be used as a lvalue. 77 ** Arguments: 78 ** M |Macro| to consider 79 **___________________________________________________ */ 80 #define MacroValue(M) ((M)->mc_value) 81 82 /*----------------------------------------------------------------------------- 83 ** Macro: MacroCount() 84 ** Type: int 85 ** Purpose: This is the functional representation of the counter 86 ** component of a |Macro|. It can be used to extract this 87 ** information. It can also be used as a lvalue. 88 ** Arguments: 89 ** M |Macro| to consider 90 **___________________________________________________ */ 91 #define MacroCount(M) ((M)->mc_used) 92 93 /*----------------------------------------------------------------------------- 94 ** Macro: NextMacro() 95 ** Type: Macro 96 ** Purpose: This is the functional representation of the next 97 ** |Macro|. It can be used to extract this information. 98 ** It can also be used as a lvalue. 99 ** Arguments: 100 ** M |Macro| to consider 101 **___________________________________________________ */ 102 #define NextMacro(M) ((M)->mc_next) 103 104 #ifdef __STDC__ 105 #define _ARG(A) A 106 #else 107 #define _ARG(A) () 108 #endif 109 Macro new_macro _ARG((Symbol name,Symbol val,Macro next,int cnt));/*macros.c*/ 110 Symbol get_item _ARG((Symbol name,int type)); /* macros.c */ 111 Symbol get_key _ARG((Symbol name)); /* macros.c */ 112 Symbol look_macro _ARG((Symbol name, int add)); /* macros.c */ 113 bool each_macro _ARG((Macro m,bool (*fct)(Symbol,Symbol)));/* macros.c */ 114 int def_macro _ARG((Symbol name,Symbol val,int count));/* macros.c */ 115 void def_field_type _ARG((String s)); /* macros.c */ 116 void dump_mac _ARG((char *fname,int allp)); /* macros.c */ 117 void foreach_macro _ARG((bool (*fct)(Symbol,Symbol)));/* macros.c */ 118 void free_macro _ARG((Macro mac)); /* macros.c */ 119 void init_macros _ARG((void)); /* macros.c */ 120 void save_key _ARG((Symbol name, Symbol key)); /* macros.c */ 121 122 /*---------------------------------------------------------------------------*/ 123