#include <grp.h>
#include <dirent.h>
#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/acct.h>
#include <errno.h>
+#include <sys/stat.h>
+
+typedef unsigned long long u64;
+#include "acct.h"
+/*#include <sys/acct.h>*/
+typedef struct acct_v3 struct_acct;
#include "myopt.h"
checkstdout();
}
-static void printrecord(const struct acct *as, const char *filename) {
+static void printrecord(const struct_acct *as, const char *filename) {
static int walkeddev;
int i, dc, r;
struct deventry *deve, devlookfor;
struct passwd *pw;
struct group *gr;
+ time_t btime;
if (raw) {
printf("%10lu ",(unsigned long)as->ac_btime);
} else {
- time_t btime=as->ac_btime;
+ btime= as->ac_btime;
tm= localtime(&btime);
strftime(buf,sizeof(buf),"%Y-%m-%d %H:%M:%S",tm); buf[sizeof(buf)-1]= 0;
printf("%19s ",buf);
else printf("%-8ld ",(long)as->ac_gid);
if (raw) {
- if (as->ac_tty == (dev_t)-1) {
+ if (!(as->ac_tty + 1) /* check for -1 without knowing type */) {
printf("- ");
} else {
printf("%08lx ",(unsigned long)as->ac_tty);
}
} else {
- if (as->ac_tty == (dev_t)-1) {
+ if (!(as->ac_tty + 1)) {
printf("- ");
} else {
if (!walkeddev) {
}
r= as->ac_flag;
- for (i=1, fp= "FSDX"; *fp; fp++, i<<=1) {
+ for (i=1, fp= "FS4DX"; *fp; fp++, i<<=1) {
if (r&i) {
putchar(*fp);
r &= ~i;
- } else {
+ } else if (!isdigit(*fp)) {
putchar(' ');
}
}
}
static void processfile(FILE *file, const char *filename) {
+ struct_acct as;
long pos;
- struct acct as;
int r;
if (forwards) {
printrecord(&as,filename);
}
} else {
+ long seekdist= -(long)sizeof(as);
r= fseek(file,0,SEEK_END); if (r) { perror(filename); exit(8); }
pos= ftell(file); if (pos==-1) { perror(filename); exit(8); }
if (pos % sizeof(as)) {
r= fseek(file,pos,SEEK_SET); if (r==-1) { perror(filename); exit(8); }
r= fread(&as,1,sizeof(as),file); if (r!=sizeof(as)) { perror(filename); exit(8); }
printrecord(&as,filename);
+ seekdist= -2*(long)sizeof(as);
}
}
if (ferror(file) || fclose(file)) { perror(filename); exit(8); }
}
int main(int argc, const char *const *argv) {
+union { struct_acct ac; char c[1]; } xu;
myopt(&argv,cmdinfos);
if (!nobanner) printbanner();
+fprintf(stdout,"s=%d %d\n",(int)sizeof(struct_acct),
+ (int)((char*)&xu.ac.ac_comm - xu.c));
if (usestdin) {
processfile(stdin,"<standard input>");
} else if (!*argv) {