Ejemplo n.º 1
0
static void
find_full_tree(void)
{
	const char * extract_subdir[] = {
		bmake_path,
		"show-subdir-var",
		"VARNAME=SUBDIR",
		NULL
	};
	char *cat_path;
	char *buf, *buf_orig, *cat, *cat_orig;
	size_t buf_len, cat_len;

	buf = read_from_child(pkgsrc_tree, bmake_path, extract_subdir);

	if (buf == NULL)
		err(1, "Cannot extract categories");

	cat = cat_orig = buf;
	for (;;) {
		cat += strspn(cat, " \t\n");
		cat_len = strcspn(cat, " \t\n");
		if (cat_len == 0)
			break;

		cat_path = xasprintf("%s/%.*s", pkgsrc_tree, (int)cat_len, cat);
		buf_orig = buf = read_from_child(cat_path, bmake_path, extract_subdir);
		free(cat_path);
		if (buf == NULL) {
			warnx("Cannot extract subdirectories for %.*s", (int)cat_len, cat);
			cat += cat_len;
			continue;
		}

		for (;;) {
			buf += strspn(buf, " \t\n");
			buf_len = strcspn(buf, " \t\n");
			if (buf_len == 0)
				break;
			add_job(cat, cat_len, buf, buf_len);
			buf += buf_len;
		}
		free(buf_orig);

		cat += cat_len;
	}

	free(cat_orig);
}
Ejemplo n.º 2
0
int main() {
	int ret;
    int fd_A[2];

    if (pipe(fd_A) == -1) {
        perror("pipe");
        exit(1);
    }

	ret = fork();
	if (ret < 0) {
		perror("fork");
		exit(1);

	} else if (ret == 0) {
		/* I am the child and I will write only, so close reading end of pipe */
        // STEP 1: Add the close call below 
        if XXX  {
            perror("close");
            exit(1);
        }
        write_to_parent(fd_A[1]);
        exit(0);

	} 
    /* I am the parent only so close writing end of pipe to child A */
    // STEP 1: Add the close call below 



	read_from_child(fd_A[0]);
	return 0;
}
Ejemplo n.º 3
0
char *
scan_pkglocation(const char *pkg_location)
{
	const char * extract_pbulk_index[] = {
		bmake_path,
		"pbulk-index",
		NULL
	};
	char *path, *buf;

	path = xasprintf("%s/%s", pkgsrc_tree, pkg_location);
	buf = read_from_child(path, bmake_path, extract_pbulk_index);
	free(path);

	return buf;
}