unp.c

Go to the documentation of this file.
00001 /* $Header: /opt/proj/minix/cvsroot/src/lib/ack/libp/unp.c,v 1.1 2005/10/10 15:27:47 beng Exp $ */
00002 /*
00003  * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
00004  *
00005  *          This product is part of the Amsterdam Compiler Kit.
00006  *
00007  * Permission to use, sell, duplicate or disclose this software must be
00008  * obtained in writing. Requests for such permissions may be sent to
00009  *
00010  *      Dr. Andrew S. Tanenbaum
00011  *      Wiskundig Seminarium
00012  *      Vrije Universiteit
00013  *      Postbox 7161
00014  *      1007 MC Amsterdam
00015  *      The Netherlands
00016  *
00017  */
00018 
00019 /* Author: J.W. Stevenson */
00020 
00021 #include        <pc_err.h>
00022 
00023 extern          _trp();
00024 
00025 #define assert(x)       /* nothing */
00026 
00027 #ifndef EM_WSIZE
00028 #define EM_WSIZE _EM_WSIZE
00029 #endif
00030 
00031 struct descr {
00032         int     low;
00033         int     diff;
00034         int     size;
00035 };
00036 
00037 _unp(ad,zd,i,ap,zp,noext) int i; struct descr *ad,*zd; char *ap,*zp; int noext; {
00038 
00039         if (zd->diff > ad->diff ||
00040                         (i -= ad->low) < 0 ||
00041                         (i+zd->diff) > ad->diff)
00042                 _trp(EUNPACK);
00043         ap += (i * ad->size);
00044         i = (zd->diff + 1) * zd->size;
00045         if (zd->size == 1) {
00046                 int *aptmp = (int *) ap;
00047                 assert(ad->size == EM_WSIZE);
00048                 while (--i >= 0)
00049                         if (noext) *aptmp++ = *zp++ & 0377;
00050                         else *aptmp++ = *zp++;
00051 #if EM_WSIZE > 2
00052         } else if (zd->size == 2) {
00053                 int *aptmp = (int *) ap;
00054                 short *zptmp = (short *) zp;
00055                 assert(ad->size == EM_WSIZE);
00056                 while (--i >= 0)
00057                         if (noext) *aptmp++ = *zptmp++ & 0177777;
00058                         else *aptmp++ = *zptmp++;
00059 #endif
00060         } else {
00061                 assert(ad->size == zd->size);
00062                 while (--i >= 0)
00063                         *ap++ = *zp++;
00064         }
00065 }

Generated on Fri Apr 14 22:57:25 2006 for minix by  doxygen 1.4.6