libyasm/file.h

Go to the documentation of this file.
00001 
00034 #ifndef YASM_FILE_H
00035 #define YASM_FILE_H
00036 
00037 #ifndef YASM_LIB_DECL
00038 #define YASM_LIB_DECL
00039 #endif
00040 
00042 typedef struct yasm_scanner {
00043     unsigned char *bot;     
00044     unsigned char *tok;     
00045     unsigned char *ptr;     
00046     unsigned char *cur;     
00047     unsigned char *lim;     
00048     unsigned char *top;     
00049     unsigned char *eof;     
00050 } yasm_scanner;
00051 
00055 YASM_LIB_DECL
00056 void yasm_scanner_initialize(yasm_scanner *scanner);
00057 
00061 YASM_LIB_DECL
00062 void yasm_scanner_delete(yasm_scanner *scanner);
00063 
00073 YASM_LIB_DECL
00074 int yasm_fill_helper
00075     (yasm_scanner *scanner, unsigned char **cursor,
00076      size_t (*input_func) (void *d, unsigned char *buf, size_t max),
00077      void *input_func_data);
00078 
00088 YASM_LIB_DECL
00089 void yasm_unescape_cstring(unsigned char *str, size_t *len);
00090 
00098 YASM_LIB_DECL
00099 size_t yasm__splitpath_unix(const char *path, /*@out@*/ const char **tail);
00100 
00108 YASM_LIB_DECL
00109 size_t yasm__splitpath_win(const char *path, /*@out@*/ const char **tail);
00110 
00118 #ifndef yasm__splitpath
00119 # if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \
00120  defined (__DJGPP__) || defined (__OS2__) || defined (__CYGWIN__) || \
00121  defined (__CYGWIN32__)
00122 #  define yasm__splitpath(path, tail)   yasm__splitpath_win(path, tail)
00123 # else
00124 #  define yasm__splitpath(path, tail)   yasm__splitpath_unix(path, tail)
00125 # endif
00126 #endif
00127 
00132 YASM_LIB_DECL
00133 /*@only@*/ char *yasm__getcwd(void);
00134 
00140 YASM_LIB_DECL
00141 /*@only@*/ char *yasm__abspath(const char *path);
00142 
00151 YASM_LIB_DECL
00152 char *yasm__combpath_unix(const char *from, const char *to);
00153 
00162 YASM_LIB_DECL
00163 char *yasm__combpath_win(const char *from, const char *to);
00164 
00174 #ifndef yasm__combpath
00175 # if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \
00176  defined (__DJGPP__) || defined (__OS2__) || defined (__CYGWIN__) || \
00177  defined (__CYGWIN32__)
00178 #  define yasm__combpath(from, to)      yasm__combpath_win(from, to)
00179 # else
00180 #  define yasm__combpath(from, to)      yasm__combpath_unix(from, to)
00181 # endif
00182 #endif
00183 
00202 YASM_LIB_DECL
00203 /*@null@*/ FILE *yasm_fopen_include
00204     (const char *iname, const char *from, const char *mode,
00205      /*@null@*/ /*@out@*/ /*@only@*/ char **oname);
00206 
00209 YASM_LIB_DECL
00210 void yasm_delete_include_paths(void);
00211 
00214 YASM_LIB_DECL
00215 const char * yasm_get_include_dir(void **iter);
00216 
00223 YASM_LIB_DECL
00224 void yasm_add_include_path(const char *path);
00225 
00231 #define YASM_WRITE_8(ptr, val)                  \
00232         *((ptr)++) = (unsigned char)((val) & 0xFF)
00233 
00240 #define YASM_WRITE_16_L(ptr, val)               \
00241         do {                                    \
00242             *((ptr)++) = (unsigned char)((val) & 0xFF);         \
00243             *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF);  \
00244         } while (0)
00245 
00252 #define YASM_WRITE_32_L(ptr, val)               \
00253         do {                                    \
00254             *((ptr)++) = (unsigned char)((val) & 0xFF);         \
00255             *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF);  \
00256             *((ptr)++) = (unsigned char)(((val) >> 16) & 0xFF); \
00257             *((ptr)++) = (unsigned char)(((val) >> 24) & 0xFF); \
00258         } while (0)
00259 
00266 #define YASM_WRITE_16_B(ptr, val)               \
00267         do {                                    \
00268             *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF);  \
00269             *((ptr)++) = (unsigned char)((val) & 0xFF);         \
00270         } while (0)
00271 
00278 #define YASM_WRITE_32_B(ptr, val)               \
00279         do {                                    \
00280             *((ptr)++) = (unsigned char)(((val) >> 24) & 0xFF); \
00281             *((ptr)++) = (unsigned char)(((val) >> 16) & 0xFF); \
00282             *((ptr)++) = (unsigned char)(((val) >> 8) & 0xFF);  \
00283             *((ptr)++) = (unsigned char)((val) & 0xFF);         \
00284         } while (0)
00285 
00286 
00292 #define YASM_SAVE_8(ptr, val)                   \
00293         *(ptr) = (unsigned char)((val) & 0xFF)
00294 
00301 #define YASM_SAVE_16_L(ptr, val)                \
00302         do {                                    \
00303             *(ptr) = (unsigned char)((val) & 0xFF);             \
00304             *((ptr)+1) = (unsigned char)(((val) >> 8) & 0xFF);  \
00305         } while (0)
00306 
00313 #define YASM_SAVE_32_L(ptr, val)                \
00314         do {                                    \
00315             *(ptr) = (unsigned char)((val) & 0xFF);             \
00316             *((ptr)+1) = (unsigned char)(((val) >> 8) & 0xFF);  \
00317             *((ptr)+2) = (unsigned char)(((val) >> 16) & 0xFF); \
00318             *((ptr)+3) = (unsigned char)(((val) >> 24) & 0xFF); \
00319         } while (0)
00320 
00327 #define YASM_SAVE_16_B(ptr, val)                \
00328         do {                                    \
00329             *(ptr) = (unsigned char)(((val) >> 8) & 0xFF);      \
00330             *((ptr)+1) = (unsigned char)((val) & 0xFF);         \
00331         } while (0)
00332 
00339 #define YASM_SAVE_32_B(ptr, val)                \
00340         do {                                    \
00341             *(ptr) = (unsigned char)(((val) >> 24) & 0xFF);     \
00342             *((ptr)+1) = (unsigned char)(((val) >> 16) & 0xFF); \
00343             *((ptr)+2) = (unsigned char)(((val) >> 8) & 0xFF);  \
00344             *((ptr)+3) = (unsigned char)((val) & 0xFF);         \
00345         } while (0)
00346 
00354 YASM_LIB_DECL
00355 size_t yasm_fwrite_16_l(unsigned short val, FILE *f);
00356 
00364 YASM_LIB_DECL
00365 size_t yasm_fwrite_32_l(unsigned long val, FILE *f);
00366 
00374 YASM_LIB_DECL
00375 size_t yasm_fwrite_16_b(unsigned short val, FILE *f);
00376 
00384 YASM_LIB_DECL
00385 size_t yasm_fwrite_32_b(unsigned long val, FILE *f);
00386 
00392 #define YASM_READ_8(val, ptr)                   \
00393         (val) = *((ptr)++) & 0xFF
00394 
00401 #define YASM_READ_16_L(val, ptr)                \
00402         do {                                    \
00403             (val) = *((ptr)++) & 0xFF;          \
00404             (val) |= (*((ptr)++) & 0xFF) << 8;  \
00405         } while (0)
00406 
00413 #define YASM_READ_32_L(val, ptr)                \
00414         do {                                    \
00415             (val) = *((ptr)++) & 0xFF;          \
00416             (val) |= (*((ptr)++) & 0xFF) << 8;  \
00417             (val) |= (*((ptr)++) & 0xFF) << 16; \
00418             (val) |= (*((ptr)++) & 0xFF) << 24; \
00419         } while (0)
00420 
00427 #define YASM_READ_16_B(val, ptr)                \
00428         do {                                    \
00429             (val) = (*((ptr)++) & 0xFF) << 8;   \
00430             (val) |= *((ptr)++) & 0xFF;         \
00431         } while (0)
00432 
00439 #define YASM_READ_32_B(val, ptr)                \
00440         do {                                    \
00441             (val) = (*((ptr)++) & 0xFF) << 24;  \
00442             (val) |= (*((ptr)++) & 0xFF) << 16; \
00443             (val) |= (*((ptr)++) & 0xFF) << 8;  \
00444             (val) |= *((ptr)++) & 0xFF;         \
00445         } while (0)
00446 
00452 #define YASM_LOAD_8(val, ptr)                   \
00453         (val) = *(ptr) & 0xFF
00454 
00461 #define YASM_LOAD_16_L(val, ptr)                \
00462         do {                                    \
00463             (val) = *(ptr) & 0xFF;              \
00464             (val) |= (*((ptr)+1) & 0xFF) << 8;  \
00465         } while (0)
00466 
00473 #define YASM_LOAD_32_L(val, ptr)                \
00474         do {                                    \
00475             (val) = (unsigned long)(*(ptr) & 0xFF);                 \
00476             (val) |= (unsigned long)((*((ptr)+1) & 0xFF) << 8);     \
00477             (val) |= (unsigned long)((*((ptr)+2) & 0xFF) << 16);    \
00478             (val) |= (unsigned long)((*((ptr)+3) & 0xFF) << 24);    \
00479         } while (0)
00480 
00487 #define YASM_LOAD_16_B(val, ptr)                \
00488         do {                                    \
00489             (val) = (*(ptr) & 0xFF) << 8;       \
00490             (val) |= *((ptr)+1) & 0xFF;         \
00491         } while (0)
00492 
00499 #define YASM_LOAD_32_B(val, ptr)                \
00500         do {                                    \
00501             (val) = (unsigned long)((*(ptr) & 0xFF) << 24);         \
00502             (val) |= (unsigned long)((*((ptr)+1) & 0xFF) << 16);    \
00503             (val) |= (unsigned long)((*((ptr)+2) & 0xFF) << 8);     \
00504             (val) |= (unsigned long)(*((ptr)+3) & 0xFF);            \
00505         } while (0)
00506 
00507 #endif

Generated on Fri Jul 25 01:23:32 2008 for libyasm by  doxygen 1.5.2