Exemple #1
0
OsStatus 
ResultSet::getIndex(
    const int& index, 
    UtlHashMap& rRecord) const
{
    // The record must be empty.  We can't clear the content because we don't own it.
    assert(rRecord.isEmpty());

    OsStatus result = OS_FAILED;
    UtlHashMap *m;
    if ((m = dynamic_cast<UtlHashMap*>(at(index))))
    {
        m->copyInto(rRecord);
        result = OS_SUCCESS;
    }
    return result;
}
Exemple #2
0
int main(int argc, char* argv[])
{
   parseArgs(argc, argv);
   initLogger(argv);
   OsEvent taskDone;

   Url url(xmlrpcURI);
    
   if (MemCheckDelay)
   {
      // Delay 45 seconds to allow memcheck start
      printf("Wating %d seconds for start of memcheck ...", MemCheckDelay);
      OsTask::delay(MemCheckDelay * 1000);
      printf("starting\n");
   }
   
   // If an input file was specified we start up the number
   // of specified threads to execute that input file. If number
   // of threads wasn't specified we start up 1 thread.
   if (bInputFile)
   {
      int signaled = 0;
      
      for (int i=0; i<numThreads; i++)
      {
         ClientTask* pTask = new ClientTask(&taskDone);
         pTask->start();
      }

      // Wait for threads to shut down
      while (signaled < numThreads)
      {
         taskDone.wait();
         taskDone.reset();
         ++signaled;
      }
      exit(0);
   }

   switch (Method)
   {
   case Version: // --version <xmlrpc URI> <dataset>
   {
      if (optind < argc)
      {
         fprintf(stderr, "Too many arguments: '%s'\n", argv[optind]);
         showHelp(argv);
         exit(1);
      }

      requestVersion(url);

      break;
   }
   case Get: // --get <xmlrpc URI> <dataset> <name> ...
   {
      UtlSList names;
      // copy remaining arguments into the names list
      while (optind < argc)
      {
         names.append(new UtlString(argv[optind++]));
      }
      
      requestGet(url, names);

      break;
   }
   case Set: // --set <xmlrpc URI> <dataset> <name> <value> [ <name> <value> ] ... 
   {
      UtlHashMap parameters;
      // copy remaining arguments into the names list
      while (optind + 1 < argc)
      {
         UtlString* setName = new UtlString(argv[optind++]);
         UtlString* setValue = new UtlString(argv[optind++]);
         parameters.insertKeyAndValue(setName, setValue);
      }
      if (optind < argc)
      {
         fprintf(stderr, "name '%s' without a value\n", argv[optind]);
         showHelp(argv);
         exit(1);
      }
      
      if (parameters.isEmpty())
      {
         fprintf(stderr, "must specify at least one name and value\n");
         showHelp(argv);
         exit(1);
      }
      else
      {
        requestSet(url, parameters);
        parameters.destroyAll();
      }

      break;
   }
   case Delete: // --delete <xmlrpc URI> <dataset> <name> ... 
   {
      UtlSList names;
      // copy remaining arguments into the names list
      while (optind < argc)
      {
         names.append(new UtlString(argv[optind++]));
      }
      
      requestDelete(url, names);

      break;
   }
   default:
      fprintf(stderr, "No method specified\n");
      showHelp(argv);
      exit(1);
   }
   
   if (MemCheckDelay)
   {
      // Delay 45 seconds to allow memcheck start
      printf("Wating %d seconds for stop of memcheck ...", MemCheckDelay);
      OsTask::delay(MemCheckDelay * 1000);
      printf("starting\n");
   }

   exit(0);
      
}