1 /* 2 * (c) 2004, Jérôme DUVAL for Haiku 3 * released under the MIT licence. 4 */ 5 6 7 #include <drivers/driver_settings.h> 8 #include <syscalls.h> 9 10 #include <stdio.h> 11 #include <string.h> 12 #include <strings.h> 13 14 15 int 16 main(int argc, char **argv) 17 { 18 const char *optionName = B_SAFEMODE_SAFE_MODE; 19 bool realString = false; 20 char buffer[B_FILE_NAME_LENGTH]; 21 size_t size = sizeof(buffer); 22 status_t status; 23 int i; 24 25 for (i = 1; i < argc; i++) { 26 if (!strcmp(argv[i], "-h")) { 27 printf("Usage: %s [-s] [optionName]\n" 28 "Prints the value of a kernel safemode option, " 29 "(default is safemode boot itself).\n\n" 30 " -s\t\tReturn the real string result, not a boolean.\n", 31 argv[0]); 32 return 0; 33 } else if (!strcmp(argv[i], "-s")) 34 realString = true; 35 else 36 optionName = argv[i]; 37 } 38 39 status = _kern_get_safemode_option(optionName, buffer, &size); 40 if (status == B_OK) { 41 if (realString) { 42 puts(buffer); 43 return 0; 44 } 45 if (!strncasecmp(buffer, "true", size) 46 || !strncasecmp(buffer, "yes", size) 47 || !strncasecmp(buffer, "on", size) 48 || !strncasecmp(buffer, "enabled", size)) { 49 puts("yes"); 50 return 1; 51 } 52 } 53 54 puts("no"); 55 return 0; 56 } 57 58