Download
jcs
/subtext
/binkp.h
(View History)
jcs binkp: Move polling out of here, tweak some log messages | Latest amendment: 417 on 2023-03-15 |
1 | /* |
2 | * Copyright (c) 2023 joshua stein <jcs@jcs.org> |
3 | * |
4 | * Permission to use, copy, modify, and distribute this software for any |
5 | * purpose with or without fee is hereby granted, provided that the above |
6 | * copyright notice and this permission notice appear in all copies. |
7 | * |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
15 | */ |
16 | |
17 | #ifndef __BINKP_H__ |
18 | #define __BINKP_H__ |
19 | |
20 | #include "tcp.h" |
21 | #include "uthread.h" |
22 | #include "util.h" |
23 | |
24 | struct binkp_frame { |
25 | u_int16_t data_size; |
26 | char command_id; |
27 | #define BINKP_DATA -1 |
28 | #define BINKP_COMMAND_M_NUL 0 |
29 | #define BINKP_COMMAND_M_ADR 1 |
30 | #define BINKP_COMMAND_M_PWD 2 |
31 | #define BINKP_COMMAND_M_FILE 3 |
32 | #define BINKP_COMMAND_M_OK 4 |
33 | #define BINKP_COMMAND_M_EOB 5 |
34 | #define BINKP_COMMAND_M_GOT 6 |
35 | #define BINKP_COMMAND_M_ERR 7 |
36 | #define BINKP_COMMAND_M_BSY 8 |
37 | #define BINKP_COMMAND_M_GET 9 |
38 | #define BINKP_COMMAND_M_SKIP 10 |
39 | |
40 | char type; |
41 | #define BINKP_TYPE_DATA 0x0 |
42 | #define BINKP_TYPE_COMMAND 0x1 |
43 | }; |
44 | |
45 | struct binkp_file { |
46 | char filename[64]; |
47 | size_t size; |
48 | unsigned long mtime; |
49 | size_t data_read; |
50 | Str255 pfilename; |
51 | short frefnum; |
52 | }; |
53 | |
54 | struct binkp_connection { |
55 | TCPiopb tcp_send_iopb; |
56 | TCPiopb tcp_read_iopb; |
57 | StreamPtr tcp_stream; |
58 | unsigned char *tcp_buf; |
59 | size_t tcp_buf_size; |
60 | wdsEntry tcp_wds[2]; |
61 | TCPStatusPB tcp_status_pb; |
62 | |
63 | char *buf; |
64 | size_t buf_size; |
65 | struct binkp_frame cur_frame; |
66 | struct binkp_file cur_incoming_file; |
67 | bool done_receiving; |
68 | bool done_sending; |
69 | }; |
70 | |
71 | extern bool binkp_ready; |
72 | extern time_t binkp_next_poll; |
73 | |
74 | void binkp_init(void); |
75 | void binkp_atexit(void); |
76 | void binkp_poll(void); |
77 | bool binkp_scan_message(struct fidopkt_message *msg); |
78 | bool binkp_packets_in_outbox(void); |
79 | |
80 | #endif |