Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / pcc / dist / pcc-libs / libI77 / due.c
blob1c65e687e7e18bbde5e254cd2dace77b113d7c5f
1 /* $Id: due.c,v 1.1.1.1 2008/08/24 05:34:47 gmcgarry Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * Redistributions of source code and documentation must retain the above
10 * copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditionsand the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed or owned by Caldera
17 * International, Inc.
18 * Neither the name of Caldera International, Inc. nor the names of other
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
22 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27 * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 #include "fio.h"
37 int
38 s_rdue(cilist *a)
40 int n;
41 if((n=c_due(a,READ))) return(n);
42 reading=1;
43 if(curunit->uwrt) nowreading(curunit);
44 return(0);
47 int
48 s_wdue(cilist *a)
50 int n;
51 if((n=c_due(a,WRITE))) return(n);
52 reading=0;
53 if(!curunit->uwrt) nowwriting(curunit);
54 return(0);
57 int
58 c_due(cilist *a, int flag)
60 if(!init) f_init();
61 if(a->ciunit>=MXUNIT || a->ciunit<0)
62 err(a->cierr,101,"startio");
63 recpos=sequential=formatted=0;
64 external=1;
65 curunit = &units[a->ciunit];
66 elist=a;
67 if(curunit->ufd==NULL && fk_open(flag,DIR,UNF,a->ciunit) ) err(a->cierr,104,"due");
68 cf=curunit->ufd;
69 if(curunit->ufmt) err(a->cierr,102,"cdue")
70 if(!curunit->useek) err(a->cierr,104,"cdue")
71 if(curunit->ufd==NULL) err(a->cierr,114,"cdue")
72 fseek(cf,(long)(a->cirec-1)*curunit->url,0);
73 curunit->uend = 0;
74 return(0);
77 int
78 e_rdue()
80 if(curunit->url==1 || recpos==curunit->url)
81 return(0);
82 fseek(cf,(long)(curunit->url-recpos),1);
83 if(ftell(cf)%curunit->url)
84 err(elist->cierr,200,"syserr");
85 return(0);
88 int
89 e_wdue()
91 return(e_rdue());