/* * Print the last transport error */ static void printLastError(jdwpTransportEnv *t, jdwpTransportError err) { char *msg; jbyte *utf8msg; jdwpTransportError rv; msg = NULL; utf8msg = NULL; rv = (*t)->GetLastError(t, &msg); /* This is a platform encoded string */ if ( msg != NULL ) { int len; int maxlen; /* Convert this string to UTF8 */ len = (int)strlen(msg); maxlen = len+len/2+2; /* Should allow for plenty of room */ utf8msg = (jbyte*)jvmtiAllocate(maxlen+1); (void)(gdata->npt->utf8FromPlatform)(gdata->npt->utf, msg, len, utf8msg, maxlen); utf8msg[maxlen] = 0; } if (rv == JDWPTRANSPORT_ERROR_NONE) { ERROR_MESSAGE(("transport error %d: %s",err, utf8msg)); } else if ( msg!=NULL ) { ERROR_MESSAGE(("transport error %d: %s",err, utf8msg)); } else { ERROR_MESSAGE(("transport error %d: %s",err, "UNKNOWN")); } jvmtiDeallocate(msg); jvmtiDeallocate(utf8msg); }
int DP_MultipleLocalBlockAlignGeneric( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, DP_LoopPenaltyFunction LoopScore, unsigned int queryFrom, unsigned int queryTo, DP_MultipleAlignmentResults **alignments, unsigned int maxAlignments) { if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_MultipleLocalBlockAlignGeneric() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } for (unsigned int block=0; block<blocks->nBlocks; ++block) { if (blocks->freezeBlocks[block] != DP_UNFROZEN_BLOCK) { WARNING_MESSAGE("DP_MultipleLocalBlockAlignGeneric() - frozen block specifications are ignored..."); break; } } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); int status = CalculateLocalMatrixGeneric(matrix, blocks, BlockScore, LoopScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_MultipleLocalBlockAlignGeneric() - CalculateLocalMatrixGeneric() failed"); return status; } return TracebackMultipleLocalAlignments(matrix, blocks, queryFrom, queryTo, alignments, maxAlignments); }
int DP_GlobalBlockAlign( const DP_BlockInfo *blocks, DP_BlockScoreFunction BlockScore, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment) { if (!blocks || blocks->nBlocks < 1 || !blocks->blockSizes || !BlockScore || queryTo < queryFrom) { ERROR_MESSAGE("DP_GlobalBlockAlign() - invalid parameters"); return STRUCT_DP_PARAMETER_ERROR; } unsigned int i, sumBlockLen = 0; for (i=0; i<blocks->nBlocks; ++i) sumBlockLen += blocks->blockSizes[i]; if (sumBlockLen > queryTo - queryFrom + 1) { ERROR_MESSAGE("DP_GlobalBlockAlign() - sum of block lengths longer than query region"); return STRUCT_DP_PARAMETER_ERROR; } int status = ValidateFrozenBlockPositions(blocks, queryFrom, queryTo, true); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_GlobalBlockAlign() - ValidateFrozenBlockPositions() returned error"); return status; } Matrix matrix(blocks->nBlocks, queryTo - queryFrom + 1); status = CalculateGlobalMatrix(matrix, blocks, BlockScore, queryFrom, queryTo); if (status != STRUCT_DP_OKAY) { ERROR_MESSAGE("DP_GlobalBlockAlign() - CalculateGlobalMatrix() failed"); return status; } return TracebackGlobalAlignment(matrix, blocks, queryFrom, queryTo, alignment); }
int TracebackGlobalAlignment(const Matrix& matrix, const DP_BlockInfo *blocks, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment) { if (!alignment) { ERROR_MESSAGE("TracebackGlobalAlignment() - NULL alignment handle"); return STRUCT_DP_PARAMETER_ERROR; } *alignment = NULL; // find max score (e.g., best-scoring position of last block) int score = DP_NEGATIVE_INFINITY; unsigned int residue, lastBlockPos = 0; for (residue=queryFrom; residue<=queryTo; ++residue) { if (matrix[blocks->nBlocks - 1][residue - queryFrom].score > score) { score = matrix[blocks->nBlocks - 1][residue - queryFrom].score; lastBlockPos = residue; } } if (score == DP_NEGATIVE_INFINITY) { ERROR_MESSAGE("TracebackGlobalAlignment() - somehow failed to find any allowed global alignment"); return STRUCT_DP_ALGORITHM_ERROR; } // INFO_MESSAGE("Score of best global alignment: " << score); *alignment = new DP_AlignmentResult; return TracebackAlignment(matrix, blocks->nBlocks - 1, lastBlockPos, queryFrom, *alignment); }
INTERNAL_TYPE_GRID_PA GridPA :: get(INTERNAL_SIZE_GRID_PA seq, INTERNAL_SIZE_SEQ_GRID_PA pos){ if(seq>size()){ ERROR_MESSAGE("Invalid sequence ("<< seq <<")."); } if(pos>size(seq)){ ERROR_MESSAGE("Invalid pos in sequence ("<< pos <<")."); } return v_sequences[seq][pos]; }
/** <!--******************************************************************--> * * @fn CHKMerror * * @brief Touched the node and its sons/attributes * * @param arg_node Error node to process * @param arg_info pointer to info structure * * @return processed node * ***************************************************************************/ node * CHKMerror (node * arg_node, info * arg_info) { DBUG_ENTER ("CHKMerror"); NODE_ERROR (arg_node) = CHKMTRAV (NODE_ERROR (arg_node), arg_info); ERROR_NEXT (arg_node) = CHKMTRAV (ERROR_NEXT (arg_node), arg_info); ERROR_MESSAGE (arg_node) = CHKMattribString (ERROR_MESSAGE (arg_node), arg_info); DBUG_RETURN (arg_node); }
bool createGIF(string fileName, bool show) { if (!createImage(fileName, "gif")) { ERROR_MESSAGE("FSMmodel::createGIF - unable to create GIF from DOT file. Check Graphviz\bin is your PATH."); return false; } if (show && !showImage(fileName + ".gif")) { ERROR_MESSAGE("FSMmodel::createGIF - unable to show GIF"); return false; } return true; }
bool createPNG(string fileName, bool show) { if (!createImage(fileName, "png")) { ERROR_MESSAGE("FSMmodel::createPNG - unable to create PNG from DOT file. Check Graphviz\bin is your PATH."); return false; } if (show && !showImage(fileName + ".png")) { ERROR_MESSAGE("FSMmodel::createPNG - unable to show PNG"); return false; } return true; }
void yacc_at (location loc, const char *message, ...) { if (yacc_flag) { ERROR_MESSAGE (&loc, NULL, message); complaint_issued = true; } else if (warnings_flag & warnings_yacc) { set_warning_issued (); ERROR_MESSAGE (&loc, _("warning"), message); } }
/** <!--******************************************************************--> * * @fn COPYerror * * @brief Copies the node and its sons/attributes * * @param arg_node Error node to process * @param arg_info pointer to info structure * * @return processed node * ***************************************************************************/ node * COPYerror (node * arg_node, info * arg_info) { node *result = TBmakeError (NULL, PH_initial, NULL); DBUG_ENTER ("COPYerror"); LUTinsertIntoLutP (INFO_LUT (arg_info), arg_node, result); /* Copy attributes */ ERROR_MESSAGE (result) = STRcpy (ERROR_MESSAGE (arg_node)); ERROR_ANYPHASE (result) = ERROR_ANYPHASE (arg_node); /* Copy sons */ ERROR_NEXT (result) = COPYTRAV (ERROR_NEXT (arg_node), arg_info); /* Return value */ DBUG_RETURN (result); }
void Shader::Init() { std::string tmp_vertexShaderSourceCode = ""; std::string tmp_geometryShaderSourceCode = ""; std::string tmp_fragmentShaderSourceCode = ""; try { tmp_vertexShaderSourceCode = LoadFile( m_vertexShaderFile ); } catch(std::string &e){ ERROR_MESSAGE(e);} try { tmp_geometryShaderSourceCode = LoadFile( m_geometryShaderFile ); } catch(std::string &e){ ERROR_MESSAGE(e);} try { tmp_fragmentShaderSourceCode = LoadFile( m_fragmentShaderFile ); } catch(std::string &e){ ERROR_MESSAGE(e);} // TODO: geometry shader GLuint tmp_vertexShaderObject = glCreateShader(GL_VERTEX_SHADER); GLuint tmp_fragmentShaderObject = glCreateShader(GL_FRAGMENT_SHADER); // attach shader source code to shader // https://stackoverflow.com/questions/6047527/how-to-convert-stdstring-to-const-char const char *c_str = tmp_vertexShaderSourceCode.c_str(); glShaderSource(tmp_vertexShaderObject,1,&c_str,NULL); c_str = tmp_fragmentShaderSourceCode.c_str(); glShaderSource(tmp_fragmentShaderObject,1,&c_str,NULL); glCompileShader(tmp_vertexShaderObject); glCompileShader(tmp_fragmentShaderObject); // now check for errors: CheckShader(tmp_vertexShaderObject); CheckShader(tmp_fragmentShaderObject); m_program = glCreateProgram(); glAttachShader(m_program,tmp_vertexShaderObject); glAttachShader(m_program,tmp_fragmentShaderObject); glLinkProgram(m_program); }
/*------------------------------------------------------------------------------- * 関数説明 * ベクトルを正規化する * 引数 * p_Vector :[I/ ] ベクトル * 戻り値 * 正常終了 :正規化されたベクトル * 異常終了 :全要素[0.0] *-------------------------------------------------------------------------------*/ vec3 Math::Normalize(const vec3 &p_Vector) { vec3 normalize = { 0.0f }; //正規化されたベクトル //計算しやすいように代入(誤差を少なくするために[double]で計算) double x = (double)(p_Vector.x); double y = (double)(p_Vector.y); double z = (double)(p_Vector.z); //引数チェック if (0.0 == x && 0.0 == y && 0.0 == z) { ERROR_MESSAGE("ベクトルを正規化 引数エラー ベクトルが[0]です。\n"); return normalize; } //ベクトルの長さを求める double length = sqrt(x * x + y * y + z * z); //正規化する length = 1.0 / length; x *= length; y *= length; z *= length; //戻り値を設定 normalize.x = (float)x; normalize.y = (float)y; normalize.z = (float)z; return normalize; }
node * PRTerror (node * arg_node, info * arg_info) { bool first_error; DBUG_ENTER ("PRTerror"); if (NODE_ERROR (arg_node) != NULL) { NODE_ERROR (arg_node) = TRAVdo (NODE_ERROR (arg_node), arg_info); } first_error = INFO_FIRSTERROR( arg_info); if( (global.outfile != NULL) && (ERROR_ANYPHASE( arg_node) == global.compiler_anyphase)) { if ( first_error) { printf ( "\n/******* BEGIN TREE CORRUPTION ********\n"); INFO_FIRSTERROR( arg_info) = FALSE; } printf ( "%s\n", ERROR_MESSAGE( arg_node)); if (ERROR_NEXT (arg_node) != NULL) { TRAVopt (ERROR_NEXT (arg_node), arg_info); } if ( first_error) { printf ( "******** END TREE CORRUPTION *******/\n"); INFO_FIRSTERROR( arg_info) = TRUE; } } DBUG_RETURN (arg_node); }
int TracebackLocalAlignment(const Matrix& matrix, const DP_BlockInfo *blocks, unsigned int queryFrom, unsigned int queryTo, DP_AlignmentResult **alignment) { if (!alignment) { ERROR_MESSAGE("TracebackLocalAlignment() - NULL alignment handle"); return STRUCT_DP_PARAMETER_ERROR; } *alignment = NULL; // find max score (e.g., best-scoring position of any block) int score = DP_NEGATIVE_INFINITY; unsigned int block, residue, lastBlock = 0, lastBlockPos = 0; for (block=0; block<blocks->nBlocks; ++block) { for (residue=queryFrom; residue<=queryTo; ++residue) { if (matrix[block][residue - queryFrom].score > score) { score = matrix[block][residue - queryFrom].score; lastBlock = block; lastBlockPos = residue; } } } if (score <= 0) { // INFO_MESSAGE("No positive-scoring local alignment found."); return STRUCT_DP_NO_ALIGNMENT; } // INFO_MESSAGE("Score of best local alignment: " << score); *alignment = new DP_AlignmentResult; return TracebackAlignment(matrix, lastBlock, lastBlockPos, queryFrom, *alignment); }
BLAST_Matrix * CreateBlastMatrix(const BlockMultipleAlignment *bma) { #ifdef DEBUG_PSSM {{ CNcbiOfstream ofs("psimsa.txt", IOS_BASE::out); }} #endif BLAST_Matrix *matrix = NULL; try { SU_PSSMInput input(bma); CPssmEngine engine(&input); CRef < CPssmWithParameters > pssm = engine.Run(); #ifdef DEBUG_PSSM CNcbiOfstream ofs("psimsa.txt", IOS_BASE::out | IOS_BASE::app); if (ofs) { CObjectOStreamAsn oosa(ofs, false); oosa << *pssm; } #endif matrix = ConvertPSSMToBLASTMatrix(*pssm); } catch (exception& e) { ERROR_MESSAGE("CreateBlastMatrix() failed with exception: " << e.what()); } return matrix; }
void Shader::CheckShader(GLuint n_shader) { GLint tmp_hasCompiled; glGetShaderiv(n_shader, GL_COMPILE_STATUS, &tmp_hasCompiled); if( !tmp_hasCompiled ) { // get length of info buffer GLint tmp_lengthOfInfoLog; glGetShaderiv(n_shader, GL_INFO_LOG_LENGTH, &tmp_lengthOfInfoLog ); // create temporary buffer for info log std::vector<char> tmp_logBuffer; tmp_logBuffer.resize(tmp_lengthOfInfoLog); // get the info log GLint tmp_finalLength; glGetShaderInfoLog(n_shader,tmp_lengthOfInfoLog,&tmp_finalLength,&tmp_logBuffer[0]); std::string tmp_finalLog(&tmp_logBuffer[0],tmp_finalLength); ERROR_MESSAGE(tmp_finalLog); throw std::string("failed to compile shader"); // TODO: find out the concrete error } }
void parse_block_map(BYTE *d, DEPLINT block_number) { DEPLINT array_size=0; DEPLINT i; segment_number_counter = 0; for (i = block_number + 1; i < (block_number+0x80); i += 2) { if ((d[i]==0x02)||(d[i+1]==0x02)) array_size++; } for (i = block_number + 1; i < (block_number+0x80); i += 2) { if ((d[i]==0x02)||(d[i+1]==0x02)) { segment_number[segment_number_counter] = (((i - block_number) + 1)/2); segment_number_counter++; } } segment_number[segment_number_counter] = 0; if (segment_number_counter != (array_size)) ERROR_MESSAGE("Error: Problem parsing block map"); segment_number_counter = 0; }
char LookupCharacterFromNCBIStdaaNumber(unsigned char n) { if (n < 28) return NCBIStdaaResidues[n]; ERROR_MESSAGE("LookupCharacterFromNCBIStdaaNumber() - valid values are 0 - 27"); return '?'; }
bool Interface::load_tex(const char *name, int idx) { char fn[MAX_PATH]; strcpy(fn, name); if (!strstr(name, ".png")) { strcat(fn, ".png"); } Stream *str = global.fs->open(fn); if ((str == NULL) || (str->getFileStreamHandle() == INVALID_HANDLE_VALUE)) { ERROR_MESSAGE("Interface: Doesn\'t load texture %s\n", fn); return false; } uint32_t sz = str->getSize(); char buf[sz]; str->read(buf, sz); delete str; bool ret = this->load_tex(buf, sz, idx); #ifdef SD_DEBUG if (ret) printf("Game: Texture %s loaded\n", fn); else { red_color(); printf("Game: Doesn\'t load texture %s\n", fn); normal_color(); } #endif return ret; }
unique_ptr<DFSM> loadFSM(string filename) { /* tr2::sys::path fn(filename); if (fn.extension().compare(".fsm") != 0) { ERROR_MESSAGE("FSMmodel::loadFSM - the extension of file %s is not '.fsm'", filename.c_str()); return nullptr; }*/ ifstream file(filename.c_str()); if (!file.is_open()) { ERROR_MESSAGE("FSMmodel::loadFSM - unable to open file %s", filename.c_str()); return nullptr; } machine_type_t type; file >> type; unique_ptr<DFSM> fsm; switch (type) { case TYPE_DFSM: fsm = move(make_unique<DFSM>()); break; case TYPE_MEALY: fsm = move(make_unique<Mealy>()); break; case TYPE_MOORE: fsm = move(make_unique<Moore>()); break; case TYPE_DFA: fsm = move(make_unique<DFA>()); break; default: return nullptr; } if (!fsm->load(filename)) return nullptr; return fsm; }
void BlackBoxDFSM::reset() { if (!_isResettable) { ERROR_MESSAGE("BlackBoxDFSM::reset - cannot be reset!"); return; } _resetCounter++; _currState = 0; }
void warn_at (location loc, const char *message, ...) { if (!(warnings_flag & warnings_other)) return; set_warning_issued (); ERROR_MESSAGE (&loc, _("warning"), message); }
void warn (const char *message, ...) { if (!(warnings_flag & warnings_other)) return; set_warning_issued (); ERROR_MESSAGE (NULL, _("warning"), message); }
void complain_at_indent (location loc, unsigned *indent, const char *message, ...) { indent_ptr = indent; ERROR_MESSAGE (&loc, NULL, message); complaint_issued = true; }
void midrule_value_at (location loc, const char *message, ...) { if (!(warnings_flag & warnings_midrule_values)) return; set_warning_issued (); ERROR_MESSAGE (&loc, _("warning"), message); }
void extended_nlist_pkt_handler (SAMPL_GATEWAY_PKT_T * gw_pkt) { char node_name[MAX_NODE_LEN]; char publisher_node_name[MAX_NODE_LEN]; uint8_t num_msgs, i; char timeStr[100]; time_t timestamp; int8_t rssi, ret; uint8_t t; if (gw_pkt->payload_len == 0) { if (debug_txt_flag) printf ("Malformed packet!\n"); return; } sprintf (publisher_node_name, "%02x%02x%02x%02x", gw_pkt->subnet_mac[2], gw_pkt->subnet_mac[1], gw_pkt->subnet_mac[0], gw_pkt->src_mac); if (debug_txt_flag == 1) printf ("Data for node: %s\n", publisher_node_name); // Check nodes and add them if need be if (xmpp_flag == 1) check_and_create_node (publisher_node_name); // publish XML data for node time (×tamp); strftime (timeStr, 100, "%Y-%m-%d %X", localtime (×tamp)); sprintf (buf, "<Node id=\"%s\" type=\"FIREFLY\" timestamp=\"%s\">", publisher_node_name, timeStr); num_msgs = gw_pkt->payload[0]; printf ("Extended Neighbor List %d:\n", num_msgs); if (gw_pkt->num_msgs > (MAX_PKT_PAYLOAD / NLIST_PKT_SIZE)) return; for (i = 0; i < num_msgs; i++) { sprintf (node_name, "%02x%02x%02x%02x", gw_pkt->payload[1 + i * 5], gw_pkt->payload[1 + i * 5 + 1], gw_pkt->payload[1 + i * 5 + 2], gw_pkt->payload[1 + i * 5 + 3]); rssi = (int8_t) gw_pkt->payload[1 + i * 5 + 4]; sprintf (&buf[strlen (buf)], "<Link linkNode=\"%s\" rssi=\"%d\"/>", node_name, rssi); } sprintf (&buf[strlen (buf)], "</Node>"); if (debug_txt_flag == 1) printf ("Publish: %s\n", buf); if (xmpp_flag == 1) ret = publish_to_node (connection, publisher_node_name, buf); if (xmpp_flag && ret != XMPP_NO_ERROR) printf ("XMPP Error: %s\n", ERROR_MESSAGE (ret)); if (debug_txt_flag == 1) printf ("Publish done\n"); }
void CKeyEditDlg::OnButtonWrite() { SRdkitKeyData keydata; BYTE bBuffer[KEY_DATA_SIZE]; CString strCaption,str; keydata.dwSize = sizeof(keydata); keydata.dwDataOffset = 0; keydata.dwDataSize = KEY_DATA_SIZE; keydata.pDataPtr = bBuffer; if(!GetPassword(keydata.pdwCustomerPassword)) { strCaption.LoadString(IDS_ERROR); str.LoadString(IDS_ERROR_INVALID_PASSWORD); MessageBox(str, strCaption, MB_OK|MB_ICONSTOP); return; } LPTSTR endptr; for(int i=0; i<KEY_DATA_SIZE; i++) { str = m_listKeyData.GetItemText(i,0); ULONG ulValue = _tcstoul(str, &endptr, 16); ASSERT(ulValue != ULONG_MAX); bBuffer[i] = BYTE(ulValue); } strCaption.LoadString(IDS_WRITE); str.LoadString(IDS_WRITE_SURE); if(MessageBox(str, strCaption, MB_YESNO|MB_ICONQUESTION) != IDYES) return; if(!RdkitWriteKeyData(&keydata)) { DWORD dwError = GetLastError(); strCaption.LoadString(IDS_ERROR); str.Format(IDS_ERROR_CANT_WRITE_KEY_DATA, ERROR_MESSAGE(dwError)); MessageBox(str, strCaption, MB_OK|MB_ICONSTOP); return; } // Clear dirty flags for(i=0; i<KEY_DATA_SIZE; i++) { m_listKeyData.SetItemData(i, false); } strCaption.LoadString(IDS_WRITE); str.LoadString(IDS_WRITE_SUCCESS); MessageBox(str, strCaption, MB_OK|MB_ICONINFORMATION); }
int tnd_perm(TWGraph *gr, int **_perm, int **_invp) { int err = 0; err = find_permutation(gr, _perm, _invp, 0); if ( err != ERROR_NO_ERROR ) ERROR_MESSAGE("tnd: find_permutation failed", err); return ERROR_NO_ERROR; }
void warn_at_indent (location loc, unsigned *indent, const char *message, ...) { if (!(warnings_flag & warnings_other)) return; set_warning_issued (); indent_ptr = indent; ERROR_MESSAGE (&loc, _("warning"), message); }
inline TCPConnection* TCPConnection_create (int descriptor) { assert(0 < descriptor); // The passed descriptor might have non-default socket options set. // Enforce blocking reads and writes. int flags = fcntl(descriptor, F_GETFL, 0); int status = fcntl(descriptor, F_SETFL, flags & ~O_NONBLOCK); report_zero_if(ERROR_MESSAGE("fcntl"), status < 0); // Ignore the SIGPIPE signal. int val = 1; setsockopt(descriptor, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof(int)); // Set TCP_NODELAY in hopes of having lower latency streaming. int flag = 1; int result = setsockopt(descriptor, /* socket descriptor */ IPPROTO_TCP, /* set option at TCP level */ TCP_NODELAY, /* name of option */ (char *) &flag, /* the cast is historical cruft */ sizeof(int)); /* length of option value */ report_zero_if(ERROR_MESSAGE("set TCP nodelay socket option"), result < 0); { struct timeval tv; tv.tv_sec = 2; tv.tv_usec = 0; result = setsockopt(descriptor, SOL_SOCKET, SO_RCVTIMEO, (char*) &tv, sizeof(struct timeval)); report_zero_if(ERROR_MESSAGE("set socket receive timeout"), result < 0); result = setsockopt(descriptor, SOL_SOCKET, SO_SNDTIMEO, (char*) &tv, sizeof(struct timeval)); report_zero_if(ERROR_MESSAGE("set socket send timeout"), result < 0); } return new BSDTCPConnection(descriptor); }