Beispiel #1
0
int NNTPResponse::NextIntField()
{
	return sstoi(NextField());
/***
	string_slice field = NextField();

	// convert to int
	char fieldStr[256];
	if (field.length() > 255)
		field.resize(255);
	int len = field.length();
	memcpy(fieldStr, field.begin(), len);
	fieldStr[len] = 0;
	return atoi(fieldStr);
***/
}
Beispiel #2
0
int NNTPResponse::NextIntTabField()
{
	return sstoi(NextTabField());
}
Beispiel #3
0
int main(int argc, char **argv)
{
   char *opt;
   int   idx  = 0;
   char buf[4096];
   int debug = 0;
   int loop = 0;
   int result;
   int loops = 0;
   argc--;
   argv++;
   func_t func;

   if ((func=checkforTest(argv[0])) == NULL)
   {
      syntax();
   }
   argc--;
   argv++;

   signal(SIGTERM, clean);
   signal(SIGQUIT, clean);
   signal(SIGINT, clean);

   while(idx < argc)
   {
      switch(getOpts("d:f:m:M:s:t:cr:n:b:DNPS:lL:R", argc, argv, &opt, &idx))
      {
         case 'd': if ( opt) testDir = opt; else syntax(); break;
         case 'f': if ( opt) maxFile = atoi(opt); else syntax(); break;
         case 'n': if ( opt) numberOp = atoi(opt); else syntax(); break;
         case 't': if ( opt) totalSize = stoi(opt); else syntax(); break;
         case 'm': if ( opt) minSize = stoi(opt); else syntax();break;
         case 'M': if ( opt) maxSize = stoi(opt); else syntax();break;
         case 's': if ( opt) stepSize = sstoi(opt, &stepType); else syntax(); break;
         case 'b': if ( opt) rwBufSize = stoi(opt); else syntax(); break;
         case 'c': csv = 1; break;
         case 'r': remount = opt; break;
         case 'D': debug = 1; break;
         case 'N': createFileBefore=0;break;
         case 'P': printCreateTime=1;break;
         case 'S': if ( opt) doSleep=atoi(opt); else syntax();break;
         case 'l': loop = 1;break;
         case 'L': if ( opt) loops = atoi(opt); else syntax();break;
         case 'R': toNull = 1;break;
         default: printf("Wrong option\n");syntax();
      }
   }

   if (maxFile <= 0 || testDir == NULL || maxSize <= 0 || rwBufSize < 1)
   {
      if ( debug )
      {
         fprintf(stderr,"Error checking parameters:\n");
         if ( maxFile <= 0 ) fprintf(stderr,"   maxFile = %d\n",maxFile);
         if ( testDir == NULL ) fprintf(stderr,"   testDir == NULL\n");
         if ( maxSize <= 0 ) fprintf(stderr,"   maxSize = %d\n",maxSize);
         if ( rwBufSize < 1 ) fprintf(stderr,"   rwBufSize = %d\n",rwBufSize);
      }
      syntax();
   }

   /* if test directory exist exit */
   if ( access(testDir,W_OK) == 0 )
   {
      fprintf(stderr,"Sorry <%s> exist\n", testDir);
      return 1;
   }

   if ( totalSize <= 0 )
   {
      totalSize = maxSize * maxFile;
   }

   if ( stepSize <= 0 && minSize <= 0 )
   {
      minSize = stepSize = maxSize;
   }

   if ( loop )
   {
      result = 1;
      while((result=func()))
         if ( killed ) break;
      /* at this stage we may have to make some cleanup */
      deleteTestDir(1);
      /* delete also sourcefile and sourcefile_* within the actual directory */
      deleteSourceFiles();
   }
   else if ( loops )
   {
      result = 1;
      while((result=func()) && --loops > 0)
         if ( killed )
         {
            /* at this stage we may have to make some cleanup */
            deleteTestDir(1);
            /* delete also sourcefile and sourcefile_* within the actual directory */
            deleteSourceFiles();
            break;
        }
   }
   else
   {
      result = func();
   }

   return result == 1 ? 0 : 1;
}