source: trunk/minix/lib/ack/libp/unp.c@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.4 KB
RevLine 
[9]1/* $Header: /cvsup/minix/src/lib/ack/libp/unp.c,v 1.1 2005/10/10 15:27:47 beng Exp $ */
2/*
3 * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 *
5 * This product is part of the Amsterdam Compiler Kit.
6 *
7 * Permission to use, sell, duplicate or disclose this software must be
8 * obtained in writing. Requests for such permissions may be sent to
9 *
10 * Dr. Andrew S. Tanenbaum
11 * Wiskundig Seminarium
12 * Vrije Universiteit
13 * Postbox 7161
14 * 1007 MC Amsterdam
15 * The Netherlands
16 *
17 */
18
19/* Author: J.W. Stevenson */
20
21#include <pc_err.h>
22
23extern _trp();
24
25#define assert(x) /* nothing */
26
27#ifndef EM_WSIZE
28#define EM_WSIZE _EM_WSIZE
29#endif
30
31struct descr {
32 int low;
33 int diff;
34 int size;
35};
36
37_unp(ad,zd,i,ap,zp,noext) int i; struct descr *ad,*zd; char *ap,*zp; int noext; {
38
39 if (zd->diff > ad->diff ||
40 (i -= ad->low) < 0 ||
41 (i+zd->diff) > ad->diff)
42 _trp(EUNPACK);
43 ap += (i * ad->size);
44 i = (zd->diff + 1) * zd->size;
45 if (zd->size == 1) {
46 int *aptmp = (int *) ap;
47 assert(ad->size == EM_WSIZE);
48 while (--i >= 0)
49 if (noext) *aptmp++ = *zp++ & 0377;
50 else *aptmp++ = *zp++;
51#if EM_WSIZE > 2
52 } else if (zd->size == 2) {
53 int *aptmp = (int *) ap;
54 short *zptmp = (short *) zp;
55 assert(ad->size == EM_WSIZE);
56 while (--i >= 0)
57 if (noext) *aptmp++ = *zptmp++ & 0177777;
58 else *aptmp++ = *zptmp++;
59#endif
60 } else {
61 assert(ad->size == zd->size);
62 while (--i >= 0)
63 *ap++ = *zp++;
64 }
65}
Note: See TracBrowser for help on using the repository browser.