Exemplo n.º 1
0
int poweroff(int argc, char *argv[])
{
    if (!acpi_connected) {
        int r = connect_to_acpi();
        assert(r == 0);
        acpi_connected = true;
    }
    return acpi_sleep(4);
}
Exemplo n.º 2
0
int
main(int argc, char *argv[])
{
	char	c, *prog;
	int	sleep_type;

	prog = argv[0];
	if (argc < 2)
		usage(prog);
		/* NOTREACHED */

	sleep_type = -1;
	acpi_init();
	while ((c = getopt(argc, argv, "hi:k:s:")) != -1) {
		switch (c) {
		case 'i':
			acpi_battinfo(atoi(optarg));
			break;
		case 'k':
			acpi_sleep_ack(atoi(optarg));
			break;
		case 's':
			if (optarg[0] == 'S')
				sleep_type = optarg[1] - '0';
			else
				sleep_type = optarg[0] - '0';
			if (sleep_type < 1 || sleep_type > 4)
				errx(EX_USAGE, "invalid sleep type (%d)",
				     sleep_type);
			break;
		case 'h':
		default:
			usage(prog);
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

	if (sleep_type != -1)
		acpi_sleep(sleep_type);

	close(acpifd);
	exit (0);
}