本文整理汇总了C++中MyString::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ MyString::IsEmpty方法的具体用法?C++ MyString::IsEmpty怎么用?C++ MyString::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyString
的用法示例。
在下文中一共展示了MyString::IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
passwd_cache::getUseridMap(MyString &usermap)
{
// fill in string with entries of form expected by loadConfig()
uid_entry *uent;
group_entry *gent;
MyString index;
uid_table->startIterations();
while ( uid_table->iterate(index, uent) ) {
if( !usermap.IsEmpty() ) {
usermap += " ";
}
usermap.formatstr_cat("%s=%ld,%ld",index.Value(),(long)uent->uid,(long)uent->gid);
if( group_table->lookup(index,gent) == 0 ) {
unsigned i;
for(i=0;i<gent->gidlist_sz;i++) {
if( gent->gidlist[i] == uent->gid ) {
// already included this gid, because it is the primary
continue;
}
usermap.formatstr_cat(",%ld",(long)gent->gidlist[i]);
}
}
else {
// indicate that supplemental groups are unknown
usermap.formatstr_cat(",?");
}
}
}
示例2: GetEnviron
void
Env::Import( void )
{
char **my_environ = GetEnviron();
for (int i=0; my_environ[i]; i++) {
const char *p = my_environ[i];
int j;
MyString varname = "";
MyString value = "";
for (j=0; ( p[j] != '\0' ) && ( p[j] != '=' ); j++) {
varname += p[j];
}
if ( p[j] == '\0' ) {
// ignore entries in the environment that do not
// contain an assignment
continue;
}
if ( varname.IsEmpty() ) {
// ignore entries in the environment that contain
// an empty variable name
continue;
}
ASSERT( p[j] == '=' );
value = p+j+1;
// Allow the application to filter the import
if ( ImportFilter( varname, value ) ) {
bool ret = SetEnv( varname, value );
ASSERT( ret ); // should never fail
}
}
}
示例3:
bool
Email::writeJobId( ClassAd* ad )
{
// if we're not currently open w/ a message, we're done
if( ! fp ) {
return false;
}
char* cmd = NULL;
ad->LookupString( ATTR_JOB_CMD, &cmd );
MyString args;
ArgList::GetArgsStringForDisplay(ad,&args);
fprintf( fp, "Condor job %d.%d\n", cluster, proc);
if( cmd ) {
fprintf( fp, "\t%s", cmd );
free( cmd );
cmd = NULL;
if( !args.IsEmpty() ) {
fprintf( fp, " %s\n", args.Value() );
} else {
fprintf( fp, "\n" );
}
}
return true;
}
示例4: gethostbyname
std::vector<MyString> get_hostname_with_alias(const condor_sockaddr& addr)
{
std::vector<MyString> ret;
MyString hostname = get_hostname(addr);
if (hostname.IsEmpty())
return ret;
ret.push_back(hostname);
if (nodns_enabled())
return ret; // no need to call further DNS functions.
hostent* ent;
//int aftype = addr.get_aftype();
//ent = gethostbyname2(hostname.Value(), addr.get_aftype());
// really should call gethostbyname2() however most platforms do not
// support. (Solaris, HP-UX, IRIX)
// complete DNS aliases can be only obtained by gethostbyname.
// however, what happens if we call it in IPv6-only system?
// can we get DNS aliases for the hostname that only contains
// IPv6 addresses?
ent = gethostbyname(hostname.Value());
if (!ent)
return ret;
char** alias = ent->h_aliases;
for (; *alias; ++alias) {
ret.push_back(MyString(*alias));
}
return ret;
}
示例5: doAction
/**
* This is the heart of the policy object. When an expression
* evaluates to true in either checkAtExit() or checkPeriodic(),
* doAction() will call the JIC to do whatever it is the action
* called for.
*
* @param action - the action ID of what we need to do
* @param is_periodic - whether the action was fired from checkPeriodic()
**/
void
StarterUserPolicy::doAction( int action, bool is_periodic )
{
MyString reason;
int reason_code;
int reason_subcode;
this->user_policy.FiringReason(reason,reason_code,reason_subcode);
if ( reason.IsEmpty() ) {
EXCEPT( "StarterUserPolicy: Empty FiringReason." );
}
switch( action ) {
// ---------------------------------
// UNDEFINED_EVAL
// ---------------------------------
case UNDEFINED_EVAL:
case HOLD_IN_QUEUE:
this->jic->holdJob( reason.Value(), reason_code, reason_subcode );
break;
// ---------------------------------
// REMOVE_FROM_QUEUE
// ---------------------------------
case REMOVE_FROM_QUEUE:
//
// We need to make a distinction that we
// are removing the job because it completed its
// execution, or it was being removed by PERIODIC_REMOVE
//
if( is_periodic ) {
this->jic->removeJob( reason.Value() );
} else {
//
// I am passing the reason, but apparently
// it isn't necessary?
//
this->jic->terminateJob( reason.Value() );
}
break;
// ---------------------------------
// STAYS_IN_QUEUE
// ---------------------------------
case STAYS_IN_QUEUE:
if( is_periodic ) {
EXCEPT( "STAYS_IN_QUEUE should never be handled by "
"periodic doAction()" );
}
this->jic->requeueJob( reason.Value() );
break;
// ---------------------------------
// UNKNOWN
// ---------------------------------
default:
EXCEPT( "Unknown action (%d) in StarterUserPolicy::doAction",
action );
} // SWITCH
return;
}
示例6: gethostbyname
std::vector<MyString> get_hostname_with_alias(const condor_sockaddr& addr)
{
std::vector<MyString> prelim_ret;
std::vector<MyString> actual_ret;
MyString hostname = get_hostname(addr);
if (hostname.IsEmpty())
return prelim_ret;
// we now start to construct a list (prelim_ret) of the hostname and all
// the aliases. first the name itself.
prelim_ret.push_back(hostname);
if (nodns_enabled())
// don't need to verify this... the string is actually an IP here
return prelim_ret; // no need to call further DNS functions.
// now, add the aliases
hostent* ent;
//int aftype = addr.get_aftype();
//ent = gethostbyname2(hostname.Value(), addr.get_aftype());
// really should call gethostbyname2() however most platforms do not
// support. (Solaris, HP-UX, IRIX)
// complete DNS aliases can be only obtained by gethostbyname.
// however, what happens if we call it in IPv6-only system?
// can we get DNS aliases for the hostname that only contains
// IPv6 addresses?
ent = gethostbyname(hostname.Value());
if (ent) {
char** alias = ent->h_aliases;
for (; *alias; ++alias) {
prelim_ret.push_back(MyString(*alias));
}
}
// WARNING! there is a reason this is implimented as two separate loops,
// so please don't try to combine them.
//
// calling verify_name_has_ip() will potentially overwrite static data that
// is referred to by ent->h_aliases (man 3 gethostbyname, see notes). so
// first, we push the name and then all aliases into the MyString vector
// prelim_ret, and then verify them in the following loop.
for (unsigned int i = 0; i < prelim_ret.size(); i++) {
if(verify_name_has_ip(prelim_ret[i], addr)) {
actual_ret.push_back(prelim_ret[i]);
} else {
dprintf(D_ALWAYS, "WARNING: forward resolution of %s doesn't match %s!\n",
prelim_ret[i].Value(), addr.to_ip_string().Value());
}
}
return actual_ret;
}
示例7: sscanf
bool
TransferQueueRequest::ReadReport(TransferQueueManager *manager)
{
MyString report;
m_sock->decode();
if( !m_sock->get(report) ||
!m_sock->end_of_message() )
{
return false;
}
if( report.IsEmpty() ) {
return false;
}
unsigned report_time;
unsigned report_interval_usec;
unsigned recent_bytes_sent;
unsigned recent_bytes_received;
unsigned recent_usec_file_read;
unsigned recent_usec_file_write;
unsigned recent_usec_net_read;
unsigned recent_usec_net_write;
IOStats iostats;
int rc = sscanf(report.Value(),"%u %u %u %u %u %u %u %u",
&report_time,
&report_interval_usec,
&recent_bytes_sent,
&recent_bytes_received,
&recent_usec_file_read,
&recent_usec_file_write,
&recent_usec_net_read,
&recent_usec_net_write);
if( rc != 8 ) {
dprintf(D_ALWAYS,"Failed to parse I/O report from file transfer worker %s: %s.\n",
m_sock->peer_description(),report.Value());
return false;
}
iostats.bytes_sent = (double)recent_bytes_sent;
iostats.bytes_received = (double)recent_bytes_received;
iostats.file_read = (double)recent_usec_file_read/1000000;
iostats.file_write = (double)recent_usec_file_write/1000000;
iostats.net_read = (double)recent_usec_net_read/1000000;
iostats.net_write = (double)recent_usec_net_write/1000000;
manager->AddRecentIOStats(iostats,m_up_down_queue_user);
return true;
}
示例8: vmprintf
void vmprintf( int flags, const char *fmt, ... )
{
int saved_flags = 0;
static pid_t mypid = 0;
if( !mypid ) {
mypid = daemonCore->getpid();
}
if( !fmt ) {
return;
}
if( !(flags & oriDebugFlags) ) {
return;
}
saved_flags = oriDebugFlags; /* Limit recursive calls */
oriDebugFlags = 0;
MyString output;
va_list args;
va_start(args, fmt);
output.vsprintf(fmt, args);
va_end(args);
if( output.IsEmpty() ) {
oriDebugFlags = saved_flags;
return;
}
if( Termlog ) {
if( (vmgahp_mode == VMGAHP_TEST_MODE) ||
(vmgahp_mode == VMGAHP_KILL_MODE) ) {
fprintf(stderr, "VMGAHP[%d]: %s", (int)mypid, output.Value());
oriDebugFlags = saved_flags;
return;
}
if( (vmgahp_stderr_tid != -1 ) &&
(vmgahp_stderr_pipe != -1 )) {
vmgahp_stderr_buffer.Write(output.Value());
daemonCore->Reset_Timer(vmgahp_stderr_tid, 0, 2);
}
}else {
dprintf(flags, "VMGAHP[%d]: %s", (int)mypid, output.Value());
}
oriDebugFlags = saved_flags;
}
示例9:
void
CCBListeners::GetCCBContactString(MyString &result)
{
classy_counted_ptr<CCBListener> ccb_listener;
m_ccb_listeners.Rewind();
while( m_ccb_listeners.Next(ccb_listener) ) {
char const *ccbid = ccb_listener->getCCBID();
if( ccbid && *ccbid ) {
if( !result.IsEmpty() ) {
result += " ";
}
result += ccbid;
}
}
}
示例10:
void
CCBListeners::GetCCBContactString(MyString &result)
{
classy_counted_ptr<CCBListener> ccb_listener;
for(CCBListenerList::iterator itr = m_ccb_listeners.begin();
itr != m_ccb_listeners.end();
itr++)
{
ccb_listener = (*itr);
char const *ccbid = ccb_listener->getCCBID();
if( ccbid && *ccbid ) {
if( !result.IsEmpty() ) {
result += " ";
}
result += ccbid;
}
}
}
示例11: while
// utility function: parse the string "<aaa.bbb.ccc.ddd:pppp>"
// Extracts the ip address portion ("aaa.bbb.ccc.ddd")
bool
parseIpPort (const MyString &ip_port_pair, MyString &ip_addr)
{
ip_addr = "";
if (ip_port_pair.IsEmpty()) {
return false;
}
const char *ip_port = ip_port_pair.Value();
ip_port++; // Skip the leading "<"
while ( *ip_port && *ip_port != ':')
{
ip_addr += *ip_port;
ip_port++;
}
// don't care about port number
return true;
}
示例12: config
void Defrag::config()
{
ASSERT( param(m_state_file,"DEFRAG_STATE_FILE") );
if( m_last_poll==0 ) {
loadState();
}
int old_polling_interval = m_polling_interval;
m_polling_interval = param_integer("DEFRAG_INTERVAL",600);
if( m_polling_interval <= 0 ) {
dprintf(D_ALWAYS,
"DEFRAG_INTERVAL=%d, so no pool defragmentation "
"will be done.\n", m_polling_interval);
if( m_polling_timer != -1 ) {
daemonCore->Cancel_Timer(m_polling_timer);
m_polling_timer = -1;
}
}
else if( m_polling_timer >= 0 ) {
if( old_polling_interval != m_polling_interval ) {
daemonCore->Reset_Timer_Period(
m_polling_timer,
m_polling_interval);
}
}
else {
time_t now = time(NULL);
int first_time = 0;
if( m_last_poll != 0 && now-m_last_poll < m_polling_interval && m_last_poll <= now ) {
first_time = m_polling_interval - (now-m_last_poll);
}
m_polling_timer = daemonCore->Register_Timer(
first_time,
m_polling_interval,
(TimerHandlercpp)&Defrag::poll,
"Defrag::poll",
this );
}
if( old_polling_interval != m_polling_interval && m_polling_interval > 0 )
{
dprintf(D_ALWAYS,
"Will evaluate defragmentation policy every DEFRAG_INTERVAL="
"%d seconds.\n", m_polling_interval);
}
m_draining_per_hour = param_double("DEFRAG_DRAINING_MACHINES_PER_HOUR",0,0);
double rate = m_draining_per_hour/3600.0*m_polling_interval;
m_draining_per_poll = (int)floor(rate + 0.00001);
if( m_draining_per_poll < 0 ) m_draining_per_poll = 0;
double error_per_hour = (rate - m_draining_per_poll)/m_polling_interval*3600.0;
m_draining_per_poll_hour = (int)floor(error_per_hour + 0.00001);
if( m_draining_per_hour < 0 || m_polling_interval > 3600 ) {
m_draining_per_hour = 0;
}
double error_per_day = (error_per_hour - m_draining_per_poll_hour)*24.0;
m_draining_per_poll_day = (int)floor(error_per_day + 0.5);
if( m_draining_per_poll_day < 0 || m_polling_interval > 3600*24 ) {
m_draining_per_poll_day = 0;
}
dprintf(D_ALWAYS,"polling interval %ds, DEFRAG_DRAINING_MACHINES_PER_HOUR = %f/hour = %d/interval + %d/hour + %d/day\n",
m_polling_interval,m_draining_per_hour,m_draining_per_poll,
m_draining_per_poll_hour,m_draining_per_poll_day);
m_max_draining = param_integer("DEFRAG_MAX_CONCURRENT_DRAINING",-1,-1);
m_max_whole_machines = param_integer("DEFRAG_MAX_WHOLE_MACHINES",-1,-1);
ASSERT( param(m_defrag_requirements,"DEFRAG_REQUIREMENTS") );
validateExpr( m_defrag_requirements.c_str(), "DEFRAG_REQUIREMENTS" );
ASSERT( param(m_whole_machine_expr,"DEFRAG_WHOLE_MACHINE_EXPR") );
validateExpr( m_whole_machine_expr.c_str(), "DEFRAG_WHOLE_MACHINE_EXPR" );
ASSERT( param(m_draining_schedule_str,"DEFRAG_DRAINING_SCHEDULE") );
if( m_draining_schedule_str.empty() ) {
m_draining_schedule = DRAIN_GRACEFUL;
m_draining_schedule_str = "graceful";
}
else {
m_draining_schedule = getDrainingScheduleNum(m_draining_schedule_str.c_str());
if( m_draining_schedule < 0 ) {
EXCEPT("Invalid draining schedule: %s\n",m_draining_schedule_str.c_str());
}
}
MyString rank;
param(rank,"DEFRAG_RANK");
if( rank.IsEmpty() ) {
m_rank_ad.Delete(ATTR_RANK);
}
else {
if( !m_rank_ad.AssignExpr(ATTR_RANK,rank.Value()) ) {
EXCEPT("Invalid expression for DEFRAG_RANK: %s\n",
rank.Value());
}
}
//.........这里部分代码省略.........
示例13: ParseField
int
MapFile::ParseCanonicalizationFile(const MyString filename)
{
int line = 0;
FILE *file = safe_fopen_wrapper_follow(filename.Value(), "r");
if (NULL == file) {
dprintf(D_ALWAYS,
"ERROR: Could not open canonicalization file '%s' (%s)\n",
filename.Value(),
strerror(errno));
return -1;
}
while (!feof(file)) {
MyString input_line;
int offset;
MyString method;
MyString principal;
MyString canonicalization;
line++;
input_line.readLine(file); // Result ignored, we already monitor EOF
if (input_line.IsEmpty()) {
continue;
}
offset = 0;
offset = ParseField(input_line, offset, method);
offset = ParseField(input_line, offset, principal);
offset = ParseField(input_line, offset, canonicalization);
method.lower_case();
if (method.IsEmpty() ||
principal.IsEmpty() ||
canonicalization.IsEmpty()) {
dprintf(D_ALWAYS, "ERROR: Error parsing line %d of %s. (Method=%s) (Principal=%s) (Canon=%s) Skipping to next line.\n",
line, filename.Value(), method.Value(), principal.Value(), canonicalization.Value());
continue;
}
dprintf(D_FULLDEBUG,
"MapFile: Canonicalization File: method='%s' principal='%s' canonicalization='%s'\n",
method.Value(),
principal.Value(),
canonicalization.Value());
/*
Regex *re = new Regex;
if (NULL == re) {
dprintf(D_ALWAYS, "ERROR: Failed to allocate Regex!\n");
}
*/
int last = canonical_entries.getlast() + 1;
canonical_entries[last].method = method;
canonical_entries[last].principal = principal;
canonical_entries[last].canonicalization = canonicalization;
}
fclose(file);
// Compile the entries and print error messages for the ones that don't compile.
// We don't do this in the loop above because canonical_entries[] allocates
// a whole new array when it needs to grow and we don't want to be copying
// compiled regex's when that happens. see #2409
for (int ix = 0; ix <= canonical_entries.getlast(); ++ix) {
const char *errptr;
int erroffset;
if (!canonical_entries[ix].regex.compile(canonical_entries[ix].principal,
&errptr,
&erroffset)) {
dprintf(D_ALWAYS, "ERROR: Error compiling expression '%s' -- %s. this entry will be ignored.\n",
canonical_entries[ix].principal.Value(),
errptr);
}
}
return 0;
}
示例14: config
void Rooster::config()
{
int old_polling_interval = m_polling_interval;
m_polling_interval = param_integer("ROOSTER_INTERVAL",300);
if( m_polling_interval < 0 ) {
dprintf(D_ALWAYS,
"ROOSTER_INTERVAL is less than 0, so no unhibernate checks "
"will be made.\n");
if( m_polling_timer != -1 ) {
daemonCore->Cancel_Timer(m_polling_timer);
m_polling_timer = -1;
}
}
else if( m_polling_timer >= 0 ) {
if( old_polling_interval != m_polling_interval ) {
daemonCore->Reset_Timer(
m_polling_timer,
m_polling_interval,
m_polling_interval);
}
}
else {
m_polling_timer = daemonCore->Register_Timer(
m_polling_interval,
m_polling_interval,
(TimerHandlercpp)&Rooster::poll,
"Rooster::poll",
this );
}
if( old_polling_interval != m_polling_interval && m_polling_interval > 0 )
{
dprintf(D_ALWAYS,
"Will perform unhibernate checks every ROOSTER_INTERVAL=%d "
"seconds.\n", m_polling_interval);
}
ASSERT( param(m_unhibernate_constraint,"ROOSTER_UNHIBERNATE") );
ASSERT( param(m_wakeup_cmd,"ROOSTER_WAKEUP_CMD") );
m_wakeup_args.Clear();
MyString error_msg;
if( !m_wakeup_args.AppendArgsV2Quoted(m_wakeup_cmd.Value(),&error_msg) ) {
EXCEPT("Invalid wakeup command %s: %s\n",
m_wakeup_cmd.Value(), error_msg.Value());
}
MyString rank;
param(rank,"ROOSTER_UNHIBERNATE_RANK");
if( rank.IsEmpty() ) {
m_rank_ad.Delete(ATTR_RANK);
}
else {
if( !m_rank_ad.AssignExpr(ATTR_RANK,rank.Value()) ) {
EXCEPT("Invalid expression for ROOSTER_UNHIBERNATE_RANK: %s\n",
rank.Value());
}
}
m_max_unhibernate = param_integer("ROOSTER_MAX_UNHIBERNATE",0,0);
}
示例15: if
void
VMGahpServer::killVM(void)
{
if( m_vm_type.IsEmpty() || m_vmgahp_server.IsEmpty() ) {
return;
}
if( m_workingdir.IsEmpty() ) {
dprintf(D_ALWAYS, "VMGahpServer::killVM() : no workingdir\n");
return;
}
MyString matchstring;
if( (strcasecmp(m_vm_type.Value(), CONDOR_VM_UNIVERSE_XEN ) == MATCH) || (strcasecmp(m_vm_type.Value(), CONDOR_VM_UNIVERSE_KVM ) == MATCH) ) {
if( create_name_for_VM(m_job_ad, matchstring) == false ) {
dprintf(D_ALWAYS, "VMGahpServer::killVM() : "
"cannot make the name of VM\n");
return;
}
} else {
// Except Xen, we need the path of working directory of Starter
// in order to destroy a VM.
matchstring = m_workingdir;
}
if( matchstring.IsEmpty() ) {
dprintf(D_ALWAYS, "VMGahpServer::killVM() : empty matchstring\n");
return;
}
// vmgahp is daemonCore, so we need to add -f -t options of daemonCore.
// Then, try to execute vmgahp with
// vmtype <vmtype> match <string>"
ArgList systemcmd;
systemcmd.AppendArg(m_vmgahp_server);
systemcmd.AppendArg("-f");
if( m_include_gahp_log ) {
systemcmd.AppendArg("-t");
}
systemcmd.AppendArg("-M");
systemcmd.AppendArg(VMGAHP_KILL_MODE);
systemcmd.AppendArg("vmtype");
systemcmd.AppendArg(m_vm_type);
systemcmd.AppendArg("match");
systemcmd.AppendArg(matchstring);
#if !defined(WIN32)
if( can_switch_ids() ) {
MyString tmp_str;
tmp_str.sprintf("%d", (int)get_condor_uid());
SetEnv("VMGAHP_USER_UID", tmp_str.Value());
}
else if (Starter->condorPrivSepHelper() != NULL) {
MyString tmp_str;
tmp_str.sprintf("%d", (int)Starter->condorPrivSepHelper()->get_uid());
SetEnv("VMGAHP_USER_UID", tmp_str.Value());
}
#endif
priv_state oldpriv;
if( (strcasecmp(m_vm_type.Value(), CONDOR_VM_UNIVERSE_XEN ) == MATCH) || (strcasecmp(m_vm_type.Value(), CONDOR_VM_UNIVERSE_KVM ) == MATCH) ) {
oldpriv = set_root_priv();
} else {
oldpriv = set_user_priv();
}
int ret = my_system(systemcmd);
set_priv(oldpriv);
if( ret == 0 ) {
dprintf( D_FULLDEBUG, "VMGahpServer::killVM() is called with "
"'%s'\n", matchstring.Value());
} else {
dprintf( D_FULLDEBUG, "VMGahpServer::killVM() failed!\n");
}
return;
}