static void annotation_add_state(struct annotations_context *ctx, uint32_t state_type, uint32_t start_offset, size_t size) { assert(ctx->index < MAX_ANNOTATIONS); add_annotation(&ctx->annotations[ctx->index++], AUB_TRACE_TYPE_NOTYPE, 0, start_offset); add_annotation(&ctx->annotations[ctx->index++], AUB_TRACE_TYPE(state_type), AUB_TRACE_SUBTYPE(state_type), start_offset + size); }
static void annotation_add_batch(struct annotations_context *ctx, size_t size) { add_annotation(&ctx->annotations[0], AUB_TRACE_TYPE_BATCH, 0, size); }
void create_adj_pcn(Arb_connection *dbp,ADJ_REC *adj, ADJ_TRANS_DESCR *adj_descr) { EQUIPMENT *equip; int i; ITEM_BALANCE *item_bal; int bill_cycle_index = Customer.fr_inx; int cdr_elemnt_id=0; int trans_target_type; int trans_target_id; /* ** First, get a pointer to the equipment structure corresponding to ** ADJ's equipment number, if ADJ is equipment level. If no equipment ** structure exists, then the equipment must no longer be actively ** billable to the current account. In this case, we still have ** to bill the ADJ, so dummy-up a fake equipment structure. */ if (adj->subscr_no + adj->subscr_no_resets == 0) equip = NULL; else { equip = find_equip(adj->subscr_no, adj->subscr_no_resets, 0, Total_emf_count -1); if (equip == NULL) equip = fake_equip(adj->subscr_no, adj->subscr_no_resets); } /* Extract the type and type ID of the entiry this adjustment adjusted. For most adjustments, this can be extracted from ADJ_TRANS_DESCR. For backout adjustments, it needs to be derived from ADJ.orig_type and ADJ.orig_subtype. */ if ((adj_descr->trans_category == ADJ_BACKOUT_NEW_CHARGE) || (adj_descr->trans_category == ADJ_BACKOUT_ADJ)) { trans_target_type = orig_type_to_target_type(adj->orig_type, adj->orig_subtype); trans_target_id = adj->orig_subtype; } else { /* If the ADJ record has the orig_type field filled in, and the adjustment is not a reversal, get the target type for it and ensure it is consistent with the adjustment type. Mismatches can happen, especially when adjusting previous adjustments. Reversals use an adjustment type consistent with the original charge that was adjusted, while orig_type is set to 4 (previous adjustment) WARNING: This is a significantly tighter verification test than BIP used to use. If it goes off, the process that inserted the ajustment is in error, not this check! */ if ((adj->orig_type != 0) && (adj->orig_type != ADJ_TYPE)) { trans_target_type = orig_type_to_target_type(adj->orig_type, adj->orig_subtype); if ((trans_target_type != adj_descr->trans_target_type) && /* RCs can also be adjusted with product line adjustments */ (!((trans_target_type == ADJ_RC_TARGET) && (adj_descr->trans_target_type == ADJ_RC_LINE_TARGET)))) { tracef((char *)"create_adj_pcn", (char *)"Target type for adj %d/%d:%d mismatch to adj type %d target %d", adj->tracking_id, adj->tracking_id_serv, trans_target_type, adj->trans_code, adj_descr->trans_target_type); emit(BIPMOD, BIP_FAIL_INFO, "Adj tracking_id", adj->tracking_id); emit(BIPMOD, BIP_FAIL_INFO, "Adj tracking_id_serv", adj->tracking_id_serv); emit(BIPMOD, BIP_FAIL_INFO, "target type implied by ADJ.orig_type", trans_target_type); gen_bill_error(BIPMOD, ERROR_CONTINUE, BIP_ADJ_TYP_TG_MSTCH, BIP_BAD_DATA_ERR, adj->trans_code, adj_descr->trans_target_type, adj->orig_type); } } /* ADJ.orig_type is not zero */ trans_target_type = adj_descr->trans_target_type; trans_target_id = adj_descr->trans_target_id; } /* Not a backout adjustment */ /* ** Create a PCN to represent this ADJ. ** Depending on the value of the trans_target_type, ** the ADJ can be adjusting a recurring charge, a non-recurring ** charge, usage, or be a miscellaneous adjustment. Get the tax location ** code appropriate to the type of charge being adjusted. */ if ((trans_target_type == ADJ_RC_TARGET) || (trans_target_type == ADJ_RC_LINE_TARGET)) { /* ** ADJ is a recurring charge adjustment. Get the tax location ** code from the PRODUCT_ELEMENTS table. */ PRODUCT_ELEMENTS *element; element = fetch_product_element(trans_target_id); if (element == NULL) { gen_bill_error(BIPMOD, ERROR_CONTINUE, BIP_NO_PROD_ELEMENT, BIP_BAD_DATA_ERR, trans_target_id); return; } if (add_pcn(ADJUSTMENT_ITEM, adj_descr->billing_category, adj_descr->description_code, adj->orig_provider_id, element->tax_location_rc, element->tax_class, adj->tracking_id, adj->tracking_id_serv, adj->open_item_id, &adj->payment_profile_id) == Failure) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_ADJ_ALLOC_ERR, BIP_ALLOC_ERR); /* does not return */ Pcn_list_end->auxtype = element->element_id; Pcn_list_end->element_id = element->element_id; Pcn_list_end->product_line_id = element->product_line_id; Pcn_list_end->prep_sequence = RC_TYPE; Pcn_list_end->is_late_fee_exempt = element->is_late_fee_exempt; } else if (trans_target_type == ADJ_USAGE_TARGET) { /* ** ADJ is a usage adjustment. Get the tax location code ** from the USAGE_TYPES table. */ USG_TYPES *usage_descr; usage_descr = find_usage_type(trans_target_id); if (usage_descr == NULL) { gen_bill_error(BIPMOD, ERROR_CONTINUE, BIP_NO_USAGE_TYPE, BIP_BAD_DATA_ERR, trans_target_id); return; } if (add_pcn(ADJUSTMENT_ITEM, adj_descr->billing_category, adj_descr->description_code, adj->orig_provider_id, usage_descr->tax_location_usg, usage_descr->tax_class, adj->tracking_id, adj->tracking_id_serv, adj->open_item_id, &adj->payment_profile_id) == Failure) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_ADJ_ALLOC_ERR, BIP_ALLOC_ERR); /* does not return */ arb_setup_results(&proc_bip_get_element_id, ARB_TYPE_INT32,&cdr_elemnt_id, NO_MORE_OUTPUTS); arb_setup_proc_exec(dbp,&proc_bip_get_element_id, SQL_DEFER_EXECUTE, "account_no", Account_no, ARG_NOT_NULL, "tracking_id",adj->tracking_id,ARG_NOT_NULL, "tracking_id_serv",adj->tracking_id_serv,ARG_NOT_NULL, NO_MORE_ARGS); while (arb_next_row(dbp) == ARB_MORE_DATA) ; if (arb_query_status(dbp) != SUCCESS) { arb_reset_query(dbp); return ; } Pcn_list_end->auxtype = usage_descr->type_id_usg; Pcn_list_end->jurisdiction = adj->jurisdiction; Pcn_list_end->element_id = cdr_elemnt_id; Pcn_list_end->product_line_id = Pcn_list_end->element_id ? lookup_product_line_id(Pcn_list_end->element_id) : usage_descr->product_line_id; Pcn_list_end->prep_sequence = USAGE_TYPE; Pcn_list_end->is_late_fee_exempt = usage_descr->is_late_fee_exempt; } else if (trans_target_type == ADJ_NRC_TARGET) { /* ** ADJ is a non-recurring charge adjustment. Get the tax ** location code from the NRC_TRANS_DESCR table. */ NRC_TRANS_DESCR *nrc_descr; nrc_descr = find_nrc_descr(trans_target_id); if (nrc_descr == NULL) { gen_bill_error(BIPMOD, ERROR_CONTINUE, BIP_ADJ_NO_NRC_MATCH, BIP_BAD_DATA_ERR, adj->tracking_id, trans_target_id); return; } if (add_pcn(ADJUSTMENT_ITEM, adj_descr->billing_category, adj_descr->description_code, adj->orig_provider_id, nrc_descr->tax_location_nrc, nrc_descr->tax_class, adj->tracking_id, adj->tracking_id_serv, adj->open_item_id, &adj->payment_profile_id) == Failure) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_ADJ_ALLOC_ERR, BIP_ALLOC_ERR); /* does not return */ Pcn_list_end->auxtype = nrc_descr->type_id_nrc; Pcn_list_end->element_id = nrc_descr->element_id; Pcn_list_end->product_line_id = Pcn_list_end->element_id ? lookup_product_line_id(Pcn_list_end->element_id) : nrc_descr->product_line_id; Pcn_list_end->prep_sequence = NRC_TYPE; Pcn_list_end->is_late_fee_exempt = nrc_descr->is_late_fee_exempt; } else if ((trans_target_type == ADJ_MISC_TARGET) /* || (trans_target_type == ADJ_TAX_TARGET) */ ) { /* ** ADJ is a miscellaneous adjustment or an adjustment of taxes. Use ** the adj->tax_on_invoice as location code to support real credit ** note. */ if (add_pcn(ADJUSTMENT_ITEM, adj_descr->billing_category, adj_descr->description_code, adj->orig_provider_id, adj->tax_on_invoice, adj->tax_class, adj->tracking_id, adj->tracking_id_serv, adj->open_item_id, &adj->payment_profile_id) == Failure) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_ADJ_ALLOC_ERR, BIP_ALLOC_ERR); /* does not return */ } else { gen_bill_error(BIPMOD, ERROR_CONTINUE, BIP_BAD_ADJ_TARGET, BIP_BAD_DATA_ERR, trans_target_type, adj_descr->trans_code, adj->tracking_id_serv, adj->tracking_id); if (adj->tax) free(adj->tax); adj->tax = NULL; return; } /* ** Fill in other adj-related PCN fields. Some of these are somewhat ** non-intuitive: ** -An ADJ's effective date is the PCN's "from" date ** -An ADJ's end date (if any) is the PCN's "to" date ** -The type of charge the ADJ is against is stored in the PCN's ** prep_sequence field. ** -The ID of the charge the ADJ is against is stored int the ** PCN's prorate_code field. */ Pcn_list_end->adj_trans_category=adj_descr->trans_category; Pcn_list_end->equip = equip; Pcn_list_end->adj_category = trans_target_type; Pcn_list_end->subtype = adj->trans_code; Pcn_list_end->primary_units_type = adj->primary_units_type; Pcn_list_end->primary_units = adj->primary_units; Arbdate_copy(&Pcn_list_end->from_date, &adj->effective_date); Arbdate_copy(&Pcn_list_end->to_date, &adj->end_date); Pcn_list_end->discount_portion = adj->discount_amt; Pcn_list_end->amount_net = adj->total_amt; strcpy(Pcn_list_end->geocode,adj->geocode); strcpy(Pcn_list_end->aux_tax_info,adj->aux_tax_info); Pcn_list_end->is_refinance = adj->is_refinance; /* If proration is active, find the run cycle of the adjustment based on when it occured. Note that for pre-bill usage adjustments, this is later overwritten by the run cycle of the charge the adjustment is against */ if (Prorate_contracts) find_charge_run_period(&adj->effective_date, &bill_cycle_index, &Pcn_list_end->cycle_from_date, &Pcn_list_end->cycle_to_date); if (adj_descr->trans_sign == -1) { arb_num_negate(&Pcn_list_end->amount_net); for (i = 0; i < adj->tax_pkg_count; i++) { arb_num_negate(&adj->tax[i].total_tax); arb_num_negate(&adj->tax[i].federal_tax); arb_num_negate(&adj->tax[i].state_tax); arb_num_negate(&adj->tax[i].county_tax); arb_num_negate(&adj->tax[i].city_tax); arb_num_negate(&adj->tax[i].other_tax); } } Pcn_list_end->tax_pkg_count = adj->tax_pkg_count; /* * If count is nonzero, pcn now "owns" array of TAXES. If count is * zero but adj->tax exists, it is an "unidentified" pretax, which can * only have one set of taxes. Negate them if necessary and copy to * pcn->total_taxes (which is NOT a pointer). */ if (adj->tax_pkg_count) Pcn_list_end->pkg_taxes = adj->tax; else if (adj->tax) { if (adj_descr->trans_sign == -1) { arb_num_negate(&adj->tax[0].federal_tax); arb_num_negate(&adj->tax[0].state_tax); arb_num_negate(&adj->tax[0].county_tax); arb_num_negate(&adj->tax[0].city_tax); arb_num_negate(&adj->tax[0].other_tax); } bip_total_taxes(&adj->tax[0].total_tax,&adj->tax[0]); Pcn_list_end->total_taxes = adj->tax[0]; free(adj->tax); adj->tax = NULL; } Pcn_list_end->annotation = add_annotation(); if (Pcn_list_end->annotation == NULL) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_MEM_ALLOC_ERR, BIP_ALLOC_ERR,1,sizeof(ANNOTATION),"Annotation"); strcpy(Pcn_list_end->annotation,adj->annotation); Pcn_list_end->prorate_code = Pcn_list_end->auxtype; Pcn_list_end->rev_rcv_cost_ctr = adj->rev_rcv_cost_ctr; Pcn_list_end->b_rev_rcv_cost_ctr = adj->b_rev_rcv_cost_ctr; Pcn_list_end->orig_bill_ref_no = adj->orig_bill_ref_no; Pcn_list_end->orig_bill_ref_resets = adj->orig_bill_ref_resets; Pcn_list_end->tax_on_invoice = adj->tax_on_invoice; /*real credit notes*/ Pcn_list_end->bill_invoice_row = adj->bill_invoice_row; /* ** Update global adjustments accumulator. ** The appropriate accumulator depends on the billing category ** and open_item_id. */ item_bal = add_item_balance(Pcn_list_end->open_item_id); switch (adj_descr->billing_category) { case APPLY_CURRENT_CHGS : /* CAMqa89369 */ if(arb_num_is_positive(&Pcn_list_end->amount_net) || !Allow_negative_new_charges) bip_num_arith(&item_bal->positive_adj_current_app, &item_bal->positive_adj_current_app, ARB_NUM_ADD, &Pcn_list_end->amount_net, BIPMOD); else bip_num_arith(&item_bal->negative_adj_current_app, &item_bal->negative_adj_current_app, ARB_NUM_ADD, &Pcn_list_end->amount_net, BIPMOD); break; case APPLY_PAST_CHGS : bip_num_arith(&item_bal->adjs_past_noapp, &item_bal->adjs_past_noapp, ARB_NUM_ADD, &Pcn_list_end->amount_net, BIPMOD); /* DENqa11329 */ if ((adj_descr->trans_category == ADJ_BACKOUT_NEW_CHARGE) || (adj_descr->trans_category == ADJ_BACKOUT_ADJ)) bip_num_arith(&item_bal->adjs_past_backout, &item_bal->adjs_past_backout, ARB_NUM_ADD, &Pcn_list_end->amount_net, BIPMOD); break; case APPLY_CREDIT_NOTE : if (arb_num_is_positive(&Pcn_list_end->amount_net)) gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_BAD_CREDIT_NOTE, BIP_BAD_DATA_ERR, adj->tracking_id, adj->tracking_id_serv); bip_num_arith(&item_bal->adjs_creditnote_app, &item_bal->adjs_creditnote_app, ARB_NUM_ADD, &Pcn_list_end->amount_net, BIPMOD); break; case APPLY_NO_CHARGES : bip_num_arith(&item_bal->adjs_creditnoterev_app, &item_bal->adjs_creditnoterev_app, ARB_NUM_ADD, &Pcn_list_end->amount_net, BIPMOD); break; default : gen_bill_error(BIPMOD, ERROR_ABORT_ACCOUNT, BIP_BAD_ADJ_BILL_CAT, BIP_BAD_DATA_ERR, adj_descr->billing_category, adj->tracking_id, adj->tracking_id_serv); } }
int main(int argc, char **argv) { int ret; char *infile_name; char *outfile_name; struct darshan_job job; struct darshan_file cp_file; char tmp_string[4096]; darshan_fd infile; darshan_fd outfile; int i; int mount_count; int64_t* devs; char** mnt_pts; char** fs_types; int last_rank = 0; int obfuscate = 0; int key = 0; char *annotation = NULL; uint64_t hash; int reset_md = 0; parse_args(argc, argv, &infile_name, &outfile_name, &obfuscate, &reset_md, &key, &annotation, &hash); infile = darshan_log_open(infile_name, "r"); if(!infile) { fprintf(stderr, "darshan_log_open() failed to open %s\n.", infile_name); return(-1); } /* TODO: safety check that outfile_name doesn't exist; we don't want to * overwrite something by accident. */ outfile = darshan_log_open(outfile_name, "w"); if(!outfile) { fprintf(stderr, "darshan_log_open() failed to open %s\n.", outfile_name); return(-1); } /* TODO: for now this tool is just reading the input file and throwing * away the data. Need to write the log_put*() functions and use this * program as a test harness */ /* read job info */ ret = darshan_log_getjob(infile, &job); if(ret < 0) { fprintf(stderr, "Error: unable to read job information from log file.\n"); darshan_log_close(infile); return(-1); } if (reset_md) reset_md_job(&job); if (obfuscate) obfuscate_job(key, &job); if (annotation) add_annotation(annotation, &job); ret = darshan_log_putjob(outfile, &job); if (ret < 0) { fprintf(stderr, "Error: unable to write job information to log file.\n"); darshan_log_close(outfile); return(-1); } ret = darshan_log_getexe(infile, tmp_string); if(ret < 0) { fprintf(stderr, "Error: unable to read trailing job information.\n"); darshan_log_close(infile); return(-1); } if (obfuscate) obfuscate_exe(key, tmp_string); ret = darshan_log_putexe(outfile, tmp_string); if(ret < 0) { fprintf(stderr, "Error: unable to write trailing job information.\n"); darshan_log_close(outfile); return(-1); } ret = darshan_log_getmounts(infile, &devs, &mnt_pts, &fs_types, &mount_count); if(ret < 0) { fprintf(stderr, "Error: unable to read trailing job information.\n"); darshan_log_close(infile); return(-1); } ret = darshan_log_putmounts(outfile, devs, mnt_pts, fs_types, mount_count); if(ret < 0) { fprintf(stderr, "Error: unable to write mount information.\n"); darshan_log_close(outfile); return(-1); } ret = darshan_log_getfile(infile, &job, &cp_file); if(ret < 0) { fprintf(stderr, "Error: failed to process log file.\n"); fflush(stderr); } if(ret == 0) { goto done; } do { if(cp_file.rank != -1 && cp_file.rank < last_rank) { fprintf(stderr, "Error: log file contains out of order rank data.\n"); fflush(stderr); return(-1); } if(cp_file.rank != -1) last_rank = cp_file.rank; if(!hash || hash == cp_file.hash) { if (obfuscate) obfuscate_file(key, &cp_file); ret = darshan_log_putfile(outfile, &job, &cp_file); if (ret < 0) { fprintf(stderr, "Error: failed to write file record.\n"); break; } } } while((ret = darshan_log_getfile(infile, &job, &cp_file)) == 1); if(ret < 0) { fprintf(stderr, "Error: failed to process log file.\n"); fflush(stderr); } done: for(i=0; i<mount_count; i++) { free(mnt_pts[i]); free(fs_types[i]); } if(mount_count > 0) { free(devs); free(mnt_pts); free(fs_types); } darshan_log_close(infile); darshan_log_close(outfile); return(ret); }
AnnotationDialog::AnnotationDialog(QWidget * parent, QString & s, bool visit) : QDialog(parent, "annotation editor", TRUE), value(s) { Q3VBoxLayout * vbox = new Q3VBoxLayout(this); vbox->setMargin(5); // multiline edit e = new MultiLineEdit(this); e->setText(s); vbox->addWidget(e); if (! visit) { e->setFocus(); // to choose and add an annotation QLabel * label = new QLabel(TR("\nTo add an annotation at the cursor position\n" "you may select it in the list and press 'add'\n"), this); label->setAlignment(Qt::AlignCenter); vbox->addWidget(label); Q3HBoxLayout * hbox = new Q3HBoxLayout(vbox); QPushButton * add_button; hbox->setMargin(5); add_button = new QPushButton(TR("Add "), this); hbox->addWidget(add_button); connect(add_button, SIGNAL(clicked()), this, SLOT(add_annotation())); cb = new Q3ComboBox(FALSE, this); QSizePolicy sp = cb->sizePolicy(); sp.setHorData(QSizePolicy::Expanding); cb->setSizePolicy(sp); cb->setAutoCompletion(completion()); for (int i = 0; i != sizeof(DefaultAnnotations) / sizeof(*DefaultAnnotations); i += 1) cb->insertItem(DefaultAnnotations[i]); QStringList list; BrowserClass::instances(annotations, "@interface"); if (! annotations.isEmpty()) { annotations.full_names(list); cb->insertStringList(list); } hbox->addWidget(cb); // buttons ok, cancel vbox->addWidget(new QLabel("", this)); hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); QPushButton * accept = new QPushButton(TR("&OK"), this); QPushButton * cancel = new QPushButton(TR("&Cancel"), this); QSize bs(cancel->sizeHint()); accept->setDefault(TRUE); accept->setFixedSize(bs); cancel->setFixedSize(bs); hbox->addWidget(accept); hbox->addWidget(cancel); connect(accept, SIGNAL(clicked()), this, SLOT(accept())); connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); } else { e->setReadOnly(TRUE); // buttons cancel vbox->addWidget(new QLabel("", this)); Q3HBoxLayout * hbox = new Q3HBoxLayout(vbox); hbox->setMargin(5); QPushButton * close = new QPushButton(TR("&Close"), this); hbox->addWidget(close); connect(close, SIGNAL(clicked()), this, SLOT(reject())); } // not done in polish else the initial size is too small UmlDesktop::setsize_center(this, previous_size, 0.3, 0.3); }