Adding upstream version 4.00~pre53+dfsg.
[syslinux-debian/hramrach.git] / com32 / rosh / rosh.h
blob0c41bac90e374ba971911ec4cb2988fad4169e1c
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 * ----------------------------------------------------------------------- */
14 * rosh.h
16 * Read-Only shell; Header
20 * History
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.
26 #ifndef ROSH_H
27 #define ROSH_H
29 #include <stdio.h>
30 #include <stdlib.h>
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 */
41 #include <getkey.h>
42 #include <consoles.h>
44 /* A GNUC extension to void out unused functions are used */
45 /* Plus, there seem to be other references for SYSLINUX to __GNUC__ */
46 #ifndef __GNUC__
47 #error SYSLINUX (I believe) requires __GNUC__
48 #endif /* __GNUC__ */
50 #define DO_DEBUG 1
52 #ifdef DO_DEBUG
53 #define ROSH_DEBUG(f, ...) printf (f, ## __VA_ARGS__)
54 #ifdef DO_DEBUG2
55 #define ROSH_DEBUG2(f, ...) printf (f, ## __VA_ARGS__)
56 #else /* DO_DEBUG2 */
57 #define ROSH_DEBUG2(f, ...) ((void)0)
58 #endif /* DO_DEBUG2 */
59 #else /* DO_DEBUG */
60 #define ROSH_DEBUG(f, ...) ((void)0)
61 #define ROSH_DEBUG2(f, ...) ((void)0)
62 #endif /* DO_DEBUG */
64 #ifdef __COM32__
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__)
70 #else
71 #include <termios.h>
72 #define ROSH_IS_COM32 0
73 static inline char *syslinux_config_file()
75 return "";
78 static inline int getscreensize(int fd, int *rows, int *cols)
80 char *str;
81 int rv;
82 *rows = 0;
83 *cols = 0;
84 if (rows) {
85 str = getenv("LINES");
86 if (str) {
87 *rows = atoi(str);
90 if (cols) {
91 str = getenv("COLUMNS");
92 if (str) {
93 *cols = atoi(str);
96 if (!rows || !cols)
97 rv = -1;
98 else if (!*rows || !*cols)
99 rv = -2;
100 else
101 rv = 0;
102 return rv;
105 #define ROSH_COM32(f, ...) ((void)0)
106 #define syslinux_run_command(f) ((void)0)
107 #endif /* __COM32__ */
109 #define SEP '/'
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
119 #else
120 #ifdef COMMAND_LINE_SIZE
121 #define ROSH_CMD_SZ COMMAND_LINE_SIZE
122 #else
123 #define ROSH_CMD_SZ 2048
124 #endif /* COMMAND_LINE_SIZE */
125 #endif /* MAX_CMDLINE_LEN */
127 /* Size of path buffer string */
128 #ifdef PATH_MAX
129 #define ROSH_PATH_SZ PATH_MAX
130 #elif NAME_MAX
131 #define ROSH_PATH_SZ NAME_MAX
132 #else
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\
146 ALSO dir\n\
147 more Page a file\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 */