mirror of
https://github.com/EnergyMech/energymech.git
synced 2025-12-29 16:14:43 +00:00
new toybox command ASCII
This commit is contained in:
@@ -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 },
|
||||
|
||||
3
src/h.h
3
src/h.h
@@ -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 */
|
||||
|
||||
25
src/toybox.c
25
src/toybox.c
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user