cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob 6f70904096a0b62330fc5e1b073aa805cd4f19ac 518 bytes (raw)
$ git show HEAD:valid_put_path.rl	# shows this blob on the CLI

 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
 
/*
 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 */
#include "cmogstored.h"

%%{
	machine valid_put_path;
	main := "/dev"digit+ ('/'+) [^/] any+;
}%%

%% write data;

bool mog_valid_put_path(const char *buf, size_t len)
{
	const char *p, *pe;
	int cs;

	if (len <= 0)
		return false;
	if (buf[len - 1] == '/')
		return false;

	%% write init;

	p = buf;
	pe = buf + len;
	%% write exec;

	return cs != valid_put_path_error;
}

git clone https://yhbt.net/cmogstored.git