Commit 030c7cf9 authored by Deucе's avatar Deucе 👌🏾
Browse files

I can't stand it anymore.

Run uncrustify on this mess.
There's a few small oddities (especially in enums), but this is
much better.
parent 652a3561
Pipeline #3505 passed with stage
in 5 minutes and 46 seconds
......@@ -9,27 +9,28 @@ enum fonttype {
};
struct StandardFontEntry {
char name[256];
uint16_t height;
uint8_t style;
uint8_t flags;
char name[256];
uint16_t height;
uint8_t style;
uint8_t flags;
};
struct TaggedFontEntry {
char name[254];
uint16_t tags;
uint16_t height;
uint8_t style;
uint8_t flags;
char name[254];
uint16_t tags;
uint16_t height;
uint8_t style;
uint8_t flags;
};
struct FontContentsHeader {
uint16_t type;
uint16_t count;
uint16_t type;
uint16_t count;
};
struct FontList {
struct FontContentsHeader header;
union {
struct StandardFontEntry std;
struct StandardFontEntry tag;
......@@ -37,39 +38,39 @@ struct FontList {
};
#if defined(_WIN32) || defined(__BORLANDC__)
#define PRAGMA_PACK
#define PRAGMA_PACK
#endif
#if defined(PRAGMA_PACK) || defined(__WATCOMC__)
#define _PACK
#define _PACK
#else
#define _PACK __attribute__ ((packed))
#define _PACK __attribute__((packed))
#endif
#if defined(PRAGMA_PACK)
#pragma pack(push,1) /* Disk image structures must be packed */
#pragma pack(push,1) /* Disk image structures must be packed */
#endif
struct _PACK FontHeader {
uint8_t ignore[0x6E];
uint16_t height;
uint8_t style;
uint8_t flags;
uint16_t xsize;
uint16_t baseline; // Distance from top to baseline
uint16_t boldsmear;
uint16_t rc; // Literally a reference count on disk.
uint8_t first;
uint8_t last;
uint32_t dataOffset;
uint16_t modulo;
uint32_t charlocOffset;
uint32_t fontSpaceOffset;
uint32_t kernOffset;
uint8_t ignore[0x6E];
uint16_t height;
uint8_t style;
uint8_t flags;
uint16_t xsize;
uint16_t baseline; // Distance from top to baseline
uint16_t boldsmear;
uint16_t rc; // Literally a reference count on disk.
uint8_t first;
uint8_t last;
uint32_t dataOffset;
uint16_t modulo;
uint32_t charlocOffset;
uint32_t fontSpaceOffset;
uint32_t kernOffset;
};
#if defined(PRAGMA_PACK)
#pragma pack(pop) /* original packing */
#pragma pack(pop) /* original packing */
#endif
#endif
#endif // ifndef AMIGAFONT_H
This diff is collapsed.
......@@ -6,126 +6,159 @@
#define _BBSLIST_H_
#include <stdbool.h>
#include <stdio.h> /* FILE * */
#include <stdio.h> /* FILE * */
#include <time.h>
#include "dirwrap.h" /* MAX_PATH */
#include "gen_defs.h"
#include "dirwrap.h" /* MAX_PATH */
#include "ini_file.h"
#include <time.h>
#if defined(_WIN32)
#include <malloc.h> /* alloca() on Win32 */
#include <malloc.h> /* alloca() on Win32 */
#endif
#include <cterm.h>
#define LIST_NAME_MAX 30
#define LIST_ADDR_MAX 64
#define MAX_USER_LEN 30
#define MAX_PASSWD_LEN 128
#define LIST_NAME_MAX 30
#define LIST_ADDR_MAX 64
#define MAX_USER_LEN 30
#define MAX_PASSWD_LEN 128
#define MAX_SYSPASS_LEN 128
enum {
USER_BBSLIST
,SYSTEM_BBSLIST
USER_BBSLIST
,
SYSTEM_BBSLIST
};
enum {
BBSLIST_SELECT
,BBSLIST_EDIT
BBSLIST_SELECT
,
BBSLIST_EDIT
};
enum {
SCREEN_MODE_CURRENT
,SCREEN_MODE_80X25
,SCREEN_MODE_LCD80X25
,SCREEN_MODE_80X28
,SCREEN_MODE_80X30
,SCREEN_MODE_80X43
,SCREEN_MODE_80X50
,SCREEN_MODE_80X60
,SCREEN_MODE_132X37
,SCREEN_MODE_132x52
,SCREEN_MODE_132X25
,SCREEN_MODE_132X28
,SCREEN_MODE_132X30
,SCREEN_MODE_132X34
,SCREEN_MODE_132X43
,SCREEN_MODE_132X50
,SCREEN_MODE_132X60
,SCREEN_MODE_C64
,SCREEN_MODE_C128_40
,SCREEN_MODE_C128_80
,SCREEN_MODE_ATARI
,SCREEN_MODE_ATARI_XEP80
,SCREEN_MODE_CUSTOM
,SCREEN_MODE_EGA_80X25
,SCREEN_MODE_VGA_80X25
,SCREEN_MODE_TERMINATOR
SCREEN_MODE_CURRENT
,
SCREEN_MODE_80X25
,
SCREEN_MODE_LCD80X25
,
SCREEN_MODE_80X28
,
SCREEN_MODE_80X30
,
SCREEN_MODE_80X43
,
SCREEN_MODE_80X50
,
SCREEN_MODE_80X60
,
SCREEN_MODE_132X37
,
SCREEN_MODE_132x52
,
SCREEN_MODE_132X25
,
SCREEN_MODE_132X28
,
SCREEN_MODE_132X30
,
SCREEN_MODE_132X34
,
SCREEN_MODE_132X43
,
SCREEN_MODE_132X50
,
SCREEN_MODE_132X60
,
SCREEN_MODE_C64
,
SCREEN_MODE_C128_40
,
SCREEN_MODE_C128_80
,
SCREEN_MODE_ATARI
,
SCREEN_MODE_ATARI_XEP80
,
SCREEN_MODE_CUSTOM
,
SCREEN_MODE_EGA_80X25
,
SCREEN_MODE_VGA_80X25
,
SCREEN_MODE_TERMINATOR
};
enum {
ADDRESS_FAMILY_UNSPEC
,ADDRESS_FAMILY_INET
,ADDRESS_FAMILY_INET6
ADDRESS_FAMILY_UNSPEC
,
ADDRESS_FAMILY_INET
,
ADDRESS_FAMILY_INET6
};
enum {
RIP_VERSION_NONE
,RIP_VERSION_1
,RIP_VERSION_3
RIP_VERSION_NONE
,
RIP_VERSION_1
,
RIP_VERSION_3
};
/* NOTE: changing this may require updating sort_order in bbslist.c */
struct bbslist {
char name[LIST_NAME_MAX+1];
char addr[LIST_ADDR_MAX+1];
short unsigned int port;
time_t added;
time_t connected;
unsigned int calls;
char user[MAX_USER_LEN+1];
char password[MAX_PASSWD_LEN+1];
char syspass[MAX_SYSPASS_LEN+1];
int type;
int conn_type;
int id;
int screen_mode;
int nostatus;
char dldir[MAX_PATH+1];
char uldir[MAX_PATH+1];
char logfile[MAX_PATH+1];
bool append_logfile;
int xfer_loglevel;
int telnet_loglevel;
int bpsrate;
int music;
int address_family;
char font[80];
int hidepopups;
char ghost_program[9]; /* GHost program can only be 8 chars max. */
int rip;
int flow_control;
char comment[1024];
char name[LIST_NAME_MAX + 1];
char addr[LIST_ADDR_MAX + 1];
short unsigned int port;
time_t added;
time_t connected;
unsigned int calls;
char user[MAX_USER_LEN + 1];
char password[MAX_PASSWD_LEN + 1];
char syspass[MAX_SYSPASS_LEN + 1];
int type;
int conn_type;
int id;
int screen_mode;
int nostatus;
char dldir[MAX_PATH + 1];
char uldir[MAX_PATH + 1];
char logfile[MAX_PATH + 1];
bool append_logfile;
int xfer_loglevel;
int telnet_loglevel;
int bpsrate;
int music;
int address_family;
char font[80];
int hidepopups;
char ghost_program[9]; /* GHost program can only be 8 chars max. */
int rip;
int flow_control;
char comment[1024];
};
extern char *music_names[];
extern char*music_names[];
extern char music_helpbuf[];
struct bbslist *show_bbslist(char *current, int connected);
extern char *log_levels[];
extern char *rate_names[];
extern int rates[];
extern int sortorder[];
struct bbslist *show_bbslist(char*current, int connected);
extern char *log_levels[];
extern char *rate_names[];
extern int rates[];
extern int sortorder[];
extern ini_style_t ini_style;
extern char *screen_modes_enum[];
void read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int type);
void read_list(char *listpath, struct bbslist **list, struct bbslist *defaults, int *i, int type);
void free_list(struct bbslist **list, int listcount);
void add_bbs(char *listpath, struct bbslist *bbs);
int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isdefault);
int get_rate_num(int rate);
cterm_emulation_t get_emulation(struct bbslist *bbs);
extern char *screen_modes_enum[];
void read_item(str_list_t listfile, struct bbslist*entry, char*bbsname, int id, int type);
void read_list(char*listpath, struct bbslist**list, struct bbslist*defaults, int*i, int type);
void free_list(struct bbslist**list, int listcount);
void add_bbs(char*listpath, struct bbslist*bbs);
int edit_list(struct bbslist**list, struct bbslist*item, char*listpath, int isdefault);
int get_rate_num(int rate);
cterm_emulation_t get_emulation(struct bbslist*bbs);
const char *get_emulation_str(cterm_emulation_t emu);
void get_term_size(struct bbslist *bbs, int *cols, int *rows);
void get_term_size(struct bbslist*bbs, int*cols, int*rows);
#endif
#endif // ifndef _BBSLIST_H_
This diff is collapsed.
......@@ -7,71 +7,86 @@
#include <stdbool.h>
#include "bbslist.h"
#include "sockwrap.h"
#include "threadwrap.h"
#include "bbslist.h"
extern char *conn_types[];
extern char *conn_types_enum[];
extern char *conn_types[];
extern char *conn_types_enum[];
extern short unsigned int conn_ports[];
enum {
CONN_TYPE_UNKNOWN
,CONN_TYPE_RLOGIN
,CONN_TYPE_RLOGIN_REVERSED
,CONN_TYPE_TELNET
,CONN_TYPE_RAW
,CONN_TYPE_SSH
,CONN_TYPE_SSHNA
,CONN_TYPE_MODEM
,CONN_TYPE_SERIAL
,CONN_TYPE_SERIAL_NORTS
,CONN_TYPE_SHELL
,CONN_TYPE_MBBS_GHOST
,CONN_TYPE_TELNETS
,CONN_TYPE_TERMINATOR
CONN_TYPE_UNKNOWN
,
CONN_TYPE_RLOGIN
,
CONN_TYPE_RLOGIN_REVERSED
,
CONN_TYPE_TELNET
,
CONN_TYPE_RAW
,
CONN_TYPE_SSH
,
CONN_TYPE_SSHNA
,
CONN_TYPE_MODEM
,
CONN_TYPE_SERIAL
,
CONN_TYPE_SERIAL_NORTS
,
CONN_TYPE_SHELL
,
CONN_TYPE_MBBS_GHOST
,
CONN_TYPE_TELNETS
,
CONN_TYPE_TERMINATOR
};
struct conn_api {
int (*connect)(struct bbslist *bbs);
int (*close)(void);
void (*binary_mode_on)(void);
void (*binary_mode_off)(void);
bool binary_mode;
void *(*rx_parse_cb)(const void* inbuf, size_t inlen, size_t *olen);
void *(*tx_parse_cb)(const void* inbuf, size_t inlen, size_t *olen);
int log_level;
int type;
int nostatus;
int (*connect)(struct bbslist*bbs);
int (*close)(void);
void (*binary_mode_on)(void);
void (*binary_mode_off)(void);
bool binary_mode;
void * (*rx_parse_cb)(const void*inbuf, size_t inlen, size_t*olen);
void * (*tx_parse_cb)(const void*inbuf, size_t inlen, size_t*olen);
int log_level;
int type;
int nostatus;
cterm_emulation_t emulation;
volatile int input_thread_running;
volatile int output_thread_running;
volatile int terminate;
unsigned char *rd_buf;
size_t rd_buf_size;
unsigned char *wr_buf;
size_t wr_buf_size;
volatile int input_thread_running;
volatile int output_thread_running;
volatile int terminate;
unsigned char *rd_buf;
size_t rd_buf_size;
unsigned char *wr_buf;
size_t wr_buf_size;
};
struct conn_buffer {
unsigned char *buf;
size_t bufsize;
size_t buftop;
size_t bufbot;
int isempty;
pthread_mutex_t mutex;
sem_t in_sem;
sem_t out_sem;
unsigned char *buf;
size_t bufsize;
size_t buftop;
size_t bufbot;
int isempty;
pthread_mutex_t mutex;
sem_t in_sem;
sem_t out_sem;
};
/*
* Functions for stuff using connections
*/
int conn_recv_upto(void *buffer, size_t buflen, unsigned int timeout);
int conn_send(const void *buffer, size_t buflen, unsigned int timeout);
int conn_send_raw(const void *buffer, size_t buflen, unsigned int timeout);
int conn_connect(struct bbslist *bbs);
int conn_recv_upto(void*buffer, size_t buflen, unsigned int timeout);
int conn_send(const void*buffer, size_t buflen, unsigned int timeout);
int conn_send_raw(const void*buffer, size_t buflen, unsigned int timeout);
int conn_connect(struct bbslist*bbs);
int conn_close(void);
bool conn_connected(void);
size_t conn_data_waiting(void);
......@@ -82,21 +97,22 @@ void conn_binary_mode_off(void);
* For connection providers
*/
#define BUFFER_SIZE 16384
#define BUFFER_SIZE 16384
extern struct conn_buffer conn_inbuf;
extern struct conn_buffer conn_outbuf;
extern struct conn_api conn_api;
struct conn_buffer *create_conn_buf(struct conn_buffer *buf, size_t size);
void destroy_conn_buf(struct conn_buffer *buf);
size_t conn_buf_bytes(struct conn_buffer *buf);
size_t conn_buf_peek(struct conn_buffer *buf, void *voutbuf, size_t outlen);
size_t conn_buf_get(struct conn_buffer *buf, void *outbuf, size_t outlen);
size_t conn_buf_put(struct conn_buffer *buf, const void *outbuf, size_t outlen);
size_t conn_buf_wait_cond(struct conn_buffer *buf, size_t bcount, unsigned long timeout, int do_free);
#define conn_buf_wait_bytes(buf, count, timeout) conn_buf_wait_cond(buf, count, timeout, 0)
#define conn_buf_wait_free(buf, count, timeout) conn_buf_wait_cond(buf, count, timeout, 1)
int conn_socket_connect(struct bbslist *bbs);
#endif
extern struct conn_api conn_api;
struct conn_buffer *create_conn_buf(struct conn_buffer*buf, size_t size);
void destroy_conn_buf(struct conn_buffer*buf);
size_t conn_buf_bytes(struct conn_buffer*buf);
size_t conn_buf_peek(struct conn_buffer*buf, void*voutbuf, size_t outlen);
size_t conn_buf_get(struct conn_buffer*buf, void*outbuf, size_t outlen);
size_t conn_buf_put(struct conn_buffer*buf, const void*outbuf, size_t outlen);
size_t conn_buf_wait_cond(struct conn_buffer*buf, size_t bcount, unsigned long timeout, int do_free);
#define conn_buf_wait_bytes(buf, count, timeout) conn_buf_wait_cond(buf, count, timeout, 0)
#define conn_buf_wait_free(buf, count, timeout) conn_buf_wait_cond(buf, count, timeout, 1)
int conn_socket_connect(struct bbslist*bbs);
#endif // ifndef _CONN_H_
This diff is collapsed.
......@@ -2,8 +2,7 @@
#ifndef _CONN_PTY_H_
#define _CONN_PTY_H_
int pty_connect(struct bbslist *bbs);
int pty_connect(struct bbslist*bbs);
int pty_close(void);
#endif
......@@ -5,38 +5,39 @@
#include <stdbool.h>
#include <stdlib.h>
#include "bbslist.h"
#include "conn.h"
#include "gen_defs.h"
#include "genwrap.h"
#include "rlogin.h"
#include "sockwrap.h"
#include "threadwrap.h"
#include "bbslist.h"
#include "conn.h"
#include "telnet_io.h"
#include "term.h"
#include "threadwrap.h"
#include "uifcinit.h"
#include "telnet_io.h"
#include "rlogin.h"
extern int telnet_log_level;
extern int telnet_log_level;
/*****************************************************************************/
// Escapes Telnet IACs in 'inbuf' by doubling the IAC char
// 'result' may point to either inbuf (if there were no IACs) or outbuf
// Returns the final byte count of the result
/*****************************************************************************/
static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf, size_t outlen, bool expand_cr, uchar** result)
static size_t
st_telnet_expand(const uchar*inbuf, size_t inlen, uchar*outbuf, size_t outlen, bool expand_cr, uchar**result)
{
static bool last_was_lf = false;
BYTE* first_iac = (BYTE*)memchr(inbuf, TELNET_IAC, inlen);
BYTE* first_cr=NULL;
BYTE *first_iac = (BYTE*)memchr(inbuf, TELNET_IAC, inlen);
BYTE *first_cr = NULL;
if (inlen == 0) {
if (result != NULL)
*result = (uchar *)inbuf;
*result = (uchar*)inbuf;
return 0;
}
if (last_was_lf && inbuf[0] == '\n') {
if (last_was_lf && (inbuf[0] == '\n')) {
inbuf++;
inlen--;
}
......@@ -46,7 +47,7 @@ static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf,
else
last_was_lf = false;
if (first_iac == NULL && first_cr == NULL) { /* Nothing to expand */
if ((first_iac == NULL) && (first_cr == NULL)) { /* Nothing to expand */
if (result != NULL)
*result = (uchar*)inbuf;
return inlen;
......@@ -54,50 +55,52 @@ static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf,
size_t o;
if(first_iac != NULL && (first_cr == NULL || first_iac < first_cr))
if ((first_iac != NULL) && ((first_cr == NULL) || (first_iac < first_cr)))
o = first_iac - inbuf;
else
o = first_cr - inbuf;
memcpy(outbuf, inbuf, o);
for (size_t i = o; i < inlen && o < outlen; i++) {
if (inbuf[i] == '\n' && last_was_lf)
if ((inbuf[i] == '\n') && last_was_lf)
continue;
last_was_lf = false;
if(inbuf[i] == TELNET_IAC)