view toys/other/reboot.c @ 1277:23817e1675f2 draft

Catch duplicate command name (which breaks the build already, but doesn't identify the culprit).
author Rob Landley <rob@landley.net>
date Sat, 10 May 2014 13:06:31 -0500
parents e1d3a9ac9e9f
children 5fac2769a159
line wrap: on
line source

/* reboot.c - Restart, halt or powerdown the system.
 *
 * Copyright 2013 Elie De Brauwer <eliedebrauwer@gmail.com>

USE_REBOOT(NEWTOY(reboot, "n", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
USE_REBOOT(OLDTOY(halt, reboot, "n", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
USE_REBOOT(OLDTOY(poweroff, reboot, "n", TOYFLAG_BIN|TOYFLAG_NEEDROOT))

config REBOOT
  bool "reboot"
  default y
  help
    usage: reboot/halt/poweroff [-n]

    Restart, halt or powerdown the system.

    -n	Don't sync before stopping the system.
*/

#define FOR_reboot
#include "toys.h"
#include <sys/reboot.h>

void reboot_main(void)
{
  int types[] = {RB_AUTOBOOT, RB_HALT_SYSTEM, RB_POWER_OFF};

  if (!(toys.optflags & FLAG_n)) sync();

  toys.exitval = reboot(types[stridx("hp", *toys.which->name)+1]);
}