本文整理汇总了C++中DB_HOST::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ DB_HOST::insert方法的具体用法?C++ DB_HOST::insert怎么用?C++ DB_HOST::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_HOST
的用法示例。
在下文中一共展示了DB_HOST::insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: authenticate_user
// Based on the info in the request message,
// look up the host and its user, and make sure the authenticator matches.
// Some special cases:
// 1) If no host ID is supplied, or if RPC seqno mismatch,
// create a new host record
// 2) If the host record specified by g_request->hostid is a "zombie"
// (i.e. it was merged with another host via the web site)
// then follow links to find the proper host
//
// POSTCONDITION:
// If this function returns zero, then:
// - reply.host contains a valid host record (possibly new)
// - reply.user contains a valid user record
// - if user belongs to a team, reply.team contains team record
//
int authenticate_user() {
int retval;
char buf[1024];
DB_HOST host;
DB_USER user;
DB_TEAM team;
if (g_request->hostid) {
retval = host.lookup_id(g_request->hostid);
while (!retval && host.userid==0) {
// if host record is zombie, follow link to new host
//
retval = host.lookup_id(host.rpc_seqno);
if (!retval) {
g_reply->hostid = host.id;
log_messages.printf(MSG_NORMAL,
"[HOST#%d] forwarding to new host ID %d\n",
g_request->hostid, host.id
);
}
}
if (retval) {
g_reply->insert_message("Can't find host record", "low");
log_messages.printf(MSG_NORMAL,
"[HOST#%d?] can't find host\n",
g_request->hostid
);
g_request->hostid = 0;
goto lookup_user_and_make_new_host;
}
g_reply->host = host;
// look up user based on the ID in host record,
// and see if the authenticator matches (regular or weak)
//
g_request->using_weak_auth = false;
sprintf(buf, "where id=%d", host.userid);
retval = user.lookup(buf);
if (!retval && !strcmp(user.authenticator, g_request->authenticator)) {
// req auth matches user auth - go on
} else {
if (!retval) {
// user for host.userid exists - check weak auth
//
get_weak_auth(user, buf);
if (!strcmp(buf, g_request->authenticator)) {
g_request->using_weak_auth = true;
log_messages.printf(MSG_DEBUG,
"[HOST#%d] accepting weak authenticator\n",
host.id
);
}
}
if (!g_request->using_weak_auth) {
// weak auth failed - look up user based on authenticator
//
strlcpy(
user.authenticator, g_request->authenticator, sizeof(user.authenticator)
);
escape_string(user.authenticator, sizeof(user.authenticator));
sprintf(buf, "where authenticator='%s'", user.authenticator);
retval = user.lookup(buf);
if (retval) {
g_reply->insert_message(
_("Invalid or missing account key. To fix, remove and add this project."),
"notice"
);
g_reply->set_delay(DELAY_MISSING_KEY);
g_reply->nucleus_only = true;
log_messages.printf(MSG_CRITICAL,
"[HOST#%d] [USER#%d] Bad authenticator '%s'\n",
host.id, user.id, g_request->authenticator
);
return ERR_AUTHENTICATOR;
}
}
}
g_reply->user = user;
if (host.userid != user.id) {
// If the request's host ID isn't consistent with the authenticator,
// create a new host record.
//
//.........这里部分代码省略.........