CContract::CContract(std::string contractname) { this->contractname = contractname; cout<<"contractname:"<<contractname<<"合约新建"<<endl; /*计算commodity*/ const char *first = contractname.c_str(); const char *last = first + strlen(first); /*gcc正则式支持不完全std::cmatch mr; std::regex rx("^[A-Za-z][A-Za-z][0-9]"); if(std::regex_match(first, last, mr, rx)) { std::string tempstr(first, 2); commodityname=tempstr; } else { std::string tempstr(first, 1); commodityname=tempstr; }*/ if(((first[1]>='a')&&(first[1]<='z'))||((first[1]>='A')&&(first[1]<='Z'))) { std::string tempstr(first, 2); commodityname=tempstr; } else { std::string tempstr(first, 1); commodityname=tempstr; } /*创建commodity对象*/ std::vector<CCommodity*>::iterator iter; CCommodity* findcommodity = NULL; for(iter=ssm_pcommodityvector.begin(); iter<ssm_pcommodityvector.end(); iter++) { if( (*iter)->commodityname == commodityname ) { findcommodity = *iter; } } if( findcommodity==NULL ) { findcommodity = SSMcreator.CreateCommodity(commodityname); ssm_pcommodityvector.push_back(findcommodity); } /*记录该品种所有的合约*/ commodity = findcommodity; if(std::find(commodity->contractvector.begin(),commodity->contractvector.end(),this) == commodity->contractvector.end()) { commodity->contractvector.push_back(this); } /*创建RTMarketdata对象*/ //if(tqm_prtmarketdatamap[contractname] != NULL) //{ marketdata = SSMcreator.CreateRTMarketData(contractname); //} ssm_prtmarketdatamap.insert( pair<std::string, CRTMarketData*>(contractname, marketdata) ); }
void FS_Init(const char *argv0) { int err = PHYSFS_init(argv0); if (err == 0) { Con_Errorf(ERR_FATAL, "Error in PHYSFS_init: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); return; } const char *baseDir = PHYSFS_getBaseDir(); fs_basepath = Con_GetVarDefault("fs.basepath", baseDir, CONVAR_STARTUP); fs_basegame = Con_GetVarDefault("fs.basegame", "base", CONVAR_STARTUP); fs_game = Con_GetVarDefault("fs.game", DEFAULT_GAME, CONVAR_STARTUP); bool modLoaded = fs_game->string[0] != '\0'; char **baseFiles, **gameFiles; // get the file listing for the basegame dir, then immediately unmount const char *fullBasePath = tempstr("%s/%s", fs_basepath->string, fs_basegame->string); PHYSFS_mount(fullBasePath, "/", 1); baseFiles = PHYSFS_enumerateFiles("/"); PHYSFS_removeFromSearchPath(fullBasePath); // if fs_game is set, do the same thing for the fs_game dir if (modLoaded) { const char *fullGamePath = tempstr("%s/%s", fs_basepath->string, fs_game->string); PHYSFS_mount(fullGamePath, "/", 1); gameFiles = PHYSFS_enumerateFiles("/"); PHYSFS_removeFromSearchPath(fullGamePath); // mount the mod dir first, then mount mod PK3s PHYSFS_mount(tempstr("%s/%s", fs_basepath->string, fs_game->string), "/", 1); FS_AddPaksFromList(gameFiles, fs_basepath->string, fs_game->string); PHYSFS_freeList(gameFiles); } // then mount the base game dir, then the mount base game PK3s PHYSFS_mount(tempstr("%s/%s", fs_basepath->string, fs_basegame->string), "/", 1); FS_AddPaksFromList(baseFiles, fs_basepath->string, fs_basegame->string); PHYSFS_freeList(baseFiles); // print all the files we've found in order of priority Con_Printf("Current filesystem search path:\n"); PHYSFS_getSearchPathCallback(printSearchPath, NULL); Con_Printf("\n"); // add command handler for dir to view virtual filesystem Con_AddCommand("dir", Cmd_Dir_f); }
void* sending (void * callerobj){ std::cout<<"sending thread online"<<std::endl; static const float nonstricttimeoutseconds=ACKTIMEOUTSECONDS; sender* senderobj = reinterpret_cast<sender*>(callerobj); if ( senderobj != nullptr ) { while ( senderobj->isSending || !senderobj->bufferIsEmpty()){ for(int i=0;i<senderobj->windowsize;i++){ int j = (senderobj->windowposition + i)%(senderobj->bufsize_sender); if (senderobj->buffered[j]) if (!senderobj->sent[j]){ size_t sentBytes; //kirim salah atau benar if (rand()%100<PROBSALAHPERCENT){ std::string tempstr (senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength()); tempstr[rand()%tempstr.length()]++; sentBytes=sendto(senderobj->s, tempstr.c_str(),tempstr.length(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other)); }else{ sentBytes=sendto(senderobj->s, senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other)); } senderobj->sent[j] = true; senderobj->timesent[j]=clock(); std::cout<<"sent frame "<<senderobj->buffer[j].getFrameNumber()<<std::endl; } else if (senderobj->sent[j] && !senderobj->acked[j] && (float(clock()-senderobj->timesent[j]))/CLOCKS_PER_SEC>nonstricttimeoutseconds){//tidak menerima ack atau menerima nak setelah timeout size_t sentBytes; //kirim salah atau benar if (rand()%100<PROBSALAHPERCENT){ std::string tempstr (senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength()); tempstr[rand()%tempstr.length()]++; sentBytes=sendto(senderobj->s, tempstr.c_str(),tempstr.length(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other)); }else{ sentBytes=sendto(senderobj->s, senderobj->buffer[j].getPointerToBytes(),senderobj->buffer[j].getBytesLength(),0,(struct sockaddr*) &senderobj->si_other ,sizeof(senderobj->si_other)); } senderobj->sent[j] = true; senderobj->timesent[j]=clock(); std::cout<<"timeout, retry, sent frame "<<senderobj->buffer[j].getFrameNumber()<<std::endl; } else if (j==senderobj->windowposition && senderobj->sent[j] && senderobj->acked[j]){ senderobj->geserJendela(1); senderobj->sent[j]=false; senderobj->acked[j]=false; senderobj->buffered[j]=false; } } } } std::cout<<"sending thread offline"<<std::endl; std::cout<<getReal(status)<<std::endl; }
Statement DB::Prepare(const std::string &sql) { if(IsOpen()) { sqlite3_stmt *statement=NULL; m_lastresult=sqlite3_prepare_v2(m_db,sql.c_str(),sql.size(),&statement,NULL); #ifdef QUERY_LOG size_t temp=reinterpret_cast<size_t>(statement); std::string tempstr(""); StringFunctions::Convert(temp,tempstr); Poco::Logger::get("querylog").information("Prepare : "+sql+" "+tempstr); #endif if(m_lastresult==SQLITE_OK) { return Statement(statement,this); } else { std::string errmsg(""); int err=GetLastExtendedError(errmsg); HandleError(err,errmsg,"DB::Prepare"); return Statement(); } } else { return Statement(); } }
char const *ip_addr_2_strv6(struct ip_addr const *addr) { if (ip_addr_is_v6(addr)) return ip_addr_2_str(addr); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "::ffff:%"PRINIPQUAD, NIPQUAD(&addr->u.v4)); return str; }
static char const *udp_info_2_str(struct proto_info const *info_) { struct udp_proto_info const *info = DOWNCAST(info_, info, udp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, ports=%"PRIu16"->%"PRIu16, proto_info_2_str(info_), info->key.port[0], info->key.port[1]); return str; }
static char const *via_2_str(struct sip_via const *via) { char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s %s:%"PRIu16, via_protocol_2_str(via->protocol), ip_addr_2_str(&via->addr), via->port); return str; }
static char const *rtp_info_2_str(struct proto_info const *info_) { struct rtp_proto_info const *info = DOWNCAST(info_, info, rtp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, payload_type=%s, SSRC=%"PRIu32", seqnum=%"PRIu16", timestamp=%"PRIu32, proto_info_2_str(info_), rtp_payload_type_2_str(info->payload_type), info->sync_src, info->seq_num, info->timestamp); return str; }
static char const *cap_info_2_str(struct proto_info const *info_) { struct cap_proto_info const *info = DOWNCAST(info_, info, cap_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, dev_id=%u, tv=%s", proto_info_2_str(info_), info->dev_id, timeval_2_str(&info->tv)); return str; }
char const *eth_addr_2_str(unsigned char const addr[ETH_ADDR_LEN]) { char *str = tempstr(); size_t len = 0; unsigned i; for (i = 0; i < ETH_ADDR_LEN; i ++) { len += snprintf(str+len, TEMPSTR_SIZE-len, "%s%.02x", len > 0 ? ":":"", addr[i]); } return str; }
static char const *fcoe_info_2_str(struct proto_info const *info_) { struct fcoe_proto_info *info = DOWNCAST(info_, info, fcoe_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, version=%d, sof=0x%02x, eof=0x%02x", proto_info_2_str(info_), info->version, info->sof, info->eof); return str; }
static char const *icmp_info_2_str(struct proto_info const *info_) { struct icmp_proto_info const *info = DOWNCAST(info_, info, icmp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, type=%s, err=%s", proto_info_2_str(info_), icmp_type_2_str(info->type, info->code), info->set_values & ICMP_ERR_SET ? icmp_err_2_str(&info->err, info->set_values) : "NONE"); return str; }
char *icmp_err_2_str(struct icmp_err const *err, unsigned set_values) { char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "protocol=%"PRIu8", src=%s:%"PRIu16", dst=%s:%"PRIu16, err->protocol, ip_addr_2_str(err->addr+0), set_values & ICMP_ERR_PORT_SET ? err->port[0] : 0, ip_addr_2_str(err->addr+1), set_values & ICMP_ERR_PORT_SET ? err->port[1] : 0); return str; }
char const *ip_addr_2_str(struct ip_addr const *addr) { if (! addr) return "null"; char *str = tempstr(); if (NULL == inet_ntop(addr->family, &addr->u, str, TEMPSTR_SIZE)) { SLOG(LOG_ERR, "Cannot inet_ntop(): %s", strerror(errno)); return "INVALID"; } return str; }
char const *tds_info_2_str(struct proto_info const *info_) { struct tds_proto_info const *info = DOWNCAST(info_, info, tds_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, type=%s, status=0x%x, length=%"PRIu16"", proto_info_2_str(info_), tds_packet_type_2_str(info->type), info->status, info->length); return str; }
static char const *sdp_info_2_str(struct proto_info const *info_) { struct sdp_proto_info const *info = DOWNCAST(info_, info, sdp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, host=%s, port=%s", proto_info_2_str(info_), info->set_values & SDP_HOST_SET ? ip_addr_2_str(&info->host) : "unset", info->set_values & SDP_PORT_SET ? tempstr_printf("%u", info->port) : "unset"); return str; }
// Not the same than ICMP(v4) since the error codes are different. static char const *icmpv6_info_2_str(struct proto_info const *info_) { struct icmp_proto_info const *info = DOWNCAST(info_, info, icmp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, type=%s, code=%"PRIu8", err=%s, id=%d", proto_info_2_str(info_), icmpv6_type_2_str(info->type), info->code, info->set_values & ICMP_ERR_SET ? icmp_err_2_str(&info->err, info->set_values) : "NONE", info->set_values & ICMP_ID_SET ? info->id : -1); return str; }
static char const *eth_info_2_str(struct proto_info const *info_) { struct eth_proto_info const *info = DOWNCAST(info_, info, eth_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, vlan_id=%d, source=%s, dest=%s, proto=%s", proto_info_2_str(info_), info->vlan_id, eth_addr_2_str(info->addr[0]), eth_addr_2_str(info->addr[1]), eth_proto_2_str(info->protocol)); return str; }
void MsgDialog::setButton(MyButton* but, bool active) { if (active) { if (-1 != m_nEditItem) m_pMenu->removeItem(m_nEditItem); QString tempstr(""); tempstr.sprintf("&Edit '%s'", but->name().ascii()); m_nEditItem = m_pMenu->insertItem(tempstr, this, SLOT(editButton())); m_pButtonOver = but; } }
static char const *tcp_options_2_str(struct tcp_proto_info const *info) { char *tmp = tempstr(); char *t = tmp; for (unsigned o = 0; o < info->nb_options; o++) { switch (info->options[o]) { case 0: t += snprintf(t, TEMPSTR_SIZE - (t-tmp), ",end"); break; case 1: t += snprintf(t, TEMPSTR_SIZE - (t-tmp), ",nop"); break; case 2: t += snprintf(t, TEMPSTR_SIZE - (t-tmp), ",MSS(%"PRIu16")", info->mss); break; case 3: t += snprintf(t, TEMPSTR_SIZE - (t-tmp), ",WSF(%"PRIu8")", info->wsf); break; default: t += snprintf(t, TEMPSTR_SIZE - (t-tmp), ",%"PRIu8, info->options[o]); break; } } return t > tmp ? tmp+1 : "none"; // skip the initial ',' }
static char const *dhcp_info_2_str(struct proto_info const *info_) { struct dhcp_proto_info const *info = DOWNCAST(info_, info, dhcp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, opcode=%s, msg_type=%s, xid=0x%x, client_ip=%s, client_mac=%s, server=%s", proto_info_2_str(info_), dhcp_opcode_2_str(info->opcode), dhcp_msg_type_2_str(info->msg_type), info->xid, info->set_values & DHCP_CLIENT_SET ? ip_addr_2_str(&info->client) : "unset", info->hw_addr_is_eth ? eth_addr_2_str(info->client_mac) : "not eth", info->server_name[0] != '\0' ? info->server_name : "unset"); return str; }
void FS_AddPaksFromList(char **list, const char *basePath, const char *gamePath) { static const char *archiveExt = "pk3"; size_t extlen = strlen(archiveExt); char **i; char *ext; for (i = list; *i != NULL; i++) { size_t l = strlen(*i); if ((l > extlen) && ((*i)[l - extlen - 1] == '.')) { ext = (*i) + (l - extlen); if (strcasecmp(ext, archiveExt) == 0) { PHYSFS_mount(tempstr("%s/%s/%s", basePath, gamePath, *i), "/", 1); } } } }
enum proto_parse_status cursor_read_fixed_string(struct cursor *cursor, char **out_str, size_t str_len) { SLOG(LOG_DEBUG, "Reading string of size %zu", str_len); if (cursor->cap_len < str_len) return PROTO_PARSE_ERR; if (!out_str) { cursor_drop(cursor, str_len); return PROTO_OK; } char *str = tempstr(); unsigned copied_len = MIN(str_len, TEMPSTR_SIZE - 1); cursor_copy(str, cursor, copied_len); str[copied_len] = '\0'; if (copied_len < str_len) { cursor_drop(cursor, str_len - copied_len); } if(out_str) *out_str = str; return PROTO_OK; }
static char const *sip_info_2_str(struct proto_info const *info_) { struct sip_proto_info const *info = DOWNCAST(info_, info, sip_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, cmd=%s, cseq=%s, via=%s, code=%s, mime_type=%s, content-length=%s, call-id=%s, from=%s, to=%s", proto_info_2_str(info_), info->set_values & SIP_CMD_SET ? sip_cmd_2_str(info->cmd) : "unset", info->set_values & SIP_CSEQ_SET ? tempstr_printf("%lu", info->cseq) : "unset", info->set_values & SIP_VIA_SET ? via_2_str(&info->via) : "unset", info->set_values & SIP_CODE_SET ? tempstr_printf("%u", info->code) : "unset", info->set_values & SIP_MIME_SET ? info->mime_type : "unset", info->set_values & SIP_LENGTH_SET ? tempstr_printf("%u", info->content_length) : "unset", info->set_values & SIP_CALLID_SET ? info->call_id : "unset", info->set_values & SIP_FROM_SET ? info->from : "unset", info->set_values & SIP_TO_SET ? info->to : "unset"); return str; }
void Text::Draw(Gdiplus::Bitmap *buffer, Gdiplus::Graphics *graphics) { int units = CalcUnits(); Gdiplus::RectF layoutRect((float) _rect.X, (float) _rect.Y, (float) _rect.Width, (float) _rect.Height); graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintAntiAlias); wchar_t perc[4]; _itow_s(units * (100 / _units), perc, 10); std::wstring tempstr(_formatString); const wchar_t *str = tempstr.replace(_replaceIndex, 8, perc).c_str(); graphics->DrawString(str, -1, _font, layoutRect, &_strFormat, _fontColor); UpdateDrawnValues(); }
enum proto_parse_status cursor_read_string(struct cursor *cursor, char **out_str, size_t max_len) { char *str = tempstr(); unsigned len; if (max_len > TEMPSTR_SIZE-1) max_len = TEMPSTR_SIZE-1; for (len = 0; len < max_len; len ++) { CHECK_LEN(cursor, 1, len); uint8_t c = cursor_read_u8(cursor); if (c == '\0') break; str[len] = c; } if (len == max_len) { cursor_rollback(cursor, len); return PROTO_TOO_SHORT; } str[len] = '\0'; SLOG(LOG_DEBUG, "Reading string '%s' of size %u", str, len); if (out_str) *out_str = str; return PROTO_OK; }
/* Read a string splitted in chunk prefixed by 1 byte size * Chunk have a maximum size of 0x40 bytes * If there are more than one chunk, a 0x00 end it * * a multi chunked string * * Size String--------- Size String End * 0x40 0x41 0x42 0x.. 0x01 0x49 0x00 * * a single chunked string * * Size String--------- * 0x20 0x41 0x42 0x.. * * The global size might be unknown, so we try to guess it. We will have a parse problem * for string of size 0x40 */ static enum proto_parse_status cursor_read_chunked_string(struct cursor *cursor, char **out_str, size_t max_chunk) { char *str = tempstr(); unsigned pos = 0; while (pos < TEMPSTR_SIZE) { CHECK(1); unsigned str_len = cursor_read_u8(cursor); SLOG(LOG_DEBUG, "Chunk of size of %u", str_len); CHECK(str_len); size_t copied_len = MIN(TEMPSTR_SIZE - (pos + str_len + 1), str_len); cursor_copy(str + pos, cursor, copied_len); pos += str_len; if (str_len < max_chunk) break; } // There seems to be an null terminator when string length is > 0x40 // However, it can be a flag after the string. Ignore it for now. if (out_str) *out_str = str; str[MIN(pos, TEMPSTR_SIZE)] = 0; SLOG(LOG_DEBUG, "Chunk parsed of size %u", pos); return PROTO_OK; }
static char const *tcp_info_2_str(struct proto_info const *info_) { struct tcp_proto_info const *info = DOWNCAST(info_, info, tcp_proto_info); char *str = tempstr(); snprintf(str, TEMPSTR_SIZE, "%s, ports=%"PRIu16"%s->%"PRIu16"%s, flags=%s%s%s%s%s%s, win=%"PRIu16", ack=%"PRIu32", seq=%"PRIu32" (%"PRIu32"), urg=%"PRIx16", opts=%s", proto_info_2_str(info_), info->key.port[0], info->to_srv ? "":"(srv)", info->key.port[1], info->to_srv ? "(srv)":"", info->syn ? "Syn":"", info->ack ? "Ack":"", info->rst ? "Rst":"", info->fin ? "Fin":"", info->urg ? "Urg":"", info->psh ? "Psh":"", info->window, info->ack_num, info->seq_num, info->rel_seq_num, info->urg_ptr, tcp_options_2_str(info)); return str; }
char const *sql_info_2_str(struct proto_info const *info_) { struct sql_proto_info const *info = DOWNCAST(info_, info, sql_proto_info); char *str = tempstr(); char const *(*spec_info_2_str)(struct sql_proto_info const *) = NULL; switch (info->msg_type) { case SQL_UNKNOWN: break; case SQL_STARTUP: spec_info_2_str = info->is_query ? startup_query_2_str : startup_reply_2_str; break; case SQL_QUERY: spec_info_2_str = info->is_query ? query_query_2_str : query_reply_2_str; break; case SQL_EXIT: spec_info_2_str = exit_2_str; break; } snprintf(str, TEMPSTR_SIZE, "%s, %s%s, %s%s%s%s%s%s%s%s%s%s", proto_info_2_str(info_), info->is_query ? "Clt->Srv" : "Srv->Clt", version_info_2_str(info), sql_msg_type_2_str(info->msg_type), spec_info_2_str ? spec_info_2_str(info) : "", info->set_values & SQL_REQUEST_STATUS ? ", Status=" : "", info->set_values & SQL_REQUEST_STATUS ? sql_request_status_2_str(info->request_status) : "", info->set_values & SQL_ERROR_SQL_STATUS ? ", SqlCode=" : "", info->set_values & SQL_ERROR_SQL_STATUS ? info->error_sql_status : "", info->set_values & SQL_ERROR_CODE ? ", ErrorCode=" : "", info->set_values & SQL_ERROR_CODE ? info->error_code : "", info->set_values & SQL_ERROR_MESSAGE ? ", ErrorMessage=" : "", info->set_values & SQL_ERROR_MESSAGE ? info->error_message : ""); return str; }
static enum proto_parse_status tns_parse_end(struct sql_proto_info *info, struct cursor *cursor) { SLOG(LOG_DEBUG, "Parsing tns end packet"); enum proto_parse_status status; uint_least64_t var[6]; for (unsigned i = 0; i < 6; i++) { if (PROTO_OK != (status = cursor_read_variable_int(cursor, var + i))) return status; } uint_least64_t nb_rows; uint_least64_t error_code; // let's use the double 0x00 to guess the position of row number and error code if (var[0] > 0 && var[4] == 0 && var[5] == 0) { // var[0] is unknown? // var[1] == sequence // var[2] == rows // var[3] == error code SLOG(LOG_DEBUG, "Unknown bits after ttc code"); nb_rows = var[2]; error_code = var[3]; DROP_VAR(cursor); } else if (var[3] == 0 && var[4] == 0) { // var[0] == sequence // var[1] == rows // var[2] == error code nb_rows = var[1]; error_code = var[2]; } else { // var[0] == rows // var[1] == error code nb_rows = var[0]; error_code = var[1]; } if (info->msg_type == SQL_QUERY) { sql_set_row_count(info, nb_rows); SLOG(LOG_DEBUG, "Nb rows %d", info->u.query.nb_rows); } SLOG(LOG_DEBUG, "Error code is %zu", error_code); DROP_VARS(cursor, 1); DROP_FIX(cursor, 2); DROP_VARS(cursor, 2); DROP_FIX(cursor, 2); DROP_VARS(cursor, 2); DROP_FIX(cursor, 1); DROP_VARS(cursor, 3); if (error_code != 0) { SLOG(LOG_DEBUG, "Parsing error message"); char *error_msg = tempstr(); unsigned error_len; // Drop an unknown number of bytes here while(cursor->cap_len > 2 && (cursor_peek_u8(cursor, 0) == 0 || !is_print(cursor_peek_u8(cursor, 1)))){ DROP_FIX(cursor, 1); } SLOG(LOG_DEBUG, "First printable char is %c", cursor_peek_u8(cursor, 1)); status = cursor_read_variable_string(cursor, error_msg, TEMPSTR_SIZE, &error_len); if (status != PROTO_OK) return status; if (error_len < 12) return PROTO_PARSE_ERR; // Split "ORA-XXXX: msg" // Part before : is the error code // Part after is the localized message char *colon_pos = memchr(error_msg, ':', error_len); sql_set_request_status(info, SQL_REQUEST_ERROR); if (colon_pos) { // We extract the error code unsigned error_code_size = colon_pos - error_msg; int size_err = MIN(error_code_size, sizeof(info->error_code)); memcpy(info->error_code, error_msg, size_err); info->error_code[size_err] = '\0'; info->set_values |= SQL_ERROR_CODE; if (0 == strcmp("ORA-01403", info->error_code)) info->request_status = SQL_REQUEST_COMPLETE; // We skip ':' in errror message char const *start_message = colon_pos + 1; // We skip spaces before errror message while (start_message < error_len + error_msg && *start_message == ' ') start_message++; copy_string(info->error_message, start_message, sizeof(info->error_message)); info->set_values |= SQL_ERROR_MESSAGE; } else { copy_string(info->error_message, error_msg, sizeof(info->error_message)); info->set_values |= SQL_ERROR_MESSAGE; } } return PROTO_OK; }