示例#1
0
int main(int argc, char *argv[]) {
    if (argc < 2 || argc > 4) {
        printf("usage: %s [-d] <app> [device_id]\n", argv[0]);
        exit(1);
    }

    
    if (strcmp(argv[1], "-d") == 0) {
        assert(argc == 3 || argc == 4);
        debug = true;
        app_path = argv[2];
        if (argc == 4) {
            device_id = argv[3];
        }
        printf("------ Install phase ------\n");
    } else {
        assert(argc == 2 || argc == 3);
        app_path = argv[1];
        if (argc == 3) {
            device_id = argv[2];
        }
    }

    assert(access(app_path, F_OK) == 0);

    AMDSetLogLevel(5); // otherwise syslog gets flooded with crap
    printf("[....] Waiting for iOS device to be connected\n");

    struct am_device_notification *notify;
    AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, &notify); 
    CFRunLoopRun();
}
示例#2
0
int main(int argc, char *argv[]) {
    static struct option longopts[] = {
        { "debug", no_argument, NULL, 'd' },
        { "id", required_argument, NULL, 'i' },
        { "bundle", required_argument, NULL, 'b' },
        { "args", required_argument, NULL, 'a' },
        { "verbose", no_argument, NULL, 'v' },
        { "timeout", required_argument, NULL, 't' },
        { "unbuffered", no_argument, NULL, 'u' },
        { "gdbargs", required_argument, NULL, 'g' },
        { "nostart", no_argument, NULL, 'n' },
        { NULL, 0, NULL, 0 },
    };
    char ch;

    while ((ch = getopt_long(argc, argv, "dvuni:b:a:t:g:", longopts, NULL)) != -1)
    {
        switch (ch) {
        case 'd':
            debug = 1;
            break;
        case 'i':
            device_id = optarg;
            break;
        case 'b':
            app_path = optarg;
            break;
        case 'a':
            args = optarg;
            break;
        case 'v':
            verbose = 1;
            break;
        case 't':
            timeout = atoi(optarg);
            break;
        case 'u':
            unbuffered = 1;
            break;
        case 'g':
            gdb_args = optarg;
            break;
        case 'n':
            nostart = 1;
            break;
        default:
            usage(argv[0]);
            return 1;
        }
    }

    if (!app_path) {
        usage(argv[0]);
        exit(0);
    }

    if (unbuffered) {
        setbuf(stdout, NULL);
        setbuf(stderr, NULL);
    }

    printf("------ Install phase ------\n");

    assert(access(app_path, F_OK) == 0);

    AMDSetLogLevel(5); // otherwise syslog gets flooded with crap
    if (timeout > 0)
    {
        CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL);
        CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
        printf("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout);
    }
    else
    {
        printf("[....] Waiting for iOS device to be connected\n");
    }

    struct am_device_notification *notify;
    AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, &notify);
    CFRunLoopRun();
}
示例#3
0
int main(int argc, char *argv[]) {
    static struct option global_longopts[]= {
        { "quiet", no_argument, NULL, 'q' },
        { "verbose", no_argument, NULL, 'v' },
        { "timeout", required_argument, NULL, 't' },

        { "id", required_argument, NULL, 'i' },
        { "bundle", required_argument, NULL, 'b' },
        { "file", required_argument, NULL, 'f' },
        { "target", required_argument, NULL, 1 },
        { "bundle-id", required_argument, NULL, 0 },

        { "debug", no_argument, NULL, 'd' },
        { "args", required_argument, NULL, 'a' },

        { NULL, 0, NULL, 0 },
    };

    char ch;
    while ((ch = getopt_long(argc, argv, "qvi:b:f:da:t:", global_longopts, NULL)) != -1)
    {
        switch (ch) {
            case 0:
                bundle_id = optarg;
                break;
            case 'q':
                quiet = 1;
                break;
            case 'v':
                verbose = 1;
                break;
            case 'd':
                debug = 1;
                break;
            case 't':
                timeout = atoi(optarg);
                break;
            case 'b':
                app_path = optarg;
                break;
            case 'f':
                doc_file_path = optarg;
                break;
            case 1:
                target_filename = optarg;
                break;
            case 'a':
                args = optarg;
                break;
            case 'i':
                device_id = optarg;
                break;

            default:
                usage(argv[0]);
                return 1;
        }
    }

    if (optind >= argc) {
        usage(argv [0]);
        exit(EXIT_SUCCESS);
    }

    operation = OP_NONE;
    if (strcmp (argv [optind], "install") == 0) {
        operation = OP_INSTALL;
    } else if (strcmp (argv [optind], "uninstall") == 0) {
        operation = OP_UNINSTALL;
    } else if (strcmp (argv [optind], "list-devices") == 0) {
        operation = OP_LIST_DEVICES;
    } else if (strcmp (argv [optind], "upload") == 0) {
        operation = OP_UPLOAD_FILE;
    } else if (strcmp (argv [optind], "list-files") == 0) {
        operation = OP_LIST_FILES;
    } else {
        usage (argv [0]);
        exit (0);
    }

    if (!args_are_valid()) {
        usage(argv[0]);
        exit(0);
    }

    if (operation == OP_INSTALL)
        assert(access(app_path, F_OK) == 0);

    AMDSetLogLevel(1+4+2+8+16+32+64+128); // otherwise syslog gets flooded with crap
    if (timeout > 0)
    {
        CFRunLoopTimerRef timer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent() + timeout, 0, 0, 0, timeout_callback, NULL);
        CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopCommonModes);
        PRINT("[....] Waiting up to %d seconds for iOS device to be connected\n", timeout);
    }
    else
    {
        PRINT("[....] Waiting for iOS device to be connected\n");
    }

    struct am_device_notification *notify;
    AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, &notify);

    CFRunLoopRun();
}