Skip to content
Snippets Groups Projects
Commit 66e922ad authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add telnet_opt_enabled() function that returns true for WILL or DO opt status

An option is enabled/supported regardless of which end makes the request, so
the status can be WILL (an ACK to a remote request) or DO (an ACK to a local
request) when an option is enabled.
parent e042d5d9
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
/* telnet.c */
/* Synchronet telnet command/option functions */ /* Synchronet telnet command/option functions */
/* $Id: telnet.c,v 1.10 2019/08/24 19:37:11 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -17,21 +13,9 @@ ...@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -149,6 +133,11 @@ uchar telnet_opt_nak(uchar cmd) ...@@ -149,6 +133,11 @@ uchar telnet_opt_nak(uchar cmd)
return 0; return 0;
} }
bool telnet_opt_enabled(uchar val)
{
return (val == TELNET_DO) || (val == TELNET_WILL);
}
/*****************************************************************************/ /*****************************************************************************/
// 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
......
/* telnet.h */
/* Synchronet telnet-related constants and function prototypes */ /* Synchronet telnet-related constants and function prototypes */
/* $Id: telnet.h,v 1.21 2019/08/24 19:37:11 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
...@@ -17,21 +13,9 @@ ...@@ -17,21 +13,9 @@
* See the GNU General Public License for more details: gpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html * * http://www.fsf.org/copyleft/gpl.html *
* * * *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -39,6 +23,7 @@ ...@@ -39,6 +23,7 @@
#define _TELNET_H #define _TELNET_H
#include "gen_defs.h" /* uchar */ #include "gen_defs.h" /* uchar */
#include <stdbool.h>
/* commands */ /* commands */
...@@ -165,6 +150,7 @@ DLLEXPORT const char* telnet_cmd_desc(uchar cmd); ...@@ -165,6 +150,7 @@ DLLEXPORT const char* telnet_cmd_desc(uchar cmd);
DLLEXPORT const char* telnet_opt_desc(uchar opt); DLLEXPORT const char* telnet_opt_desc(uchar opt);
DLLEXPORT uchar telnet_opt_ack(uchar cmd); DLLEXPORT uchar telnet_opt_ack(uchar cmd);
DLLEXPORT uchar telnet_opt_nak(uchar cmd); DLLEXPORT uchar telnet_opt_nak(uchar cmd);
DLLEXPORT bool telnet_opt_enabled(uchar value);
DLLEXPORT size_t telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf, size_t outlen DLLEXPORT size_t telnet_expand(const uchar* inbuf, size_t inlen, uchar* outbuf, size_t outlen
,BOOL expand_cr, uchar** result); ,BOOL expand_cr, uchar** result);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment