home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / ixemul-39.47-env-bin.lha / include / packets.h < prev    next >
C/C++ Source or Header  |  1994-07-08  |  3KB  |  73 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *  Portions Copyright (C) 1994 Rafael W. Luebbert
  5.  *
  6.  *  This library is free software; you can redistribute it and/or
  7.  *  modify it under the terms of the GNU Library General Public
  8.  *  License as published by the Free Software Foundation; either
  9.  *  version 2 of the License, or (at your option) any later version.
  10.  *
  11.  *  This library is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.  *  Library General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU Library General Public
  17.  *  License along with this library; if not, write to the Free
  18.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef _PACKETS_H
  22. #define _PACKETS_H
  23.  
  24. #define PutPacket(port,pack) PutMsg((port), (struct Message *)(pack))
  25.  
  26. #define GetPacket(port) ((struct StandardPacket *)GetMsg(port))
  27.  
  28. /***************************************************************************/
  29.  
  30. #define LastResult(f) ((f)->f_sp.sp_Pkt.dp_Res1)
  31.  
  32. #define LastError(f) ((f)->f_sp.sp_Pkt.dp_Res2)
  33.  
  34. /***************************************************************************/
  35.  
  36. #define SendPacket0(fp,port,act) \
  37.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  38.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  39.  
  40. #define SendPacket1(fp,port,act,arg1) \
  41.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  42.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), \
  43.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  44.  
  45. #define SendPacket2(fp,port,act,arg1,arg2) \
  46.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  47.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  48.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  49.  
  50. #define SendPacket3(fp,port,act,arg1,arg2,arg3) \
  51.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  52.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  53.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), \
  54.   PutPacket((fp)->f_fh->fh_Type, &((fp)->f_sp)))
  55.  
  56. #define SendPacket4(fp,port,act,arg1,arg2,arg3,arg4) \
  57.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  58.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  59.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), (fp)->f_sp.sp_Pkt.dp_Arg4 = (arg4), \
  60.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  61.  
  62. /***************************************************************************/
  63.  
  64. #define HANDLER_NIL(fp) (!(fp)->f_fh->fh_Type)
  65.  
  66. #define CTOBPTR(ptr) (((long)(ptr)) >> 2)
  67. #define BTOCPTR(ptr) ((void *)((ptr) << 2))
  68.  
  69. /* this version only works for word-aligned data as you get it from alloca()! */
  70. #define LONG_ALIGN(ptr) ((void *)((((long)(ptr))&3)?((long)ptr)+2:(long)ptr))
  71.  
  72. #endif /* _PACKETS_H */
  73.