本文整理汇总了C++中SimpleList::Rewind方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleList::Rewind方法的具体用法?C++ SimpleList::Rewind怎么用?C++ SimpleList::Rewind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleList
的用法示例。
在下文中一共展示了SimpleList::Rewind方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
int
LoadCredentialList () {
CredentialWrapper * pCred;
// Clear the old list
if (!credentials.IsEmpty()) {
credentials.Rewind();
while (credentials.Next(pCred)) {
credentials.DeleteCurrent();
delete pCred;
}
}
credentials.Rewind();
classad::ClassAdXMLParser parser;
char buff[50000];
priv_state priv = set_root_priv();
FILE * fp = safe_fopen_wrapper(cred_index_file, "r");
if (!fp) {
dprintf (D_FULLDEBUG, "Credential database %s does not exist!\n", cred_index_file);
set_priv (priv);
return TRUE;
}
while (fgets(buff, 50000, fp)) {
if ((buff[0] == '\n') || (buff[0] == '\r')) {
continue;
}
classad::ClassAd * classad = parser.ParseClassAd (buff);
int type=0;
if ((!classad) || (!classad->EvaluateAttrInt ("Type", type))) {
dprintf (D_ALWAYS, "Invalid classad %s\n", buff);
set_priv (priv);
fclose (fp);
return FALSE;
}
if (type == X509_CREDENTIAL_TYPE) {
pCred = new X509CredentialWrapper (*classad);
credentials.Append (pCred);
}
else {
dprintf (D_ALWAYS, "Invalid type %d\n",type);
}
}
fclose (fp);
set_priv (priv);
return TRUE;
}
示例2: temp_classad
int
SaveCredentialList() {
priv_state priv = set_root_priv();
FILE * fp = safe_fopen_wrapper(cred_index_file, "w");
if (!fp) {
set_priv (priv);
dprintf (D_ALWAYS, "Unable to open credential index file %s!\n", cred_index_file);
return FALSE;
}
classad::ClassAdXMLUnParser unparser;
CredentialWrapper * pCred = NULL;
// Clear the old list
credentials.Rewind();
while (credentials.Next(pCred)) {
const classad::ClassAd * pclassad = pCred->cred->GetMetadata();
classad::ClassAd temp_classad(*pclassad); // lame
std::string buff;
unparser.Unparse (buff, &temp_classad);
fprintf (fp, "%s\n", buff.c_str());
}
fclose (fp);
set_priv (priv);
return TRUE;
}
示例3: while
void GenericQuery::
clearFloatCategory (SimpleList<float> &float_category)
{
float item;
float_category.Rewind ();
while (float_category.Next (item))
float_category.DeleteCurrent ();
}
示例4: getPlugins
void
NegotiatorPluginManager::Initialize()
{
NegotiatorPlugin *plugin;
SimpleList<NegotiatorPlugin *> plugins = getPlugins();
plugins.Rewind();
while (plugins.Next(plugin)) {
plugin->initialize();
}
}
示例5: getPlugins
void
CollectorPluginManager::Invalidate(int command, const ClassAd &ad)
{
CollectorPlugin *plugin;
SimpleList<CollectorPlugin *> plugins = getPlugins();
plugins.Rewind();
while (plugins.Next(plugin)) {
plugin->invalidate(command, ad);
}
}
示例6:
int
allAmazonCommands(StringList &output)
{
AmazonGahpCommand *one_cmd = NULL;
amazon_gahp_commands.Rewind();
while( amazon_gahp_commands.Next(one_cmd) ) {
output.append(one_cmd->command.c_str());
}
return amazon_gahp_commands.Number();
}
示例7:
void
flush_results()
{
std::string *next_str;
results_queue.Rewind();
while ( results_queue.Next( next_str ) ) {
daemonCore->Write_Pipe( RESULT_OUTBOX, next_str->c_str(),
next_str->length() );
delete next_str;
}
results_queue.Clear();
}
示例8: strlen
bool
MyString::replaceString(
const char *pszToReplace,
const char *pszReplaceWith,
int iStartFromPos)
{
SimpleList<int> listMatchesFound;
int iToReplaceLen = strlen(pszToReplace);
if (!iToReplaceLen) {
return false;
}
int iWithLen = strlen(pszReplaceWith);
while (iStartFromPos <= Len){
iStartFromPos = find(pszToReplace, iStartFromPos);
if (iStartFromPos == -1)
break;
listMatchesFound.Append(iStartFromPos);
iStartFromPos += iToReplaceLen;
}
if (!listMatchesFound.Number())
return false;
int iLenDifPerMatch = iWithLen - iToReplaceLen;
int iNewLen = Len + iLenDifPerMatch * listMatchesFound.Number();
char *pNewData = new char[iNewLen+1];
int iItemStartInData;
int iPosInNewData = 0;
int iPreviousEnd = 0;
listMatchesFound.Rewind();
while(listMatchesFound.Next(iItemStartInData)) {
memcpy(pNewData + iPosInNewData,
Data + iPreviousEnd,
iItemStartInData - iPreviousEnd);
iPosInNewData += (iItemStartInData - iPreviousEnd);
memcpy(pNewData + iPosInNewData, pszReplaceWith, iWithLen);
iPosInNewData += iWithLen;
iPreviousEnd = iItemStartInData + iToReplaceLen;
}
memcpy(pNewData + iPosInNewData,
Data + iPreviousEnd,
Len - iPreviousEnd + 1);
delete [] Data;
Data = pNewData;
capacity = iNewLen;
Len = iNewLen;
return true;
}
示例9: if
void
CheckCredentials () {
CredentialWrapper * pCred;
credentials.Rewind();
dprintf (D_FULLDEBUG, "In CheckCredentials()\n");
// Get current time
time_t now = time(NULL);
while (credentials.Next(pCred)) {
init_user_id_from_FQN (pCred->cred->GetOwner());
priv_state priv = set_user_priv();
time_t time = pCred->cred->GetRealExpirationTime();
dprintf (D_FULLDEBUG, "Checking %s:%s = %ld\n",
pCred->cred->GetOwner(),
pCred->cred->GetName(),
time);
if (time - now < 0) {
dprintf (D_FULLDEBUG, "Credential %s:%s expired!\n",
pCred->cred->GetOwner(),
pCred->cred->GetName());
}
else if (time - now < default_cred_expire_threshold) {
dprintf (D_FULLDEBUG, "Credential %s:%s about to expire\n",
pCred->cred->GetOwner(),
pCred->cred->GetName());
if (pCred->cred->GetType() == X509_CREDENTIAL_TYPE) {
RefreshProxyThruMyProxy ((X509CredentialWrapper*)pCred);
}
}
set_priv (priv); // restore old priv
}
}
示例10: doContactSchedd
//.........这里部分代码省略.........
if ( BaseJob::JobsByProcId.lookup( procID, old_job ) != 0 ) {
JobType *job_type = NULL;
BaseJob *new_job = NULL;
// job had better be either managed or matched! (or both)
ASSERT( job_is_managed || job_is_matched );
if ( MustExpandJobAd( next_ad ) ) {
// Get the expanded ClassAd from the schedd, which
// has the GridResource filled in with info from
// the matched ad.
delete next_ad;
next_ad = NULL;
next_ad = GetJobAd(procID.cluster,procID.proc);
if ( next_ad == NULL && errno == ETIMEDOUT ) {
failure_line_num = __LINE__;
commit_transaction = false;
goto contact_schedd_disconnect;
}
if ( next_ad == NULL ) {
// We may get here if it was not possible to expand
// one of the $$() expressions. We don't want to
// roll back the transaction and blow away the
// hold that the schedd just put on the job, so
// simply skip over this ad.
dprintf(D_ALWAYS,"Failed to get expanded job ClassAd from Schedd for %d.%d. errno=%d\n",procID.cluster,procID.proc,errno);
goto contact_schedd_next_add_job;
}
}
// Search our job types for one that'll handle this job
jobTypes.Rewind();
while ( jobTypes.Next( job_type ) ) {
if ( job_type->AdMatchFunc( next_ad ) ) {
// Found one!
dprintf( D_FULLDEBUG, "Using job type %s for job %d.%d\n",
job_type->Name, procID.cluster, procID.proc );
break;
}
}
if ( job_type != NULL ) {
new_job = job_type->CreateFunc( next_ad );
} else {
dprintf( D_ALWAYS, "No handlers for job %d.%d\n",
procID.cluster, procID.proc );
new_job = new BaseJob( next_ad );
}
ASSERT(new_job);
new_job->SetEvaluateState();
dprintf(D_ALWAYS,"Found job %d.%d --- inserting\n",
new_job->procID.cluster,new_job->procID.proc);
num_ads++;
if ( !job_is_managed ) {
rc = tSetAttributeString( new_job->procID.cluster,
new_job->procID.proc,
ATTR_JOB_MANAGED,
MANAGED_EXTERNAL);
if ( rc < 0 ) {
failure_line_num = __LINE__;
commit_transaction = false;
示例11: dprintf
int
get_cred_handler(Service * /*service*/, int /*i*/, Stream *stream) {
char * name = NULL;
int rtnVal = FALSE;
bool found_cred=false;
CredentialWrapper * cred = NULL;
char * owner = NULL;
const char * user = NULL;
void * data = NULL;
ReliSock * socket = (ReliSock*)stream;
// Authenticate
if (!socket->triedAuthentication()) {
CondorError errstack;
if( ! SecMan::authenticate_sock(socket, READ, &errstack) ) {
dprintf (D_ALWAYS, "Unable to authenticate, qutting\n");
goto EXIT;
}
}
socket->decode();
if (!socket->code(name)) {
dprintf (D_ALWAYS, "Error receiving credential name\n");
goto EXIT;
}
user = socket->getFullyQualifiedUser();
dprintf (D_ALWAYS, "Authenticated as %s\n", user);
if (strchr (name, ':')) {
// The name is of the form user:name
// This better be a super-user!
// TODO: Check super-user's list
// Owner is the first part
owner = strdup (name);
char * pColon = strchr (owner, ':');
*pColon = '\0';
// Name is the second part
sprintf (name, "%s", (char*)(pColon+sizeof(char)));
if (strcmp (owner, user) != 0) {
dprintf (D_ALWAYS, "Requesting another user's (%s) credential %s\n", owner, name);
if (!isSuperUser (user)) {
dprintf (D_ALWAYS, "User %s is NOT super user, request DENIED\n", user);
goto EXIT;
} else {
dprintf (D_FULLDEBUG, "User %s is super user, request GRANTED\n", user);
}
}
} else {
owner = strdup (user);
}
dprintf (D_ALWAYS, "sending cred %s for user %s\n", name, owner);
credentials.Rewind();
while (credentials.Next(cred)) {
if (cred->cred->GetType() == X509_CREDENTIAL_TYPE) {
if ((strcmp(cred->cred->GetName(), name) == 0) &&
(strcmp(cred->cred->GetOwner(), owner) == 0)) {
found_cred=true;
break; // found it
}
}
}
socket->encode();
if (found_cred) {
dprintf (D_FULLDEBUG, "Found cred %s\n", cred->GetStorageName());
int data_size;
int rc = LoadData (cred->GetStorageName(), data, data_size);
dprintf (D_FULLDEBUG, "Credential::LoadData returned %d\n", rc);
if (rc == 0) {
goto EXIT;
}
socket->code (data_size);
socket->code_bytes (data, data_size);
dprintf (D_ALWAYS, "Credential name %s for owner %s returned to user %s\n",
name, owner, user);
}
else {
dprintf (D_ALWAYS, "Cannot find cred %s\n", name);
int rc = CREDD_CREDENTIAL_NOT_FOUND;
socket->code (rc);
}
rtnVal = TRUE;
EXIT:
if ( name != NULL) {
//.........这里部分代码省略.........
示例12: dc_schedd
void
doContactSchedd()
{
if (command_queue.IsEmpty()) {
daemonCore->Reset_Timer( contactScheddTid, contact_schedd_interval ); // Come back in a min
return;
}
dprintf(D_FULLDEBUG,"in doContactSchedd\n");
SchedDRequest * current_command = NULL;
int error=FALSE;
std::string error_msg;
CondorError errstack;
bool do_reschedule = false;
int failure_line_num = 0;
int failure_errno = 0;
// Try connecting to schedd
DCSchedd dc_schedd ( ScheddAddr, ScheddPool );
if (dc_schedd.error() || !dc_schedd.locate()) {
sprintf( error_msg, "Error locating schedd %s", ScheddAddr );
dprintf( D_ALWAYS, "%s\n", error_msg.c_str() );
// If you can't connect return "Failure" on every job request
command_queue.Rewind();
while (command_queue.Next(current_command)) {
if (current_command->status != SchedDRequest::SDCS_NEW)
continue;
if (current_command->command == SchedDRequest::SDC_STATUS_CONSTRAINED) {
const char * result[] = {
GAHP_RESULT_FAILURE,
error_msg.c_str(),
"0"};
enqueue_result (current_command->request_id, result, 3);
} else if (current_command->command == SchedDRequest::SDC_SUBMIT_JOB) {
const char * result[] = {
GAHP_RESULT_FAILURE,
NULL,
error_msg.c_str() };
enqueue_result (current_command->request_id, result, 3);
} else if (current_command->command == SchedDRequest::SDC_UPDATE_LEASE) {
const char * result[] = {
GAHP_RESULT_FAILURE,
error_msg.c_str(),
NULL };
enqueue_result (current_command->request_id, result, 3);
} else {
const char * result[] = {
GAHP_RESULT_FAILURE,
error_msg.c_str() };
enqueue_result (current_command->request_id, result, 2);
}
current_command->status = SchedDRequest::SDCS_COMPLETED;
}
}
SchedDRequest::schedd_command_type commands [] = {
SchedDRequest::SDC_REMOVE_JOB,
SchedDRequest::SDC_HOLD_JOB,
SchedDRequest::SDC_RELEASE_JOB };
const char * command_titles [] = {
"REMOVE_JOB", "HOLD_JOB", "RELEASE_JOB" };
// REMOVE
// HOLD
// RELEASE
int i=0;
while (i<3) {
StringList id_list;
SimpleList <SchedDRequest*> this_batch;
SchedDRequest::schedd_command_type this_command = commands[i];
const char * this_action = command_titles[i];
const char * this_reason = NULL;
dprintf (D_FULLDEBUG, "Processing %s requests\n", this_action);
error = FALSE;
// Create a batch of commands with the same command type AND the same reason
command_queue.Rewind();
while (command_queue.Next(current_command)) {
if (current_command->status != SchedDRequest::SDCS_NEW)
continue;
if (current_command->command != this_command)
continue;
if ((this_reason != NULL) && (strcmp (current_command->reason, this_reason) != 0))
continue;
//.........这里部分代码省略.........
示例13: MyProxyGetDelegationReaper
int MyProxyGetDelegationReaper(Service *, int exitPid, int exitStatus)
{
dprintf (D_ALWAYS, "MyProxyGetDelegationReaper pid = %d, rc = %d\n", exitPid, exitStatus);
credentials.Rewind();
CredentialWrapper * cred_wrapper;
X509CredentialWrapper * matched_entry = NULL;
while (credentials.Next (cred_wrapper)) {
if (cred_wrapper->cred->GetType() == X509_CREDENTIAL_TYPE) {
if (((X509CredentialWrapper*)cred_wrapper)->get_delegation_pid == exitPid) {
matched_entry = (X509CredentialWrapper*)cred_wrapper;
break;
}
}
} //elihw
if (matched_entry) {
while (exitStatus != 0) {
int read_fd = matched_entry->get_delegation_err_fd; // shorthand
off_t offset = lseek(read_fd, 0, SEEK_SET); // rewind
if (offset == (off_t)-1) {
dprintf (D_ALWAYS, "myproxy-get-delegation for proxy (%s, %s), "
"stderr tmp file %s lseek() failed: %s\n",
matched_entry->cred->GetOwner(),
matched_entry->cred->GetName(),
matched_entry->get_delegation_err_filename,
strerror(errno)
);
break;
}
struct stat statbuf;
int status = fstat(read_fd, &statbuf);
if (status == -1) {
dprintf (D_ALWAYS, "myproxy-get-delegation for proxy (%s, %s), "
"stderr tmp file %s fstat() failed: %s\n",
matched_entry->cred->GetOwner(),
matched_entry->cred->GetName(),
matched_entry->get_delegation_err_filename,
strerror(errno)
);
break;
}
matched_entry->get_delegation_err_buff =
(char *) calloc ( statbuf.st_size + 1, sizeof(char) );
int bytes_read =
read (
read_fd,
matched_entry->get_delegation_err_buff,
statbuf.st_size
);
if (bytes_read < 0 ) {
dprintf (D_ALWAYS, "myproxy-get-delegation for proxy (%s, %s), "
"stderr tmp file %s read() failed: %s\n",
matched_entry->cred->GetOwner(),
matched_entry->cred->GetName(),
matched_entry->get_delegation_err_filename,
strerror(errno)
);
break;
}
if ( WIFEXITED(exitStatus) ) {
dprintf (D_ALWAYS, "myproxy-get-delegation for proxy (%s, %s), "
"exited with status %d, output (top):\n%s\n\n",
matched_entry->cred->GetOwner(),
matched_entry->cred->GetName(),
WEXITSTATUS(exitStatus),
matched_entry->get_delegation_err_buff
);
break;
} else if ( WIFSIGNALED(exitStatus) ) {
dprintf (D_ALWAYS, "myproxy-get-delegation for proxy (%s, %s), "
"terminated by signal %d, output (top):\n%s\n\n",
matched_entry->cred->GetOwner(),
matched_entry->cred->GetName(),
WTERMSIG(exitStatus),
matched_entry->get_delegation_err_buff
);
break;
} else {
dprintf (D_ALWAYS, "myproxy-get-delegation for proxy (%s, %s), "
"unknown status %d, output (top):\n%s\n\n",
matched_entry->cred->GetOwner(),
matched_entry->cred->GetName(),
exitStatus,
matched_entry->get_delegation_err_buff
);
break;
}
} // if exitStatus != 0
// Clean up
matched_entry->get_delegation_reset();
} else {
dprintf (D_ALWAYS,
//.........这里部分代码省略.........