• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UtlString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中UtlString的典型用法代码示例。如果您正苦于以下问题:C++ UtlString类的具体用法?C++ UtlString怎么用?C++ UtlString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UtlString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: testSendInput

    void testSendInput()
    {
        OsStatus stat;
        OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "testSendInput");

        // this command will produce a mix of stdout and stderr
        UtlString appName = "sh";
        UtlString params[10];
        params[0] = "-c";
        params[1] = "cat";
        params[2] = NULL;

        OsProcess process;

        OsPath startupDir = ".";

        // std::cout << "Launching process: " << appName.data() << std::endl;
        OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "launching process %s %s", appName.data(), params[0].data());
        stat = process.launch(appName, params, startupDir,
                              OsProcessBase::NormalPriorityClass, false,
                              false/* don't ignore child signals*/);
        CPPUNIT_ASSERT(stat == OS_SUCCESS);
        CPPUNIT_ASSERT(process.isRunning());

        UtlString stdoutMsg, stderrMsg;
        int rc;

        // send "well", then "hello", and expect "goodbye" back
        bool bGotGoodbye = false;

        OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "starting sendInput task");
        SimpleTask * pTask = new SimpleTask(&process);
        pTask->start();

        OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "calling getOutput");
        while ( !bGotGoodbye && pTask->isStarted() && (rc = process.getOutput(&stdoutMsg, &stderrMsg)) > 0 )
        {
           if ( stdoutMsg.length() > 0 )
           {
              // The output is sure to contain newlines, and may contain several lines.
              // Clean it up before dispatching.
              UtlTokenizer tokenizer(stdoutMsg);
              UtlString    msg;
              while ( tokenizer.next(msg, "\r\n") )
              {
                 OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "got stdout: %s", msg.data());
                 if ( msg == "goodbye" ) {
                    OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "got goodbye command");
                    bGotGoodbye = true;
                 }
              }

           }
           if ( stderrMsg.length() > 0 )
           {
              OsSysLog::add(FAC_KERNEL, PRI_DEBUG, "got stderr: %s", stderrMsg.data());
           }
        }

        CPPUNIT_ASSERT(bGotGoodbye==true);
        pTask->requestShutdown();
        delete pTask;
    }
开发者ID:LordGaav,项目名称:sipxecs,代码行数:63,代码来源:OsProcessTest.cpp


示例2: strstr

int HttpGetCommand::execute(int argc, char* argv[])
{
    int commandStatus = CommandProcessor::COMMAND_FAILED;
    if(argc == 2)
    {
        commandStatus = CommandProcessor::COMMAND_SUCCESS;
        const char* url = argv[1];
        const char* serverBegin = strstr(url, "http://");
        if(serverBegin != url)
        {
            printf("unsupported protocol in Url: %s\n",
                url);
                    commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX;
        }

        else
        {
            serverBegin += 7;
            UtlString uri(serverBegin);
            ssize_t serverEndIndex = uri.index("/");
            if(serverEndIndex < 0) serverEndIndex = uri.length();
            if(serverEndIndex > 0)
            {
                UtlString server = uri;
                server.remove(serverEndIndex);
                ssize_t portIndex = server.index(":");
                int port = PORT_NONE;
                if(portIndex > 0)
                {
                    UtlString portString = server;
                    server.remove(portIndex);
                    portString.remove(0, portIndex + 1);
                    printf("port string: %s\n", portString.data());
                    port = atoi(portString.data());
                }
                uri.remove(0, serverEndIndex);
                if(uri.isNull()) uri = "/";
                printf("HTTP get of %s from server %s port: %d\n",
                    uri.data(), server.data(), port);

                if (!portIsValid(port))
                {
                    port = 80;
                    printf("defaulting to http port 80\n");
                }

                OsConnectionSocket getSocket(port, server.data());
                HttpMessage getRequest;
                getRequest.setFirstHeaderLine("GET", uri.data(), HTTP_PROTOCOL_VERSION);

                int wroteBytes = getRequest.write(&getSocket);
                printf("wrote %d\n", wroteBytes);

                HttpMessage getResponse;
                getResponse.read(&getSocket);

                UtlString responseBytes;
                ssize_t responseLength;
                getResponse.getBytes(&responseBytes, &responseLength);
                printf("Got %zu bytes\n", responseLength);
                printf("Response: ++++++++++++++++++++++++++++++++++\n%s\n",
                    responseBytes.data());
            }

            else
            {
                printf("invalid server in Url: %s\n",
                url);
                        commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX;
            }
        }
    }

        else
        {
                UtlString usage;
                getUsage(argv[0], &usage);
                printf("%s", usage.data());
                commandStatus = CommandProcessor::COMMAND_BAD_SYNTAX;
                //commandStatus = CommandProcessor::COMMAND_FAILED;
        }

        return(commandStatus);
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:84,代码来源:HttpGetCommand.cpp


示例3: buildOutputFiles

bool SwAdminRpcMethod::buildOutputFiles(const UtlString&     command,
                         UtlString&      stdoutfn,
                         UtlString&      stderrfn
                        )
{
   bool result = true;
   stdoutfn.remove(0);
   stderrfn.remove(0);
   if ( command.compareTo(SwAdminVersion_cmd, UtlString::ignoreCase) == 0)
   {
       stdoutfn.append(SwAdminVersion_cmd);
       stderrfn.append(SwAdminVersion_cmd);
   }
   else
      if ( command.compareTo(SwAdminCheckUpdate_cmd, UtlString::ignoreCase) == 0)
      {
         stdoutfn.append(SwAdminCheckUpdate_cmd);
         stderrfn.append(SwAdminCheckUpdate_cmd);
      }
      else
         if ( command.compareTo(SwAdminUpdate_cmd, UtlString::ignoreCase) == 0)
         {
            stdoutfn.append(SwAdminUpdate_cmd);
            stderrfn.append(SwAdminUpdate_cmd);
         }
         else
            if ( command.compareTo(SwAdminRestart_cmd, UtlString::ignoreCase) == 0)
            {
               stdoutfn.append(SwAdminRestart_cmd);
               stderrfn.append(SwAdminRestart_cmd);
            }
            else
               if ( command.compareTo(SwAdminReboot_cmd, UtlString::ignoreCase) == 0)
               {
                  stdoutfn.append(SwAdminReboot_cmd);
                  stderrfn.append(SwAdminReboot_cmd);
               }
               else
               {
                  return false;
               }

   stderrfn.append(SwAdminStdErr_filetype);
   stdoutfn.append(SwAdminStdOut_filetype);

   return result;
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:47,代码来源:SwAdminRpc.cpp


示例4: while

// Construct mappings from an input string.
UtlBoolean
SipRedirectorGateway::addMappings(const char* value,
                                  int length,
                                  UtlString*& user,
                                  const char*& error_msg,
                                  int& location)
{
   // Process the input string one character at a time.
   // Buffer into which to edit the input string.
   char buffer[FORM_SIZE];
   // Pointer for filling the edit buffer.
   char* p = buffer;
   char c;
   int count = length;
   while (count-- > 0)
   {
      c = *value++;
      switch (c)
      {
      case '\n':
         // Trim trailing whitespace on the line.
         while (p > buffer && p[-1] != '\n' && isspace(p[-1]))
         {
            p--;
         }
         // Fall through to insert if not at the beginning of a line.
      case ' ':
      case '\t':
         // If at the beginning of a line, ignore it.
         if (p > buffer && p[-1] != '\n' && p[-1] != '{')
         {
            *p++ = c;
         }
         break;
      case '}':
      {
         // Process component redirection.
         // Trim trailing whitespace.
         while (p > buffer && isspace(p[-1]))
         {
            p--;
         }
         // Find the matching '{'.
         *p = '\0';             // End scope of strrchr.
         char* open = strrchr(buffer, '{');
         if (open == NULL)
         {
            error_msg = "Unmatched '}'";
            location = length - count;
            return FALSE;
         }
         if (open+1 == p)
         {
            error_msg = "No contacts given";
            location = length - count;
            return FALSE;
         }
         // Insert the addresses into the map and get the assigned user name.
         UtlString* user = addMapping(open+1, p - (open+1));
         // Truncate off the sub-redirection.
         p = open;
         // Append the resulting user name.
         strcpy(p, user->data());
         p += strlen(user->data());
      }
         break;
      case '{':
         // '{' is copied into the buffer like other characters.
      default:
         // Ordinary characters are just copied.
         *p++ = c;
         break;
      }
   }
   // Trim trailing whitespace.
   while (p > buffer && isspace(p[-1]))
   {
      p--;
   }
   // Check that there are no unclosed '{'.
   *p = '\0';                   // To limit strchr's search.
   if (strchr(buffer, '{') != NULL)
   {
      error_msg = "Unmatched '{'";
      // Report at end of string because we have no better choice.
      location = length;
      return FALSE;
   }
   // Check that the contacts are not empty.
   if (p == buffer)
   {
      error_msg = "No contacts given";
      location = 0;
      return FALSE;
   }
   // Insert the addresses into the map and return the assigned user name.
   user = addMapping(buffer, p - buffer);
   return TRUE;
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:100,代码来源:SipRedirectorGateway.cpp


示例5: execute

   virtual bool execute(const HttpRequestContext& requestContext, ///< request context
                        UtlSList& params,                         ///< request param list
                        void* userData,                           ///< user data
                        XmlRpcResponse& response,                 ///< request response
                        ExecutionStatus& status
                        )
      {
         UtlString* dbName = dynamic_cast<UtlString*>(params.at(0));

         if (dbName && !dbName->isNull())
         {
            OsReadLock lock(*ConfigRPC::spDatabaseLock);

            ConfigRPC* db = ConfigRPC::find(*dbName);
            if (db)
            {
               status = db->mCallback->accessAllowed(requestContext, ConfigRPC_Callback::Set);
               if ( XmlRpcMethod::OK == status )
               {
                  // read in the dataset
                  OsConfigDb dataset;
                  OsStatus datasetStatus = db->load(dataset);
                  if ( OS_SUCCESS == datasetStatus )
                  {
                     // get the list of names that the request is asking for
                     UtlContainable* secondParam = params.at(1);
                     if ( secondParam )
                     {
                        UtlHashMap* paramList = dynamic_cast<UtlHashMap*>(secondParam);
                        if (paramList)
                        {
                           /*
                            * Iterate over the requested name/value pairs
                            */
                           UtlHashMapIterator params(*paramList);
                           UtlContainable* nextParam = NULL;
                           size_t paramsSet = 0;

                           while (    XmlRpcMethod::OK == status
                                  && (nextParam = params())
                                  )
                           {
                              UtlString* name = dynamic_cast<UtlString*>(params.key());
                              if ( name )
                              {
                                 UtlString* value = dynamic_cast<UtlString*>(params.value());
                                 if (value)
                                 {
                                    dataset.set(*name, *value);
                                    paramsSet++;
                                 }
                                 else
                                 {
                                    UtlString faultMsg;
                                    faultMsg.append("parameter name '");
                                    faultMsg.append(*name);
                                    faultMsg.append("' value is not a string");
                                    response.setFault(ConfigRPC::invalidType, faultMsg.data());
                                    status = XmlRpcMethod::FAILED;
                                 }
                              }
                              else
                              {
                                 UtlString faultMsg;
                                 faultMsg.append("parameter number ");
                                 char paramIndex[10];
                                 sprintf(paramIndex,"%zu", paramsSet + 1);
                                 faultMsg.append(paramIndex);
                                 faultMsg.append(" name is not a string");
                                 response.setFault(ConfigRPC::invalidType, faultMsg.data());
                                 status = XmlRpcMethod::FAILED;
                              }
                           }

                           if ( XmlRpcMethod::OK == status )
                           {
                              if (OS_SUCCESS == db->store(dataset))
                              {
                                 UtlInt numberSet(paramList->entries());
                                 response.setResponse(&numberSet);
                              }
                              else
                              {
                                 response.setFault( ConfigRPC::storeFailed
                                                   ,"error storing dataset"
                                                   );
                                 status = XmlRpcMethod::FAILED;
                              }
                           }
                        }
                        else
                        {
                           // The second parameter was not a list
                           response.setFault( ConfigRPC::invalidType
                                             ,"second parameter is not a struct"
                                             );
                           status = XmlRpcMethod::FAILED;
                        }
                     }
                     else // no parameter names specified
//.........这里部分代码省略.........
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:101,代码来源:ConfigRPC.cpp


示例6: lock

UtlBoolean SipTransactionList::waitUntilAvailable(SipTransaction* transaction,
                                                 const UtlString& hash)
{
    UtlBoolean exists;
    UtlBoolean busy = FALSE;
    int numTries = 0;

    do
    {
        numTries++;

        lock();
        exists = transactionExists(transaction, hash);

        if(exists)
        {
            busy =  transaction->isBusy();
            if(!busy)
            {
                transaction->markBusy();
                unlock();
//#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p locked after %d tries\n",
                    transaction, numTries);
//#endif
            }
            else
            {
                // We set an event to be signaled when a
                // transaction is released.
                OsEvent* waitEvent = new OsEvent;
                transaction->notifyWhenAvailable(waitEvent);

                // Must unlock while we wait or there is a deadlock
                unlock();

//#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p waiting on: %p after %d tries\n",
                    transaction, waitEvent, numTries);
//#endif

                OsStatus waitStatus;
                OsTime transBusyTimeout(1, 0);
                int waitTime = 0;
                do
                {
                    if(waitTime > 0)
                        OsSysLog::add(FAC_SIP, PRI_WARNING, "SipTransactionList::waitUntilAvailable %p still waiting: %d",
                            transaction, waitTime);

                    waitStatus = waitEvent->wait(transBusyTimeout);
                    waitTime+=1;
                }
                while(waitStatus != OS_SUCCESS && waitTime < 30);

                // If we were never signaled, then we signal the
                // event so the other side knows that it has to
                // free up the event
                if(waitEvent->signal(-1) == OS_ALREADY_SIGNALED)
                {
                    delete waitEvent;
                    waitEvent = NULL;
                }

                // If we bailed out before the event was signaled
                // pretend the transaction does not exist.
                if(waitStatus != OS_SUCCESS)
                {
                    exists = FALSE;
                }

                if(waitTime > 1)
                {
                    if (OsSysLog::willLog(FAC_SIP, PRI_WARNING))
                    {
                        UtlString transTree;
                        UtlString waitingTaskName;
                        OsTask* waitingTask = OsTask::getCurrentTask();
                        if(waitingTask) waitingTaskName = waitingTask->getName();
                        transaction->dumpTransactionTree(transTree, FALSE);
                        OsSysLog::add(FAC_SIP, PRI_WARNING, "SipTransactionList::waitUntilAvailable status: %d wait time: %d transaction: %p task: %s transaction tree: %s",
                            waitStatus, waitTime, transaction, waitingTaskName.data(), transTree.data());
                    }
                }

//#ifdef TEST_PRINT
                OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p done waiting after %d tries\n",
                    transaction, numTries);
//#endif
            }
        }
        else
        {
            unlock();
//#ifdef TEST_PRINT
            OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipTransactionList::waitUntilAvailable %p gone after %d tries\n",
                    transaction, numTries);
//#endif
        }
    }
//.........这里部分代码省略.........
开发者ID:Konnekt,项目名称:lib-sipx,代码行数:101,代码来源:SipTransactionList.cpp


示例7: string_get

void
SipRedirectorGateway::processForm(const HttpRequestContext& requestContext,
                              const HttpMessage& request,
                              HttpMessage*& response)
{
   UtlString string_get("get");
   UtlString string_set("set");
   UtlString string_prefix("prefix");
   UtlString string_destination("destination");

   Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                 "%s::processForm entered", mLogName.data());
   UtlString* user;

   // Process the request.

   // Get the body of the request.
   const HttpBody* request_body = request.getBody();

   Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                 "%s::processForm A *** request body is '%s'",
                 mLogName.data(), request_body->getBytes());

   // Get the values from the form.
   if (request_body->isMultipart())
   {
      // Extract the values from the form data.
      UtlHashMap values;
      int c = request_body->getMultipartCount();
      for (int i = 0; i < c; i++)
      {
         UtlString* name = new UtlString;
         if (request_body->getMultipart(i)->getPartHeaderValue("name", *name))
         {
            const char* v;
            int l;
            request_body->getMultipartBytes(i, &v, &l);
            // Strip leading and trailing whitespace from values.
            UtlString* value = new UtlString(v, l);
            value->strip(UtlString::both);
            Os::Logger::instance().log(FAC_SIP, PRI_CRIT,
                          "%s::processForm "
                          "form value '%s' = '%s'",
                          mLogName.data(), name->data(), value->data());
            // 'name' and 'value' are now owned by 'values'.
            values.insertKeyAndValue(name, value);
         }
         else
         {
            // 'name' is not owned by 'values' and we have to delete it.
            delete name;
         }
      }

      if (values.findValue(&string_get))
      {
         // This is a "get gateway" request.

         // Insert the HTML into the response.
         HttpBody* response_body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML);
         response->setBody(response_body);
      }
      else if (values.findValue(&string_set))
      {
         // This is a "set gateway" request.

         // Validate the routing prefix.
         UtlString* prefix =
            dynamic_cast <UtlString*> (values.findValue(&string_prefix));
         if (prefixIsValid(*prefix))
         {
            // Validate the destination.
            UtlString* destination =
               dynamic_cast <UtlString*>
                   (values.findValue(&string_destination));
            if (destination_is_valid(destination))
            {
               Os::Logger::instance().log(FAC_SIP, PRI_CRIT,
                             "%s::processForm "
                             "add mapping '%s' -> '%s'",
                             mLogName.data(), prefix->data(), destination->data());

               mMapLock.acquire();
               // Insert the mapping.
               mMapUserToContacts.insertKeyAndValue(prefix, destination);
               mMapContactsToUser.insertKeyAndValue(destination, prefix);
               mMapLock.release();

               writeMappings();
            }
         }
         // Insert the HTML into the response.
         HttpBody* response_body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML);
         response->setBody(response_body);
      }
      else
      {
         // Incomprehensible request.

         // Insert the HTML into the response.
//.........这里部分代码省略.........
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:101,代码来源:SipRedirectorGateway.cpp


示例8: testAllLongDistancePermutations

      void testAllLongDistancePermutations()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;
         UtlString callTag = "UNK";

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         // permutations for the 'boston' location
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.8",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.8",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.8",actual);
         registrations.destroyAll();

         // permutations for the 'seattle' location
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("seattle"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.7",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("seattle"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.7",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("seattle"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 2 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.9",actual);
         getResult( registrations, 1, "contact", actual);
         ASSERT_STR_EQUAL("<sip:[email protected]>;q=0.7",actual);
         registrations.destroyAll();

         // permutations for the other locations
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("walla-walla"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString(""),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
//.........这里部分代码省略.........
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:101,代码来源:FallbackRulesUrlMappingTest.cpp


示例9: testAllEmergencyPermutations

      void testAllEmergencyPermutations()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;
         UtlString callTag = "UNK";

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         // permutations for the 'boston' location
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         // permutation for the 'seattle' location
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("seattle"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
//.........这里部分代码省略.........
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:101,代码来源:FallbackRulesUrlMappingTest.cpp


示例10: main

int main(int argc, char* argv[])
{
    int provisioningAgentPort = 8110;
    int watchdogRpcServerPort = 8092;
    ACDServer* pAcdServer;

    // Disable osPrintf's
    enableConsoleOutput(false);

    UtlString argString;
    for (int argIndex = 1; argIndex < argc; argIndex++) {
        osPrintf("arg[%d]: %s\n", argIndex, argv[argIndex]);
        argString = argv[argIndex];
        NameValueTokenizer::frontBackTrim(&argString, "\t ");
        if (argString.compareTo("-v") == 0) {
            enableConsoleOutput(true);
            osPrintf("Version: %s (%s)\n", VERSION, PACKAGE_REVISION);
            return(1);
        }
        else if (argString.compareTo("-c") == 0) {
            // Enable osPrintf's
            enableConsoleOutput(true);
        }
        else if (argString.compareTo("-d") == 0) {
            // Switch ACDServer PRI_DEBUG to PRI_NOTICE
            gACD_DEBUG = PRI_NOTICE;
        }
        else if (argString.compareTo("-P") == 0) {
            argString = argv[++argIndex];
            provisioningAgentPort = atoi(argString.data());
        }
        else if (argString.compareTo("-W") == 0) {
            argString = argv[++argIndex];
            watchdogRpcServerPort = atoi(argString.data());
        }
        else {
            enableConsoleOutput(true);
            osPrintf("usage: %s [-v] [-c] [-d] [-P port] [-W wport]\nwhere:\n -v      Provides the software version\n"
                     " -c       Enables console output of log and debug messages\n"
                     " -d       Changes ACDServer DEBUG logging to run at NOTICE level\n"
                     " -P port  Specifies the provisioning interface port number\n"
                     " -W wport Specifies the Watchdog interface port number\n",
                     argv[0]);
            return(1);
        }
    }


    // Create the ACDServer and get to work.
    pAcdServer = new ACDServer(provisioningAgentPort, watchdogRpcServerPort);

    // Loop forever until signaled to shut down
    while (!Os::UnixSignals::instance().isTerminateSignalReceived() && !gShutdownFlag) {
        OsTask::delay(2000);
    }

    // Shut down the ACDServer.
    delete pAcdServer;

    // Flush the log file
    Os::Logger::instance().flush();

    // Say goodnight Gracie...

    // Use _exit to avoid the atexit() processing which will cause the
    // destruction of static objects...yet there are still threads out
    // there using those static objects.  This prevents core dumps
    // due to those threads accessing the static objects post destruction.
    //
    // --Woof!

    _exit(0);

    /*NOTREACHED*/
    return 0 ; // To appease the compiler gods
}
开发者ID:ciuc,项目名称:sipxecs,代码行数:76,代码来源:main.cpp


示例11: testAll800Permutations

      void testAll800Permutations()
      {
         FallbackRulesUrlMapping* urlmap;
         ResultSet registrations;
         UtlString actual;
         UtlString callTag = "UNK";

         CPPUNIT_ASSERT( urlmap = new FallbackRulesUrlMapping() );
         UtlString simpleXml;
         mFileTestContext->inputFilePath("fallbackrules.xml", simpleXml);
         CPPUNIT_ASSERT( urlmap->loadMappings(simpleXml.data() ) == OS_SUCCESS );

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("boston"),
                                registrations, callTag
                                ) == OS_SUCCESS );

         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("regina"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString(""),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("new-york"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();
         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:1800[email protected]")
                                ,UtlString("DC"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("Philly"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString(""),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("miami"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         CPPUNIT_ASSERT( urlmap->getContactList( Url("sip:[email protected]")
                                ,UtlString("orlando"),
                                registrations, callTag
                                ) == OS_SUCCESS );
         CPPUNIT_ASSERT_EQUAL( 1 ,  registrations.getSize() );
         getResult( registrations, 0, "contact", actual);
         ASSERT_STR_EQUAL("sip:[email protected]",actual);
         registrations.destroyAll();

         delete urlmap;
      }
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:94,代码来源:FallbackRulesUrlMappingTest.cpp


示例12: reportDialogTrackerReadyForDeletion

void SessionContext::reportDialogTrackerReadyForDeletion( const UtlString& handleOfRequestingDialogContext )
{
   OsSysLog::add(FAC_NAT, PRI_DEBUG, "SessionContext[%s]::reportDialogTrackerReadyForDeletion for dialog tracker %s",
                                     mHandle.data(), handleOfRequestingDialogContext.data() ); 
   mListOfDialogTrackersReadyForDeletion.push_back( handleOfRequestingDialogContext );
}
开发者ID:chemeris,项目名称:sipxecs,代码行数:6,代码来源:SessionContext.cpp


示例13: linkFarEndMediaRelayPortToRequester

bool SessionContext::linkFarEndMediaRelayPortToRequester(  const UtlString& handleOfRequestingDialogContext,
                                                           const tMediaRelayHandle& relayHandle, 
                                                           const MediaDescriptor* pMediaDescriptor, 
                                                           EndpointRole endpointRoleOfRequester )
{
   EndpointRole farEndRole;
   EndpointDescriptor *pRequestingEndpointDescriptor;

   if( endpointRoleOfRequester == CALLER )
   {
      farEndRole = CALLEE;
      pRequestingEndpointDescriptor = mpCaller;
   }
   else
   {
      farEndRole = CALLER;
      pRequestingEndpointDescriptor = mpCallee;
   }

   bool bLinkPerformed = false;

   LocationCode requestingEndpointLocation; 
   UtlString    requestingEndpointIpAddress;
   int          requestingEndpointRtpPort;
   int          requestingEndpointRtcpPort;

   requestingEndpointLocation = pRequestingEndpointDescriptor->getLocationCode();

   if( requestingEndpointLocation != UNKNOWN &&
       pMediaDescriptor->getEndpoint( endpointRoleOfRequester ).getAddress() == pRequestingEndpointDescriptor->getNativeTransportAddress().getAddress() )
   {
      // SDP originates from the actual endpoint, the call is not 3PCC. If the endpoint falls into one
      // of these two categories then link the media relay to the endpoint's media IP and port
      // #1 - the location of the endpoint is PUBLIC
      // #2 - the location of the endpoint is LOCAL_NATED and the media server is location in the same subnet as sipXecs
      if( ( requestingEndpointLocation == PUBLIC ) ||
          ( requestingEndpointLocation == LOCAL_NATED &&
            mpMediaRelay->isPartOfsipXLocalPrivateNetwork() ) )
      {
         // the endpoint is at a predictable IP address and port, no need to autolearn anything
         requestingEndpointIpAddress = pMediaDescriptor->getEndpoint( endpointRoleOfRequester ).getAddress();
         requestingEndpointRtpPort =   pMediaDescriptor->getEndpoint( endpointRoleOfRequester ).getRtpPort();
         requestingEndpointRtcpPort =  pMediaDescriptor->getEndpoint( endpointRoleOfRequester ).getRtcpPort();      
      }
      else 
      {
         // the endpoint is behind a NAT relative to the media relay server.  This means that its 
         // media IP address is going to be its public IP address but the port is non-deterministic
         requestingEndpointIpAddress = pRequestingEndpointDescriptor->getPublicTransportAddress().getAddress();
         requestingEndpointRtpPort   = 0;
         requestingEndpointRtcpPort  = 0;
      }
   }
   else
   {
      // The location of the endpoint is UNKNOWN or the IP address in the SDP does not 
      // belong to the sender of the SDP in which case we may be in the presence or a 3PCC.  
      // In either case, since we cannot establish the position of the endpoint relative 
      // to the media relay, let's assume the worst case and autolearn both the IP address 
      // and port number.
      requestingEndpointIpAddress =  "";
      requestingEndpointRtpPort   =  0;
      requestingEndpointRtcpPort  =  0;
   }
   OsSysLog::add(FAC_NAT, PRI_DEBUG, "SessionContext[%s]::linkMediaRelayPortToFarEnd for dialog tracker %s: relay handle %d - linking far-end relay port to '%s':%d,%d",
                                     mHandle.data(), handleOfRequestingDialogContext.data(), (int)(relayHandle.getValue()), requestingEndpointIpA 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UtlVoidPtr类代码示例发布时间:2022-05-31
下一篇:
C++ UtlSList类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap