コード例 #1
0
/************************************************************************
 * fm_validate_existence_and_get ()
 *
 *   	Function to validate the existence of a field.  If a null
 *	pointer was found, an error is returned.  If not, then the
 *      (pointer to the) value is returned.
 *
 ************************************************************************/
void
fm_validate_existence_and_get(
pin_flist_t	*flistp,		/* Pointer to input flist	*/
int		partial,		/* If set, no mandatory fields  */
u_int		pin_fld_field_num,	/* Field currently checked	*/
void		**valpp,  		/* Set if empty field found	*/
pin_errbuf_t	*ebufp)			/* Error buffer pointer		*/

{
	void	*vp = NULL;			/* Void pointer			*/

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	if (partial) {
		vp = PIN_FLIST_FLD_GET(flistp, pin_fld_field_num, 1, ebufp);
	} else {
		vp = PIN_FLIST_FLD_GET(flistp, pin_fld_field_num, 0, ebufp);
	}

	if ( (vp == (void *)NULL)  && !partial) {
		pin_set_err(ebufp, PIN_ERRLOC_FM,
			    PIN_ERRCLASS_SYSTEM_DETERMINATE, 
			    PIN_ERR_MISSING_ARG,
			    pin_fld_field_num, 0, 0);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
				 "fm_validate_existence(): NULL ptr.", ebufp);
	}
	*valpp = vp;
	return;
}
コード例 #2
0
/*******************************************************************
 * fm_bill_pol_spec_billno()
 *
 *	Prep the billno for the given bill obj.
 *
 *******************************************************************/
static void
fm_bill_pol_spec_billno(
	pcm_context_t		*ctxp,
	u_int			flags,
	pin_flist_t		*in_flistp,
	pin_flist_t		**out_flistpp,
        pin_errbuf_t		*ebufp)
{
	pin_flist_t	*b_flistp = NULL;
	poid_t		*pdp = NULL;
	void            *vp = NULL;

	int64		poid_db;
	int64		poid_id;
	char		billno[60];

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	b_flistp = PIN_FLIST_COPY(in_flistp, ebufp);

	/***********************************************************
	 * We don't need a bill_no if the bill type is subordinate.
	 ***********************************************************/
	vp = PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_PAY_TYPE, 0, ebufp);

	if (vp != (void *)NULL) {
		PIN_FLIST_FLD_DROP(b_flistp, PIN_FLD_PAY_TYPE, ebufp);
	}

	/***********************************************************
	 * Set the BILL_NO field according to poid.
	 ***********************************************************/
        vp = PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_BILL_NO, 1, ebufp);
	if ((vp == (void *)NULL) || (strlen((char *)vp) <= 0)) {

		pdp = (poid_t *)PIN_FLIST_FLD_GET(in_flistp, 
			PIN_FLD_POID, 0, ebufp);

		poid_db = PIN_POID_GET_DB(pdp);
		poid_id = PIN_POID_GET_ID(pdp);

		sprintf(billno, "%u.%u.%u.%u-%llu",
		(u_int)((poid_db & (u_int64)MASKUPPER) >> 48),
		(u_int)((poid_db & (u_int64)MASKSECOND) >> 32),
		(u_int)((poid_db & (u_int64)MASKTHIRD) >> 16),
		(u_int)(poid_db & (u_int64)0xFFFF), poid_id);

		PIN_FLIST_FLD_SET(b_flistp, PIN_FLD_BILL_NO, 
			(void *)billno, ebufp);
	}
コード例 #3
0
/*******************************************************************
 * fm_rate_pol_get_taxcode():
 *
 *    This policy will return the cached list of taxcodes
 *    in an flist.
 *
 *******************************************************************/
static void
fm_rate_pol_get_taxcode(
	pcm_context_t		*ctxp,
	pin_flist_t		*i_flistp,
	pin_flist_t		**o_flistpp,
	pin_errbuf_t		*ebufp)
{
	void			*vp = NULL;
	pin_flist_t             *flistp = NULL;
	char            *taxCode = NULL;
	u_int32                 glid = 0;
	pin_cookie_t    cookie = NULL;
	int32           elemid = 0;

	if (PIN_ERR_IS_ERR(ebufp)) {
		return;
		/*****/
	}

	PIN_ERR_CLEAR_ERR(ebufp);
	*o_flistpp = NULL;

	/*
	 * set something to return
	 */
	*o_flistpp = PIN_FLIST_CREATE(ebufp);
	vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	PIN_FLIST_FLD_SET(*o_flistpp, PIN_FLD_POID, (void *)vp, ebufp);

	/*
	 * populate the return flist with cached list of taxcodes
	 */
	fm_utils_tax_get_taxcodes(*o_flistpp, ebufp);

	vp = PIN_FLIST_FLD_GET(i_flistp,PIN_FLD_GL_ID, 1, ebufp);
        if (vp) {
		while ((flistp = PIN_FLIST_ELEM_GET_NEXT(*o_flistpp, PIN_FLD_RESULTS,
			&elemid, 1, &cookie, ebufp)) != (pin_flist_t *)NULL) {

			/* Get the tax code from the results array */
		        taxCode = (char*)PIN_FLIST_FLD_GET(flistp,PIN_FLD_TAX_CODE, 0, ebufp);
			fm_utils_taxcode_to_glid(ctxp, taxCode, &glid, ebufp);
			PIN_FLIST_FLD_SET(flistp, PIN_FLD_GL_ID, (void *)&glid, ebufp);
		}

	}

	return;
}
コード例 #4
0
/*ARGSUSED*/
static void
fm_cust_pol_set_brandname(
	pcm_context_t		*ctxp,
	int32			opflags,
	pin_flist_t		*i_flistp,
	pin_flist_t		**r_flistpp,
	pin_errbuf_t		*ebufp)
{
	char			*namep;
	poid_t			*poidp;
        poid_t                  *g_pdp;
	pin_flist_t		*sublistp;

	/* 
	 * For pending errors, return immediately.
	 */
	if(PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/*
	 * For completeness, dump the input flist if debugging is enabled.
	 */
        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
                          "fm_cust_pol_set_brandname input flist:",
                          i_flistp);

	/*
	 * Get the name if there is one 
	 */
	poidp = (poid_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	sublistp = (pin_flist_t *)PIN_FLIST_FLD_GET(i_flistp, 
		PIN_FLD_BRAND_INFO, 0, ebufp);
	namep = (char *)PIN_FLIST_FLD_GET(sublistp, PIN_FLD_NAME, 1, ebufp);
	if((namep == (char *)NULL) || (*namep == '\0')) {
		return;
	}	

	if(check_unique == BRANDWIDE_UNIQUE) {
		fm_cust_pol_is_brandname_unique_within_brand(ctxp, poidp,
			namep, r_flistpp, ebufp);
	}
	else if(check_unique == SYSTEMWIDE_UNIQUE) {
		fm_cust_pol_is_brandname_unique_global(ctxp, poidp, namep,
			r_flistpp, ebufp);
	}
}
コード例 #5
0
/************************************************************************
 * fm_validate_existence ()
 *
 *   	Function to validate the existence of a field.  If a null
 *	pointer was found, an error is returned.  The *empty_field
 *	flag will be set to PIN_BOOLEAN_TRUE if there's a 0 length
 *	string found.  This routine does NOT initialize this flag.
 *
 ************************************************************************/
void
fm_validate_existence(
pin_flist_t	*flistp,		/* Pointer to input flist	*/
int		partial,		/* if set, no mandatory fields  */
pin_flist_t	*r_flistp,		/* Pointer to return flist	*/
u_int		pin_fld_field_num,	/* Field currently checked	*/
u_int		pin_fld_element_id,	/* Element id of current array 	*/
u_int		*empty_field,		/* Set if empty field found	*/
pin_errbuf_t	*ebufp)			/* Error buffer pointer		*/

{
	void	*vp = NULL;		/* Void pointer			*/

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/****************************************************************
	 * Only fill the failed field descriptor if the field exists but
	 * there is nothing there (i.e. *vp == '\0').
	 ****************************************************************/
	if (partial) {
		vp = PIN_FLIST_FLD_GET(flistp, pin_fld_field_num, 1, ebufp);
	} else {
		vp = PIN_FLIST_FLD_GET(flistp, pin_fld_field_num, 0, ebufp);
	}

	if (vp != (char *)NULL && (!partial))
	{
		if (strlen(vp) == 0)
		{
			(void)fm_cust_pol_valid_add_fail(r_flistp,
				pin_fld_field_num, pin_fld_element_id,
				PIN_CUST_VAL_ERR_MISSING, 
				"Missing field.", vp, ebufp);
			*empty_field = PIN_BOOLEAN_TRUE;
		}
	} else if (!partial) {
                pin_set_err(ebufp, PIN_ERRLOC_FM,
                        PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_MISSING_ARG,
			pin_fld_field_num, pin_fld_element_id, 0);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_validate_existence(): NULL ptr.", ebufp);
	}
	return;
}
コード例 #6
0
/*******************************************************************
 * PCM_OP_BILL_POL_GET_PENDING_ITEMS 
 *
 * This policy provides a hook to the Bill Now opcode for selecting 
 * the Pending Items to be included in the Bill. The default 
 * implementation select all the Pending Items to be included in the
 * Bill.
 *******************************************************************/
void 
op_bill_pol_get_pending_items(
	cm_nap_connection_t	*connp,
	int32			opcode,
	int32			flags,
	pin_flist_t		*i_flistp,
	pin_flist_t		**r_flistpp,
	pin_errbuf_t		*ebufp)
{
	void		*vp = NULL;
	pcm_context_t	*ctxp = connp->dm_ctx;
	
	*r_flistpp = NULL;
	
	if (PIN_ERR_IS_ERR(ebufp)) {
		return;
	}
	PIN_ERR_CLEAR_ERR(ebufp);

	/*******************************************************************
	 * Insanity Check 
	 *******************************************************************/
	if (opcode != PCM_OP_BILL_POL_GET_PENDING_ITEMS) {
		pin_set_err(ebufp, PIN_ERRLOC_FM, 
			PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_BAD_OPCODE, 0, 0, opcode);
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"op_bill_pol_get_pending_items error",
			ebufp);
		return;
	}

	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, 
		"op_bill_pol_get_pending_items input flist", i_flistp);

	/*******************************************************************
	 * Call the function in order to get pending items to be included
	 *  into the Bill Now. 
	 *******************************************************************/
	fm_bill_pol_get_pending_items(ctxp, i_flistp, r_flistpp, ebufp);
	
	 /******************************************************************
         * Set account poid and bill_type to the output flist.
         ******************************************************************/
	
	vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_POID, vp, ebufp);
	
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, 
			"op_bill_pol_get_pending_items error", ebufp);
	}
	else {
		PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, 
		"op_bill_pol_get_pending_items output flist", *r_flistpp);
	}
	return;
}
コード例 #7
0
/*******************************************************************
 * fm_cust_pol_valid_passwd()
 *
 *	Validate the given passwd according to the given poid type.
 *
 *******************************************************************/
static void
fm_cust_pol_valid_passwd(
	pcm_context_t		*ctxp,
	pin_flist_t		*in_flistp,
	pin_flist_t		**out_flistpp,
        pin_errbuf_t		*ebufp)
{
	pin_flist_t		*r_flistp = NULL;

	poid_t			*o_pdp;
	const char		*o_type = NULL;

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/***********************************************************
	 * Create outgoing flist
	 ***********************************************************/
	r_flistp = PIN_FLIST_CREATE(ebufp);
	*out_flistpp = r_flistp;

	/***********************************************************
	 * Get (and add) the object poid.
	 ***********************************************************/
	o_pdp = (poid_t *)PIN_FLIST_FLD_GET(in_flistp, PIN_FLD_POID, 0, ebufp);
	PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_POID, (void *)o_pdp, ebufp);

	/***********************************************************
	 * We might have different rules for different services.
	 ***********************************************************/
	o_type = PIN_POID_GET_TYPE(o_pdp);

	if (!strncmp(o_type, "/service", 8)) {

		/* Any service password */
		fm_cust_pol_valid_pwd_srvc(ctxp, in_flistp, r_flistp, ebufp);

	} else {

		/* Error - unknown/usupported type */
		pin_set_err(ebufp, PIN_ERRLOC_FM,
			PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_BAD_POID_TYPE, PIN_FLD_POID, 0, 0);

	}

	/***********************************************************
	 * Error?
	 ***********************************************************/
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_valid_passwd error", ebufp);
	}

	return;
}
コード例 #8
0
/*******************************************************************
 * fm_cust_pol_valid_pwd_srvc():
 *
 *	Validate the service level password.
 *
 *******************************************************************/
static void
fm_cust_pol_valid_pwd_srvc(
	pcm_context_t		*ctxp,
	pin_flist_t		*i_flistp,
	pin_flist_t		*r_flistp,
        pin_errbuf_t		*ebufp)
{
	u_int			result;
        const char              *pwd = NULL;

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/***********************************************************
	 * Pass by default.
	 ***********************************************************/
	result = PIN_CUST_VERIFY_PASSED;
	PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_RESULT, (void *)&result, ebufp);

	pwd = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_PASSWD_CLEAR, 0, ebufp); 
	if (pwd && !strncmp(pwd, FM_PWD_INVALID_PASSWD, strlen(FM_PWD_INVALID_PASSWD))) {
		PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_ERROR, " Invalid Password."); 
		pin_errbuf_set_err( ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE,
                                     PIN_ERR_VALIDATION_FAILED, 0, 0, 0, PIN_DOMAIN_ERRORS,
                                     PIN_ERR_VALIDATE_PASSWORD,1, 0, NULL);
		goto cleanup;
		/***********/
	}



	/***********************************************************
	 * If it's there, is it too long?
         * Try to validate based on /config/fld_validate (Pswd) obj.
         ***********************************************************/
	fm_cust_pol_validate_fld_value( ctxp, i_flistp, i_flistp, r_flistp,
		PIN_FLD_PASSWD_CLEAR,
		0,              /* element_id   */
		"Pswd",
		1,
		ebufp);

cleanup:
	/***********************************************************
	 * Error?
	 ***********************************************************/
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_valid_pwd_srvc error", ebufp);
	}

	return;
}
コード例 #9
0
/*******************************************************************
 * Main routine for the PCM_OP_CREATE_METAFIELD operation.
 *******************************************************************/
void
op_create_metafield(
    cm_nap_connection_t     *connp,
    int32                    opcode,
    int32                    flags,
    pin_flist_t             *in_flistp,
    pin_flist_t            **ret_flistpp,
    pin_errbuf_t            *ebufp)
{
    pcm_context_t           *ctxp = connp->dm_ctx;
    void				*vp =NULL;

    PIN_ERR_CLEAR_ERR(ebufp);

    /***********************************************************
     * Insanity check.
     ***********************************************************/
    if (opcode != PCM_OP_CREATE_METAFIELD) {
        pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode);
        PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_create_metafield opcode error", ebufp);
        return;
    }

    /***********************************************************
     * Debug: What we got.
     ***********************************************************/
    PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_create_metafield input flist", in_flistp);

    /***********************************************************
     * Do the actual op in a sub-function.
     ***********************************************************/
    fm_cust_pol_create_metafield_obj(ctxp, flags, in_flistp, ret_flistpp, ebufp);

    /***********************************************************
     * Error?
     ***********************************************************/
    if (PIN_ERR_IS_ERR(ebufp))
    {
        PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_create_metafield error", ebufp);
        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_ERROR, "op_create_metafield return flist", *ret_flistpp);
    }
    else
    {
        /***************************************************
         * Debug: What we're sending back.
         ***************************************************/
        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_create_metafield return flist", *ret_flistpp);
        vp = PIN_FLIST_FLD_GET(*ret_flistpp,PIN_FLD_POID,1,ebufp);

        if(PIN_POID_IS_NULL(vp)==0)
            PIN_ERR_LOG_POID(PIN_ERR_LEVEL_DEBUG, "metafield poid created is", vp);
    }
    return;
}
コード例 #10
0
/*******************************************************************
 * fm_device_pol_set_state:
 *
 *******************************************************************/
static void
fm_device_pol_set_state(
	pcm_context_t           *ctxp,
	int32                   flags,
	pin_flist_t             *i_flistp,
	pin_flist_t             **r_flistpp,
	pin_errbuf_t            *ebufp)
{

	poid_t          *dev_poidp = NULL;
	char            *poid_type = NULL;

	if (PIN_ERR_IS_ERR(ebufp)) {
		return;
	}

	PIN_ERR_CLEAR_ERR(ebufp);
	
	/*
	 * Get the old device object poid
	 */
	dev_poidp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	
	/*
	 * Get the device poid type
	 * this poid will be used in identifiing different Devices like sim,num..
	 */
	poid_type = (char *) PIN_POID_GET_TYPE(dev_poidp);

	if (strcmp(poid_type, PIN_OBJ_TYPE_DEVICE_IP) == 0) {
		/*
		 * call IP policy to do the work we want
		 */
		 PCM_OP(ctxp, PCM_OP_IP_POL_DEVICE_SET_STATE, flags, i_flistp,
			r_flistpp, ebufp);
	} else if (strcmp(poid_type, PIN_OBJ_TYPE_DEVICE_APN) == 0) {
		/*
		 * call APN policy to do the work we want
		 */
		 PCM_OP(ctxp, PCM_OP_APN_POL_DEVICE_SET_STATE, flags, i_flistp,
			r_flistpp, ebufp);
	}
	else {
		/***********************************************************
		 * Prepare return flist
		 ***********************************************************/
		*r_flistpp = PIN_FLIST_COPY(i_flistp, ebufp);
	}

	return;
}
コード例 #11
0
/************************************************************************
 * fm_bill_pol_reverse_payment()
 ************************************************************************/
static  void
fm_bill_pol_reverse_payment(
	pcm_context_t      	*ctxp,
	int			flags,
	pin_flist_t             *in_flistp,
	pin_flist_t             **ret_flistpp,
	pin_errbuf_t       	*ebufp)	
{
	poid_t                  *a_pdp 		= NULL;
	pin_flist_t             *inh_flistp 	= NULL;
	
	if (PIN_ERR_IS_ERR(ebufp)){
		return;
	}
	PIN_ERR_CLEAR_ERR(ebufp);

	*ret_flistpp	=  PIN_FLIST_CREATE(ebufp);

	/***********************************************************
	 * Get and set PIN_FLD_POID in the output flist
	 ***********************************************************/
	a_pdp = PIN_FLIST_FLD_GET(in_flistp, PIN_FLD_POID, 0, ebufp);
	PIN_FLIST_FLD_SET(*ret_flistpp, PIN_FLD_POID, (void *)a_pdp, ebufp);

	/***********************************************************
	 * Get INHERITED_INFO from the input flist and
	 * Set in the ouput flist if present
	 ***********************************************************/
	inh_flistp = PIN_FLIST_SUBSTR_GET(in_flistp,
				PIN_FLD_INHERITED_INFO, 1, ebufp);
	if ( inh_flistp ) {
		PIN_FLIST_SUBSTR_SET(*ret_flistpp, inh_flistp, 
				PIN_FLD_INHERITED_INFO, ebufp);
	}

	fm_bill_pol_reverse_payment_writeoff_account(ctxp, flags, in_flistp,
						 ebufp);

	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
				"fm_bill_pol_reverse_payment error", ebufp);
	} else {
		PIN_ERR_CLEAR_ERR(ebufp);
	}
	return;
}
コード例 #12
0
/*******************************************************************
 * fm_rate_pol_tax_loc():
 *
 *    This policy could do several things to prepare the input
 *    flist for the tax calculation.  It could locate the locale's
 *    involved. 
 *
 *    The return flist should look like this:
 *	0 PIN_FLD_POID           POID [0] 0.0.0.1 /event/session -1 0
 *	0 PIN_FLD_ORDER_ACCEPT    STR [0] "Cupertino;CA;95014;US"
 *	0 PIN_FLD_ORDER_ORIGIN    STR [0] "Cupertino;CA;95014;US"
 *	0 PIN_FLD_SHIP_FROM       STR [0] "Cupertino;CA;95014;US"
 *	0 PIN_FLD_SHIP_TO         STR [0] "Cupertino ;CA ;95014 ;USA"
 *
 *    The default implementation is just to return the POID only. 
 *
 *******************************************************************/
static void
fm_rate_pol_tax_loc(
	pcm_context_t		*ctxp,
	pin_flist_t		*i_flistp,
	pin_flist_t		**o_flistpp,
	pin_errbuf_t		*ebufp)
{
	void			*vp = NULL;

	if (PIN_ERR_IS_ERR(ebufp)) 
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	*o_flistpp = PIN_FLIST_CREATE(ebufp);
	vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	if (vp) {
		PIN_FLIST_FLD_SET(*o_flistpp, PIN_FLD_POID, (void *)vp, ebufp);
	}

	return;
}
コード例 #13
0
/*******************************************************************
 * fm_cust_pol_pre_commit()
 *
 *	Pre-creation legacy system hook.
 *
 *	XXX NOOP - STUBBED ONLY XXX
 *
 *******************************************************************/
static void
fm_cust_pol_pre_commit(
	pcm_context_t		*ctxp,
	u_int           flags,
	pin_flist_t		*in_flistp,
	pin_flist_t		**out_flistpp,
        pin_errbuf_t		*ebufp)
{
	void			*vp;

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/***********************************************************
	 * Create outgoing flist
	 ***********************************************************/
	*out_flistpp = PIN_FLIST_CREATE(ebufp);

	vp = PIN_FLIST_FLD_GET(in_flistp, PIN_FLD_POID, 0, ebufp);
	PIN_FLIST_FLD_SET(*out_flistpp, PIN_FLD_POID, vp, ebufp);

	/***********************************************************
	 * Check if Out Of Order detection feature is enabled.
	 * If so, create the /profile/event_ordering object.
	 ***********************************************************/
	if (fm_cust_pol_pre_commit_is_OOD_feature_enabled(ctxp, in_flistp, ebufp)) {
		fm_cust_pol_pre_commit_create_profile_OOD_obj(ctxp, flags, in_flistp, ebufp);
	}	

	/***********************************************************
	 * Error?
	 ***********************************************************/
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_pre_commit error", ebufp);
	}

	return;
}
コード例 #14
0
/*****************************************************************
 * fm_pymt_pol_charge_set_domain_id()
 * Function to set the reason domain ID
 ******************************************************************/
static void
fm_pymt_pol_charge_set_domain_id(
        pcm_context_t           *ctxp,
        pin_flist_t             *i_flistp,
	pin_flist_t		*res_flistp,
        int32                   *domain_idp,
        pin_errbuf_t            *ebufp)
{
        void                    *vp = NULL;

        if (PIN_ERR_IS_ERR(ebufp))
        {
                return ;
        }
        PIN_ERR_CLEAR_ERR(ebufp);
	vp = PIN_FLIST_FLD_GET(i_flistp,
			PIN_FLD_REASON_DOMAIN_ID, 1,ebufp);
	/*****************************************************
	 * Set the domain ID in the Results array
	 *****************************************************/
	if(!vp){
		PIN_FLIST_FLD_SET(res_flistp, PIN_FLD_REASON_DOMAIN_ID,
					(void *) domain_idp, ebufp);

        }
	else{
		PIN_FLIST_FLD_SET(res_flistp, PIN_FLD_REASON_DOMAIN_ID,
						vp, ebufp);
	}

        if (PIN_ERR_IS_ERR(ebufp)) {
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                        "fm_pymt_pol_charge_set_domain_id", ebufp);
        }
        return ;
}
コード例 #15
0
/**************************************************************************
 * fm_validate_value()   
 *
 *	Validates abbreviated string and sets the field in the flist to
 *	an expanded string if the caller wants it and one is available.  
 *
 *************************************************************************/
void 
fm_validate_value(
pin_flist_t	*flistp,		/* Pointer to input flist	*/
pin_flist_t	*r_flistp,		/* Pointer to return flist	*/
u_int		pin_fld_field_num,	/* Field currently checked	*/
u_int		pin_fld_element_id,	/* Element id of current array 	*/
char		*config_file,		/* File used for validation	*/
int		type,			/* VALIDATE|EXPAND		*/
pin_errbuf_t	*ebufp)			/* Error buffer pointer		*/
{

	FILE	*fp = NULL;		/* Pointer to the config file	*/
	char	buf[MAXLINE];		/* Buffer to read line into	*/
	char	errmsg[MAXLINE];	/* Error message buffer		*/
	short	found = 0;		/* Set if string found		*/ 
	char	*tok = NULL;		/* Token parsed			*/
	void	*vp = NULL;		/* Void pointer			*/

	buf[0] = errmsg[0] = '\0';

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/**************************************************************** 
	 * Initialize.  If the field can't be found, then return FAILED.
	 ****************************************************************/
	found = 0;
	vp = PIN_FLIST_FLD_GET(flistp, pin_fld_field_num, 0, ebufp);
	if (vp == NULL)
	{
                pin_set_err(ebufp, PIN_ERRLOC_FM,
                        PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_MISSING_ARG, pin_fld_field_num, 0, 0);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, 
			"fm_validate_value(): missing field.", ebufp);
		return;
	}
	if (!(fp = fopen(config_file, "r")))
	{
                pin_set_err(ebufp, PIN_ERRLOC_FM,
                        PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_FILE_IO, 0, 0, 0);
		sprintf(errmsg, "fm_validate_value(): fopen(%s \"r\") failed", 
			config_file);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, errmsg, ebufp);
		return;
	}

	/****************************************************************
	 * Go through file a line at a time and check for a match.
	 ****************************************************************/
	while (!found && fgets(buf, MAXLINE, fp) != NULL) 
	{
		/********************************************************
		 * Skip comments (sort of).
		 ********************************************************/
		if (buf[0] != '#')
		{
			tok = (char *)strtok(buf, "|\n");
			if (tok == (char *)NULL) {
				break;
			}
			if (strcmp(tok, (char *)vp) == 0)
			{
				found = 1;
			}
		}
	}

	/****************************************************************
	 * Create return flist if needed.			
	 ****************************************************************/
	switch(type)
	{
	case EXPAND_FROMFILE:
		if (found)
		{
			tok = (char *)strtok(NULL, "\n");
		} else {
			(void)fm_cust_pol_valid_add_fail(r_flistp,
				pin_fld_field_num, pin_fld_element_id,
				PIN_CUST_VAL_ERR_INVALID, 
				"Not a valid value.", vp, ebufp);
		}
		if (tok)
		{
			PIN_FLIST_FLD_SET(r_flistp, pin_fld_field_num, 
				(void *)tok, ebufp);
		} else {
			(void)fm_cust_pol_valid_add_fail(r_flistp,
				pin_fld_field_num, pin_fld_element_id,
				PIN_CUST_VAL_ERR_INVALID, 
				"No expanded equivalent.", vp, ebufp);
		}
		break;

	case VALIDATE_INFILE:
		if (!found)
		{
			(void)fm_cust_pol_valid_add_fail(r_flistp,
				pin_fld_field_num, pin_fld_element_id,
				PIN_CUST_VAL_ERR_INVALID, 
				"Not a valid value.", vp, ebufp);
		}
		break;

	case VALIDATE_NOTINFILE:
		if (found)
		{
			(void)fm_cust_pol_valid_add_fail(r_flistp,
				pin_fld_field_num, pin_fld_element_id,
				PIN_CUST_VAL_ERR_INVALID, 
				"Not a valid value.", vp, ebufp);
		}
		break;

	default:
                pin_set_err(ebufp, PIN_ERRLOC_FM,
                        PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_BAD_VALUE, 0, 0, type);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_validate_value(): unexpected type", ebufp);
	}

	/****************************************************************
	 * Close the file.
	 ****************************************************************/
	if (fclose(fp) == EOF)
	{
                pin_set_err(ebufp, PIN_ERRLOC_FM,
                        PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_FILE_IO, 0, 0, 0);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                        "fm_validate_value(): fclose() failed", ebufp);
	}

	return;
}
コード例 #16
0
/***********************************************************************
 * fm_validate_format ()
 *
 *   	Function to validate the format of a field.
 *
 ************************************************************************/
void
fm_validate_format(
pin_flist_t	*flistp,		/* Pointer to input flist	*/
pin_flist_t	*r_flistp,		/* Pointer to return flist	*/
u_int		pin_fld_field_num,	/* Field currently checked	*/
u_int		pin_fld_element_id,	/* Element id of current array 	*/
char		*format,		/* Regular expression format	*/
char		*errmsg,		/* Error message in case error	*/
pin_errbuf_t	*ebufp)			/* Error buffer pointer		*/
{
	void	*vp = NULL;	    /* Void pointer			*/
	regex_t	expbuf;
	int	err;
        char    temp[256] = "";     /* Local buffer for format      */
        char    *tok = "";          /* Parsed token from format     */
        short   match = 0;          /* Match flag                   */


	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	if ( format == NULL )
		return;

	/****************************************************************
	 * Get the field.  Just return if it couldn't find the field.
	 ****************************************************************/
	vp = PIN_FLIST_FLD_GET(flistp, pin_fld_field_num, 1, ebufp);
	if ((vp == NULL) || (strlen(vp) == 0))
	{
		return;
	}

	/****************************************************************
         * Copy format to a local temp buffer because strtok will hack
         * it up.
         ****************************************************************/
	if ( strlen(format) >= sizeof(temp) )
	{
		pin_set_err(ebufp, PIN_ERRLOC_FM,
			PIN_ERRCLASS_SYSTEM_DETERMINATE, 0, 0, 0, 0);
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_validate_format(): temp buffer overflows.", ebufp);
                return;
	}
        strcpy(temp, format);

	/****************************************************************
         * Start looking for a match.  There can be more than one
	 * regular expression in format.  Each regex will be delimited
	 * by a '|'.  
	 * FIX THIS:  We will need to handle cases where '|'
	 * 		is an actual character in the pattern.
         ****************************************************************/
        tok = (char *)strtok(temp, "|");
        while (tok && !match)
        {
                if (err = regcomp(&expbuf, tok, REG_EXTENDED | REG_NOSUB) != 0)
                {
			pin_set_err(ebufp, PIN_ERRLOC_FM,
				PIN_ERRCLASS_SYSTEM_DETERMINATE, 0, 0, 0, err);
			PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
				"fm_validate_format(): regcomp failed. The error is in "
				"the reserved field. See hsregex.h for the meaning.", ebufp);
			regfree(&expbuf);
                        return;
                }
                /*****************************************************
                 * regexec() returns a zero value if there is a match.
                 *****************************************************/
                if (regexec(&expbuf, vp, (size_t)0, NULL, 0))
                {
                        tok = (char *)strtok(NULL, "|");
                } else {
                        match = 1;
                }
		/* Free the memory allocated by regcomp */
		regfree(&expbuf);
	}

	/****************************************************************
	 * If a match was not found, in other words, the format was wrong,
	 * then create the appropriate flist to express the inconformance.
	 ****************************************************************/ 
	if (!match)
        {
		(void)fm_cust_pol_valid_add_fail(r_flistp, pin_fld_field_num,
			pin_fld_element_id, PIN_CUST_VAL_ERR_INVALID, 
			errmsg, vp, ebufp);
        }
	return;
}
コード例 #17
0
ファイル: sample_del.c プロジェクト: cubastion-umesh/cubnbrm
/*******************************************************************
 * Main
 *
 *	This sets up the parameters and then calls the FM.
 *
 *******************************************************************/
int main(
	int		argc,
	char		*argv[])
{
	pcm_context_t	*ctxp;

	pin_flist_t	*flistp = NULL;
	pin_flist_t	*a_flistp = NULL;
	pin_flist_t	*r_flistp = NULL;

	poid_t		*acct_pdp = NULL;
	poid_t		*srvc_pdp = NULL;

	u_int		opcode;

	int64		database;

	void		*vp;

	char		logfile[256];
	char		*c_ptr = (char *)NULL;
	char		*program;
	int32		err;

	pin_errbuf_t	ebuf;

	PIN_ERR_CLEAR_ERR(&ebuf);

	/*
	 * Logging initialization
	 */
	program = basename(argv[0]);
	PIN_ERR_SET_PROGRAM(program);
	PIN_ERR_SET_LEVEL(PIN_ERR_LEVEL_WARNING);

	strcpy(logfile, "default.pinlog");
	pin_conf(program, "logfile", PIN_FLDT_STR, (caddr_t *)&(c_ptr), &err);
	if (c_ptr != (char *)NULL) {
		pin_strlcpy(logfile, c_ptr, sizeof(logfile));
		pin_free(c_ptr);
		c_ptr = (char *)NULL;
	}
	PIN_ERR_SET_LOGFILE(logfile);

	/*
	 * Check the input.
	 */
	if (argc != 3) {
		usage(argv[0]);
		PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_ERROR, "bad # of arguments");
		exit(1);
	}

	/*
	 * Initialize PCM connection.
	 */
	PCM_CONNECT(&ctxp, &database, &ebuf);
	if (PIN_ERR_IS_ERR(&ebuf)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"pcm_connect error", &ebuf);
		exit(2);
	}

	/*
	 * Create the poid prototype.
	 */
	srvc_pdp = PIN_POID_CREATE(database, argv[1], 0, &ebuf);

	/*
	 * Look up the account.
	 */
	flistp = PIN_FLIST_CREATE(&ebuf);

	vp = (void *)srvc_pdp;
	PIN_FLIST_FLD_SET(flistp, PIN_FLD_POID, vp, &ebuf);

	vp = (void *)argv[2];
	PIN_FLIST_FLD_SET(flistp, PIN_FLD_LOGIN, vp, &ebuf);

	opcode = PCM_OP_ACT_FIND;
	PCM_OP(ctxp, opcode, 0, flistp, &a_flistp, &ebuf);

	/*
	 * Did we find anything?
	 */
	acct_pdp = PIN_FLIST_FLD_GET(a_flistp, PIN_FLD_ACCOUNT_OBJ, 0, &ebuf);

	if (!PIN_POID_IS_NULL(acct_pdp)) {

		/*
		 * Advisory (or add confirm?)
		 */
		fprintf(stdout, "Deleting Account:\t");
		pin_poid_print(acct_pdp, 0, &ebuf);
		fprintf(stdout, "\n");

		/*
		 * Put the real account poid on the flist
		 * (The account_obj field will just be ignored)
		 */
		vp = (void *)acct_pdp;
		PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, vp, &ebuf);

		/*
		 * Delete the account.
		 */
		opcode = PCM_OP_CUST_DELETE_ACCT;
		PCM_OP(ctxp, opcode, 0, a_flistp, &r_flistp, &ebuf);

		/*
		 * Did we delete or not?
		 */
		if (PIN_ERR_IS_ERR(&ebuf)) {

			fprintf(stdout, "Account Deletion Error Occurred.\n");
			PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
				"op_cust_delete_acct error", &ebuf);

		} else {

			fprintf(stdout, "Account Deleted.\n");

		}

	} else {

		/*
		 * FIND error.
		 */
		fprintf(stdout, "Unable to locate Account.\n");
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"op_act_find error", &ebuf);

	}

	/*
	 * Close the PCM context.
	 */
	PCM_CONTEXT_CLOSE(ctxp, 0, &ebuf);

	/*
	 * Clean up.
	 */
	/* Free local memory. */
	PIN_FLIST_DESTROY(flistp, NULL);
	PIN_FLIST_DESTROY(a_flistp, NULL);
	PIN_FLIST_DESTROY(r_flistp, NULL);

	/* No errors. */
	return(0);
}
コード例 #18
0
/*******************************************************************
 * fm_pymt_pol_chagre_process_result()
 * This function reads the response from vendor
 * and assigns a reason ID for the response
 *******************************************************************/
static void
fm_pymt_pol_charge_process_result(
	pcm_context_t           *ctxp,
	pin_flist_t		*i_flistp,
	int			*reason_id,
	int			*domain_idp,
	pin_errbuf_t		*ebufp)
{
	pin_flist_t             *info_flistp = NULL;
	pin_errbuf_t            any_field_ebuf;
	pin_cookie_t            cookie = NULL;
	pin_fld_num_t		field = 0;
	int32			rec_id = 0;
	pin_charge_result_t	*resultp = NULL;
	if (PIN_ERR_IS_ERR(ebufp))
	{
		return ;
	}
	PIN_ERR_CLEAR_ERR(ebufp);

	PIN_ERR_CLEAR_ERR(&any_field_ebuf);	

	while (PIN_FLIST_ANY_GET_NEXT(i_flistp, &field, 
				&rec_id, &cookie, &any_field_ebuf) != NULL ){
		if (field == PIN_FLD_CC_INFO || field == PIN_FLD_DD_INFO) {
			info_flistp = PIN_FLIST_ELEM_GET(i_flistp, 
					field, 0, 0, ebufp);
			resultp = (pin_charge_result_t *)PIN_FLIST_FLD_GET(info_flistp,
					PIN_FLD_RESULT, 0,ebufp);
			/*******************************************
			 * Set the PIN_FLD_RESULT_ID in the PIN_FLD_RESULTS 
			 * array
			 ******************************************/
			if (resultp){
				/******************************
				 *Set Default Reason ID to 0
				 *******************************/
				switch (*resultp) {
				case PIN_CHARGE_RES_PASS: 
					*reason_id = PIN_REASON_ID_APPROVED;
					*domain_idp = PIN_PYMT_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_NO_ANS:
					*reason_id = PIN_REASON_ID_FAIL_NO_ANS;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_ADDR_AVS:
					*reason_id = PIN_REASON_ID_FAIL_ADDR_AVS;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_ADDR_LOC:
					*reason_id = PIN_REASON_ID_FAIL_ADDR_LOC;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_ADDR_ZIP:
					*reason_id = PIN_REASON_ID_FAIL_ADDR_ZIP;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_CARD_BAD:
					*reason_id = PIN_REASON_ID_FAIL_CARD_BAD;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_DECL_SOFT:
					*reason_id = PIN_REASON_ID_FAIL_DECL_SOFT;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_SRVC_UNAVAIL:
					*reason_id = PIN_REASON_ID_FAIL_SRVC_UNAVAIL;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_DECL_HARD:
					*reason_id = PIN_REASON_ID_FAIL_DECL_HARD;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_NO_MIN:
					*reason_id = PIN_REASON_ID_FAIL_NO_MIN;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_INVALID_CMD:
					*reason_id = PIN_REASON_ID_INVALID_CMD;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_SELECT_ITEMS:
					*reason_id = PIN_REASON_ID_FAIL_SELECT_ITEMS;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_CVV_BAD:
					*reason_id = PIN_REASON_ID_FAIL_CVV_BAD;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_NO_CREDIT_BALANCE:
					*reason_id =  PIN_REASON_ID_NO_CREDIT_BALANCE;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_LOGICAL_PROBLEM:
					*reason_id = PIN_REASON_ID_FAIL_LOGICAL_PROBLEM;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_FORMAT_ERROR:
					*reason_id = PIN_REASON_ID_FAIL_FORMAT_ERROR;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_INVALID_CONTENT:
					*reason_id = PIN_REASON_ID_FAIL_INVALID_CONTENT;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				case PIN_CHARGE_RES_FAIL_TECHNICAL_PROBLEM:
					*reason_id = PIN_REASON_ID_FAIL_TECHNICAL_PROBLEM;
					*domain_idp = PIN_PYMT_FAILED_REASON_DOMAIN_ID;
					break;
				default:
					*reason_id = PIN_REASON_ID_DEFAULT;
					/*******************************************
					 * Setting the default reason domain
					 * since we are setting default reason ID
					 * The following line can be commented if
					 * the domain id has to be retained as 
					 * it was passed in the function.
					 ******************************************/
					*domain_idp = PIN_PYMT_REASON_DOMAIN_ID;
					break;
				}
			}
                }
	}
	/*************************************************
	 * Check Error buf and Debug it
	 ************************************************/
	if (PIN_ERR_IS_ERR(ebufp)) {
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_DEBUG,
                                "fm_pymt_pol_charge_process_result", ebufp);
	}

	return;
}
コード例 #19
0
static void
fm_get_meta_field(
	pcm_context_t           *ctxp,
        pin_flist_t             *in_flistp,
        pin_flist_t             **out_flistpp,
        pin_errbuf_t            *ebufp)
{
	pin_flist_t     *keys_flistp = NULL;
        pin_flist_t     *search_flistp = NULL;
        pin_flist_t     *flistp = NULL; 
        poid_t          *s_pdp = NULL; 
        poid_t          *bi_pdp = NULL; 
        int64           database = 0;
        int32           sflags = 256;
        int32           result = PIN_BOOLEAN_FALSE;
        void            *vp = NULL;
        pin_decimal_t   *zero_decimal =  pin_decimal("0.0", ebufp);
	pin_flist_t	*r_flistp = NULL;
	char                    *name = NULL;
	char                    *class_name = NULL;
	char                    *default_value;
	int32           count = 0;
	int32           cnt_flds = 0;
	int32                   elemid = 1;
	pin_errbuf_t            any_field_ebuf;
        pin_cookie_t            cookie = NULL;
        pin_fld_num_t           field = 0;
        int32                   rec_id = 0;
	void            *type = NULL;

        if (PIN_ERR_IS_ERR(ebufp)) {
                return;
        }
        PIN_ERR_CLEAR_ERR(ebufp);
	PIN_ERR_CLEAR_ERR(&any_field_ebuf);
	
	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "fm_get_meta_field input flistp", in_flistp);
	bi_pdp = (poid_t *) PIN_FLIST_FLD_GET(in_flistp,
                                PIN_FLD_POID,0, ebufp);

	count = PIN_FLIST_ELEM_COUNT (in_flistp,
                        PIN_FLD_KEYS, ebufp);
	if (count == 0)
        {

                 pin_set_err(ebufp, PIN_ERRLOC_FM,
                        PIN_ERRCLASS_SYSTEM_DETERMINATE,
                        PIN_ERR_BAD_OPCODE, 0, 0, count);
                PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                        "op_get_meta_field search flistp", ebufp);

                *out_flistpp = NULL;
                return;
        }

	else {
	keys_flistp = PIN_FLIST_ELEM_GET (in_flistp, PIN_FLD_KEYS,
                PIN_ELEMID_ANY, 0, ebufp);
	while (PIN_FLIST_ANY_GET_NEXT(keys_flistp, &field,
                                &rec_id, &cookie, &any_field_ebuf) != NULL ){
        cnt_flds = cnt_flds + 1;
	if (field == PIN_FLD_NAME){
 	name = (char *)PIN_FLIST_FLD_GET(keys_flistp, PIN_FLD_NAME, 1, ebufp);
	}
	if (field == PIN_FLD_CLASS_NAME){
       class_name = PIN_FLIST_FLD_GET(keys_flistp, PIN_FLD_CLASS_NAME, 0, ebufp );
	}
	if (field == PIN_FLD_TYPE){
	type = PIN_FLIST_FLD_GET(keys_flistp, PIN_FLD_TYPE, 0, ebufp );			
	}
	}
	if ( cnt_flds == 1)
        {
        vp = (void *)"select X from /metafield where F1 = V1 ";
        }
        if ( cnt_flds == 2)
        {
        vp = (void *)"select X from /metafield where F1 = V1 and F2 = V2 ";
        }
        if ( cnt_flds == 3)
        {
        vp = (void *)"select X from /metafield where F1 = V1 and F2 = V2 and F3 = V3 ";
        }

	 /*********************************************************
         * Create the search flist to search in the item objects
         *********************************************************/
        search_flistp = PIN_FLIST_CREATE(ebufp);
        database = PIN_POID_GET_DB(bi_pdp);
        s_pdp = PIN_POID_CREATE(database, "/search", -1, ebufp);
        PIN_FLIST_FLD_PUT(search_flistp, PIN_FLD_POID, (void *)s_pdp, ebufp);
       /******************************************************************
         * Set the search template.
         ******************************************************************/
        PIN_FLIST_FLD_SET(search_flistp, PIN_FLD_TEMPLATE, vp, ebufp);
        PIN_FLIST_FLD_SET(search_flistp, PIN_FLD_FLAGS, (void *)&sflags, ebufp);

	/*********************************************************
         * Add the search arguments.
         *********************************************************/
	if (name != NULL) {
        flistp = PIN_FLIST_ELEM_ADD(search_flistp, PIN_FLD_ARGS, elemid++, ebufp);
        PIN_FLIST_FLD_SET(flistp, PIN_FLD_NAME, name, ebufp);
	}

        /*********************************************************
         * Add the search arguments.
         *********************************************************/
	if (class_name != NULL) {
        flistp = PIN_FLIST_ELEM_ADD(search_flistp, PIN_FLD_ARGS, elemid++, ebufp);
        PIN_FLIST_FLD_SET(flistp, PIN_FLD_CLASS_NAME, class_name, ebufp);
        }
	
	/*********************************************************
         * Add the search arguments.
         *********************************************************/
        if (type != NULL) {
        flistp = PIN_FLIST_ELEM_ADD(search_flistp, PIN_FLD_ARGS, elemid++, ebufp);
        PIN_FLIST_FLD_SET(flistp, PIN_FLD_TYPE, type, ebufp);
        }


        /*********************************************************
         * Add the result array for the search.
         *********************************************************/

        flistp = PIN_FLIST_ELEM_ADD(search_flistp, PIN_FLD_RESULTS, 0, ebufp);
	PIN_FLIST_FLD_SET(flistp, PIN_FLD_TYPE,(void *)NULL, ebufp);
        
	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_get_meta_field search flistp", search_flistp);  

	 PCM_OP(ctxp, PCM_OP_SEARCH, 0, search_flistp, out_flistpp, ebufp);

	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_get_meta_field search flistp", *out_flistpp);
	}
	     
 	}
コード例 #20
0
/**********************************************************************
 * fm_pymt_pol_spec_collect_get_ach()
 * Get ACH information
 **********************************************************************/
static void
fm_pymt_pol_spec_collect_get_ach(
	pcm_context_t	*ctxp,
	int32		flags,
	pin_flist_t	*i_flistp,
	pin_flist_t	*o_flistp,
	pin_errbuf_t	*ebufp)
{

	void		*vp		= NULL;
	pin_flist_t	*flistp		= NULL;
	pin_flist_t	*p_flistp	= NULL;
	pin_flist_t	*rp_flistp	= NULL;
	pin_flist_t	*a_flistp	= NULL;
	pin_flist_t	*ra_flistp	= NULL;
	int32		rec_id		= 0;
	poid_t		*p_pdp		= NULL;
	poid_t		*a_pdp		= NULL;

	if (PIN_ERR_IS_ERR(ebufp)) {
		return;
	}

	PIN_ERR_CLEAR_ERR(ebufp);

	p_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_PAYINFO_OBJ, 0, ebufp);
        a_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	
	/** read the payinfo to get the ach pointer. **/
	p_flistp = PIN_FLIST_CREATE(ebufp);
	PIN_FLIST_FLD_SET(p_flistp, PIN_FLD_POID, p_pdp, ebufp);
	PIN_FLIST_FLD_SET(p_flistp, PIN_FLD_ACH, &rec_id, ebufp);
	
	PCM_OP(ctxp, PCM_OP_READ_FLDS, PCM_OPFLG_READ_UNCOMMITTED, 
					p_flistp, &rp_flistp, ebufp);	

	if (rp_flistp != (pin_flist_t *)NULL) {
		vp = PIN_FLIST_FLD_GET(rp_flistp, PIN_FLD_ACH, 0, ebufp);
		
		if (vp) {
			rec_id = *(int32 *)vp;
		}
                a_flistp = PIN_FLIST_CREATE(ebufp);
                PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, a_pdp, ebufp);
                PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_ACH,
                                                (void *) &rec_id, ebufp);

                PCM_OP(ctxp, PCM_OP_PYMT_GET_ACH_INFO, 0, a_flistp,
                                                &ra_flistp, ebufp);

                flistp = PIN_FLIST_ELEM_GET(ra_flistp, PIN_FLD_RESULTS, 0,
                                                PIN_ELEMID_ANY, ebufp);

                vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_MERCHANT, 0, ebufp);
                PIN_FLIST_FLD_SET(o_flistp, PIN_FLD_MERCHANT, vp, ebufp);

                PIN_FLIST_FLD_SET(o_flistp, PIN_FLD_ACH, (void *) &rec_id, ebufp);

                vp = PIN_FLIST_FLD_TAKE(flistp, PIN_FLD_POID_VAL, 0, ebufp);

                flistp = PIN_FLIST_ELEM_ADD(o_flistp, PIN_FLD_BATCH_INFO, 0,
                                                                ebufp);
                PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID_VAL, vp, ebufp);
	}

	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
				"fm_pymt_pol_spec_collect_get_ach error", ebufp);
	}

	PIN_FLIST_DESTROY_EX(&p_flistp, NULL);
	PIN_FLIST_DESTROY_EX(&rp_flistp, NULL);
	PIN_FLIST_DESTROY_EX(&a_flistp, NULL);
	PIN_FLIST_DESTROY_EX(&ra_flistp, NULL);

	return;
}
コード例 #21
0
/*
 * Search for a brand name within a brand.
 */
static void
fm_cust_pol_is_brandname_unique_within_brand(
	pcm_context_t		*ctxp,
	poid_t			*poidp,
	char			*namep,
	pin_flist_t		**r_flistpp,
	pin_errbuf_t		*ebufp)
{
	pin_flist_t		*flistp = (pin_flist_t *)NULL;
	pin_flist_t		*rlistp = (pin_flist_t *)NULL;
	pin_flist_t		*sublistp;
	poid_t			*search_poidp;
	int32			int_val;
	int32			cred;
	pin_account_type_t	brand_type = PIN_ACCOUNT_TYPE_BRAND;
	pin_cookie_t		cookie = (pin_cookie_t)NULL;
	pin_flist_t             *b_flistp = NULL;
	pin_flist_t             *t_flistp = NULL;
	poid_t                  *b_pdp = NULL;
	poid_t                  *g_pdp = NULL;
	poid_t                  *rootp = NULL;
	int32                   elemid = 0;
	int			under_host = PIN_BOOLEAN_FALSE;
	void			*vp = NULL;

	/*
	 * If there are pending errors, then short circuit immediately
	 */
        if (PIN_ERR_IS_ERR(ebufp))
                return;
        PIN_ERR_CLEAR_ERR(ebufp);

	fm_utils_lineage_get_brand_hierarchy(ctxp, poidp, &b_flistp, ebufp);
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_is_brandname_unique_within_brand() : "
			"Call to get brand hierarchy failed ",
			ebufp);
	 	PIN_FLIST_DESTROY_EX (&b_flistp, NULL);
		fm_cust_pol_read_err_return_list(poidp, namep, r_flistpp,
			ebufp);
                goto cleanup;
        }

        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
		"Got brand hierarchy.  Return flist :", b_flistp);

	t_flistp = PIN_FLIST_ELEM_GET_NEXT(b_flistp,
		PIN_FLD_RESULTS, &elemid, 1, &cookie, ebufp);
	if (PIN_ERR_IS_ERR(ebufp) || t_flistp == (pin_flist_t *)NULL) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_is_brandname_unique_within_brand() : "
			"Call to get first brand failed ",
			ebufp);
		PIN_FLIST_DESTROY_EX (&b_flistp, NULL);
		fm_cust_pol_read_err_return_list(poidp, namep, r_flistpp,
			ebufp);
                goto cleanup;
	}
	
	/********************************************
	 * Get the first brand object from hierarchy
	 ********************************************/
	b_pdp = PIN_FLIST_FLD_GET(t_flistp, PIN_FLD_BRAND_OBJ, 0, ebufp);

	/***************************************************************
	 * During the brand creation, the first brand object from the
	 * the hierarchy is the parent brand. But, for an existing 
	 * brand, the first object is self, the next one in hierarchy 
	 * is the parent brand.
	 ***************************************************************/
	if (!PIN_POID_COMPARE(b_pdp, poidp, 0, ebufp)) {
		PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "first brand is self");
		t_flistp = PIN_FLIST_ELEM_GET_NEXT(b_flistp,
			PIN_FLD_RESULTS, &elemid, 1, &cookie, ebufp);
		if (PIN_ERR_IS_ERR(ebufp) || t_flistp == (pin_flist_t *)NULL) {
			PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_is_brandname_unique_within_brand() : "
			"Call to get second brand failed ",
			ebufp);
			PIN_FLIST_DESTROY_EX (&b_flistp, NULL);
			fm_cust_pol_read_err_return_list(poidp, namep, 	
				r_flistpp, ebufp);
                	goto cleanup;
		}
	 	/* Get the parent brand object */
		b_pdp = PIN_FLIST_FLD_GET(t_flistp, PIN_FLD_BRAND_OBJ, 
			0, ebufp);
	}
	else {
		PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "first brand is parent");
	}

	PIN_ERR_LOG_POID(PIN_ERR_LEVEL_DEBUG, "parent brand = ", b_pdp);

	/***************************************************************
	 * Check to see if we are creating brand under brandhost
	 ***************************************************************/
	rootp = PIN_POID_CREATE(PIN_POID_GET_DB(poidp), "/account", 1, ebufp);
	if (!PIN_POID_COMPARE(b_pdp, rootp, 0, ebufp)) {
		under_host = PIN_BOOLEAN_TRUE;  /* creating brand under 
						   brandhost */
	}
	else {	/* creating sub-brand under a brand */
		/* get the group_obj_id0 for the parent brand */
		cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); 
		g_pdp = fm_utils_lineage_get_billing_group_by_parent(ctxp, 
			b_pdp, ebufp);
		CM_FM_END_OVERRIDE_SCOPE(cred); 
		if (PIN_ERR_IS_ERR(ebufp) || g_pdp == (poid_t*)NULL) {
			PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_is_brandname_unique_within_brand() : "
			"Call to get parent group failed ",
			ebufp);
			PIN_POID_DESTROY(rootp, NULL);
			PIN_FLIST_DESTROY_EX (&b_flistp, NULL);
			fm_cust_pol_read_err_return_list(poidp, namep, 
				r_flistpp, ebufp);
                	goto cleanup;
		}
	}
	PIN_POID_DESTROY(rootp, NULL);
	PIN_FLIST_DESTROY_EX (&b_flistp, NULL);
	
	/*
	 * Create search flist to try to figure out if someother brand already
	 * has this name within the parent brand.
	 */
	flistp = PIN_FLIST_CREATE(ebufp);
	search_poidp = PIN_POID_CREATE(PIN_POID_GET_DB(poidp), "/search", -1,
		ebufp);
	PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, (void *)search_poidp, ebufp);
	int_val = SRCH_DISTINCT;
	PIN_FLIST_FLD_SET(flistp, PIN_FLD_FLAGS, (void *)&int_val, ebufp);

	/***************************************************************
	 * We need different search templates for checking duplicate
	 * brandnames under the brandhost or another brand.
	 * The brandhost doesnot have an entry in the /group/billing
	 * storable class. The only way we can get the names of the 
	 * existing brands under the brandhost is to check the lineage
	 * tag. Arguments 1 to 3 are the same for both search templates,
	 * but arguments 4 & 5 are different. 
	 ***************************************************************/
	if (under_host == PIN_BOOLEAN_FALSE) {  
		/* creating sub-brands under a brand */
		PIN_FLIST_FLD_SET(flistp, PIN_FLD_TEMPLATE, 
			(void *)TEMPLATE_UNIQUE_UNDER_BRAND, ebufp);
	}
	else {                   /* creating brand under brandhost */
		PIN_FLIST_FLD_SET(flistp, PIN_FLD_TEMPLATE, 
			(void *)TEMPLATE_UNIQUE_UNDER_BRANDHOST, ebufp);
	}
	PIN_FLIST_ELEM_SET(flistp, NULL, PIN_FLD_RESULTS, 0, ebufp);

	/*
	 * Arg 1 is the type of the account; only interested in brand accounts
	 */
	sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 1, ebufp);
	PIN_FLIST_FLD_SET(sublistp, PIN_FLD_ACCOUNT_TYPE, (void *)&brand_type,
		ebufp);

	/*
	 * Arg 2 is the name of the brand.
	 */
	sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 2, ebufp);
	PIN_FLIST_FLD_SET(sublistp, PIN_FLD_NAME, (void *)namep, ebufp);

	/*
	 * Arg 3 -- POID of account
	 */
	sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 3, ebufp);
	PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_POID, NULL, ebufp);

	if (under_host == PIN_BOOLEAN_FALSE) {  
		/* creating sub-brands under a brand */
		/*
	 	 * Arg 4 -- OBJECT_ID of members from /group/billing 
	 	 */
		sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 4, ebufp);
		sublistp = PIN_FLIST_ELEM_ADD(sublistp, PIN_FLD_MEMBERS, 
			PIN_ELEMID_ANY, ebufp);
        	PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_OBJECT, (void *)NULL, 
			ebufp);

		/*
	 	 * Arg 5 -- POID of the group
	 	 */
		sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 5, ebufp);
		PIN_FLIST_FLD_SET(sublistp, PIN_FLD_POID, (void *)g_pdp, ebufp);
	}
	else {                   /* creating brand under brandhost */
		/*
	 	 * Arg 4 -- Parent of the group
	 	 */
		sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 4, ebufp);
		PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_PARENT, NULL, ebufp);

		/*
	 	 * Arg 5 -- LINEAGE of account
	 	 */
		/* accounts under brandhost have only one ":" in their
		   lineage tag. We want to exclude others. */

		vp = (void *)"%:%:%";	
		sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 5, ebufp);
		PIN_FLIST_FLD_SET(sublistp, PIN_FLD_LINEAGE, vp, ebufp);
	}

        /*
         * Arg 6 -- POID of current account
         */
        sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 6, ebufp);
        PIN_FLIST_FLD_SET(sublistp, PIN_FLD_POID, poidp, ebufp);

	/*
	 * For completeness, dump the input flist if debugging is enabled.
	 */
        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
                          "fm_cust_pol_is_brandname_unique_within_brand search input flist:",
                          flistp);

	/*
	 * Ready to search! Temporarily suspend search to ensure that
	 * all brands are traversed.
	 */
	cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT);
	PCM_OP(ctxp, PCM_OP_GLOBAL_SEARCH, PCM_OPFLG_COUNT_ONLY, 
		flistp, &rlistp, ebufp);
	CM_FM_END_OVERRIDE_SCOPE(cred);

	/*
	 * For completeness, dump the results flist if debugging is enabled
	 * and we actually have a results flist.
	 */
	if(rlistp != (pin_flist_t *)NULL) {
		PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
			"fm_cust_pol_is_brandname_unique_within_brand search output flist:",
			rlistp);
	}

	/* 
	 * See if there is a brand out there right now that already has
	 * this name. If so, flag it as an error.
	 */
	cookie = (pin_cookie_t)NULL;
	int_val = 0;
	PIN_FLIST_ELEM_GET_NEXT(rlistp, PIN_FLD_RESULTS, &int_val, 1, 
		&cookie, ebufp);
	if(int_val > 0) {
		*r_flistpp = PIN_FLIST_CREATE(ebufp);
		PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_POID, (void *)poidp, 
			ebufp);
		fm_cust_pol_valid_add_fail(*r_flistpp, 
			PIN_FLD_NAME,
			0,
			PIN_CUST_VAL_ERR_DUPE,
			PIN_CUST_DUPE_VALUE_ERR_MSG,
			(void *)namep, ebufp);

		pin_set_err(ebufp, PIN_ERRLOC_FM,
			PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_DUPLICATE, PIN_FLD_NAME, 
			0, 0);
	}

cleanup:
	/*
	 * Cleanup and return
	 */
	PIN_FLIST_DESTROY_EX(&flistp, NULL);
	PIN_FLIST_DESTROY_EX(&rlistp, NULL);
	PIN_POID_DESTROY(g_pdp, NULL);
}
コード例 #22
0
/*******************************************************************
 * Main routine for the PCM_OP_PYMT_POL_SPEC_COLLECT operation.
 *******************************************************************/
void
op_pymt_pol_spec_collect(
        cm_nap_connection_t	*connp,
	int32			opcode,
        int32			flags,
        pin_flist_t		*i_flistp,
        pin_flist_t		**o_flistpp,
        pin_errbuf_t		*ebufp)
{
	pcm_context_t		*ctxp = connp->dm_ctx;
	pin_flist_t		*r_flistp = NULL;
	pin_bill_type_t		*p_type = NULL;
	int32			result = PIN_BOOLEAN_FALSE;

	char			*action = NULL;

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/***********************************************************
	 * Insanity check.
	 ***********************************************************/
	if (opcode != PCM_OP_PYMT_POL_SPEC_COLLECT) {
		pin_set_err(ebufp, PIN_ERRLOC_FM,
			PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_BAD_OPCODE, 0, 0, opcode);
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"op_pymt_pol_spec_collect opcode error", ebufp);
		return;
	}

	/***********************************************************
	 * Debug: What we got.
	 ***********************************************************/
	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
		"op_pymt_pol_spec_collect input flist", i_flistp);

	/***********************************************************
	 * Prep the return flist.
	 ***********************************************************/
	r_flistp = PIN_FLIST_CREATE(ebufp);

	/***********************************************************
	 * Get the requested action. The following are supported:
	 *	- "commit customer"
	 *
	 ***********************************************************/
	action = (char *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_ACTION, 0, ebufp);

	if ((action != (char *)NULL) && (!strcmp(action, "commit customer"))) {

		p_type = (pin_bill_type_t *)PIN_FLIST_FLD_GET(i_flistp,
			PIN_FLD_PAY_TYPE, 0, ebufp);

		/***************************************************
		 * Credit card
		 ***************************************************/
		if ((p_type != NULL) && (*p_type == PIN_BILL_TYPE_CC)) {
			fm_pymt_pol_spec_collect_commit_cust_cc(ctxp,
				flags, i_flistp, r_flistp, ebufp);

		/***************************************************
		 * Direct Debit
		 ***************************************************/
		} else if ((p_type != NULL) && (*p_type == PIN_BILL_TYPE_DD)) {
			fm_pymt_pol_spec_collect_commit_cust_dd(ctxp,
				flags, i_flistp, r_flistp, ebufp);

		/***************************************************
		 * Assume nothing to collect
		 ***************************************************/
		} else {
			result = PIN_BOOLEAN_FALSE;
			PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_BOOLEAN,
			(void *)&result, ebufp);
        	}

	} else {
		pin_set_err(ebufp, PIN_ERRLOC_FM,
			PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_BAD_VALUE, PIN_FLD_ACTION, 0, 0);
	}

	/***********************************************************
	 * Results.
	 ***********************************************************/
	if (PIN_ERR_IS_ERR(ebufp)) {

		/***************************************************
		 * Log something and return nothing.
		 ***************************************************/
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"op_pymt_pol_spec_collect error", ebufp);
		PIN_FLIST_DESTROY_EX(&r_flistp, NULL);
		*o_flistpp = NULL;

	} else {

		/***************************************************
		 * Point the real return flist to the right thing.
		 ***************************************************/
		PIN_ERR_CLEAR_ERR(ebufp);
		*o_flistpp = r_flistp;

		/***************************************************
		 * Debug: What we're sending back.
		 ***************************************************/
		PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
			"op_pymt_pol_spec_collect return flist", r_flistp);

	}

	return;
}
コード例 #23
0
/*******************************************************************
 * Main routine for the PCM_OP_PRICE_POL_DELETE_DEAL operation.
 *******************************************************************/
EXPORT_OP void
op_price_pol_delete_deal(
        cm_nap_connection_t	*connp,
	u_int32			opcode,
        u_int32			flags,
        pin_flist_t		*i_flistp,
        pin_flist_t		**r_flistpp,
        pin_errbuf_t		*ebufp)
{
	pcm_context_t		*ctxp = connp->dm_ctx;
	u_int32			result;
	void			*vp = NULL;

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/*
	 * Null out results until we have some.
	 */
	*r_flistpp = NULL;

	/*
	 * Insanity check.
	 */
	if (opcode != PCM_OP_PRICE_POL_DELETE_DEAL) {
		pin_set_err(ebufp, PIN_ERRLOC_FM,
			PIN_ERRCLASS_SYSTEM_DETERMINATE,
			PIN_ERR_BAD_OPCODE, 0, 0, opcode);
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"bad opcode in op_price_pol_delete_deal", ebufp);
		return;
	}

	/*
	 * Debug - What we got.
	 */
	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
		"op_price_pol_delete_deal input flist", i_flistp);

	/*
	 * Setup the result flist
	 */
	*r_flistpp = PIN_FLIST_CREATE(ebufp);

	vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp);
	PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_POID, vp, ebufp);

	result = PIN_PRICE_VERIFY_PASSED;
	PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_RESULT, (void *)&result, ebufp);

	/*
	 * Error?
	 */
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_DEBUG,
			"op_price_pol_delete_deal error", ebufp);
	} else {
		PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
			"op_price_pol_delete_deal return flist", *r_flistpp);
	}

	return;
}
コード例 #24
0
/*******************************************************************
 * fm_act_pol_add_event_bal_impacts():
 *******************************************************************/
void
fm_act_pol_add_event_bal_impacts(
    pcm_context_t		*ctxp,
    pin_flist_t		*a_flistp,
    pin_errbuf_t		*ebufp)
{
    pin_cookie_t		cookie = NULL;
    pin_flist_t		*bi_flistp = NULL;
    pin_flist_t		*flistp = NULL;
    pin_flist_t		*bia_flistp = NULL;
    poid_t			*r_pdp = NULL;
    void			*vp = NULL;

    int			impact_type = 0;
    int			count = 0;
    int			rec_id = 0;
    pin_decimal_t 		*dummyp = NULL;

    if (PIN_ERR_IS_ERR(ebufp))
        return;
    PIN_ERR_CLEAR_ERR(ebufp);

    dummyp = pbo_decimal_from_str("0.0", ebufp);
    /***********************************************************
     * Set the balance impact type as pre-rated.
     ***********************************************************/
    impact_type = PIN_IMPACT_TYPE_PRERATED;

    bia_flistp = PIN_FLIST_CREATE(ebufp);

    /***********************************************************
     * Walk the PIN_FLD_TOTALS array in the original event and
     * add a corresponding balance impact arary for that.
     ***********************************************************/
    while ((flistp = PIN_FLIST_ELEM_GET_NEXT(a_flistp, PIN_FLD_TOTAL,
                     &rec_id, 1, &cookie, ebufp)) != (pin_flist_t *)NULL) {

        /***************************************************
         * Add a new element for this balance impact.
         ***************************************************/
        count = (int)PIN_FLIST_ELEM_COUNT(bia_flistp,
                                          PIN_FLD_BAL_IMPACTS, ebufp);
        bi_flistp = PIN_FLIST_ELEM_ADD(bia_flistp,
                                       PIN_FLD_BAL_IMPACTS, count, ebufp);

        /***************************************************
         * Start filling in the standard field values now.
         ***************************************************/
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_IMPACT_TYPE,
                          (void *)&impact_type, ebufp);
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_RESOURCE_ID,
                          (void *)&rec_id, ebufp);
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_TAX_CODE,
                          (void *)"", ebufp);
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_RATE_TAG,
                          (void *)"", ebufp);

        /***************************************************
         * Get and Set the account and item object poids.
         ***************************************************/
        vp = PIN_FLIST_FLD_GET(a_flistp,
                               PIN_FLD_ACCOUNT_OBJ, 0, ebufp);
        PIN_FLIST_FLD_SET(bi_flistp,
                          PIN_FLD_ACCOUNT_OBJ, vp, ebufp);

        vp = PIN_FLIST_FLD_GET(a_flistp,
                               PIN_FLD_ITEM_OBJ, 1, ebufp);
        if (vp) {
            PIN_FLIST_FLD_SET(bi_flistp,
                              PIN_FLD_ITEM_OBJ, vp, ebufp);
        }

        /***************************************************
         * Fill in the dummy rate object poid.
         ***************************************************/
        r_pdp = PIN_POID_CREATE(0, "", 0, ebufp);
        PIN_FLIST_FLD_PUT(bi_flistp, PIN_FLD_RATE_OBJ,
                          (void *)r_pdp, ebufp);

        /***************************************************
         * set the 0 for quantity, discount and percentage
         ***************************************************/
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_DISCOUNT,
                          (void *)dummyp, ebufp);
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_PERCENT,
                          (void *)dummyp, ebufp);
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_QUANTITY,
                          (void *)dummyp, ebufp);

        /***************************************************
         * Set the amount deferred to 0.0
         ***************************************************/
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_AMOUNT_DEFERRED,
                          (void *)dummyp, ebufp);

        /***************************************************
         * Get the amount and set in the bal impact.
         ***************************************************/
        vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_AMOUNT, 0, ebufp);
        PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_AMOUNT, vp, ebufp);

    }

    PIN_FLIST_CONCAT(a_flistp, bia_flistp, ebufp);

    PIN_FLIST_DESTROY_EX(&bia_flistp, NULL);
    pbo_decimal_destroy(&dummyp);
    /***********************************************************
     * Error?
     ***********************************************************/
    if (PIN_ERR_IS_ERR(ebufp)) {
        PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                         "fm_act_pol_add_event_bal_impacts error", ebufp);
    }

    return;
}
コード例 #25
0
void
fm_cust_pol_create_metafield_obj(
    pcm_context_t           *ctxp,
    int32                    flags,
    pin_flist_t             *in_flistp,
    pin_flist_t            **ret_flistpp,
    pin_errbuf_t            *ebufp)

{
    void 		   *vp = NULL;
    int 		   count =0;
    int64        database  = pcm_get_current_db_no(ctxp);
    pin_flist_t   *i_flist = NULL;
    pin_flist_t   *sub_flistp = NULL;
    pin_flist_t   *r_flistp = NULL;
    char 	      *program_name = NULL;
    char 	      *class_name= NULL;
    char 	      *default_value= NULL;
    int 	       fld_type=0;

    if(PIN_ERRBUF_IS_ERR(ebufp))
        return;
    PIN_ERR_CLEAR_ERR(ebufp);

    *ret_flistpp = NULL;

    //Count FIELDS array
    count = PIN_FLIST_ELEM_COUNT(in_flistp,PIN_FLD_VALUES,ebufp);


    if (count==0)
        return;

    if(count==1)
    {

        i_flist= PIN_FLIST_CREATE(ebufp);
        vp = PIN_FLIST_FLD_GET(in_flistp,PIN_FLD_POID,1,ebufp);
        PIN_FLIST_FLD_SET(i_flist,PIN_FLD_POID,(void*)vp,ebufp);

        sub_flistp = PIN_FLIST_ELEM_GET(in_flistp, PIN_FLD_VALUES,PIN_ELEMID_ANY, 1, ebufp);
        program_name = PIN_FLIST_FLD_GET(sub_flistp,PIN_FLD_NAME,1,ebufp);
        PIN_FLIST_FLD_SET(i_flist,PIN_FLD_NAME,program_name,ebufp);

        fld_type =*(int*) PIN_FLIST_FLD_GET(sub_flistp,PIN_FLD_TYPE,1,ebufp);
        PIN_FLIST_FLD_SET(i_flist,PIN_FLD_TYPE,&fld_type,ebufp);

        class_name=PIN_FLIST_FLD_GET(sub_flistp,PIN_FLD_CLASS_NAME,1,ebufp);
        PIN_FLIST_FLD_SET(i_flist,PIN_FLD_CLASS_NAME,class_name,ebufp);

        default_value=PIN_FLIST_FLD_GET(sub_flistp,PIN_FLD_DEFAULT_VALUE,1,ebufp);
        if(default_value)
            PIN_FLIST_FLD_SET(i_flist,PIN_FLD_DEFAULT_VALUE,default_value,ebufp);

        if (PIN_ERRBUF_IS_ERR(ebufp))
        {
            PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,"Error Occured while creating the input flist",ebufp);
            return;
        }

        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,"input flist for metafield obj ",i_flist);


        //Call pcm_op_create_obj
        PCM_OP(ctxp,PCM_OP_CREATE_OBJ,0,i_flist,ret_flistpp,ebufp);

        if(PIN_ERRBUF_IS_ERR(ebufp))
        {
            PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,"Error Occured while calling PCM_OP_CREATE_OBJ",ebufp);
            return;
        }

    }
    else if (count >1)
    {
        //Call pcm_op_bulk_create_obj
        PCM_OP(ctxp,PCM_OP_BULK_CREATE_OBJ ,0,in_flistp,ret_flistpp,ebufp);

        if(PIN_ERRBUF_IS_ERR(ebufp))
        {
            PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,"Error Occured while calling PCM_OP_BULK_CREATE_OBJ" ,ebufp);
            return;
        }
    }

    if(ret_flistpp)
        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,"Output flist for metafield obj ",*ret_flistpp);

    return;

}
コード例 #26
0
/*******************************************************************
 * fm_pymt_pol_charge_set_reason_id()
 * This function sets the PIN_FLD_REASON_ID
 *******************************************************************/
static void
fm_pymt_pol_charge_set_reason_id(
	pcm_context_t           *ctxp,
	pin_flist_t		*i_flistp,
	pin_errbuf_t		*ebufp)
{
	pin_flist_t		*res_flistp = NULL;
	pin_flist_t		*reason_flistp = NULL;
	pin_flist_t		*p_flistp = NULL;
	pin_flist_t		*iinfo_flistp = NULL;
	pin_cookie_t            cookie = NULL;
	int32			domain_id = PIN_PYMT_REASON_DOMAIN_ID;
	int32			reason_id = 0;
	int32			elem_id  = 0;
	void 			*vp = NULL;
	
	if (PIN_ERR_IS_ERR(ebufp))
	{
		return ;
	}
	PIN_ERR_CLEAR_ERR(ebufp);

	vp = (int32 *) PIN_FLIST_FLD_GET(i_flistp,
			PIN_FLD_STR_VERSION, 1, ebufp);
	if(vp){
		domain_id = * (int32 *) vp;
	}

	while ((res_flistp = PIN_FLIST_ELEM_GET_NEXT(i_flistp, PIN_FLD_RESULTS,
                        &elem_id, 1, &cookie, ebufp)) != NULL) {
                p_flistp = PIN_FLIST_SUBSTR_GET(res_flistp,
                                        PIN_FLD_PAYMENT, 1, ebufp);
		if(p_flistp)
		{
			iinfo_flistp = PIN_FLIST_SUBSTR_GET(p_flistp, 
					PIN_FLD_INHERITED_INFO, 1, ebufp);
			if (iinfo_flistp) {
				fm_pymt_pol_charge_process_result(ctxp, 
						iinfo_flistp,
						&reason_id,
						&domain_id,
						ebufp);
				reason_flistp = PIN_FLIST_ELEM_ADD(res_flistp,
							PIN_FLD_PAYMENT_REASONS,
							0, ebufp);
				PIN_FLIST_FLD_SET(reason_flistp,
						PIN_FLD_REASON_ID,
						(void *) &reason_id, ebufp);
				fm_pymt_pol_charge_set_domain_id(ctxp,
						p_flistp,
						reason_flistp,
						&domain_id,
						ebufp);
				
			}
		}
	}
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_DEBUG,
				"fm_pymt_pol_charge_set_reason_id", ebufp);
	}

	return;
}
コード例 #27
0
/*******************************************************************
 * fm_act_pol_spec_glid
 * Routine that assigns the G/L id for pre/partially rated events.
 *******************************************************************/
static void
fm_act_pol_spec_glid (
    cm_nap_connection_t	*connp,
    pin_flist_t		*i_flistp,
    const char			*event_type,
    pin_flist_t		*s_flistp,
    pin_errbuf_t		*ebufp)
{
    int			glid = 0;
    pcm_context_t           *ctxp = connp->dm_ctx;
    pin_flist_t		*p_flistp = NULL;
    pin_flist_t		*e_flistp = NULL;
    int32			*cmdp = NULL;

    /*******************************************************************
     * get glid from /config/map_glid based on event_type and
     * string version and string id of the Debit/Credit account
     * adjustment reason code, if any.
     *******************************************************************/

    e_flistp = PIN_FLIST_SUBSTR_GET(i_flistp, PIN_FLD_EVENT,
                                    0, ebufp);

    glid = fm_utils_get_glid(ctxp, e_flistp, ebufp);

    if (!strstr(event_type, "/event/billing/payment") &&
            !strstr(event_type, "/event/billing/refund")) {

        PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_GL_ID,
                          (void *)&glid, ebufp);
    } else {

        /**********************************************************
         * Check the command to see if it was PIN_CHARGE_CMD_REFUND
         **********************************************************/
        if (strstr(event_type, "/event/billing/payment")) {
            p_flistp = PIN_FLIST_SUBSTR_GET(e_flistp,
                                            PIN_FLD_PAYMENT, 0, ebufp);
        } else {
            p_flistp = PIN_FLIST_SUBSTR_GET(e_flistp,
                                            PIN_FLD_REFUND, 0, ebufp);
        }
        cmdp = (int32 *)PIN_FLIST_FLD_GET(p_flistp,
                                          PIN_FLD_COMMAND, 0, ebufp);

        if (PIN_ERR_IS_ERR(ebufp)) {
            PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                             "fm_act_pol_spec_glid error - no command",
                             ebufp);
            return;
        }

        if (*cmdp == PIN_CHARGE_CMD_REFUND) {
            /***********************************************
             * Important - This is where a GLID for the
             * refund should be specified, it is set to a
             * default of the payment GLID.
             ***********************************************/
            PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_GL_ID,
                              (void *)&glid, ebufp);
        } else {
            PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_GL_ID,
                              (void *)&glid, ebufp);
        }
    }
    return;
}
コード例 #28
0
//****************************************************
// updateStatus
// Pre:
// Post:
//
bool bs_UpdateStatus::updateStatus(
  pin_Session * pinp,
  poid_t * account_pdp,
  poid_t * service_pdp,
  int status,
  int status_flags,
  string source,
  string description,
  pin_flist_t   **return_flistpp,
  pin_errbuf_t  *ebufp  )
{
  pin_flist_t * x_flistp = NULL;
  pin_flist_t * d_flistp = NULL;
  pin_flist_t * f_flistp = NULL;
  pin_flist_t * f_outflistp = NULL;
  pin_errbuf_t  localebuf;
  int     flag=status_flags;
  poid_t * pdp = NULL;
  void * vp = NULL;
  bool rc;

  const string this_program("updateStatus");
  if ( source.empty() )
  {
    source.assign(this_program);
  }
  if ( description.empty() )
  {
    description.assign(this_program);
  }

  PIN_ERR_CLEAR_ERR(ebufp);

  //--enter function--------------
  PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, (char*)this_program.c_str() );


  /*--- Create set_status ---*/
  if ( status == PIN_STATUS_ACTIVE && status_flags <= 0 )
  {
    PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_ERROR,
      (char*)"This is an activation - get existing flags" );

    PIN_ERR_CLEAR_ERR(&localebuf);
    pdp = ( pin_poid_is_null(service_pdp)) ? account_pdp : service_pdp;

    f_flistp = PIN_FLIST_CREATE(ebufp);
    PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_POID, (void*)pdp, &localebuf);
    PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_STATUS_FLAGS, (void*)NULL, &localebuf);
    if ( pinp->call_opcode( PCM_OP_READ_FLDS, 0, f_flistp, &f_outflistp, &localebuf))
    {
      if ((vp=PIN_FLIST_FLD_GET(
        f_outflistp, PIN_FLD_STATUS_FLAGS, 1, &localebuf )) != NULL )
        status_flags = *(int*)vp;
    }
    if (f_flistp) PIN_FLIST_DESTROY(f_flistp,NULL); f_flistp = NULL;
    if (f_outflistp) PIN_FLIST_DESTROY_EX(&f_outflistp,NULL); f_outflistp = NULL;
  }
  if ( status_flags < 0) {
    status_flags = 0;
  }

  /*--- Create set_status ---*/
  x_flistp = PIN_FLIST_CREATE(ebufp);
  PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_POID, account_pdp, ebufp);
  if ( ! pin_poid_is_null(service_pdp) )
    PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_SERVICE_OBJ, service_pdp, ebufp);
  PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_PROGRAM_NAME, (void*)source.c_str(), ebufp);
  PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_DESCR, (void*)description.c_str(), ebufp);
  d_flistp = PIN_FLIST_ELEM_ADD( x_flistp, PIN_FLD_STATUSES, PIN_ELEMID_ASSIGN, ebufp );
    PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_STATUS, (void*)&status, ebufp);
    PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_STATUS_FLAGS, (void*)&status_flags, ebufp);

  if ( (! pin_poid_is_null(service_pdp)) && (status == PIN_STATUS_CLOSED) ) {
     rc = pinp->call_opcode(
         PCM_OP_CUST_SET_STATUS, 0, x_flistp, return_flistpp, ebufp);
  }
  else {
     rc = pinp->call_opcode(
         UOL_OP_SET_STATUS, 0, x_flistp, return_flistpp, ebufp);
  }

  PIN_ERR_LOG_FLIST(
    PIN_ERR_LEVEL_DEBUG,(char*)"leaving bs_UpdateStatus::updateStatus" , *return_flistpp );

  if (x_flistp) PIN_FLIST_DESTROY(x_flistp,NULL);
  return rc;
}
コード例 #29
0
/*******************************************************************
 * Main routine for the PCM_OP_ACT_POL_SPEC_GLID operation.
 *******************************************************************/
void
op_act_pol_spec_glid(
    cm_nap_connection_t	*connp,
    int			opcode,
    int			flags,
    pin_flist_t		*i_flistp,
    pin_flist_t		**r_flistpp,
    pin_errbuf_t		*ebufp)
{
    pin_cookie_t		cookie = NULL;
    pcm_context_t		*ctxp = connp->dm_ctx;
    pin_flist_t		*e_flistp = NULL;
    pin_flist_t		*s_flistp = NULL;
    pin_flist_t		*flistp = NULL;
    const char			*event_type = NULL;
    poid_t			*e_pdp = NULL;

    int			rec_id = 0;
    int			*glid = NULL;

    if (PIN_ERR_IS_ERR(ebufp))
        return;
    PIN_ERR_CLEAR_ERR(ebufp);
    *r_flistpp = (pin_flist_t *)NULL;

    /*******************************************************************
     * Insanity check.
     *******************************************************************/
    if (opcode != PCM_OP_ACT_POL_SPEC_GLID) {
        pin_set_err(ebufp, PIN_ERRLOC_FM,
                    PIN_ERRCLASS_SYSTEM_DETERMINATE,
                    PIN_ERR_BAD_OPCODE, 0, 0, opcode);
        PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                         "op_act_pol_spec_glid bad opcode error", ebufp);
        return;
    }

    /*******************************************************************
     * Debug: What we got.
     *******************************************************************/
    PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
                      "op_act_pol_spec_glid input flist", i_flistp);

    /*******************************************************************
     * Our action will depend on the type of event
     * Get the event substruct to get all the needed data
     *******************************************************************/
    *r_flistpp = PIN_FLIST_COPY(i_flistp, ebufp);
    e_flistp = PIN_FLIST_SUBSTR_GET(*r_flistpp, PIN_FLD_EVENT, 0, ebufp);
    e_pdp = (poid_t *)PIN_FLIST_FLD_GET(e_flistp, PIN_FLD_POID, 0, ebufp);
    event_type = PIN_POID_GET_TYPE(e_pdp);

    /******************************************************************
     * Check PIN_FLD_RATES_USED array, add a dummy one if not.
     ******************************************************************/
    if (PIN_FLIST_ELEM_COUNT(e_flistp, PIN_FLD_BAL_IMPACTS, ebufp) == 0) {

        /**********************************************************
         * Add the bal impacts array for this pre-rates event.
         **********************************************************/
        fm_act_pol_add_event_bal_impacts(ctxp, e_flistp, ebufp);
    }

    /******************************************************************
     * Now walk the PIN_FLD_RATES_USED array and check for G/L ID.
     ******************************************************************/
    while ((flistp = PIN_FLIST_ELEM_GET_NEXT(e_flistp, PIN_FLD_BAL_IMPACTS,
                     &rec_id, 1, &cookie, ebufp)) != (pin_flist_t *)NULL) {

        /**********************************************************
         * G/L id is inside the PIN_FLD_SUBTOTAL array.
         **********************************************************/
        glid = (int *)PIN_FLIST_FLD_GET(flistp,
                                        PIN_FLD_GL_ID, 1, ebufp);

        /**********************************************************
         * We need to fill in the G/L id now.
         **********************************************************/
        if (glid == (int *)NULL) {
            fm_act_pol_spec_glid(connp, i_flistp,
                                 event_type, flistp, ebufp);
        }
    }

    /*******************************************************************
     * Error?
     *******************************************************************/
    if (PIN_ERR_IS_ERR(ebufp)) {
        PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
                         "op_act_pol_spec_glid error", ebufp);
    } else {
        PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
                          "op_act_pol_spec_glid return flist", *r_flistpp);
    }

    return;
}
コード例 #30
0
/*******************************************************************
 * fm_cust_pol_prep_inherited()
 *
 *	Prep the inherited info to be ready for on-line registration.
 *
 *	XXX STUBBED ONLY XXX
 *
 *	We do fill in an empty service_ip substruct if one is needed. 
 *
 *******************************************************************/
static void
fm_cust_pol_prep_inherited(
	pcm_context_t		*ctxp,
	pin_flist_t		*in_flistp,
	pin_flist_t		**out_flistpp,
        pin_errbuf_t		*ebufp)
{
	pin_flist_t		*flistp = NULL;
	pin_flist_t		*sub_flistp = NULL;
	poid_t			*s_pdp = NULL;
	int32			intValue = 0;
	int32			*intp = NULL;
	char			*strp = NULL;
	const char		*s_type = NULL;

	if (PIN_ERR_IS_ERR(ebufp))
		return;
	PIN_ERR_CLEAR_ERR(ebufp);

	/***********************************************************
	 * Create outgoing flist
	 ***********************************************************/
	*out_flistpp = PIN_FLIST_COPY(in_flistp, ebufp);

	/***********************************************************
	 * Dummy up the inherited info if none provided 
	 ***********************************************************/
	s_pdp = (poid_t *)PIN_FLIST_FLD_GET(in_flistp, PIN_FLD_POID, 0, ebufp);

	/**********************************************************
	 * Get the type information for quick comaparisons
	 **********************************************************/
	s_type = PIN_POID_GET_TYPE(s_pdp);

	/***********************************************************
	 * Add any mandatory "inherited_info" to the input flist. This
	 * effectively gets around the problem of missing substructs
	 * on service creations.
	 ***********************************************************/
        fm_utils_cust_add_missing_service_substructs(ctxp, *out_flistpp, ebufp);
	PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,
		"op_cust_pol_prep_inherited ouput flist after adding missing substructs...", *out_flistpp);

	/***********************************************************
	 * Next, for any services that require special initialization,
	 * do that right here.
	 ***********************************************************/
	if ( s_type ) {
		
		if (strstr(s_type, "/service/gsm")) {
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			flistp = PIN_FLIST_SUBSTR_GET(flistp,
				PIN_FLD_GSM_INFO, 0, ebufp);

			PIN_FLIST_FLD_SET(flistp, PIN_FLD_BEARER_SERVICE, (void *)" ",
						ebufp);
			PIN_FLIST_FLD_SET(flistp, PIN_FLD_PRIMARY_MSISDN,
						(void *)&intValue, ebufp);
                }
	
		if ((strcmp(s_type, "/service/telco") == 0) ||
			(strncmp(s_type, "/service/telco/", 15) == 0)) {
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			flistp = PIN_FLIST_SUBSTR_GET(flistp,
				PIN_FLD_TELCO_INFO, 0, ebufp);

			intValue = 1;
			PIN_FLIST_FLD_SET(flistp, PIN_FLD_PRIMARY_NUMBER,
				(void *)&intValue, ebufp);
        }

		if (strstr(s_type, "/service/telco/gsm") == s_type) {
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			flistp = PIN_FLIST_SUBSTR_GET(flistp,
				PIN_FLD_TELCO_INFO, 0, ebufp);

			/*
			 * By default Primary Number flag is 0 for GSM 
			 * services, so override the value set in above
			 * generic /service/telco block.
			 */
			intValue = 0;
			PIN_FLIST_FLD_SET(flistp, PIN_FLD_PRIMARY_NUMBER,
				(void *)&intValue, ebufp);

			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			flistp = PIN_FLIST_SUBSTR_GET(flistp,
				PIN_FLD_GSM_INFO, 0, ebufp);

			PIN_FLIST_FLD_SET(flistp, PIN_FLD_BEARER_SERVICE,
					(void *)"Bearer Service", ebufp);
			PIN_FLIST_FLD_SET(flistp, PIN_FLD_IMEI,
					(void *)"IMEI", ebufp);
		}

		if ( !strcmp("/service/telephony", s_type ) ) { 

			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			flistp = PIN_FLIST_SUBSTR_GET(flistp,
				PIN_FLD_SERVICE_TELEPHONY, 0, ebufp);

			intp = (int32 *)PIN_FLIST_FLD_GET(flistp, 
				PIN_FLD_MAX_ACTIVE_CALLS, 1, ebufp);
			if(intp == (int32 *)NULL) {
				/* Set "non-zero, non-blank" default values */
				intValue = 1;  /* Default Max Active Calls */
				PIN_FLIST_FLD_SET(flistp, PIN_FLD_MAX_ACTIVE_CALLS, 
						(void*)&intValue, ebufp);

			}

		}
	
		if ( !strcmp( "/service/ip/cable/teracomm", s_type ) ) {
			int32		zero = 0;
			int32		init_led_status;
	
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			sub_flistp = PIN_FLIST_SUBSTR_GET(flistp, 
				PIN_FLD_SERVICE_IP_CABLE, 0, ebufp);
			/*
		 	 * Set PIN_FLD_MODEM_MAC_ADDR and the bandwidth limit
		 	 * fields to known initial values, so that dm_teracomm
		 	 * can determine whether provisioning fields are set.
		 	 * The initial value for PIN_FLD_MODEM_MAC_ADDR is not
		 	 * a valid address (valid addresses are 12 hex. chars.).
		 	 */
			strp = (char *)PIN_FLIST_FLD_GET(sub_flistp, 
				PIN_FLD_MODEM_MAC_ADDR, 1, ebufp);
			if(strp == (char *)NULL) {
				PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_MODEM_MAC_ADDR,
					(void *)PIN_TERACOMM_UNSPECIFIED_MODEM_MAC_ADDR,
					ebufp);
			}
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_MIN_DOWNSTREAM_BANDWD,
					(void *)&zero, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_MAX_DOWNSTREAM_BANDWD,
					(void *)&zero, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_MIN_UPSTREAM_BANDWD,
					(void *)&zero, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_MAX_UPSTREAM_BANDWD,
					(void *)&zero, ebufp);
	
			/* 
		 	 * Initialize fields in /service/ip/cable/teracomm substruct.
		 	 */
			sub_flistp = PIN_FLIST_SUBSTR_GET(flistp, 
					PIN_FLD_SERVICE_IP_CABLE_TERACOMM, 0, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_IP_LIMIT,
					(void *)&zero, ebufp);
			init_led_status = PIN_TERACOMM_LED_STATUS_OFF;
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_LED_STATUS,
					(void *)&init_led_status, ebufp);
			strp = (char *)PIN_FLIST_FLD_GET(sub_flistp, 
					PIN_FLD_TERALINK_NAME, 1, ebufp);
			if(strp == (char *)NULL) {
				PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_TERALINK_NAME,
					(void *)"", ebufp);
			}
			strp = (char *)PIN_FLIST_FLD_GET(sub_flistp, 
					PIN_FLD_ASSOC_NETWORK, 1, ebufp);
			if(strp == (char *)NULL) {
				PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_ASSOC_NETWORK,
					(void *)"", ebufp);
			}
		}
	
		if ( !strcmp(PIN_MSEXCHANGE_SERVICE_TYPE_USER, s_type ) ) {
			char 		*int_str = "";
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			sub_flistp = PIN_FLIST_SUBSTR_GET(flistp, 
				PIN_FLD_SERVICE_MSEXCHANGE_USER, 0, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_ORG_UNIT_NAME,
					(void *)int_str, ebufp);
		}
		if ( !strcmp( PIN_MSEXCHANGE_SERVICE_TYPE_FIRSTADMIN, s_type ) ){
			int32		int_value = PIN_MSEXCHANGE_INIT_STATE_INT_VALUE;
			char 		*int_str = "";
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			sub_flistp = PIN_FLIST_SUBSTR_GET(flistp, 
				PIN_FLD_SERVICE_MSEXCHANGE_USER, 0, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_ORG_UNIT_NAME,
					(void *)int_str, ebufp);
			flistp = PIN_FLIST_SUBSTR_GET(*out_flistpp,
				PIN_FLD_INHERITED_INFO, 0, ebufp);
			sub_flistp = PIN_FLIST_SUBSTR_GET(flistp, 
				PIN_FLD_SERVICE_MSEXCHANGE_ORG, 0, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_ORG_DISPLAY_NAME,
					(void *)int_str, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_SMTP_DOMAIN_NAME,
					(void *)int_str, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_MAX_USER_COUNT,
					(void *)&int_value, ebufp);
			PIN_FLIST_FLD_SET(sub_flistp, PIN_FLD_DEFAULT_MAX_MBOX_SIZE,
					(void *)&int_value, ebufp);
		}
	}

	/***********************************************************
	 * Error?
	 ***********************************************************/
	if (PIN_ERR_IS_ERR(ebufp)) {
		PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR,
			"fm_cust_pol_prep_inherited error", ebufp);
	}

	return;
}