in src/fc_section_list_argc_argv.c [70:150]
ARGC_ARGV_DATA_RESULT FABRIC_CONFIGURATION_SECTION_LIST_from_ARGC_ARGV(int argc, char** argv, FABRIC_CONFIGURATION_SECTION_LIST* fabric_configuration_section_list, int* argc_consumed)
{
ARGC_ARGV_DATA_RESULT result;
if (
(fabric_configuration_section_list == NULL) ||
(argc_consumed == NULL)
)
{
LogError("invalid arguments int argc=%d, char** argv=%p, FABRIC_CONFIGURATION_SECTION_LIST* fabric_configuration_section_list=%p, int* argc_consumed=%p",
argc, argv, fabric_configuration_section_list, argc_consumed);
result = ARGC_ARGV_DATA_ERROR;
}
else
{
*argc_consumed = 0;
fabric_configuration_section_list->Count = 0;
fabric_configuration_section_list->Items = NULL;
bool done = false;
bool wasError = false;
while(!done && !wasError)
{
FABRIC_CONFIGURATION_SECTION fabric_configuration_section;
int c_argc;
ARGC_ARGV_DATA_RESULT r = FABRIC_CONFIGURATION_SECTION_from_ARGC_ARGV(argc - *argc_consumed, argv + *argc_consumed, &fabric_configuration_section, &c_argc);
switch (r)
{
case ARGC_ARGV_DATA_OK:
{
if (c_argc == 0)
{
/*valid data, but nothing was consumed, we are done*/
done = true;
}
else
{
fabric_configuration_section_list->Count++;
FABRIC_CONFIGURATION_SECTION* new_sections = realloc_2((void*)fabric_configuration_section_list->Items, fabric_configuration_section_list->Count, sizeof(FABRIC_CONFIGURATION_SECTION));
if (new_sections == NULL)
{
fabric_configuration_section_list->Count--;
LogError("failure in realloc_2");
}
else
{
fabric_configuration_section_list->Items = new_sections;
/*cast the const away*/
*(FABRIC_CONFIGURATION_SECTION*)& fabric_configuration_section_list->Items[fabric_configuration_section_list->Count - 1] = fabric_configuration_section;
}
*argc_consumed += c_argc;
}
break;
}
case ARGC_ARGV_DATA_INVALID:
{
done = true;
break;
}
default:
case ARGC_ARGV_DATA_ERROR:
{
wasError = true;
break;
}
}
}
if (wasError)
{
result = ARGC_ARGV_DATA_ERROR;
}
else
{
result = ARGC_ARGV_DATA_OK;
}
}
return result;
}