nasmlib.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* nasmlib.h header file for nasmlib.c
  2. *
  3. * The Netwide Assembler is copyright (C) 1996 Simon Tatham and
  4. * Julian Hall. All rights reserved. The software is
  5. * redistributable under the licence given in the file "Licence"
  6. * distributed in the NASM archive.
  7. */
  8. #ifndef YASM_NASMLIB_H
  9. #define YASM_NASMLIB_H
  10. /*
  11. * Wrappers around malloc, realloc and free. nasm_malloc will
  12. * fatal-error and die rather than return NULL; nasm_realloc will
  13. * do likewise, and will also guarantee to work right on being
  14. * passed a NULL pointer; nasm_free will do nothing if it is passed
  15. * a NULL pointer.
  16. */
  17. #define nasm_malloc yasm_xmalloc
  18. #define nasm_realloc yasm_xrealloc
  19. #ifdef WITH_DMALLOC
  20. #define nasm_free(p) do { if (p) yasm_xfree(p); } while(0)
  21. #else
  22. #define nasm_free(p) yasm_xfree(p)
  23. #endif
  24. #define nasm_strdup yasm__xstrdup
  25. #define nasm_strndup yasm__xstrndup
  26. #define nasm_stricmp yasm__strcasecmp
  27. #define nasm_strnicmp yasm__strncasecmp
  28. /*
  29. * Convert a string into a number, using NASM number rules. Sets
  30. * `*error' to TRUE if an error occurs, and FALSE otherwise.
  31. */
  32. yasm_intnum *nasm_readnum(char *str, int *error);
  33. /*
  34. * Convert a character constant into a number. Sets
  35. * `*warn' to TRUE if an overflow occurs, and FALSE otherwise.
  36. * str points to and length covers the middle of the string,
  37. * without the quotes.
  38. */
  39. yasm_intnum *nasm_readstrnum(char *str, size_t length, int *warn);
  40. char *nasm_src_set_fname(char *newname);
  41. char *nasm_src_get_fname(void);
  42. long nasm_src_set_linnum(long newline);
  43. long nasm_src_get_linnum(void);
  44. /*
  45. * src_get may be used if you simply want to know the source file and line.
  46. * It is also used if you maintain private status about the source location
  47. * It return 0 if the information was the same as the last time you
  48. * checked, -1 if the name changed and (new-old) if just the line changed.
  49. */
  50. int nasm_src_get(long *xline, char **xname);
  51. void nasm_quote(char **str);
  52. char *nasm_strcat(const char *one, const char *two);
  53. #endif