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__
53 #define ROSH_DEBUG(f, ...) printf (f, ## __VA_ARGS__)
55 #define ROSH_DEBUG2(f, ...) printf (f, ## __VA_ARGS__)
57 #define ROSH_DEBUG2(f, ...) ((void)0)
58 #endif /* DO_DEBUG2 */
60 #define ROSH_DEBUG(f, ...) ((void)0)
61 #define ROSH_DEBUG2(f, ...) ((void)0)
65 #define ROSH_IS_COM32 1
66 #include <console.h> /* openconsole() */
67 #include <syslinux/config.h> /* Has info on the SYSLINUX variant */
68 #include <syslinux/boot.h> /* syslinux_run_command() */
69 #define ROSH_COM32(f, ...) printf (f, ## __VA_ARGS__)
72 #define ROSH_IS_COM32 0
73 static inline char *syslinux_config_file()
78 static inline int getscreensize(int fd
, int *rows
, int *cols
)
85 str
= getenv("LINES");
91 str
= getenv("COLUMNS");
98 else if (!*rows
|| !*cols
)
105 #define ROSH_COM32(f, ...) ((void)0)
106 #define syslinux_run_command(f) ((void)0)
107 #endif /* __COM32__ */
111 /* Size of buffer string */
112 #define ROSH_BUF_SZ 16384
113 /* Size of screen output buffer (80*40) */
114 #define ROSH_SBUF_SZ 1200
116 /* Size of command buffer string */
117 #ifdef MAX_CMDLINE_LEN
118 #define ROSH_CMD_SZ MAX_CMDLINE_LEN
120 #ifdef COMMAND_LINE_SIZE
121 #define ROSH_CMD_SZ COMMAND_LINE_SIZE
123 #define ROSH_CMD_SZ 2048
124 #endif /* COMMAND_LINE_SIZE */
125 #endif /* MAX_CMDLINE_LEN */
127 /* Size of path buffer string */
129 #define ROSH_PATH_SZ PATH_MAX
131 #define ROSH_PATH_SZ NAME_MAX
133 #define ROSH_PATH_SZ 255
134 #endif /* NAME_MAX */
136 const char rosh_help_str1
[] =
137 "Commands: ? cat cd cfg dir exit help less ls man more pwd run quit ver";
139 const char rosh_help_str2
[] =
140 "Commands: (some 1-letter abreviations also allowed)\n\
141 h HELP\n ALSO ? help man\n\
142 cat Concatenate file to console\n cat <file>\n\
143 cd Change to directory <dir>\n cd <dir>\n\
144 less Page a file with rewind\n\
145 ls List contents of current directory\n ls <dir>\n\
148 pwd display Present Working Directory\n\
149 run Run a program/kernel with options\n\
150 exit Exit to previous environment\n ALSO quit";
152 #endif /* Not ROSH_H */