forked from Imagelibrary/rtems
* 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.
44 lines
671 B
C
44 lines
671 B
C
/*
|
|
*
|
|
* Write buffer to a file
|
|
*
|
|
* 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>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
|
|
void rtems_shell_write_file(
|
|
const char *name,
|
|
const char *content
|
|
)
|
|
{
|
|
FILE * fd;
|
|
|
|
fd = fopen(name,"w");
|
|
if ( !fd ) {
|
|
fprintf( stderr, "Unable to write %s\n", name );
|
|
}
|
|
|
|
if (fd) {
|
|
fwrite(content,1,strlen(content),fd);
|
|
fclose(fd);
|
|
}
|
|
}
|
|
|
|
|