void inspectCommand_execute(command_pt command, char * commandline, void (*out)(char *), void (*err)(char *)) { celix_status_t status = CELIX_SUCCESS; char outString[256]; char *token; char *commandStr = strtok_r(commandline, " ", &token); char *type = strtok_r(NULL, " ", &token); if (type != NULL) { char *direction = strtok_r(NULL, " ", &token); if (direction != NULL) { array_list_pt ids = NULL; char *id = strtok_r(NULL, " ", &token); arrayList_create(&ids); while (id != NULL) { arrayList_add(ids, id); id = strtok_r(NULL, " ", &token); } if (strcmp(type, SERVICE_TYPE) == 0) { if (strcmp(direction, CAPABILITY) == 0) { status = inspectCommand_printExportedServices(command, ids, out, err); if (status != CELIX_SUCCESS) { out("INSPECT: Error\n"); } } else if (strcmp(direction, REQUIREMENT) == 0) { status = inspectCommand_printImportedServices(command, ids, out, err); if (status != CELIX_SUCCESS) { out("INSPECT: Error\n"); } } else { out("INSPECT: Invalid argument\n"); sprintf(outString, "%s\n", command->usage); out(outString); } } else { out("INSPECT: Invalid argument\n"); sprintf(outString, "%s\n", command->usage); out(outString); } } else { out("INSPECT: Too few arguments\n"); sprintf(outString, "%s\n", command->usage); out(outString); } } else { out("INSPECT: Too few arguments\n"); sprintf(outString, "%s\n", command->usage); out(outString); } }
celix_status_t inspectCommand_execute(void *handle, char * commandline, FILE *outStream, FILE *errStream) { celix_status_t status = CELIX_SUCCESS; bundle_context_pt context = handle; char *token; strtok_r(commandline, " ", &token); char *type = strtok_r(NULL, " ", &token); if (type != NULL) { char *direction = strtok_r(NULL, " ", &token); if (direction != NULL) { array_list_pt ids = NULL; char *id = strtok_r(NULL, " ", &token); arrayList_create(&ids); while (id != NULL) { arrayList_add(ids, id); id = strtok_r(NULL, " ", &token); } if (strcmp(type, SERVICE_TYPE) == 0) { if (strcmp(direction, CAPABILITY) == 0) { status = inspectCommand_printExportedServices(context, ids, outStream, errStream); if (status != CELIX_SUCCESS) { fprintf(errStream, "INSPECT: Error\n"); } } else if (strcmp(direction, REQUIREMENT) == 0) { status = inspectCommand_printImportedServices(context, ids, outStream, errStream); if (status != CELIX_SUCCESS) { fprintf(errStream, "INSPECT: Error\n"); } } else { fprintf(errStream, "INSPECT: Invalid argument\n"); } } else { fprintf(errStream, "INSPECT: Invalid argument\n"); } arrayList_destroy(ids); } else { fprintf(errStream, "INSPECT: Too few arguments\n"); } } else { fprintf(errStream, "INSPECT: Too few arguments\n"); } return status; }