本文整理汇总了C++中rxx类的典型用法代码示例。如果您正苦于以下问题:C++ rxx类的具体用法?C++ rxx怎么用?C++ rxx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rxx类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: split
int
split (vec<str> *out, rxx pat, str expr, size_t lim, bool emptylast)
{
const char *p = expr;
const char *const e = p + expr.len ();
size_t n;
if (out)
out->clear ();
// check p < e to see that we're not dealing with an empty
// string (especially since x? matches "").
for (n = 0; p < e && n + 1 < lim; n++) {
if (!pat._exec (p, e - p, 0)) {
return 0;
}
if (!pat.success ())
break;
if (out)
out->push_back (str (p, pat.start (0)));
p += max (pat.end (0), 1);
}
if (lim && (p < e || emptylast)) {
n++;
if (out) {
out->push_back (str (p, e - p));
}
}
return n;
}
开发者ID:gildafnai82,项目名称:craq,代码行数:30,代码来源:rxx.C
示例2: collect_pound_def
static void
collect_pound_def (str s)
{
static rxx x ("#\\s*define\\s*(\\S+)\\s+(.*)");
if (guess_defines && x.match (s)) {
collect_constant (x[1], "RPC_CONSTANT_POUND_DEF");
}
}
开发者ID:okws,项目名称:sfslite,代码行数:8,代码来源:gencfile.C
示例3: is_builtin
static bool
is_builtin(const str &s)
{
static rxx x ("(((unsigned|long|const)\\s+)*|(u_?)?)"
"(bool|char|int|short|quad|long|"
"int(8|16|32|64)_t)");
return x.match (s);
}
开发者ID:gildafnai82,项目名称:craq,代码行数:9,代码来源:genheader.C
示例4: main
int
main (int argc, const char *argv[])
{
if (argc < 2)
return -1;
str parent, filename;
parentpath (parent, filename, str (argv[1]));
warn << parent << "\n";
warn << filename << "\n";
return 0;
vec<str> out;
splitpath (out, argv[1]);
str foo;
while (out.size () > 0 && (foo = out.pop_front ()))
warn << foo << "\n";
return 0;
str path (argv[1]);
// vec<str> out;
static rxx r ("^(.*)/([^/]+)$");
// static rxx r ("^/*([^/]+)(/.*)?$");
// static rxx r ("^s%/[^/]*$%%");
// static rxx pathsplit ("^/*([^/]+)(/.*)?$");
warn << "path: " << path << "\n";
// path = path/r;
if (r.search (path))
{
if (r.len(1) != -1)
warn << r[1] << " -> ";
if (r.len(2) != -1)
warn << r[2] << "\n";
warn << "r[0]: " << r[0] << "\n";
}
warn << split (&out, "/", path) << "\n";
for (unsigned int i=0; i< out.size(); i++)
warn << out[i] << "\n";
return 0;
}
开发者ID:bougyman,项目名称:sfs,代码行数:54,代码来源:rxx_test.C
示例5: str
void
repl_el_capture_t::output (strbuf &out, const char *s, rxx &x)
{
int start = x.start (_i);
int ln = x.len (_i);
if (start >= 0 && ln > 0) {
str repl = str (s + start, ln);
strbuf_output (out, repl);
}
}
开发者ID:aosmith,项目名称:okws,代码行数:11,代码来源:rxx.C
示例6: grouphostrx
bool
sfsgroupmgr::parsegroup (str group, str *gname, str *ghost)
{
static rxx grouphostrx ("([A-Za-z][\\-\\w\\.]{0,31})(@[A-Za-z].+)?");
if (!grouphostrx.match (group)) {
warn << "Could not parse group[@host]: " << group << "\n";
return false;
}
*gname = grouphostrx[1];
*ghost = grouphostrx[2] ? grouphostrx[2].cstr () : "-";
return true;
}
开发者ID:gildafnai82,项目名称:craq,代码行数:12,代码来源:sfsgroupmgr.C
示例7: extract_matches
static void
extract_matches (vec<str> *out, const char *base, rxx &x)
{
bool go = true;
for (int i = 0; go; i++) {
int ln = x.len (i);
int start = x.start (i);
if (ln < 0 || start < 0) { go = false; }
else if (ln > 0) { out->push_back (str (base + start, ln)); }
}
}
开发者ID:aosmith,项目名称:okws,代码行数:13,代码来源:rxx.C
示例8: is_safe
bool
is_safe (const str &d)
{
if (!d || d[0] == '.' || d[d.len () - 1] == '.' || safe_rxx.search (d))
return false;
return true;
}
开发者ID:Y317608039,项目名称:okws,代码行数:7,代码来源:pubutil.C
示例9: parse_hn
bool
parse_hn (const str &in, str *host, int *port)
{
static rxx host_port_rxx ("([.0-9A-Za-z_-]*)(:[0-9]+)?");
if (!host_port_rxx.match (in))
return false;
str h = host_port_rxx[1];
if (h && h.len () > 0 && h != "-")
*host = h;
str p = host_port_rxx[2];
if (p && p.len () > 1) {
const char *pc = p.cstr () + 1;
p = pc;
if (!convertint (p, port))
return false;
}
return true;
}
开发者ID:okws,项目名称:dsdc,代码行数:18,代码来源:dsdc_util.C
示例10:
bool
cgi_mpfd_t::match (const http_inhdr_t &hdr, str *bndry)
{
if (multipart_rxx.match (hdr["content-type"])) {
*bndry = multipart_rxx[1];
return true;
}
return false;
}
开发者ID:Keloran,项目名称:okws,代码行数:9,代码来源:mpfd.C
示例11: rxx_replace_2
str
rxx_replace_2 (str input, rxx pat, str repl_str)
{
repl_t repl;
str ret;
if (!repl.parse (repl_str)) {
warn << "XX cannot parse replacement string: " << repl_str << "\n";
} else {
const char *p = input;
const char *const e = p + input.len ();
strbuf b;
bool go = true;
bool err = false;
// check p < e to see that we're not dealing with an empty
// string (especially since x? matches "").
while (go && !err && p < e) {
if (!pat._exec (p, e - p, 0)) {
warn << "XX regex execution failed\n";
err = true;
}
else if (!pat.success ()) { go = false; }
else {
str pre = str (p, pat.start (0));
strbuf_output (b, pre);
repl.output (b, p, pat);
p += max (pat.end (0), 1);
}
}
if (p < e && !err) {
str post = str (p, e - p);
strbuf_output (b, post);
}
if (!err) { ret = b; }
}
return ret;
}
开发者ID:aosmith,项目名称:okws,代码行数:44,代码来源:rxx.C
示例12: rxx_replace
// Call the replace function for each matched pattern.
str
rxx_replace (str input, rxx pat, rxx_replace_cb_t cb)
{
const char *p = input;
const char *const e = p + input.len ();
strbuf b;
bool go = true;
bool err = false;
str ret;
// check p < e to see that we're not dealing with an empty
// string (especially since x? matches "").
while (go && !err && p < e) {
if (!pat._exec (p, e - p, 0)) {
warn << "XX regex execution failed\n";
err = true;
}
else if (!pat.success ()) { go = false; }
else {
str pre = str (p, pat.start (0));
strbuf_output (b, pre);
vec<str> v;
extract_matches (&v, p, pat);
str repl = (*cb) (&v);
if (repl) {
strbuf_output (b, repl);
}
p += max (pat.end (0), 1);
}
}
if (p < e && !err) {
str post = str (p, e - p);
strbuf_output (b, post);
}
if (!err) { ret = b; }
return ret;
}
开发者ID:aosmith,项目名称:okws,代码行数:44,代码来源:rxx.C
示例13: sockfdre
int
agentconn::cagent_fd (bool required)
{
if (agentfd >= 0)
return agentfd;
static rxx sockfdre ("^-(\\d+)?$");
if (agentsock && sockfdre.search (agentsock)) {
if (sockfdre[1])
agentfd = atoi (sockfdre[1]);
else
agentfd = 0;
if (!isunixsocket (agentfd))
fatal << "fd specified with '-S' not unix domain socket\n";
}
else if (agentsock) {
agentfd = unixsocket_connect (agentsock);
if (agentfd < 0 && required)
fatal ("%s: %m\n", agentsock.cstr ());
}
else if (ccd (false)) {
int32_t res;
if (clnt_stat err = ccd ()->scall (AGENT_GETAGENT, NULL, &res)) {
if (required)
fatal << "sfscd: " << err << "\n";
}
else if (res) {
if (required)
fatal << "connecting to agent via sfscd: " << strerror (res) << "\n";
}
else if ((agentfd = sfscdxprt->recvfd ()) < 0) {
fatal << "connecting to agent via sfscd: "
<< "could not get file descriptor\n";
}
}
else {
if (str sock = agent_usersock (true))
agentfd = unixsocket_connect (sock);
if (agentfd < 0 && required)
fatal << "sfscd not running and no standalone agent socket\n";
}
return agentfd;
}
开发者ID:gildafnai82,项目名称:craq,代码行数:43,代码来源:agentconn.C
示例14: pri2del
bool
pri2del (sfsauth_dbrec *dbrp, str aek)
{
static rxx userrx ("^USER:([^:])$");
static rxx grouprx ("^GROUP:([^:])$");
if (userrx.match (aek)) {
dbrp->set_type (SFSAUTH_DELUSER);
*dbrp->deleted = userrx[1];
}
else if (grouprx.match (aek)) {
dbrp->set_type (SFSAUTH_DELGROUP);
*dbrp->deleted = grouprx[1];
}
else {
dbrp->set_type (SFSAUTH_ERROR);
*dbrp->errmsg = strbuf () << "illegal deleted DB key " << aek;
return false;
}
return true;
}
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:20,代码来源:dbrec2str.C
示例15: aekey
str
aekey (const sfsauth_dbrec &ae)
{
switch (ae.type) {
case SFSAUTH_USER:
return strbuf () << "USER:" << ae.userinfo->name;
case SFSAUTH_GROUP:
return strbuf () << "GROUP:" << ae.groupinfo->name;
case SFSAUTH_CACHEENTRY:
return strbuf () << "CACHE:" << ae.cacheentry->key;
default:
{
static rxx knrx ("^[^:]*:[^:]*");
str astr = authdbrec2str (&ae);
if (!astr)
return NULL;
if (!knrx.search (astr))
panic << "missing colon: " << astr << "\n";
return knrx[0];
}
}
}
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:22,代码来源:authdb.C
示例16: sfs_connect_srp
sfs_connect_t *
sfs_connect_srp (str u, srp_client *srpp, sfs_connect_cb cb,
str *userp, str *pwdp, bool *serverokp)
{
static rxx usrhost ("^([^@]+)[email protected](.*)$");
if (!usrhost.match (u)) {
if (userp)
*userp = u;
(*cb) (NULL, "not of form [user]@hostname");
return NULL;
}
str user (usrhost[1]), host (usrhost[2]);
if (!user && !(user = myusername ())) {
(*cb) (NULL, "could not get local username");
return NULL;
}
ref<sfssrp_authorizer> a (New refcounted<sfssrp_authorizer>);
a->srpc = srpp;
sfs_connect_t *cs
= New sfs_connect_t (wrap (sfs_connect_srp_2,
sfs::bundle_t<ref<sfssrp_authorizer>,
str *, str *> (a, userp, pwdp),
serverokp, cb));
cs->sname () = host;
cs->service () = SFS_AUTHSERV;
cs->encrypt = true;
cs->check_hostid = false;
cs->authorizer = a;
cs->aarg.user = user;
if (!cs->start ())
return NULL;
return cs;
}
开发者ID:Sidnicious,项目名称:sfslite,代码行数:36,代码来源:sfssrpconnect.C
示例17: str2authdbrec
bool
str2authdbrec (sfsauth_dbrec *dbr, str s)
{
static rxx _userrx ("^USER:(.*)$");
rxx userrx (_userrx);
static rxx grouprx ("^GROUP:(.*)$");
static rxx cacherx ("^CACHE:(.*)$");
static rxx logrx ("^LOG:(.*)$");
static rxx revinfo ("^REVINFO:([0-9a-fA-F]+):(\\d+)$");
if (revinfo.match (s)) {
str id = hex2bytes (revinfo[1]);
u_int64_t rev;
if (!id || id.len () != sizeof (dbr->revinfo->dbid)
|| !convertint (revinfo[2], &rev))
return false;
dbr->set_type (SFSAUTH_REVINFO);
dbr->revinfo->dbrev = rev;
memcpy (dbr->revinfo->dbid.base (), id, id.len ());
return true;
}
else if (userrx.match (s)) {
dbr->set_type (SFSAUTH_USER);
return str2userinfo (dbr->userinfo, str2wstr (userrx[1]));
}
else if (grouprx.match (s)) {
dbr->set_type (SFSAUTH_GROUP);
return str2groupinfo (dbr->groupinfo, grouprx[1]);
}
else if (cacherx.match (s)) {
dbr->set_type (SFSAUTH_CACHEENTRY);
return str2cacheentry (dbr->cacheentry, cacherx[1]);
}
else if (logrx.match (s)) {
dbr->set_type (SFSAUTH_LOGENTRY);
return str2logentry (dbr->logentry, logrx[1]);
}
else
return false;
}
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:40,代码来源:dbrec2str.C
示例18: parseconfig
static void
parseconfig ()
{
str cf = configfile;
parseargs pa (cf);
bool errors = false;
str hostname;
rpc_ptr<sfs_hash> hostid;
server *s = NULL;
release *r = NULL;
extension *e = NULL;
char *c;
int line;
vec<str> av;
while (pa.getline (&av, &line)) {
if (!strcasecmp (av[0], "BindAddr")) {
in_addr addr;
u_int16_t port = 0;
if (av.size () < 2 || av.size () > 3
|| !inet_aton (av[1], &addr)
|| (av.size () == 3 && !convertint (av[2], &port))) {
warn << cf << ":" << line
<< ": usage: BindAddr addr [port]\n";
errors = true;
continue;
}
if (!port)
port = sfs_defport ? sfs_defport : SFS_PORT;
sockaddr_in *sinp
= static_cast<sockaddr_in *> (xmalloc (sizeof (*sinp)));
bzero (sinp, sizeof (*sinp));
sinp->sin_family = AF_INET;
sinp->sin_port = htons (port);
sinp->sin_addr = addr;
#ifdef HAVE_SA_LEN
sinp->sin_len = sizeof (*sinp);
#endif /* HAVE_SA_LEN */
listenaddrs.push_back (reinterpret_cast<sockaddr *> (sinp));
}
else if (!strcasecmp (av[0], "Server")) {
if (av.size () != 2) {
warn << cf << ":" << line
<< ": usage: Server {hostname|*}[:hostid]\n";
errors = true;
continue;
}
if (strchr (av[1], ':') ||
((c = strchr (av[1], '@')) && strchr (c, ','))) {
hostid.alloc ();
if (!sfs_parsepath (av[1], &hostname, hostid)) {
warn << cf << ":" << line << ": bad hostname/hostid\n";
errors = true;
continue;
}
}
else {
hostid.clear ();
if (av[1] == "*")
hostname = sfshostname ();
else
hostname = av[1];
}
for (s = serverlist.first; s; s = serverlist.next (s))
if (hostname == s->host
&& ((hostid && s->hostid && *hostid == *s->hostid)
|| (!hostid && !s->hostid)))
break;
if (!s)
s = New server (hostname, hostid);
r = NULL;
e = NULL;
}
else if (!strcasecmp (av[0], "Release")) {
static rxx relrx ("^(\\d+)\\.(\\d\\d?)$");
if (av.size () != 2 || (!relrx.search (av[1]) && av[1] != "*")) {
warn << cf << ":" << line << ": usage Release { N.NN | * }\n";
errors = true;
r = NULL;
continue;
}
if (!s) {
warn << cf << ":" << line << ": Release must follow Server\n";
errors = true;
r = NULL;
continue;
}
u_int32_t rel;
if (av[1] == "*")
rel = 0xffffffff;
else
rel = strtoi64 (relrx[1]) * 100 + strtoi64 (relrx[2]);
r = s->reltab[rel];
if (!r)
s->reltab.insert ((r = New release (rel)));
for (e = r->extlist.first; r->extlist.next (e); e = r->extlist.next (e))
;
}
//.........这里部分代码省略.........
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:101,代码来源:sfssd.C
示例19: adminrx
void
authclnt::sfsauth_update (svccb *sbp)
{
update_info i;
i.cp = NULL;
i.ur = NULL;
if (sbp->getaui () >= credtab.size ()
|| !(i.cp = &credtab[sbp->getaui ()])
|| i.cp->type != SFS_UNIXCRED
|| !(i.ur = utab[sbp->getaui ()])
|| i.ur->authtype == SFS_NOAUTH) {
sbp->reject (AUTH_REJECTEDCRED);
return;
}
i.res.set_ok (false);
i.kname.set_type (SFSAUTH_DBKEY_NAME);
*i.kname.name = i.cp->unixcred->username;
dbfile *cdbp;
if (!get_user_cursor (&cdbp, NULL, &i.cdbr, i.kname)
|| i.cp->unixcred->username != i.cdbr.userinfo->name) {
*i.res.errmsg = "could not load credential db record";
sbp->replyref (i.res);
return;
}
if (i.cp->unixcred->uid != i.cdbr.userinfo->id) {
*i.res.errmsg = "invalid uid";
warn << i.cp->unixcred->username << " authenticated with uid "
<< i.cp->unixcred->uid << " while DB record has uid "
<< i.cdbr.userinfo->id << "\n";
warn << "could user " << i.cp->unixcred->username << " have"
<< " wrong UID in sfs_users file?\n";
sbp->replyref (i.res);
return;
}
i.argp = sbp->Xtmpl getarg<sfsauth2_update_arg> ();
if (i.argp->req.type != SFS_UPDATEREQ
|| (i.argp->req.rec.type != SFSAUTH_USER
&& i.argp->req.rec.type != SFSAUTH_GROUP)) {
*i.res.errmsg = "invalid request";
sbp->replyref (i.res);
return;
}
i.opts = i.argp->req.opts;
if (i.argp->req.authid != authid) {
*i.res.errmsg = "invalid authid";
sbp->replyref (i.res);
return ;
}
static rxx adminrx ("(\\A|,)admin(\\Z|,)");
i.admin = cdbp->allow_admin && adminrx.search (i.cdbr.userinfo->privs);
if (!update_checksig (sbp, i, cdbp))
return;
if (i.argp->req.rec.type == SFSAUTH_USER)
update_user (sbp, i);
else
update_group (sbp, i);
sbp->replyref (i.res);
}
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:67,代码来源:authclnt_update.C
示例20: get_group_cursor
void
authclnt::update_group (svccb *sbp, update_info &i)
{
dbfile *udbp;
ptr<authcursor> uac;
sfsauth_dbrec udbr;
*i.kname.name = i.argp->req.rec.groupinfo->name;
bool create = i.argp->req.rec.groupinfo->id == 0
&& i.argp->req.rec.groupinfo->vers == 1;
bool exists = get_group_cursor (&udbp, &uac, &udbr, i.kname, true, create);
if (exists && create && udbr.groupinfo->id > udbp->grprange->id_max) {
*i.res.errmsg = strbuf () << "all group IDs in the allowed range ("
<< udbp->grprange->id_min << "-"
<< udbp->grprange->id_max << ") are in use";
return;
}
if (!exists) {
if (!create) {
*i.res.errmsg = "perhaps record is read-only "
"or database doesn't accept group updates";
return;
}
else {
*i.res.errmsg = "no writable databases that accept group updates";
return;
}
}
if (create && udbr.groupinfo->vers != 0) {
*i.res.errmsg = strbuf () << "group `" << udbr.groupinfo->name
<< "'already exists";
return;
}
if (!i.admin) {
if (create) {
str gname;
if (!(gname = group_prefix (udbr.groupinfo->name, i.cdbr.userinfo->name))
|| gname.len () < 1) {
*i.res.errmsg = strbuf () << "group name must be of the form `"
<< i.cdbr.userinfo->name << ".groupname'";
return;
}
static rxx groupquotarx ("(\\A|,)groupquota=([0-9]+)(\\Z|,)");
if (groupquotarx.search (i.cdbr.userinfo->privs)
|| udbp->default_groupquota >= 0) {
u_int32_t max_groups;
u_int32_t cur_groups;
if (groupquotarx.success ())
convertint (groupquotarx[2], &max_groups);
else
max_groups = udbp->default_groupquota;
// XXX - open could fail
ptr<authcursor> gac = udbp->db->open (udbp->dbflags);
cur_groups = gac->count_group_prefix (strbuf ()
<< i.cdbr.userinfo->name << ".");
if (cur_groups + 1 > max_groups) {
*i.res.errmsg = strbuf () << "group quota exceeded (current="
<< cur_groups << "/quota=" << max_groups << ")";
return;
}
}
}
else {
ptr<sfspub> pk = sfscrypt.alloc (i.cdbr.userinfo->pubkey);
str h = armor32 (pk->get_pubkey_hash ());
sfs_groupmembers list;
unsigned int n = udbr.groupinfo->owners.size ();
for (unsigned int j = 0; j < n; j++)
list.push_back (udbr.groupinfo->owners[j]);
if (!group_prefix (udbr.groupinfo->name, i.cdbr.userinfo->name)
&& !is_a_member (i.cdbr.userinfo->name, h, list)) {
*i.res.errmsg = "access denied";
return;
}
}
}
if (i.argp->req.rec.groupinfo->vers < 1) {
*i.res.errmsg = "version number of record must be greater than 0";
return;
}
if (i.argp->req.rec.groupinfo->vers != udbr.groupinfo->vers + 1) {
*i.res.errmsg = "version mismatch";
return;
}
uac->ae.groupinfo->vers = i.argp->req.rec.groupinfo->vers;
strbuf sb;
sb << "Last modified " << timestr () << " by " ;
if (uid && !*uid)
sb << "*superuser*";
else
sb << i.cp->unixcred->username;
sb << "@" << client_name;
uac->ae.groupinfo->audit = sb;
//.........这里部分代码省略.........
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:101,代码来源:authclnt_update.C
注:本文中的rxx类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论