void _handleInputFile (const char *path, int structures) { if ((strlen(path) > 4 && strcmp(path + strlen(path) - 4, ".sdf") == 0) || (strlen(path) > 7 && strcmp(path + strlen(path) - 7, ".sdf.gz") == 0)) { int item, iter = indigoIterateSDFile(path); while ((item = indigoNext(iter))) { indigoArrayAdd(structures, item); indigoFree(item); } indigoFree(iter); } else if ((strlen(path) > 4 && strcmp(path + strlen(path) - 4, ".rdf") == 0) || (strlen(path) > 7 && strcmp(path + strlen(path) - 7, ".rdf.gz") == 0)) { int item, iter = indigoIterateRDFile(path); while ((item = indigoNext(iter))) { indigoArrayAdd(structures, item); indigoFree(item); } indigoFree(iter); } else if ((strlen(path) > 4 && strcmp(path + strlen(path) - 4, ".smi") == 0) || (strlen(path) > 7 && strcmp(path + strlen(path) - 7, ".smi.gz") == 0)) { int item, iter = indigoIterateSmilesFile(path); while ((item = indigoNext(iter))) { indigoArrayAdd(structures, item); indigoFree(item); } indigoFree(iter); } else if ((strlen(path) > 4 && strcmp(path + strlen(path) - 4, ".cml") == 0)) { int item, iter = indigoIterateCMLFile(path); while ((item = indigoNext(iter))) { indigoArrayAdd(structures, item); indigoFree(item); } indigoFree(iter); } else { int item = indigoLoadMoleculeFromFile(path); indigoArrayAdd(structures, item); indigoFree(item); } }
int _isMultipleCML (const char *filename, int *reaction) { int iter = indigoIterateCMLFile(filename); *reaction = 0; if (indigoHasNext(iter)) { int item = indigoNext(iter); if (strstr(indigoRawData(item), "<reaction") != NULL) *reaction = 1; if (indigoHasNext(iter)) { indigoFree(item); indigoFree(iter); return 1; } indigoFree(item); } indigoFree(iter); return 0; }