new toybox command ASCII

This commit is contained in:
joonicks
2018-03-26 01:52:24 +02:00
parent bb8893c188
commit c44d8598c6
7 changed files with 51 additions and 28 deletions

View File

@@ -158,6 +158,7 @@ struct
{ 0, "PICKUP", "do_random_msg", 50 | CCPW , RANDPICKUPFILE },
{ 0, "RSAY", "do_random_msg", 50 | CCPW , RANDSAYFILE },
{ 0, "RT", "do_randtopic", 50 | CCPW | CAXS | ACCHAN },
{ 0, "ASCII", "do_ascii", 50 | CCPW | CAXS | CARGS },
#endif /* TOYBOX */
#ifdef TRIVIA
{ 0, "TRIVIA", "do_trivia", 50 | CCPW | CAXS | CARGS | CBANG },

View File

@@ -210,6 +210,9 @@ LS int SockOpts(void) __page(CORE_SEG);
/* tcl.c */
/* telnet.c */
/* toybox.c */
LS void do_ascii(COMMAND_ARGS) __page(CMD1_SEG);
/* trivia.c */
/* uptime.c */
/* urlcap.c */

View File

@@ -344,4 +344,29 @@ void do_8ball(COMMAND_ARGS)
to_user_q(from,FMT_PLAIN,message);
}
char *ascii_from;
int read_ascii(char *rest)
{
to_user_q(ascii_from,FMT_PLAIN,rest);
}
void do_ascii(COMMAND_ARGS)
{
char fname[MSGLEN];
int fd;
Strcat(Strcpy(fname,"ascii/"),rest);
#ifdef DEBUG
debug("(do_ascii) file = \"%s\"\n",fname);
#endif
if (is_safepath(fname,FILE_MUST_EXIST) != FILE_IS_SAFE)
return;
if ((fd = open(fname,O_RDONLY)) < 0)
return;
ascii_from = from;
readline(fd,&read_ascii); /* readline closes fd */
}
#endif /* TOYBOX */