this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add --help and --version parameters to darling.c Version outputs the branch and latest commit that Darling was compiled with

+65 -4
+13 -1
src/CMakeLists.txt
··· 11 11 12 12 add_definitions(-D__APPLE__ -D__DYNAMIC__) 13 13 14 + execute_process( 15 + COMMAND git rev-parse --abbrev-ref HEAD 16 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 17 + OUTPUT_VARIABLE GIT_BRANCH 18 + OUTPUT_STRIP_TRAILING_WHITESPACE 19 + ) 20 + execute_process( 21 + COMMAND git log -1 --format=%h 22 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 23 + OUTPUT_VARIABLE GIT_COMMIT_HASH 24 + OUTPUT_STRIP_TRAILING_WHITESPACE 25 + ) 26 + 14 27 configure_file(darling-config.h.in darling-config.h) 15 28 include_directories("${CMAKE_CURRENT_BINARY_DIR}") 16 29 include_directories("${CMAKE_CURRENT_SOURCE_DIR}") ··· 168 181 add_custom_target(lkm 169 182 COMMAND gmake 170 183 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/lkm") 171 -
+3
src/darling-config.h.in
··· 12 12 // Path where the system root gets "mounted" inside the prefix 13 13 #define SYSTEM_ROOT "/Volumes/SystemRoot" 14 14 15 + #define GIT_BRANCH "@GIT_BRANCH@" 16 + #define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@" 17 + 15 18 #cmakedefine MULTILIB 16 19 #cmakedefine FRAMEWORK_COREAUDIO 17 20 #cmakedefine FRAMEWORK_APPKIT
+48 -3
src/dyld/darling.c
··· 34 34 #include <sys/utsname.h> 35 35 #include <sys/stat.h> 36 36 #include <sys/syscall.h> 37 + #include <getopt.h> 37 38 #include "darling.h" 38 39 #include "darling-config.h" 39 40 ··· 42 43 char *prefix; 43 44 uid_t g_originalUid, g_originalGid; 44 45 45 - int main(int argc, const char** argv) 46 + int main(int argc, char const ** argv) 46 47 { 47 48 pid_t pidInit, pidChild; 48 49 int wstatus; ··· 75 76 if (!checkPrefixDir()) 76 77 setupPrefix(); 77 78 checkPrefixOwner(); 79 + 80 + int c; 81 + while (1) 82 + { 83 + static struct option long_options[] = 84 + { 85 + {"help", no_argument, 0, 0}, 86 + {"version", no_argument, 0, 0}, 87 + {0, 0, 0, 0} 88 + }; 89 + int option_index = 0; 90 + 91 + c = getopt_long(argc, (char *const *)argv, "", long_options, &option_index); 92 + 93 + if (c == -1) 94 + { 95 + break; 96 + } 97 + 98 + switch (c) 99 + { 100 + case 0: 101 + if (strcmp(long_options[option_index].name, "help") == 0) 102 + { 103 + showHelp(argv[0]); 104 + exit(EXIT_SUCCESS); 105 + } 106 + else if (strcmp(long_options[option_index].name, "version") == 0) 107 + { 108 + showVersion(argv[0]); 109 + exit(EXIT_SUCCESS); 110 + } 111 + break; 112 + case '?': 113 + break; 114 + default: 115 + abort(); 116 + } 117 + } 78 118 79 119 pidInit = getInitProcess(); 80 120 ··· 302 342 void showHelp(const char* argv0) 303 343 { 304 344 fprintf(stderr, "This is Darling, translation layer for macOS software.\n\n"); 305 - fprintf(stderr, "Copyright (C) 2012-2016 Lubos Dolezel\n\n"); 345 + fprintf(stderr, "Copyright (C) 2012-2017 Lubos Dolezel\n\n"); 306 346 307 347 fprintf(stderr, "Usage:\n"); 308 348 fprintf(stderr, "\t%s program-path [arguments...]\n", argv0); ··· 310 350 fprintf(stderr, "\n"); 311 351 fprintf(stderr, "Environment variables:\n" 312 352 "DPREFIX - specifies the location of Darling prefix, defaults to ~/.darling\n"); 353 + } 354 + 355 + void showVersion(const char* argv0) { 356 + fprintf(stderr, "%s " GIT_BRANCH " @ " GIT_COMMIT_HASH "\n", argv0); 357 + fprintf(stderr, "Copyright (C) 2012-2017 Lubos Dolezel\n"); 313 358 } 314 359 315 360 void missingSetuidRoot(void) ··· 845 890 printf("Loaded kernel module: %s\n", path); 846 891 847 892 close(fd); 848 - 893 + 849 894 return 0; 850 895 } 851 896
+1
src/dyld/darling.h
··· 23 23 #define _DARLING_H_ 24 24 25 25 void showHelp(const char* argv0); 26 + void showVersion(const char* argv0); 26 27 27 28 // Reports that this executable is not setuid root 28 29 void missingSetuidRoot(void);