static int Command(Context_t *context, ContainerCmd_t command, void *argument) { int ret = 0; container_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); switch (command) { case CONTAINER_ADD: { ret = selectContainer(context, (char *) argument); break; } case CONTAINER_CAPABILITIES: { printContainerCapabilities(); break; } case CONTAINER_DEL: { context->container->selectedContainer = NULL; break; } default: container_err("%s::%s ContainerCmd %d not supported!\n", FILENAME, __FUNCTION__, command); break; } return ret; }
static int selectContainer(Context_t *context, char * extension) { int i, j; int ret = -1; container_printf(10, "%s::%s\n", FILENAME, __FUNCTION__); for (i = 0; AvailableContainer[i] != NULL; i++) { for (j = 0; AvailableContainer[i]->Capabilities[j] != NULL; j++) if (!strcasecmp(AvailableContainer[i]->Capabilities[j], extension)) { context->container->selectedContainer = AvailableContainer[i]; container_printf(10, "Selected Container: %s\n", context->container->selectedContainer->Name); ret = 0; break; } if (ret == 0) break; } if (ret != 0) { container_err("No Container found :-(\n"); } return ret; }