Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/src/cmd/refer/result.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#include "refer.h"

/*
 * write the tag values referenced by the List items;
 * limit output to at most taglim values
 */
void result(List *drops, int taglim, FILE *fc)
{
	int i, nf;
	char *s;
	char res[200];

	if ((nf = drops->n) > taglim)
		nf = taglim;
	for (i = 0; i < nf; i++) {
		xseek(fc, drops->el[i], 0);
		fgets(res, sizeof(res), fc);
		if ((s = strchr(res, ';')) != 0) {
			*s++ = '\n';
			*s = '\0';
		}
		if (tagout != 0) {
			if (res[0] == '/' || usedir[0] == 0)
				sprintf(tagout, "%s", res);
			else
				sprintf(tagout, "%s/%s", usedir, res);
			tagout += strlen(tagout);
		} else {
			if (res[0] != '/' || usedir[0] == 0)
				printf("%s/", usedir);
			printf("%s\n", res);
		}
	}
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.