1  /* commands.h - declarations for commands.c and command_data.c */
       2  #ifndef COMMANDS_H
       3  #define COMMANDS_H
       4  /* Copyright 2010-2023 Free Software Foundation, Inc.
       5  
       6     This program is free software: you can redistribute it and/or modify
       7     it under the terms of the GNU General Public License as published by
       8     the Free Software Foundation, either version 3 of the License, or
       9     (at your option) any later version.
      10  
      11     This program is distributed in the hope that it will be useful,
      12     but WITHOUT ANY WARRANTY; without even the implied warranty of
      13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14     GNU General Public License for more details.
      15  
      16     You should have received a copy of the GNU General Public License
      17     along with this program.  If not, see <http://www.gnu.org/licenses/>. */
      18  
      19  typedef struct command_struct {
      20      char *cmdname;
      21      unsigned long flags; /* Up to 32 flags */
      22      int data; /* type of command. */
      23      int args_number; /* Number of arguments for brace or line commands. */
      24  } COMMAND;
      25  
      26  extern COMMAND builtin_command_data[];
      27  extern COMMAND *user_defined_command_data;
      28  
      29  /* Command ID's with this bit set represent a user-defined command. */
      30  #define USER_COMMAND_BIT 0x8000
      31  
      32  enum command_id lookup_command (char *cmdname);
      33  
      34  #define command_data(id) \
      35    (!((id) & USER_COMMAND_BIT) \
      36     ? builtin_command_data[(id)] \
      37     : user_defined_command_data[(id) & ~USER_COMMAND_BIT])
      38  
      39  #define command_flags(e) (!(e) ? 0 : (command_data((e)->cmd).flags))
      40  #define command_name(cmd) (command_data(cmd).cmdname)
      41  
      42  int close_preformatted_command (enum command_id cmd_id);
      43  int item_line_command (enum command_id cmd_id);
      44  enum command_id add_texinfo_command (char *name);
      45  void remove_texinfo_command (enum command_id cmd);
      46  void wipe_user_commands (void);
      47  
      48  /* Available command flags. */
      49  
      50  #define CF_line			        0x0001
      51  #define CF_deprecated   	        0x0002
      52  /* commands that should only appear at the root level and contain up to
      53     the next root command.  @node and sectioning commands. */
      54  #define CF_root			        0x0004
      55  /* sectioning and heading commands */
      56  #define CF_sectioning_heading	        0x0008
      57  #define CF_brace		        0x0010
      58  /* CF_letter_no_arg is not used in XS parser, used in perl */
      59  #define CF_letter_no_arg	        0x0020
      60  #define CF_accent		        0x0040
      61  /* CF_math is not used in XS parser, used in perl */
      62  #define CF_math			        0x0080
      63  /* commands with an unlimited number of arguments */
      64  #define CF_variadic		        0x0100
      65  #define CF_INFOENCLOSE  	        0x0200
      66  /* in_heading_spec only valid in heading or footing specifications */
      67  #define CF_in_heading_spec     	        0x0400
      68  #define CF_ref			        0x0800
      69  #define CF_ALIAS                        0x1000
      70  #define CF_block		        0x2000
      71  /* in_heading_spec commands are only valid in heading_spec */
      72  #define CF_heading_spec		        0x4000
      73  /* CF_internal is not used in code, but it should be kept as internal
      74   * commands marker */
      75  #define CF_internal		        0x8000
      76  /* command that affect the document as a whole and can appear more than once */
      77  #define CF_global			0x00010000
      78  #define CF_def		        	0x00020000
      79  #define CF_def_alias	        	0x00040000
      80  /* only accept plain text, ie only accent, symbol and glyph commands */
      81  #define CF_contain_plain_text		0x00080000
      82  /* CF_close_paragraph commands force closing an opened paragraph */
      83  #define CF_close_paragraph		0x00100000
      84  /* for commands containing simple text only, corresponding to paragraph
      85     text without @ref, @footnote, @titlefont, @anchor nor @verb. */
      86  #define CF_contain_basic_inline        	0x00200000
      87  #define CF_preformatted	        	0x00400000
      88  #define CF_preformatted_code		0x00800000
      89  #define CF_no_paragraph			0x01000000
      90  /* a user-defined command that is referenced to by another command,
      91     which should keep its place in the user_defined_command_data table */
      92  #define CF_REGISTERED		        0x02000000
      93  #define CF_nobrace			0x04000000
      94  /* blockitem commands have a possible content before an item */
      95  #define CF_blockitem			0x08000000
      96  /* used for REGISTERED commands before they have been set to something */
      97  #define CF_UNKNOWN		        0x10000000
      98  #define CF_MACRO 			0x20000000
      99  #define CF_index_entry_command  	0x40000000
     100  /* command that affect the document as a whole and should appear only once */
     101  #define CF_global_unique		0x80000000
     102  
     103  /* NOTE: We often run out of spaces for flags
     104  
     105     Could combine CF_MACRO, CF_ALIAS, and CF_INFOENCLOSE into 2 bits.
     106   */
     107  
     108  /* Types of line command (has CF_line flag).  Values for COMMAND.data. */
     109  #define LINE_lineraw -1
     110  #define LINE_specific -2
     111  #define LINE_text -3
     112  #define LINE_line -4
     113  
     114  /* Types of command without brace nor argument on line (has CF_nobrace flag). */
     115  #define NOBRACE_symbol 0
     116  #define NOBRACE_skipspace -1
     117  #define NOBRACE_other -2
     118  
     119  /* Types of block command (CF_block). */
     120  #define BLOCK_conditional -1
     121  #define BLOCK_raw -2
     122  #define BLOCK_multitable -3
     123  #define BLOCK_region -4
     124  #define BLOCK_item_line -5
     125  /* not used in code but consistent with type in perl hash */
     126  #define BLOCK_item_container -6
     127  /* not used in code but consistent with type in perl hash */
     128  #define BLOCK_quotation -7
     129  #define BLOCK_float -8
     130  #define BLOCK_menu -9
     131  #define BLOCK_format_raw -10
     132  /* not used in code but consistent with type in perl hash */
     133  #define BLOCK_def -11
     134  /* not used in code but consistent with type in perl hash */
     135  #define BLOCK_preformatted -12
     136  /* not used in code but consistent with type in perl hash */
     137  #define BLOCK_math -13
     138  #define BLOCK_other -14
     139  
     140  /* Types of brace command (CF_brace). */
     141  #define BRACE_arguments 1
     142  #define BRACE_noarg 0
     143  #define BRACE_context -1 /* Can enclose paragraph breaks. */
     144  #define BRACE_accent -2
     145  #define BRACE_style_other -3
     146  #define BRACE_style_code -5
     147  #define BRACE_style_no_code -6
     148  #define BRACE_other -7
     149  #define BRACE_special -8
     150  #define BRACE_inline -9
     151  
     152  /* Types of internal commands (CF_internal). */
     153  #define INTERNAL_brace -1
     154  
     155  #endif