/* * MusicMUD Helper program, version 1.0 * Copyright (C) 1998 Abigail Brady * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { char buffer[4096]; FILE * f = popen("grep \"^int [lp][er][vi][ev][ls]\" ../vardata/users/* | uniq", "r"); char lastuser[500] = ""; int lastprivs=0; while (1) { fgets(buffer, 4000, f); if (feof(f)) break; *strchr(buffer, '\n') = 0; char *user = buffer; if (strchr(user, '~')) continue; if (strstr(user, "/root:")) continue; while (strchr(user, '/')) { user = strchr(user, '/')+1; } char *colon = strchr(user, ':'); char *priv_str = strchr(strchr(colon, ' ')+1, ' ')+1; *colon = 0; int privs = atoi(priv_str); if (privs>=10000) privs = 9999; if (lastuser[0] && strcmp(user, lastuser)) { printf("%04i %s\n", lastprivs, lastuser); } strcpy(lastuser, user); lastprivs = privs; } printf("%04i %s\n", lastprivs, lastuser); pclose(f); }