File: buffer.c

package info (click to toggle)
postgresql 7.2.1-2woody8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 42,424 kB
  • ctags: 30,027
  • sloc: ansic: 290,568; java: 18,529; sh: 12,197; sql: 11,401; yacc: 11,189; tcl: 8,063; perl: 4,067; makefile: 3,332; xml: 2,874; lex: 2,799; python: 1,237; cpp: 845; pascal: 81; asm: 70; awk: 20; sed: 8
file content (84 lines) | stat: -rw-r--r-- 1,471 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
/* This module defines the parse buffer and routines for setting/reading it */

#include "postgres.h"

#include "utils/elog.h"

static char *PARSE_BUFFER;
static char *PARSE_BUFFER_PTR;
static unsigned int PARSE_BUFFER_SIZE;
static unsigned int SCANNER_POS;

void		set_parse_buffer(char *s);
void		reset_parse_buffer(void);
int			read_parse_buffer(void);
char	   *parse_buffer(void);
char	   *parse_buffer_ptr(void);
unsigned int parse_buffer_curr_char(void);
unsigned int parse_buffer_size(void);
unsigned int parse_buffer_pos(void);

extern void cube_flush_scanner_buffer(void);	/* defined in cubescan.l */

void
set_parse_buffer(char *s)
{
	PARSE_BUFFER = s;
	PARSE_BUFFER_SIZE = strlen(s);
	if (PARSE_BUFFER_SIZE == 0)
		elog(ERROR, "cube_in: can't parse an empty string");
	PARSE_BUFFER_PTR = PARSE_BUFFER;
	SCANNER_POS = 0;
}

void
reset_parse_buffer(void)
{
	PARSE_BUFFER_PTR = PARSE_BUFFER;
	SCANNER_POS = 0;
	cube_flush_scanner_buffer();
}

int
read_parse_buffer(void)
{
	int			c;

	/*
	 * c = *PARSE_BUFFER_PTR++; SCANNER_POS++;
	 */
	c = PARSE_BUFFER[SCANNER_POS];
	if (SCANNER_POS < PARSE_BUFFER_SIZE)
		SCANNER_POS++;
	return c;
}

char *
parse_buffer(void)
{
	return PARSE_BUFFER;
}

unsigned int
parse_buffer_curr_char(void)
{
	return PARSE_BUFFER[SCANNER_POS];
}

char *
parse_buffer_ptr(void)
{
	return PARSE_BUFFER_PTR;
}

unsigned int
parse_buffer_pos(void)
{
	return SCANNER_POS;
}

unsigned int
parse_buffer_size(void)
{
	return PARSE_BUFFER_SIZE;
}