|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T l
Length: 3995 (0xf9b) Types: TextFile Names: »list.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/list.c«
/****************************************************************************\ * * * list.c * * * * Code for the list- commands. listgeneric() just chooses and prints the * * appropriate completion list. The other routines handle special cases for * * which there are no completion lists kept. * * * \****************************************************************************/ #include <stdio.h> #include <sys/types.h> #include <lastlog.h> #include "sysdep.h" #include "macros.h" #include "mem.h" #include "lists.h" #include "account.h" #ifdef SENDMAIL #include "alias.h" #endif #include "groupmap.h" #include "job.h" #ifdef BSD4_3 time_t time(); #endif #ifdef SENDMAIL extern struct list Aliases; #endif extern struct list Users, Groups, Vigs, Ranges, Classes, Sigs; extern struct list AccountList, AllCommands; char *sprintf(); struct list *picklist(); static char *allv[2] = { ".*", 0 }; listgeneric(c, v) int c; addr *v; { int count; struct list *List; List = picklist((char *)v[0]); c--; v++; if (c == 0) { (void) showlist(List, (addr *)allv); count = List->l_count; } else count = showlist(List, v); if (count) (void) printf("%d listed\n", count); return; } listcryos(c, v) int c; addr *v; { static struct list cryos; struct account *ac; int indx, count; zerolist(&cryos); tmplistadd(&cryos); for (indx=0; indx < AccountList.l_count; indx++) { ac = (struct account *) AccountList.l_list[indx]; if (eq((char *)ac->ac_shell, FREEZE_SH)) strlistadd(&cryos, (char *)ac->ac_name); } c--; v++; if (c == 0) { (void) showlist(&cryos, (addr *)allv); count = cryos.l_count; } else count = showlist(&cryos, v); if (count) (void) printf("%d listed\n", count); return; } listdeadbeats(c, v) int c; addr *v; { static struct list deadbeats; struct account *ac; struct groupmap *gm; int indx, count; char errmsg[LONG_BUF]; zerolist(&deadbeats); tmplistadd(&deadbeats); for (indx=0; indx < AccountList.l_count; indx++) { ac = (struct account *) AccountList.l_list[indx]; if (ac->ac_classes.l_count) continue; if (ac->ac_sigs.l_count) continue; /* * Cryos are not deadbeats. */ if (eq(ac->ac_shell, FREEZE_SH)) continue; gm = getgmgid(ac->ac_gid); if (!gm) { (void) sprintf(errmsg, "no group for gid %d!", ac->ac_gid); err(errmsg); return; } if (vigexists(gm->gm_name)) continue; strlistadd(&deadbeats, (char *)ac->ac_name); } c--; v++; if (c == 0) { (void) showlist(&deadbeats, (addr *)allv); count = deadbeats.l_count; } else count = showlist(&deadbeats, v); if (count) (void) printf("%d listed\n", count); return; } listinactives(c, v) int c; addr *v; { static struct list inactives; struct account *ac; struct groupmap *gm; int indx, count; time_t now; long toolong; char errmsg[LONG_BUF]; if ( c < 2 ) { err1("usage: %s <days> [expr ...]", (char *)v[0]); return; } if (!validint((char *)v[1])) { err2("%s: %s doesn't make sense as a number", (char *)v[0], (char *)v[1]); return; } toolong = atoi((char *)v[1]) * 86400; zerolist(&inactives); tmplistadd(&inactives); now = time((time_t *)0); for (indx=0; indx < AccountList.l_count; indx++) { ac = (struct account *) AccountList.l_list[indx]; if ((long)(now - ac->ac_ll.ll_time) < toolong) continue; /* * Cryos are not inactive. */ if (eq(ac->ac_shell, FREEZE_SH)) continue; /* * Vig members are not inactive. */ gm = getgmgid(ac->ac_gid); if (!gm) { (void) sprintf(errmsg, "no group for gid %d!", ac->ac_gid); err(errmsg); return; } if (vigexists(gm->gm_name)) continue; strlistadd(&inactives, (char *)ac->ac_name); } c -= 2; v += 2; if (c == 0) { (void) showlist(&inactives, (addr *)allv); count = inactives.l_count; } else count = showlist(&inactives, v); if (count) (void) printf("%d listed\n", count); return; }