// // main.m // kordophone // // Created by James Magahern on 11/12/18. // Copyright © 2018 James Magahern. All rights reserved. // #import #import "MBIMBridge.h" void printUsage() { fprintf(stderr, "Usage: kordophoned [-h] [-s | -c (certificate.p12)]\n"); fprintf(stderr, "\t-h \t Show this help message\n"); fprintf(stderr, "\t-s \t Use SSL (requires -c option)\n"); fprintf(stderr, "\t-c \t SSL certificate path encoded as pkcs12\n"); } int main(int argc, char *const argv[]) { @autoreleasepool { BOOL usesSSL = NO; BOOL showHelp = NO; const char *certPath = NULL; int c = -1; while ( (c = getopt(argc, argv, "hsc:")) != -1 ) { switch (c) { case 's': usesSSL = YES; break; case 'c': certPath = optarg; break; case 'h': showHelp = YES; break; case '?': if (optopt == 'c') { fprintf (stderr, "Option -%c requires an argument.\n", optopt); } else if (isprint(optopt)) { fprintf (stderr, "Unknown option `-%c'.\n", optopt); } else { fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); return 1; } default: abort (); } } if (showHelp) { printUsage(); return 1; } if (usesSSL && certPath == NULL) { fprintf(stderr, "Error: wants SSL (-s) but no ssl certificate path (-c) provided\n"); return 1; } MBIMBridge *bridge = [MBIMBridge sharedInstance]; if (usesSSL && certPath != NULL) { bridge.usesSSL = YES; bridge.sslCertPath = [NSString stringWithCString:certPath encoding:NSASCIIStringEncoding]; } [bridge connect]; BOOL running = YES; while (running) { [[NSRunLoop currentRunLoop] run]; } } return 0; }