/* * =========================== Build_segment() ============================ */ int Build_segment(int fd) { int nread = 0; /* number of records in file */ int rcnt; /* record size */ int stt; /* return status */ int type; /* prime record type */ Pacct_offset = 0; if (db_flag > 0) { Ndebug("Build_segment(1): called.\n"); } /* * Process the pacct files, we must be able to process both a * sorted pacct file (pacct0) and regular pacct files (pacct1-n). */ while(TRUE) { if (readacctent(fd, &acctent, FORWARD) <= 0) { if (!nread) { fprintf(stderr, _("%s: CAUTION: Empty pacct file found.\n"), Prg_name); } break; } nread++; type = acctent.prime->ah_type; rcnt = acctent.prime->ah_size; Last_upTime = upind; stt = RC_GOOD; if (db_flag > 3) { Ndebug("Build_segment(4): Record(%d), offset(%d, %#o):", nread, Pacct_offset, Pacct_offset); Dump_acct_hdr(acctent.prime); } switch(type) { case (ACCT_KERNEL_CSA): rcnt = acctent.csa->ac_hdr1.ah_size + acctent.csa->ac_hdr2.ah_size; stt = process_eop(fd, File_Index, mark); break; case (ACCT_KERNEL_CFG): stt = process_special(fd, File_Index, mark); break; case (ACCT_KERNEL_EOJ): rcnt = acctent.eoj->ac_hdr1.ah_size + acctent.eoj->ac_hdr2.ah_size; stt = process_special(fd, File_Index, mark); break; case (ACCT_KERNEL_SOJ): stt = process_special(fd, File_Index, mark); break; case (ACCT_DAEMON_WKMG): stt = process_wm(fd, File_Index); break; default: acct_err(ACCT_WARN, _("Bad daemon identifier (%d) in header field."), type); } /* end of switch(type) */ /* Check the processing routine's reply. */ if ((stt == RC_BAD) || (stt == RC_CFG) ) { Pacct_offset += rcnt; continue; } else if (stt == RC_NOJOB) { if (i_opt) { acct_err(ACCT_INFO, _("No Job ID was found for a record from file '%s%d' near offset %lld."), pacct, File_Index, Pacct_offset); acct_err(ACCT_INFO, _("The record was ignored.") ); if (db_flag > 2) { Ndebug("Uptime reset to %d\n", Last_upTime); } upind = Last_upTime; continue; } else { acct_err(ACCT_INFO, _("No Job ID was found for a record from file '%s%d' near offset %lld."), pacct, File_Index, Pacct_offset); } } /* Update the file position. */ Pacct_offset += rcnt; } /* while(TRUE) */ return(rcnt); }
void kokompe::special(int key) { process_special(key); }