File: shared_parser.c

package info (click to toggle)
drbd-utils 9.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,388 kB
  • sloc: ansic: 43,698; xml: 15,968; cpp: 7,783; sh: 3,699; makefile: 1,353; perl: 353
file content (73 lines) | stat: -rw-r--r-- 1,740 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 *
   drbdadm_parser.c a hand crafted parser

   This file is part of DRBD by Philipp Reisner and Lars Ellenberg.

   Copyright (C) 2014, LINBIT HA Solutions GmbH

   drbd is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   drbd is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with drbd; see the file COPYING.  If not, write to
   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

 */


#define _GNU_SOURCE

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <glob.h>
#include <search.h>
#include <fcntl.h>
#include <unistd.h>

#include "shared_parser.h"
#include "drbdadm.h"
#include "drbdadm_parser.h"

extern void my_parse(void);


void save_parse_context(struct include_file_buffer *buffer, FILE *f, char *name)
{
	buffer->line = line;
	buffer->config_file = config_file;
	buffer->config_save = config_save;

	line = 1;
	config_file = name;
	config_save = canonify_path(name);

	my_yypush_buffer_state(f);

}

void restore_parse_context(struct include_file_buffer *buffer)
{
	yypop_buffer_state();

	line = buffer->line;
	config_file = buffer->config_file;
	config_save = buffer->config_save;
}

void include_file(FILE *f, char *name)
{
	struct include_file_buffer buffer;

	save_parse_context(&buffer, f, name);
	my_parse();
	restore_parse_context(&buffer);
}