we do need a separate scrollback size and possibly multiple packets

This commit is contained in:
Michael Krayer 2023-10-13 10:51:44 +02:00
parent 821fa0d5ce
commit d50a0e3d72
2 changed files with 21 additions and 4 deletions

View File

@ -104,7 +104,7 @@ static bool server_write_scrollback(Packet *pkt) {
uint32_t ii;
for (ii=0;ii<size;ii++) {
scrollback.buffer[scrollback.position++] = pkt->u.msg[ii];
if (scrollback.position>PACKET_MSG_SIZE) {
if (scrollback.position>SCROLLBACK_SIZE) {
scrollback.position = 0;
scrollback.wrap = true;
}
@ -114,6 +114,23 @@ static bool server_write_scrollback(Packet *pkt) {
static bool server_send_scrollback(Packet *pkt) {
print_packet("server-send-scrollback:", pkt);
ssize_t len, sblen;
uint32_t ii;
if (scrollback.wrap)
sblen = SCROLLBACK_SIZE;
else
sblen = scrollback.position-1;
pkt->type = MSG_CONTENT;
// Multiple packets need to be set possibly: need a double loop
for (ii=0;ii<len;ii++) {
pkt->u.msg[ii] = 1;
}
/* if (len > 0) */
/* pkt->len = len; */
/* else if (len == 0) */
/* server.running = false; */
/* else if (len == -1 && errno != EAGAIN && errno != EINTR && errno != EWOULDBLOCK) */
/* server.running = false; */
// double loop to message size
return true;
}

View File

@ -63,8 +63,8 @@
#define countof(arr) (sizeof(arr) / sizeof((arr)[0]))
#define RV_DETACH -1
/* #define PACKET_MSG_SIZE 4096-2*sizeof(uint32_t) */
#define PACKET_MSG_SIZE 8192-2*sizeof(uint32_t)
#define PACKET_MSG_SIZE 4096-2*sizeof(uint32_t)
#define SCROLLBACK_SIZE 1024
char* splex_session_names = "0123456789";
char* shell_cmd[2] = { "/bin/bash", NULL };
@ -128,7 +128,7 @@ typedef struct {
} Server;
typedef struct {
char buffer[PACKET_MSG_SIZE];
char buffer[SCROLLBACK_SIZE];
uint32_t position;
bool wrap;
} Scrollback;