|
|
1.1 root 1: /* std2ps.c - stdio-backed abstraction for PStreams */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/psap/RCS/std2ps.c,v 7.0 89/11/23 22:13:45 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/psap/RCS/std2ps.c,v 7.0 89/11/23 22:13:45 mrose Rel $
9: *
10: *
11: * $Log: std2ps.c,v $
12: * Revision 7.0 89/11/23 22:13:45 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: /* LINTLIBRARY */
29:
30: #include <stdio.h>
31: #include "psap.h"
32:
33: /* */
34:
35: /* ARGSUSED */
36:
37: static int std_read (ps, data, n, in_line)
38: PS ps;
39: PElementData data;
40: PElementLen n;
41: int in_line;
42: {
43: int i;
44:
45: if ((i = fread ((char *) data, sizeof *data, (int) n,
46: (FILE *) ps -> ps_addr)) == NOTOK)
47: ps -> ps_errno = PS_ERR_IO;
48:
49: return i;
50: }
51:
52:
53: /* ARGSUSED */
54:
55: static int std_write (ps, data, n, in_line)
56: PS ps;
57: PElementData data;
58: PElementLen n;
59: int in_line;
60: {
61: int i;
62:
63:
64: if ((i = fwrite ((char *) data, sizeof *data, (int) n,
65: (FILE *) ps -> ps_addr)) == NOTOK)
66: ps -> ps_errno = PS_ERR_IO;
67:
68: return i;
69: }
70:
71:
72: static int std_flush (ps)
73: PS ps;
74: {
75: if (fflush ((FILE *) ps -> ps_addr) != EOF)
76: return OK;
77:
78: return ps_seterr (ps, PS_ERR_IO, NOTOK);
79: }
80:
81: /* */
82:
83: int std_open (ps)
84: register PS ps;
85: {
86: ps -> ps_readP = std_read;
87: ps -> ps_writeP = std_write;
88: ps -> ps_flushP = std_flush;
89:
90: return OK;
91: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.