source: rtems/cpukit/libmisc/shell/write_file.c @ 0893220

4.104.115
Last change on this file since 0893220 was a3ddb08b, checked in by Joel Sherrill <joel.sherrill@…>, on 03/05/08 at 02:49:35

2008-03-04 Joel Sherrill <joel.sherrill@…>

  • libmisc/Makefile.am, libmisc/shell/main_cp.c, libmisc/shell/main_cpuuse.c, libmisc/shell/main_date.c, libmisc/shell/main_mallocinfo.c, libmisc/shell/main_netstats.c, libmisc/shell/main_perioduse.c, libmisc/shell/main_stackuse.c, libmisc/shell/main_wkspaceinfo.c, libmisc/shell/print_heapinfo.c, libmisc/shell/shell.c, libmisc/shell/shell.h, libmisc/shell/shell_makeargs.c, libmisc/shell/shellconfig.c, libmisc/shell/shellconfig.h, libmisc/shell/write_file.c: Add initial capability to automatically execute a script from the filesystem. Add echo command from NetBSD and sleep command.
  • libmisc/shell/main_echo.c, libmisc/shell/main_sleep.c, libmisc/shell/shell_script.c: New files.
  • Property mode set to 100644
File size: 671 bytes
Line 
1/*
2 *
3 *  Write buffer to a file
4 *
5 *  Author:
6 *
7 *   WORK: fernando.ruiz@ctv.es
8 *   HOME: correo@fernando-ruiz.com
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <stdio.h>
22#include <unistd.h>
23#include <string.h>
24
25void rtems_shell_write_file(
26  const char *name,
27  const char *content
28)
29{
30  FILE * fd;
31
32  fd = fopen(name,"w");
33  if ( !fd ) {
34    fprintf( stderr, "Unable to write %s\n", name );
35  }
36
37  if (fd) {
38    fwrite(content,1,strlen(content),fd);
39    fclose(fd);
40  }
41}
42
43
Note: See TracBrowser for help on using the repository browser.