VixError VixToolsValidateEnviron(char const * const *environ) // IN { if (NULL == environ) { return VIX_E_FAIL; } while (NULL != *environ) { /* * Each string should contain at least one '=', to delineate between * the name and the value. */ if (NULL == Str_Strchr(*environ, '=')) { return VIX_E_INVALID_ARG; } environ++; } return VIX_OK; }
char * File_PrependToPath(const char *searchPath, // IN: const char *elem) // IN: { const char sep = FILE_SEARCHPATHTOKEN[0]; char *newPath; char *path; size_t n; ASSERT(searchPath); ASSERT(elem); newPath = Str_SafeAsprintf(NULL, "%s%s%s", elem, FILE_SEARCHPATHTOKEN, searchPath); n = strlen(elem); path = newPath + n + 1; for (;;) { char *next = Str_Strchr(path, sep); size_t len = next ? next - path : strlen(path); if ((len == n) && (Str_Strncmp(path, elem, len) == 0)) { if (next) { memmove(path, next + 1, strlen(next + 1) + 1); } else { *--path = '\0'; } break; } if (!next) { break; } path = next + 1; } return newPath; }