Esempio n. 1
0
   // Check for memory error
   U_MEMORY_TEST

   // Allocator e Deallocator
   U_MEMORY_ALLOCATOR
   U_MEMORY_DEALLOCATOR

    UThreadImpl(bool suspendEnable, bool joinEnable)
      {
      U_TRACE(0, "UThreadImpl::UThreadImpl(%b,%b)", suspendEnable, joinEnable)

      _tid           = 0;
      _signal        = 0;
      _cancel        = 0;
      _suspendCount  = 0;
      _suspendEnable = suspendEnable;

      (void) U_SYSCALL(pthread_attr_init,           "%p",    &_attr);
      (void) U_SYSCALL(pthread_attr_setdetachstate, "%p,%d", &_attr, (joinEnable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED));
      }
Esempio n. 2
0
bool UCDB::open(bool brdonly)
{
   U_TRACE(0, "UCDB::open(%b)", brdonly)

   nrecord = start_hash_table_slot = 0;

   if (UFile::isOpen() ||
       UFile::open(brdonly ? O_RDONLY : O_CREAT | O_RDWR))
      {
      UFile::readSize();

      if (UFile::st_size)
         {
         (void) UFile::memmap(PROT_READ | (brdonly ? 0 : PROT_WRITE));

         if (UFile::map == MAP_FAILED)
            {
            data.dptr = 0;

            hp   =   &hp_buf;
            hr   =   &hr_buf;
            slot = &slot_buf;

            (void) UFile::pread(&start_hash_table_slot, sizeof(uint32_t), 0);
            }
         else
            {
            UFile::close();

            start_hash_table_slot = *(uint32_t*)UFile::map;
            }

         nrecord = (UFile::st_size - start_hash_table_slot) / sizeof(cdb_hash_table_slot);
         }

      U_INTERNAL_DUMP("nrecord = %u", nrecord)

#  ifdef DEBUG
      if (UFile::st_size) checkForAllEntry();
#  endif

      U_RETURN(true);
      }
Esempio n. 3
0
bool UDynamic::load(const char* pathname)
{
   U_TRACE(0, "UDynamic::load(%S)", pathname)

   U_CHECK_MEMORY

   U_INTERNAL_ASSERT_EQUALS(handle, 0)

#ifdef _MSWINDOWS_
   handle = ::LoadLibrary(pathname);
#else
   /**
    * Perform lazy binding
    * --------------------------------------------------------------------
    * Only resolve symbols as the code that references them is executed.
    * If the symbol is never referenced, then it is never resolved.
    * Lazy binding is only performed for function references; references
    * to variables are always immediately bound when the library is loaded
    * --------------------------------------------------------------------
    */

   handle = U_SYSCALL(dlopen, "%S,%d", pathname, RTLD_LAZY); // RTLD_NOW
#endif

   if (handle == 0)
      {
#  if defined(_MSWINDOWS_)
      err = "load failed";
#  else
      err = ::dlerror();
#  endif

      U_WARNING("UDynamic::load(%S) failed: %.*S", pathname, 256, err);

      U_RETURN(false);
      }

#ifndef _MSWINDOWS_
   (void) ::dlerror(); /* Clear any existing error */
#endif

   U_RETURN(true);
}
Esempio n. 4
0
int U_EXPORT main(int argc, char* argv[])
{
    U_ULIB_INIT(argv);

    U_TRACE(5,"main(%d)",argc)

    UString x, url(argv[1], strlen(argv[1]));

    UHttpClient<USSLSocket> http(0);
    http.setRequestPasswordAuthentication(U_STRING_FROM_CONSTANT("Aladdin"),
                                          U_STRING_FROM_CONSTANT("open sesame"));

    if (http.connectServer(url) &&
            http.sendRequest(x))
    {
        UString content = http.getContent();

        cout.write(content.data(), content.size());
    }
}
Esempio n. 5
0
void UPosting::reset()
{
   U_TRACE(5, "UPosting::reset()")

   max_distance      = 2;
   sub_word_pos_prev = 0;

   if (vec_sub_word) resetVectorCompositeWord();

   if (vec_word)
      {
      delete vec_word;
      delete vec_entry;
      delete vec_posting;

      vec_word    = 0;
      vec_entry   = 0;
      vec_posting = 0;
      }
}
Esempio n. 6
0
static void check_content(const UString& content, const UString& filename)
{
   U_TRACE(5, "check_content(%p,%p)", content.data(), filename.data())

   UString dati = UFile::contentOf(filename);

   if (dati != content)
      {
      UFile save_file;

      if (save_file.creat(U_STRING_FROM_CONSTANT("tmp/content.different")))
         {
         save_file.write(content);

         save_file.close();
         }
      }

   U_ASSERT( dati == content )
}
Esempio n. 7
0
UString USOAPParser::getFaultResponse()
{
   U_TRACE(0, "USOAPParser::getFaultResponse()")

   U_INTERNAL_ASSERT_POINTER(method)

   URPCFault fault;
   UString retval(U_CAPACITY);

   fault.setFaultCode();

                                 fault.getFaultReason() = (*envelope.arg)[0];
   if (envelope.arg->size() > 1) fault.getDetail()      = (*envelope.arg)[1];

   fault.encode(retval);

   (void) retval.shrink();

   U_RETURN_STRING(retval);
}
Esempio n. 8
0
   UString getOptionValue(const char* param, const char* tag)
      {
      U_TRACE(5, "Application::getOptionValue(%S,%S)", param, tag)

      UString result;

      if (param && *param) result = param;
      else
         {
         UString tmp(100U);

         U_INTERNAL_DUMP("xades_c = %b", xades_c)

         tmp.snprintf(U_CONSTANT_TO_PARAM("XAdES-%s.%s"), (xades_c ? "C" : "BES"), tag);

         result = cfg[tmp];
         }

      U_RETURN_STRING(result);
      }
Esempio n. 9
0
void HttpBaWwwAuthenticate::stringify(UString& field)
{
   U_TRACE(5, "HttpBaWwwAuthenticate::stringify(%.*S)", U_STRING_TO_TRACE(field))

   field += name;

   field.append(U_CONSTANT_TO_PARAM(": Basic realm="));

   bool quoted = (realm[0] == '"');

   if (quoted == false) field += '"';

   field += realm;

   if (quoted == false) field += '"';

   field.append(U_CONSTANT_TO_PARAM("\r\n"));

   U_INTERNAL_DUMP("field = %.*S", U_STRING_TO_TRACE(field))
}
Esempio n. 10
0
UString UPKCS10::getSubject(X509_REQ* _request)
{
   U_TRACE(1, "UPKCS10::getSubject(%p)", _request)

   U_INTERNAL_ASSERT_POINTER(_request)

   X509_NAME* name = X509_REQ_get_subject_name(_request);
   unsigned len    = U_SYSCALL(i2d_X509_NAME, "%p,%p", name, 0);

   UString subject(len);
   char* ptr = subject.data();

   (void) U_SYSCALL(X509_NAME_oneline, "%p,%p,%d", name, ptr, subject.capacity());

   len = u__strlen(ptr, __PRETTY_FUNCTION__);

   subject.size_adjust(len);

   U_RETURN_STRING(subject);
}
Esempio n. 11
0
int main(int argc, char *argv[])
{
   U_ULIB_INIT(argv);

   U_TRACE(5,"main(%d)",argc)

   UTwilioClient tc(U_STRING_FROM_CONSTANT("SID"), U_STRING_FROM_CONSTANT("TOKEN"));

   bool ok = tc.getCompletedCalls();

   U_INTERNAL_ASSERT(ok)

   ok = tc.makeCall(U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("http://xxxx"));

   U_INTERNAL_ASSERT(ok)

   ok = tc.sendSMS(U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("xxx-xxx-xxxx"), U_CONSTANT_TO_PARAM("\"Hello, how are you?\""));

   U_INTERNAL_ASSERT(ok)
}
Esempio n. 12
0
File: tree.cpp Progetto: fast01/ULib
void UTree<void*>::callForAllEntry(vPFpvpv function)
{
   U_TRACE(0, "UTree<void*>::callForAllEntry(%p)", function)

   U_CHECK_MEMORY

   UTree<void*>* p;

   if (_elem) function((void*)_elem, this);

   if (UVector<void*>::empty() == false)
      {
      for (const void** ptr = vec; ptr < (vec + _length); ++ptr)
         {
         p = (UTree<void*>*)(*ptr);

         p->callForAllEntry(function);
         }
      }
}
Esempio n. 13
0
bool UBase64::decodeAll(const char* s, uint32_t n, UString& buffer)
{
   U_TRACE(0, "UBase64::decodeAll(%.*S,%u,%.*S)", n, s, n, U_STRING_TO_TRACE(buffer))

   uint32_t pos = u_base64all_decode(s, n, (unsigned char*)buffer.data());

   buffer.size_adjust(pos);

   U_INTERNAL_DUMP("u_base64_errors = %u buffer(%u) = %#.*S", u_base64_errors, buffer.size(), U_STRING_TO_TRACE(buffer))

   if (pos > 0 &&
       u_base64_errors == 0)
      {
      U_RETURN(true);
      }

   U_INTERNAL_DUMP("buffer(%u) = %#.*S", buffer.size(), U_STRING_TO_TRACE(buffer))

   U_RETURN(false);
}
Esempio n. 14
0
int
U_EXPORT main (int argc, char* argv[])
{
   U_ULIB_INIT(argv);

   U_TRACE(5,"main(%d)",argc)

   U_ASSERT_EQUALS( UServices::dosMatchWithOR(U_CONSTANT_TO_PARAM("www.sito1.com"), U_CONSTANT_TO_PARAM("SSI|benchmark|www.sito1.com|www.sito2.com"), FNM_INVERT), false)

   UString buffer(2000);

   u_base64_max_columns = 72;

   UBase64::encode(U_CONSTANT_TO_PARAM(TESTOA), buffer);

   U_INTERNAL_DUMP("buffer = %#.*S", U_STRING_TO_TRACE(buffer))

   U_ASSERT( buffer == U_STRING_FROM_CONSTANT(TESTOB) )

   UBase64::decode( U_CONSTANT_TO_PARAM(TESTOB), buffer);

   U_ASSERT( buffer == U_STRING_FROM_CONSTANT(TESTOA) )

   UString cmd, result1, result2;
   int fd_stderr = U_SYSCALL(open, "%S,%d", "err/services.err", O_WRONLY);

   cmd = U_STRING_FROM_CONSTANT("ls test_services.cpp");
   result1 = UCommand::outputCommand(cmd);

// U_ASSERT( result1 == U_STRING_FROM_CONSTANT("test_services.cpp\n") )

   buffer = UServices::getUUID();
   U_INTERNAL_DUMP("buffer = %#.*S", U_STRING_TO_TRACE(buffer))

   cmd = U_STRING_FROM_CONSTANT("cat test_services.cpp");
   result2 = UCommand::outputCommand(cmd, 0, -1, fd_stderr);

   U_ASSERT( result2.empty() == false )

   cout.write(result2.data(), result2.size());
}
Esempio n. 15
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");
      const char* env_redis_port  = (const char*) U_SYSCALL(getenv, "%S", "REDIS_PORT");

      if (env_redis_port) _port = atoi(env_redis_port);

      uint32_t env_redis_host_len = (env_redis_host ? u__strlen(env_redis_host, __PRETTY_FUNCTION__) : 0);

      if (env_redis_host_len) (void) host.assign(env_redis_host, env_redis_host_len);
      else                           host = *UString::str_localhost;
      }

   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);
}
Esempio n. 16
0
bool UTranformXPointer::setExpr(const char* expr, int nodeSetType, xmlNodePtr node)
{
   U_TRACE(0, "UTranformXPointer::setExpr(%S,%d,%p)", expr, nodeSetType, node)

   UBaseTransform::hereNode = node;

   UXPathData* data;

   U_NEW(UXPathData, data, UXPathData(UXPathData::XPOINTER, nodeSetType, expr));

   if (data->registerNamespaces(node))
      {
      dataList.push(data);

      U_RETURN(true);
      }

   U_DELETE(data)

   U_RETURN(false);
}
Esempio n. 17
0
UString URPCObject::processMessage(URPCEnvelope& envelope, bool& bContainsFault)
{
   U_TRACE(0, "URPCObject::processMessage(%p,%p)", &envelope, &bContainsFault)

   U_INTERNAL_ASSERT_POINTER(URPCMethod::encoder)

   UString retval;

   // Iterate over the list of methods

   URPCMethod* method = find(envelope.getMethodName());

   if (method == 0)
      {
      // Return object not found error. This would be a Client fault

      setFailed();

      URPCMethod::pFault->setFaultReason(U_CONSTANT_TO_PARAM("The requested method does not exist on this server"));

      bContainsFault = true;
      retval         = URPCMethod::encoder->encodeFault(URPCMethod::pFault);
      }
   else
      {
      UString ns = envelope.getNsName();

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

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

      if (ns.empty()) ns = method->getNamespaces();
      if (ns.empty()) ns = *UString::str_ns;

      bContainsFault = (method->execute(envelope) == false);
      retval         = URPCMethod::encoder->encodeMethodResponse(*method, ns);
      }

   U_RETURN_STRING(retval);
}
Esempio n. 18
0
U_EXPORT ostream& operator<<(ostream& os, const UXMLElement& e)
{
   U_TRACE(0+256, "UXMLElement::operator<<(%p,%p)", &os, &e)

   // encode the element name

   os.put('<');

   if (e.namespaceName)
      {
      os << e.namespaceName;

      os.put(':');
      }

   os << e.accessorName;

   os.put(' ');

   // encode the element's attributes

   os << e.attributeContainer;

   // terminate the element declaration

   os.put(' ');
   os.put('>');

   if (e.value)
      {
      (void) os.write(U_CONSTANT_TO_PARAM(" VALUE = "));

      char buffer[4096];
      uint32_t len = u_escape_encode((const unsigned char*)U_STRING_TO_PARAM(e.value), buffer, sizeof(buffer), false);

      (void) os.write(buffer, len);
      }

   return os;
}
Esempio n. 19
0
uint32_t UXML2Document::getElement(UVector<UString>& velement, const char* tag, uint32_t tag_len)
{
   U_TRACE(0, "UXML2Document::getElement(%p,%.*S,%u)", &velement, tag_len, tag, tag_len)

   U_INTERNAL_ASSERT_POINTER(tag)

   UString element;
   uint32_t n = velement.size(), pos = 0;

   while (true)
      {
      pos = getElement(element, pos, tag, tag_len);

      if (pos == U_NOT_FOUND) break;

      velement.push(element);
      }

   uint32_t result = velement.size() - n;

   U_RETURN(result);
}
Esempio n. 20
0
void UDirWalk::ctor(const UString* dir, const char* _filter, uint32_t _filter_len)
{
   U_TRACE(0, "UDirWalk::ctor(%p,%.*S,%u)", dir, _filter_len, _filter, _filter_len)

   max               = 128 * 1024;
   depth             = -1; // starting recursion depth
   pthis             = this;
   sort_by           = 0;
   call_if_up        = 0;
   call_internal     = 0;
   suffix_file_type  = 0;
   call_if_directory = brecurse = is_directory = false;

   if (dir) (void) setDirectory(*dir, _filter, _filter_len);
   else
      {
      pathname[0]             = '.';
      pathname[(pathlen = 1)] = '\0';

      setFilter(_filter, _filter_len);
      }
}
Esempio n. 21
0
xmlNodePtr UXML2Document::findChild(const xmlNodePtr parent, const xmlChar* name, const xmlChar* ns)
{
   U_TRACE(0, "UXML2Document::findChild(%p,%S,%S)", parent, name, ns)

   U_INTERNAL_ASSERT_POINTER(name)
   U_INTERNAL_ASSERT_POINTER(parent)

   xmlNodePtr cur = parent->children;

   while (cur)
      {
      if (cur->type == XML_ELEMENT_NODE &&
          UXML2Node(cur).checkNodeName(name, ns))
         {
         U_RETURN_POINTER(cur, xmlNode);
         }

      cur = cur->next;
      }

   U_RETURN_POINTER(0, xmlNode);
}
Esempio n. 22
0
U_EXPORT ostream& operator<<(ostream& os, const UXMLAttribute& a)
{
    U_TRACE(0+256, "UXMLAttribute::operator<<(%p,%p)", &os, &a)

    os.put('{');
    os.put(' ');

    if (a.namespaceName)
    {
        os << a.namespaceName;

        os.put(':');
    }

    os << a.accessor;
    os.put('=');
    os << a.value;
    os.put(' ');
    os.put('}');

    return os;
}
Esempio n. 23
0
void ULog::startup()
{
   U_TRACE(0, "ULog::startup()")

   U_INTERNAL_ASSERT_POINTER(fmt)

   log(fmt, "STARTUP", sizeof(void*) * 8);

   log("Building Environment: " PLATFORM_VAR " (" __DATE__ ")\n", 0);

#ifndef __MINGW32__
   struct utsname u;

   (void) U_SYSCALL(uname, "%p", &u);

   log("Current Operating System: %s %s v%s %s\n", u.sysname, u.machine, u.version, u.release);
#endif

#if defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
   log("Big endian arch detected\n", 0);
#endif
}
Esempio n. 24
0
File: cdb.cpp Progetto: psfu/ULib
void UCDB::init_internal(int ignore_case)
{
   U_TRACE(0, "UCDB::init_internal(%d)", ignore_case)

   (void) U_SYSCALL(memset, "%p,%d,%d",  &key, 0, sizeof(datum));
   (void) U_SYSCALL(memset, "%p,%d,%d", &data, 0, sizeof(datum));

   hr   = 0;
   slot = 0;
   hp   = 0;

   pattern                 = 0;
   pbuffer                 = 0;
   ptr_vector              = 0;
   function_to_call        = 0;
   filter_function_to_call = functionCall;

   // when mmap not available we use this storage...

   (void) U_SYSCALL(memset, "%p,%d,%d",   &hp_buf, 0, sizeof(hp_buf));
   (void) U_SYSCALL(memset, "%p,%d,%d",   &hr_buf, 0, sizeof(cdb_record_header));
   (void) U_SYSCALL(memset, "%p,%d,%d", &slot_buf, 0, sizeof(cdb_hash_table_slot));

   loop = nslot = khash = nrecord = offset = start_hash_table_slot = 0;

   union uucdb_flag {
      unsigned char* pc;
      uint32_t*      pi;
   };

   union uucdb_flag u = { (unsigned char*)&flag };

   *u.pi = 0x00000000;

   U_cdb_ignore_case(this) = ignore_case;

   flag[1] = flag[2] = flag[3] = 0;
}
Esempio n. 25
0
   void run(int argc, char* argv[], char* env[])
      {
      U_TRACE(5, "Application::run(%d,%p,%p)", argc, argv, env)

      UApplication::run(argc, argv, env);

      U_ASSERT( num_args == 2 )

      U_ASSERT( opt[(uint32_t)0U] == U_STRING_FROM_CONSTANT("1") )
      U_ASSERT( opt[(uint32_t)1U] == U_STRING_FROM_CONSTANT("pippo") )
      U_ASSERT( opt[(uint32_t)2U] == U_STRING_FROM_CONSTANT("Hello") )
      U_ASSERT( opt[(uint32_t)3U] == U_STRING_FROM_CONSTANT("1") )
      U_ASSERT( opt[(uint32_t)4U] == U_STRING_FROM_CONSTANT("Bucaiolo_a_te") )

      U_ASSERT( opt['a'] == U_STRING_FROM_CONSTANT("1") )
      U_ASSERT( opt['b'] == U_STRING_FROM_CONSTANT("pippo") )
      U_ASSERT( opt['c'] == U_STRING_FROM_CONSTANT("Hello") )

      U_ASSERT( opt[U_STRING_FROM_CONSTANT("option_with_no_short_1")] == U_STRING_FROM_CONSTANT("1") )
      U_ASSERT( opt[U_STRING_FROM_CONSTANT("option_with_no_short_2")] == U_STRING_FROM_CONSTANT("Bucaiolo_a_te") )

      U_ASSERT( strcmp(argv[optind], "argument_1") == 0 )
      ++optind;
      U_ASSERT( strcmp(argv[optind], "argument_2") == 0 )

      u_atexit(reset);

      (void) write(STDOUT_FILENO, U_CONSTANT_TO_PARAM("AutoSending SIGTERM...\n"));
      
#  ifndef DEBUG
      UInterrupt::act.sa_flags   = 0;
      UInterrupt::act.sa_handler = UInterrupt::handlerInterrupt;

      (void) U_SYSCALL(sigaction, "%d,%p,%p", SIGTERM, &UInterrupt::act, 0); // 15
#  endif

      UInterrupt::sendSignal(SIGTERM, u_pid);
      }
Esempio n. 26
0
void UEscape::encode(const UString& s, UString& buffer, char before, char after)
{
   U_TRACE(0, "UEscape::encode(%.*S,%.*S,%C,%C)", U_STRING_TO_TRACE(s), U_STRING_TO_TRACE(buffer), before, after)

   U_INTERNAL_ASSERT_DIFFERS(after, '\0')
   U_ASSERT(buffer.capacity() >= s.size())

   uint32_t sz = buffer.size();
   char* ptr   = buffer.c_pointer(sz);

   if (before)
      {
      ++sz;

      *ptr++ = before;
      }

   uint32_t pos = u_escape_encode((const unsigned char*)U_STRING_TO_PARAM(s), ptr, buffer.space(), true);

   ptr[pos] = after;

   buffer.size_adjust(sz + 1 + pos);
}
Esempio n. 27
0
bool USOAPParser::parse(const UString& msg)
{
   U_TRACE(0+256, "USOAPParser::parse(%V)", msg.rep)

   initParser();

   if (UXMLParser::parse(msg))
      {
      // If we succeeded, get the name of the method being called. This of course assumes only
      // one method in the body, and that there are no objects outside of the serialization root.
      // This method will need an override if this assumption is invalid

      U_INTERNAL_ASSERT_POINTER(body)

#  ifndef U_COVERITY_FALSE_POSITIVE // Explicit null dereferenced (FORWARD_NULL)
      method              = body->childAt(0);
      envelope.methodName = method->elem()->getAccessorName();

      // load the parameters for the method to execute

      UString param;

      for (uint32_t i = 0, num_arguments = method->numChild(); i < num_arguments; ++i)
         {
         param = method->childAt(i)->elem()->getValue();

         // check if parameter optional

         if (param) envelope.arg->push_back(param);
         }
#  endif

      U_RETURN(true);
      }

   U_RETURN(false);
}
Esempio n. 28
0
static void check(const UString& dati_cert, const UString& dati_ca)
{
   U_TRACE(5,"check(%p,%p)", &dati_cert, &dati_ca)

   UCertificate c(dati_cert);
   UCertificate ca(dati_ca);

   UVector<UString> vec1, vec2;
   (void) c.getCAIssuers(vec1);
   (void) c.getRevocationURL(vec2);

   cout << c                        << '\n'
        << c.isSelfSigned()         << '\n'
        << c.isIssued(ca)           << '\n'
        << c.getIssuer()            << '\n' 
   //   << c.getIssuerForLDAP()     << '\n' 
        << c.getSubject()           << '\n'
        << c.getVersionNumber()     << '\n'           
        << c.getSerialNumber()      << '\n' 
        << c.hashCode()             << '\n' 
        << c.getSignatureAlgorithm()<< '\n' 
        << c.getNotBefore()         << '\n' 
        << c.getNotAfter()          << '\n' 
        << c.checkValidity()        << '\n'
   //   << c.getSignature()         << '\n' 
   //   << c.getSignable()          << '\n' 
        << vec1                     << '\n'
        << vec2                     << '\n';

   UString encoded = c.getEncoded("PEM");

   /*
   UFile::writeTo("certificate.encode", encoded);

   U_ASSERT( dati_cert == encoded )
   */
}
Esempio n. 29
0
X509* UCertificate::readX509(const UString& x, const char* format)
{
   U_TRACE(1, "UCertificate::readX509(%V,%S)", x.rep, format)

   BIO* in;
   X509* _x509 = 0;
   UString tmp = x;

   if (format == 0) format = (x.isBinary() ? "DER" : "PEM");

   if (strncmp(format, U_CONSTANT_TO_PARAM("PEM")) == 0 &&
       strncmp(x.data(), U_CONSTANT_TO_PARAM("-----BEGIN CERTIFICATE-----")) != 0)
      {
      unsigned length = x.size();

      UString buffer(length);

      UBase64::decode(x.data(), length, buffer);

      if (buffer &&
          u_base64_errors == 0)
         {
         tmp    = buffer;
         format = "DER";
         }
      }

   in = (BIO*) U_SYSCALL(BIO_new_mem_buf, "%p,%d", U_STRING_TO_PARAM(tmp));

   _x509 = (X509*) (strncmp(format, U_CONSTANT_TO_PARAM("PEM")) == 0 ? U_SYSCALL(PEM_read_bio_X509, "%p,%p,%p,%p", in, 0, 0, 0)
                                                                     : U_SYSCALL(d2i_X509_bio,      "%p,%p",       in, 0));

   (void) U_SYSCALL(BIO_free, "%p", in);

   U_RETURN_POINTER(_x509, X509);
}
Esempio n. 30
0
xmlNodePtr UXML2Document::findParent(const xmlNodePtr cur, const xmlChar* name, const xmlChar* ns)
{
   U_TRACE(0, "UXML2Document::findParent(%p,%S,%S)", cur, name, ns)

   U_INTERNAL_ASSERT_POINTER(cur)
   U_INTERNAL_ASSERT_POINTER(name)

   xmlNodePtr ret;

   if (cur->type == XML_ELEMENT_NODE &&
       UXML2Node(cur).checkNodeName(name, ns))
      {
      U_RETURN_POINTER(cur, xmlNode);
      }

   if (cur->parent)
      {
      ret = findParent(cur->parent, name, ns);

      if (ret) U_RETURN_POINTER(ret, xmlNode);
      }

   U_RETURN_POINTER(0, xmlNode);
}