summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/shell/cat_file.c
blob: 1a5efb4418ecec7cdb3598f0ea03cd05b7bfc41b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 *  CAT Command Implementation
 *
 *  Author:
 *   WORK: fernando.ruiz@ctv.es
 *   HOME: correo@fernando-ruiz.com
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 *
 *  $Id$
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h>

int rtems_shell_cat_file(FILE * out,const char * name) {
  FILE * fd;
  int c;

  if (out) {
    fd = fopen(name,"r");
    if (!fd) {
      return -1;
    }
    while ((c=fgetc(fd))!=EOF)
      fputc(c,out);
    fclose(fd);
  }
  return 0;
}