AzureSphere/AzureSphereSampleDevice/main.c
static void ParseCommandLineArguments(int argc, char *argv[])
{
    int option = 0;
    static const struct option cmdLineOptions[] = {
        {.name = "ConnectionType", .has_arg = required_argument, .flag = NULL, .val = 'c'},
        {.name = "ScopeID", .has_arg = required_argument, .flag = NULL, .val = 's'},
        {.name = "Hostname", .has_arg = required_argument, .flag = NULL, .val = 'h'},
        {.name = "IoTEdgeRootCAPath", .has_arg = required_argument, .flag = NULL, .val = 'i'},
        {.name = NULL, .has_arg = 0, .flag = NULL, .val = 0}};

    // Loop over all of the options.
    while ((option = getopt_long(argc, argv, "c:s:h:i:", cmdLineOptions, NULL)) != -1) {
        // Check if arguments are missing. Every option requires an argument.
        if (optarg != NULL && optarg[0] == '-') {
            Log_Debug("WARNING: Option %c requires an argument\n", option);
            continue;
        }
        switch (option) {
        case 'c':
            Log_Debug("ConnectionType: %s\n", optarg);
            if (strcmp(optarg, "DPS") == 0) {
                connectionType = ConnectionType_DPS;
            } else if (strcmp(optarg, "Direct") == 0) {
                connectionType = ConnectionType_Direct;
            } else if (strcmp(optarg, "IoTEdge") == 0) {
                connectionType = ConnectionType_IoTEdge;
            }
            break;
        case 's':
            Log_Debug("ScopeID: %s\n", optarg);
            scopeId = optarg;
            break;
        case 'h':
            Log_Debug("Hostname: %s\n", optarg);
            hostName = optarg;
            break;
        case 'i':
            Log_Debug("IoTEdgeRootCAPath: %s\n", optarg);
            iotEdgeRootCAPath = optarg;
            break;
        default:
            // Unknown options are ignored.
            break;
        }
    }
}
/// <summary>
///     Parse the command line arguments given in the application manifest.
/// </summary>

Parse the command line arguments given in the application manifest.
Parse the command line arguments given in the application manifest .
static void ParseCommandLineArguments(int argc, char *argv[])
{
    int option = 0;
    static const struct option cmdLineOptions[] = {
        {.name = "ConnectionType", .has_arg = required_argument, .flag = NULL, .val = 'c'},
        {.name = "ScopeID", .has_arg = required_argument, .flag = NULL, .val = 's'},
        {.name = "Hostname", .has_arg = required_argument, .flag = NULL, .val = 'h'},
        {.name = "IoTEdgeRootCAPath", .has_arg = required_argument, .flag = NULL, .val = 'i'},
        {.name = NULL, .has_arg = 0, .flag = NULL, .val = 0}};
    while ((option = getopt_long(argc, argv, "c:s:h:i:", cmdLineOptions, NULL)) != -1) {
        if (optarg != NULL && optarg[0] == '-') {
            Log_Debug("WARNING: Option %c requires an argument\n", option);
            continue;
        }
        switch (option) {
        case 'c':
            Log_Debug("ConnectionType: %s\n", optarg);
            if (strcmp(optarg, "DPS") == 0) {
                connectionType = ConnectionType_DPS;
            } else if (strcmp(optarg, "Direct") == 0) {
                connectionType = ConnectionType_Direct;
            } else if (strcmp(optarg, "IoTEdge") == 0) {
                connectionType = ConnectionType_IoTEdge;
            }
            break;
        case 's':
            Log_Debug("ScopeID: %s\n", optarg);
            scopeId = optarg;
            break;
        case 'h':
            Log_Debug("Hostname: %s\n", optarg);
            hostName = optarg;
            break;
        case 'i':
            Log_Debug("IoTEdgeRootCAPath: %s\n", optarg);
            iotEdgeRootCAPath = optarg;
            break;
        default:
            break;
        }
    }
}
static void ParseCommandLineArguments ( int argc , char * argv [ ] ) { int option = 0 ; static const struct option cmdLineOptions [ ] = { { . name = " " , . has_arg = required_argument , . flag = NULL , . val = ' ' } , { . name = " " , . has_arg = required_argument , . flag = NULL , . val = ' ' } , { . name = " " , . has_arg = required_argument , . flag = NULL , . val = ' ' } , { . name = " " , . has_arg = required_argument , . flag = NULL , . val = ' ' } , { . name = NULL , . has_arg = 0 , . flag = NULL , . val = 0 } } ; while ( ( option = getopt_long ( argc , argv , " " , cmdLineOptions , NULL ) ) != -1 ) { if ( optarg != NULL && optarg [ 0 ] == ' ' ) { Log_Debug ( " \n " , option ) ; continue ; } switch ( option ) { case ' ' : Log_Debug ( " \n " , optarg ) ; if ( strcmp ( optarg , " " ) == 0 ) { connectionType = ConnectionType_DPS ; } else if ( strcmp ( optarg , " " ) == 0 ) { connectionType = ConnectionType_Direct ; } else if ( strcmp ( optarg , " " ) == 0 ) { connectionType = ConnectionType_IoTEdge ; } break ; case ' ' : Log_Debug ( " \n " , optarg ) ; scopeId = optarg ; break ; case ' ' : Log_Debug ( " \n " , optarg ) ; hostName = optarg ; break ; case ' ' : Log_Debug ( " \n " , optarg ) ; iotEdgeRootCAPath = optarg ; break ; default : break ; } } }
<summary>
Parse the command line arguments given in the application manifest.
<summary > Parse the command line arguments given in the application manifest .
// Loop over all of the options. // Check if arguments are missing. Every option requires an argument. // Unknown options are ignored.