Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
finish option handling
Baptiste Daroussin committed 15 years ago
commit 1b43fed910c46f1945e4bc0414ccbbf1519e0508
parent 997b4ecdfb403a5632ea1e16ee22e5cc22737262
3 files changed +30 -1
modified libpkg/pkg.h
@@ -173,5 +173,6 @@ int ports_parse_plist(struct pkg *, char *, const char *);
int ports_parse_depends(struct pkg *, char *);
int ports_parse_conflicts(struct pkg *, char *);
int ports_parse_scripts(struct pkg *, char *);
+
int ports_parse_options(struct pkg *, char *);

#endif
modified libpkg/pkg_ports.c
@@ -184,3 +184,31 @@ ports_parse_scripts(struct pkg *pkg, char *scripts)

	return (0);
}
+

+
int
+
ports_parse_options(struct pkg *pkg, char *options)
+
{
+
	int nbel, i;
+
	char *option_p;
+
	size_t next;
+
	char *value;
+

+
	if (options == NULL)
+
		return (-1);
+

+
	nbel = split_chr(options, ' ');
+
	option_p = options;
+

+
	next = strlen(option_p);
+
	for (i = 0; i <= nbel; i++) {
+
		value = strrchr(option_p, '=');
+
		value[0] = '\0';
+
		value++;
+
		pkg_addoption(pkg, option_p, value);
+

+
		option_p += next + 1;
+
		next = strlen(option_p);
+
	}
+

+
	return (0);
+
}
modified pkg/register.c
@@ -82,7 +82,7 @@ exec_register(int argc, char **argv)
				pkg_set(pkg, PKG_WWW, optarg);
				break;
			case 'O':
-
				/* TODO options handling */
+
				ret += ports_parse_options(pkg, optarg);
				break;
			default:
				printf("%c\n", ch);