Ejemplo n.º 1
0
int
BaseExample::add (const double _y, feature_node * _x)
{
  try {
    int fnum = 0;
    feature_node *node = fix_feature_node ((feature_node *) _x);
     
    // check contents
    for (int i = 0; (node + i)->index >= 0; i++) {
      if ((node + i)->value != 1) feature_type = DOUBLE_FEATURE; // check feature type
      d = _max (d, (node + i)->index);	// save max dimension
      fnum++;
    }
     
    // incriment refcount
    inc_refcount_feature_node (node);
    pack_d = _max (fnum, pack_d);

    // check class type
    if (_y != +1 && _y != -1) class_type = DOUBLE_FEATURE;

    // resize
    x = _append (x, l, node, (feature_node*)0);
    y = _append (y, l, _y, 0.0);
    l++;

    return 1;
  }

  catch (...) {
    fprintf (stderr, "BaseExample::add(): Out of memory\n");
    exit (EXIT_FAILURE);
    return 0;
  }
}
Ejemplo n.º 2
0
static GString *
_curl_reference_url (struct oio_url_s *u, const char *action)
{
	GString *hu = _curl_url_prefix_reference (u);
	g_string_append_printf (hu, "/%s/%s/reference/%s", PROXYD_PREFIX,
			oio_url_get(u, OIOURL_NS), action);
	_append (hu, '?', "acct", oio_url_get (u, OIOURL_ACCOUNT));
	_append (hu, '&', "ref",  oio_url_get (u, OIOURL_USER));
	return hu;
}
Ejemplo n.º 3
0
static GString *
_curl_content_url (struct oio_url_s *u, const char *action)
{
	GString *hu = _curl_url_prefix_containers (u);
	g_string_append_printf (hu, "/%s/%s/content/%s", PROXYD_PREFIX,
			oio_url_get(u, OIOURL_NS), action);
	_append (hu, '?', "acct", oio_url_get (u, OIOURL_ACCOUNT));
	_append (hu, '&', "ref",  oio_url_get (u, OIOURL_USER));
	_append_type (u, hu);
	_append (hu, '&', "path", oio_url_get (u, OIOURL_PATH));
	return hu;
}
Ejemplo n.º 4
0
    BSONObj LockStat::report() const { 
        BSONObjBuilder b;

        BSONObjBuilder t( b.subobjStart( "timeLockedMicros" ) );
        _append( b , timeLocked );
        t.done();
        
        BSONObjBuilder a( b.subobjStart( "timeAcquiringMicros" ) );
        _append( a , timeAcquiring );
        a.done();
        
        return b.obj();
    }
Ejemplo n.º 5
0
size_t AOutputBuffer::append(const AString& str, size_t len)
{
  if (!len)
    return 0;

  if (AConstant::npos == len)
    return _append(str.c_str(), str.getSize());
  else
  {
    AASSERT(this, len <= str.getSize());
    return _append(str.c_str(), len);
  }
}
Ejemplo n.º 6
0
gchar *
assemble_chunk_id(const gchar *straddr, const gchar *strvol, const gchar *strid)
{
	void _append(GString *gstr, const gchar *s) {
		if (gstr->str[gstr->len - 1] != '/' && *s != '/')
			g_string_append_c(gstr, '/');
		g_string_append(gstr, s);
	}

	GString *gstr = g_string_new("http://");
	_append(gstr, straddr);
	_append(gstr, strvol);
	_append(gstr, strid);
	return g_string_free(gstr, FALSE);
}
Ejemplo n.º 7
0
bool LogRLD::Init(const int iLoglevel, const std::string &strHostName, const std::string &strLogInnerShowName, const std::string &strLogFilePath,
    const int iSchedule, const int iMaxLogFileBackupNum, const std::string &strVersion)
{
    log4cplus::DailyRollingFileSchedule schedulelog = (log4cplus::DailyRollingFileSchedule)iSchedule;
    

    /* step 1: Instantiate an appender object */
    log4cplus::SharedAppenderPtr _append(new log4cplus::DailyRollingFileAppenderExtend(strLogFilePath.c_str(), schedulelog, true, iMaxLogFileBackupNum));
    _append->setName("file log test");

    /* step 2: Instantiate a layout object */
    //std::string pattern = "%D{%Y%m%d %H:%M:%S.%Q} [%s-thread-%t ] %p   %s - %m - %l%n";
    std::string strPattern = "%D{%Y%m%d %H:%M:%S.%Q} [" + strHostName + "-thread-%T ] %p   " + strLogInnerShowName + " - " + strVersion + "%m - %l%n";
    

    std::auto_ptr<log4cplus::Layout> _layout(new log4cplus::PatternLayout(strPattern));

    /* step 3: Attach the layout object to the appender */
    _append->setLayout(_layout);

    /* step 4: Instantiate a logger object */
    pLoggerImpl = new log4cplus::Logger(log4cplus::Logger::getInstance("main_log"));
    //pLoggerImpl = log4cplus::Logger::getInstance("main_log");

    /* step 5: Attach the appender object to the logger  */
    pLoggerImpl->addAppender(_append);

    /* step 6: Set a priority for the logger  */
    pLoggerImpl->setLogLevel(iLoglevel);

    return true;
}
Ejemplo n.º 8
0
 void AppenderSkeleton::doAppend(const LoggingEvent& event) {
     if ((Priority::NOTSET == _threshold) || (event.priority <= _threshold)) {
         if (!_filter || (_filter->decide(event) != Filter::DENY)) {
             _append(event);
         }
     }
 }
Ejemplo n.º 9
0
void appender::do_append(const logging_event& event)
{
    if(priority::PL_ALL==threshold_|| (event.get_priority() >= threshold_))
    {
        _append(event);
    }
}
Ejemplo n.º 10
0
bool Log::open_log()
{
	std::string level;
	if (!Config::instance().get_str_conf("log_level", level)) {
		std::cout << "Can not get log_level in configuration file!" << std::endl;
		return false;
	}
	LogLevel Log_level = string_to_log_level(level);

	/* step 1: Instantiate an appender object */
	SharedAppenderPtr _append(new RollingFileAppender(LOG_FILE_NAME, 1000*1024, 5));
	_append->setName("file log test");

	/* step 2: Instantiate a layout object */
	std::string pattern = "[%p] [%D{%m/%d/%y %H:%M:%S}] [%l] - %m %n";
	std::auto_ptr<Layout> _layout(new PatternLayout(pattern));

	/* step 3: Attach the layout object to the appender */
	_append->setLayout(_layout);

	/* step 4: Instantiate a logger object */

	/* step 5: Attach the appender object to the logger  */
	_logger.addAppender(_append);

	/* step 6: Set a priority for the logger  */
	_logger.setLogLevel(Log_level);

	return true;
}
Ejemplo n.º 11
0
size_t AOutputBuffer::appendU2(u2 d)
{
#ifdef _WIN32_
  u1 *pData = (u1 *)&d;
  char pBuffer[0x2];
  
  //a_Reverse bytes
  pBuffer[0x0] = pData[0x1];
  pBuffer[0x1] = pData[0x0];
  
  //a_Write bytes
  return _append(pBuffer, 0x2);
#else
  return _append((const char *)&d, 0x2);
#endif
}
Ejemplo n.º 12
0
size_t AOutputBuffer::append(const char *pcc)
{
  if (!pcc) return 0;

  size_t len = strlen(pcc);
  return _append(pcc, len);
}
Ejemplo n.º 13
0
static GString *
_append_type (struct oio_url_s *u, GString *hu)
{
	const char *type = oio_url_get (u, OIOURL_TYPE);
	if (type && *type)
		_append (hu, '&', "type", type);
	return hu;
}
Ejemplo n.º 14
0
static LObject *
lisp_string_append (LObject *args)
{
  LObject *obj = lipa_new_string ();

  L_STRING(obj) = _append (args, L_STRING(obj));
  return obj;
}
Ejemplo n.º 15
0
int
BaseExample::readSVindex (const char *filename, const char *mode, const int offset)
{
  if (l == 0) {
    fprintf(stderr, "Fatal: size == 0, Read model/example file before reading .idx file\n");
    return 0;
  }

  FILE *fp = fopen (filename, mode);
  if (!fp) return 0;

  delete [] alpha;
  delete [] G;

  int _l = 0;
  char *buf;

  while ((buf = readLine (fp)) != NULL) {
    double alpha_, G_;
    if (2 != sscanf (buf, "%lf %lf\n", &alpha_, &G_)) {
      fprintf(stderr, "Fatal: Format error %s, line %d\n", filename, _l);
      fclose (fp);
      return 0;
    }

    alpha = _append (alpha, _l, alpha_, 0.0);
    G     = _append (G,     _l, G_,     0.0);
    _l++;
  }

  fclose (fp);

  //  check size of idx file
  if (l < _l) {
    fprintf(stderr, "Fatal: model/example size (%d) < idx size (%d)\n", l, _l);
    delete [] alpha;
    delete [] G;
    alpha = 0;
    G = 0;
    return 0;
  }

  svindex_size = _l;
  return 1;
}
Ejemplo n.º 16
0
size_t AOutputBuffer::appendU4_LSB(u4 d)
{
#ifndef _WIN32_
  u1 *pData = (u1 *)&d;
  char pBuffer[0x4];
  
  //a_Reverse bytes
  pBuffer[0x0] = pData[0x3];
  pBuffer[0x1] = pData[0x2];
  pBuffer[0x2] = pData[0x1];
  pBuffer[0x3] = pData[0x0];
  
  //a_Write 4 bytes
  return _append(pBuffer, 0x4);
#else
  return _append((const char *)&d, 0x4);
#endif
}
Ejemplo n.º 17
0
T StringBuffer_vappend(T S, const char *s, va_list ap) {
        assert(S);
        if (STR_DEF(s)) {
                va_list ap_copy;
                va_copy(ap_copy, ap);
                _append(S, s, ap_copy);
                va_end(ap_copy);
        }
        return S;
}
Ejemplo n.º 18
0
T StringBuffer_append(T S, const char *s, ...) {
        assert(S);
        if (STR_DEF(s)) {
                va_list ap;
                va_start(ap, s);
                _append(S, s, ap);
                va_end(ap);
        }
        return S;
}
Ejemplo n.º 19
0
static void
_append_url (GString *gs, struct oio_url_s *url)
{
	void _append (const char *n, const char *v) {
		if (v)
			g_string_append_printf (gs, "\"%s\":\"%s\"", n, v);
		else
			g_string_append_printf (gs, "\"%s\":null", n);
	}
	_append ("ns", oio_url_get(url, OIOURL_NS));
	g_string_append_c (gs, ',');
	_append ("account", oio_url_get(url, OIOURL_ACCOUNT));
	g_string_append_c (gs, ',');
	_append ("user", oio_url_get(url, OIOURL_USER));
	g_string_append_c (gs, ',');
	_append ("type", oio_url_get(url, OIOURL_TYPE));
	g_string_append_c (gs, ',');
	_append ("id", oio_url_get(url, OIOURL_HEXID));
}
Ejemplo n.º 20
0
GError *
oio_proxy_call_conscience_flush (CURL *h, const char *ns,
		const char *srvtype)
{
	GString *http_url = _curl_conscience_url (ns, "flush");
	_append (http_url, '?', "type", srvtype);
	GError *err = _proxy_call (h, "POST", http_url->str, NULL, NULL);
	g_string_free(http_url, TRUE);
	return err;
}
Ejemplo n.º 21
0
entry *_append(char lastName[], entry *e)
{
    if (e->height == 0) {
        strcpy(e->lastName, lastName);
        e->height = 1;
        e->pLeft = mallocEntry();
        e->pRight = mallocEntry();
        return e;
    }

    int cmp = strcmp(lastName, e->lastName);
    if (cmp < 0)
        e->pLeft = _append(lastName, e->pLeft);
    else if (cmp > 0)
        e->pRight = _append(lastName, e->pRight);
    else
        return e;

    return balance(e);
}
Ejemplo n.º 22
0
GError *
oio_proxy_call_conscience_list_types (CURL *h, const char *ns,
		GString *out)
{
	GString *http_url = _curl_conscience_url (ns, "info");
	_append (http_url, '?', "what", "types");
	struct http_ctx_s o = { .headers = NULL, .body = out };
	GError *err = _proxy_call (h, "GET", http_url->str, NULL, &o);
	g_strfreev (o.headers);
	g_string_free(http_url, TRUE);
	return err;
}
Ejemplo n.º 23
0
size_t AOutputBuffer::appendU8(u8 d)
{
#ifdef _WIN32_
  u1 *pData = (u1 *)&d;
  char pBuffer[0x8];
  
  //a_Reverse bytes
  pBuffer[0x0] = pData[0x7];
  pBuffer[0x1] = pData[0x6];
  pBuffer[0x2] = pData[0x5];
  pBuffer[0x3] = pData[0x4];
  pBuffer[0x4] = pData[0x3];
  pBuffer[0x5] = pData[0x2];
  pBuffer[0x6] = pData[0x1];
  pBuffer[0x7] = pData[0x0];
  
  //a_Write bytes
  return _append(pBuffer, 0x8);
#else
  return _append((const char *)&d, 0x8);
#endif
}
void NetworkTransporter::send(void) {
    #ifdef DEBUG
    Serial.println("NetworkTransporter: send");
    #endif
    
    if (socket.connect()) {
        char buffer[200];
        int pos = 0;
        int i;
        
        buffer[0] = '\0';
        for (i = 0; i < nr_sensors; i++) {
            if (i > 0) pos = _append('&', buffer, pos);
            // pos = _append(i, buffer, pos);
            pos = _append(names[i], buffer, pos);
            pos = _append('=', buffer, pos);
            pos = _append(temperatures[i], buffer, pos);
        }
        
        #ifdef DEBUG
        Serial.print("NetworkTransporter: ");
        Serial.println(buffer);
        #endif
        
        
        socket.println("POST /save_measures HTTP/1.0");
        
        // socket.println("Host: www.xxx.de");
        socket.println("Content-Type: application/x-www-form-urlencoded");
        socket.print("Content-Length: "); socket.println(pos, DEC);
        socket.println();
        
        socket.print(buffer);
        
        set_state(NET_STATE_RECEIVE);
    }
}
Ejemplo n.º 25
0
Archivo: zrsx3.c Proyecto: djytw/Zept
int _draw_power(SDL_Surface * f1, SDL_Surface * f2, int typ)
{
	int yt;
	proc_ret = f1;
	if (f1->h >= f2->h)
		if (typ)
			yt = f2->h * POWER_SMALL_PADDING;
		else
			yt = f2->h * POWER_BIG_PADDING;
	else if (typ)
		yt = SMALLFONT / 2 + f2->h + f1->h * (POWER_SMALL_PADDING - 1);
	else
		yt = BIGFONT / 2 + f2->h + f1->h * (POWER_BIG_PADDING - 1);
	_append(f2, 0, yt);
	return yt;
}
Ejemplo n.º 26
0
void ObjectGroup::append(Object* obj, int spacing)
{
    if (! obj)
        return;

    int starty = this->y();
    for(int i=0; i < mObjects.size(); i++) {
        if (mObjects[i]->y() + mObjects[i]->height() > starty)
            starty = mObjects[i]->y() + mObjects[i]->height();
    }

    starty += spacing;
    obj->setY(starty);
    obj->setX(this->x());
    _append(obj);
    this->notify("objects", variantObjects());
    //connect(this, SIGNAL(resized(int,int)), obj, SLOT(onParentResized(int, int)));
}
Ejemplo n.º 27
0
GError *
oio_proxy_call_reference_link (CURL *h, struct oio_url_s *u,
		const char *srvtype, gboolean autocreate, GString *out)
{
	GString *http_url = _curl_reference_url (u, "link");
	_append (http_url, '&', "type", srvtype);
	gchar *hdrin[] = {
		g_strdup(PROXYD_HEADER_MODE),
		g_strdup(autocreate ? "autocreate" : ""),
		NULL,
	};

	struct http_ctx_s i = { .headers = hdrin, .body = NULL };
	struct http_ctx_s o = { .headers = NULL, .body = out };
	GError *err = _proxy_call (h, "POST", http_url->str, &i, &o);

	_ptrv_free_content (i.headers);
	g_strfreev (o.headers);
	g_string_free(http_url, TRUE);
	return err;
}
Ejemplo n.º 28
0
static GString *
_append (LObject *args, GString *str)
{
  if (!lipa_null (args))
    {
      LObject *obj = lipa_car (args);
      if (obj->type == L_OBJ_STRING)
	{
	  return g_string_prepend (_append (lipa_cdr (args), str),
				   L_STRING(obj)->str);
	}
      else
	{
	  fprintf (stderr, "append can only take string arguments");
	}
    }
  else
    return str;

  return NULL;
}
Ejemplo n.º 29
0
void ObjectGroup::_load(const QVariantMap& data)
{
    this->blockNotifications(true);
    ResourceManager * resourceManager = ResourceManager::instance();

    if (data.contains("objects") && data.value("objects").type() == QVariant::List) {
        this->removeAllObjects(true);
        QVariantList objects = data.value("objects").toList();
        Object *obj = 0;

        for(int i=0; i < objects.size(); i++) {
            if (objects[i].type() == QVariant::Map) {
                obj = resourceManager->createObject(objects[i].toMap(), this);
            }
            else if (objects[i].type() == QMetaType::QObjectStar) {
                obj = qobject_cast<Object*>(objects[i].value<QObject*>());
            }

            if(obj)
                _append(obj);
        }
    }

    //internal data passed between resource and clones
    if (data.contains("_object") && data.value("_object").type() == QVariant::Map) {
        QVariantMap object = data.value("_object").toMap();
        if (object.contains("_index") && object.value("_index").canConvert(QVariant::Int)) {
            int _index = object.value("_index").toInt();
            if (_index >= 0 && _index < mObjects.size()) {
                mObjects[_index]->load(object);
                //some properties are ignored by default so we need to apply them here for the child objects
                if (object.contains("visible") && object.value("visible").type() == QVariant::Bool)
                    mObjects[_index]->setVisible(object.value("visible").toBool());
            }
        }
    }

    this->blockNotifications(false);
}
Ejemplo n.º 30
0
void	utl::startLogInfrastrue(const char *path, int log_level) {

    /* step 1: Instantiate an appender object */
    //log4cplus::SharedAppenderPtr _append(new log4cplus::RollingFileAppender( logfilename.c_str(), 20*1024, 1000));
    log4cplus::SharedAppenderPtr _append(new log4cplus::FileAppender( path));//, 20*1024, 1000));
    //SharedAppenderPtr _append(new DailyRollingFileAppender(logfilename.c_str(), HOURLY, true, 1000));
    _append->setName("append for test");

    /* step 2: Instantiate a layout object */
    std::string pattern = "%-6p  %-15c %D %m %n ";

    std::auto_ptr<log4cplus::Layout>  _layout(new log4cplus::PatternLayout(pattern));

    /* step 3: Attach the layout object to the appender */
    _append->setLayout( _layout );

    /* step 4: Instantiate a logger object */
    log4cplus::Logger _logger = log4cplus::Logger::getRoot();

    _logger.setLogLevel( log_level);

    /* step 5: Attach the appender object to the logger  */
    _logger.addAppender(_append);
}