listing.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* ----------------------------------------------------------------------- *
  2. *
  3. * Copyright 1996-2016 The NASM Authors - All Rights Reserved
  4. * See the file AUTHORS included with the NASM distribution for
  5. * the specific copyright holders.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following
  9. * conditions are met:
  10. *
  11. * * Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * * Redistributions in binary form must reproduce the above
  14. * copyright notice, this list of conditions and the following
  15. * disclaimer in the documentation and/or other materials provided
  16. * with the distribution.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  19. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  20. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  23. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  29. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  30. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * ----------------------------------------------------------------------- */
  33. /*
  34. * listing.h header file for listing.c
  35. */
  36. #ifndef NASM_LISTING_H
  37. #define NASM_LISTING_H
  38. /*
  39. * List-file generators should look like this:
  40. */
  41. struct lfmt {
  42. /*
  43. * Called to initialize the listing file generator. Before this
  44. * is called, the other routines will silently do nothing when
  45. * called. The `char *' parameter is the file name to write the
  46. * listing to.
  47. */
  48. void (*init)(const char *fname);
  49. /*
  50. * Called to clear stuff up and close the listing file.
  51. */
  52. void (*cleanup)(void);
  53. /*
  54. * Called to output binary data. Parameters are: the offset;
  55. * the data; the data type. Data types are similar to the
  56. * output-format interface, only OUT_ADDRESS will _always_ be
  57. * displayed as if it's relocatable, so ensure that any non-
  58. * relocatable address has been converted to OUT_RAWDATA by
  59. * then.
  60. */
  61. void (*output)(const struct out_data *data);
  62. /*
  63. * Called to send a text line to the listing generator. The
  64. * `int' parameter is LIST_READ or LIST_MACRO depending on
  65. * whether the line came directly from an input file or is the
  66. * result of a multi-line macro expansion.
  67. */
  68. void (*line)(int type, char *line);
  69. /*
  70. * Called to change one of the various levelled mechanisms in
  71. * the listing generator. LIST_INCLUDE and LIST_MACRO can be
  72. * used to increase the nesting level of include files and
  73. * macro expansions; LIST_TIMES and LIST_INCBIN switch on the
  74. * two binary-output-suppression mechanisms for large-scale
  75. * pseudo-instructions.
  76. *
  77. * LIST_MACRO_NOLIST is synonymous with LIST_MACRO except that
  78. * it indicates the beginning of the expansion of a `nolist'
  79. * macro, so anything under that level won't be expanded unless
  80. * it includes another file.
  81. */
  82. void (*uplevel)(int type);
  83. /*
  84. * Reverse the effects of uplevel.
  85. */
  86. void (*downlevel)(int type);
  87. /*
  88. * Called on a warning or error, with the error message.
  89. */
  90. void printf_func(2, 3) (*error)(int severity, const char *fmt, ...);
  91. /*
  92. * Update the current offset. Used to give the listing generator
  93. * an offset to work with when doing things like
  94. * uplevel(LIST_TIMES) or uplevel(LIST_INCBIN); see
  95. * list_set_offset();
  96. */
  97. void (*set_offset)(uint64_t offset);
  98. };
  99. extern const struct lfmt *lfmt;
  100. extern bool user_nolist;
  101. #endif