unsigned int ma_ssl_get_finger_print(MARIADB_SSL *cssl, unsigned char *fp, unsigned int len) { MYSQL *mysql; size_t fp_len= len; const gnutls_datum_t *cert_list; unsigned int cert_list_size; if (!cssl || !cssl->ssl) return 0; mysql= (MYSQL *)gnutls_session_get_ptr(cssl->ssl); cert_list = gnutls_certificate_get_peers (cssl->ssl, &cert_list_size); if (cert_list == NULL) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Unable to get server certificate"); return 0; } if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &cert_list[0], fp, &fp_len) == 0) return fp_len; else { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Finger print buffer too small"); return 0; } }
/* SSL error handling */ static void my_SSL_error(MYSQL *mysql) { ulong ssl_errno= ERR_get_error(); char ssl_error[MAX_SSL_ERR_LEN]; const char *ssl_error_reason; DBUG_ENTER("my_SSL_error"); if (mysql_errno(mysql)) DBUG_VOID_RETURN; if (!ssl_errno) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, "Unknown SSL error"); DBUG_VOID_RETURN; } if ((ssl_error_reason= ERR_reason_error_string(ssl_errno))) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), ssl_error_reason); DBUG_VOID_RETURN; } my_snprintf(ssl_error, MAX_SSL_ERR_LEN, "SSL errno=%lu", ssl_errno, mysql->charset); my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), ssl_error); DBUG_VOID_RETURN; }
tryhide() { #ifdef HAS_COM register nodep hidenode; register nodep wheretopatch; if(is_a_revorhide(cursparent) ) cursor = cursparent; grab_range(R_FORCE|R_FLIST); if( c_at_root(sel_node)) { error( ER(10,"hideprogram`Can't hide the whole program") ); } wheretopatch = node_kid(sel_node,sel_first); if( !(ntype_info(ntype(wheretopatch)) & F_LINE ) ) error( ER(11,"badhide`You must select at least a whole line for hiding") ); if( sel_first == sel_last && is_a_revorhide(wheretopatch) ) { change_ntype(wheretopatch, N_HIDE); cursor = wheretopatch; } else { hidenode = l_lower(N_HIDE, 1); cursor = kid1(hidenode); /* the hide comment */ } #endif HAS_COM }
static error bignum_monty_modmul_alias(bignum *r, const bignum *a, const bignum *b, const bignum *p, const monty_ctx *monty) { BIGNUM_TMP(rt); ER(bignum_monty_modmul_noalias(&rt, a, b, p, monty)); ER(bignum_dup(r, &rt)); return OK; }
error monty_normalise_n(bignum *xR, const bignum *x, const bignum *m, size_t R_shift) { BIGNUM_TMP(tmp); ER(bignum_dup(&tmp, x)); ER(bignum_shl(&tmp, R_shift)); ER(bignum_mod(xR, &tmp, m)); return OK; }
static error bignum_monty_modmul_normalised_reduce(bignum *A, const bignum *x, const bignum *y, const bignum *m, const monty_ctx *monty) { BIGNUM_TMP(rx); BIGNUM_TMP(ry); ER(bignum_mod(&rx, x, m)); ER(bignum_mod(&ry, y, m)); return bignum_monty_modmul_normalised(A, &rx, &ry, m, monty); }
static int bug_conc1(MYSQL *mysql) { mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0); FAIL_IF(mysql_errno(mysql) != CR_ALREADY_CONNECTED, "Expected errno=CR_ALREADY_CONNECTED"); FAIL_IF(strcmp(mysql_error(mysql), ER(CR_ALREADY_CONNECTED)) != 0, "Wrong error message"); FAIL_IF(strcmp(ER(CR_ALREADY_CONNECTED), "Can't connect twice. Already connected") != 0, "wrong error message"); return OK; }
uint8_t kdnet_driver_processInterruptPacketSent() { uint8_t st1, st2; ER(rfm69ReadRegister(RFM69_IRQFLAGS1, &st1)); ER(rfm69ReadRegister(RFM69_IRQFLAGS2, &st2)); if (st2 & RFM69_IRQFLAGS2_PACKETSENT) { ER(kdnet_cb_onPacketSent()); } return KDNET_SUCCESS; }
void QuasiNewton<double>::reconstructSolution(const int NTrial){ RealCMMap XTSigmaR (this->XTSigmaRMem,NTrial, NTrial); RealCMMap UR (this->URMem, this->N_,NTrial); RealCMMap TrialVecR(this->TVecRMem, this->N_,NTrial); RealCMMap XTRhoR (this->XTRhoRMem, 0,0); RealCMMap XTSigmaL (this->XTSigmaLMem,0,0); RealCMMap XTRhoL (this->XTRhoLMem, 0,0); RealCMMap UL (this->ULMem, 0,0); RealCMMap TrialVecL(this->TVecLMem, 0,0); RealVecMap ER(this->ERMem,NTrial); if(!this->isHermitian_ || this->symmetrizedTrial_){ new (&XTRhoR ) RealCMMap(this->XTRhoRMem, NTrial, NTrial); new (&XTSigmaL ) RealCMMap(this->XTSigmaLMem,NTrial, NTrial); new (&XTRhoL ) RealCMMap(this->XTRhoLMem, NTrial, NTrial); new (&UL ) RealCMMap(this->ULMem, this->N_,NTrial); new (&TrialVecL) RealCMMap(this->TVecLMem, this->N_,NTrial); } UR = TrialVecR * XTSigmaR; if(this->symmetrizedTrial_) UL = TrialVecL * XTSigmaL; // Stash away current approximation of eigenvalues and eigenvectors (NSek) (*this->solutionValues_) = ER.block(0,0,nSek_,1); (*this->solutionVector_) = UR.block(0,0,N_,nSek_); // | X > = | X_g > + | X_u > (viz. Kauczor et al. JCTC 7 (2010) p. 1610 (Eq 80)) if(this->symmetrizedTrial_)(*solutionVector_) += UL.block(0,0,N_,nSek_); } // reconstructSolution
/* 20150820.085950 */ SR( SCCBH, sel_cb2_node, duf_sccb_handle_t * sccbh, duf_stmnt_t * pstmt_arg, duf_str_cb2s_t str_cb2, duf_scanstage_t scanstage ) { assert( H_PDI ); assert( CRX( pdi_depth, H_PDI ) >= 0 ); assert( CRX( pdi_depth, H_PDI ) == CRX( levinfo_calc_depth, H_PDI ) ); /* data from db at pstmt_arg */ MAST_TRACE( scan, 10, " " DUF_DEPTH_PFMT ": =====> scan node2", CRX( pdi_depth, H_PDI ) ); MAST_TRACE( explain, 40, "@ sel cb2 node" ); assert( str_cb2 == duf_sccbh_eval_all || str_cb2 == NULL ); MAST_TRACE( scan, 6, "NODE %s", CRX( levinfo_path, H_PDI ) ); { /*@ 1. go down + dbopenat */ assert( pstmt_arg == duf_pdi_each_stmt( H_PDI, 0 ) ); CR( sccbh_pstmt_godown_dbopenat_dh, sccbh, pstmt_arg, DUF_NODE_NODE /* node_type */ ); assert( QISERR_N( TOO_DEEP ) || pstmt_arg == duf_pdi_each_stmt( H_PDI, 1 ) ); if ( QNOERR ) { MAST_TRACE( scan, 6, "(%s) NODE down %s", QERRNAME, CRX( levinfo_path, H_PDI ) ); assert( CRX( pdi_depth, H_PDI ) >= 0 ); CR( sel_cb2_node_at, sccbh, /* pstmt_arg, */ str_cb2, scanstage ); assert( CRX( pdi_depth, H_PDI ) == CRX( levinfo_calc_depth, H_PDI ) ); CR( levinfo_goup, H_PDI ); } } MAST_TRACE( scan, 6, "/NODE %s", CRX( levinfo_path, H_PDI ) ); ER( SCCBH, sel_cb2_node, duf_sccb_handle_t * sccbh, duf_stmnt_t * pstmt_arg, duf_str_cb2s_t str_cb2, duf_scanstage_t scanstage ); }
void cm_set_error (T_CM_ERROR * err_buf, int err_code) { err_buf->err_code = err_code; snprintf (err_buf->err_msg, sizeof (err_buf->err_msg) - 1, ER (err_buf->err_code)); }
error bignum_mulw(bignum *r, const bignum *a, uint32_t b) { if (b == 0) { bignum_set(r, 0); return OK; } else if (b == 1) { return bignum_dup(r, a); } assert(!bignum_check_mutable(r)); assert(!bignum_check(a)); assert(r != a); uint8_t sza = bignum_len_bits(a); uint8_t szb = bignum_math_uint32_fls(b); if (bignum_capacity_bits(r) < sza + szb) return error_bignum_sz; size_t words = bignum_len_words(a); bignum_set(r, 0); ER(bignum_cleartop(r, words + 1)); bignum_math_mul_accum(r->v, a->v, words, b); bignum_canon(r); return OK; }
/* delete level-control array, close 0 level */ SR( PDI, levinfo_delete, duf_depthinfo_t * pdi ) { assert( pdi ); /* assert( pdi->pathinfo.levinfo ); */ assert( pdi->pathinfo.depth == duf_levinfo_calc_depth( pdi ) ); if ( duf_pdi_levinfo( pdi ) /* pdi->pathinfo.levinfo */ ) { #if 0 while ( QNOERR && duf_pdi_depth( pdi ) /* pdi->pathinfo.depth */ >= 0 ) { assert( pdi->pathinfo.depth == duf_levinfo_calc_depth( pdi ) ); CRX( levinfo_goup, pdi ); } assert( duf_levinfo_closed( pdi ) ); assert( pdi->pathinfo.depth == -1 ); #else CRX( levinfo_gotop, pdi ); #endif mas_free( pdi->pathinfo.levinfo ); pdi->pathinfo.levinfo = NULL; } ER( PDI, levinfo_delete, duf_depthinfo_t * pdi ); }
void GEMENI_charsent() { unsigned long r = s->log[s->lc]; if (UCA0IFG & UCTXIFG) { s->nch++; switch (s->nch) { case 1: UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r); break; case 2: UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3; break; case 3: UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r); break; case 4: UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r); break; case 5: UCA0TXBUF = POUND(r)<<1 | ZRS(r); break; default: s->lc++; if (s->lc != s->nc-1) { s->nch = 0; UCA0TXBUF = 1 << 7; // first packet, no fn or '#' } else { s->flags &= ~CSEND; } } } }
error bignum_slow_modexp(bignum *r, const bignum *a, const bignum *b, const bignum *p) { BIGNUM_TMP(S); ER(bignum_dup(&S, a)); bignum_setu(r, 1); for (size_t i = 0; i < bignum_len_bits(b); i++) { if (bignum_get_bit(b, i) == 1) { ER(bignum_modmul(r, r, &S, p)); } ER(bignum_modmul(&S, &S, &S, p)); } return OK; }
static int client_mpvio_write_packet(struct st_plugin_vio *mpv, const uchar *pkt, size_t pkt_len) { int res; MCPVIO_EXT *mpvio= (MCPVIO_EXT*)mpv; if (mpvio->packets_written == 0) { if (mpvio->mysql_change_user) res= send_change_user_packet(mpvio, pkt, (int)pkt_len); else res= send_client_reply_packet(mpvio, pkt, (int)pkt_len); } else { NET *net= &mpvio->mysql->net; if (mpvio->mysql->thd) res= 1; /* no chit-chat in embedded */ else res= my_net_write(net, (char *)pkt, pkt_len) || net_flush(net); if (res) my_set_error(mpvio->mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, ER(CR_SERVER_LOST_EXTENDED), "sending authentication information", errno); } mpvio->packets_written++; return res; }
/* establish SSL connection between client and server SYNOPSIS my_ssl_connect ssl ssl object RETURN VALUES 0 success 1 error */ int my_ssl_connect(SSL *ssl) { my_bool blocking; MYSQL *mysql; long rc; my_bool try_connect= 1; DBUG_ENTER("my_ssl_connect"); DBUG_ASSERT(ssl != NULL); mysql= (MYSQL *)SSL_get_app_data(ssl); CLEAR_CLIENT_ERROR(mysql); /* Set socket to non blocking */ if (!(blocking= vio_is_blocking(mysql->net.vio))) vio_blocking(mysql->net.vio, FALSE, 0); SSL_clear(ssl); SSL_SESSION_set_timeout(SSL_get_session(ssl), mysql->options.connect_timeout); SSL_set_fd(ssl, mysql->net.vio->sd); while (try_connect && (rc= SSL_connect(ssl)) == -1) { switch(SSL_get_error(ssl, rc)) { case SSL_ERROR_WANT_READ: if (vio_wait_or_timeout(mysql->net.vio, TRUE, mysql->options.connect_timeout) < 1) try_connect= 0; break; case SSL_ERROR_WANT_WRITE: if (vio_wait_or_timeout(mysql->net.vio, TRUE, mysql->options.connect_timeout) < 1) try_connect= 0; break; default: try_connect= 0; } } if (rc != 1) { my_SSL_error(mysql); DBUG_RETURN(1); } rc= SSL_get_verify_result(ssl); if (rc != X509_V_OK) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), X509_verify_cert_error_string(rc)); /* restore blocking mode */ if (!blocking) vio_blocking(mysql->net.vio, FALSE, 0); DBUG_RETURN(1); } vio_reset(mysql->net.vio, VIO_TYPE_SSL, mysql->net.vio->sd, 0, 0); mysql->net.vio->ssl= ssl; DBUG_RETURN(0); }
uint8_t kdnet_driver_readPayload(uint8_t* data, uint16_t* len) { // *len = kdnet_driver_getMaxPayloadLength(); uint8_t len2; ER(rfm69ReadPayloadVarLen(data, &len2)); *len = len2; return KDNET_SUCCESS; }
SR( PDI, levinfo_set_li, duf_depthinfo_t * pdi, duf_levinfo_t * pli, size_t maxdepth ) { CR( levinfo_gotop, pdi ); assert( duf_levinfo_closed( pdi ) ); CR( pi_levinfo_set, duf_pdi_pathinfo_p( pdi ) /* &pdi->pathinfo */ , pli, maxdepth ); ER( PDI, levinfo_set_li, duf_depthinfo_t * pdi, duf_levinfo_t * pli, size_t maxdepth ); }
error bignum_monty_sqr_normalised(bignum *A, const bignum *x, const bignum *m, const monty_ctx *monty) { BIGNUM_TMP(r); ER(bignum_monty_modmul_normalised(&r, x, x, m, monty)); return bignum_dup(A, &r); (void) bignum_monty_reduce; }
void QuasiNewton<double>::symmNonHerDiag(int NTrial, ostream &output){ char JOBVL = 'N'; char JOBVR = 'V'; int TwoNTrial = 2*NTrial; int *IPIV = new int[TwoNTrial]; int INFO; RealCMMap SSuper(this->SSuperMem, TwoNTrial,TwoNTrial); RealCMMap ASuper(this->ASuperMem, TwoNTrial,TwoNTrial); RealCMMap SCPY(this->SCPYMem, TwoNTrial,TwoNTrial); RealCMMap NHrProd(this->NHrProdMem,TwoNTrial,TwoNTrial); SCPY = SSuper; // Copy of original matrix to use for re-orthogonalization // Invert the metric (maybe not needed?) dgetrf_(&TwoNTrial,&TwoNTrial,this->SSuperMem,&TwoNTrial,IPIV,&INFO); dgetri_(&TwoNTrial,this->SSuperMem,&TwoNTrial,IPIV,this->WORK,&this->LWORK,&INFO); delete [] IPIV; NHrProd = SSuper * ASuper; //cout << endl << "PROD" << endl << NHrProd << endl; dgeev_(&JOBVL,&JOBVR,&TwoNTrial,NHrProd.data(),&TwoNTrial,this->ERMem,this->EIMem, this->SSuperMem,&TwoNTrial,this->SSuperMem,&TwoNTrial,this->WORK,&this->LWORK, &INFO); // Sort eigensystem using Bubble Sort RealVecMap ER(this->ERMem,TwoNTrial); RealVecMap EI(this->EIMem,TwoNTrial); RealCMMap VR(this->SSuperMem,TwoNTrial,TwoNTrial); // cout << endl << ER << endl; this->eigSrt(VR,ER); // cout << endl << ER << endl; // Grab the "positive paired" roots (throw away other element of the pair) this->ERMem += NTrial; new (&ER ) RealVecMap(this->ERMem,NTrial); new (&SSuper) RealCMMap(this->SSuperMem+2*NTrial*NTrial,2*NTrial,NTrial); /* * Re-orthogonalize the eigenvectors with respect to the metric S(R) * because DSYGV orthogonalzies the vectors with respect to E(R) * because we solve the opposite problem. * * Gramm-Schmidt */ this->metBiOrth(SSuper,SCPY); // Separate the eigenvectors into gerade and ungerade parts RealCMMap XTSigmaR(this->XTSigmaRMem,NTrial,NTrial); RealCMMap XTSigmaL(this->XTSigmaLMem,NTrial,NTrial); XTSigmaR = SSuper.block(0, 0,NTrial,NTrial); XTSigmaL = SSuper.block(NTrial,0,NTrial,NTrial); //cout << endl << "ER" << endl << ER << endl << endl; //cout << endl << "CR" << endl << XTSigmaR << endl << endl; //cout << endl << "CR" << endl << XTSigmaL << endl << endl; // CErr(); }
error bignum_mul(bignum *r, const bignum *a, const bignum *b) { assert(!bignum_check_mutable(r)); assert(!bignum_check(a)); assert(!bignum_check(b)); size_t sza = bignum_len_bits(a); size_t szb = bignum_len_bits(b); /* Shortcuts? */ /* x * 0 -> 0 */ if (bignum_eq32(a, 0) || bignum_eq32(b, 0)) { bignum_set(r, 0); return OK; } /* 1 * b -> b */ if (bignum_eq32(a, 1)) return bignum_dup(r, b); /* a * 1 -> a */ if (bignum_eq32(b, 1)) return bignum_dup(r, a); if (bignum_capacity_bits(r) < sza + szb) return error_bignum_sz; /* Ensure a <= b. */ if (sza > szb) { SWAP(a, b); SWAP(sza, szb); } /* We cannot alias. */ assert(r != a && r != b); bignum_set(r, 0); ER(bignum_cleartop(r, (sza + szb + 31) / 32)); size_t nb = bignum_len_words(b); for (uint32_t *wr = r->v, *wa = a->v, *wb = b->v; wa <= a->vtop; wa++, wr++) { bignum_math_mul_accum(wr, wb, nb, *wa); } unsigned nega = bignum_is_negative(a), negb = bignum_is_negative(b); bignum_setsign(r, (nega ^ negb) ? -1 : 1); bignum_canon(r); return OK; }
uint8_t kdnet_driver_waitForMode() { uint8_t ready; do { ER(rfm69IsReady(&ready)); } while (ready == 0); return KDNET_SUCCESS; }
int my_ssl_verify_server_cert(SSL *ssl) { X509 *cert; MYSQL *mysql; char *p1, *p2, buf[256]; DBUG_ENTER("my_ssl_verify_server_cert"); mysql= (MYSQL *)SSL_get_app_data(ssl); if (!mysql->host) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Invalid (empty) hostname"); DBUG_RETURN(1); } if (!(cert= SSL_get_peer_certificate(ssl))) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Unable to get server certificate"); DBUG_RETURN(1); } X509_NAME_oneline(X509_get_subject_name(cert), buf, 256); X509_free(cert); /* Extract the server name from buffer: Format: ....CN=/hostname/.... */ if ((p1= strstr(buf, "/CN="))) { p1+= 4; if ((p2= strchr(p1, '/'))) *p2= 0; if (!strcmp(mysql->host, p1)) DBUG_RETURN(0); } my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Validation of SSL server certificate failed"); DBUG_RETURN(1); }
static error bignum_monty_modmul_noalias(bignum *A, const bignum *x, const bignum *y, const bignum *m, const monty_ctx *monty) { /* Make x < y. */ if (!bignum_lt(x, y)) SWAP(x, y); BIGNUM_TMP(xR); ER(bignum_monty_normalise(&xR, x, m, monty)); return bignum_monty_modmul_normalised(A, &xR, y, m, monty); }
my_bool ma_pvio_tls_check_fp(MARIADB_TLS *ctls, const char *fp, const char *fp_list) { unsigned int cert_fp_len= 64; char *cert_fp= NULL; my_bool rc=1; MYSQL *mysql= ctls->pvio->mysql; cert_fp= (char *)malloc(cert_fp_len); if ((cert_fp_len= ma_tls_get_finger_print(ctls, cert_fp, cert_fp_len)) < 1) goto end; if (fp) rc= ma_pvio_tls_compare_fp(cert_fp, cert_fp_len, fp, (unsigned int)strlen(fp)); else if (fp_list) { MA_FILE *fp; char buff[255]; if (!(fp = ma_open(fp_list, "r", mysql))) goto end; while (ma_gets(buff, sizeof(buff)-1, fp)) { /* remove trailing new line character */ char *pos= strchr(buff, '\r'); if (!pos) pos= strchr(buff, '\n'); if (pos) *pos= '\0'; if (!ma_pvio_tls_compare_fp(cert_fp, cert_fp_len, buff, (unsigned int)strlen(buff))) { /* finger print is valid: close file and exit */ ma_close(fp); rc= 0; goto end; } } /* No finger print matched - close file and return error */ ma_close(fp); } end: if (cert_fp) free(cert_fp); if (rc) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Fingerprint verification of server certificate failed"); } return rc; }
uint8_t kdnet_driver_process() { uint8_t op, st1, st2; ER(rfm69ReadRegister(RFM69_OPMODE, &op)); ER(rfm69ReadRegister(RFM69_IRQFLAGS1, &st1)); ER(rfm69ReadRegister(RFM69_IRQFLAGS2, &st2)); if (op & RFM69_OPMODE_TRANSMITTER) { if (st2 & RFM69_IRQFLAGS2_PACKETSENT) { ER(kdnet_cb_onPacketSent()); } } else if (op & RFM69_OPMODE_RECEIVER) { if (st2 & RFM69_IRQFLAGS2_PAYLOADREADY) { if (st2 & RFM69_IRQFLAGS2_CRCOK) { ER(kdnet_cb_onPacketReceived()); } else { kdnet_driver_setIdleMode(); kdnet_driver_setRxMode(); KDNET_DEBUG("CRC ERROR!"); } ER(kdnet_cb_onChannelFree()); } else { if (st1 & RFM69_IRQFLAGS1_SYNCADDRESSMATCH) { kdnet_cb_setConnectionRssi(rfm69GetRSSI()); ER(kdnet_cb_onChannelBusy()); } else { ER(kdnet_cb_onChannelFree()); } } if (st1 & RFM69_IRQFLAGS1_RSSI) { } } return KDNET_SUCCESS; }
static void * cm_get_command_result (const char *argv[], EXTRACT_FUNC func, const char *func_arg1, T_CM_ERROR * err_buf) { void *retval; FILE *fp = NULL; char outputfile[PATH_MAX]; char errfile[PATH_MAX]; char tmpfile[100]; snprintf (tmpfile, sizeof (tmpfile) - 1, "%s%d", "cmd_res_", getpid ()); (void) envvar_tmpdir_file (outputfile, PATH_MAX, tmpfile); snprintf (tmpfile, sizeof (tmpfile) - 1, "%s%d", "cmd_err_", getpid ()); (void) envvar_tmpdir_file (errfile, PATH_MAX, tmpfile); if (run_child (argv, 1, NULL, outputfile, errfile, NULL) < 0) { err_buf->err_code = CM_ERR_SYSTEM_CALL; snprintf (err_buf->err_msg, sizeof (err_buf->err_msg) - 1, ER (err_buf->err_code), argv[0]); return NULL; } fp = fopen (outputfile, "r"); if (fp == NULL) { err_buf->err_code = CM_FILE_OPEN_FAILED; snprintf (err_buf->err_msg, sizeof (err_buf->err_msg) - 1, ER (err_buf->err_code), outputfile, strerror (errno)); unlink (outputfile); return NULL; } retval = func (fp, func_arg1, err_buf); /* call extract function */ fclose (fp); unlink (outputfile); unlink (errfile); return retval; }
static inline int execute_break(node *stmt, exec_env *env) { symbol sym = 0; if(stmt->sym == 0) return pop_block(env); do { sym = env->block_stack->label; ER(pop_block(env)); } while (sym != stmt->sym && env->block_stack); return 0; }
int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, struct st_find_field *find_fields, int16 key_id, List<String> *names, String *name, String *description, String *example) { uchar buff[8]; // Max int length int count= 0; int iindex_topic, iindex_relations; Field *rtopic_id, *rkey_id; DBUG_ENTER("get_topics_for_keyword"); if ((iindex_topic= find_type((char*) primary_key_name, &topics->s->keynames, 1+2)-1)<0 || (iindex_relations= find_type((char*) primary_key_name, &relations->s->keynames, 1+2)-1)<0) { my_message(ER_CORRUPT_HELP_DB, ER(ER_CORRUPT_HELP_DB), MYF(0)); DBUG_RETURN(-1); } rtopic_id= find_fields[help_relation_help_topic_id].field; rkey_id= find_fields[help_relation_help_keyword_id].field; topics->file->ha_index_init(iindex_topic,1); relations->file->ha_index_init(iindex_relations,1); rkey_id->store((longlong) key_id, TRUE); rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW); int key_res= relations->file->index_read_map(relations->record[0], buff, (key_part_map) 1, HA_READ_KEY_EXACT); for ( ; !key_res && key_id == (int16) rkey_id->val_int() ; key_res= relations->file->index_next(relations->record[0])) { uchar topic_id_buff[8]; longlong topic_id= rtopic_id->val_int(); Field *field= find_fields[help_topic_help_topic_id].field; field->store((longlong) topic_id, TRUE); field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW); if (!topics->file->index_read_map(topics->record[0], topic_id_buff, (key_part_map)1, HA_READ_KEY_EXACT)) { memorize_variant_topic(thd,topics,count,find_fields, names,name,description,example); count++; } } topics->file->ha_index_end(); relations->file->ha_index_end(); DBUG_RETURN(count); }