info-utils.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* info-utils.h -- Exported functions and variables from info-utils.c.
  2. $Id$
  3. Copyright 1993, 1996, 1998, 2002, 2003, 2004, 2007, 2011, 2012, 2013,
  4. 2014, 2015, 2016 Free Software Foundation, Inc.
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. Originally written by Brian Fox. */
  16. #ifndef INFO_UTILS_H
  17. #define INFO_UTILS_H
  18. #include "nodes.h"
  19. #include "window.h"
  20. #include "search.h"
  21. #if HAVE_ICONV
  22. # include <iconv.h>
  23. #endif
  24. /* Variable which holds the most recent filename parsed as a result of
  25. calling info_parse_xxx (). */
  26. extern char *info_parsed_filename;
  27. /* Variable which holds the most recent nodename parsed as a result of
  28. calling info_parse_xxx (). */
  29. extern char *info_parsed_nodename;
  30. /* Parse the filename and nodename out of STRING. */
  31. void info_parse_node (char *string);
  32. long read_quoted_string (char *start, char *terminator, int lines,
  33. char **output);
  34. void scan_node_contents (NODE *node, FILE_BUFFER *fb, TAG **tag_ptr);
  35. /* Get the menu entry associated with LABEL in NODE. Return a
  36. pointer to the reference if found, or NULL. If SLOPPY, accept
  37. initial substrings and check insensitively to case. */
  38. REFERENCE *info_get_menu_entry_by_label (NODE *node, char *label,
  39. int sloppy);
  40. /* A utility function for concatenating REFERENCE **. Returns a new
  41. REFERENCE ** which is the concatenation of REF1 and REF2. The REF1
  42. and REF2 arrays are freed, but their contents are not. */
  43. REFERENCE **info_concatenate_references (REFERENCE **ref1, REFERENCE **ref2);
  44. /* Copy an existing reference into new memory. */
  45. REFERENCE *info_copy_reference (REFERENCE *src);
  46. /* Copy a list of existing references into new memory. */
  47. REFERENCE **info_copy_references (REFERENCE **ref1);
  48. /* Free the data associated with a single REF */
  49. void info_reference_free (REFERENCE *ref);
  50. /* Free the data associated with REFERENCES. */
  51. void info_free_references (REFERENCE **references);
  52. /* Create new REFERENCE structure. */
  53. REFERENCE *info_new_reference (char *filename, char *nodename);
  54. /* Search for sequences of whitespace or newlines in STRING, replacing
  55. all such sequences with just a single space. Remove whitespace from
  56. start and end of string. */
  57. void canonicalize_whitespace (char *string);
  58. /* Used with multibyte iterator mbi_iterator_t. */
  59. #define ITER_SETBYTES(iter,n) ((iter).cur.bytes = n)
  60. #define ITER_LIMIT(iter) ((iter).limit - (iter).cur.ptr)
  61. int ansi_escape (mbi_iterator_t iter, size_t *plen);
  62. /* Return a pointer to a string which is the printed representation
  63. of CHARACTER if it were printed at HPOS. */
  64. char *printed_representation (mbi_iterator_t *iter,
  65. int *delim, size_t pl_chars,
  66. size_t *pchars, size_t *pbytes);
  67. FILE_BUFFER *file_buffer_of_window (WINDOW *window);
  68. char *node_printed_rep (NODE *node);
  69. /* Return a pointer to the part of PATHNAME that simply defines the file. */
  70. char *filename_non_directory (char *pathname);
  71. /* Return non-zero if NODE is one especially created by Info. */
  72. int internal_info_node_p (NODE *node);
  73. /* Make NODE appear to be one especially created by Info, and give it NAME. */
  74. void name_internal_node (NODE *node, char *name);
  75. /* Return the window displaying NAME, the name of an internally created
  76. Info window. */
  77. WINDOW *get_internal_info_window (char *name);
  78. struct text_buffer
  79. {
  80. char *base;
  81. size_t size;
  82. size_t off;
  83. };
  84. #define MIN_TEXT_BUF_ALLOC 512
  85. void text_buffer_init (struct text_buffer *buf);
  86. void text_buffer_free (struct text_buffer *buf);
  87. void text_buffer_alloc (struct text_buffer *buf, size_t len);
  88. size_t text_buffer_vprintf (struct text_buffer *buf, const char *format,
  89. va_list ap);
  90. size_t text_buffer_space_left (struct text_buffer *buf);
  91. #if HAVE_ICONV
  92. size_t text_buffer_iconv (struct text_buffer *buf, iconv_t iconv_state,
  93. ICONV_CONST char **inbuf, size_t *inbytesleft);
  94. #endif
  95. size_t text_buffer_add_string (struct text_buffer *buf, const char *str,
  96. size_t len);
  97. size_t text_buffer_fill (struct text_buffer *buf, int c, size_t len);
  98. void text_buffer_add_char (struct text_buffer *buf, int c);
  99. size_t text_buffer_printf (struct text_buffer *buf, const char *format, ...);
  100. #define text_buffer_reset(buf) ((buf)->off = 0)
  101. #define text_buffer_base(buf) ((buf)->base)
  102. #define text_buffer_off(buf) ((buf)->off)
  103. struct info_namelist_entry;
  104. int info_namelist_add (struct info_namelist_entry **ptop, const char *name);
  105. void info_namelist_free (struct info_namelist_entry *top);
  106. #if defined(__MSDOS__) || defined(__MINGW32__)
  107. int fncmp (const char *fn1, const char *fn2);
  108. #else
  109. # define fncmp(s,t) strcmp(s,t)
  110. #endif
  111. #endif /* not INFO_UTILS_H */