list<EcosiaWebResult> WINAPI EcosiaWebSearcher::simple_web_research(const string research) { string parameters; return do_search(research, parameters); }
list<EcosiaWebResult> WINAPI EcosiaWebSearcher::web_research(string research, ecosia_web_parameters params) { return do_search(research,params.get_string_parameter()); }
int main( int argc, char **argv ) { int i; char *uri = NULL; char *host = "localhost"; int port = -1; char *manager = NULL; struct berval passwd = { 0, NULL }; char *sbase = NULL; int scope = LDAP_SCOPE_SUBTREE; char *filter = NULL; char *attr = NULL; char *srchattrs[] = { "cn", "sn", NULL }; char **attrs = srchattrs; int loops = LOOPS; int outerloops = 1; int retries = RETRIES; int delay = 0; int force = 0; int chaserefs = 0; int noattrs = 0; int nobind = 0; tester_init( "slapd-search", TESTER_SEARCH ); /* by default, tolerate referrals and no such object */ tester_ignore_str2errlist( "REFERRAL,NO_SUCH_OBJECT" ); while ( ( i = getopt( argc, argv, "Aa:b:CD:f:FH:h:i:l:L:Np:r:Ss:t:T:w:" ) ) != EOF ) { switch ( i ) { case 'A': noattrs++; break; case 'C': chaserefs++; break; case 'H': /* the server uri */ uri = strdup( optarg ); break; case 'h': /* the servers host */ host = strdup( optarg ); break; case 'i': tester_ignore_str2errlist( optarg ); break; case 'N': nobind++; break; case 'p': /* the servers port */ if ( lutil_atoi( &port, optarg ) != 0 ) { usage( argv[0], i ); } break; case 'D': /* the servers manager */ manager = strdup( optarg ); break; case 'w': /* the server managers password */ passwd.bv_val = strdup( optarg ); passwd.bv_len = strlen( optarg ); memset( optarg, '*', passwd.bv_len ); break; case 'a': attr = strdup( optarg ); break; case 'b': /* file with search base */ sbase = strdup( optarg ); break; case 'f': /* the search request */ filter = strdup( optarg ); break; case 'F': force++; break; case 'l': /* number of loops */ if ( lutil_atoi( &loops, optarg ) != 0 ) { usage( argv[0], i ); } break; case 'L': /* number of loops */ if ( lutil_atoi( &outerloops, optarg ) != 0 ) { usage( argv[0], i ); } break; case 'r': /* number of retries */ if ( lutil_atoi( &retries, optarg ) != 0 ) { usage( argv[0], i ); } break; case 't': /* delay in seconds */ if ( lutil_atoi( &delay, optarg ) != 0 ) { usage( argv[0], i ); } break; case 'T': attrs = ldap_str2charray( optarg, "," ); if ( attrs == NULL ) { usage( argv[0], i ); } break; case 'S': swamp++; break; case 's': scope = ldap_pvt_str2scope( optarg ); if ( scope == -1 ) { usage( argv[0], i ); } break; default: usage( argv[0], i ); break; } } if (( sbase == NULL ) || ( filter == NULL ) || ( port == -1 && uri == NULL )) usage( argv[0], '\0' ); if ( *filter == '\0' ) { fprintf( stderr, "%s: invalid EMPTY search filter.\n", argv[0] ); exit( EXIT_FAILURE ); } if ( argv[optind] != NULL ) { attrs = &argv[optind]; } uri = tester_uri( uri, host, port ); for ( i = 0; i < outerloops; i++ ) { if ( attr != NULL ) { do_random( uri, manager, &passwd, sbase, scope, filter, attr, attrs, noattrs, nobind, loops, retries, delay, force, chaserefs ); } else { do_search( uri, manager, &passwd, sbase, scope, filter, NULL, attrs, noattrs, nobind, loops, retries, delay, force, chaserefs ); } } exit( EXIT_SUCCESS ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); m_resizeColumns = true; //停止显示结果,初始值false m_stop_ShowResult = false; this->GotResultFileNum = 0; //状态栏--label msgLabel = new QLabel(this); msgLabel->setMinimumSize(msgLabel->sizeHint()); msgLabel->setStyleSheet("background: transparent"); // msg2Label = new QLabel(this); msg2Label->setMinimumSize(msgLabel->sizeHint()); msg2Label->setStyleSheet("background: transparent"); //状态栏--progressBar msgProgressBar = new QProgressBar(this); msgProgressBar->setMinimumSize(msgProgressBar->sizeHint()); msgProgressBar->setStyleSheet("background: transparent"); msgProgressBar->setHidden(true); msgProgressBar->setRange(0, 400); msgProgressBar->setTextVisible(false); msgPBCnt = 0; //状态栏 ui->statusBar->setStyleSheet("QStatusBar::item{border:0px}"); ui->statusBar->addWidget(msgProgressBar); ui->statusBar->addWidget(msgLabel); ui->statusBar->addWidget(msg2Label); // QCompleter *completer = new QCompleter(this); QFileSystemModel *fsModel = new QFileSystemModel(completer); fsModel->setRootPath(""); completer->setModel(fsModel); completer->setCaseSensitivity(Qt::CaseInsensitive); ui->comboBox_Dir->setCompleter(completer); //设置右下角小图标 this->setup_trayicon(); //设置tableView按钮 this->setup_tabmenu(ui->tableView_result); /***************各个组件背景设置 *****************/ ui->centralWidget->setStyleSheet("background-image:url(':/img/frame-mid.png')"); ui->statusBar->setStyleSheet("background-image:url(':/img/frame-mid.png')"); ui->toolButtonSearchST->setStyleSheet("QToolButton:!hover{background: transparent;}" "QToolButton:hover{background-image: url(':/img/ico-hover-bg.png');border:0px;}" ); ui->toolButtonGetDir->setStyleSheet("QToolButton:!hover{background: transparent;}" "QToolButton:hover{background-image: url(':/img/ico-hover-bg.png');border:0px;}" ); ui->toolButtonHelp->setStyleSheet("QToolButton:!hover{background: transparent;}" "QToolButton:hover{background-image: url(':/img/ico-hover-bg.png');border:0px;}" ); /**************************************************/ connect(ui->toolButtonSearchST, SIGNAL(clicked()), this, SLOT(do_search())); connect(ui->toolButtonHelp, SIGNAL(clicked()), this, SLOT(do_help())); connect(ui->toolButtonGetDir, SIGNAL(clicked()), this, SLOT(do_brower_targetdir())); find = new searchThread(this); connect(find, SIGNAL(finished()), this,SLOT(do_resume_searchFileIcon())); connect(find, SIGNAL(PushGotFiles(QString,QList<TFileInfo>)), this, SLOT(do_GetResultFileInfo(QString,QList<TFileInfo>) )); /********************设置软件信息**********************/ QCoreApplication::setOrganizationName(QObject::tr(APP_NAME)); QCoreApplication::setApplicationName(QObject::tr(APP_NAME)); QCoreApplication::setApplicationVersion(tr("V1.2")); //注册元类 qRegisterMetaType< QList<TFileInfo> >("QList<TFileInfo>"); // this->defaultDir = "."; // QTimer *idleTimer = new QTimer(this); connect(idleTimer, SIGNAL(timeout()), this, SLOT(do_ShowResultFileInfo())); idleTimer->start(0); // show_watcher.addPath("shownow.cmd"); connect(&show_watcher, SIGNAL(fileChanged(QString)), this, SLOT(do_show())); }
int main(int argc, char *argv[]) { ps_decoder_t *ps; dict_t *dict; dict2pid_t *d2p; acmod_t *acmod; ps_alignment_t *al; ps_alignment_iter_t *itor; ps_search_t *search; cmd_ln_t *config; int i; config = cmd_ln_init(NULL, ps_args(), FALSE, "-hmm", MODELDIR "/en-us/en-us", "-dict", MODELDIR "/en-us/cmudict-en-us.dict", "-input_endian", "little", "-samprate", "16000", NULL); TEST_ASSERT(ps = ps_init(config)); dict = ps->dict; d2p = ps->d2p; acmod = ps->acmod; al = ps_alignment_init(d2p); TEST_EQUAL(1, ps_alignment_add_word(al, dict_wordid(dict, "<s>"), 0)); TEST_EQUAL(2, ps_alignment_add_word(al, dict_wordid(dict, "go"), 0)); TEST_EQUAL(3, ps_alignment_add_word(al, dict_wordid(dict, "forward"), 0)); TEST_EQUAL(4, ps_alignment_add_word(al, dict_wordid(dict, "ten"), 0)); TEST_EQUAL(5, ps_alignment_add_word(al, dict_wordid(dict, "meters"), 0)); TEST_EQUAL(6, ps_alignment_add_word(al, dict_wordid(dict, "</s>"), 0)); TEST_EQUAL(0, ps_alignment_populate(al)); TEST_ASSERT(search = state_align_search_init(config, acmod, al)); for (i = 0; i < 5; ++i) do_search(search, acmod); itor = ps_alignment_words(al); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 0); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 3); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 3); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 12); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 15); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 53); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 68); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 36); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 104); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 59); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 163); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 51); itor = ps_alignment_iter_next(itor); TEST_EQUAL(itor, NULL); ps_search_free(search); ps_alignment_free(al); ps_free(ps); cmd_ln_free_r(config); return 0; }
long search(struct old_xfer_req *req, struct nrts_chn *chn, double target, long ldef, long rdef, char *buffer) { struct span *span, dl; long oldest, yngest; static char *fid = "search"; oldest = chn->hdr.oldest; yngest = chn->hdr.yngest; util_log(3, "`%s' search for time %s", chn->name, util_dttostr(target, 0)); util_log(3, "`%s' oldest = %ld, youngest = %ld", chn->name, oldest, yngest); /* First, insure the desired time falls inside the disk buffer */ span = get_span(req, oldest, chn, buffer); dl.beg = span->beg; span = get_span(req, yngest, chn, buffer); dl.end = span->end; sprintf(buffer, "`%s' spans %s ", chn->name, util_dttostr(dl.beg, 0)); util_log(3, "%s to %s", buffer, util_dttostr(dl.end, 0)); if (target < dl.beg) { util_log(3, "`%s' target too old, return %d", chn->name, ldef); return ldef; } if (target > dl.end) { util_log(3, "`%s' target too young, return %d", chn->name, rdef); return rdef; } /* It must be available, so search for it */ /* First case, no wraparound at end of disk buffer */ if (oldest < yngest) { util_log(3, "`%s' no disk loop wrap around"); util_log(3, "`%s' search from oldest (%ld) to youngest (%ld)", chn->name, oldest, yngest ); return do_search(req, target, chn, oldest, yngest, buffer); } /* Second case, data wrap around end of disk buffer */ span = get_span(req, (long) 0, chn, buffer); span->beg -= chn->sint; /* will allow for one sample slop */ if (target > span->beg && target <= dl.end) { util_log(3, "`%s' target is in later half of disk buffer", chn->name); util_log(3, "`%s' search from 0 to youngest (%ld)", chn->name, yngest ); return do_search(req, target, chn, 0, yngest, buffer); } else { span = get_span(req, (long) chn->hdr.nrec - 1, chn, buffer); if (target > dl.beg && target <= span->end) { util_log(3, "`%s' search from oldest (%ld) to eof (%ld)", chn->name, oldest, chn->hdr.nrec - 1 ); return do_search(req,target,chn,oldest,chn->hdr.nrec - 1,buffer); } else { util_log(1, "HELP! I don't know what to do!"); util_log(1, "target = %s", util_dttostr(target, 0)); util_log(1, "dl beg = %s", util_dttostr(dl.beg, 0)); util_log(1, "dl end = %s", util_dttostr(dl.end, 0)); util_log(1, "end of dl file time = %s", util_dttostr(span->end, 0)); ack(0); die(1); } } util_log(1, "%s: FATAL PROGRAM LOGIC ERROR!", fid); util_log(1, "%s: target = %s", fid, util_dttostr(target, 0)); util_log(1, "%s: dl beg = %s", fid, util_dttostr(dl.beg, 0)); util_log(1, "%s: dl end = %s", fid, util_dttostr(dl.end, 0)); }
int do_combined_search (void) { message_t *M; int prune_neg = 0, prune_pos = 0, first_neg = -0x7fffffff, first_pos = 0x7fffffff; ResL = 0; prefetch_search_lists(); if (UH) { for (M = UH->msgs; M; M = M->prev) { if (M->message_id < 0 && M->message_id > first_neg) { first_neg = M->message_id; } if (M->message_id > 0 && M->message_id < first_pos) { first_pos = M->message_id; } if (search_in_msg (M->hashes, M->hc)) { ResBuff[ResL++] = M->message_id; if (ResL >= MAX_INTERMEDIATE_SIZE) { return ResL; } } } prune_pos = UH->pos_to; prune_neg = UH->neg_to; if (verbosity > 0) { fprintf (stderr, "recent_search(): %d messages found\n", ResL); } } ResR = ResL; ResL = 0; if (cur_user > 0) { do_search (prune_pos, prune_neg, first_pos, first_neg); } ResL += ResR; Res = ResBuff; if (UH && UH->delmsg_cnt) { int *A = UH->delmsg_list, *B = A + UH->delmsg_cnt - 1; int i, j = 0, t; if (verbosity > 0) { fprintf (stderr, "user has %d deleted messages %d %d %d ..., pruning\n", UH->delmsg_cnt, A[0], A[1], A[2]); } assert (A); for (i = 0; i < ResL; i++) { t = ResBuff[i]; if (t < 0) { while (A <= B && *A < t) { A++; } if (A <= B && *A == t) { A++; } else { ResBuff[j++] = t; } } else { while (A <= B && *B > t) { B--; } if (A <= B && *B == t) { B--; } else { ResBuff[j++] = t; } } } if (verbosity > 0) { fprintf (stderr, "pruned: resulting list contains %d, original %d\n", j, ResL); } ResL = j; } return ResL; }
int main(int argc, char *argv[]) { struct sigaction sa; bdaddr_t bdaddr = { 0 }; int ctl, csk, isk, debug, legacy, remote; if (argc > 3) { debug = atoi(argv[1]); legacy = atoi(argv[2]); remote = atoi(argv[3]); } else { std::cerr << argv[0] << " requires 'sixad'. Please run sixad instead" << std::endl; return 1; } #if 0 // Enable all bluetooth adapters int hci_ctl; if ((hci_ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) >= 0) { for (int i=0; i < 4; i++) { di.dev_id = i; if (ioctl(hci_ctl, HCIGETDEVINFO, (void *) &di) == 0) { if (hci_test_bit(HCI_RAW, &di.flags) && !bacmp(&di.bdaddr, BDADDR_ANY)) { int dd = hci_open_dev(di.dev_id); hci_read_bd_addr(dd, &di.bdaddr, 1000); hci_close_dev(dd); } } cmd_reset(hci_ctl, di.dev_id); } } #endif open_log("sixad-bin"); syslog(LOG_INFO, "started"); ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HIDP); if (ctl < 0) { syslog(LOG_ERR, "Can't open HIDP control socket"); close(ctl); return 1; } if (remote) { // BD Remote only syslog(LOG_INFO, "BD Remote mode active, hold Enter+Start on your remote now"); while (!io_canceled()) { do_search(ctl, &bdaddr, debug); sleep(2); } } else { // Normal behaviour csk = l2cap_listen(&bdaddr, L2CAP_PSM_HIDP_CTRL, L2CAP_LM_MASTER, 10); if (csk < 0) { syslog(LOG_ERR, "Can't listen on HID control channel"); close(csk); close(ctl); return 1; } isk = l2cap_listen(&bdaddr, L2CAP_PSM_HIDP_INTR, L2CAP_LM_MASTER, 10); if (isk < 0) { syslog(LOG_ERR, "Can't listen on HID interrupt channel"); close(isk); close(csk); close(ctl); return 1; } memset(&sa, 0, sizeof(sa)); sa.sa_flags = SA_NOCLDSTOP; sa.sa_handler = sig_term; sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); sa.sa_handler = sig_hup; sigaction(SIGHUP, &sa, NULL); sa.sa_handler = SIG_IGN; sigaction(SIGCHLD, &sa, NULL); sigaction(SIGPIPE, &sa, NULL); syslog(LOG_INFO, "sixad started, press the PS button now"); hid_server(ctl, csk, isk, debug, legacy); close(isk); close(csk); } close(ctl); syslog(LOG_INFO, "Done"); return 0; }
void do_search(std::size_t k, ResultCallback callback, SearchHeuristic heuristic) { if (toroid_m.right_of(&toroid_m.header_m) == &toroid_m.header_m) { ++solutions_m; #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "<solved/>" << std::endl; #endif for (std::size_t i(0); i < k; ++i) callback(toroid_m.row_index_of(output_m[i]), i + 1 == k); return; } std::size_t next_k(k + 1); toroid_header_t* c(heuristic(toroid_m)); #if ADOBE_DLX_VERBOSE ++tab_count_m; std::cout << adobe::indents(tab_count_m) << "<c" << toroid_m.column_index_of(toroid_m.down_of(c)) << ">" << std::endl; #endif toroid_m.cover_column(c); // branch on each node in this column for (toroid_node_t* r(toroid_m.down_of(c)); r != c; r = toroid_m.down_of(r)) { #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "<r" << toroid_m.row_index_of(r) << ">" << std::endl; #endif output_m[k] = r; // cover or purify each node on the same row as the node we're branching on for (toroid_node_t* j(toroid_m.right_of(r)); j != r; j = toroid_m.right_of(j)) { if (j->color_m == 0) { #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "<c" << toroid_m.column_index_of(j) << ">" << std::endl; #endif toroid_m.cover_column(toroid_m.column_of(j)); } else if (j->color_m > 0) { #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "<p" << toroid_m.column_index_of(j) << ">" << std::endl; #endif toroid_m.purify(j); } } #if ADOBE_DLX_VERBOSE // std::cout << *this << std::endl; #endif do_search(next_k, callback, heuristic); if (solutions_m >= max_solutions_m) return; r = output_m[k]; c = toroid_m.column_of(r); // undo the cover/purify for (toroid_node_t* j(toroid_m.left_of(r)); j != r; j = toroid_m.left_of(j)) { if (j->color_m == 0) { #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "</c" << toroid_m.column_index_of(j) << ">" << std::endl; #endif toroid_m.uncover_column(toroid_m.column_of(j)); } else if (j->color_m > 0) { #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "</p" << toroid_m.column_index_of(j) << ">" << std::endl; #endif toroid_m.unpurify(j); } } #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "</r" << toroid_m.row_index_of(r) << ">" << std::endl; #endif } toroid_m.uncover_column(c); #if ADOBE_DLX_VERBOSE std::cout << adobe::indents(tab_count_m) << "</c" << toroid_m.column_index_of(toroid_m.down_of(c)) << ">" << std::endl; --tab_count_m; #endif };
void Searching::OnTurn() { do_search(); //mdk: we search even if asleep! }
int32_t main(int32_t argc, char *argv[]) { int32_t rankID = 0, nRanks = 1; char rankName[MAX_STRING_LENGTH]; gethostname(rankName, MAX_STRING_LENGTH); MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rankID); MPI_Comm_size(MPI_COMM_WORLD, &nRanks); char *target_path = argv[1], *target = NULL; int64_t target_length = 0; target_length = get_filesize(target_path); if(target_length < 0) { printf("\nError: Cannot read target file [ %s ]\n", target_path); MPI_Finalize(); exit(-1); } if(rankID == 0) { printf("--------------------------------------------------\n"); printf("- Read target: [ %s ]\n", target_path); target = (char*)malloc(sizeof(char)*target_length); double read_time = 0; read_time -= MPI_Wtime(); read_targetfile(target, target_length, target_path); read_time += MPI_Wtime(); printf("- Target length: %ld (read time: %lf secs)\n", target_length, read_time); printf("--------------------------------------------------\n"); } char *pattern = argv[2]; int64_t pattern_length = 0; if(pattern == NULL) { printf("\nError: Cannot read pattern [ %s ]\n", pattern); free(target); MPI_Finalize(); exit(-1); } pattern_length = strlen(pattern); if(rankID == 0) { printf("- Pattern: [ %s ]\n", pattern); printf("- Pattern length: %ld\n", pattern_length); printf("--------------------------------------------------\n"); } int32_t* BCS = (int32_t*)malloc(ALPHABET_LEN * sizeof(int32_t)); int32_t* GSS = (int32_t*)malloc(pattern_length * sizeof(int32_t));; make_BCS(BCS, pattern, pattern_length); make_GSS(GSS, pattern, pattern_length); int64_t found_count = 0; double search_time = 0; if(rankID == 0) { search_time -= MPI_Wtime(); } // DO NOT EDIT UPPER CODE // //==============================================================================================================// int64_t mpi_found_count = 0; char* chunk = NULL; if(argv[3] == NULL) { printf("\nError: Check chunk size [ %s ]\n", argv[3]); free(target); free(BCS); free(GSS); MPI_Finalize(); exit(-1); } if(rankID == 0) printf("\ttarget_length = %ld\n", target_length); int64_t nChunksPerRank = atoi(argv[3]); //각 rank에 몇개의 문자열 덩어리를 줄것인가 결정 int64_t nTotalChunks = (nRanks-1) * nChunksPerRank; //rank 0은 검사하지않으므로 nRanks - 1 //문자열은 총 nTotalChunks개로 쪼개진다. if(rankID == 0) printf("\tnTotalChunks = %ld\n", nTotalChunks); int64_t overlap_length = (pattern_length - 1) * (nTotalChunks - 1); //쪼개진 덩어리 중 마지막 1개는 겹치는 부분이 없으므로 nTotalChunks - 1 //문자열은 최악의 경우 pattern의 첫글자가 하나의 코어 //나머지 글자가 하나의 코어에 분배되는 경우이므로 pattern_length - 1 if(rankID == 0) printf("\toverlap_length = %ld\n", overlap_length); int64_t quotient = (target_length + overlap_length) / nTotalChunks; //각 코어당 최악의 경우를 방지하기 위해 덩어리마다 pattern_length - 1을 추가 //즉 target_length + overlap_length가 되고 이를 정해진 nChunksPerRank씩 //각 코어에 분배하기 위하여 nTotalChunks로 나누어 준다. if(rankID == 0) printf("\tquotient = %ld\n", quotient); int64_t remainder = (target_length + overlap_length) - (quotient * nTotalChunks); //나누는 경우에 나누어 떨어지지 않는 경우가 있으므로 나머지를 따로 처리해준다. if(rankID == 0) printf("\tremainder = %ld\n\n", remainder); int64_t chunkID = 0; int64_t* chunk_length = (int64_t*)malloc((nTotalChunks+1)*sizeof(int64_t)); int64_t* chunk_start_idx = (int64_t*)malloc((nTotalChunks+1)*sizeof(int64_t)); //remainder의 경우를 위해 nTotalChunks에 + 1 을 한다. int64_t i; for(i=0; i<nTotalChunks; i++) chunk_length[i] = quotient; for(i=0; i<remainder; i++) chunk_length[i] += 1; chunk_start_idx[0] = 0; for(i=1; i<nTotalChunks; i++) chunk_start_idx[i] = chunk_start_idx[i-1] + chunk_length[i-1] - (pattern_length-1); //마지막에 - (pattern_length - 1) 을 해줌으로서 첫 번째 chunk를 제외하고 //모든 chunk는 이전 chunk의 마지막 문자열의 -4번째 포인터를 chunk_start_idx로 가진다. //따라서 첫번째 chunk를 제외한 모든 chunk 이전 chunk의 마지막 4글자를 무조건 포함한다. chunk_start_idx[nTotalChunks] = 0; chunk_length[nTotalChunks] = 0; //chunk가 끝났다는 것을 표시하기 위해 nTotalChunk + 1번째 chunk의 //start idx 와 length는 모두 0으로 지정한다. MPI_Request MPI_req[2]; MPI_Status MPI_stat[2]; int32_t MPI_tag = 0; int32_t request_rankID = -1; if(rankID == 0) { int64_t nFinishRanks = 0; while(nFinishRanks < nRanks-1) { MPI_Recv(&request_rankID, 1, MPI_INT32_T, MPI_ANY_SOURCE, MPI_tag, MPI_COMM_WORLD, &MPI_stat[0]); //Rank 0 은 다른 Rank들의 송신을 기다린다. //MPI_stat[0]로 다른 Rank가 이제 일을 시작한다는 것을 확인한다. MPI_Isend(&target[chunk_start_idx[chunkID]], chunk_length[chunkID], MPI_CHAR, request_rankID, chunkID, MPI_COMM_WORLD, &MPI_req[1]); //위에서 각 rank가 할당 받는 chunk_length의 길이를 구했었다. //chunkID를 tag로 받는 것에 주의할 것 //파일 전체를 읽어서(target) rank 마다 검사할 위치의 시작점을 정해주고 다시 해당 rank에 전송한다. //파일 전체 위치에서 chunk_length[chunkID]길이 만큼만 보낸다는 것을 주의할 것 //req[1]을 보냄으로서 검사를 시작해라는 요청을 보낸다. printf("\trequest_rankID = %d\n", request_rankID); printf("\tchunkID = %ld\n", chunkID); printf("\tchunk_start_idx[chunkID] = %ld\n", chunk_start_idx[chunkID]); printf("\ttarget[chunk_start_idx[chunkID] = %c\n\n", target[chunk_start_idx[chunkID]]); if(chunkID < nTotalChunks) chunkID++; else nFinishRanks++; } } else { chunk = (char *)malloc(chunk_length[0] * sizeof(char)); //chunk 는 문자열임을 기억한다. int64_t chunk_found_count = 0; int64_t call_count = 0; while(chunkID < nTotalChunks) { //선언될 때 chunkID = 0인 상태이다. MPI_Isend(&rankID, 1, MPI_INT32_T, 0, MPI_tag, MPI_COMM_WORLD, &MPI_req[0]); //Rank 0에게 현재 어떤 Rank가 일을 하는지 알려준다. //MPI_requ[0]은 검사를 준비하는 상태라는 의미이다. MPI_Recv(chunk, chunk_length[0], MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &MPI_stat[1]); //각 rank가 부여받은 chunk 사이즈의 크기는 균일하게 나눈 뒤 나머지를 각 chunk에 1씩 더해 주었으므로 //받는 크기는 chunk_length[0]으로 고정한다. chunkID = MPI_stat[1].MPI_TAG; printf("\trank = %d chunk = %s chunkID = %d\n", rankID, chunk, chunkID); if(chunkID < nTotalChunks) { chunk_found_count = do_search(chunk, target_length, 0, chunk_length[chunkID], pattern, pattern_length, BCS, GSS); if(found_count < 0) { free(chunk); free(BCS); free(GSS); free(chunk_length); free(chunk_start_idx); MPI_Finalize(); exit(-1); } mpi_found_count += chunk_found_count; call_count++; } } printf("- [%02d: %s] call_count: %ld\n", rankID, rankName, call_count); } MPI_Reduce(&mpi_found_count, &found_count, 1, MPI_INT64_T, MPI_SUM, 0, MPI_COMM_WORLD); //Rank 0 의 mpi_found_count 변수에 각 프로세서들의 mpi_found_count값을 더해서 모은다. free(chunk); free(chunk_length); free(chunk_start_idx); //==============================================================================================================// // DO NOT EDIT LOWER CODE // if(rankID == 0) { search_time += MPI_Wtime(); printf("- Found_count: %ld\n", found_count); printf("--------------------------------------------------\n"); printf("- Time: %lf secs\n", search_time); printf("--------------------------------------------------\n"); } free(target); free(BCS); free(GSS); MPI_Finalize(); return 0; }
static void gui_button_cb_search (Manual me, GuiButtonEvent /* event */) { do_search (me); }
void test() { int ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); int ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); int id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); int ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); int ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); int ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sj = sizeof(ij)/sizeof(ij[0]); int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; const unsigned sk = sizeof(ik)/sizeof(ik[0]); do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); }
static void gui_button_cb_search (I, GuiButtonEvent event) { (void) event; iam (Manual); do_search (me); }
/* * routine to do N, _, E_ searches: search, if search fails, then get * next page and continue * * arg - 'n', '_', or 'e' to define which search */ int do_nsearch(char arg) { int scount; /* search count */ /* read the search string */ build_string(&sbuf); /* count must be >0 */ if ((scount = get_value(1)) <= 0) { ERROR(E_ISA); } /* start search at dot */ set_pointer(dot, &aa); /* make it unbounded */ esp->flag2 = locb = 0; /* search until found */ while (scount > 0) { /* search forwards */ if (!do_search(1)) { /* if search fails... */ /* if no input, quit */ if (infile->eofsw || !infile->fd) { break; } if (arg == 'n') { set_pointer(0, &aa); /* write file if 'n' */ write_file(&aa, z, ctrl_e); /* * Not 'n': if _, and an output file, * and data to lose, error */ } else if ((arg == '_') && (outfile->fd) && (z) && (ed_val & ED_YPROT)) { ERROR(E_YCA); } /* clear buffer */ buff_mod = dot = z = 0; set_pointer(0, &aa); /* read next page */ read_file(&aa, &z, (ed_val & ED_EXPMEM ? -1 : 0) ); /* search next page from beginning */ set_pointer(0, &aa); } else { /* search successful: one fewer to look for */ --scount; } } /* use end_search to clean up */ return( end_search( (scount == 0) ? -1 : 0) ); }
static void gui_cb_search (GUI_ARGS) { GUI_IAM (Manual); do_search (me); }
else ok = leT; } free ((char *) ms); return ok; } DEFUN_ARGS ("search-forward", search_forward, STR_ARG (pattern)) /*+ Search forward from point for the user specified text. +*/ { STR_INIT (pattern); ok = do_search (true, false, pattern); STR_FREE (pattern); } END_DEFUN DEFUN_ARGS ("search-backward", search_backward, STR_ARG (pattern)) /*+ Search backward from point for the user specified text. +*/ { STR_INIT (pattern); ok = do_search (false, false, pattern); STR_FREE (pattern); } END_DEFUN
int cmd_find ( int argc, char ** argv, mpd_Connection * conn ) { return do_search(argc, argv, conn, 1); }
int do_more(FILE *fpout,int line_number, int pause_after, const char *lines[]) { int code; #define MORE_HELP \ "More? f)orward b)ackward d)own e)nd q)uit r)efresh t)op u)p \\/)search\n\r" (void)fputs(MORE_HELP,fpout); (void)fflush(fpout); /* make screen up-to-date */ for (;;) /* loop until a valid input code is received */ { switch (code = kbcode()) { case KEYBOARD_PGUP: /* backward screen */ return (MAX(0,line_number + 1 - 2*pause_after)); case KEYBOARD_DOWN: /* go down 1 line (scroll up 1 line) */ return (line_number + 2 - pause_after); case KEYBOARD_END: /* end */ return (LAST_SCREEN_LINE); case KEYBOARD_PGDN: /* forward screen */ return (line_number + 1); case KEYBOARD_HELP: (void)fputs(MORE_HELP,fpout); break; case KEYBOARD_EOF: case KEYBOARD_QUIT: return (EOF); case KEYBOARD_AGAIN: /* refresh */ return (MAX(0,line_number + 1 - pause_after)); case KEYBOARD_HOME: /* top */ return (0); case KEYBOARD_UP: /* go up 1 line (scroll down 1 line) */ return (line_number + 0 - pause_after); case KEYBOARD_DOWN_PARAGRAPH: /* Move down so that paragraph following the paragraph of the current top-of-screen line is at top-of-screen */ line_number++; if (line_number >= (screen_lines - 2)) line_number -= (screen_lines - 2); while ((lines[line_number] != (char*)NULL) && (lines[line_number][0] != '\n')) line_number++; return ((lines[line_number] == (char*)NULL) ? LAST_SCREEN_LINE : line_number + 1); case KEYBOARD_UP_PARAGRAPH: /* Move up so that paragraph of current top-of-screen line has its first line at top of screen. */ line_number--; if (line_number >= (screen_lines - 2)) line_number -= (screen_lines - 2); while ((line_number >= 0) && (lines[line_number] != (char*)NULL) && (lines[line_number][0] != '\n')) line_number--; return (line_number + 1); case KEYBOARD_SEARCH_BACKWARD: case KEYBOARD_SEARCH_FORWARD: return (do_search(fpout,code,line_number,pause_after,lines)); case KEYBOARD_UNKNOWN: default: /* anything else produces */ beep(fpout); /* an error beep */ break; } /* end switch (c...) */ } /* end for (;;) */ }
int main(int argc, char **argv) { int opt; char *alt_config = NULL; int r = IMAP_NOTFOUND; strarray_t mboxnames = STRARRAY_INITIALIZER; const char *query = NULL; int background = 1; const char *channel = "squatter"; const char *synclogfile = NULL; int init_flags = CYRUSINIT_PERROR; int multi_folder = 0; int user_mode = 0; int compact_flags = 0; const char *fromfile = NULL; strarray_t *srctiers = NULL; const char *desttier = NULL; enum { UNKNOWN, INDEXER, INDEXFROM, SEARCH, ROLLING, SYNCLOG, START_DAEMON, STOP_DAEMON, RUN_DAEMON, COMPACT } mode = UNKNOWN; if ((geteuid()) == 0 && (become_cyrus(/*is_master*/0) != 0)) { fatal("must run as the Cyrus user", EC_USAGE); } setbuf(stdout, NULL); while ((opt = getopt(argc, argv, "C:I:N:RXT:S:Fc:de:f:mn:riavz:t:ouh")) != EOF) { switch (opt) { case 'C': /* alt config file */ alt_config = optarg; break; case 'F': compact_flags |= SEARCH_COMPACT_FILTER; break; case 'X': compact_flags |= SEARCH_COMPACT_REINDEX; break; case 'N': name_starts_from = optarg; break; case 'I': /* indexer, using specified mbox/uids in file */ if (mode != UNKNOWN && mode != INDEXFROM) usage(argv[0]); fromfile = optarg; mode = INDEXFROM; break; case 'R': /* rolling indexer */ if (mode != UNKNOWN) usage(argv[0]); mode = ROLLING; incremental_mode = 1; /* always incremental if rolling */ batch_mode = 1; break; case 'S': /* sleep time in seconds */ sleepmicroseconds = (atof(optarg) * 1000000); break; case 'T': /* temporary root directory for search */ temp_root_dir = optarg; break; /* This option is deliberately undocumented, for testing only */ case 'c': /* daemon control mode */ if (mode != UNKNOWN) usage(argv[0]); if (!strcmp(optarg, "start")) mode = START_DAEMON; else if (!strcmp(optarg, "stop")) mode = STOP_DAEMON; else if (!strcmp(optarg, "run")) mode = RUN_DAEMON; else usage(argv[0]); break; case 'd': /* foreground (with -R) */ background = 0; break; /* This option is deliberately undocumented, for testing only */ case 'e': /* add a search term */ if (mode != UNKNOWN && mode != SEARCH) usage(argv[0]); query = optarg; mode = SEARCH; break; case 'f': /* alternate synclogfile used in SYNCLOG mode */ synclogfile = optarg; mode = SYNCLOG; break; /* This option is deliberately undocumented, for testing only */ case 'm': /* multi-folder in SEARCH mode */ if (mode != UNKNOWN && mode != SEARCH) usage(argv[0]); multi_folder = 1; mode = SEARCH; break; case 'n': /* sync channel name (with -R) */ channel = optarg; break; case 'o': /* copy one DB rather than compressing */ compact_flags |= SEARCH_COMPACT_COPYONE; break; case 'v': /* verbose */ verbose++; break; case 'r': /* recurse */ if (mode != UNKNOWN && mode != INDEXER) usage(argv[0]); recursive_flag = 1; mode = INDEXER; break; case 'i': /* incremental mode */ incremental_mode = 1; break; case 'a': /* use /squat annotation */ if (mode != UNKNOWN && mode != INDEXER) usage(argv[0]); annotation_flag = 1; mode = INDEXER; break; case 'z': if (mode != UNKNOWN && mode != COMPACT) usage(argv[0]); desttier = optarg; mode = COMPACT; break; case 't': if (mode != UNKNOWN && mode != COMPACT) usage(argv[0]); srctiers = strarray_split(optarg, ",", 0); mode = COMPACT; break; case 'u': user_mode = 1; break; case 'h': usage("squatter"); default: usage("squatter"); } } compact_flags |= SEARCH_VERBOSE(verbose); if (mode == UNKNOWN) mode = INDEXER; /* fork and close fds if required */ if (mode == ROLLING && background) { become_daemon(); init_flags &= ~CYRUSINIT_PERROR; } if (mode == COMPACT && (!desttier || !srctiers)) { /* need both src and dest for compact */ usage("squatter"); } cyrus_init(alt_config, "squatter", init_flags, CONFIG_NEED_PARTITION_DATA); /* Set namespace -- force standard (internal) */ if ((r = mboxname_init_namespace(&squat_namespace, 1)) != 0) { fatal(error_message(r), EC_CONFIG); } annotate_init(NULL, NULL); annotatemore_open(); mboxlist_init(0); mboxlist_open(NULL); if (mode == ROLLING || mode == SYNCLOG) { signals_set_shutdown(&shut_down); signals_add_handlers(0); } switch (mode) { case UNKNOWN: break; case INDEXER: /* -r requires at least one mailbox */ if (recursive_flag && optind == argc) usage(argv[0]); expand_mboxnames(&mboxnames, argc-optind, (const char **)argv+optind, user_mode); syslog(LOG_NOTICE, "indexing mailboxes"); r = do_indexer(&mboxnames); syslog(LOG_NOTICE, "done indexing mailboxes"); break; case INDEXFROM: syslog(LOG_NOTICE, "indexing messages"); r = do_indexfrom(fromfile); syslog(LOG_NOTICE, "done indexing messages"); break; case SEARCH: if (recursive_flag && optind == argc) usage(argv[0]); expand_mboxnames(&mboxnames, argc-optind, (const char **)argv+optind, user_mode); r = do_search(query, !multi_folder, &mboxnames); break; case ROLLING: do_rolling(channel); /* never returns */ break; case SYNCLOG: r = do_synclogfile(synclogfile); break; case START_DAEMON: if (optind != argc) usage("squatter"); search_start_daemon(verbose); break; case STOP_DAEMON: if (optind != argc) usage("squatter"); search_stop_daemon(verbose); break; case RUN_DAEMON: if (optind != argc) usage("squatter"); do_run_daemon(); break; case COMPACT: if (recursive_flag && optind == argc) usage(argv[0]); expand_mboxnames(&mboxnames, argc-optind, (const char **)argv+optind, user_mode); r = do_compact(&mboxnames, srctiers, desttier, compact_flags); break; } strarray_fini(&mboxnames); shut_down(r ? EC_TEMPFAIL : 0); }
int cmd_search(int argc, char **argv, struct mpd_connection *conn) { return do_search(argc, argv, conn, 0); }
static void do_random( char *uri, char *manager, struct berval *passwd, char *sbase, int scope, char *filter, char *attr, char **srchattrs, int noattrs, int nobind, int innerloop, int maxretries, int delay, int force, int chaserefs ) { LDAP *ld = NULL; int i = 0, do_retry = maxretries; char *attrs[ 2 ]; int rc = LDAP_SUCCESS; int version = LDAP_VERSION3; int nvalues = 0; char **values = NULL; LDAPMessage *res = NULL, *e = NULL; attrs[ 0 ] = attr; attrs[ 1 ] = NULL; ldap_initialize( &ld, uri ); if ( ld == NULL ) { tester_perror( "ldap_initialize", NULL ); exit( EXIT_FAILURE ); } (void) ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ); (void) ldap_set_option( ld, LDAP_OPT_REFERRALS, chaserefs ? LDAP_OPT_ON : LDAP_OPT_OFF ); if ( do_retry == maxretries ) { fprintf( stderr, "PID=%ld - Search(%d): base=\"%s\", filter=\"%s\" attr=\"%s\".\n", (long) pid, innerloop, sbase, filter, attr ); } if ( nobind == 0 ) { rc = ldap_sasl_bind_s( ld, manager, LDAP_SASL_SIMPLE, passwd, NULL, NULL, NULL ); if ( rc != LDAP_SUCCESS ) { tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); switch ( rc ) { case LDAP_BUSY: case LDAP_UNAVAILABLE: /* fallthru */ default: break; } exit( EXIT_FAILURE ); } } rc = ldap_search_ext_s( ld, sbase, LDAP_SCOPE_SUBTREE, filter, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res ); switch ( rc ) { case LDAP_SIZELIMIT_EXCEEDED: case LDAP_TIMELIMIT_EXCEEDED: case LDAP_SUCCESS: if ( ldap_count_entries( ld, res ) == 0 ) { if ( rc ) { tester_ldap_error( ld, "ldap_search_ext_s", NULL ); } break; } for ( e = ldap_first_entry( ld, res ); e != NULL; e = ldap_next_entry( ld, e ) ) { struct berval **v = ldap_get_values_len( ld, e, attr ); if ( v != NULL ) { int n = ldap_count_values_len( v ); int j; values = realloc( values, ( nvalues + n + 1 )*sizeof( char * ) ); for ( j = 0; j < n; j++ ) { values[ nvalues + j ] = strdup( v[ j ]->bv_val ); } values[ nvalues + j ] = NULL; nvalues += n; ldap_value_free_len( v ); } } ldap_msgfree( res ); if ( !values ) { fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n", (long) pid, sbase, filter, nvalues ); exit(EXIT_FAILURE); } if ( do_retry == maxretries ) { fprintf( stderr, " PID=%ld - Search base=\"%s\" filter=\"%s\" got %d values.\n", (long) pid, sbase, filter, nvalues ); } for ( i = 0; i < innerloop; i++ ) { char buf[ BUFSIZ ]; #if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */ int r = rand() % nvalues; #endif int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0); snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ r ] ); do_search( uri, manager, passwd, sbase, scope, buf, &ld, srchattrs, noattrs, nobind, 1, maxretries, delay, force, chaserefs ); } break; default: tester_ldap_error( ld, "ldap_search_ext_s", NULL ); break; } fprintf( stderr, " PID=%ld - Search done (%d).\n", (long) pid, rc ); if ( ld != NULL ) { ldap_unbind_ext( ld, NULL, NULL ); } }
MedialibDialog::MedialibDialog (QWidget *parent, XClient *client) : QDialog (parent) { QSettings s; setAttribute (Qt::WA_DeleteOnClose); setWindowTitle (tr ("Esperanza - Medialib Search")); QGridLayout *g = new QGridLayout (this); m_client = client; m_completer = NULL; m_qb = new QComboBox (this); m_qb->addItem (tr ("All"), MedialibSearchModel::ALL); m_qb->addItem (tr ("Artist"), MedialibSearchModel::ARTIST); m_qb->addItem (tr ("Album"), MedialibSearchModel::ALBUM); m_qb->addItem (tr ("Title"), MedialibSearchModel::TITLE); m_qb->addItem (tr ("Year"), MedialibSearchModel::YEAR); g->addWidget (m_qb, 0, 0, 1, 1); QLabel *l = new QLabel (tr ("="), this); g->addWidget (l, 0, 1, 1, 1); m_le = new QLineEdit (this); m_le->setFocus (Qt::OtherFocusReason); m_le->setFocusPolicy (Qt::StrongFocus); connect (m_le, SIGNAL (returnPressed ()), this, SLOT (do_search ())); g->addWidget (m_le, 0, 2, 1, 1); g->setColumnStretch (2, 1); m_indicator = new ProgressIndicator (this); g->addWidget (m_indicator, 0, 3, 1, 1); PlayerButton *expand = new PlayerButton (this, ":images/minmax.png"); g->addWidget (expand, 0, 4, 1, 1); connect (expand, SIGNAL (clicked (QMouseEvent *)), this, SLOT (expand_clicked ())); m_browser = new MedialibPaneBrowser (this, m_client); if (!s.value ("medialib/paneopen", false).toBool ()) { m_browser->hide (); } else { m_le->setEnabled (false); m_qb->setEnabled (false); } g->addWidget (m_browser, 1, 0, 1, 5); m_list = new MedialibView (this, client); g->addWidget (m_list, 2, 0, 1, 5); QWidget *dummy = new QWidget (this); QHBoxLayout *hbox = new QHBoxLayout (dummy); g->setRowStretch (2, 1); m_cb = new QCheckBox (tr ("Display unavailable entries"), dummy); hbox->addWidget (m_cb); connect (m_cb, SIGNAL (stateChanged (int)), this, SLOT (do_search ())); hbox->addStretch (1); PlayerButton *plus = new PlayerButton (dummy, ":images/plus.png"); connect (plus, SIGNAL (clicked (QMouseEvent *)), this, SLOT (plus_pressed (QMouseEvent *))); PlayerButton *stop = new PlayerButton (dummy, ":images/stop.png"); connect (stop, SIGNAL (clicked (QMouseEvent *)), this, SLOT (close ())); hbox->addWidget (plus); hbox->addWidget (stop); g->addWidget (dummy, 3, 0, 1, 5); g->setMargin (1); resize (s.value ("medialibdialog/size", QSize (500, 350)).toSize ()); connect (m_list, SIGNAL (searchDone ()), this, SLOT (search_done ())); m_qb->setCurrentIndex (s.value ("medialib/searchdef", 0).toInt ()); load_compl_list (m_qb->currentIndex ()); connect (m_qb, SIGNAL (currentIndexChanged (int)), this, SLOT (load_compl_list (int))); }
void test2() { char ia[] = {0, 1, 2, 3, 4, 5}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); char ic[] = {1}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); char id[] = {1, 2}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); char ie[] = {1, 2, 3}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); char ig[] = {1, 2, 3, 4}; do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; const unsigned sh = sizeof(ih)/sizeof(ih[0]); char ii[] = {1, 1, 2}; do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); }
int main(int argc, char *argv[]) { ps_decoder_t *ps; bin_mdef_t *mdef; dict_t *dict; dict2pid_t *d2p; acmod_t *acmod; ps_alignment_t *al; ps_alignment_iter_t *itor; ps_search_t *search; state_align_search_t *sas; cmd_ln_t *config; int i; config = cmd_ln_init(NULL, ps_args(), FALSE, "-hmm", MODELDIR "/hmm/en_US/hub4wsj_sc_8k", "-dict", MODELDIR "/lm/en_US/cmu07a.dic", "-input_endian", "little", "-samprate", "16000", NULL); TEST_ASSERT(ps = ps_init(config)); dict = ps->dict; d2p = ps->d2p; acmod = ps->acmod; mdef = d2p->mdef; al = ps_alignment_init(d2p); TEST_EQUAL(1, ps_alignment_add_word(al, dict_wordid(dict, "<s>"), 0)); TEST_EQUAL(2, ps_alignment_add_word(al, dict_wordid(dict, "go"), 0)); TEST_EQUAL(3, ps_alignment_add_word(al, dict_wordid(dict, "forward"), 0)); TEST_EQUAL(4, ps_alignment_add_word(al, dict_wordid(dict, "ten"), 0)); TEST_EQUAL(5, ps_alignment_add_word(al, dict_wordid(dict, "meters"), 0)); TEST_EQUAL(6, ps_alignment_add_word(al, dict_wordid(dict, "</s>"), 0)); TEST_EQUAL(0, ps_alignment_populate(al)); TEST_ASSERT(search = state_align_search_init(config, acmod, al)); sas = (state_align_search_t *)search; for (i = 0; i < 5; ++i) do_search(search, acmod); itor = ps_alignment_words(al); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 0); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 46); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 46); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 18); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 64); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 53); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 117); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 29); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 146); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 67); itor = ps_alignment_iter_next(itor); TEST_EQUAL(ps_alignment_iter_get(itor)->start, 213); TEST_EQUAL(ps_alignment_iter_get(itor)->duration, 61); itor = ps_alignment_iter_next(itor); TEST_EQUAL(itor, NULL); ps_search_free(search); ps_alignment_free(al); ps_free(ps); return 0; }