Upload Tizen:Base source
[framework/base/util-linux-ng.git] / sys-utils / ctrlaltdel.c
1 /*
2  * ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination
3  * Created 4-Jul-92 by Peter Orbaek <poe@daimi.aau.dk>
4  * ftp://ftp.daimi.aau.dk/pub/linux/poe/
5  * 1999-02-22 Arkadiusz Mi¶kiewicz <misiek@pld.ORG.PL>
6  * - added Native Language Support
7  *
8  */
9
10 #include <stdio.h>
11 #include <unistd.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include "linux_reboot.h"
15 #include "nls.h"
16
17 int
18 main(int argc, char *argv[]) {
19
20         setlocale(LC_ALL, "");
21         bindtextdomain(PACKAGE, LOCALEDIR);
22         textdomain(PACKAGE);
23         
24
25         if(geteuid()) {
26                 fprintf(stderr,
27                     _("You must be root to set the Ctrl-Alt-Del behaviour.\n"));
28                 exit(1);
29         }
30
31         if(argc == 2 && !strcmp("hard", argv[1])) {
32                 if(my_reboot(LINUX_REBOOT_CMD_CAD_ON) < 0) {
33                         perror("ctrlaltdel: reboot");
34                         exit(1);
35                 }
36         } else if(argc == 2 && !strcmp("soft", argv[1])) {
37                 if(my_reboot(LINUX_REBOOT_CMD_CAD_OFF) < 0) {
38                         perror("ctrlaltdel: reboot");
39                         exit(1);
40                 }
41         } else {
42                 fprintf(stderr, _("Usage: ctrlaltdel hard|soft\n"));
43                 exit(1);
44         }
45         exit(0);
46 }
47
48