本文整理汇总了C++中rxx::match方法的典型用法代码示例。如果您正苦于以下问题:C++ rxx::match方法的具体用法?C++ rxx::match怎么用?C++ rxx::match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rxx
的用法示例。
在下文中一共展示了rxx::match方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static bool
userinfo2str (strbuf &sb, const sfsauth_userinfo *ui)
{
str audit = single_char_sub (ui->audit, ':', ".");
if (!namerx.match (ui->name) ||
(ui->owner && !namerx.match (*ui->owner)) ||
!nobadrx.match (ui->privs) ||
badcharrx.search (ui->pwauth) ||
badcharrx.search (audit))
return false;
sb << ui->name;
sb.fmt (":%u:%u:%u:", ui->id, ui->vers, ui->gid);
if (ui->owner)
sb << *ui->owner;
sb << ":";
ptr<sfspub> pk = sfscrypt.alloc (ui->pubkey);
if (!pk)
return false;
pk->export_pubkey (sb);
sb << ":" << ui->privs << ":" << ui->pwauth << ":";
str priv = str2wstr (armor64 (ui->privkey.base (), ui->privkey.size()));
sb << priv << ":";
sfs_2schnorr_priv::export_keyhalf (ui->srvprivkey, sb);
// sb << ":" << ui->refresh << ":" << ui->timeout;
sb << ":" << audit;
return true;
}
示例2: x
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");
}
}
示例3: x
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);
}
示例4:
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;
}
示例5: userrx
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;
}
示例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;
}
示例7:
bool
to_hostname_and_port (const str &in, str *out, int *port)
{
bool ret = true;
if (!host_and_port.match (in) ||
(host_and_port[3] && !convertint (host_and_port[3], port))) {
ret = false;
} else {
*out = host_and_port[1];
}
return ret;
}
示例8: _userrx
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;
}
示例9: host_port_rxx
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;
}
示例10: usrhost
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;
}
示例11: namerx
bool
nameok (const str &name)
{
static rxx namerx ("[a-zA-Z0-9\\-]+(\\.[a-zA-Z0-9\\-]+)*");
return name.len () < NFS_MAXNAMLEN && namerx.match (name);
}
示例12: lose_patience_rxx
//.........这里部分代码省略.........
break;
case 'M':
if (!convertint (optarg, &lat_mean))
usage ();
if (noisy) warn << "Mean of latencies: " << lat_mean << "\n";
break;
case 'P':
if (!convertint (optarg, &tmp))
usage ();
tpt_sample_period_secs = tmp / THOUSAND;
tpt_sample_period_nsecs = (tmp % THOUSAND) * MILLION;
if (noisy)
warn ("Sample throughput period=%d.%03d secs\n",
tpt_sample_period_secs,
tpt_sample_period_nsecs / MILLION);
break;
case 'R':
req_cycler = New id_cycler_t ();
if (!req_cycler->init (optarg))
usage ();
break;
case 'S':
if (!convertint (optarg, &lat_stddv))
usage ();
if (noisy) warn << "Standard dev. of latency: " << lat_stddv << "\n";
break;
case 'T':
if (!lose_patience_rxx.match (optarg) ||
!convertint (lose_patience_rxx[1], &n_still_patient) ||
!convertint (lose_patience_rxx[2], &lose_patience_after))
usage ();
break;
case 'V':
svc_cycler = New id_cycler_t ();
if (!svc_cycler->init (optarg))
usage ();
break;
default:
usage ();
}
}
argc -= optind;
argv += optind;
if (argc == 0)
usage ();
str dest = argv[0];
argc --;
argv ++;
// make the appropriate cyclers...
if (argc > 0) {
// in this case, the user supplied extra arguments after the hostname
// and port; therefore, they're going to be making their own URL
// by alternating static parts and cyclers.
if (req_cycler) {
示例13: memcpy
bool
str2userinfo (sfsauth_userinfo *ui, str s)
{
str name;
vec<str> uv;
if (split (&uv, colon, s, 12, true) != 11)
return false;
str2wstr (uv[7]);
str2wstr (uv[8]);
str fields[13] = { "name", "uid", "version", "gid", "owner",
"pubkey", "privs", "srp", "privkey",
"srvprivkey", // "refresh", "timeout",
"audit" };
if (!namerx.match (uv[0])) {
err_report ("<null>", 1, fields[0], uv[0]);
return false;
}
name = uv[0];
for (int i = 1; i < 4; i++) {
if (!decrx.match (uv[i])) {
err_report (name, i+1, fields[i], uv[i]);
return false;
}
}
if (uv[4].len () && !namerx.match (uv[4])) {
err_report (name, 5, fields[4], uv[4]);
return false;
}
for (int i = 6; i < 10; i++) {
if (badcharrx.search (uv[i])) {
err_report (name, i+1, fields[i], uv[i]);
return false;
}
}
#if 0
for (int i = 10; i < 12; i++) {
if (!decrx.match (uv[i])) {
err_report (name, i+1, fields[i], uv[i]);
return false;
}
}
#endif
str privkey = dearmor64 (uv[8]);
if (!privkey) {
err_report (name, 9, fields[8], "could not dearmor64");
return false;
}
str2wstr (privkey);
ui->privkey.setsize (privkey.len ());
memcpy (ui->privkey.base (), privkey, ui->privkey.size ());
ui->name = uv[0];
if (!convertint (uv[1], &ui->id)
|| !convertint (uv[2], &ui->vers)
|| !convertint (uv[3], &ui->gid)
// || !convertint (uv[10], &ui->refresh)
// || !convertint (uv[11], &ui->timeout)
)
return false;
if (uv[4].len ())
*ui->owner.alloc () = uv[4];
else
ui->owner.clear ();
ptr<sfspub> pk = sfscrypt.alloc (uv[5]);
if (!pk)
return false;
if (!pk->export_pubkey (&ui->pubkey)) {
warn << "Cannot load keypair for " << uv[0] << "\n";
return false;
}
ui->privs = uv[6];
ui->pwauth = uv[7];
if (uv[9] && uv[9].len ()) {
if (!sfs_2schnorr_priv::parse_keyhalf (&ui->srvprivkey, uv[9])) {
warn << "Cannot load server keyhalf for " << uv[0] << "\n";
return false;
}
} else {
ui->srvprivkey.set_type (SFSAUTH_KEYHALF_NONE);
}
// ui->audit = uv[12];
ui->audit = uv[10];
return true;
}
示例14: while
void
cgi_mpfd_t::parse_guts ()
{
abuf_stat_t r = ABUF_OK;
str dummy;
bool inc;
while (r == ABUF_OK) {
OKDBG4(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts loop "
"r=%d, state=%d", int (r), int (state));
inc = true;
switch (state) {
case MPFD_START:
r = match_boundary ();
break;
case MPFD_EOL0:
r = require_crlf ();
break;
case MPFD_KEY:
r = gobble_crlf ();
if (r == ABUF_OK) {
if (to_start) {
state = MPFD_START;
to_start = false;
} else
state = MPFD_SEARCH;
inc = false;
} else if (r == ABUF_NOMATCH) {
r = delimit_key (&mpfd_key);
if (r == ABUF_OK)
kt = mpfd_ktmap.lookup (mpfd_key);
} // else a WAIT or an EOF in gobble_crlf
break;
case MPFD_SPC:
r = abuf->skip_hws (1);
cdp.reset ();
break;
case MPFD_VALUE:
if (kt == MPFD_DISPOSITION) {
OKDBG3(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts branch to nested "
"content disposition parser");
cdp.parse (wrap (this, &cgi_mpfd_t::ext_parse_cb));
OKDBG3(SVC_MPFD, CHATTER, "cgi_mpfd_t::parse_guts return due to "
"content disposition parser");
return;
} else if (kt == MPFD_TYPE) {
r = delimit_val (&content_typ);
if (r == ABUF_OK) {
if (multipart_rxx.match (content_typ)) {
add_boundary (multipart_rxx[1]);
to_start = true;
}
}
} else {
r = delimit_val (&dummy);
}
break;
case MPFD_EOL1A:
r = require_crlf ();
break;
case MPFD_EOL1B:
if (kt == MPFD_DISPOSITION) {
if (cdp.typ == CONTDISP_FORMDAT) {
cgi_key = cdp.name;
filename = cdp.filename;
attach = filename;
} else if (cdp.typ == CONTDISP_ATTACH) {
filename = cdp.filename;
attach = true;
} else {
r = ABUF_PARSE_ERR;
}
}
state = MPFD_KEY;
inc = false;
break;
case MPFD_SEARCH:
r = match_boundary (&dat);
if (r == ABUF_OK) {
if (cgi_key) {
if (attach)
finsert (cgi_key, cgi_file_t (filename, content_typ, dat));
else
insert (cgi_key, dat);
cgi_key = NULL;
}
// in this case, no more boundaries
} else if (r == ABUF_PARSE_ERR) {
r = ABUF_OK;
//.........这里部分代码省略.........