Exemplo n.º 1
0
bool UMagic::init(int flags)
{
   U_TRACE(1, "UMagic::init(%d)", flags)

   U_INTERNAL_ASSERT_EQUALS(magic, U_NULLPTR)

   magic = (magic_t) U_SYSCALL(magic_open, "%d", flags);

   bool ok = (magic && U_SYSCALL(magic_load, "%p,%S", magic, U_NULLPTR) != -1);

   U_DUMP("ok = %b status = %.*S", ok, 512, getError())

   U_RETURN(ok);
}
Exemplo n.º 2
0
bool UREDISClient_Base::connect(const char* phost, unsigned int _port)
{
   U_TRACE(0, "UREDISClient_Base::connect(%S,%u)", phost, _port)

   UString host;

   if (phost) (void) host.assign(phost);
   else
      {
      const char* env_redis_host = (const char*) U_SYSCALL(getenv, "%S", "REDIS_HOST");

      if (env_redis_host == 0)
         {
         UClient_Base::response.snprintf("connection disabled");

         U_RETURN(false);
         }

      (void) host.assign(env_redis_host, u__strlen(env_redis_host, __PRETTY_FUNCTION__));

      const char* env_redis_port = (const char*) U_SYSCALL(getenv, "%S", "REDIS_PORT");

      if (env_redis_port) _port = atoi(env_redis_port);
      }

   if (UClient_Base::setHostPort(host, _port) &&
       UClient_Base::connect())
      {
      UClient_Base::iovcnt = 4;

      UClient_Base::iov[1].iov_base =
      UClient_Base::iov[4].iov_base = (caddr_t)" ";
      UClient_Base::iov[1].iov_len  =
      UClient_Base::iov[4].iov_len  = 1;

      UClient_Base::iov[3].iov_base =
      UClient_Base::iov[5].iov_base = (caddr_t)U_CRLF;
      UClient_Base::iov[3].iov_len  =
      UClient_Base::iov[5].iov_len  = 2;

      U_DUMP("getRedisVersion() = %V", getRedisVersion().rep)

      U_RETURN(true);
      }

   U_RETURN(false);
}
Exemplo n.º 3
0
void USOAPParser::startElement(const XML_Char* name, const XML_Char** attrs)
{
   U_TRACE(0, "USOAPParser::startElement(%S,%p)", name, attrs)

   U_DUMP_ATTRS(attrs)

   UXMLAttribute* attribute;
   UString str((void*)name), namespaceName, accessorName, value;

   UXMLElement::splitNamespaceAndName(str, namespaceName, accessorName);

   if (flag_state == 0)
      {
      U_INTERNAL_ASSERT(u_rmatch(U_STRING_TO_PARAM(str), U_CONSTANT_TO_PARAM(":Envelope")))

      flag_state = 1;
      }

   U_DUMP("flag_state = %d ptree = %p ptree->parent() = %p ptree->numChild() = %u ptree->depth() = %u",
           flag_state, ptree, ptree->parent(), ptree->numChild(), ptree->depth())

   current = U_NEW(UXMLElement(str, accessorName, namespaceName));
   ptree   = ptree->push(current);

   if (flag_state <= 2)
      {
      if (flag_state == 1 &&
          u_rmatch(U_STRING_TO_PARAM(str), U_CONSTANT_TO_PARAM(":Header")))
         {
         header     = ptree;
         flag_state = 2;
         }
      else if (u_rmatch(U_STRING_TO_PARAM(str), U_CONSTANT_TO_PARAM(":Body")))
         {
         body       = ptree;
         flag_state = 3;
         }
      }

   U_INTERNAL_DUMP("flag_state = %d", flag_state)

   while (*attrs)
      {
        str.replace(*attrs++);
      value.replace(*attrs++);

      UXMLElement::splitNamespaceAndName(str, namespaceName, accessorName);

      attribute = U_NEW(UXMLAttribute(str, accessorName, namespaceName, value));

      current->addAttribute(attribute);

      // check if anybody has mustUnderstand set to true

      if (flag_state == 2 &&
          accessorName.equal(U_CONSTANT_TO_PARAM("mustUnderstand")))
         {
         envelope.mustUnderstand = value.equal(U_CONSTANT_TO_PARAM("true"));

         U_INTERNAL_DUMP("envelope.mustUnderstand = %b", envelope.mustUnderstand)
         }

      // set the name of namespace qualified element information (gSOAP)

      if (flag_state == 1                                   &&
          namespaceName.equal(U_CONSTANT_TO_PARAM("xmlns")) &&
           accessorName == *UString::str_ns)
         {
         envelope.nsName = value;

         U_INTERNAL_DUMP("envelope.nsName = %V", envelope.nsName.rep)
         }