#include #include /*spiros : who's the novice with the bad behaviour? *Answer me REAL FAST! I'm gonna realy kick some ass! */ main() { FILE *fp; char login[50],tty[50],date[50],state[10],fline[100]; int on,i; struct term { char date[30]; char tty[30]; char login[30]; } terms[30]; if ((fp=fopen("novice.log","r"))==0) { perror("novice.log"); exit(1); } while (fgets(fline,sizeof(fline),fp)){ sscanf(fline,"%[^#]#%[//A-z0-9]#%[^#]#%[A-z]",login,tty,date,state); if (strcmp(state,"off")) on=1; else on=0; if (!strcmp(tty,"/dev/tty1p1") && on) { strcpy(terms[0].date,date); strcpy(terms[0].login,login); strcpy(terms[0].tty,"tty1p1"); } if (!strcmp(tty,"/dev/tty1p1") && !on) { strcpy(terms[0].date,""); strcpy(terms[0].login,""); } if (!strcmp(tty,"/dev/tty1p3") && on) { strcpy(terms[1].date,date); strcpy(terms[1].login,login); strcpy(terms[1].tty,"tty1p3"); } if (!strcmp(tty,"/dev/tty1p3") && !on) { strcpy(terms[1].date,""); strcpy(terms[1].login,""); } if (!strcmp(tty,"/dev/tty1p0") && on) { strcpy(terms[2].date,date); strcpy(terms[2].login,login); strcpy(terms[2].tty,"tty1p0"); } if (!strcmp(tty,"/dev/tty1p0") && !on) { strcpy(terms[2].date,""); strcpy(terms[2].login,""); } if (!strcmp(tty,"/dev/tty1p2") && on) { strcpy(terms[3].date,date); strcpy(terms[3].login,login); strcpy(terms[3].tty,"tty1p2"); } if (!strcmp(tty,"/dev/tty1p2") && !on) { strcpy(terms[3].date,""); strcpy(terms[3].login,""); } if (!strcmp(tty,"/dev/tty1pf") && on) { strcpy(terms[4].date,date); strcpy(terms[4].login,login); strcpy(terms[4].tty,"tty1pf"); } if (!strcmp(tty,"/dev/tty1pf") && !on) { strcpy(terms[4].date,""); strcpy(terms[4].login,""); } if (!strcmp(tty,"/dev/tty1p4") && on) { strcpy(terms[5].date,date); strcpy(terms[5].login,login); strcpy(terms[5].tty,"tty1p4"); } if (!strcmp(tty,"/dev/tty1p4") && !on) { strcpy(terms[5].date,""); strcpy(terms[5].login,""); } if (!strcmp(tty,"/dev/tty1pd") && on) { strcpy(terms[6].date,date); strcpy(terms[6].login,login); strcpy(terms[6].tty,"tty1pd"); } if (!strcmp(tty,"/dev/tty1pd") && !on) { strcpy(terms[6].date,""); strcpy(terms[6].login,""); } if (!strcmp(tty,"/dev/tty1pa") && on) { strcpy(terms[7].date,date); strcpy(terms[7].login,login); strcpy(terms[7].tty,"tty1pa"); } if (!strcmp(tty,"/dev/tty1pa") && !on) { strcpy(terms[7].date,""); strcpy(terms[7].login,""); } if (!strcmp(tty,"/dev/tty1p9") && on) { strcpy(terms[8].date,date); strcpy(terms[8].login,login); strcpy(terms[8].tty,"tty1p9"); } if (!strcmp(tty,"/dev/tty1p9") && !on) { strcpy(terms[8].date,""); strcpy(terms[8].login,""); } if (!strcmp(tty,"/dev/tty1p8") && on) { strcpy(terms[9].date,date); strcpy(terms[9].login,login); strcpy(terms[9].tty,"tty1p8"); } if (!strcmp(tty,"/dev/tty1p8") && !on) { strcpy(terms[9].date,""); strcpy(terms[9].login,""); } if (!strcmp(tty,"/dev/tty1pb") && on) { strcpy(terms[10].date,date); strcpy(terms[10].login,login); strcpy(terms[10].tty,"tty1pb"); } if (!strcmp(tty,"/dev/tty1pb") && !on) { strcpy(terms[10].date,""); strcpy(terms[10].login,""); } if (!strcmp(tty,"/dev/tty0p9") && on) { strcpy(terms[11].date,date); strcpy(terms[11].login,login); strcpy(terms[11].tty,"tty0p9"); } if (!strcmp(tty,"/dev/tty0p9") && !on) { strcpy(terms[11].date,""); strcpy(terms[11].login,""); } if (!strcmp(tty,"/dev/tty0pa") && on) { strcpy(terms[12].date,date); strcpy(terms[12].login,login); strcpy(terms[12].tty,"tty0pa"); } if (!strcmp(tty,"/dev/tty0pa") && !on) { strcpy(terms[12].date,""); strcpy(terms[12].login,""); } if (!strcmp(tty,"/dev/tty0p8") && on) { strcpy(terms[13].date,date); strcpy(terms[13].login,login); strcpy(terms[13].tty,"tty0p8"); } if (!strcmp(tty,"/dev/tty0p8") && !on) { strcpy(terms[13].date,""); strcpy(terms[13].login,""); } if (!strcmp(tty,"/dev/tty0p5") && on) { strcpy(terms[14].date,date); strcpy(terms[14].login,login); strcpy(terms[14].tty,"tty0p5"); } if (!strcmp(tty,"/dev/tty0p5") && !on) { strcpy(terms[14].date,""); strcpy(terms[14].login,""); } if (!strcmp(tty,"/dev/tty0pc") && on) { strcpy(terms[15].date,date); strcpy(terms[15].login,login); strcpy(terms[15].tty,"tty0pc"); } if (!strcmp(tty,"/dev/tty0pc") && !on) { strcpy(terms[15].date,""); strcpy(terms[15].login,""); } if (!strcmp(tty,"/dev/tty0pb") && on) { strcpy(terms[16].date,date); strcpy(terms[16].login,login); strcpy(terms[16].tty,"tty0pb"); } if (!strcmp(tty,"/dev/tty0pb") && !on) { strcpy(terms[16].date,""); strcpy(terms[16].login,""); } if (!strcmp(tty,"/dev/tty0p4") && on) { strcpy(terms[17].date,date); strcpy(terms[17].login,login); strcpy(terms[17].tty,"tty0p4"); } if (!strcmp(tty,"/dev/tty0p4") && !on) { strcpy(terms[17].date,""); strcpy(terms[17].login,""); } if (!strcmp(tty,"/dev/tty0p3") && on) { strcpy(terms[18].date,date); strcpy(terms[18].login,login); strcpy(terms[18].tty,"tty0p3"); } if (!strcmp(tty,"/dev/tty0p3") && !on) { strcpy(terms[18].date,""); strcpy(terms[18].login,""); } if (!strcmp(tty,"/dev/tty0pd") && on) { strcpy(terms[19].date,date); strcpy(terms[19].login,login); strcpy(terms[19].tty,"tty0pd"); } if (!strcmp(tty,"/dev/tty0pd") && !on) { strcpy(terms[19].date,""); strcpy(terms[19].login,""); } if (!strcmp(tty,"/dev/tty0p1") && on) { strcpy(terms[20].date,date); strcpy(terms[20].login,login); strcpy(terms[20].tty,"tty0p1"); } if (!strcmp(tty,"/dev/tty0p1") && !on) { strcpy(terms[20].date,""); strcpy(terms[20].login,""); } if (!strcmp(tty,"/dev/tty0p6") && on) { strcpy(terms[21].date,date); strcpy(terms[21].login,login); strcpy(terms[21].tty,"tty0p6"); } if (!strcmp(tty,"/dev/tty0p6") && !on) { strcpy(terms[21].date,""); strcpy(terms[21].login,""); } if (!strcmp(tty,"/dev/tty1p6") && on) { strcpy(terms[22].date,date); strcpy(terms[22].login,login); strcpy(terms[22].tty,"tty1p6"); } if (!strcmp(tty,"/dev/tty1p6") && !on) { strcpy(terms[22].date,""); strcpy(terms[22].login,""); } if (!strcmp(tty,"/dev/tty1p5") && on) { strcpy(terms[23].date,date); strcpy(terms[23].login,login); strcpy(terms[23].tty,"tty1p5"); } if (!strcmp(tty,"/dev/tty1p5") && !on) { strcpy(terms[23].date,""); strcpy(terms[23].login,""); } if (!strcmp(tty,"/dev/tty1pe") && on) { strcpy(terms[24].date,date); strcpy(terms[24].login,login); strcpy(terms[24].tty,"tty1pe"); } if (!strcmp(tty,"/dev/tty1pe") && !on) { strcpy(terms[24].date,""); strcpy(terms[24].login,""); } if (!strcmp(tty,"/dev/tty1p7") && on) { strcpy(terms[25].date,date); strcpy(terms[25].login,login); strcpy(terms[25].tty,"tty1p7"); } if (!strcmp(tty,"/dev/tty1p7") && !on) { strcpy(terms[25].date,""); strcpy(terms[25].login,""); } if (!strcmp(tty,"/dev/tty1pc") && on) { strcpy(terms[26].date,date); strcpy(terms[26].login,login); strcpy(terms[26].tty,"tty1pc"); } if (!strcmp(tty,"/dev/tty1pc") && !on) { strcpy(terms[26].date,""); strcpy(terms[26].login,""); } if (!strcmp(tty,"/dev/tty0p2") && on) { strcpy(terms[27].date,date); strcpy(terms[27].login,login); strcpy(terms[27].tty,"tty0p2"); } if (!strcmp(tty,"/dev/tty0p2") && !on) { strcpy(terms[27].date,""); strcpy(terms[27].login,""); } } for (i=0;i<=27;i++) if (strlen(terms[i].login)>1) printf ("\nUser: %-25s tty: %s\t date: %s ",terms[i].login,terms[i].tty,terms[i].date); printf("\n"); printf("\n"); }