File: ctrlaltdel.c

package info (click to toggle)
loop-aes-utils 2.12p-4sarge2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,644 kB
  • ctags: 5,072
  • sloc: ansic: 46,123; sh: 7,606; makefile: 884; perl: 86; csh: 62; sed: 55
file content (48 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination
 * Created 4-Jul-92 by Peter Orbaek <poe@daimi.aau.dk>
 * ftp://ftp.daimi.aau.dk/pub/linux/poe/
 * 1999-02-22 Arkadiusz Mikiewicz <misiek@pld.ORG.PL>
 * - added Native Language Support
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include "linux_reboot.h"
#include "nls.h"

int
main(int argc, char *argv[]) {

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	

	if(geteuid()) {
		fprintf(stderr,
		    _("You must be root to set the Ctrl-Alt-Del behaviour.\n"));
		exit(1);
	}

	if(argc == 2 && !strcmp("hard", argv[1])) {
		if(my_reboot(LINUX_REBOOT_CMD_CAD_ON) < 0) {
			perror("ctrlaltdel: reboot");
			exit(1);
		}
	} else if(argc == 2 && !strcmp("soft", argv[1])) {
		if(my_reboot(LINUX_REBOOT_CMD_CAD_OFF) < 0) {
			perror("ctrlaltdel: reboot");
			exit(1);
		}
	} else {
		fprintf(stderr, _("Usage: ctrlaltdel hard|soft\n"));
		exit(1);
	}
	exit(0);
}