int main(int argc, char* argv[]) { int result = 0; int custom_addr = 0; int daemon_mode = 0; if (argc > 1) { if (strcmp(argv[1], "-d") == 0) { daemon_mode = 1; } else { if (_psmove_btaddr_from_string(argv[1], NULL)) { printf("Using user-supplied host address: %s\n", argv[1]); } else { printf("Cannot convert host address: %s\n", argv[1]); return 1; } custom_addr = 1; } } #ifdef __linux /** * In order to be able to start/stop bluetoothd and to * add new entries to the Bluez configuration files, we * need to run as root (platform/psmove_linuxsupport.c) **/ if (geteuid() != 0) { printf("This program must be run as root (or use sudo).\n"); return 1; } #endif if (daemon_mode == 0) { if (custom_addr != 0) { result = pair(argv[1]); } else { result = pair(NULL); } } else { result = run_daemon(); } return result; }
int main(int argc, char* argv[]) { int result = 0; int custom_addr = 0; int daemon_mode = 0; if (argc > 1) { if (strcmp(argv[1], "-d") == 0) { daemon_mode = 1; } else { if (_psmove_btaddr_from_string(argv[1], NULL)) { printf("Using user-supplied host address: %s\n", argv[1]); } else { printf("Cannot convert host address: %s\n", argv[1]); return 1; } custom_addr = 1; } } if (!psmove_port_check_pairing_permissions()) { return 1; } if (daemon_mode == 0) { if (custom_addr != 0) { result = pair(argv[1]); } else { result = pair(NULL); } } else { result = run_daemon(); } return result; }