char * parse_simple(const char *type, const char *line) { char *field = trim_xstrdup(line + strlen(type) + 1); if (strlen(field) == 0) { free(field); return NULL; } return field; }
static int parseDepends(compound_depend_t * compound_depend, const char *depend_str) { char *pkg_name, buffer[2048]; unsigned int num_of_ors = 0; unsigned int i; const char *src; char *dest; depend_t **possibilities; /* first count the number of ored possibilities for satisfying dependency */ src = depend_str; while (*src) if (*src++ == '|') num_of_ors++; compound_depend->type = DEPEND; compound_depend->possibility_count = num_of_ors + 1; possibilities = xcalloc((num_of_ors + 1), sizeof(depend_t *)); compound_depend->possibilities = possibilities; src = depend_str; for (i = 0; i < num_of_ors + 1; i++) { possibilities[i] = depend_init(); /* gobble up just the name first */ dest = buffer; while (*src && !isspace(*src) && (*src != '(') && (*src != '*') && (*src != '|')) *dest++ = *src++; *dest = '\0'; pkg_name = trim_xstrdup(buffer); /* now look at possible version info */ /* skip to next chars */ if (isspace(*src)) while (*src && isspace(*src)) src++; /* extract constraint and version */ if (*src == '(') { src++; possibilities[i]->constraint = str_to_constraint(&src); /* now we have any constraint, pass space to version string */ while (isspace(*src)) src++; /* this would be the version string */ dest = buffer; while (*src && *src != ')') *dest++ = *src++; *dest = '\0'; possibilities[i]->version = trim_xstrdup(buffer); } /* hook up the dependency to its abstract pkg */ possibilities[i]->pkg = ensure_abstract_pkg_by_name(pkg_name); free(pkg_name); /* now get past the ) and any possible | chars */ while (*src && (isspace(*src) || (*src == ')') || (*src == '|'))) src++; if (*src == '*') { compound_depend->type = GREEDY_DEPEND; src++; } } return 0; }
char * parse_simple(const char *type, const char *line) { return trim_xstrdup(line + strlen(type) + 1); }