コード例 #1
0
void stats_entry_recent<Probe>::PublishDebug(ClassAd & ad, const char * pattr, int flags) const
{
   MyString str;
   MyString var1;
   MyString var2;
   ProbeToStringDebug(var1, this->value);
   ProbeToStringDebug(var2, this->recent);

   str.sprintf_cat("(%s) (%s)", var1.Value(), var2.Value());
   str.sprintf_cat(" {h:%d c:%d m:%d a:%d}", 
                   this->buf.ixHead, this->buf.cItems, this->buf.cMax, this->buf.cAlloc);
   if (this->buf.pbuf) {
      for (int ix = 0; ix < this->buf.cAlloc; ++ix) {
         ProbeToStringDebug(var1, this->buf.pbuf[ix]);
         str.sprintf_cat(!ix ? "[%s" : (ix == this->buf.cMax ? "|%s" : ",%s"), var1.Value());
         }
      str += "]";
      }

   MyString attr(pattr);
   if (flags & this->PubDecorateAttr)
      attr += "Debug";

   ad.Assign(pattr, str);
}
コード例 #2
0
void
Env::WriteToDelimitedString(char const *input,MyString &output) {
	// Append input to output.
	// Would be nice to escape special characters here, but the
	// existing syntax does not support it, so we leave the
	// "specials" strings blank.

	char const inner_specials[] = {'\0'};
	char const first_specials[] = {'\0'};

	char const *specials = first_specials;
	char const *end;
	bool ret;

	if(!input) return;

	while(*input) {
		end = input + strcspn(input,specials);
		ret = output.sprintf_cat("%.*s", (int)(end-input), input);
		ASSERT(ret);
		input = end;

		if(*input != '\0') {
			// Escape this special character.
			// Escaping is not yet implemented, so we will never get here.
			ret = output.sprintf_cat("%c",*input);
			ASSERT(ret);
			input++;
		}

		// Switch out of first-character escaping mode.
		specials = inner_specials;
	}
}
コード例 #3
0
void stats_entry_recent<double>::PublishDebug(ClassAd & ad, const char * pattr, int flags) const {
   MyString str;
   str.sprintf_cat("%g %g", this->value, this->recent);
   str.sprintf_cat(" {h:%d c:%d m:%d a:%d}", 
                   this->buf.ixHead, this->buf.cItems, this->buf.cMax, this->buf.cAlloc);
   if (this->buf.pbuf) {
      for (int ix = 0; ix < this->buf.cAlloc; ++ix) {
         str.sprintf_cat(!ix ? "[%g" : (ix == this->buf.cMax ? "|%g" : ",%g"), this->buf.pbuf[ix]);
         }
      str += "]";
      }

   MyString attr(pattr);
   if (flags & this->PubDecorateAttr)
      attr += "Debug";

   ad.Assign(pattr, str);
}
コード例 #4
0
MyString
AvailStats::serialize()
{
	MyString state;

	state.sprintf( "%ld %d %d", (long)(time(0)-as_birthdate),
				   as_tot_avail_time, as_last_avail_interval );
	as_avail_periods.Rewind();
	int item;
	while( as_avail_periods.Next(item) ) {
		state.sprintf_cat( " %d", item );
	}

	return state;
}
コード例 #5
0
bool
StartdCronJobParams::Initialize( void )
{
	if ( !ClassAdCronJobParams::Initialize() ) {
		return false;
	}

	MyString	slots_str;
	Lookup( "SLOTS", slots_str );

	m_slots.clear();
	StringList	slot_list( slots_str.Value() );
	slot_list.rewind();
	const char *slot;
	while( ( slot = slot_list.next()) != NULL ) {
		if( !isdigit(*slot)) {
			dprintf( D_ALWAYS,
					 "Cron Job '%s': INVALID slot # '%s': ignoring slot list",
					 GetName(), slot );
			m_slots.clear();
			break;
		}
		unsigned	slotno = atoi( slot );
		m_slots.push_back( slotno );
	}

	// Print out the slots for D_FULLDEBUG
	if ( IsFulldebug(D_FULLDEBUG) ) {
		MyString	s;
		s.sprintf( "CronJob '%s' slots: ", GetName() );
		if ( m_slots.empty() ) {
			s += "ALL";
		}
		else {
			list<unsigned>::iterator iter;
			for( iter = m_slots.begin(); iter != m_slots.end(); iter++ ) {
				s.sprintf_cat( "%u ", *iter );
			}
		}
		dprintf( D_ALWAYS, "%s\n", s.Value() );
	}

	return true;
};
コード例 #6
0
void
IpVerify::UserHashToString(UserHash_t *user_hash, MyString &result)
{
	ASSERT( user_hash );
	user_hash->startIterations();
	MyString host;
	StringList *users;
	char const *user;
	while( user_hash->iterate(host,users) ) {
		if( users ) {
			users->rewind();
			while( (user=users->next()) ) {
				result.sprintf_cat(" %s/%s",
								   user,
								   host.Value());
			}
		}
	}
}
コード例 #7
0
// make query
int GenericQuery::
makeQuery (ExprTree *&tree)
{
    int		i, value;
    char	*item;
    float   fvalue;
    MyString req = "";

    tree = NULL;

    // construct query requirement expression
    bool firstCategory = true;

    // add string constraints
    for (i = 0; i < stringThreshold; i++)
    {
        stringConstraints [i].Rewind ();
        if (!stringConstraints [i].AtEnd ())
        {
            bool firstTime = true;
            req += firstCategory ? "(" : " && (";
            while ((item = stringConstraints [i].Next ()))
            {
                req.sprintf_cat ("%s(%s == \"%s\")",
                                 firstTime ? " " : " || ",
                                 stringKeywordList [i], item);
                firstTime = false;
                firstCategory = false;
            }
            req += " )";
        }
    }

    // add integer constraints
    for (i = 0; i < integerThreshold; i++)
    {
        integerConstraints [i].Rewind ();
        if (!integerConstraints [i].AtEnd ())
        {
            bool firstTime = true;
            req += firstCategory ? "(" : " && (";
            while (integerConstraints [i].Next (value))
            {
                req.sprintf_cat ("%s(%s == %d)",
                                 firstTime ? " " : " || ",
                                 integerKeywordList [i], value);
                firstTime = false;
                firstCategory = false;
            }
            req += " )";
        }
    }

    // add float constraints
    for (i = 0; i < floatThreshold; i++)
    {
        floatConstraints [i].Rewind ();
        if (!floatConstraints [i].AtEnd ())
        {
            bool firstTime = true;
            req += firstCategory ? "(" : " && (";
            while (floatConstraints [i].Next (fvalue))
            {
                req.sprintf_cat ("%s(%s == %f)",
                                 firstTime ? " " : " || ",
                                 floatKeywordList [i], fvalue);
                firstTime = false;
                firstCategory = false;
            }
            req += " )";
        }
    }

    // add custom AND constraints
    customANDConstraints.Rewind ();
    if (!customANDConstraints.AtEnd ())
    {
        bool firstTime = true;
        req += firstCategory ? "(" : " && (";
        while ((item = customANDConstraints.Next ()))
        {
            req.sprintf_cat ("%s(%s)", firstTime ? " " : " && ", item);
            firstTime = false;
            firstCategory = false;
        }
        req += " )";
    }

    // add custom OR constraints
    customORConstraints.Rewind ();
    if (!customORConstraints.AtEnd ())
    {
        bool firstTime = true;
        req += firstCategory ? "(" : " && (";
        while ((item = customORConstraints.Next ()))
        {
            req.sprintf_cat ("%s(%s)", firstTime ? " " : " || ", item);
            firstTime = false;
            firstCategory = false;
        }
        req += " )";
    }

    // absolutely no constraints at all
    if (firstCategory) {
        req += "TRUE";
    }

    // parse constraints and insert into query ad
    if (ParseClassAdRvalExpr (req.Value(), tree) > 0) return Q_PARSE_ERROR;

    return Q_OK;
}