~ubuntu-branches/ubuntu/utopic/sip-tester/utopic

« back to all changes in this revision

Viewing changes to actions.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell, Paul Belanger, Mark Purcell
  • Date: 2011-11-03 21:56:17 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20111103215617-nnxicj1oto9e8ix5
Tags: 1:3.2-1
[ Paul Belanger ]
* New Upstream Release (Closes: #623915).
* Switch to dpkg-source 3.0 (quilt) format
* Building with PCAP play.
* Switch back to Debhelper.
* debian/patches/spelling-error-in-binary: Fix lintian warning

[ Mark Purcell ]
* Drop pabs from Uploaders: at his request
* fix debhelper-overrides-need-versioned-build-depends
* fix description-synopsis-starts-with-article

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 
67
67
bool CAction::compare(VariableTable *variableTable) {
68
68
  double lhs = variableTable->getVar(M_varInId)->getDouble();
69
 
  double rhs = M_doubleValue;
 
69
  double rhs = M_varIn2Id ? variableTable->getVar(M_varIn2Id)->getDouble() : M_doubleValue;
70
70
 
71
71
  switch(M_comp) {
72
72
    case E_C_EQ:
91
91
{
92
92
  if (M_action == E_AT_ASSIGN_FROM_REGEXP) {
93
93
    if(M_lookingPlace == E_LP_MSG) {
94
 
      printf("Type[%d] - regexp[%s] where[%s] - checkIt[%d] - $%s",
 
94
            printf("Type[%d] - regexp[%s] where[%s] - checkIt[%d] - checkItInverse[%d] - $%s",
95
95
             M_action,
96
96
             M_regularExpression,
97
97
             "Full Msg",
98
98
             M_checkIt,
 
99
                   M_checkItInverse,
99
100
                       display_scenario->allocVars->getName(M_varId));
100
101
    } else {
101
 
      printf("Type[%d] - regexp[%s] where[%s-%s] - checkIt[%d] - $%d",
 
102
            printf("Type[%d] - regexp[%s] where[%s-%s] - checkIt[%d] - checkItInverse[%d] - $%s",
102
103
             M_action,
103
104
             M_regularExpression,
104
105
             "Header",
105
106
             M_lookingChar,
106
 
             M_checkIt, display_scenario->allocVars->getName(M_varId));
 
107
                   M_checkIt,
 
108
                   M_checkItInverse, display_scenario->allocVars->getName(M_varId));
107
109
    }
108
110
  } else if (M_action == E_AT_EXECUTE_CMD) {
109
 
    if (M_cmdLine) {
110
 
        printf("Type[%d] - command[%-32.32s]", M_action, M_cmdLine);
111
 
    }
 
111
    printf("Type[%d] - command[%-32.32s]", M_action, M_message_str[0]);
112
112
  } else if (M_action == E_AT_EXEC_INTCMD) {
113
113
      printf("Type[%d] - intcmd[%-32.32s]", M_action, strIntCmd(M_IntCmd));
114
114
  } else if (M_action == E_AT_LOG_TO_FILE) {
115
 
      printf("Type[%d] - message[%-32.32s]", M_action, M_message[0]);
 
115
      printf("Type[%d] - message[%-32.32s]", M_action, M_message_str[0]);
116
116
  } else if (M_action == E_AT_LOG_WARNING) {
117
 
      printf("Type[%d] - warning[%-32.32s]", M_action, M_message[0]);
 
117
      printf("Type[%d] - warning[%-32.32s]", M_action, M_message_str[0]);
 
118
  } else if (M_action == E_AT_LOG_ERROR) {
 
119
      printf("Type[%d] - error[%-32.32s]", M_action, M_message_str[0]);
118
120
  } else if (M_action == E_AT_ASSIGN_FROM_SAMPLE) {
119
121
      char tmp[40];
120
122
      M_distribution->textDescr(tmp, sizeof(tmp));
121
 
      printf("Type[%d] - sample varId[%d] %s", M_action, display_scenario->allocVars->getName(M_varId), tmp);
 
123
      printf("Type[%d] - sample varId[%s] %s", M_action, display_scenario->allocVars->getName(M_varId), tmp);
122
124
  } else if (M_action == E_AT_ASSIGN_FROM_VALUE) {
123
 
      printf("Type[%d] - assign varId[%d] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
 
125
      printf("Type[%d] - assign varId[%s] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
124
126
  } else if (M_action == E_AT_ASSIGN_FROM_INDEX) {
125
 
      printf("Type[%d] - assign index[%d]", M_action, display_scenario->allocVars->getName(M_varId));
 
127
      printf("Type[%d] - assign index[%s]", M_action, display_scenario->allocVars->getName(M_varId));
126
128
  } else if (M_action == E_AT_ASSIGN_FROM_GETTIMEOFDAY) {
127
 
      printf("Type[%d] - assign gettimeofday[%d, %d]", M_action, display_scenario->allocVars->getName(M_varId));
 
129
      printf("Type[%d] - assign gettimeofday[%s, %s]", M_action, display_scenario->allocVars->getName(M_varId), display_scenario->allocVars->getName(M_subVarId[0]));
128
130
  } else if (M_action == E_AT_ASSIGN_FROM_STRING) {
129
 
      printf("Type[%d] - string assign varId[%d] [%-32.32s]", M_action, display_scenario->allocVars->getName(M_varId), M_message[0]);
 
131
      printf("Type[%d] - string assign varId[%s] [%-32.32s]", M_action, display_scenario->allocVars->getName(M_varId), M_message_str[0]);
130
132
  } else if (M_action == E_AT_JUMP) {
131
 
      printf("Type[%d] - jump varInId[%d] %lf", M_action, display_scenario->allocVars->getName(M_varInId), M_doubleValue);
 
133
      printf("Type[%d] - jump varInId[%s] %lf", M_action, display_scenario->allocVars->getName(M_varInId), M_doubleValue);
132
134
  } else if (M_action == E_AT_PAUSE_RESTORE) {
133
 
      printf("Type[%d] - restore pause varInId[%d] %lf", M_action, display_scenario->allocVars->getName(M_varInId), M_doubleValue);
 
135
      printf("Type[%d] - restore pause varInId[%s] %lf", M_action, display_scenario->allocVars->getName(M_varInId), M_doubleValue);
134
136
  } else if (M_action == E_AT_VAR_ADD) {
135
 
      printf("Type[%d] - add varId[%d] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
 
137
      printf("Type[%d] - add varId[%s] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
136
138
  } else if (M_action == E_AT_VAR_MULTIPLY) {
137
 
      printf("Type[%d] - multiply varId[%d] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
 
139
      printf("Type[%d] - multiply varId[%s] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
138
140
  } else if (M_action == E_AT_VAR_DIVIDE) {
139
 
      printf("Type[%d] - divide varId[%d] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
 
141
      printf("Type[%d] - divide varId[%s] %lf", M_action, display_scenario->allocVars->getName(M_varId), M_doubleValue);
140
142
  } else if (M_action == E_AT_VAR_TRIM) {
141
 
      printf("Type[%d] - trim varId[%d]", M_action, display_scenario->allocVars->getName(M_varId));
 
143
      printf("Type[%d] - trim varId[%s]", M_action, display_scenario->allocVars->getName(M_varId));
142
144
  } else if (M_action == E_AT_VAR_TEST) {
143
 
      printf("Type[%d] - divide varId[%d] varInId[%d] %s %lf", M_action, display_scenario->allocVars->getName(M_varId), display_scenario->allocVars->getName(M_varInId), comparatorToString(M_comp), M_doubleValue);
 
145
      printf("Type[%d] - divide varId[%s] varInId[%s] %s %lf", M_action, display_scenario->allocVars->getName(M_varId), display_scenario->allocVars->getName(M_varInId), comparatorToString(M_comp), M_doubleValue);
144
146
  } else if (M_action == E_AT_VAR_TO_DOUBLE) {
145
 
      printf("Type[%d] - toDouble varId[%d]", M_action, display_scenario->allocVars->getName(M_varId));
 
147
      printf("Type[%d] - toDouble varId[%s]", M_action, display_scenario->allocVars->getName(M_varId));
146
148
#ifdef PCAPPLAY
147
149
  } else if ((M_action == E_AT_PLAY_PCAP_AUDIO) || (M_action == E_AT_PLAY_PCAP_VIDEO)) {
148
150
      printf("Type[%d] - file[%s]", M_action, M_pcapArgs->file);
159
161
CAction::T_Comparator   CAction::getComparator ()  { return(M_comp);         }
160
162
 
161
163
bool           CAction::getCheckIt()      { return(M_checkIt);      }
 
164
bool           CAction::getCheckItInverse() { return(M_checkItInverse);      }
162
165
bool           CAction::getCaseIndep()    { return(M_caseIndep);    }
163
166
bool           CAction::getHeadersOnly()  { return(M_headersOnly);  }
164
167
int            CAction::getOccurence()    { return(M_occurence);    }
165
168
int            CAction::getVarId()        { return(M_varId);        }
166
169
int            CAction::getVarInId()      { return(M_varInId);      }
 
170
int            CAction::getVarIn2Id()      { return(M_varIn2Id);      }
167
171
char*          CAction::getLookingChar()  { return(M_lookingChar);  }
168
172
SendingMessage *CAction::getMessage(int n)      { return(M_message[n]);      }
169
 
SendingMessage *CAction::getCmdLine()      { return(M_cmdLine);      }
170
173
CSample*       CAction::getDistribution() { return(M_distribution); }
171
174
double         CAction::getDoubleValue()  { return(M_doubleValue);  }
172
175
char*          CAction::getStringValue()  { return(M_stringValue);  }
180
183
{ M_lookingPlace = P_value; }
181
184
void CAction::setCheckIt      (bool           P_value) 
182
185
{ M_checkIt      = P_value; }
 
186
void CAction::setCheckItInverse      (bool           P_value) 
 
187
{ M_checkItInverse      = P_value; }
183
188
void CAction::setVarId        (int            P_value) 
184
189
{ M_varId        = P_value; }
185
190
void CAction::setVarInId      (int            P_value)
186
191
{ M_varInId        = P_value; }
 
192
void CAction::setVarIn2Id      (int            P_value)
 
193
{ M_varIn2Id        = P_value; }
187
194
void CAction::setCaseIndep    (bool           P_value)
188
195
{ M_caseIndep    = P_value; }
189
196
void CAction::setOccurence   (int            P_value) 
328
335
void CAction::setSubString(char** P_target, char* P_source, int P_start, int P_stop)
329
336
{
330
337
  int sizeOf;
331
 
  int sourceLength;
332
 
  size_t L_size = 0;
333
338
 
334
339
  if(P_source != NULL) {
335
340
    sizeOf = P_stop - P_start;
336
 
    if(sizeOf > 0) {
337
 
      L_size = (size_t) sizeOf;
338
 
      L_size += 1;
339
 
      (*P_target) = new char[L_size];
 
341
    (*P_target) = new char[sizeOf + 1];
340
342
 
 
343
    if (sizeOf > 0) {
341
344
      memcpy((*P_target), &(P_source[P_start]), sizeOf);
 
345
    }
342
346
 
343
 
      (*P_target)[sizeOf] = '\0';
344
 
         }
 
347
    (*P_target)[sizeOf] = '\0';
345
348
  } else {
346
349
    *P_target = NULL ;
347
350
  }
348
351
}
349
352
 
350
353
 
351
 
void CAction::setCmdLine  (char*          P_value)
352
 
{
353
 
  if(M_cmdLine != NULL)
354
 
  {
355
 
    delete [] M_cmdLine;
356
 
    M_cmdLine = NULL;
357
 
  }
358
 
 
359
 
  if(P_value != NULL)
360
 
  {
361
 
    M_cmdLine_str = strdup(P_value);
362
 
    M_cmdLine = new SendingMessage(M_scenario, P_value, true /* skip sanity */);
363
 
  }
364
 
}
365
 
 
366
354
#ifdef PCAPPLAY
367
355
void CAction::setPcapArgs (pcap_pkts  *  P_value)
368
356
{
426
414
 
427
415
  setLookingChar  ( P_action.getLookingChar()  );
428
416
  setCheckIt      ( P_action.getCheckIt()      );
 
417
    setCheckItInverse      ( P_action.getCheckItInverse()      );
429
418
  setCaseIndep    ( P_action.getCaseIndep()    ); 
430
419
  setOccurence    ( P_action.getOccurence()   );
431
420
  setHeadersOnly  ( P_action.getHeadersOnly()  );
433
422
    setMessage(P_action.M_message_str[L_i], L_i);
434
423
  }
435
424
  setRegExp       ( P_action.M_regularExpression);
436
 
  setCmdLine      ( P_action.M_cmdLine_str     );
437
425
  setIntCmd       ( P_action.M_IntCmd          );
438
426
#ifdef PCAPPLAY
439
427
  setPcapArgs     ( P_action.M_pcapArgs        );
445
433
  M_action       = E_AT_NO_ACTION;
446
434
  M_varId        = 0;
447
435
  M_varInId        = 0;
 
436
  M_varIn2Id        = 0;
448
437
 
449
438
  M_nbSubVarId    = 0;
450
439
  M_maxNbSubVarId = 0;
451
440
  M_subVarId      = NULL;
452
441
 
453
442
  M_checkIt      = false;
 
443
    M_checkItInverse      = false;
454
444
  M_lookingPlace = E_LP_MSG;
455
445
  M_lookingChar  = NULL;
456
446
  M_caseIndep    = false;
460
450
    M_message[i]   = NULL;
461
451
    M_message_str[i] = NULL;
462
452
  }
463
 
  M_cmdLine      = NULL;
464
453
  M_IntCmd       = E_INTCMD_INVALID;
465
454
  M_doubleValue  = 0;
466
455
  M_stringValue  = NULL;
468
457
#ifdef PCAPPLAY
469
458
  M_pcapArgs     = NULL;
470
459
#endif
471
 
  M_cmdLine_str  = NULL;
472
460
  M_scenario     = scenario;
473
461
  M_regExpSet    = false;
474
462
  M_regularExpression = NULL;
490
478
    free(M_message_str[i]);
491
479
    M_message_str[i] = NULL;
492
480
  }
493
 
  if(M_cmdLine != NULL)
494
 
  {
495
 
    delete M_cmdLine;
496
 
    M_cmdLine = NULL;
497
 
  }
498
 
  if(M_cmdLine_str != NULL)
499
 
  {
500
 
    delete M_cmdLine_str;
501
 
    M_cmdLine_str = NULL;
502
 
  }
503
481
  if(M_subVarId != NULL)
504
482
  {
505
483
    delete [] M_subVarId;