zabbix-agent2/src/libs/zbxdb/db.c
/******************************************************************************
 *                                                                            *
 * Function: db_bind_dynamic_cb                                               *
 *                                                                            *
 * Purpose: callback function used by dynamic parameter binding               *
 *                                                                            *
 ******************************************************************************/
db_bind_dynamic_cb

Purpose: callback function used by dynamic parameter binding
db_bind_dynamic_cb Purpose : callback function used by dynamic parameter binding
static sb4 db_bind_dynamic_cb(dvoid *ctxp, OCIBind *bindp, ub4 iter, ub4 index, dvoid **bufpp, ub4 *alenp, ub1 *piecep,
		dvoid **indpp)
{
	zbx_db_bind_context_t	*context = (zbx_db_bind_context_t *)ctxp;
	ZBX_UNUSED(bindp);
	ZBX_UNUSED(index);
	switch (context->type)
	{
		case ZBX_TYPE_ID: 
			if (0 == context->rows[iter][context->position].ui64)
			{
				*bufpp = NULL;
				*alenp = 0;
				break;
			}
			ZBX_FALLTHROUGH;
		case ZBX_TYPE_UINT:
			*bufpp = &((OCINumber *)context->data)[iter];
			*alenp = sizeof(OCINumber);
			break;
		case ZBX_TYPE_INT:
			*bufpp = &context->rows[iter][context->position].i32;
			*alenp = sizeof(int);
			break;
		case ZBX_TYPE_FLOAT:
			*bufpp = &context->rows[iter][context->position].dbl;
			*alenp = sizeof(double);
			break;
		case ZBX_TYPE_CHAR:
		case ZBX_TYPE_TEXT:
		case ZBX_TYPE_SHORTTEXT:
		case ZBX_TYPE_LONGTEXT:
		case ZBX_TYPE_CUID:
			*bufpp = context->rows[iter][context->position].str;
			*alenp = ((size_t *)context->data)[iter];
			break;
		default:
			return FAIL;
	}
	*indpp = NULL;
	*piecep = OCI_ONE_PIECE;
	return OCI_CONTINUE;
}
static sb4 db_bind_dynamic_cb ( dvoid * ctxp , OCIBind * bindp , ub4 iter , ub4 index , dvoid * * bufpp , ub4 * alenp , ub1 * piecep , dvoid * * indpp ) { zbx_db_bind_context_t * context = ( zbx_db_bind_context_t * ) ctxp ; ZBX_UNUSED ( bindp ) ; ZBX_UNUSED ( index ) ; switch ( context -> type ) { case ZBX_TYPE_ID : if ( 0 == context -> rows [ iter ] [ context -> position ] . ui64 ) { * bufpp = NULL ; * alenp = 0 ; break ; } ZBX_FALLTHROUGH ; case ZBX_TYPE_UINT : * bufpp = & ( ( OCINumber * ) context -> data ) [ iter ] ; * alenp = sizeof ( OCINumber ) ; break ; case ZBX_TYPE_INT : * bufpp = & context -> rows [ iter ] [ context -> position ] . i32 ; * alenp = sizeof ( int ) ; break ; case ZBX_TYPE_FLOAT : * bufpp = & context -> rows [ iter ] [ context -> position ] . dbl ; * alenp = sizeof ( double ) ; break ; case ZBX_TYPE_CHAR : case ZBX_TYPE_TEXT : case ZBX_TYPE_SHORTTEXT : case ZBX_TYPE_LONGTEXT : case ZBX_TYPE_CUID : * bufpp = context -> rows [ iter ] [ context -> position ] . str ; * alenp = ( ( size_t * ) context -> data ) [ iter ] ; break ; default : return FAIL ; } * indpp = NULL ; * piecep = OCI_ONE_PIECE ; return OCI_CONTINUE ; }
Function: db_bind_dynamic_cb                                               
                                                                            
 Purpose: callback function used by dynamic parameter binding
Function : db_bind_dynamic_cb Purpose : callback function used by dynamic parameter binding
/* handle 0 -> NULL conversion */