More debianization
[erwise] / Cl / Cl.h
1 /*
2  * Cl.h --
3  *
4  * Author: Teemu Rantanen <tvr@cs.hut.fi>
5  * Copyright (c) 1992 Teemu Rantanen
6  *                    All rights reserved
7  *
8  * Created: Thu Apr 16 21:40:39 1992 tvr
9  * Last modified: Wed May 13 00:11:13 1992 tvr
10  *
11  */
12
13 #include "HTAnchor.h"
14 #include "HTStyle.h"
15 #include "HText.h"
16
17 /*
18  * Data is store on linked list
19  */
20 typedef struct cl_data_s
21 {
22   struct cl_data_s *next;
23   struct cl_data_s *prev;
24   void *data;
25   void *freeptr;
26   int size;
27 }         cl_data_t;
28
29
30 /*
31  * This structure contains all information needed to accomplish this
32  * connection.
33  */
34 typedef struct ClConnection_s
35 {
36   /*
37    * address of this connection
38    */
39   char *address;
40
41   /*
42    * Fd of the connection. Also ftp connection data channel.
43    */
44   int fd;
45   int secondary_fd;
46
47   /*
48    * If this fd is not set connection has to be polled. If it is NOT
49    * set, connection has to be selected (must not poll!)
50    */
51   int select_fd;
52
53   /*
54    * Function of this state machine
55    */
56   void (**function) ();
57
58   /*
59    * Store junk here (address of data on connect() )
60    */
61   void *addr;
62   int addr_size;
63
64   /*
65    * Store command to write to the net here
66    */
67   char *command;
68
69   /*
70    * Data Buffer
71    */
72   cl_data_t *buffer_first;
73   cl_data_t *buffer_last;
74
75   /*
76    * stuff given to HTLoadHTTP()
77    */
78   int diag;
79   struct HTAnchor *anAnchor;
80
81   /*
82    * How happened with load if on nonblocking mode
83    */
84   int status;
85
86   /*
87    * Hostname on ftp connections
88    */
89   char *ftphost;
90
91   /*
92    * Data port on ftp connections
93    */
94   int port;
95
96
97   /*
98    * Load to file ?
99    */
100   int load_to_file;
101   int load_to_file_fd;
102
103 }              ClConnection_t;
104
105
106 /*
107  * More data is to be read
108  */
109 #define CL_CONTINUES            0
110
111 /*
112  * Connection completed
113  */
114 #define CL_COMPLETED            1
115
116 /*
117  * Connection failed
118  */
119 #define CL_FAILED               2
120
121 /*
122  * Document already loaded (error)
123  */
124 #define CL_ALREADY_LOADED       3
125
126
127 /*
128  * Prototypes
129  */
130 ClConnection_t *ClOpenConnection (char *address);
131
132 struct HText *ClReadData (ClConnection_t * connection, int *how_done, int *fd);
133
134 void ClSetOptions (ClConnection_t * connection, int argc, char *argv[]);
135
136 void ClCloseConnection (ClConnection_t * connection);
137
138 int ClCanLoadToFile (char *address);
139
140 void ClSetFileNameForLoadingToFile (char *filename);
141
142 int ClConnectionOnLoadToFileMode (ClConnection_t * connection);
143
144 /*
145  * Globals
146  */
147
148 extern int WWWErwiseStatus;
149 extern ClConnection_t *WWWErwiseConnection;
150
151 void WWWErwiseConnect ();
152 void WWWErwiseSendCommand ();
153 void WWWErwiseReadData ();
154 void WWWErwiseParse ();
155
156
157 /*
158  * Internals
159  */
160
161 void WWWErwiseFtpUser ();
162 void WWWErwiseFtpPass ();
163 void WWWErwiseFtpPassive ();
164 void WWWErwiseFtpGetPassive ();
165 void WWWErwiseFtpGetCommand ();
166 void WWWErwiseFtpDataChannel ();
167 void WWWErwiseFtpCheckForError ();
168 void WWWErwiseFtpBinary ();
169 void WWWErwiseCheckParse ();
170 void WWWErwiseSetPoll ();
171 void WWWErwiseSetSelect ();
172 void WWWErwiseTerminateIfLoadToFile ();
173
174 int cl_start_connection ();
175
176 /*
177  * Debug ...
178  */
179
180 #define CL_DEBUG(a)    printf a