Adding upstream version 3.86+dfsg.
[syslinux-debian/hramrach.git] / com32 / rosh / rosh.h
blob64b0564c1d69f18f3176e207740cadd959ace8be
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 #ifdef DO_DEBUG
51 #define ROSH_DEBUG(f, ...) printf (f, ## __VA_ARGS__)
52 #ifdef DO_DEBUG2
53 #define ROSH_DEBUG2(f, ...) printf (f, ## __VA_ARGS__)
54 #else /* DO_DEBUG2 */
55 #define ROSH_DEBUG2(f, ...) ((void)0)
56 #endif /* DO_DEBUG2 */
57 #else /* DO_DEBUG */
58 #define ROSH_DEBUG(f, ...) ((void)0)
59 #define ROSH_DEBUG2(f, ...) ((void)0)
60 #endif /* DO_DEBUG */
62 #ifdef __COM32__
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__)
68 #else
69 #include <termios.h>
70 #define ROSH_IS_COM32 0
71 static inline char *syslinux_config_file()
73 return "";
76 static inline int getscreensize(int fd, int *rows, int *cols)
78 char *str;
79 int rv;
80 *rows = 0;
81 *cols = 0;
82 if (rows) {
83 str = getenv("LINES");
84 if (str) {
85 *rows = atoi(str);
88 if (cols) {
89 str = getenv("COLUMNS");
90 if (str) {
91 *cols = atoi(str);
94 if (!rows || !cols)
95 rv = -1;
96 else if (!*rows || !*cols)
97 rv = -2;
98 else
99 rv = 0;
100 return rv;
103 #define ROSH_COM32(f, ...) ((void)0)
104 #define syslinux_run_command(f) ((void)0)
105 #endif /* __COM32__ */
107 #define SEP '/'
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
117 #else
118 #ifdef COMMAND_LINE_SIZE
119 #define ROSH_CMD_SZ COMMAND_LINE_SIZE
120 #else
121 #define ROSH_CMD_SZ 2048
122 #endif /* COMMAND_LINE_SIZE */
123 #endif /* MAX_CMDLINE_LEN */
125 /* Size of path buffer string */
126 #ifdef PATH_MAX
127 #define ROSH_PATH_SZ PATH_MAX
128 #elif NAME_MAX
129 #define ROSH_PATH_SZ NAME_MAX
130 #else
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\
144 ALSO dir\n\
145 more Page a file\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 */