/* * test3 -- ファイルからのデータの読み出し */ Result test3() { int i; int fileNum, pageNum; File *file[2]; char page[PAGE_SIZE]; /* ファイルからの読み出しに使う配列 */ /* ファイルをオープンする */ if ((file[0] = openFile(TEST_FILE1)) == NULL) { fprintf(stderr, "Cannot open file.\n"); return NG; } if ((file[1] = openFile(TEST_FILE2)) == NULL) { fprintf(stderr, "Cannot open file.\n"); return NG; } /* ファイルからランダムにページを読み出し、正しく読めるかチェックする */ for (i = 0; i < (3 * FILE_SIZE); i++) { /* 0〜1の範囲の乱数を発生させる */ fileNum = getRandomInteger(0, 1); /* 0〜FILE_SIZE-1の範囲の乱数を発生させる */ pageNum = getRandomInteger(0, FILE_SIZE - 1); /* ファイルからページ番号pageNumのページを読み出す */ if (readPage(file[fileNum], pageNum, page) != OK) { fprintf(stderr, "Cannot read page.\n"); exit(1); } /* 書き込んだものと同じものが読み出せたかどうかチェックする */ if (memcmp(pagePattern[pageNum], page, PAGE_SIZE) == 0) { printf(" File %2d, Page %2d: OK\n", fileNum, pageNum); } else { printf(" File %2d, Page %2d: NG\n", fileNum, pageNum); } } /* ファイルをクローズする */ if (closeFile(file[0]) == NG) { fprintf(stderr, "Cannot close file.\n"); return NG; } if (closeFile(file[1]) == NG) { fprintf(stderr, "Cannot close file.\n"); return NG; } return OK; }
void NoAssociationSimulator::runSimulation() { if( m_numSamples == 0 ) { m_numSamples = numCombinations( m_order, m_snps.size( ) ); } m_simulatedAuc.resize( m_numSamples, 0.0f ); std::vector<bool> shuffledPhenotypes( m_phenotypes ); for(unsigned int sample = 0; sample < m_numSamples; sample++) { shufflePhenotypes( &shuffledPhenotypes ); ColumnData<unsigned char> snps; for(unsigned int k = 0; k < m_order; k++) { unsigned int snpIndex = getRandomInteger( m_snps.size( ) - 1 ); snps.addColumn( m_snps.getColumn( snpIndex ) ); } RocMdrAnalysis mdrAnalyzer( snps, m_phenotypes ); m_simulatedAuc[ sample ] = mdrAnalyzer.getAuc( ); } sort( m_simulatedAuc.begin( ), m_simulatedAuc.end( ) ); }
void getElement<M2::ARingZZp>(const M2::ARingZZp& R, int index, M2::ARingZZp::ElementType& result) { if (index < 50) R.set_from_long(result, index - 25); else { gmp_ZZ a = getRandomInteger(); R.set_from_mpz(result, a); } }
void NoAssociationSimulator::shufflePhenotypes(std::vector<bool> *phenotypes) { /* Fisher-Yates shuffle */ for(unsigned int i = phenotypes->size( ); i >= 1; i--) { /* j random between 0 and i inclusive. */ unsigned int j = getRandomInteger( i ); bool tmp = (*phenotypes)[ i ]; (*phenotypes)[ i ] = (*phenotypes)[ j ]; (*phenotypes)[ j ] = tmp; } }
/** Makes a new roll for RandomLvl perso attributes * * This class is static to get access to thegsCreatePerso::getHandlerList() * function. * * The tThis pointer get access to the current erCreatePerso instance but * none test is done, so if this pointer is NULL, this cause a segfault. * * \param root The root IGUIElement pointer * \param tThis A pointer to the current erCreatePerso instance */ void RainbruRPG::Events::erCreatePerso::roll(IGUIElement* root, erCreatePerso* tThis){ LOGI("Rolling new perso"); IGUIElement* guiE; stringw win; int lGet=0; int lAvail=0; int ran=0; AttrbHandlerList* handlerList=gsCreatePerso::getHandlerList(); AttrbHandlerList::const_iterator iter; // Iterate through list and output each element. for (iter=handlerList->begin(); iter != handlerList->end(); iter++){ ran=getRandomInteger(RANDOM_LVL_MIN,RANDOM_LVL_MAX ); win=StringConv::getSingleton().itow(ran); lGet+=ran; lAvail+=10; if ( (*iter)->type== AT_RANDOM_LVL){ guiE=root->getElementFromId((*iter)->irrId, true); if (guiE) guiE->setText(win.c_str()); else LOGE("Cannot change AT_RANDOM_LVL text"); } } tThis->setLevelGet(lGet); tThis->setLevelAvail(lAvail); // Get the level get/total static text guiE=root->getElementFromId(10000, true); ostringstream oss; oss << "Levels (get/total available) : "; oss << lGet; oss << "/"; oss << lAvail; stringw wi=StringConv::getSingleton().stow(oss.str()); guiE->setText(wi.c_str()); }
void child(char *s){ int points=0; int dice, n=10; signal(SIGUSR1, action2); // block myself while(1){ int fp = open("file.txt", O_RDWR); pause(); printf("%s: playing my dice\n", s); dice = getRandomInteger(n); printf("%s: got %d points\n", s, dice); points+=dice; printf("%s: Total so far %d\n\n", s, points); lseek(fp, 0 , SEEK_SET); write(fp, &points, sizeof(points)); close(fp); sleep(3); // fp = fopen ("file.txt", "w"); // fprintf(fp,"%d\n",points); // lseek(fd,0,SEEK_SET); // write(fd,&points,sizeof(points)); // fclose(fp); /* if(points >= total){ printf("%s: game over I won\n", s); kill(0, SIGTERM); } */ kill(getppid(), SIGUSR1); } }
void child(char *s, int fd){ int points=0; int dice, n=20; char buf[20]; while(1){ signal(16, action); // block myself pause(); printf("%s: playing my dice\n", s); dice = getRandomInteger(n); printf("%s: got %d points\n", s, dice); points+=dice; printf("%s: Total so far %d\n\n", s, points); lseek(fd, 0, SEEK_SET); sprintf(buf, "%d %s", points, s); //writes name and score to file write(fd, buf,strlen(buf)); sleep(1); kill(getppid(), 16); } }
/* * main -- エントリポイント */ int main(int argc, char **argv) { int i, j; /* 乱数の初期化 */ initializeRandomGenerator(); /* * ファイルアクセスモジュールの初期化 */ if (initializeFileModule() != OK) { fprintf(stderr, "%s: initialization failed.\n", TEST_NAME); } /* * 前回このプログラムを実行したときのテストファイルが * 残っている可能性があるので、まず消去する */ deleteFile(TEST_FILE1); deleteFile(TEST_FILE2); /* FILE_SIZE分のページの内容を乱数で作成 */ for (i = 0; i < FILE_SIZE; i++) { for (j = 0; j < PAGE_SIZE; j++) { /* 0〜9の範囲の乱数を発生しパターンを作る */ int x; x = getRandomInteger(0, 9); /* ページに'0'〜'9'の文字を入れる */ pagePattern[i][j] = '0' + x; } } /* テストの実行 */ fprintf(stderr, "%s: test 1: Start\n", TEST_NAME); if (test1() == OK) { fprintf(stderr, "%s: test 1: OK\n\n", TEST_NAME); } else { fprintf(stderr, "%s: test 1: NG\n\n", TEST_NAME); } fprintf(stderr, "%s: test 2: Start\n", TEST_NAME); if (test2() == OK) { fprintf(stderr, "%s: test 2: OK\n\n", TEST_NAME); } else { fprintf(stderr, "%s: test 2: NG\n\n", TEST_NAME); } fprintf(stderr, "%s: test 3: Start\n", TEST_NAME); if (test3() == OK) { fprintf(stderr, "%s: test 3: OK\n\n", TEST_NAME); } else { fprintf(stderr, "%s: test 3: NG\n\n", TEST_NAME); } fprintf(stderr, "%s: test 4: Start\n", TEST_NAME); if (test4() == OK) { fprintf(stderr, "%s: test 4: OK\n\n", TEST_NAME); } else { fprintf(stderr, "%s: test 4: NG\n\n", TEST_NAME); } /* * ファイルアクセスモジュールの終了処理 */ if (finalizeFileModule() != OK) { fprintf(stderr, "%s: finalization failed.\n", TEST_NAME); } exit(0); }
int qml_interface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: itFogz(); break; case 1: destroyAll(); break; case 2: fair(); break; case 3: pCloudy(); break; case 4: cloudy(); break; case 5: rain(); break; case 6: thunder(); break; case 7: snow(); break; case 8: updateSlot(); break; case 9: replyFinished((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break; case 10: { QString _r = getWindSpeed(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 11: { QString _r = getWindDirection(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 12: { QString _r = getTemperature(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 13: { QString _r = getTime(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 14: { QString _r = depsurx(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 15: { QString _r = arvsurx(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 16: { QString _r = depsury(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 17: { QString _r = arvsury(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 18: { QString _r = depsurz(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 19: { QString _r = arvsurz(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 20: { QString _r = getNextUpdate(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 21: { QString _r = getFrequence(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 22: { QString _r = getSymbol(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; case 23: ItFogs(); break; case 24: { int _r = getPositionCiel(); if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break; case 25: setSymbol(); break; case 26: { QString _r = getRandomInteger(); if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break; default: ; } _id -= 27; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< Forecast*>(_v) = getCurrentForecast(); break; } _id -= 1; } else if (_c == QMetaObject::WriteProperty) { _id -= 1; } else if (_c == QMetaObject::ResetProperty) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 1; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 1; } #endif // QT_NO_PROPERTIES return _id; }
void test1(){ RecordData record; int i; int j; int r; char id[MAX_STRING]; /*乱数を初期化して発生させる*/ srand((unsigned int)time(NULL)); /*100個のレコードを挿入する*/ for (i = 0; i < TEST_SIZE; i++){ j = 0; r = getRandomInteger(MY_MIN, MY_MAX); switch (r){ case 1: sprintf(id, "i0000%c", '0' + r); strcpy(record.fieldData[j].name, "id"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, id); j++; strcpy(record.fieldData[j].name, "name"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Mickey"); j++; strcpy(record.fieldData[j].name, "age"); record.fieldData[j].dataType = TYPE_INTEGER; record.fieldData[j].intValue = 85; j++; strcpy(record.fieldData[j].name, "address"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Urayasu"); j++; record.numField = j; break; case 2: sprintf(id, "i0000%c", '0' + r); strcpy(record.fieldData[j].name, "id"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, id); j++; strcpy(record.fieldData[j].name, "name"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Minnie"); j++; strcpy(record.fieldData[j].name, "age"); record.fieldData[j].dataType = TYPE_INTEGER; record.fieldData[j].intValue = 85; j++; strcpy(record.fieldData[j].name, "address"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Urayasu"); j++; record.numField = j; break; case 3: sprintf(id, "i0000%c", '0' + r); strcpy(record.fieldData[j].name, "id"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, id); j++; strcpy(record.fieldData[j].name, "name"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Pooh"); j++; strcpy(record.fieldData[j].name, "age"); record.fieldData[j].dataType = TYPE_INTEGER; record.fieldData[j].intValue = 4; j++; strcpy(record.fieldData[j].name, "address"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Canada"); j++; record.numField = j; break; case 4: sprintf(id, "i0000%c", '0' + r); strcpy(record.fieldData[j].name, "id"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, id); j++; strcpy(record.fieldData[j].name, "name"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Pocahontas"); j++; strcpy(record.fieldData[j].name, "age"); record.fieldData[j].dataType = TYPE_INTEGER; record.fieldData[j].intValue = 16; j++; strcpy(record.fieldData[j].name, "address"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "America"); j++; record.numField = j; break; case 5: sprintf(id, "i0000%c", '0' + r); strcpy(record.fieldData[j].name, "id"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, id); j++; strcpy(record.fieldData[j].name, "name"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "Simba"); j++; strcpy(record.fieldData[j].name, "age"); record.fieldData[j].dataType = TYPE_INTEGER; record.fieldData[j].intValue = 20; j++; strcpy(record.fieldData[j].name, "address"); record.fieldData[j].dataType = TYPE_STRING; strcpy(record.fieldData[j].stringValue, "PrideLand"); j++; record.numField = j; break; } if (insertRecord("student", &record) != OK){ fprintf(stderr, "cannot insert record\n"); return; } } }
/* * test1 -- 読み出しのテスト */ void test1() { File *file[2]; char page[PAGE_SIZE]; int i; int fileNum, pageNum; printf("---------- test1 start ----------"); /* ファイルをープンする */ if ((file[0] = openFile(TEST_FILE1)) == NULL) { fprintf(stderr, "Cannot open file.\n"); exit(1); } if ((file[1] = openFile(TEST_FILE2)) == NULL) { fprintf(stderr, "Cannot open file.\n"); exit(1); } /* * (TEST_SIZE)回に渡ってランダムにページにアクセスし、 * 正しく稼働するかどうかを確認する */ for (i = 0; i < TEST_SIZE; i++) { /* アクセスするファイルをランダムに決定 */ fileNum = getRandomInteger(0, 1); /* アクセスするページをランダムに決定 */ pageNum = getRandomInteger(0, FILE_SIZE - 1); /* ページにアクセス */ printf("\nread file %d page %d\n", fileNum, pageNum); if (readPage(file[fileNum], pageNum, page) != OK) { fprintf(stderr, "Cannot read page (fileNum = %d, pageNum = %d).\n", fileNum, pageNum); exit(1); } /* バッファのリストの内容を出力 */ printBufferList(); } /* ファイルをクローズする */ if (closeFile(file[0]) != OK) { fprintf(stderr, "Cannot close file.\n"); exit(1); } if (closeFile(file[1]) != OK) { fprintf(stderr, "Cannot close file.\n"); exit(1); } printf(" -------- files closed ------- \n"); /* クローズした直後のバッファリストの状態を出力 */ printBufferList(); /* * 本格的にテストするためには、このあと何度かファイルをオープンし、 * 同じようなテストを繰り返すのが良い。 */ printf("---------- test1 end ----------\n\n"); }
/* * test2 -- 読み書きのテスト */ void test2() { File *file[2]; char page[PAGE_SIZE]; int i; int fileNum, pageNum; printf("---------- test2 start ----------\n"); /* ファイルをープンする */ if ((file[0] = openFile(TEST_FILE1)) == NULL) { fprintf(stderr, "Cannot open file.\n"); exit(1); } if ((file[1] = openFile(TEST_FILE2)) == NULL) { fprintf(stderr, "Cannot open file.\n"); exit(1); } printf(" -------- files opened ------- \n"); /* * (TEST_SIZE)回に渡ってページの読み書きを交互に行い、 * 正しく稼働するかどうかを確認する */ for (i = 0; i < TEST_SIZE; i++) { /* アクセスするファイルをランダムに決定 */ fileNum = getRandomInteger(0, 1); /* アクセスするページをランダムに決定 */ pageNum = getRandomInteger(0, FILE_SIZE - 1); /* ページの読み出し */ printf("\nread file %d page %d\n", fileNum, pageNum); if (readPage(file[fileNum], pageNum, page) != OK) { fprintf(stderr, "Cannot read page (fileNum = %d, pageNum = %d).\n", fileNum, pageNum); exit(1); } /* バッファのリストの内容を出力 */ printBufferList(); /* アクセスするファイルをランダムに決定 */ fileNum = getRandomInteger(0, 1); /* アクセスするページをランダムに決定 */ pageNum = getRandomInteger(0, FILE_SIZE - 1); /* ページに書き込む内容を作成 */ sprintf(page, "%c%c%c", '0' + fileNum, 'A' + i, '0' + pageNum); /* ページの書き込み */ printf("\nwrite file %d page %d -> %s\n", fileNum, pageNum, page); if (writePage(file[fileNum], pageNum, page) != OK) { fprintf(stderr, "Cannot write page (fileNum = %d, pageNum = %d).\n", fileNum, pageNum); exit(1); } /* バッファのリストの内容を出力 */ printBufferList(); } /* いったんファイルをクローズする */ if (closeFile(file[0]) != OK) { fprintf(stderr, "Cannot close file.\n"); exit(1); } if (closeFile(file[1]) != OK) { fprintf(stderr, "Cannot close file.\n"); exit(1); } printf(" -------- files closed ------- \n"); /* クローズした直後のバッファリストの状態を出力 */ printBufferList(); /* もう一度ファイルをオープンする */ if ((file[0] = openFile(TEST_FILE1)) == NULL) { fprintf(stderr, "Cannot open file.\n"); exit(1); } if ((file[1] = openFile(TEST_FILE2)) == NULL) { fprintf(stderr, "Cannot open file.\n"); exit(1); } printf(" -------- files opened ------- \n"); /* * もう一度、(TEST_SIZE)回に渡ってページの読み書きを交互に行い、 * 正しく稼働するかどうかを確認する */ for (i = 0; i < TEST_SIZE; i++) { /* アクセスするファイルをランダムに決定 */ fileNum = getRandomInteger(0, 1); /* アクセスするページをランダムに決定 */ pageNum = getRandomInteger(0, FILE_SIZE - 1); /* ページの読み出し */ printf("\nread file %d page %d\n", fileNum, pageNum); if (readPage(file[fileNum], pageNum, page) != OK) { fprintf(stderr, "Cannot read page (fileNum = %d, pageNum = %d).\n", fileNum, pageNum); exit(1); } /* バッファのリストの内容を出力 */ printBufferList(); /* アクセスするファイルをランダムに決定 */ fileNum = getRandomInteger(0, 1); /* アクセスするページをランダムに決定 */ pageNum = getRandomInteger(0, FILE_SIZE - 1); /* ページに書き込む内容を作成 */ sprintf(page, "%c%c%c", '0' + fileNum, 'A' + i, '0' + pageNum); /* ページの書き込み */ printf("\nwrite file %d page %d -> %s\n", fileNum, pageNum, page); if (writePage(file[fileNum], pageNum, page) != OK) { fprintf(stderr, "Cannot write page (fileNum = %d, pageNum = %d).\n", fileNum, pageNum); exit(1); } /* バッファのリストの内容を出力 */ printBufferList(); } /* ファイルのクローズ */ if (closeFile(file[0]) != OK) { fprintf(stderr, "Cannot close file.\n"); exit(1); } if (closeFile(file[1]) != OK) { fprintf(stderr, "Cannot close file.\n"); exit(1); } printf(" -------- files closed ------- \n"); /* クローズした直後のバッファリストの状態を出力 */ printBufferList(); printf("---------- test2 end ----------\n\n"); }
LOCAL bool parseDefinition(const char *s, Definition *definition, uint64 maxPosition) { StringTokenizer stringTokenizer; String t; String w; uint length; char buffer[1024]; assert(definition != NULL); t = String_newCString(s); String_initTokenizer(&stringTokenizer,t,STRING_BEGIN,":",NULL,FALSE); /* get type */ if (String_getNextToken(&stringTokenizer,&w,NULL)) { if (String_equalsCString(w,"m")) definition->type = DEFINITION_TYPE_MODIFY; else if (String_equalsCString(w,"r")) definition->type = DEFINITION_TYPE_RANDOMIZE; else if (String_equalsCString(w,"i")) definition->type = DEFINITION_TYPE_INSERT; else if (String_equalsCString(w,"d")) definition->type = DEFINITION_TYPE_DELETE; else { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid definition '%s': expected m,i,d!\n",s); return FALSE; } } else { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid definition '%s'!\n",s); return FALSE; } /* get position */ if (String_getNextToken(&stringTokenizer,&w,NULL)) { if (!String_scan(w,STRING_BEGIN,"%llu",&definition->position)) { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid position in definition '%s'!\n",s); return FALSE; } } else { definition->position = getRandomInteger64(maxPosition); } /* get value/length */ if (String_getNextToken(&stringTokenizer,&w,NULL)) { switch (definition->type) { case DEFINITION_TYPE_MODIFY: definition->value = String_new(); if (!String_scan(w,STRING_BEGIN,"%S",definition->value)) { String_delete(definition->value); String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid length in definition '%s'!\n",s); return FALSE; } break; case DEFINITION_TYPE_RANDOMIZE: if (!String_scan(w,STRING_BEGIN,"%u",&length)) { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid length in definition '%s'!\n",s); return FALSE; } if (length > sizeof(buffer)) length = sizeof(buffer); getRandomBuffer(buffer,length); definition->value = String_newBuffer(buffer,length); break; case DEFINITION_TYPE_INSERT: definition->value = String_new(); if (!String_scan(w,STRING_BEGIN,"%S",definition->value)) { String_delete(definition->value); String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid value in definition '%s'!\n",s); return FALSE; } break; case DEFINITION_TYPE_DELETE: if (!String_scan(w,STRING_BEGIN,"%u",&definition->length)) { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid length in definition '%s'!\n",s); return FALSE; } break; } } else { switch (definition->type) { case DEFINITION_TYPE_MODIFY: definition->value = String_newChar((char)getRandomByte(256)); break; case DEFINITION_TYPE_RANDOMIZE: getRandomBuffer(buffer,sizeof(buffer)); definition->value = String_newBuffer(buffer,getRandomInteger(sizeof(buffer))); break; case DEFINITION_TYPE_INSERT: definition->value = String_new(); if (!String_scan(w,STRING_BEGIN,"%S",&definition->value)) { String_delete(definition->value); String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid value in definition '%s'!\n",s); return FALSE; } break; case DEFINITION_TYPE_DELETE: if (!String_scan(w,STRING_BEGIN,"%u",&definition->length)) { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid length in definition '%s'!\n",s); return FALSE; } break; } } if (String_getNextToken(&stringTokenizer,&w,NULL)) { String_doneTokenizer(&stringTokenizer); String_delete(t); fprintf(stderr,"ERROR: Invalid definition '%s'!\n",s); return FALSE; } String_doneTokenizer(&stringTokenizer); String_delete(t); return TRUE; }