home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / stex2-18.zip / SeeTeX / Xtex / mio.h < prev    next >
Text File  |  1991-02-21  |  2KB  |  93 lines

  1. /*
  2.  * Copyright 1989 Dirk Grunwald
  3.  * 
  4.  * Permission to use, copy, modify, distribute, and sell this software
  5.  * and its documentation for any purpose is hereby granted without fee,
  6.  * provided that the above copyright notice appear in all copies and that
  7.  * both that copyright notice and this permission notice appear in
  8.  * supporting documentation, and that the name of Dirk Grunwald or M.I.T.
  9.  * not be used in advertising or publicity pertaining to distribution of
  10.  * the software without specific, written prior permission.  Dirk
  11.  * Grunwald and M.I.T. makes no representations about the suitability of
  12.  * this software for any purpose.  It is provided "as is" without express
  13.  * or implied warranty.
  14.  * 
  15.  * DIRK GRUNWALD AND M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  16.  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  17.  * FITNESS, IN NO EVENT SHALL M.I.T.  BE LIABLE FOR ANY SPECIAL, INDIRECT
  18.  * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  19.  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  20.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  21.  * OR PERFORMANCE OF THIS SOFTWARE.
  22.  * 
  23.  * Author:
  24.  *     Dr. Dirk Grunwald
  25.  *     Dept. of Computer Science
  26.  *     Campus Box 430
  27.  *     Univ. of Colorado, Boulder
  28.  *     Boulder, CO 80309
  29.  * 
  30.  *     grunwald@colorado.edu
  31.  *     
  32.  */ 
  33.  
  34. /*
  35.  * Memory I/O: numbers.
  36.  *
  37.  */
  38.  
  39. #if defined(__GNUC__)  && defined(__STDC__)
  40.  
  41. static 
  42. inline int mGetByte(char **m)
  43. {
  44.     unsigned char foo = **m;
  45.     unsigned int retval = foo & 0xff;
  46.     (*m)++;
  47.     return retval;
  48. }
  49.  
  50. static 
  51. inline void mGetWord( char **m, i32 *r)
  52. {
  53.     int x = mGetByte( m ) << 8;
  54.     x |= mGetByte(m); 
  55.     *r = x;
  56. }
  57.  
  58. static 
  59. inline void mGet3Byte( char **m, i32 *r)
  60. {
  61.     long x = mGetByte( m ) << 16;
  62.     x |= ( mGetByte(m ) << 8 ); 
  63.     x |= mGetByte(m);
  64.     *r = x;
  65. }
  66.  
  67. static 
  68. inline void mGetLong( char **m, i32 *r)
  69. {
  70.     long x = mGetByte( m ) << 24;
  71.     x |= ( mGetByte(m) << 16 ); 
  72.     x |= ( mGetByte(m) << 8 ); 
  73.     x |= mGetByte(m); 
  74.     *r = x;
  75. }
  76.  
  77. #else
  78.  
  79. #define    mGetByte(m)    ( *((*m)++) & 0xff )
  80.  
  81. #define mGetWord(m, r)    {*(r)  = mGetByte(m) << 8;  *(r) |= mGetByte(m);}
  82.  
  83. #define mGet3Byte(m,r) {*(r)  = mGetByte(m) << 16;\
  84.              *(r) |= mGetByte(m) << 8;\
  85.              *(r) |= mGetByte(m);}
  86.  
  87. #define mGetLong(m, r)    {*(r)  = mGetByte(m) << 24;\
  88.              *(r) |= mGetByte(m) << 16;\
  89.              *(r) |= mGetByte(m) << 8;\
  90.              *(r) |= mGetByte(m);}
  91.  
  92. #endif
  93.