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

@@ -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 */