-static int prow(void *f, int ncols, char **vals, char **cols) {
- FILE *out = f;
- int i;
-
- if (cols == 0) {
- fprintf(stderr, "sqlite can't get column names\n");
- }
- for (i=3;i<ncols;i++) {
- if (i>3) fprintf(out, "\t");
- fprintf(out, "%s", vals[i]);
- }
- fprintf(out, "\n");
- found++;
- return 0;
-}
-
-void parse_package(char *pstr, char *name, char *ver, int *rel) {
- if (name) *name = 0;
- if (ver) *ver = 0;
- if (rel) *rel = -1;
-
- /* string - ver - rel */
- /* rel is all digits */
- /* possible forms:
- * ^(.+)-([0-9][^-]*)-([\d+])$
- * ^(.+)-([0-9][^-]*)$
- * ^(.+)$
- * The main problem in parsing is that the package name itself
- * can contain a '-', so you can't just split on '-'
- * Also, the version can be just digits.
- */
-
- /* everything up to the first '-' is in the name */
- while (*pstr) {
- if (*pstr == '-' && isdigit(*(pstr+1))) {
- break;
- }
- if (name) {
- *name++ = *pstr;
- }
- pstr++;
- }
- if (name) *name = 0;
- if (*pstr == '-') {
- pstr++;
- }
- while (*pstr && *pstr != '-') {
- if (ver) {
- *ver++ = *pstr;
- }
- pstr++;
- }
- if (ver) *ver = 0;
- if (*pstr == '-') {
- pstr++;
- }
- if (rel && *pstr) {
- *rel = atoi(pstr);
- }
-}
-