From 714f06c7fa0520bed36fa2a1b9e29986d1184ed0 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Sat, 17 Apr 2004 08:12:02 +0000 Subject: 2004-04-17 Ralf Corsepius * libmisc/capture/capture-cli.c, libmisc/cpuuse/cpuuse.c, libmisc/dumpbuf/dumpbuf.c, libmisc/fsmount/fsmount.c, libmisc/monitor/mon-command.c, libmisc/monitor/mon-config.c, libmisc/monitor/mon-dname.c, libmisc/monitor/mon-driver.c, libmisc/monitor/mon-extension.c, libmisc/monitor/mon-itask.c, libmisc/monitor/mon-monitor.c, libmisc/monitor/mon-mpci.c, libmisc/monitor/mon-object.c, libmisc/monitor/mon-prmisc.c, libmisc/monitor/mon-queue.c, libmisc/monitor/mon-symbols.c, libmisc/monitor/mon-task.c, libmisc/rtmonuse/rtmonuse.c, libmisc/shell/cmds.c, libmisc/shell/shell.c, libmisc/shell/shell.h, libmisc/stackchk/check.c, libmisc/untar/untar.c: Use fprintf(stdout,...) instead of printf. --- cpukit/libmisc/shell/cmds.c | 62 ++++++++++++++++++++++---------------------- cpukit/libmisc/shell/shell.c | 40 ++++++++++++++-------------- cpukit/libmisc/shell/shell.h | 8 +++--- 3 files changed, 55 insertions(+), 55 deletions(-) (limited to 'cpukit/libmisc/shell') diff --git a/cpukit/libmisc/shell/cmds.c b/cpukit/libmisc/shell/cmds.c index 50a086c0cf..ba3a4b030e 100644 --- a/cpukit/libmisc/shell/cmds.c +++ b/cpukit/libmisc/shell/cmds.c @@ -130,14 +130,14 @@ int main_mdump(int argc,char * argv[]) { max/=16; if (!max) max=20; for (m=0;mpw_name:"nouser"; grp=getgrgid(stat_buf.st_gid); group=grp?grp->gr_name:"nogrp"; - printf("%c%c%c%c%c%c%c%c%c%c %3d %6.6s %6.6s %11d %s %s%c\n", + fprintf(stdout,"%c%c%c%c%c%c%c%c%c%c %3d %6.6s %6.6s %11d %s %s%c\n", (S_ISLNK(stat_buf.st_mode)?('l'): (S_ISDIR(stat_buf.st_mode)?('d'):('-'))), (stat_buf.st_mode & S_IRUSR)?('r'):('-'), @@ -313,7 +313,7 @@ int main_ls(int argc, char *argv[]) size+=stat_buf.st_size; } } - printf("%d files %d bytes occupied\n",n,size); + fprintf(stdout,"%d files %d bytes occupied\n",n,size); closedir(dirp); return 0; } @@ -321,7 +321,7 @@ int main_ls(int argc, char *argv[]) int main_pwd (int argc, char *argv[]) { char dir[1024]; getcwd(dir,1024); - printf("%s\n",dir); + fprintf(stdout,"%s\n",dir); return 0; } /*-----------------------------------------------------------*/ @@ -330,7 +330,7 @@ int main_chdir (int argc, char *argv[]) { dir="/"; if (argc>1) dir=argv[1]; if (chdir(dir)) { - printf("chdir to '%s' failed:%s\n",dir,strerror(errno)); + fprintf(stdout,"chdir to '%s' failed:%s\n",dir,strerror(errno)); return errno; }; return 0; @@ -343,7 +343,7 @@ int main_mkdir (int argc, char *argv[]) { while (nexit_shell=TRUE; return 0; } /*-----------------------------------------------------------*/ int main_tty (int argc,char *argv[]) { - printf("%s\n",ttyname(fileno(stdin))); + fprintf(stdout,"%s\n",ttyname(fileno(stdin))); return 0; } /*-----------------------------------------------------------*/ @@ -420,7 +420,7 @@ int main_whoami(int argc,char *argv[]) { struct passwd * pwd; pwd=getpwuid(getuid()); - printf("%s\n",pwd?pwd->pw_name:"nobody"); + fprintf(stdout,"%s\n",pwd?pwd->pw_name:"nobody"); return 0; } /*-----------------------------------------------------------*/ @@ -430,12 +430,12 @@ int main_id (int argc,char *argv[]) struct group * grp; pwd=getpwuid(getuid()); grp=getgrgid(getgid()); - printf("uid=%d(%s),gid=%d(%s),", + fprintf(stdout,"uid=%d(%s),gid=%d(%s),", getuid(),pwd?pwd->pw_name:"", getgid(),grp?grp->gr_name:""); pwd=getpwuid(geteuid()); grp=getgrgid(getegid()); - printf("euid=%d(%s),egid=%d(%s)\n", + fprintf(stdout,"euid=%d(%s),egid=%d(%s)\n", geteuid(),pwd?pwd->pw_name:"", getegid(),grp?grp->gr_name:""); return 0; @@ -447,7 +447,7 @@ int main_umask(int argc,char *argv[]) if (argc == 2) msk=str2int(argv[1]); umask(msk); msk=umask(0); - printf("0%o\n", (unsigned int) msk); + fprintf(stdout,"0%o\n", (unsigned int) msk); umask(msk); return 0; } diff --git a/cpukit/libmisc/shell/shell.c b/cpukit/libmisc/shell/shell.c index 4f106d5390..01a9c36ec8 100644 --- a/cpukit/libmisc/shell/shell.c +++ b/cpukit/libmisc/shell/shell.c @@ -180,11 +180,11 @@ int shell_make_args(char * cmd, int shell_help_cmd(shell_cmd_t * shell_cmd) { char * pc; int col,line; - printf("%-10.10s -",shell_cmd->name); + fprintf(stdout,"%-10.10s -",shell_cmd->name); col=12; line=1; if (shell_cmd->alias) { - printf("is an for command '%s'",shell_cmd->alias->name); + fprintf(stdout,"is an for command '%s'",shell_cmd->alias->name); } else if (shell_cmd->usage) { pc=shell_cmd->usage; @@ -206,7 +206,7 @@ int shell_help_cmd(shell_cmd_t * shell_cmd) { }; }; if (!col && *pc) { - printf(" "); + fprintf(stdout," "); col=12;line++; }; }; @@ -224,51 +224,51 @@ int shell_help(int argc,char * argv[]) { shell_topic_t *topic; shell_cmd_t * shell_cmd=shell_first_cmd; if (argc<2) { - printf("help: ('r' repeat last cmd - 'e' edit last cmd)\n" + fprintf(stdout,"help: ('r' repeat last cmd - 'e' edit last cmd)\n" " TOPIC? The topics are\n"); topic=shell_first_topic; col=0; while (topic) { if (!col){ - col=printf(" %s",topic->topic); + col=fprintf(stdout," %s",topic->topic); } else { if ((col+strlen(topic->topic)+2)>78){ - printf("\n"); - col=printf(" %s",topic->topic); + fprintf(stdout,"\n"); + col=fprintf(stdout," %s",topic->topic); } else { - col+=printf(", %s",topic->topic); + col+=fprintf(stdout,", %s",topic->topic); }; }; topic=topic->next; }; - printf("\n"); + fprintf(stdout,"\n"); return 1; }; line=0; for (arg=1;arg16) { - printf("Press any key to continue...");getchar(); - printf("\n"); + fprintf(stdout,"Press any key to continue...");getchar(); + fprintf(stdout,"\n"); line=0; }; topic=shell_lookup_topic(argv[arg]); if (!topic){ if ((shell_cmd=shell_lookup_cmd(argv[arg]))==NULL) { - printf("help: topic or cmd '%s' not found. Try alone for a list\n",argv[arg]); + fprintf(stdout,"help: topic or cmd '%s' not found. Try alone for a list\n",argv[arg]); line++; } else { line+=shell_help_cmd(shell_cmd); } continue; }; - printf("help: list for the topic '%s'\n",argv[arg]); + fprintf(stdout,"help: list for the topic '%s'\n",argv[arg]); line++; while (shell_cmd) { if (!strcmp(topic->topic,shell_cmd->topic)) line+=shell_help_cmd(shell_cmd); if (line>16) { - printf("Press any key to continue...");getchar(); - printf("\n"); + fprintf(stdout,"Press any key to continue...");getchar(); + fprintf(stdout,"\n"); line=0; }; shell_cmd=shell_cmd->next; @@ -569,7 +569,7 @@ rtems_task shell_shell(rtems_task_argument task_argument) { setvbuf(stdout,NULL,_IONBF,0); /* Not buffered*/ stderr=fopen(devname,"r+"); if (!stderr) { - printf("shell:unable to open stderr.%s:%s\n",devname,strerror(errno)); + fprintf(stdout,"shell:unable to open stderr.%s:%s\n",devname,strerror(errno)); }; /* when the future user environment runs ok * a freopen() reopens the terminals. Now this don't work @@ -588,7 +588,7 @@ rtems_task shell_shell(rtems_task_argument task_argument) { cat_file(stdout,"/etc/motd"); strcpy(last_cmd,""); strcpy(cmd,""); - printf("\n" + fprintf(stdout,"\n" "RTEMS SHELL (Ver.1.0-FRC):%s. "__DATE__". 'help' to list commands.\n",devname); chdir("/"); /* XXX: chdir to getpwent homedir */ shell_env->exit_shell=FALSE; @@ -596,7 +596,7 @@ rtems_task shell_shell(rtems_task_argument task_argument) { /* Prompt section */ /* XXX: show_prompt user adjustable */ getcwd(curdir,sizeof(curdir)); - printf("%s [%s] %c ",shell_env->taskname,curdir,geteuid()?'$':'#'); + fprintf(stdout,"%s [%s] %c ",shell_env->taskname,curdir,geteuid()?'$':'#'); /* getcmd section */ if (!shell_scanline(cmd,sizeof(cmd),stdin,stdout)) break; /*EOF*/ /* evaluate cmd section */ @@ -621,7 +621,7 @@ rtems_task shell_shell(rtems_task_argument task_argument) { if ((shell_cmd=shell_lookup_cmd(argv[0]))!=NULL) { shell_env->errorlevel=shell_cmd->command(argc,argv); } else { - printf("shell:%s command not found\n",argv[0]); + fprintf(stdout,"shell:%s command not found\n",argv[0]); shell_env->errorlevel=-1; }; }; @@ -629,7 +629,7 @@ rtems_task shell_shell(rtems_task_argument task_argument) { if (shell_env->exit_shell) break; cmd[0]=0; }; - printf("\nGoodbye from RTEMS SHELL :-(\n"); + fprintf(stdout,"\nGoodbye from RTEMS SHELL :-(\n"); }; } while (shell_env->forever); fclose(stdin ); diff --git a/cpukit/libmisc/shell/shell.h b/cpukit/libmisc/shell/shell.h index c4bf49067a..c95bef5436 100644 --- a/cpukit/libmisc/shell/shell.h +++ b/cpukit/libmisc/shell/shell.h @@ -16,14 +16,14 @@ #ifndef __SHELL_H__ #define __SHELL_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef int (*shell_command_t)(int argc,char * argv[]); struct shell_cmd_tt ; -- cgit v1.2.3