QString AWebservice::parseMessageList (const QString& data, ADataList& list, ARowVersion& row_version) { list.Rating.clear(); list.Message.clear(); list.Moderate.clear(); int seed = 0; QString message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed); while (message_info.length()) { AMessageInfo info; info.ID = getTextBetween(&message_info, "<messageId>", "</messageId>").toInt(); info.IDTopic = getTextBetween(&message_info, "<topicId>", "</topicId>").toInt(); info.IDParent = getTextBetween(&message_info, "<parentId>", "</parentId>").toInt(); info.IDUser = getTextBetween(&message_info, "<userId>", "</userId>").toInt(); info.IDForum = getTextBetween(&message_info, "<forumId>", "</forumId>").toInt(); info.Subject = getTextBetween(&message_info, "<subject>", "</subject>"); info.MessageName = getTextBetween(&message_info, "<messageName>", "</messageName>"); info.UserNick = getTextBetween(&message_info, "<userNick>", "</userNick>"); info.Message = getTextBetween(&message_info, "<message>", "</message>"); info.IDArticle = getTextBetween(&message_info, "<articleId>", "</articleId>").toInt(); info.MessageDate = getDateTimeFromString(getTextBetween(&message_info, "<messageDate>", "</messageDate>")); info.UpdateDate = getDateTimeFromString(getTextBetween(&message_info, "<updateDate>", "</updateDate>")); info.UserRole = getTextBetween(&message_info, "<userRole>", "</userRole>"); info.UserTitle = getTextBetween(&message_info, "<userTitle>", "</userTitle>"); info.UserTitleColor = getTextBetween(&message_info, "<userTitleColor>", "</userTitleColor>").toInt(); info.LastModerated = getDateTimeFromString(getTextBetween(&message_info, "<lastModerated>", "</lastModerated>")); info.Closed = getBooleanFromString(getTextBetween(&message_info, "<closed>", "</closed>")); if (info.MessageDate.isValid() == false) return QString::fromUtf8("Некорректное значение даты <messageDate>: ") + getTextBetween(&message_info, "<messageDate>", "</messageDate>"); if (info.UpdateDate.isValid() == false) return QString::fromUtf8("Некорректное значение даты <updateDate>: ") + getTextBetween(&message_info, "<updateDate>", "</updateDate>"); if (info.LastModerated.isValid() == false) return QString::fromUtf8("Некорректное значение даты <lastModerated>: ") + getTextBetween(&message_info, "<lastModerated>", "</lastModerated>"); list.Message.append(info); message_info = getNextBlock(&data, "<JanusMessageInfo>", "</JanusMessageInfo>", seed); } seed = 0; QString rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed); while (rating_info.length()) { ARatingInfo info; info.IDMessage = getTextBetween(&rating_info, "<messageId>", "</messageId>").toInt(); info.IDTopic = getTextBetween(&rating_info, "<topicId>", "</topicId>").toInt(); info.IDUser = getTextBetween(&rating_info, "<userId>", "</userId>").toInt(); info.UserRating = getTextBetween(&rating_info, "<userRating>", "</userRating>").toInt(); info.Rate = getTextBetween(&rating_info, "<rate>", "</rate>").toInt(); info.RateDate = getDateTimeFromString(getTextBetween(&rating_info, "<rateDate>", "</rateDate>")); if (info.RateDate.isValid() == false) return QString::fromUtf8("Некорректное значение даты <rateDate>: ") + getTextBetween(&rating_info, "<rateDate>", "</rateDate>"); list.Rating.append(info); rating_info = getNextBlock(&data, "<JanusRatingInfo>", "</JanusRatingInfo>", seed); } seed = 0; QString moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed); while (moderate_info.length()) { AModerateInfo info; info.IDMessage = getTextBetween(&moderate_info, "<messageId>", "</messageId>").toInt(); info.IDTopic = getTextBetween(&moderate_info, "<topicId>", "</topicId>").toInt(); info.IDUser = getTextBetween(&moderate_info, "<userId>", "</userId>").toInt(); info.IDForum = getTextBetween(&moderate_info, "<forumId>", "</forumId>").toInt(); info.Created = getDateTimeFromString(getTextBetween(&moderate_info, "<create>", "</create>")); if (info.Created.isValid() == false) return QString::fromUtf8("Некорректное значение даты <create>: ") + getTextBetween(&moderate_info, "<create>", "</create>"); list.Moderate.append(info); moderate_info = getNextBlock(&data, "<JanusModerateInfo>", "</JanusModerateInfo>", seed); } seed = 0; QString lastRatingRowVersion = getNextBlock(&data, "<lastRatingRowVersion>", "</lastRatingRowVersion>", seed); seed = 0; QString lastForumRowVersion = getNextBlock(&data, "<lastForumRowVersion>", "</lastForumRowVersion>", seed); seed = 0; QString lastModerateRowVersion = getNextBlock(&data, "<lastModerateRowVersion>", "</lastModerateRowVersion>", seed); // проверка ошибок получения версий строк // подавлять ошибки сбросом в значение по умолчанию ("AAAAAAAAAAA=") оказалось неправильно // подробнее см. https://rsdn.ru/forum/janus/3449147.1 // выбрасывать ошибку (r253) тоже оказалось неправильно - для некоторых форумов не приходят ни рейтинги ни модерилки if (lastRatingRowVersion.length() != 0) row_version.Rating = lastRatingRowVersion; if (lastForumRowVersion.length() != 0) row_version.Message = lastForumRowVersion; if (lastModerateRowVersion.length() != 0) row_version.Moderate = lastModerateRowVersion; return ""; }
QString AWebservice::parsePostChangeCommit (const QString& data, ACommitInfo& commit_info) { int seed = 0; QString messages = getTextBetween(&data, "<commitedIds>", "</commitedIds>"); QString id_info = getNextBlock(&messages, "<int>", "</int>", seed); while (id_info.length()) { commit_info.Messages.append(id_info.toInt()); id_info = getNextBlock(&messages, "<int>", "</int>", seed); } seed = 0; QString message_exceptions = getTextBetween(&data, "<exceptions>", "</exceptions>"); QString message_exception_info = getNextBlock(&message_exceptions, "<PostExceptionInfo>", "</PostExceptionInfo>", seed); while (message_exception_info.length()) { ACommitExceptionInfo info; info.Exception = getTextBetween(&message_exception_info, "<exception>", "</exception>"); info.ID = getTextBetween(&message_exception_info, "<localMessageId>", "</localMessageId>").toInt(); info.Info = getTextBetween(&message_exception_info, "<info>", "</info>"); commit_info.MessagesExceptions.append(info); message_exception_info = getNextBlock(&message_exceptions, "<PostExceptionInfo>", "</PostExceptionInfo>", seed); } seed = 0; QString ratings = getTextBetween(&data, "<commitedRatingIds>", "</commitedRatingIds>"); id_info = getNextBlock(&ratings, "<int>", "</int>", seed); while (id_info.length()) { commit_info.Rating.append(id_info.toInt()); id_info = getNextBlock(&ratings, "<int>", "</int>", seed); } seed = 0; QString rating_exceptions = getTextBetween(&data, "<ratingExceptions>", "</ratingExceptions>"); QString rating_exception_info = getNextBlock(&rating_exceptions, "<RatingExceptionInfo>", "</RatingExceptionInfo>", seed); while (rating_exception_info.length()) { ACommitExceptionInfo info; info.Exception = getTextBetween(&rating_exception_info, "<exception>", "</exception>"); info.ID = getTextBetween(&rating_exception_info, "<localRatingId>", "</localRatingId>").toInt(); info.Info = getTextBetween(&rating_exception_info, "<info>", "</info>"); commit_info.RatingExceptions.append(info); rating_exception_info = getNextBlock(&rating_exceptions, "<RatingExceptionInfo>", "</RatingExceptionInfo>", seed); } seed = 0; QString moderates = getTextBetween(&data, "<commitedModerateIds>", "</commitedModerateIds>"); id_info = getNextBlock(&moderates, "<int>", "</int>", seed); while (id_info.length()) { commit_info.Moderate.append(id_info.toInt()); id_info = getNextBlock(&moderates, "<int>", "</int>", seed); } seed = 0; QString moderate_exceptions = getTextBetween(&data, "<moderateExceptions>", "</moderateExceptions>"); QString moderate_exception_info = getNextBlock(&moderate_exceptions, "<ModerateExceptionInfo>", "</ModerateExceptionInfo>", seed); while (moderate_exception_info.length()) { ACommitExceptionInfo info; info.Exception = getTextBetween(&moderate_exception_info, "<ExceptionMessage>", "</ExceptionMessage>"); info.ID = getTextBetween(&moderate_exception_info, "<LocalModerateId>", "</LocalModerateId>").toInt(); info.Info = getTextBetween(&moderate_exception_info, "<Info>", "</Info>"); commit_info.MessagesExceptions.append(info); moderate_exception_info = getNextBlock(&moderate_exceptions, "<ModerateExceptionInfo>", "</ModerateExceptionInfo>", seed); } return ""; }
// NOTE! for this to work ... // ss_old must point the the head of a void SSDifBlock( ss_block *ss_old, char *text, int start_col, line *line, linenum line_no, int *dif ) { ss_block ss_new, *ss_inc; int index; bool changed; bool anychange; int text_col; *dif = 0; index = 0; anychange = false; switch( CurrentInfo->fsi.Language ) { case LANG_C: case LANG_CPP: case LANG_JAVA: case LANG_SQL: case LANG_BAT: case LANG_BASIC: case LANG_DBTEST: case LANG_RC: case LANG_USER: InitCLine( text ); break; case LANG_FORTRAN: InitFORTRANLine( text, line_no ); break; case LANG_HTML: case LANG_WML: InitHTMLLine( text ); break; case LANG_GML: InitGMLLine( text ); break; case LANG_MAKEFILE: InitMkLine( text ); break; case LANG_PERL: case LANG_AWK: InitPerlLine( text ); break; } ss_inc = ss_old; text_col = 0; do { ss_new.type = SE_UNPARSED; do { getNextBlock( &ss_new, text, text_col, line, line_no ); // -3 because as many as 2 extra blocks could be needed // when selection is inserted if( index == MAX_SS_BLOCKS - 3 && ss_new.end != BEYOND_TEXT ) { // out of room - fake rest of line ss_new.end = BEYOND_TEXT; break; } index++; text_col = ss_new.end + 1; } while( ss_new.end < start_col ); changed = ( memcmp( ss_inc, &ss_new, sizeof( ss_block ) ) != 0 ); if( changed ) { memcpy( ss_inc, &ss_new, sizeof( ss_block ) ); } anychange |= changed; if( !anychange ) { *dif = ss_inc->end + 1; } } while( (ss_inc++)->end != BEYOND_TEXT ); if( SelRgn.selected ) { addSelection( ss_old, line_no ); fixSelection( ss_old, start_col ); } // change origin of ->ends from text[0] to text[start_col] for( ss_inc = ss_old; ss_inc->end != BEYOND_TEXT; ++ss_inc ) { ss_inc->end -= start_col; } }
void AWebservice::parseForumList (const QString& data, AForumGroupInfoList& list) { list.clear(); // // список групп форумов // AGroupInfoList group_list; int seed = 0; QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed); while (group_info.length()) { AGroupInfo info; info.ID = getTextBetween(&group_info, "<forumGroupId>", "</forumGroupId>").toInt(); info.Name = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>"); info.SortOrder = getTextBetween(&group_info, "<sortOrder>", "</sortOrder>").toInt(); group_list.append(info); group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed); } // // список форумов // AForumInfoList forum_list; seed = 0; QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed); while (forum_info.length()) { AForumInfo info; info.ID = getTextBetween(&forum_info, "<forumId>", "</forumId>").toInt(); info.IDGroup = getTextBetween(&forum_info, "<forumGroupId>", "</forumGroupId>").toInt(); info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>"); info.Name = getTextBetween(&forum_info, "<forumName>", "</forumName>"); info.Rated = getTextBetween(&forum_info, "<rated>", "</rated>").toInt(); info.InTop = getTextBetween(&forum_info, "<inTop>", "</inTop>").toInt(); info.RateLimit = getTextBetween(&forum_info, "<rateLimit>", "</rateLimit>").toInt(); forum_list.append(info); forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed); } // // заполнение результата // for (int group_index = 0; group_index < group_list.count(); group_index++) { AForumGroupInfo group_info; group_info.Group = group_list[group_index]; for (int forum_index = 0; forum_index < forum_list.count(); forum_index++) if (forum_list[forum_index].IDGroup == group_info.Group.ID) group_info.Forums.append(forum_list[forum_index]); list.append(group_info); } }
/*! * @brief Handles packet received when core dump is enabled. * * @param pkt Received packet. * * @return * - Always returns WIFI_ENGINE_SUCCESS */ void WiFiEngine_HandleCoreDumpPkt(char* pkt) { size_t size; unsigned char *msg = NULL; if (!WES_TEST_FLAG(WES_FLAG_HW_PRESENT)) return; switch(core_dump_state) { case W4_SCB_ERROR_CFM: { unsigned char tx_desc[TX_DESC_SIZE]; hic_message_context_t msg_ref; uint8_t messageId; uint8_t messageType; Blob_t blob; Mlme_CreateMessageContext(msg_ref); INIT_BLOB(&blob, pkt, 1500); /* XXX */ /* Remove HIC header and add type/id info to msg_ref */ packer_HIC_Unpack(&msg_ref, &blob); messageId = msg_ref.msg_id; messageType = msg_ref.msg_type; msg_ref.packed = NULL; Mlme_ReleaseMessageContext(msg_ref); if((messageType == HIC_MESSAGE_TYPE_CTRL) && (messageId == HIC_CTRL_SCB_ERROR_CFM)) { /* Handle confirm message */ if(handleSCBErrorCfm(pkt) == 0) { /* SCB_ERROR_CFM has error code 0, this means that firmware. * is executing "normally" (no scb error has occured). * However a command timeout has occured so it would be nice * to force firmware in scb error and try to get a core dump. */ DE_TRACE_STATIC(TR_ALWAYS,"Cancel timer\n"); DriverEnvironment_CancelTimer(wifiEngineState.cmd_timer_id); DE_TRACE_STATIC(TR_ALWAYS,"Suicide requested\n"); sendCommitSuicideRequest(); wifiEngineState.core_dump_state = WEI_CORE_DUMP_DISABLED; return; } if(m_ext_ctx) { /* Coredump already started */ DriverEnvironment_Core_Dump_Abort( registry.network.basic.enableCoredump, registry.network.basic.restartTargetAfterCoredump, m_objId, m_errCode, &m_ext_ctx); } else { DriverEnvironment_indicate(WE_IND_CORE_DUMP_START, NULL, 0); } DriverEnvironment_Core_Dump_Started( registry.network.basic.enableCoredump, registry.network.basic.restartTargetAfterCoredump, m_objId, m_errCode, dump_total_size(dump_address_table), dump_total_size(dump_address_table), &m_ext_ctx); /* Turn off traces */ //trace_mask &= ~(TR_CMD | TR_NOISE | TR_PS | TR_HIGH_RES | TR_DATA ); trace_mask = 0; DriverEnvironment_Enable_Boot(); /* This is to prevent command timeout logic to re-start the timer */ WES_SET_FLAG(WES_FLAG_CMD_TIMEOUT_RUNNING); /* Initiate physical bm-descriptor to point to tx-descriptors */ createDataReq_u32(&msg, StartDescriptorAddress, StartTxBmDesc + OFFSET_TO_POINTER_BM_DESC, &size); /* Clear any pending flags and flush queue*/ wifiEngineState.cmdReplyPending = 0; wei_clear_cmd_queue(); wei_send_cmd_raw((char *)msg, size); /* Initiate targets tx-descriptor to be used */ createTxDescriptor(tx_desc); createDataReq(&msg, tx_desc, sizeof(tx_desc), StartDescriptorAddress, &size); /* Clear any pending flags and flush queue*/ wifiEngineState.cmdReplyPending = 0; wei_clear_cmd_queue(); wei_send_cmd_raw((char *)msg, size); core_dump_state = W4_MEMORY_DUMP; /* * if m_ext_ctx==NULL we are not interested in the coredump and can restart the target directly * Not sure of how to do this in a safe way so will go ahead with the coredump anyway for now and fix this later */ if(m_ext_ctx==NULL) { trace_mask = old_trace_mask; DriverEnvironment_Core_Dump_Complete( FALSE, registry.network.basic.restartTargetAfterCoredump, m_objId, m_errCode, &m_ext_ctx); DriverEnvironment_indicate(WE_IND_CORE_DUMP_COMPLETE, NULL, 0); DriverEnvironment_CancelTimer(wifiEngineState.cmd_timer_id); WES_CLEAR_FLAG(WES_FLAG_CMD_TIMEOUT_RUNNING); return; } currentRegion = dump_address_table; currentAddress = dump_region_start(currentRegion); getNextBlock(currentAddress); } else { DE_TRACE_INT2(TR_ALWAYS, "unexpected message %u.%u\n", messageType, messageId); } } break; case W4_MEMORY_DUMP: { uint32_t len; /* Store recevied packet in a file */ len = HIC_MESSAGE_LENGTH_GET(pkt); /* Move beyond size */ pkt += 2; len -= 2; /* Write dumpfile header (for nrx600 coredumps) */ if (dump_address_table == dump_address_table_nrx600 && m_ext_ctx && currentAddress == dump_region_start(currentRegion)) { DriverEnvironment_Core_Dump_Write(m_ext_ctx, (char *)currentRegion, sizeof(*currentRegion)); } len = DE_MIN(len, dump_region_end(currentRegion) - currentAddress); /* Copy to buffer */ if (m_ext_ctx) { DriverEnvironment_Core_Dump_Write(m_ext_ctx, pkt, len); } currentAddress += len; if(currentAddress >= dump_region_end(currentRegion)) { /* end of region, skip forward */ currentRegion++; currentAddress = dump_region_start(currentRegion); if(dump_region_size(currentRegion) == 0) { /* Complete - Start store data on a file and restart driver */ trace_mask = old_trace_mask; DE_TRACE_STATIC(TR_ALWAYS,"Coredump complete - cancel timer\n"); DriverEnvironment_CancelTimer(wifiEngineState.cmd_timer_id); WES_CLEAR_FLAG(WES_FLAG_CMD_TIMEOUT_RUNNING); DriverEnvironment_Core_Dump_Complete(registry.network.basic.enableCoredump && m_ext_ctx != NULL, /* see driverenv.h */ registry.network.basic.restartTargetAfterCoredump, m_objId, m_errCode, &m_ext_ctx); DriverEnvironment_indicate(WE_IND_CORE_DUMP_COMPLETE, NULL, 0); return; } } getNextBlock(currentAddress); } break; default: DE_BUG_ON(TRUE, "Invalid core dump state\n"); break; } }
/* * Write size bytes from buf into file starting from offset * */ static int cs1550_write(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { int ret = 0; (void) fi; char dir[MAX_FILENAME + 1]; char fileName[MAX_FILENAME + 1]; char ext[MAX_EXTENSION + 1]; getPath(path, dir, fileName, ext); int pathType = getPathType(path, dir, fileName, ext); int fileSize = getFileSize(dir, fileName, ext, pathType); if (dirExists(dir) == 1 && pathType >= 2 && fileSize != -1 && size > 0) { cs1550_directory_entry parentDir; getDir(&parentDir, dir); int i =0; for (i = 0; i < parentDir.nFiles; i++) { if ((pathType==2 && strcmp(parentDir.files[i].fname, fileName)==0) || (pathType==3 && strcmp(parentDir.files[i].fname, fileName) == 0 && strcmp(parentDir.files[i].fext, ext) == 0)) { if (offset > parentDir.files[i].fsize) { return -EFBIG; } else { long startBlock = parentDir.files[i].nStartBlock; int blockNum = offset / BLOCK_SIZE; long seek = startBlock; long bStart = 0; FILE *f = fopen(".disk", "rb+"); int j = 0; for (j = 0; j <= blockNum; j++) { bStart = seek; fseek(f, seek, SEEK_SET); cs1550_disk_block fileBlock; fread(&fileBlock, BLOCK_SIZE, 1, f); seek = fileBlock.magic_number; } rewind(f); int off = (int)offset - (blockNum * BLOCK_SIZE); int index; int count = off; seek = bStart; fseek(f, seek, SEEK_SET); cs1550_disk_block curBlock; fread(&curBlock, BLOCK_SIZE, 1, f); for (index = 0; index < strlen(buf); index++) { if (count < MAX_DATA_IN_BLOCK) { curBlock.data[count] = (char)buf[index]; count++; } else { count = 0; if (curBlock.magic_number != 0) { writeBlock(&curBlock, seek); seek = curBlock.magic_number; fseek(f, seek, SEEK_SET); fread(&curBlock, BLOCK_SIZE, 1, f); } else { long cSeek = seek; int nextBlock = getNextBlock(); seek = nextBlock * BLOCK_SIZE; curBlock.magic_number = seek; writeBlock(&curBlock, cSeek); fseek(f, seek, SEEK_SET); fread(&curBlock, BLOCK_SIZE, 1, f); updateBitmap(nextBlock, 1); } } if (index == strlen(buf)-1) { writeBlock(&curBlock, seek); count = 0; } } fclose(f); int old = parentDir.files[i].fsize; int newSize = (size - (old - offset)) + (old - (old - offset)); parentDir.files[i].fsize = newSize; updateDir(&parentDir, dir); ret = newSize; } } } } return ret; }
void doJob(int rank, int worldSize) { long pCount; int nBlocks = 0; int BlockSize = worldSize * POINTS_PER_PROCCESSOR; int ActualLocalBlockSize = POINTS_PER_PROCCESSOR * OBJ_SIZE; int globalCount[worldSize]; int i = 0, k=0, z=0; int localCount = 0; int ThreadCount=0; float *block = malloc(sizeof(float) * BlockSize * OBJ_SIZE); float *localBlock = malloc(sizeof(float) * ActualLocalBlockSize); float *BlockRemaing=NULL; int remaining=0; if (rank == 0) { pCount = OpenFileAndGetPointCount(arg3); nBlocks = pCount / BlockSize; if (pCount % BlockSize != 0) { nBlocks++; } printf("Total points: %ld\n%d Blocks of %d points each\n", pCount, nBlocks, BlockSize); } MPI_Bcast(&nBlocks, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast(&pCount, 1, MPI_INT, 0, MPI_COMM_WORLD); for (k = 0; k < nBlocks; k++) { if (rank == 0) { printf("\nBlock %d from %d", k+1,nBlocks); getNextBlock(block, BlockSize); // printf("\nBlock %d ", k); } if (k == nBlocks - 1) { remaining =(int) (pCount - BlockSize * (nBlocks - 1)); if (remaining != BlockSize) { BlockSize = remaining - (remaining % worldSize); remaining = remaining % worldSize; //printf("\nremaining: %d", BlockSize + remaining); // MPI_Bcast(&BlockSize, 1, MPI_INT, 0, MPI_COMM_WORLD); ActualLocalBlockSize = (BlockSize / worldSize) * OBJ_SIZE; //printf("BlockSize:%d\n",BlockSize); if (rank == 0) { //printf("\nremaining: %d\n", BlockSize); float *tempBlock = floatdup(block, (size_t) BlockSize * OBJ_SIZE); // printf("size of temp %d",sizeof(tempBlock)); BlockRemaing = malloc(remaining * OBJ_SIZE * sizeof(float)); for (z = 0; z < remaining; z++) { BlockRemaing[z] = block[BlockSize * OBJ_SIZE + z]; } free(block); block = &tempBlock[0]; } localBlock = realloc(localBlock, ActualLocalBlockSize * sizeof(float)); //printf("\n%d DONE\n", rank); //printf("rank: %d,Blocksize: %d, block-size: %d\n", rank, BlockSize, sizeof(block)); } else { remaining = 0; } } MPI_Scatter(block, ActualLocalBlockSize, MPI_FLOAT, localBlock, ActualLocalBlockSize, MPI_FLOAT, 0, MPI_COMM_WORLD); ThreadCount=0; #pragma omp parallel { // printf("rank: %d num Threads: %d\n",rank,omp_get_num_threads()); #pragma omp for reduction(+:ThreadCount) for (i = 0; i < ActualLocalBlockSize; i = i + 3) if (checkColizion(&localBlock[i])) { ThreadCount++; // printf("rank: %d %f\n", rank, localBlock[i]); } } localCount=localCount+ThreadCount; MPI_Gather(&localCount, 1, MPI_INT, globalCount, 1, MPI_INT, 0, MPI_COMM_WORLD); if (rank == 0) { int totalCount = 0; for (i = 0; i < worldSize; i++) { totalCount += globalCount[i]; } if (checkColizionLimmit(totalCount)) { //Do something Like exit } //printf("\nTotalCount: %d\n", totalCount); if (checkExecutionTime()) { //Do something like exit } } } if (rank == 0) { CloseFile(); #pragma omp parallel for reduction(+:localCount) for (i = 0; i < remaining; i = i + 3) if (checkColizion(&BlockRemaing[i])) { localCount++; // printf("rank: %d %f\n", rank, localBlock[i]); } } MPI_Gather(&localCount, 1, MPI_INT, globalCount, 1, MPI_INT, 0, MPI_COMM_WORLD); if (rank == 0) { int totalCount = 0; for (i = 0; i < worldSize; i++) { totalCount += globalCount[i]; } printf("\nTotalCount: %d\n", totalCount); } }
void DrawNextShape(){ //DrawShape_idx=0; asm("ldy #$00"); //DrawShape_i=4; asm("lda #$04"); asm("sta %b",DrawShape_i); //for(i=4;i>0;i--) fori: //DrawShape_j=4; asm("lda #$04"); asm("sta %b",DrawShape_j); //for(j=4;j>0;j--) forj: //getBlock_i = DrawShape_i-1; asm("ldx %b",DrawShape_i); asm("dex"); asm("stx %b",getBlock_i); //getBlock_j = DrawShape_j-1; asm("ldx %b",DrawShape_j); asm("dex"); asm("stx %b",getBlock_j); getNextBlock(); //if(getBlock_ret) asm("lda %b",getBlock_ret); asm("beq %g",else1); { ////DrawBuff[DrawShape_idx++]=((4+DrawShape_j)<<3)-1; ////DrawShape_temp=31+(DrawShape_j<<3); //DrawShape_temp = DrawShape_j; asm("lda %b",DrawShape_j); //DrawShape_temp <<= 3; asm("asl"); asm("asl"); asm("asl"); //DrawShape_temp += 31; asm("clc"); asm("adc #$1F"); //DrawBuff[DrawShape_idx++]=DrawShape_temp; asm("sta %w,Y",DrawBuff); asm("iny"); //DrawBuff[DrawShape_idx++]=getBlock_ret; asm("lda %b",getBlock_ret); asm("sta %w,Y",DrawBuff); asm("iny"); //DrawBuff[DrawShape_idx++]=0; asm("lda #$00"); asm("sta %w,Y",DrawBuff); asm("iny"); //DrawShape_temp=(13+DrawShape_i)<<3 asm("lda %b",DrawShape_i); asm("clc"); asm("adc #$0D"); asm("asl"); asm("asl"); asm("asl"); //DrawBuff[DrawShape_idx++]=DrawShape_temp; asm("sta %w,Y",DrawBuff); asm("iny"); }else1: asm("dec %b",DrawShape_j); asm("bne %g",forj); asm("dec %b",DrawShape_i); asm("bne %g",fori); waitvblank(); //*(char*)(0x2003)=16; //i<<2 asm("lda #$10"); asm("sta $2003"); DrawBuffToPPU(); }
void AWebservice::getForumList_WebserviceParse (const QString& data, AForumGroupInfoList& list, IProgress* progress) { if (progress != NULL) progress->onProgress(0); list.clear(); // // список групп форумов // AGroupInfoList group_list; int seed = 0; QString group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed); while (group_info.length()) { AGroupInfo info; info.ID = getTextBetween(&group_info, "<forumGroupId>", "</forumGroupId>").toInt(); info.Name = getTextBetween(&group_info, "<forumGroupName>", "</forumGroupName>"); info.SortOrder = getTextBetween(&group_info, "<sortOrder>", "</sortOrder>").toInt(); group_list.append(info); group_info = getNextBlock(&data, "<JanusForumGroupInfo>", "</JanusForumGroupInfo>", seed); } // // список форумов // AForumInfoList forum_list; seed = 0; QString forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed); while (forum_info.length()) { AForumInfo info; info.ID = getTextBetween(&forum_info, "<forumId>", "</forumId>").toInt(); info.IDGroup = getTextBetween(&forum_info, "<forumGroupId>", "</forumGroupId>").toInt(); info.ShortName = getTextBetween(&forum_info, "<shortForumName>", "</shortForumName>"); info.Name = getTextBetween(&forum_info, "<forumName>", "</forumName>"); info.Rated = getTextBetween(&forum_info, "<rated>", "</rated>").toInt(); info.InTop = getTextBetween(&forum_info, "<inTop>", "</inTop>").toInt(); info.RateLimit = getTextBetween(&forum_info, "<rateLimit>", "</rateLimit>").toInt(); forum_list.append(info); forum_info = getNextBlock(&data, "<JanusForumInfo>", "</JanusForumInfo>", seed); } // // заполнение результата // for (int group_index = 0; group_index < group_list.count(); group_index++) { AForumGroupInfo group_info; group_info.Group = group_list[group_index]; for (int forum_index = 0; forum_index < forum_list.count(); forum_index++) if (forum_list[forum_index].IDGroup == group_info.Group.ID) group_info.Forums.append(forum_list[forum_index]); list.append(group_info); } // // добавление "мусорки" // /* AForumGroupInfo trash_group; trash_group.Group.ID = 0; trash_group.Group.Name = QString::fromUtf8("Корзина"); trash_group.Group.SortOrder = 10000; AForumInfo trash_forum; trash_forum.ID = 0; trash_forum.IDGroup = 0; trash_forum.ShortName = "trash"; trash_forum.Name = QString::fromUtf8("Удаленные"); trash_forum.Rated = true; trash_forum.InTop = true; trash_forum.RateLimit = 0; trash_group.Forums.append(trash_forum); list.append(trash_group); */ }