5 typedef struct Who Who;
13 int cmp(void *arg1, void *arg2)
15 Who **a = arg1, **b = arg2;
17 return strcmp((*a)->name, (*b)->name);
21 main(int argc, char **argv)
26 Who *first, *last, *w, *nw, **l;
29 fprint(2, "usage: auth/uniq file\n");
34 b = Bopen(argv[1], OREAD);
40 while(p = Brdline(b, '\n')){
43 while(*p && *p != '|')
48 for(nw = first; nw; nw = nw->next){
49 if(strcmp(nw->name, name) == 0){
59 w = malloc(sizeof(Who));
61 fprint(2, "auth/uniq: out of memory\n");
64 memset(w, 0, sizeof(Who));
65 w->name = strdup(name);
76 l = malloc(n*sizeof(Who*));
77 for(i = 0, nw = first; nw; nw = nw->next, i++)
79 qsort(l, n, sizeof(Who*), cmp);
84 b = Bopen(argv[1], OWRITE);
86 fprint(2, "auth/uniq: can't open %s\n", argv[1]);
89 for(i = 0; i < n; i++)
90 Bprint(b, "%s|%s\n", l[i]->name, l[i]->line);