/* * Copyright (c) 2021-2022 joshua stein * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __BROWSER_H__ #define __BROWSER_H__ #include #include "tcp.h" #include "util.h" enum { REQ_STATE_IDLE, REQ_STATE_CONNECTED, REQ_STATE_DISCONNECTED }; enum { GEM_STATE_HEADER, GEM_STATE_GEMTEXT, GEM_STATE_REDIRECT, GEM_STATE_DOWNLOAD }; #define STYLE_NONE 0 #define STYLE_BOLD (1UL << 0) #define STYLE_ITALIC (1UL << 1) #define STYLE_H1 (1UL << 2) #define STYLE_H2 (1UL << 3) #define STYLE_H3 (1UL << 4) #define STYLE_LINK (1UL << 5) #define STYLE_PRE (1UL << 6) #define STYLE_LIST (1UL << 7) #define STYLE_QUOTE (1UL << 8) struct client_link { char *link; char *title; unsigned short pos; unsigned short len; }; struct tcp_request { short tls_id; unsigned char tcp_buf[(4 * 1500) + 2048]; /* 4*MTU + tcp_input */ unsigned char tcp_input[2048]; size_t tcp_input_len; short state; char hostname[256]; ip_addr host_ip; unsigned short port; TCPiopb tcp_iopb; StreamPtr tcp_stream; wdsEntry tcp_wds[2]; TCPStatusPB tcp_status_pb; char uri[1024 + 2]; size_t uri_len; short gem_state; char input[1024]; size_t input_len; char mime_type[64]; unsigned long style; size_t links_count; size_t links_size; struct client_link *links; }; struct client { WindowPtr win; TEHandle uri_te; ControlHandle go_button; TEHandle output_te; ControlHandle output_te_scroller; Handle scrp_rec_h; #define CLIENT_SCRAP_ELEMENTS 20 TEHandle active_te; struct tcp_request *req; unsigned char scsi_buf[2048]; }; struct client * client_init(void); size_t client_print(struct client *client, const char *str, size_t len); void client_clear(struct client *client); #endif