/******************************************************************* * 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; }
/******************************************************************* * 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; }
/******************************************************************* * 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; }
/******************************************************************* * fm_pymt_pol_collect_clear_pending(): *******************************************************************/ static void fm_pymt_pol_collect_clear_pending( pin_flist_t *r_flistp, pin_decimal_t *amount, char *descr, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; char *action; int count; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Don't bother with zero amounts. ***********************************************************/ if (pbo_decimal_sign(amount, ebufp) == 0) { return; /*****/ } /*********************************************************** * What elemid to add. ***********************************************************/ count = PIN_FLIST_ELEM_COUNT(r_flistp, PIN_FLD_ACTIVITIES, ebufp); /*********************************************************** * Add our element. ***********************************************************/ flistp = PIN_FLIST_ELEM_ADD(r_flistp, PIN_FLD_ACTIVITIES, count, ebufp); /*********************************************************** * Fill in our values. ***********************************************************/ action = "clear_pending"; PIN_FLIST_FLD_SET(flistp, PIN_FLD_ACTION, (void *)action, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AMOUNT, (void *)amount, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DESCR, (void *)descr, ebufp); return; }
/******************************************************************* * 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; }
/******************************************************************* * 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); }
/******************************************************************* * fm_pymt_pol_collect_set_status(): *******************************************************************/ static void fm_pymt_pol_collect_set_status( pin_flist_t *r_flistp, pin_status_t status, int flags, char *descr, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; char *action; int count; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * What elemid to add. ***********************************************************/ count = PIN_FLIST_ELEM_COUNT(r_flistp, PIN_FLD_ACTIVITIES, ebufp); /*********************************************************** * Add our element. ***********************************************************/ flistp = PIN_FLIST_ELEM_ADD(r_flistp, PIN_FLD_ACTIVITIES, count, ebufp); /*********************************************************** * Fill in our values. ***********************************************************/ action = "set_status"; PIN_FLIST_FLD_SET(flistp, PIN_FLD_ACTION, (void *)action, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)&status, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS_FLAGS, (void *)&flags, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DESCR, (void *)descr, ebufp); return; }
/***************************************************************** * 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 ; }
/************************************************************************ * 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; }
/******************************************************************* * 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; }
/******************************************************************* * 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; }
/* * build the return list in case of a read error for func * fm_cust_pol_is_brandname_unique_within_brand(). */ static void fm_cust_pol_read_err_return_list( poid_t *poidp, char *namep, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { *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_MISSING, PIN_CUST_BAD_VALUE_ERR_MSG, (void *)namep, ebufp); pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_READ, PIN_FLD_NAME, 0, 0); }
static void fm_pymt_pol_spec_collect_get_items( pcm_context_t *ctxp, int32 flags, pin_flist_t *i_flistp, pin_flist_t *o_flistp, pin_errbuf_t *ebufp) { pin_flist_t *items_flistp = NULL; pin_flist_t *r_flistp = NULL; pin_flist_t *flistp = NULL; poid_t *s_pdp = NULL; poid_t *bi_pdp = NULL; int32 status = 0; int64 database = 0; int32 sflags = SRCH_DISTINCT; int32 result = PIN_BOOLEAN_FALSE; void *vp = NULL; pin_decimal_t *zero_decimal = pin_decimal("0.0", ebufp); if (PIN_ERR_IS_ERR(ebufp)) { return; } PIN_ERR_CLEAR_ERR(ebufp); /********************************************************* * Get the ACH details. *********************************************************/ fm_pymt_pol_spec_collect_get_ach(ctxp, flags, i_flistp, o_flistp, ebufp); bi_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_BILLINFO_OBJ, 0, ebufp); /********************************************************* * Create the search flist to search in the item objects *********************************************************/ items_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(items_flistp, PIN_FLD_POID, (void *)s_pdp, ebufp); PIN_FLIST_FLD_SET(items_flistp, PIN_FLD_TEMPLATE, (void *) "select X from /item where F1 = V1 and ( F2 = V2 or F3 = V3 )" \ " and F4 != V4 order by F5 ", ebufp); PIN_FLIST_FLD_SET(items_flistp, PIN_FLD_FLAGS, (void *)&sflags, ebufp); /********************************************************* * Add the search arguments. *********************************************************/ flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AR_BILLINFO_OBJ, (void *)bi_pdp, ebufp); status = PIN_ITEM_STATUS_PENDING; flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 2, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)&status, ebufp); status = PIN_ITEM_STATUS_OPEN; flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 3, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)&status, ebufp); flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 4, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DUE, (void *)zero_decimal, ebufp); flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 5, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EFFECTIVE_T, (void *)NULL, ebufp); /********************************************************* * Add the results array for the search. *********************************************************/ flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_RESULTS, 0, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_POID,(void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_BILL_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AR_BILL_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ACCOUNT_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DUE,(void *) NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EFFECTIVE_T, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ITEM_TOTAL, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DISPUTED, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_RECVD, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ADJUSTED, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_TRANSFERED, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_CURRENCY, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ITEM_NO, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_BILLINFO_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AR_BILLINFO_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_SERVICE_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EVENT_POID_LIST, (void *)NULL, ebufp); /********************************************************** * search ALL Open and Pending items **********************************************************/ PCM_OP(ctxp, PCM_OP_SEARCH, PCM_OPFLG_READ_UNCOMMITTED , items_flistp, &r_flistp,ebufp); if (PIN_FLIST_FLD_COPY(r_flistp, PIN_FLD_RESULTS, o_flistp, PIN_FLD_ITEMS, ebufp) == 1) { result = PIN_BOOLEAN_TRUE; } PIN_FLIST_FLD_SET(o_flistp, PIN_FLD_BOOLEAN, (void *)&result, ebufp); /********************************************************* * Cleanup... *********************************************************/ PIN_FLIST_DESTROY_EX(&items_flistp, NULL); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); PIN_DECIMAL_DESTROY_EX(&zero_decimal); /********************************************************* * Errors..? *********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_spec_collect_get_items error", ebufp); } return; }
/******************************************************************* * 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; }
/* * 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); }
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; }
/* * Search for a brand name in the whole system. */ static void fm_cust_pol_is_brandname_unique_global( 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; /* * If there are pending errors, then short circuit immediately */ if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /* * Create search flist to try to figure out if someone brand already * has this name. * * NOTE: we really only need to search for accounts that are of type * 'brand' and of a particular name. Unfortunately, neither of these * fields are indexed by default, thus causing a performance problem. * * To get around this, we'll turn this into a complex search. We know * that brands are the parent of a /group/billing object, so glue that * in as well. That should be indexed... */ 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); PIN_FLIST_FLD_SET(flistp, PIN_FLD_TEMPLATE, (void *)"select X from /account 1, /group 2 where 1.F1 = V1 " "AND 1.F2 = V2 AND 1.F3 = 2.F4 AND 1.F5 != V5 ", 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); /* * 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 -- POID of current account */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 5, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_POID, poidp, ebufp); /* * 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); /* * See if there is a brand out there right now that already has * this name. If so, flag it as an error. */ 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 and return */ PIN_FLIST_DESTROY_EX(&flistp, NULL); PIN_FLIST_DESTROY_EX(&rlistp, NULL); }
/******************************************************************* * 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; }
/************************************************************************ * fm_cust_pol_valid_add_fail(): * * Add a field validation failure element to the given flist * using the info passed in. We assume the flist has N field * failures on it already with element ids of 0 to (N-1) so * we add a new element with an element id of N. * * No error checking is done on the values passed in, but we * do allow for some values to be optional according to the * PCM_OP_CUST_POL_VALID_* return flist specs. * * We return a pointer to the element we add to facilitate * layering (by the caller) of the validation failures within * substruct and array fields. * ************************************************************************/ pin_flist_t * fm_cust_pol_valid_add_fail( pin_flist_t *r_flistp, u_int field, u_int elemid, u_int result, char *descr, void *val, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; u_int my_id = 0; u_int type = 0; u_int fail = 0; if (PIN_ERR_IS_ERR(ebufp)) return(flistp); PIN_ERR_CLEAR_ERR(ebufp); /**************************************************************** * Create the field failure element. ****************************************************************/ my_id = PIN_FLIST_ELEM_COUNT(r_flistp, PIN_FLD_FIELD, ebufp); flistp = PIN_FLIST_ELEM_ADD(r_flistp, PIN_FLD_FIELD, my_id, ebufp); /**************************************************************** * If this is the first time, mark the main result as _FAILED. ****************************************************************/ if (my_id == 0) { fail = PIN_CUST_VERIFY_FAILED; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_RESULT, (void *)&fail, ebufp); } /**************************************************************** * The required fields. ****************************************************************/ /* ** PIN_FLD_FIELD_NUM. */ PIN_FLIST_FLD_SET(flistp, PIN_FLD_FIELD_NUM, (void *)&field, ebufp); /* ** PIN_FLD_RESULT. */ PIN_FLIST_FLD_SET(flistp, PIN_FLD_RESULT, (void *)&result, ebufp); /**************************************************************** * The optional fields. ****************************************************************/ /* ** PIN_FLD_ELEMENT_ID */ if (elemid != (u_int)NULL) { PIN_FLIST_FLD_SET(flistp, PIN_FLD_ELEMENT_ID, (void *)&elemid, ebufp); } /* ** PIN_FLD_DESCR. */ if (descr != (char *)NULL) { PIN_FLIST_FLD_SET(flistp, PIN_FLD_DESCR, (void *)descr, ebufp); } /* ** The actual field value. */ type = PIN_FIELD_GET_TYPE(field); switch (type) { case PIN_FLDT_ARRAY: case PIN_FLDT_SUBSTRUCT: break; default: /* Val reqd on list - even if NULL */ PIN_FLIST_FLD_SET(flistp, field, (void *)val, ebufp); } /* Error? */ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "error", ebufp); } return(flistp); }
/******************************************************************* * Step search. * * Performs a read-object step search for services with * md5 encrypted passwords. The first 10 such services are * retrieved in two blocks of 5 services each. * * The "one arg like" search for /service is 236. * *******************************************************************/ void sample_step_search( pcm_context_t *ctxp, u_int64 database, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; pin_flist_t *a_flistp = NULL; pin_flist_t *r_flistp = NULL; poid_t *objp = NULL; u_int64 id; char *passwd = "md5|%"; pin_cookie_t cookie = NULL; int32 rec_id; /*********************************************************** * Check the error buffer. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Allocate the flist for searching. ***********************************************************/ flistp = PIN_FLIST_CREATE(ebufp); /*********************************************************** * Allocate the search poid and give it to the flist. ***********************************************************/ id = (u_int64)236; objp = PIN_POID_CREATE(database, "/search", id, ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, (void *)objp, ebufp); /*********************************************************** * Add a search arguments array. ***********************************************************/ a_flistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 1, ebufp); /*********************************************************** * Put the password value in element 1 of the args array. ***********************************************************/ PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_PASSWD, (void *)passwd, ebufp); /*********************************************************** * Add a search results marker. * * Making this NULL forces the read-object result we want. * The key here is the value 5, which says give me the * first 5 results or objects. ***********************************************************/ a_flistp = (pin_flist_t *)NULL; PIN_FLIST_ELEM_PUT(flistp, a_flistp, PIN_FLD_RESULTS, 5, ebufp); /*********************************************************** * Call the DM to initiate the step search. ***********************************************************/ PCM_OP(ctxp, PCM_OP_STEP_SEARCH, 0, flistp, &r_flistp, ebufp); /*********************************************************** * Walk the first results array. ***********************************************************/ fprintf(stdout,"\n** The first 5 objects:\n"); a_flistp = PIN_FLIST_ELEM_GET_NEXT(r_flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); while (a_flistp != (pin_flist_t *)NULL) { /*************************************************** * Show this result. ***************************************************/ fprintf(stdout,"\nStep Search Result(%d) Flist:\n", rec_id); PIN_FLIST_PRINT(a_flistp, stdout, ebufp); /*************************************************** * Get the next result. ***************************************************/ a_flistp = PIN_FLIST_ELEM_GET_NEXT(r_flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); } /*********************************************************** * Recycle the results flist. ***********************************************************/ PIN_FLIST_DESTROY(r_flistp, NULL); r_flistp = (pin_flist_t *)NULL; /*********************************************************** * Call the DM to get the next 5 objects using step next. ***********************************************************/ PCM_OP(ctxp, PCM_OP_STEP_NEXT, 0, flistp, &r_flistp, ebufp); /*********************************************************** * Walk the next results array. ***********************************************************/ fprintf(stdout,"\n** The next 5 objects:\n"); cookie = NULL; a_flistp = PIN_FLIST_ELEM_GET_NEXT(r_flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); while (a_flistp != (pin_flist_t *)NULL) { /*************************************************** * Show this result. ***************************************************/ fprintf(stdout,"\nStep Search Result(%d) Flist:\n", rec_id); PIN_FLIST_PRINT(a_flistp, stdout, ebufp); /*************************************************** * Get the next result. ***************************************************/ a_flistp = PIN_FLIST_ELEM_GET_NEXT(r_flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); } /*********************************************************** * Recycle the results flist. ***********************************************************/ PIN_FLIST_DESTROY(r_flistp, NULL); r_flistp = (pin_flist_t *)NULL; /*********************************************************** * Call the DM to end step searching. ***********************************************************/ PCM_OP(ctxp, PCM_OP_STEP_END, 0, flistp, &r_flistp, ebufp); /*********************************************************** * Clean up. ***********************************************************/ /* Free local memory */ PIN_FLIST_DESTROY(r_flistp, NULL); PIN_FLIST_DESTROY(flistp, NULL); /* Error? */ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "sample_step_search error", ebufp); } return; }
/******************************************************************* * 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; }
/********************************************************************** * 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; }
/******************************************************************* * Multi search. * * Performs a read-fields search to get the poid, merchant * and status of all non-billable accounts in the database. * We walk the results array and display each individually. * * The "one arg equal" search for /account is 201. * *******************************************************************/ void sample_read_flds_search( pcm_context_t *ctxp, u_int64 database, pin_errbuf_t *ebufp) { pin_cookie_t cookie = NULL; pin_flist_t *flistp = NULL; pin_flist_t *a_flistp = NULL; pin_flist_t *r_flistp = NULL; poid_t *objp = NULL; u_int64 id; u_int vp; int32 rec_id; /*********************************************************** * Check the error buffer. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Allocate the flist for searching. ***********************************************************/ flistp = PIN_FLIST_CREATE(ebufp); /*********************************************************** * Allocate the search poid and give it to the flist. ***********************************************************/ id = (u_int64)201; objp = PIN_POID_CREATE(database, "/search", id, ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, (void *)objp, ebufp); /*********************************************************** * Add a search arguments array. ***********************************************************/ a_flistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 1, ebufp); /*********************************************************** * Add non-billable (= undefined) as the argument. ***********************************************************/ vp = PIN_BILL_TYPE_UNDEFINED; PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_BILL_TYPE, (void *)&vp, ebufp); /*********************************************************** * Add a search results array. ***********************************************************/ a_flistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_RESULTS, 0, ebufp); /*********************************************************** * Add markers for the fields we want to read. ***********************************************************/ PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_MERCHANT, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_STATUS, (void *)NULL, ebufp); /*********************************************************** * Call the DM to do the search. ***********************************************************/ PCM_OP(ctxp, PCM_OP_SEARCH, 0, flistp, &r_flistp, ebufp); /*********************************************************** * Walk the results array. ***********************************************************/ a_flistp = PIN_FLIST_ELEM_GET_NEXT(r_flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); while (a_flistp != (pin_flist_t *)NULL) { /*************************************************** * Show this result. ***************************************************/ fprintf(stdout,"\nMulti Search Result(%d) Flist:\n", rec_id); PIN_FLIST_PRINT(a_flistp, stdout, ebufp); /*************************************************** * Get the next result. ***************************************************/ a_flistp = PIN_FLIST_ELEM_GET_NEXT(r_flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); } /*********************************************************** * Clean up. ***********************************************************/ /* Free local memory */ PIN_FLIST_DESTROY(r_flistp, NULL); PIN_FLIST_DESTROY(flistp, NULL); /* Error? */ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "sample_read_flds_search error", ebufp); } return; }
/******************************************************************* * 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; }
/******************************************************************* * 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); }
/******************************************************************* * 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; }
/************************************************************************** * 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; }
//**************************************************** // 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; }
/******************************************************************* * 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; }
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); } }