source: rtems/cpukit/libmisc/shell/main_whoami.c @ f97536d

5
Last change on this file since f97536d was f97536d, checked in by Sebastian Huber <sebastian.huber@…>, on 10/16/15 at 06:21:48

basdefs.h: Add and use RTEMS_UNUSED

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 *  WHOAMI Shell Command Implmentation
3 *
4 *  Author: Fernando RUIZ CASAS
5 *  Work: fernando.ruiz@ctv.es
6 *  Home: correo@fernando-ruiz.com
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13#ifdef HAVE_CONFIG_H
14#include "config.h"
15#endif
16
17#include <stdio.h>
18#include <unistd.h>
19#include <string.h>
20#include <errno.h>
21#include <pwd.h>
22
23#include <rtems.h>
24#include <rtems/shell.h>
25#include "internal.h"
26
27static int rtems_shell_main_whoami(
28  int   argc RTEMS_UNUSED,
29  char *argv[] RTEMS_UNUSED
30)
31{
32  struct passwd *pwd;
33
34  pwd = getpwuid(geteuid());
35  printf( "%s\n", (pwd) ? pwd->pw_name : "nobody");
36  return 0;
37}
38
39rtems_shell_cmd_t rtems_shell_WHOAMI_Command = {
40  "whoami",                                   /* name */
41  "show current user",                        /* usage */
42  "misc",                                     /* topic */
43  rtems_shell_main_whoami,                    /* command */
44  NULL,                                       /* alias */
45  NULL                                        /* next */
46};
Note: See TracBrowser for help on using the repository browser.