Home | History | Annotate | Download | only in nasm
      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 
      9 #ifndef YASM_NASMLIB_H
     10 #define YASM_NASMLIB_H
     11 
     12 /*
     13  * Wrappers around malloc, realloc and free. nasm_malloc will
     14  * fatal-error and die rather than return NULL; nasm_realloc will
     15  * do likewise, and will also guarantee to work right on being
     16  * passed a NULL pointer; nasm_free will do nothing if it is passed
     17  * a NULL pointer.
     18  */
     19 #define nasm_malloc yasm_xmalloc
     20 #define nasm_realloc yasm_xrealloc
     21 #ifdef WITH_DMALLOC
     22 #define nasm_free(p) do { if (p) yasm_xfree(p); } while(0)
     23 #else
     24 #define nasm_free(p) yasm_xfree(p)
     25 #endif
     26 #define nasm_strdup yasm__xstrdup
     27 #define nasm_strndup yasm__xstrndup
     28 #define nasm_stricmp yasm__strcasecmp
     29 #define nasm_strnicmp yasm__strncasecmp
     30 
     31 /*
     32  * Convert a string into a number, using NASM number rules. Sets
     33  * `*error' to TRUE if an error occurs, and FALSE otherwise.
     34  */
     35 yasm_intnum *nasm_readnum(char *str, int *error);
     36 
     37 /*
     38  * Convert a character constant into a number. Sets
     39  * `*warn' to TRUE if an overflow occurs, and FALSE otherwise.
     40  * str points to and length covers the middle of the string,
     41  * without the quotes.
     42  */
     43 yasm_intnum *nasm_readstrnum(char *str, size_t length, int *warn);
     44 
     45 char *nasm_src_set_fname(char *newname);
     46 char *nasm_src_get_fname(void);
     47 long nasm_src_set_linnum(long newline);
     48 long nasm_src_get_linnum(void);
     49 /*
     50  * src_get may be used if you simply want to know the source file and line.
     51  * It is also used if you maintain private status about the source location
     52  * It return 0 if the information was the same as the last time you
     53  * checked, -1 if the name changed and (new-old) if just the line changed.
     54  */
     55 int nasm_src_get(long *xline, char **xname);
     56 
     57 void nasm_quote(char **str);
     58 char *nasm_strcat(const char *one, const char *two);
     59 
     60 #endif
     61