Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /**
0002  * @file
0003  * 
0004  * @brief CAT Shell Command Implmentation
0005  */
0006 
0007 /*
0008  * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com>
0009  *
0010  *  The license and distribution terms for this file may be
0011  *  found in the file LICENSE in this distribution or at
0012  *  http://www.rtems.org/license/LICENSE.
0013  */
0014 
0015 #ifdef HAVE_CONFIG_H
0016 #include "config.h"
0017 #endif
0018 
0019 #include <stdio.h>
0020 #include <termios.h>
0021 #include <string.h>
0022 #include <stdlib.h>
0023 #include <ctype.h>
0024 #include <dirent.h>
0025 #include <time.h>
0026 #include <fcntl.h>
0027 #include <unistd.h>
0028 #include <pwd.h>
0029 #include <grp.h>
0030 #include <errno.h>
0031 #include <sys/types.h>
0032 #include <stddef.h>
0033 
0034 #include <rtems.h>
0035 #include <rtems/shell.h>
0036 #include "internal.h"
0037 
0038 static int rtems_shell_main_cat(int argc, char *argv[])
0039 {
0040   int n;
0041   int sc;
0042 
0043   for ( n=1; n < argc ; n++) {
0044     sc = rtems_shell_cat_file(stdout, argv[n]);
0045     if ( sc == -1 ) {
0046       fprintf(stderr, "%s: %s: %s\n", argv[0], argv[n], strerror(errno));
0047       return -1;
0048     }
0049   }
0050   return 0;
0051 }
0052 
0053 rtems_shell_cmd_t rtems_shell_CAT_Command = {
0054   "cat",                                           /* name */
0055   "cat n1 [n2 [n3...]] # show the ascii contents", /* usage */
0056   "files",                                         /* topic */
0057   rtems_shell_main_cat ,                           /* command */
0058   NULL,                                            /* alias */
0059   NULL                                             /* next */
0060 };