Skip to content
Snippets Groups Projects
Commit 030c7cf9 authored by Deucе's avatar Deucе :ok_hand_tone4:
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
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3505 passed
Showing
with 6815 additions and 5141 deletions
...@@ -9,27 +9,28 @@ enum fonttype { ...@@ -9,27 +9,28 @@ enum fonttype {
}; };
struct StandardFontEntry { struct StandardFontEntry {
char name[256]; char name[256];
uint16_t height; uint16_t height;
uint8_t style; uint8_t style;
uint8_t flags; uint8_t flags;
}; };
struct TaggedFontEntry { struct TaggedFontEntry {
char name[254]; char name[254];
uint16_t tags; uint16_t tags;
uint16_t height; uint16_t height;
uint8_t style; uint8_t style;
uint8_t flags; uint8_t flags;
}; };
struct FontContentsHeader { struct FontContentsHeader {
uint16_t type; uint16_t type;
uint16_t count; uint16_t count;
}; };
struct FontList { struct FontList {
struct FontContentsHeader header; struct FontContentsHeader header;
union { union {
struct StandardFontEntry std; struct StandardFontEntry std;
struct StandardFontEntry tag; struct StandardFontEntry tag;
...@@ -37,39 +38,39 @@ struct FontList { ...@@ -37,39 +38,39 @@ struct FontList {
}; };
#if defined(_WIN32) || defined(__BORLANDC__) #if defined(_WIN32) || defined(__BORLANDC__)
#define PRAGMA_PACK #define PRAGMA_PACK
#endif #endif
#if defined(PRAGMA_PACK) || defined(__WATCOMC__) #if defined(PRAGMA_PACK) || defined(__WATCOMC__)
#define _PACK #define _PACK
#else #else
#define _PACK __attribute__ ((packed)) #define _PACK __attribute__((packed))
#endif #endif
#if defined(PRAGMA_PACK) #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 #endif
struct _PACK FontHeader { struct _PACK FontHeader {
uint8_t ignore[0x6E]; uint8_t ignore[0x6E];
uint16_t height; uint16_t height;
uint8_t style; uint8_t style;
uint8_t flags; uint8_t flags;
uint16_t xsize; uint16_t xsize;
uint16_t baseline; // Distance from top to baseline uint16_t baseline; // Distance from top to baseline
uint16_t boldsmear; uint16_t boldsmear;
uint16_t rc; // Literally a reference count on disk. uint16_t rc; // Literally a reference count on disk.
uint8_t first; uint8_t first;
uint8_t last; uint8_t last;
uint32_t dataOffset; uint32_t dataOffset;
uint16_t modulo; uint16_t modulo;
uint32_t charlocOffset; uint32_t charlocOffset;
uint32_t fontSpaceOffset; uint32_t fontSpaceOffset;
uint32_t kernOffset; uint32_t kernOffset;
}; };
#if defined(PRAGMA_PACK) #if defined(PRAGMA_PACK)
#pragma pack(pop) /* original packing */ #pragma pack(pop) /* original packing */
#endif #endif
#endif #endif // ifndef AMIGAFONT_H
This diff is collapsed.
...@@ -6,126 +6,159 @@ ...@@ -6,126 +6,159 @@
#define _BBSLIST_H_ #define _BBSLIST_H_
#include <stdbool.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 "gen_defs.h"
#include "dirwrap.h" /* MAX_PATH */
#include "ini_file.h" #include "ini_file.h"
#include <time.h>
#if defined(_WIN32) #if defined(_WIN32)
#include <malloc.h> /* alloca() on Win32 */ #include <malloc.h> /* alloca() on Win32 */
#endif #endif
#include <cterm.h> #include <cterm.h>
#define LIST_NAME_MAX 30 #define LIST_NAME_MAX 30
#define LIST_ADDR_MAX 64 #define LIST_ADDR_MAX 64
#define MAX_USER_LEN 30 #define MAX_USER_LEN 30
#define MAX_PASSWD_LEN 128 #define MAX_PASSWD_LEN 128
#define MAX_SYSPASS_LEN 128 #define MAX_SYSPASS_LEN 128
enum { enum {
USER_BBSLIST USER_BBSLIST
,SYSTEM_BBSLIST ,
SYSTEM_BBSLIST
}; };
enum { enum {
BBSLIST_SELECT BBSLIST_SELECT
,BBSLIST_EDIT ,
BBSLIST_EDIT
}; };
enum { enum {
SCREEN_MODE_CURRENT SCREEN_MODE_CURRENT
,SCREEN_MODE_80X25 ,
,SCREEN_MODE_LCD80X25 SCREEN_MODE_80X25
,SCREEN_MODE_80X28 ,
,SCREEN_MODE_80X30 SCREEN_MODE_LCD80X25
,SCREEN_MODE_80X43 ,
,SCREEN_MODE_80X50 SCREEN_MODE_80X28
,SCREEN_MODE_80X60 ,
,SCREEN_MODE_132X37 SCREEN_MODE_80X30
,SCREEN_MODE_132x52 ,
,SCREEN_MODE_132X25 SCREEN_MODE_80X43
,SCREEN_MODE_132X28 ,
,SCREEN_MODE_132X30 SCREEN_MODE_80X50
,SCREEN_MODE_132X34 ,
,SCREEN_MODE_132X43 SCREEN_MODE_80X60
,SCREEN_MODE_132X50 ,
,SCREEN_MODE_132X60 SCREEN_MODE_132X37
,SCREEN_MODE_C64 ,
,SCREEN_MODE_C128_40 SCREEN_MODE_132x52
,SCREEN_MODE_C128_80 ,
,SCREEN_MODE_ATARI SCREEN_MODE_132X25
,SCREEN_MODE_ATARI_XEP80 ,
,SCREEN_MODE_CUSTOM SCREEN_MODE_132X28
,SCREEN_MODE_EGA_80X25 ,
,SCREEN_MODE_VGA_80X25 SCREEN_MODE_132X30
,SCREEN_MODE_TERMINATOR ,
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 { enum {
ADDRESS_FAMILY_UNSPEC ADDRESS_FAMILY_UNSPEC
,ADDRESS_FAMILY_INET ,
,ADDRESS_FAMILY_INET6 ADDRESS_FAMILY_INET
,
ADDRESS_FAMILY_INET6
}; };
enum { enum {
RIP_VERSION_NONE RIP_VERSION_NONE
,RIP_VERSION_1 ,
,RIP_VERSION_3 RIP_VERSION_1
,
RIP_VERSION_3
}; };
/* NOTE: changing this may require updating sort_order in bbslist.c */ /* NOTE: changing this may require updating sort_order in bbslist.c */
struct bbslist { struct bbslist {
char name[LIST_NAME_MAX+1]; char name[LIST_NAME_MAX + 1];
char addr[LIST_ADDR_MAX+1]; char addr[LIST_ADDR_MAX + 1];
short unsigned int port; short unsigned int port;
time_t added; time_t added;
time_t connected; time_t connected;
unsigned int calls; unsigned int calls;
char user[MAX_USER_LEN+1]; char user[MAX_USER_LEN + 1];
char password[MAX_PASSWD_LEN+1]; char password[MAX_PASSWD_LEN + 1];
char syspass[MAX_SYSPASS_LEN+1]; char syspass[MAX_SYSPASS_LEN + 1];
int type; int type;
int conn_type; int conn_type;
int id; int id;
int screen_mode; int screen_mode;
int nostatus; int nostatus;
char dldir[MAX_PATH+1]; char dldir[MAX_PATH + 1];
char uldir[MAX_PATH+1]; char uldir[MAX_PATH + 1];
char logfile[MAX_PATH+1]; char logfile[MAX_PATH + 1];
bool append_logfile; bool append_logfile;
int xfer_loglevel; int xfer_loglevel;
int telnet_loglevel; int telnet_loglevel;
int bpsrate; int bpsrate;
int music; int music;
int address_family; int address_family;
char font[80]; char font[80];
int hidepopups; int hidepopups;
char ghost_program[9]; /* GHost program can only be 8 chars max. */ char ghost_program[9]; /* GHost program can only be 8 chars max. */
int rip; int rip;
int flow_control; int flow_control;
char comment[1024]; char comment[1024];
}; };
extern char *music_names[]; extern char*music_names[];
extern char music_helpbuf[]; extern char music_helpbuf[];
struct bbslist *show_bbslist(char *current, int connected); struct bbslist *show_bbslist(char*current, int connected);
extern char *log_levels[];
extern char *rate_names[]; extern char *log_levels[];
extern int rates[]; extern char *rate_names[];
extern int sortorder[]; extern int rates[];
extern int sortorder[];
extern ini_style_t ini_style; extern ini_style_t ini_style;
extern char *screen_modes_enum[]; extern char *screen_modes_enum[];
void read_item(str_list_t listfile, struct bbslist *entry, char *bbsname, int id, int type); 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 read_list(char*listpath, struct bbslist**list, struct bbslist*defaults, int*i, int type);
void free_list(struct bbslist **list, int listcount); void free_list(struct bbslist**list, int listcount);
void add_bbs(char *listpath, struct bbslist *bbs); void add_bbs(char*listpath, struct bbslist*bbs);
int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isdefault); int edit_list(struct bbslist**list, struct bbslist*item, char*listpath, int isdefault);
int get_rate_num(int rate); int get_rate_num(int rate);
cterm_emulation_t get_emulation(struct bbslist *bbs); cterm_emulation_t get_emulation(struct bbslist*bbs);
const char *get_emulation_str(cterm_emulation_t emu); 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 @@ ...@@ -7,71 +7,86 @@
#include <stdbool.h> #include <stdbool.h>
#include "bbslist.h"
#include "sockwrap.h" #include "sockwrap.h"
#include "threadwrap.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[]; extern short unsigned int conn_ports[];
enum { enum {
CONN_TYPE_UNKNOWN CONN_TYPE_UNKNOWN
,CONN_TYPE_RLOGIN ,
,CONN_TYPE_RLOGIN_REVERSED CONN_TYPE_RLOGIN
,CONN_TYPE_TELNET ,
,CONN_TYPE_RAW CONN_TYPE_RLOGIN_REVERSED
,CONN_TYPE_SSH ,
,CONN_TYPE_SSHNA CONN_TYPE_TELNET
,CONN_TYPE_MODEM ,
,CONN_TYPE_SERIAL CONN_TYPE_RAW
,CONN_TYPE_SERIAL_NORTS ,
,CONN_TYPE_SHELL CONN_TYPE_SSH
,CONN_TYPE_MBBS_GHOST ,
,CONN_TYPE_TELNETS CONN_TYPE_SSHNA
,CONN_TYPE_TERMINATOR ,
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 { struct conn_api {
int (*connect)(struct bbslist *bbs); int (*connect)(struct bbslist*bbs);
int (*close)(void); int (*close)(void);
void (*binary_mode_on)(void); void (*binary_mode_on)(void);
void (*binary_mode_off)(void); void (*binary_mode_off)(void);
bool binary_mode;
void *(*rx_parse_cb)(const void* inbuf, size_t inlen, size_t *olen); bool binary_mode;
void *(*tx_parse_cb)(const void* inbuf, size_t inlen, size_t *olen);
int log_level; void * (*rx_parse_cb)(const void*inbuf, size_t inlen, size_t*olen);
int type; void * (*tx_parse_cb)(const void*inbuf, size_t inlen, size_t*olen);
int nostatus;
int log_level;
int type;
int nostatus;
cterm_emulation_t emulation; cterm_emulation_t emulation;
volatile int input_thread_running; volatile int input_thread_running;
volatile int output_thread_running; volatile int output_thread_running;
volatile int terminate; volatile int terminate;
unsigned char *rd_buf; unsigned char *rd_buf;
size_t rd_buf_size; size_t rd_buf_size;
unsigned char *wr_buf; unsigned char *wr_buf;
size_t wr_buf_size; size_t wr_buf_size;
}; };
struct conn_buffer { struct conn_buffer {
unsigned char *buf; unsigned char *buf;
size_t bufsize; size_t bufsize;
size_t buftop; size_t buftop;
size_t bufbot; size_t bufbot;
int isempty; int isempty;
pthread_mutex_t mutex; pthread_mutex_t mutex;
sem_t in_sem; sem_t in_sem;
sem_t out_sem; sem_t out_sem;
}; };
/* /*
* Functions for stuff using connections * Functions for stuff using connections
*/ */
int conn_recv_upto(void *buffer, size_t buflen, unsigned int timeout); 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(const void*buffer, size_t buflen, unsigned int timeout);
int conn_send_raw(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_connect(struct bbslist*bbs);
int conn_close(void); int conn_close(void);
bool conn_connected(void); bool conn_connected(void);
size_t conn_data_waiting(void); size_t conn_data_waiting(void);
...@@ -82,21 +97,22 @@ void conn_binary_mode_off(void); ...@@ -82,21 +97,22 @@ void conn_binary_mode_off(void);
* For connection providers * For connection providers
*/ */
#define BUFFER_SIZE 16384 #define BUFFER_SIZE 16384
extern struct conn_buffer conn_inbuf; extern struct conn_buffer conn_inbuf;
extern struct conn_buffer conn_outbuf; extern struct conn_buffer conn_outbuf;
extern struct conn_api conn_api; extern struct conn_api conn_api;
struct conn_buffer *create_conn_buf(struct conn_buffer *buf, size_t size); struct conn_buffer *create_conn_buf(struct conn_buffer*buf, size_t size);
void destroy_conn_buf(struct conn_buffer *buf); void destroy_conn_buf(struct conn_buffer*buf);
size_t conn_buf_bytes(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_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_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_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); 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) #define conn_buf_wait_bytes(buf, count, timeout) conn_buf_wait_cond(buf, count, timeout, 0)
int conn_socket_connect(struct bbslist *bbs); #define conn_buf_wait_free(buf, count, timeout) conn_buf_wait_cond(buf, count, timeout, 1)
int conn_socket_connect(struct bbslist*bbs);
#endif
#endif // ifndef _CONN_H_
This diff is collapsed.
...@@ -2,8 +2,7 @@ ...@@ -2,8 +2,7 @@
#ifndef _CONN_PTY_H_ #ifndef _CONN_PTY_H_
#define _CONN_PTY_H_ #define _CONN_PTY_H_
int pty_connect(struct bbslist*bbs);
int pty_connect(struct bbslist *bbs);
int pty_close(void); int pty_close(void);
#endif #endif
...@@ -5,38 +5,39 @@ ...@@ -5,38 +5,39 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include "bbslist.h"
#include "conn.h"
#include "gen_defs.h" #include "gen_defs.h"
#include "genwrap.h" #include "genwrap.h"
#include "rlogin.h"
#include "sockwrap.h" #include "sockwrap.h"
#include "threadwrap.h" #include "telnet_io.h"
#include "bbslist.h"
#include "conn.h"
#include "term.h" #include "term.h"
#include "threadwrap.h"
#include "uifcinit.h" #include "uifcinit.h"
#include "telnet_io.h" extern int telnet_log_level;
#include "rlogin.h"
extern int telnet_log_level;
/*****************************************************************************/ /*****************************************************************************/
// Escapes Telnet IACs in 'inbuf' by doubling the IAC char // Escapes Telnet IACs in 'inbuf' by doubling the IAC char
// 'result' may point to either inbuf (if there were no IACs) or outbuf // 'result' may point to either inbuf (if there were no IACs) or outbuf
// Returns the final byte count of the result // 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; static bool last_was_lf = false;
BYTE* first_iac = (BYTE*)memchr(inbuf, TELNET_IAC, inlen); BYTE *first_iac = (BYTE*)memchr(inbuf, TELNET_IAC, inlen);
BYTE* first_cr=NULL; BYTE *first_cr = NULL;
if (inlen == 0) { if (inlen == 0) {
if (result != NULL) if (result != NULL)
*result = (uchar *)inbuf; *result = (uchar*)inbuf;
return 0; return 0;
} }
if (last_was_lf && inbuf[0] == '\n') { if (last_was_lf && (inbuf[0] == '\n')) {
inbuf++; inbuf++;
inlen--; inlen--;
} }
...@@ -46,7 +47,7 @@ static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf, ...@@ -46,7 +47,7 @@ static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf,
else else
last_was_lf = false; 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) if (result != NULL)
*result = (uchar*)inbuf; *result = (uchar*)inbuf;
return inlen; return inlen;
...@@ -54,50 +55,52 @@ static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf, ...@@ -54,50 +55,52 @@ static size_t st_telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf,
size_t o; 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; o = first_iac - inbuf;
else else
o = first_cr - inbuf; o = first_cr - inbuf;
memcpy(outbuf, inbuf, o); memcpy(outbuf, inbuf, o);
for (size_t i = o; i < inlen && o < outlen; i++) { 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; continue;
last_was_lf = false; last_was_lf = false;
if(inbuf[i] == TELNET_IAC) if (inbuf[i] == TELNET_IAC)
outbuf[o++] = TELNET_IAC; outbuf[o++] = TELNET_IAC;
if(o >= outlen) if (o >= outlen)
break; break;
outbuf[o++] = inbuf[i]; outbuf[o++] = inbuf[i];
if(expand_cr && inbuf[i] == '\r' && o < outlen) { if (expand_cr && (inbuf[i] == '\r') && (o < outlen)) {
last_was_lf = true; last_was_lf = true;
outbuf[o++] = '\n'; // See RFC5198 outbuf[o++] = '\n'; // See RFC5198
} }
} }
if(result != NULL) if (result != NULL)
*result = outbuf; *result = outbuf;
return o; return o;
} }
void *telnet_rx_parse_cb(const void *buf, size_t inlen, size_t *olen) void*
telnet_rx_parse_cb(const void*buf, size_t inlen, size_t*olen)
{ {
// telnet_interpret() can add up to one byte to inbuf ('\r') // telnet_interpret() can add up to one byte to inbuf ('\r')
void *ret = malloc(inlen + 1); void*ret = malloc(inlen + 1);
if (ret == NULL) if (ret == NULL)
return ret; return ret;
if (telnet_interpret((BYTE *)buf, inlen, ret, olen) != ret) if (telnet_interpret((BYTE*)buf, inlen, ret, olen) != ret)
memcpy(ret, buf, *olen); memcpy(ret, buf, *olen);
return ret; return ret;
} }
void *telnet_tx_parse_cb(const void *buf, size_t len, size_t *olen) void*
telnet_tx_parse_cb(const void*buf, size_t len, size_t*olen)
{ {
void *ret = malloc(len * 2); void*ret = malloc(len * 2);
void *parsed; void*parsed;
*olen = st_telnet_expand(buf, len, ret, len * 2 *olen = st_telnet_expand(buf, len, ret, len * 2
,telnet_local_option[TELNET_BINARY_TX]!=TELNET_DO, (BYTE **)&parsed); , telnet_local_option[TELNET_BINARY_TX] != TELNET_DO, (BYTE**)&parsed);
if (parsed != ret) if (parsed != ret)
memcpy(ret, parsed, *olen); memcpy(ret, parsed, *olen);
...@@ -105,41 +108,42 @@ void *telnet_tx_parse_cb(const void *buf, size_t len, size_t *olen) ...@@ -105,41 +108,42 @@ void *telnet_tx_parse_cb(const void *buf, size_t len, size_t *olen)
return ret; return ret;
} }
int telnet_connect(struct bbslist *bbs) int
telnet_connect(struct bbslist*bbs)
{ {
if (!bbs->hidepopups) if (!bbs->hidepopups)
init_uifc(true, true); init_uifc(true, true);
telnet_log_level = bbs->telnet_loglevel; telnet_log_level = bbs->telnet_loglevel;
rlogin_sock=conn_socket_connect(bbs); rlogin_sock = conn_socket_connect(bbs);
if(rlogin_sock==INVALID_SOCKET) if (rlogin_sock == INVALID_SOCKET)
return(-1); return -1;
if(!create_conn_buf(&conn_inbuf, BUFFER_SIZE)) if (!create_conn_buf(&conn_inbuf, BUFFER_SIZE))
return(-1); return -1;
if(!create_conn_buf(&conn_outbuf, BUFFER_SIZE)) { if (!create_conn_buf(&conn_outbuf, BUFFER_SIZE)) {
destroy_conn_buf(&conn_inbuf); destroy_conn_buf(&conn_inbuf);
return(-1); return -1;
} }
conn_api.rd_buf=(unsigned char *)malloc(BUFFER_SIZE); conn_api.rd_buf = (unsigned char*)malloc(BUFFER_SIZE);
if(!conn_api.rd_buf) { if (!conn_api.rd_buf) {
destroy_conn_buf(&conn_inbuf); destroy_conn_buf(&conn_inbuf);
destroy_conn_buf(&conn_outbuf); destroy_conn_buf(&conn_outbuf);
return(-1); return -1;
} }
conn_api.rd_buf_size=BUFFER_SIZE; conn_api.rd_buf_size = BUFFER_SIZE;
conn_api.wr_buf=(unsigned char *)malloc(BUFFER_SIZE); conn_api.wr_buf = (unsigned char*)malloc(BUFFER_SIZE);
if(!conn_api.wr_buf) { if (!conn_api.wr_buf) {
FREE_AND_NULL(conn_api.rd_buf); FREE_AND_NULL(conn_api.rd_buf);
destroy_conn_buf(&conn_inbuf); destroy_conn_buf(&conn_inbuf);
destroy_conn_buf(&conn_outbuf); destroy_conn_buf(&conn_outbuf);
return(-1); return -1;
} }
conn_api.wr_buf_size=BUFFER_SIZE; conn_api.wr_buf_size = BUFFER_SIZE;
memset(telnet_local_option,0,sizeof(telnet_local_option)); memset(telnet_local_option, 0, sizeof(telnet_local_option));
memset(telnet_remote_option,0,sizeof(telnet_remote_option)); memset(telnet_remote_option, 0, sizeof(telnet_remote_option));
conn_api.rx_parse_cb = telnet_rx_parse_cb; conn_api.rx_parse_cb = telnet_rx_parse_cb;
conn_api.tx_parse_cb = telnet_tx_parse_cb; conn_api.tx_parse_cb = telnet_tx_parse_cb;
...@@ -149,17 +153,19 @@ int telnet_connect(struct bbslist *bbs) ...@@ -149,17 +153,19 @@ int telnet_connect(struct bbslist *bbs)
if (!bbs->hidepopups) if (!bbs->hidepopups)
uifc.pop(NULL); uifc.pop(NULL);
return(0); return 0;
} }
void telnet_binary_mode_on(void) void
telnet_binary_mode_on(void)
{ {
request_telnet_opt(TELNET_DO,TELNET_BINARY_TX); request_telnet_opt(TELNET_DO, TELNET_BINARY_TX);
request_telnet_opt(TELNET_WILL,TELNET_BINARY_TX); request_telnet_opt(TELNET_WILL, TELNET_BINARY_TX);
} }
void telnet_binary_mode_off(void) void
telnet_binary_mode_off(void)
{ {
request_telnet_opt(TELNET_DONT,TELNET_BINARY_TX); request_telnet_opt(TELNET_DONT, TELNET_BINARY_TX);
request_telnet_opt(TELNET_WONT,TELNET_BINARY_TX); request_telnet_opt(TELNET_WONT, TELNET_BINARY_TX);
} }
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
extern SOCKET telnet_sock; extern SOCKET telnet_sock;
void telnet_binary_mode_on(void); void telnet_binary_mode_on(void);
void telnet_binary_mode_off(void); void telnet_binary_mode_off(void);
int telnet_connect(struct bbslist *bbs); int telnet_connect(struct bbslist*bbs);
void *telnet_rx_parse_cb(const void *buf, size_t inlen, size_t *olen); void *telnet_rx_parse_cb(const void*buf, size_t inlen, size_t*olen);
void *telnet_tx_parse_cb(const void *buf, size_t len, size_t *olen); void *telnet_tx_parse_cb(const void*buf, size_t len, size_t*olen);
#define telnet_close rlogin_close #define telnet_close rlogin_close
#endif #endif
...@@ -3,26 +3,23 @@ ...@@ -3,26 +3,23 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "gen_defs.h" #include "bbslist.h"
#include "ini_file.h"
#include "ciolib.h" #include "ciolib.h"
#include "uifc.h"
#include "filepick.h" #include "filepick.h"
#include "bbslist.h"
#include "fonts.h" #include "fonts.h"
#include "gen_defs.h"
#include "ini_file.h"
#include "syncterm.h" #include "syncterm.h"
#include "uifc.h"
#include "uifcinit.h" #include "uifcinit.h"
void
void free_font_files(struct font_files *ff) free_font_files(struct font_files*ff)
{ {
int i; int i;
if(ff==NULL) if (ff == NULL)
return; return;
for(i=0; ff[i].name != NULL; i++) { for (i = 0; ff[i].name != NULL; i++) {
FREE_AND_NULL(ff[i].name); FREE_AND_NULL(ff[i].name);
FREE_AND_NULL(ff[i].path8x8); FREE_AND_NULL(ff[i].path8x8);
FREE_AND_NULL(ff[i].path8x14); FREE_AND_NULL(ff[i].path8x14);
...@@ -30,53 +27,53 @@ void free_font_files(struct font_files *ff) ...@@ -30,53 +27,53 @@ void free_font_files(struct font_files *ff)
} }
free(ff); free(ff);
} }
void
void save_font_files(struct font_files *fonts) save_font_files(struct font_files*fonts)
{ {
FILE *inifile; FILE *inifile;
char inipath[MAX_PATH+1]; char inipath[MAX_PATH + 1];
char newfont[MAX_PATH+1]; char newfont[MAX_PATH + 1];
char *fontid; char *fontid;
str_list_t ini_file; str_list_t ini_file;
str_list_t fontnames; str_list_t fontnames;
int i; int i;
if(safe_mode) if (safe_mode)
return; return;
get_syncterm_filename(inipath, sizeof(inipath), SYNCTERM_PATH_INI, false); get_syncterm_filename(inipath, sizeof(inipath), SYNCTERM_PATH_INI, false);
if((inifile=fopen(inipath,"r"))!=NULL) { if ((inifile = fopen(inipath, "r")) != NULL) {
ini_file=iniReadFile(inifile); ini_file = iniReadFile(inifile);
fclose(inifile); fclose(inifile);
} }
else { else {
ini_file=strListInit(); ini_file = strListInit();
} }
fontnames=iniGetSectionList(ini_file, "Font:"); fontnames = iniGetSectionList(ini_file, "Font:");
/* TODO: Remove all sections... we don't *NEED* to do this */ /* TODO: Remove all sections... we don't *NEED* to do this */
while((fontid=strListPop(&fontnames))!=NULL) { while ((fontid = strListPop(&fontnames)) != NULL) {
iniRemoveSection(&ini_file, fontid); iniRemoveSection(&ini_file, fontid);
free(fontid); free(fontid);
} }
if(fonts != NULL) { if (fonts != NULL) {
for(i=0; fonts[i].name && fonts[i].name[0]; i++) { for (i = 0; fonts[i].name && fonts[i].name[0]; i++) {
sprintf(newfont,"Font:%s",fonts[i].name); sprintf(newfont, "Font:%s", fonts[i].name);
if(fonts[i].path8x8) if (fonts[i].path8x8)
iniSetString(&ini_file, newfont, "Path8x8", fonts[i].path8x8, &ini_style); iniSetString(&ini_file, newfont, "Path8x8", fonts[i].path8x8, &ini_style);
if(fonts[i].path8x14) if (fonts[i].path8x14)
iniSetString(&ini_file, newfont, "Path8x14", fonts[i].path8x14, &ini_style); iniSetString(&ini_file, newfont, "Path8x14", fonts[i].path8x14, &ini_style);
if(fonts[i].path8x16) if (fonts[i].path8x16)
iniSetString(&ini_file, newfont, "Path8x16", fonts[i].path8x16, &ini_style); iniSetString(&ini_file, newfont, "Path8x16", fonts[i].path8x16, &ini_style);
} }
} }
if((inifile=fopen(inipath,"w"))!=NULL) { if ((inifile = fopen(inipath, "w")) != NULL) {
iniWriteFile(inifile,ini_file); iniWriteFile(inifile, ini_file);
fclose(inifile); fclose(inifile);
} }
else { else {
uifc.helpbuf="There was an error writing the INI file.\nCheck permissions and try again.\n"; uifc.helpbuf = "There was an error writing the INI file.\nCheck permissions and try again.\n";
uifc.msg("Cannot write to the .ini file!"); uifc.msg("Cannot write to the .ini file!");
check_exit(false); check_exit(false);
} }
...@@ -85,108 +82,102 @@ void save_font_files(struct font_files *fonts) ...@@ -85,108 +82,102 @@ void save_font_files(struct font_files *fonts)
strListFree(&ini_file); strListFree(&ini_file);
} }
struct font_files *read_font_files(int *count) struct font_files*
read_font_files(int*count)
{ {
FILE *inifile; FILE *inifile;
char inipath[MAX_PATH+1]; char inipath[MAX_PATH + 1];
char fontpath[MAX_PATH+1]; char fontpath[MAX_PATH + 1];
char *fontid; char *fontid;
str_list_t fonts; str_list_t fonts;
struct font_files *ret=NULL; struct font_files*ret = NULL;
struct font_files *tmp; struct font_files*tmp;
*count=0; *count = 0;
get_syncterm_filename(inipath, sizeof(inipath), SYNCTERM_PATH_INI, false); get_syncterm_filename(inipath, sizeof(inipath), SYNCTERM_PATH_INI, false);
if((inifile=fopen(inipath, "r"))==NULL) { if ((inifile = fopen(inipath, "r")) == NULL)
return(ret); return ret;
} fonts = iniReadSectionList(inifile, "Font:");
fonts=iniReadSectionList(inifile, "Font:"); while ((fontid = strListRemove(&fonts, 0)) != NULL) {
while((fontid=strListRemove(&fonts, 0))!=NULL) { if (!fontid[5]) {
if(!fontid[5]) {
free(fontid); free(fontid);
continue; continue;
} }
(*count)++; (*count)++;
tmp=(struct font_files *)realloc(ret, sizeof(struct font_files)*(*count+1)); tmp = (struct font_files*)realloc(ret, sizeof(struct font_files) * (*count + 1));
if(tmp==NULL) { if (tmp == NULL) {
count--; count--;
free(fontid); free(fontid);
continue; continue;
} }
ret=tmp; ret = tmp;
ret[*count].name=NULL; ret[*count].name = NULL;
ret[*count-1].name=strdup(fontid+5); ret[*count - 1].name = strdup(fontid + 5);
if((ret[*count-1].path8x8=iniReadString(inifile,fontid,"Path8x8",NULL,fontpath))!=NULL) if ((ret[*count - 1].path8x8 = iniReadString(inifile, fontid, "Path8x8", NULL, fontpath)) != NULL)
ret[*count-1].path8x8=strdup(fontpath); ret[*count - 1].path8x8 = strdup(fontpath);
if((ret[*count-1].path8x14=iniReadString(inifile,fontid,"Path8x14",NULL,fontpath))!=NULL) if ((ret[*count - 1].path8x14 = iniReadString(inifile, fontid, "Path8x14", NULL, fontpath)) != NULL)
ret[*count-1].path8x14=strdup(fontpath); ret[*count - 1].path8x14 = strdup(fontpath);
if((ret[*count-1].path8x16=iniReadString(inifile,fontid,"Path8x16",NULL,fontpath))!=NULL) if ((ret[*count - 1].path8x16 = iniReadString(inifile, fontid, "Path8x16", NULL, fontpath)) != NULL)
ret[*count-1].path8x16=strdup(fontpath); ret[*count - 1].path8x16 = strdup(fontpath);
free(fontid); free(fontid);
} }
fclose(inifile); fclose(inifile);
strListFree(&fonts); strListFree(&fonts);
return(ret); return ret;
} }
void
void load_font_files(void) load_font_files(void)
{ {
int count=0; int count = 0;
int i; int i;
int nextfont=CONIO_FIRST_FREE_FONT; int nextfont = CONIO_FIRST_FREE_FONT;
struct font_files *ff; struct font_files*ff;
FILE *fontfile; FILE *fontfile;
char *fontdata; char *fontdata;
ff=read_font_files(&count); ff = read_font_files(&count);
for(i=0; i<count; i++) { for (i = 0; i < count; i++) {
if(conio_fontdata[nextfont].eight_by_sixteen) if (conio_fontdata[nextfont].eight_by_sixteen)
FREE_AND_NULL(conio_fontdata[nextfont].eight_by_sixteen); FREE_AND_NULL(conio_fontdata[nextfont].eight_by_sixteen);
if(conio_fontdata[nextfont].eight_by_fourteen) if (conio_fontdata[nextfont].eight_by_fourteen)
FREE_AND_NULL(conio_fontdata[nextfont].eight_by_fourteen); FREE_AND_NULL(conio_fontdata[nextfont].eight_by_fourteen);
if(conio_fontdata[nextfont].eight_by_eight) if (conio_fontdata[nextfont].eight_by_eight)
FREE_AND_NULL(conio_fontdata[nextfont].eight_by_eight); FREE_AND_NULL(conio_fontdata[nextfont].eight_by_eight);
if(conio_fontdata[nextfont].desc) if (conio_fontdata[nextfont].desc)
FREE_AND_NULL(conio_fontdata[nextfont].desc); FREE_AND_NULL(conio_fontdata[nextfont].desc);
if(ff[i].name) if (ff[i].name)
conio_fontdata[nextfont].desc=strdup(ff[i].name); conio_fontdata[nextfont].desc = strdup(ff[i].name);
else else
continue; continue;
if(ff[i].path8x8 && ff[i].path8x8[0]) { if (ff[i].path8x8 && ff[i].path8x8[0]) {
if((fontfile=fopen(ff[i].path8x8,"rb"))!=NULL) { if ((fontfile = fopen(ff[i].path8x8, "rb")) != NULL) {
if((fontdata=(char *)malloc(2048))!=NULL) { if ((fontdata = (char*)malloc(2048)) != NULL) {
if(fread(fontdata, 1, 2048, fontfile)==2048) { if (fread(fontdata, 1, 2048, fontfile) == 2048)
conio_fontdata[nextfont].eight_by_eight=fontdata; conio_fontdata[nextfont].eight_by_eight = fontdata;
} else
else {
free(fontdata); free(fontdata);
}
} }
fclose(fontfile); fclose(fontfile);
} }
} }
if(ff[i].path8x14 && ff[i].path8x14[0]) { if (ff[i].path8x14 && ff[i].path8x14[0]) {
if((fontfile=fopen(ff[i].path8x14,"rb"))!=NULL) { if ((fontfile = fopen(ff[i].path8x14, "rb")) != NULL) {
if((fontdata=(char *)malloc(3584))!=NULL) { if ((fontdata = (char*)malloc(3584)) != NULL) {
if(fread(fontdata, 1, 3584, fontfile)==3584) { if (fread(fontdata, 1, 3584, fontfile) == 3584)
conio_fontdata[nextfont].eight_by_fourteen=fontdata; conio_fontdata[nextfont].eight_by_fourteen = fontdata;
} else
else {
free(fontdata); free(fontdata);
}
} }
fclose(fontfile); fclose(fontfile);
} }
} }
if(ff[i].path8x16 && ff[i].path8x16[0]) { if (ff[i].path8x16 && ff[i].path8x16[0]) {
if((fontfile=fopen(ff[i].path8x16,"rb"))!=NULL) { if ((fontfile = fopen(ff[i].path8x16, "rb")) != NULL) {
if((fontdata=(char *)malloc(4096))!=NULL) { if ((fontdata = (char*)malloc(4096)) != NULL) {
if(fread(fontdata, 1, 4096, fontfile)==4096) { if (fread(fontdata, 1, 4096, fontfile) == 4096)
conio_fontdata[nextfont].eight_by_sixteen=fontdata; conio_fontdata[nextfont].eight_by_sixteen = fontdata;
} else
else {
free(fontdata); free(fontdata);
}
} }
fclose(fontfile); fclose(fontfile);
} }
...@@ -195,185 +186,202 @@ void load_font_files(void) ...@@ -195,185 +186,202 @@ void load_font_files(void)
} }
free_font_files(ff); free_font_files(ff);
for(i=0; conio_fontdata[i].desc != NULL; i++) { for (i = 0; conio_fontdata[i].desc != NULL; i++) {
font_names[i]=conio_fontdata[i].desc; font_names[i] = conio_fontdata[i].desc;
if(!strcmp(conio_fontdata[i].desc,"Codepage 437 English")) { if (!strcmp(conio_fontdata[i].desc, "Codepage 437 English"))
default_font=i; default_font = i;
}
} }
/* Set default font */
/* Set default font */
setfont(default_font, false, 0); setfont(default_font, false, 0);
font_names[i]=""; font_names[i] = "";
} }
int
int find_font_id(char *name) find_font_id(char*name)
{ {
int ret=0; int ret = 0;
int i; int i;
for(i=0; i<256; i++) { for (i = 0; i < 256; i++) {
if(!conio_fontdata[i].desc) if (!conio_fontdata[i].desc)
continue; continue;
if(!strcmp(conio_fontdata[i].desc,name)) { if (!strcmp(conio_fontdata[i].desc, name)) {
ret=i; ret = i;
break; break;
} }
} }
return(ret); return ret;
} }
void
void font_management(void) font_management(void)
{ {
int i,j; int i, j;
int cur=0; int cur = 0;
int bar=0; int bar = 0;
int fcur=0; int fcur = 0;
int fbar=0; int fbar = 0;
int count=0; int count = 0;
struct font_files *fonts; struct font_files*fonts;
char *opt[256]; char *opt[256];
char opts[5][80]; char opts[5][80];
struct font_files *tmp; struct font_files*tmp;
char str[128]; char str[128];
fonts=read_font_files(&count); fonts = read_font_files(&count);
opts[4][0]=0; opts[4][0] = 0;
for(;!quitting;) { for (; !quitting;) {
uifc.helpbuf= "`Font Management`\n\n" uifc.helpbuf = "`Font Management`\n\n"
"Allows you to add and remove font files to/from the default font set.\n\n" "Allows you to add and remove font files to/from the default font set.\n\n"
"`INS` Adds a new font.\n" "`INS` Adds a new font.\n"
"`DEL` Removes an existing font.\n\n" "`DEL` Removes an existing font.\n\n"
"Selecting a font allows you to set the files for all three font sizes:\n\n" "Selecting a font allows you to set the files for all three font sizes:\n\n"
"`8x8` Used for screen modes with 35 or more lines and all C64/C128 modes\n" "`8x8` Used for screen modes with 35 or more lines and all C64/C128 modes\n"
"`8x14` Used for screen modes with 28 and 34 lines\n" "`8x14` Used for screen modes with 28 and 34 lines\n"
"`8x16` Used for screen modes with 30 lines or fewer than 28 lines."; "`8x16` Used for screen modes with 30 lines or fewer than 28 lines.";
if(fonts) { if (fonts) {
for(j=0;fonts[j].name && fonts[j].name[0]; j++) for (j = 0; fonts[j].name && fonts[j].name[0]; j++)
opt[j]=fonts[j].name; opt[j] = fonts[j].name;
opt[j]=""; opt[j] = "";
} }
else { else {
opts[0][0]=0; opts[0][0] = 0;
opt[0]=opts[0]; opt[0] = opts[0];
} }
i=uifc.list(WIN_SAV|WIN_INS|WIN_INSACT|WIN_DEL|WIN_XTR|WIN_ACT,0,0,0,&cur,&bar,"Font Management",opt); i = uifc.list(WIN_SAV | WIN_INS | WIN_INSACT | WIN_DEL | WIN_XTR | WIN_ACT,
if(i==-1) { 0,
0,
0,
&cur,
&bar,
"Font Management",
opt);
if (i == -1) {
check_exit(false); check_exit(false);
save_font_files(fonts); save_font_files(fonts);
free_font_files(fonts); free_font_files(fonts);
return; return;
} }
for(;!quitting;) { for (; !quitting;) {
char *fontmask; char *fontmask;
int show_filepick=0; int show_filepick = 0;
char **path; char**path;
if(i&MSK_DEL) { if (i & MSK_DEL) {
if (fonts) { if (fonts) {
FREE_AND_NULL(fonts[cur].name); FREE_AND_NULL(fonts[cur].name);
FREE_AND_NULL(fonts[cur].path8x8); FREE_AND_NULL(fonts[cur].path8x8);
FREE_AND_NULL(fonts[cur].path8x14); FREE_AND_NULL(fonts[cur].path8x14);
FREE_AND_NULL(fonts[cur].path8x16); FREE_AND_NULL(fonts[cur].path8x16);
memmove(&(fonts[cur]),&(fonts[cur+1]),sizeof(struct font_files)*(count-cur)); memmove(&(fonts[cur]), &(fonts[cur + 1]),
sizeof(struct font_files) * (count - cur));
count--; count--;
} }
break; break;
} }
if(i&MSK_INS) { if (i & MSK_INS) {
str[0]=0; str[0] = 0;
uifc.helpbuf="Enter the name of the font as you want it to appear in menus."; uifc.helpbuf = "Enter the name of the font as you want it to appear in menus.";
if(uifc.input(WIN_SAV|WIN_MID,0,0,"Font Name",str,50,0)==-1) { if (uifc.input(WIN_SAV | WIN_MID, 0, 0, "Font Name", str, 50, 0) == -1) {
check_exit(false); check_exit(false);
break; break;
} }
count++; count++;
tmp=(struct font_files *)realloc(fonts, sizeof(struct font_files)*(count+1)); tmp = (struct font_files*)realloc(fonts, sizeof(struct font_files) * (count + 1));
if(tmp==NULL) { if (tmp == NULL) {
uifc.msg("realloc() failure, cannot add font."); uifc.msg("realloc() failure, cannot add font.");
check_exit(false); check_exit(false);
count--; count--;
break; break;
} }
fonts=tmp; fonts = tmp;
memmove(fonts+cur+1,fonts+cur,sizeof(struct font_files)*(count-cur)); memmove(fonts + cur + 1, fonts + cur, sizeof(struct font_files) * (count - cur));
memset(&(fonts[count]),0,sizeof(fonts[count])); memset(&(fonts[count]), 0, sizeof(fonts[count]));
fonts[cur].name=strdup(str); fonts[cur].name = strdup(str);
fonts[cur].path8x8=NULL; fonts[cur].path8x8 = NULL;
fonts[cur].path8x14=NULL; fonts[cur].path8x14 = NULL;
fonts[cur].path8x16=NULL; fonts[cur].path8x16 = NULL;
} }
for(i=0; i<5; i++) for (i = 0; i < 5; i++)
opt[i]=opts[i]; opt[i] = opts[i];
uifc.helpbuf="`Font Details`\n\n" uifc.helpbuf = "`Font Details`\n\n"
"`8x8` Used for screen modes with 35 or more lines and all C64/C128 modes\n" "`8x8` Used for screen modes with 35 or more lines and all C64/C128 modes\n"
"`8x14` Used for screen modes with 28 and 34 lines\n" "`8x14` Used for screen modes with 28 and 34 lines\n"
"`8x16` Used for screen modes with 30 lines or fewer than 28 lines."; "`8x16` Used for screen modes with 30 lines or fewer than 28 lines.";
sprintf(opts[0],"Name: %.50s",fonts[cur].name?fonts[cur].name:"<undefined>"); sprintf(opts[0], "Name: %.50s", fonts[cur].name ? fonts[cur].name : "<undefined>");
sprintf(opts[1],"8x8 %.50s",fonts[cur].path8x8?fonts[cur].path8x8:"<undefined>"); sprintf(opts[1], "8x8 %.50s", fonts[cur].path8x8 ? fonts[cur].path8x8 : "<undefined>");
sprintf(opts[2],"8x14 %.50s",fonts[cur].path8x14?fonts[cur].path8x14:"<undefined>"); sprintf(opts[2], "8x14 %.50s", fonts[cur].path8x14 ? fonts[cur].path8x14 : "<undefined>");
sprintf(opts[3],"8x16 %.50s",fonts[cur].path8x16?fonts[cur].path8x16:"<undefined>"); sprintf(opts[3], "8x16 %.50s", fonts[cur].path8x16 ? fonts[cur].path8x16 : "<undefined>");
opts[4][0]=0; opts[4][0] = 0;
i=uifc.list(WIN_SAV|WIN_ACT|WIN_INS|WIN_INSACT|WIN_DEL|WIN_RHT|WIN_BOT,0,0,0,&fcur,&fbar,"Font Details",opt); i = uifc.list(WIN_SAV | WIN_ACT | WIN_INS | WIN_INSACT | WIN_DEL | WIN_RHT | WIN_BOT,
if(i==-1) { 0,
0,
0,
&fcur,
&fbar,
"Font Details",
opt);
if (i == -1) {
check_exit(false); check_exit(false);
break; break;
} }
switch(i) { switch (i) {
case 0: case 0:
SAFECOPY(str,fonts[cur].name); SAFECOPY(str, fonts[cur].name);
uifc.helpbuf="Enter the name of the font as you want it to appear\nin menus."; uifc.helpbuf = "Enter the name of the font as you want it to appear\nin menus.";
if (uifc.input(WIN_SAV|WIN_MID,0,0,"Font Name",str,50,K_EDIT)==-1) if (uifc.input(WIN_SAV | WIN_MID, 0, 0, "Font Name", str, 50, K_EDIT) == -1) {
check_exit(false); check_exit(false);
}
else { else {
FREE_AND_NULL(fonts[cur].name); FREE_AND_NULL(fonts[cur].name);
fonts[cur].name=strdup(str); fonts[cur].name = strdup(str);
show_filepick=0; show_filepick = 0;
} }
break; break;
case 1: case 1:
sprintf(str,"8x8 %.50s",fonts[cur].name); sprintf(str, "8x8 %.50s", fonts[cur].name);
path=&(fonts[cur].path8x8); path = &(fonts[cur].path8x8);
fontmask="*.f8"; fontmask = "*.f8";
show_filepick=1; show_filepick = 1;
break; break;
case 2: case 2:
sprintf(str,"8x14 %.50s",fonts[cur].name); sprintf(str, "8x14 %.50s", fonts[cur].name);
path=&(fonts[cur].path8x14); path = &(fonts[cur].path8x14);
fontmask="*.f14"; fontmask = "*.f14";
show_filepick=1; show_filepick = 1;
break; break;
case 3: case 3:
sprintf(str,"8x16 %.50s",fonts[cur].name); sprintf(str, "8x16 %.50s", fonts[cur].name);
path=&(fonts[cur].path8x16); path = &(fonts[cur].path8x16);
fontmask="*.f16"; fontmask = "*.f16";
show_filepick=1; show_filepick = 1;
break; break;
} }
if(show_filepick && !safe_mode) { if (show_filepick && !safe_mode) {
int result; int result;
struct file_pick fpick; struct file_pick fpick;
struct vmem_cell *savbuf; struct vmem_cell*savbuf;
struct text_info ti; struct text_info ti;
gettextinfo(&ti); gettextinfo(&ti);
savbuf=alloca((ti.screenheight-2)*ti.screenwidth*sizeof(*savbuf)); savbuf = alloca((ti.screenheight - 2) * ti.screenwidth * sizeof(*savbuf));
if(savbuf==NULL) { if (savbuf == NULL) {
uifc.helpbuf="malloc() has failed. Available Memory is dangerously low."; uifc.helpbuf = "malloc() has failed. Available Memory is dangerously low.";
uifc.msg("malloc() failure."); uifc.msg("malloc() failure.");
check_exit(false); check_exit(false);
continue; continue;
} }
vmem_gettext(1,2,ti.screenwidth,ti.screenheight-1,savbuf); vmem_gettext(1, 2, ti.screenwidth, ti.screenheight - 1, savbuf);
result=filepick(&uifc, str, &fpick, ".", fontmask, UIFC_FP_ALLOWENTRY); result = filepick(&uifc, str, &fpick, ".", fontmask, UIFC_FP_ALLOWENTRY);
if(result!=-1 && fpick.files>0) { if ((result != -1) && (fpick.files > 0)) {
FREE_AND_NULL(*path); FREE_AND_NULL(*path);
*(path)=strdup(fpick.selected[0]); *(path) = strdup(fpick.selected[0]);
} }
else else {
check_exit(false); check_exit(false);
}
filepick_free(&fpick); filepick_free(&fpick);
vmem_puttext(1,2,ti.screenwidth,ti.screenheight-1,savbuf); vmem_puttext(1, 2, ti.screenwidth, ti.screenheight - 1, savbuf);
} }
} }
} }
......
...@@ -4,17 +4,17 @@ ...@@ -4,17 +4,17 @@
#define _SYNCTERM_FONTS_H #define _SYNCTERM_FONTS_H
struct font_files { struct font_files {
char *name; char*name;
char *path8x8; char*path8x8;
char *path8x14; char*path8x14;
char *path8x16; char*path8x16;
}; };
void free_font_files(struct font_files *ff); void free_font_files(struct font_files*ff);
void save_font_files(struct font_files *fonts); void save_font_files(struct font_files*fonts);
struct font_files *read_font_files(int *count); struct font_files *read_font_files(int*count);
void load_font_files(void); void load_font_files(void);
int find_font_id(char *name); int find_font_id(char*name);
void font_management(void); void font_management(void);
#endif #endif // ifndef _SYNCTERM_FONTS_H
...@@ -2,73 +2,78 @@ ...@@ -2,73 +2,78 @@
/* $Id: menu.c,v 1.67 2020/05/07 18:12:10 deuce Exp $ */ /* $Id: menu.c,v 1.67 2020/05/07 18:12:10 deuce Exp $ */
#include <ciolib.h>
#include <genwrap.h> #include <genwrap.h>
#include <uifc.h> #include <uifc.h>
#include <ciolib.h>
#include <vidmodes.h> #include <vidmodes.h>
#include "bbslist.h"
#include "conn.h"
#include "cterm.h" #include "cterm.h"
#include "syncterm.h"
#include "term.h" #include "term.h"
#include "uifcinit.h" #include "uifcinit.h"
#include "bbslist.h"
#include "conn.h"
#include "window.h" #include "window.h"
#include "syncterm.h" void
viewscroll(void)
void viewscroll(void)
{ {
int top; int top;
int key; int key;
int i; int i;
struct vmem_cell *scrollback; struct vmem_cell *scrollback;
struct text_info txtinfo; struct text_info txtinfo;
int x,y; int x, y;
struct mouse_event mevent; struct mouse_event mevent;
struct ciolib_screen *savscrn; struct ciolib_screen*savscrn;
x=wherex(); x = wherex();
y=wherey(); y = wherey();
uifcbail(); uifcbail();
gettextinfo(&txtinfo); gettextinfo(&txtinfo);
/* too large for alloca() */
scrollback=malloc((scrollback_buf==NULL?0:(term.width*sizeof(*scrollback)*settings.backlines))+(txtinfo.screenheight*txtinfo.screenwidth*sizeof(*scrollback))); /* too large for alloca() */
if(scrollback==NULL) scrollback =
malloc((scrollback_buf
== NULL ? 0 : (term.width * sizeof(*scrollback) * settings.backlines))
+ (txtinfo.screenheight * txtinfo.screenwidth * sizeof(*scrollback)));
if (scrollback == NULL)
return; return;
memcpy(scrollback,cterm->scrollback,term.width*sizeof(*scrollback)*settings.backlines); memcpy(scrollback, cterm->scrollback, term.width * sizeof(*scrollback) * settings.backlines);
vmem_gettext(1,1,txtinfo.screenwidth,txtinfo.screenheight,scrollback+(cterm->backpos)*cterm->width); vmem_gettext(1, 1, txtinfo.screenwidth, txtinfo.screenheight, scrollback + (cterm->backpos) * cterm->width);
savscrn = savescreen(); savscrn = savescreen();
setfont(0, false, 1); setfont(0, false, 1);
setfont(0, false, 2); setfont(0, false, 2);
setfont(0, false, 3); setfont(0, false, 3);
setfont(0, false, 4); setfont(0, false, 4);
drawwin(); drawwin();
top=cterm->backpos; top = cterm->backpos;
set_modepalette(palettes[COLOUR_PALETTE]); set_modepalette(palettes[COLOUR_PALETTE]);
gotoxy(1,1); gotoxy(1, 1);
textattr(uifc.hclr|(uifc.bclr<<4)|BLINK); textattr(uifc.hclr | (uifc.bclr << 4) | BLINK);
ciomouse_addevent(CIOLIB_BUTTON_4_PRESS); ciomouse_addevent(CIOLIB_BUTTON_4_PRESS);
ciomouse_addevent(CIOLIB_BUTTON_5_PRESS); ciomouse_addevent(CIOLIB_BUTTON_5_PRESS);
for(i=0;(!i) && (!quitting);) { for (i = 0; (!i) && (!quitting);) {
if(top<1) if (top < 1)
top=1; top = 1;
if(top>cterm->backpos) if (top > cterm->backpos)
top=cterm->backpos; top = cterm->backpos;
vmem_puttext(term.x-1,term.y-1,term.x+term.width-2,term.y+term.height-2,scrollback+(term.width*top)); vmem_puttext(term.x - 1, term.y - 1, term.x + term.width - 2, term.y + term.height - 2,
scrollback + (term.width * top));
cputs("Scrollback"); cputs("Scrollback");
gotoxy(cterm->width-9,1); gotoxy(cterm->width - 9, 1);
cputs("Scrollback"); cputs("Scrollback");
gotoxy(1,1); gotoxy(1, 1);
key=getch(); key = getch();
switch(key) { switch (key) {
case 0xe0: case 0xe0:
case 0: case 0:
switch(key|getch()<<8) { switch (key | getch() << 8) {
case CIO_KEY_QUIT: case CIO_KEY_QUIT:
check_exit(true); check_exit(true);
break; break;
case CIO_KEY_MOUSE: case CIO_KEY_MOUSE:
getmouse(&mevent); getmouse(&mevent);
switch(mevent.event) { switch (mevent.event) {
case CIOLIB_BUTTON_1_DRAG_START: case CIOLIB_BUTTON_1_DRAG_START:
mousedrag(scrollback); mousedrag(scrollback);
break; break;
...@@ -89,18 +94,18 @@ void viewscroll(void) ...@@ -89,18 +94,18 @@ void viewscroll(void)
top++; top++;
break; break;
case CIO_KEY_PPAGE: case CIO_KEY_PPAGE:
top-=term.height; top -= term.height;
break; break;
case CIO_KEY_NPAGE: case CIO_KEY_NPAGE:
top+=term.height; top += term.height;
break; break;
case CIO_KEY_F(1): case CIO_KEY_F(1):
init_uifc(false, false); init_uifc(false, false);
uifc.helpbuf= "`Scrollback Buffer`\n\n" uifc.helpbuf = "`Scrollback Buffer`\n\n"
"~ J ~ or ~ Up Arrow ~ Scrolls up one line\n" "~ J ~ or ~ Up Arrow ~ Scrolls up one line\n"
"~ K ~ or ~ Down Arrow ~ Scrolls down one line\n" "~ K ~ or ~ Down Arrow ~ Scrolls down one line\n"
"~ H ~ or ~ Page Up ~ Scrolls up one screen\n" "~ H ~ or ~ Page Up ~ Scrolls up one screen\n"
"~ L ~ or ~ Page Down ~ Scrolls down one screen\n"; "~ L ~ or ~ Page Down ~ Scrolls down one screen\n";
uifc.showhelp(); uifc.showhelp();
check_exit(false); check_exit(false);
uifcbail(); uifcbail();
...@@ -118,154 +123,155 @@ void viewscroll(void) ...@@ -118,154 +123,155 @@ void viewscroll(void)
break; break;
case 'h': case 'h':
case 'H': case 'H':
top-=term.height; top -= term.height;
break; break;
case 'l': case 'l':
case 'L': case 'L':
top+=term.height; top += term.height;
break; break;
case ESC: case ESC:
i=1; i = 1;
break; break;
} }
} }
restorescreen(savscrn); restorescreen(savscrn);
gotoxy(x,y); gotoxy(x, y);
free(scrollback); free(scrollback);
freescreen(savscrn); freescreen(savscrn);
return; return;
} }
int
int syncmenu(struct bbslist *bbs, int *speed) syncmenu(struct bbslist*bbs, int*speed)
{ {
char *opts[]={ char *opts[] = {
"Scrollback ("ALT_KEY_NAMEP"-B)" "Scrollback ("ALT_KEY_NAMEP "-B)"
,"Disconnect (Ctrl-Q)" , "Disconnect (Ctrl-Q)"
,"Send Login ("ALT_KEY_NAMEP"-L)" , "Send Login ("ALT_KEY_NAMEP "-L)"
,"Upload ("ALT_KEY_NAMEP"-U)" , "Upload ("ALT_KEY_NAMEP "-U)"
,"Download ("ALT_KEY_NAMEP"-D)" , "Download ("ALT_KEY_NAMEP "-D)"
,"Change Output Rate (" ALT_KEY_NAMEP "-Up/" ALT_KEY_NAMEP "-Down)" , "Change Output Rate (" ALT_KEY_NAMEP "-Up/" ALT_KEY_NAMEP "-Down)"
,"Change Log Level" , "Change Log Level"
,"Capture Control ("ALT_KEY_NAMEP"-C)" , "Capture Control ("ALT_KEY_NAMEP "-C)"
,"ANSI Music Control ("ALT_KEY_NAMEP"-M)" , "ANSI Music Control ("ALT_KEY_NAMEP "-M)"
,"Font Setup ("ALT_KEY_NAMEP"-F)" , "Font Setup ("ALT_KEY_NAMEP "-F)"
,"Toggle Doorway Mode" , "Toggle Doorway Mode"
#ifndef WITHOUT_OOII #ifndef WITHOUT_OOII
,"Toggle Operation Overkill ][ Mode" , "Toggle Operation Overkill ][ Mode"
#endif #endif
,"Exit ("ALT_KEY_NAMEP"-X)" , "Exit ("ALT_KEY_NAMEP "-X)"
,"Edit Dialing Directory ("ALT_KEY_NAMEP"-E)" , "Edit Dialing Directory ("ALT_KEY_NAMEP "-E)"
,""}; , ""
int opt=0; };
int i,j; int opt = 0;
struct text_info txtinfo; int i, j;
struct ciolib_screen *savscrn; struct text_info txtinfo;
int ret; struct ciolib_screen*savscrn;
int ret;
gettextinfo(&txtinfo); gettextinfo(&txtinfo);
savscrn = savescreen(); savscrn = savescreen();
setfont(0, false, 1); setfont(0, false, 1);
setfont(0, false, 2); setfont(0, false, 2);
setfont(0, false, 3); setfont(0, false, 3);
setfont(0, false, 4); setfont(0, false, 4);
if(cio_api.mode!=CIOLIB_MODE_CURSES if ((cio_api.mode != CIOLIB_MODE_CURSES)
&& cio_api.mode!=CIOLIB_MODE_CURSES_IBM && (cio_api.mode != CIOLIB_MODE_CURSES_IBM)
&& cio_api.mode!=CIOLIB_MODE_ANSI) { && (cio_api.mode != CIOLIB_MODE_ANSI))
opts[1]="Disconnect ("ALT_KEY_NAMEP"-H)"; opts[1] = "Disconnect ("ALT_KEY_NAMEP "-H)";
}
for(ret=0;(!ret) && (!quitting);) { for (ret = 0; (!ret) && (!quitting);) {
init_uifc(false, !(bbs->nostatus)); init_uifc(false, !(bbs->nostatus));
uifc.helpbuf= "`Online Menu`\n\n" uifc.helpbuf = "`Online Menu`\n\n"
"`Scrollback` Allows to you to view the scrollback buffer\n" "`Scrollback` Allows to you to view the scrollback buffer\n"
"`Disconnect` Disconnects the current connection\n" "`Disconnect` Disconnects the current connection\n"
"`Send Login` Sends the username and password pair separated by CR\n" "`Send Login` Sends the username and password pair separated by CR\n"
"`Upload` Initiates a file upload\n" "`Upload` Initiates a file upload\n"
"`Download` Initiates a file download\n" "`Download` Initiates a file download\n"
"`Output Rate` Changes the speed characters are output to the screen\n" "`Output Rate` Changes the speed characters are output to the screen\n"
"`Log Level` Changes the minimum log level for transfer information\n" "`Log Level` Changes the minimum log level for transfer information\n"
"`Capture` Enables/Disables screen capture\n" "`Capture` Enables/Disables screen capture\n"
"`ANSI Music` Enables/Disables ANSI Music\n" "`ANSI Music` Enables/Disables ANSI Music\n"
"`Font` Changes the current font (when supported)\n" "`Font` Changes the current font (when supported)\n"
"`Doorway Mode` Toggles the current DoorWay (keyboard input) setting\n" "`Doorway Mode` Toggles the current DoorWay (keyboard input) setting\n"
#ifndef WITHOUT_OOII #ifndef WITHOUT_OOII
"`Operation Overkill ][ Mode`\n" "`Operation Overkill ][ Mode`\n"
" Toggles the current Operation Overkill ][ setting\n" " Toggles the current Operation Overkill ][ setting\n"
#endif #endif
"`Exit` Disconnects and closes Syncterm\n" "`Exit` Disconnects and closes Syncterm\n"
"`Edit Dialing Directory`\n" "`Edit Dialing Directory`\n"
" Opens the directory/setting menu\n"; " Opens the directory/setting menu\n";
i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&opt,NULL,"SyncTERM Online Menu",opts); i = uifc.list(WIN_MID | WIN_SAV, 0, 0, 0, &opt, NULL, "SyncTERM Online Menu", opts);
switch(i) { switch (i) {
case -1: /* Cancel */ case -1: /* Cancel */
check_exit(false); check_exit(false);
ret=1; ret = 1;
break; break;
case 0: /* Scrollback */ case 0: /* Scrollback */
uifcbail(); uifcbail();
restorescreen(savscrn); restorescreen(savscrn);
viewscroll(); viewscroll();
break; break;
case 1: /* Disconnect */ case 1: /* Disconnect */
ret=-1; ret = -1;
break; break;
case 2: /* Login */ case 2: /* Login */
ret=1; ret = 1;
conn_send(bbs->user,strlen(bbs->user),0); conn_send(bbs->user, strlen(bbs->user), 0);
conn_send("\r",1,0); conn_send("\r", 1, 0);
SLEEP(10); SLEEP(10);
conn_send(bbs->password,strlen(bbs->password),0); conn_send(bbs->password, strlen(bbs->password), 0);
conn_send("\r",1,0); conn_send("\r", 1, 0);
if(bbs->syspass[0]) { if (bbs->syspass[0]) {
SLEEP(10); SLEEP(10);
conn_send(bbs->syspass,strlen(bbs->syspass),0); conn_send(bbs->syspass, strlen(bbs->syspass), 0);
conn_send("\r",1,0); conn_send("\r", 1, 0);
} }
break; break;
case 5: /* Output rate */ case 5: /* Output rate */
if(bbs->conn_type==CONN_TYPE_MODEM || bbs->conn_type==CONN_TYPE_SERIAL || bbs->conn_type == CONN_TYPE_SERIAL_NORTS) { if ((bbs->conn_type == CONN_TYPE_MODEM) || (bbs->conn_type == CONN_TYPE_SERIAL)
|| (bbs->conn_type == CONN_TYPE_SERIAL_NORTS)) {
uifcmsg("Not supported for this connection type" uifcmsg("Not supported for this connection type"
,"Cannot change the display rate for Modem/Serial connections."); , "Cannot change the display rate for Modem/Serial connections.");
} }
else if(speed != NULL) { else if (speed != NULL) {
j=get_rate_num(*speed); j = get_rate_num(*speed);
uifc.helpbuf="`Output Rate`\n\n" uifc.helpbuf = "`Output Rate`\n\n"
"The output rate is the rate in emulated \"bits per second\" to draw incoming\n" "The output rate is the rate in emulated \"bits per second\" to draw incoming\n"
"data on the screen. This rate is a maximum, not guaranteed to be attained\n" "data on the screen. This rate is a maximum, not guaranteed to be attained\n"
"In general, you will only use this option for ANSI animations."; "In general, you will only use this option for ANSI animations.";
i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,NULL,"Output Rate",rate_names); i = uifc.list(WIN_MID | WIN_SAV, 0, 0, 0, &j, NULL, "Output Rate", rate_names);
if (i==-1) if (i == -1)
check_exit(false); check_exit(false);
if(i>=0) if (i >= 0)
*speed = rates[i]; *speed = rates[i];
} }
ret=5; ret = 5;
break; break;
case 6: /* Change log level (temporarily) */ case 6: /* Change log level (temporarily) */
j=log_level; j = log_level;
uifc.helpbuf="`Log Level\n\n" uifc.helpbuf = "`Log Level\n\n"
"The log level changes the verbosity of messages shown in the transfer\n" "The log level changes the verbosity of messages shown in the transfer\n"
"window. For the selected log level, messages of that level and those above\n" "window. For the selected log level, messages of that level and those above\n"
"it will be displayed."; "it will be displayed.";
i=uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,NULL,"Log Level",log_levels); i = uifc.list(WIN_MID | WIN_SAV, 0, 0, 0, &j, NULL, "Log Level", log_levels);
if (i==-1) if (i == -1)
check_exit(false); check_exit(false);
if(i>=0) if (i >= 0)
log_level = j; log_level = j;
ret=6; ret = 6;
break; break;
default: default:
ret=i; ret = i;
uifcbail(); uifcbail();
restorescreen(savscrn); restorescreen(savscrn);
freescreen(savscrn); freescreen(savscrn);
return(ret); return ret;
} }
} }
uifcbail(); uifcbail();
restorescreen(savscrn); restorescreen(savscrn);
freescreen(savscrn); freescreen(savscrn);
return(ret); return ret;
} }
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
#define _MENU_H_ #define _MENU_H_
#include "bbslist.h" #include "bbslist.h"
int syncmenu(struct bbslist*, int*speed);
int syncmenu(struct bbslist *, int *speed);
void viewscroll(void); void viewscroll(void);
#endif #endif
This diff is collapsed.
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
#define _MODEM_H_ #define _MODEM_H_
#include "bbslist.h" #include "bbslist.h"
int modem_connect(struct bbslist*bbs);
int modem_connect(struct bbslist *bbs);
int serial_close(void); int serial_close(void);
int modem_close(void); int modem_close(void);
......
This diff is collapsed.
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <stdbool.h> #include <stdbool.h>
#define MAX_OOII_MODE 3 #define MAX_OOII_MODE 3
bool handle_ooii_code(unsigned char*codeStr, int*ooii_mode, unsigned char*retbuf, size_t retsize);
bool handle_ooii_code(unsigned char *codeStr, int *ooii_mode, unsigned char *retbuf, size_t retsize);
#endif #endif
This diff is collapsed.
#ifndef _BMENUS_H_ #ifndef _BMENUS_H_
#define _BMENUS_H_ #define _BMENUS_H_
extern const unsigned char *ooii_bmenus[3][6]; extern const unsigned char*ooii_bmenus[3][6];
#endif #endif
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment