1 /* ----------------------------------------------------------------------- *
3 * Copyright 2008 Gene Cumm - All Rights Reserved
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 * Boston MA 02111-1307, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
16 * Read-Only shell; Header
21 * b021 Move much PreProcessing stuff to rosh.h
22 * b018 Create rosh_debug() macro
23 * b012 Version of rosh.c at time of creating this file.
31 #include <stdbool.h> /* macro: true false */
32 #include <string.h> /* strcpy() strlen() memcpy() strchr() */
33 #include <sys/types.h>
34 #include <sys/stat.h> /* fstat() */
35 #include <fcntl.h> /* open(); open mode macros */
36 #include <dirent.h> /* fdopendir() opendir() readdir() closedir() DIR */
37 #include <unistd.h> /* getcwd() */
38 #include <errno.h> /* errno; error macros */
39 #include <netinet/in.h> /* For htonl/ntohl/htons/ntohs */
44 /* A GNUC extension to void out unused functions are used */
45 /* Plus, there seem to be other references for SYSLINUX to __GNUC__ */
47 #error SYSLINUX (I believe) requires __GNUC__
51 #define ROSH_DEBUG(f, ...) printf (f, ## __VA_ARGS__)
53 #define ROSH_DEBUG2(f, ...) printf (f, ## __VA_ARGS__)
55 #define ROSH_DEBUG2(f, ...) ((void)0)
56 #endif /* DO_DEBUG2 */
58 #define ROSH_DEBUG(f, ...) ((void)0)
59 #define ROSH_DEBUG2(f, ...) ((void)0)
63 #define ROSH_IS_COM32 1
64 #include <console.h> /* openconsole() */
65 #include <syslinux/config.h> /* Has info on the SYSLINUX variant */
66 #include <syslinux/boot.h> /* syslinux_run_command() */
67 #define ROSH_COM32(f, ...) printf (f, ## __VA_ARGS__)
70 #define ROSH_IS_COM32 0
71 static inline char *syslinux_config_file()
76 static inline int getscreensize(int fd
, int *rows
, int *cols
)
83 str
= getenv("LINES");
89 str
= getenv("COLUMNS");
96 else if (!*rows
|| !*cols
)
103 #define ROSH_COM32(f, ...) ((void)0)
104 #define syslinux_run_command(f) ((void)0)
105 #endif /* __COM32__ */
109 /* Size of buffer string */
110 #define ROSH_BUF_SZ 16384
111 /* Size of screen output buffer (80*40) */
112 #define ROSH_SBUF_SZ 1200
114 /* Size of command buffer string */
115 #ifdef MAX_CMDLINE_LEN
116 #define ROSH_CMD_SZ MAX_CMDLINE_LEN
118 #ifdef COMMAND_LINE_SIZE
119 #define ROSH_CMD_SZ COMMAND_LINE_SIZE
121 #define ROSH_CMD_SZ 2048
122 #endif /* COMMAND_LINE_SIZE */
123 #endif /* MAX_CMDLINE_LEN */
125 /* Size of path buffer string */
127 #define ROSH_PATH_SZ PATH_MAX
129 #define ROSH_PATH_SZ NAME_MAX
131 #define ROSH_PATH_SZ 255
132 #endif /* NAME_MAX */
134 const char rosh_help_str1
[] =
135 "Commands: ? cat cd cfg dir exit help less ls man more pwd run quit ver";
137 const char rosh_help_str2
[] =
138 "Commands: (some 1-letter abreviations also allowed)\n\
139 h HELP\n ALSO ? help man\n\
140 cat Concatenate file to console\n cat <file>\n\
141 cd Change to directory <dir>\n cd <dir>\n\
142 less Page a file with rewind\n\
143 ls List contents of current directory\n ls <dir>\n\
146 pwd display Present Working Directory\n\
147 run Run a program/kernel with options\n\
148 exit Exit to previous environment\n ALSO quit";
150 #endif /* Not ROSH_H */