EXPORT void setpwent() { if (pwdf == (FILE *)NULL) { pwdf = fileopen("/etc/passwd", "r"); if (pwdf == (FILE *)NULL) return; } fileseek(pwdf, (off_t)0); }
/* *********************************************************************** */ edit_out() { int i,j; int rdl; int totins; /* get total inserts */ int totdel; /* get total deletes */ unsigned char fmtwk[9]; unsigned char timebuf[9]; unsigned char *pnmwk; /* make sure we read the beginning */ fileseek( Infile, (long)0 ) ; /* read into fci struct */ if ( (rdl = fileread(Infile,&Fm,FCINSIZE) ) <=0) { disperr("COULD NOT READ %s",Pathbuf); return(-1); } charfill(&Bi,sizeof (Bi),' '); strncpy_s(Bi.drtdir, sizeof(Bi.drtdir), Fm.fc_drtdir, FILENMSZ); strncpy_s(Bi.dname, sizeof(Bi.dname), Fm.fc_dname, FILENMSZ); strncpy_s(Bi.dbtch, sizeof(Bi.dbtch), Fm.fc_dbtch, FILENMSZ); strncpy_s(Bi.frtdir, sizeof(Bi.frtdir), Fm.fc_frtdir, FILENMSZ); strncpy_s(Bi.fname, sizeof(Bi.fname), Fm.fc_fname, FILENMSZ); for( i=0 ; i < MAXMODES ; i++ ) { Bi.stat[i] = Status[Fm.fc_stat[i]] ; Bi.dopen[i] = Fm.fc_dopen[i] ; } for( i=0 ; i < MAXIO ; i++ ) { fmtstr(fmtwk,"%02d",Fm.fc_ioiter[i]); strncpy_s(Bi.ioiter[i], sizeof(Bi.ioiter[i]), fmtwk, 2); if( Fm.fc_iouid[i] > 0 ) { fmtstr( fmtwk, "%03d", Fm.fc_iouid[i] ) ; strncpy_s(Bi.iouid[i], sizeof(Bi.iouid[i]), fmtwk, 3); if( ( pnmwk = getusrnam( Fm.fc_iouid[i] ) ) != (char *)ERRCODE ) { strncpy_s(Bi.iouname[i], sizeof(Bi.iouname[i]), pnmwk, NMSZ); } else { charfill(Bi.iouname[i],NMSZ,'*'); } } else { charfill(Bi.iouid[i],3,'*'); charfill(Bi.iouname[i],NMSZ,'*'); } Bi.iostatus[i] = Fm.fc_iostatus[i]; } for (i=0; i< MAXMODES;i++) { fmtstr(fmtwk,"%05d",Fm.fc_rcntt[i]); strncpy_s(Bi.rcntt[i], sizeof(Bi.rcntt[i]), fmtwk, 5); fmtstr(fmtwk,"%05d",Fm.fc_dcntt[i]); strncpy_s(Bi.dcntt[i], sizeof(Bi.dcntt[i]), fmtwk, 5); fmtstr(fmtwk,"%08d",Fm.fc_kscntt[i]); strncpy_s(Bi.kscntt[i], sizeof(Bi.kscntt[i]), fmtwk, 8); fmtstr(fmtwk,"%08d",Fm.fc_kscnttf[i]); strncpy_s(Bi.kscnttf[i], sizeof(Bi.kscnttf[i]), fmtwk, 8); fmtstr(fmtwk,"%05d",Fm.fc_ercntt[i]); strncpy_s(Bi.ercntt[i], sizeof(Bi.ercntt[i]), fmtwk, 5); fmtstr(fmtwk,"%08d",Fm.fc_ekscntt[i]); strncpy_s(Bi.ekscntt[i],sizeof(Bi.ekscntt[i]) , fmtwk, 8); /* error k.s.count of function key */ fmtstr(fmtwk,"%08d",Fm.fc_ekscnttf[i]); strncpy_s(Bi.ekscnttf[i], sizeof(Bi.ekscnttf[i]), fmtwk, 8); /* total flag count */ fmtstr(fmtwk,"%05d",Fm.fc_flgcntt[i]); strncpy_s(Bi.flgcntt[i], sizeof(Bi.flgcntt[i]), fmtwk, 5); if (Fm.fc_fstime[i] == 0) charfill(Bi.fstime[i],24,'*'); else timetostr(Fm.fc_fstime[i],Bi.fstime[i]); if (Fm.fc_strtime[i] == 0) charfill(Bi.strtime[i],24,'*'); else timetostr(Fm.fc_strtime[i],Bi.strtime[i]); if (Fm.fc_lstime[i] == 0) charfill(Bi.lstime[i],24,'*'); else timetostr(Fm.fc_lstime[i],Bi.lstime[i]); if (elapsed_time(i,timebuf) ) /* calculate total elapsed time */ strncpy_s(Bi.eltimet[i], sizeof(Bi.eltimet[i]), timebuf, 8); else charfill(Bi.eltimet[i],8,'*'); } /* # inserts, # deletes */ totins = Fm.fc_mins[0] + Fm.fc_mins[1]; /* total inserts */ totdel = Fm.fc_mdel[0] + Fm.fc_mdel[1]; /* total deletes */ fmtstr(Bi.mins,"%05d",totins); fmtstr(Bi.mdel,"%05d",totdel); totins = Fm.fc_mdins[0] + Fm.fc_mdins[1]; /* total doc inserts */ totdel = Fm.fc_mddel[0] + Fm.fc_mddel[1]; /* total doc deletes */ fmtstr(Bi.mdins,"%05d",totins); fmtstr(Bi.mddel,"%05d",totdel); for (i=0; i< MAXMODES;i++) { for (j=0 ;j < MAXUSER;j++) { if (Fm.fc_muid[j][i] > 0) { fmtstr(fmtwk,"%03d",Fm.fc_muid[j][i]); strncpy_s(Bi.muid[j][i], sizeof(Bi.muid[j][i]), fmtwk, 3); if ( (pnmwk=getusrnam(Fm.fc_muid[j][i]) ) != (char *)ERRCODE) { strncpy_s(Bi.muidname[j][i], sizeof(Bi.muidname[j][i]), pnmwk, NMSZ); } else { charfill(Bi.muidname[j][i],NMSZ,'*'); } } else { charfill(Bi.muid[j][i],3,'*'); charfill(Bi.muidname[j][i],NMSZ,'*'); } } } Bi.sysfile = Fm.fc_sysfile; for (i=0; i< MAXMODES;i++) { fmtstr(fmtwk,"%05d",Fm.fc_iter[i]); strncpy_s(Bi.iter[i], sizeof(Bi.iter[i]), fmtwk, 5); } for (i=0; i< MAXIO;i++) { fmtstr(fmtwk,"%05d",Fm.fc_iositer[i]); strncpy_s(Bi.iositer[i], sizeof(Bi.iositer[i]), fmtwk, 5); fmtstr(fmtwk,"%05d",Fm.fc_iorcnt[i]); strncpy_s(Bi.iorcnt[i], sizeof(Bi.iorcnt[i]), fmtwk, 5); fmtstr(fmtwk,"%05d",Fm.fc_iodcnt[i]); strncpy_s(Bi.iodcnt[i], sizeof(Bi.iodcnt[i]), fmtwk, 5); if ( Fm.fc_iostime[i] == 0) charfill(Bi.iostime[i],24,'*'); else timetostr(Fm.fc_iostime[i],Bi.iostime[i]); if (Fm.fc_ioetime[i] == 0) charfill(Bi.ioetime[i],24,'*'); else timetostr(Fm.fc_ioetime[i],Bi.ioetime[i]); fmtstr(fmtwk,"%05d",Fm.fc_iopen[i]); strncpy_s(Bi.iopen[i], sizeof(Bi.iopen[i]), fmtwk, 5); } Bi.endmark= ' '; filewrite(BATCH_infof,&Bi,sizeof (Bi)); filewrite(BATCH_infof,"\n",1); return( 0 ) ; }