Updating STTY command for use in RTEMS shell

This commit is contained in:
Kevin Kirspel 2017-05-04 08:27:57 -04:00 committed by Sebastian Huber
parent f6c52e086d
commit 567cce1260
16 changed files with 175 additions and 0 deletions

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -37,6 +40,9 @@ static char sccsid[] = "@(#)cchar.c 8.5 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <err.h>
@ -47,6 +53,9 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
#ifdef __rtems__
#include "rtems-bsd-stty-cchar-data.h"
#endif /* __rtems__ */
static int c_cchar(const void *, const void *);

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -37,6 +40,9 @@ static char sccsid[] = "@(#)gfmt.c 8.6 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <err.h>

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -37,6 +40,9 @@ static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <err.h>
@ -96,6 +102,9 @@ static struct key {
{ "speed", f_speed, 0 },
{ "tty", f_tty, 0 },
};
#ifdef __rtems__
#include "rtems-bsd-stty-key-data.h"
#endif /* __rtems__ */
static int
c_key(const void *a, const void *b)

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -37,10 +40,16 @@ static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <stddef.h>
#include <string.h>
#include "stty.h"
#ifdef __rtems__
#include "rtems-bsd-stty-modes-data.h"
#endif /* __rtems__ */
int msearch(char ***, struct info *);

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -37,6 +40,9 @@ static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <stddef.h>
@ -45,6 +51,9 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
#ifdef __rtems__
#include "rtems-bsd-stty-print-data.h"
#endif /* __rtems__ */
static void binit(const char *);
static void bput(const char *);

View File

@ -0,0 +1,4 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* cchar.c */

View File

@ -0,0 +1,11 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
/* cchar.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, extern struct cchar cchars1[]);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, extern struct cchar cchars2[]);
/* gfmt.c */
/* key.c */
/* modes.c */
/* print.c */
/* stty.c */
/* util.c */

View File

@ -0,0 +1,4 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* gfmt.c */

View File

@ -0,0 +1,5 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* key.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static struct key keys[20]);

View File

@ -0,0 +1,4 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* modes.c */

View File

@ -0,0 +1,34 @@
/* generated by userspace-header-gen.py */
/* cchar.c */
#define cchars1 _bsd_stty_cchars1
#define cchars2 _bsd_stty_cchars2
#define csearch _bsd_stty_csearch
/* gfmt.c */
#define gread _bsd_stty_gread
#define gprint _bsd_stty_gprint
/* key.c */
#define f_tty _bsd_stty_f_tty
#define f_speed _bsd_stty_f_speed
#define f_size _bsd_stty_f_size
#define f_sane _bsd_stty_f_sane
#define f_rows _bsd_stty_f_rows
#define f_raw _bsd_stty_f_raw
#define f_ospeed _bsd_stty_f_ospeed
#define f_nl _bsd_stty_f_nl
#define f_ispeed _bsd_stty_f_ispeed
#define f_extproc _bsd_stty_f_extproc
#define f_everything _bsd_stty_f_everything
#define f_ek _bsd_stty_f_ek
#define f_dec _bsd_stty_f_dec
#define f_columns _bsd_stty_f_columns
#define f_cbreak _bsd_stty_f_cbreak
#define f_all _bsd_stty_f_all
#define ksearch _bsd_stty_ksearch
/* modes.c */
#define msearch _bsd_stty_msearch
/* print.c */
#define print _bsd_stty_print
/* stty.c */
#define usage _bsd_stty_usage
/* util.c */
#define checkredirect _bsd_stty_checkredirect

View File

@ -0,0 +1,6 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* print.c */
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static int col);
RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static char const *label);

View File

@ -0,0 +1,4 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* stty.c */

View File

@ -0,0 +1,4 @@
/* generated by userspace-header-gen.py */
#include <rtems/linkersets.h>
#include "rtems-bsd-stty-data.h"
/* util.c */

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1989, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -43,6 +46,12 @@ static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#define __need_getopt_newlib
#include <getopt.h>
#include <machine/rtems-bsd-program.h>
#include <machine/rtems-bsd-commands.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <ctype.h>
@ -57,7 +66,33 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
#ifdef __rtems__
#include "rtems-bsd-stty-stty-data.h"
#endif /* __rtems__ */
#ifdef __rtems__
static int main(int argc, char *argv[]);
RTEMS_LINKER_RWSET(bsd_prog_stty, char);
int
rtems_bsd_command_stty(int argc, char *argv[])
{
int exit_code;
void *data_begin;
size_t data_size;
data_begin = RTEMS_LINKER_SET_BEGIN(bsd_prog_stty);
data_size = RTEMS_LINKER_SET_SIZE(bsd_prog_stty);
rtems_bsd_program_lock();
exit_code = rtems_bsd_program_call_main_with_data_restore("stty",
main, argc, argv, data_begin, data_size);
rtems_bsd_program_unlock();
return exit_code;
}
#endif /* __rtems__ */
int
main(int argc, char *argv[])
{
@ -65,6 +100,15 @@ main(int argc, char *argv[])
enum FMT fmt;
int ch;
const char *file, *errstr = NULL;
#ifdef __rtems__
struct getopt_data getopt_data;
memset(&getopt_data, 0, sizeof(getopt_data));
#define optind getopt_data.optind
#define optarg getopt_data.optarg
#define opterr getopt_data.opterr
#define optopt getopt_data.optopt
#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
#endif /* __rtems__ */
fmt = NOTSET;
i.fd = STDIN_FILENO;
@ -72,7 +116,11 @@ main(int argc, char *argv[])
opterr = 0;
while (optind < argc &&
#ifndef __rtems__
strspn(argv[optind], "-aefg") == strlen(argv[optind]) &&
#else /* __rtems__ */
strspn(argv[optind == 0 ? 1 : optind], "-aefg") == strlen(argv[optind == 0 ? 1 : optind]) &&
#endif /* __rtems__ */
(ch = getopt(argc, argv, "aef:g")) != -1)
switch(ch) {
case 'a': /* undocumented: POSIX compatibility */

View File

@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
#ifdef __rtems__
#include "rtems-bsd-stty-namespace.h"
#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@ -37,6 +40,9 @@ static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef __rtems__
#include <machine/rtems-bsd-program.h>
#endif /* __rtems__ */
#include <sys/types.h>
#include <sys/stat.h>
@ -47,6 +53,9 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
#ifdef __rtems__
#include "rtems-bsd-stty-util-data.h"
#endif /* __rtems__ */
/*
* Gross, but since we're changing the control descriptor from 1 to 0, most