4 /* This file is part of the Project Athena Zephyr Notification System.
5 * It is one of the source files comprising zwgc, the Zephyr WindowGram
8 * Created by: Marc Horowitz <marc@athena.mit.edu>
10 * $Id: port.h,v 1.6 1999/01/22 23:20:32 ghudson Exp $
12 * Copyright (c) 1989 by the Massachusetts Institute of Technology.
13 * For copying and distribution information, see the file
18 #include <zephyr/mit-copyright.h>
21 #include "new_string.h"
22 #include "string_stack.h"
26 FILE *input_connector;
27 FILE *output_connector;
30 string_stack waiting_packets;
38 typedef struct { /* PRIVATE */
41 char *(*close_input)();
42 char *(*close_output)();
43 #define INPUT_CLOSED 0x1
44 #define OUTPUT_CLOSED 0x2
45 #define PORT_CLOSED 0x3
47 union port__data data;
53 * Effects: Closes all existing ports. Must be called before
54 * any other port call is made.
57 extern void init_ports();
60 * string read_from_port(string name)
61 * Requires: init_ports has been called
62 * Modifies: the port named name if any, $error
63 * Effects: If a port by name name does not exist, sets $error to
64 * "No such port" & returns "". Otherwise, attempts to
65 * read from that port. If an error occurs, $error is
66 * set to the error message and "" returned. Otherwise
67 * the read string is returned. The returned string is
68 * on the heap & must be eventually freed.
71 extern string read_from_port();
74 * void write_on_port(string name, char *text, int length)
75 * Requires: init_ports has been called, length>=0
76 * Modifies: the port named name if any, $error
77 * Effects: If a port by name name does not exist, sets $error to
78 * "No such port" & returns. Otherwise, attempts to
79 * write text[0..length-1] on that port. If an error
80 * occurs, $error is set to the error message.
83 extern void write_on_port();
86 * void close_port_input(string name)
87 * Requires: init_ports has been called
88 * Modifies: the port named name if any, $error
89 * Effects: If a port by name name does not exist, sets $error to
90 * "No such port" & returns. Otherwise, closes the
91 * input part of the port by name name. When both a
92 * port's input & output parts have been closed, the
93 * port is deleted to save space. If an error
94 * occurs, $error is set to the error message.
97 extern void close_port_input();
100 * void close_port_output(string name)
101 * Requires: init_ports has been called
102 * Modifies: the port named name if any, $error
103 * Effects: If a port by name name does not exist, sets $error to
104 * "No such port" & returns. Otherwise, closes the
105 * output part of the port by name name. When both a
106 * port's input & output parts have been closed, the
107 * port is deleted to save space. If an error
108 * occurs, $error is set to the error message.
111 extern void close_port_output();
114 extern void create_subprocess_port();
115 extern void create_file_append_port();
116 extern void create_file_input_port();
117 extern void create_file_output_port();
118 extern void create_port_from_filter();
119 extern void create_port_from_output_proc();
121 extern void init_standard_ports();
122 extern void create_port_from_files();