Пример #1
0
int
pfr_buf_load(struct pfr_buffer *b, char *file, int nonetwork)
{
	FILE	*fp;
	char	 buf[BUF_SIZE];
	int	 rv;
	int	 ev = 0;

	if (file == NULL)
		return (0);
	if (!strcmp(file, "-"))
		fp = stdin;
	else {
		fp = pfctl_fopen(file, "r");
		if (fp == NULL)
			return (-1);
	}
	while ((rv = pfr_next_token(buf, fp)) == 1)
		if ((ev = append_addr(b, buf, nonetwork)) == -1) {
			rv = -1;
			break;
		}
	if (ev == 1) /* expected further append_addr call */
		rv = -1;
	if (fp != stdin)
		fclose(fp);
	return (rv);
}
Пример #2
0
int
pfr_buf_load(struct pfr_buffer *b, char *file, int nonetwork,
    int (*append_addr)(struct pfr_buffer *, char *, int))
{
	FILE	*fp;
	char	 buf[BUF_SIZE];
	int	 rv;

	if (file == NULL)
		return (0);
	if (!strcmp(file, "-"))
		fp = stdin;
	else {
		fp = pfctl_fopen(file, "r");
		if (fp == NULL)
			return (-1);
	}
	while ((rv = pfr_next_token(buf, fp)) == 1)
		if (append_addr(b, buf, nonetwork)) {
			rv = -1;
			break;
		}
	if (fp != stdin)
		fclose(fp);
	return (rv);
}