]> code.citadel.org Git - citadel.git/commitdiff
Added the P/C ratio back to stats
authorArt Cancro <ajc@citadel.org>
Mon, 7 Dec 1998 02:47:34 +0000 (02:47 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 7 Dec 1998 02:47:34 +0000 (02:47 +0000)
citadel/Makefile.in
citadel/stats.c

index f21afdcef6246a0e784d1d226c59573966b3d1b2..163410ef06f3ed362f1566b0cfbecde37ea6ab14 100644 (file)
@@ -177,8 +177,8 @@ rcit: rcit.o config.o
        @echo "* ln -s rcit /usr/bin/rnews"
        @echo "*"
 
-stats: stats.o config.o
-       $(CC) stats.o config.o $(LDFLAGS) -o stats
+stats: stats.o ipc_c_tcp.o tools.o config.o $(SNPRINTF)
+       $(CC) stats.o ipc_c_tcp.o tools.o config.o $(SNPRINTF) $(LDFLAGS) -o stats
 
 .PHONY: install-data install-doc install-exec clean cleaner distclean
 
index 94f9dc72b3d233e248d91dc23de19d4bb70b9462..7eba60ffcc0b7ccc3c7995ec84676e86a63d1424 100644 (file)
@@ -11,6 +11,8 @@
 #include <limits.h>
 #include "citadel.h"
 #include "config.h"
+#include "ipc.h"
+#include "tools.h"
 
 #define disply(x,y) printf("%20s            %4.1f    %4.1f    %4d\n",x,((float)y)/calls,((float)y)/days,y)
 
@@ -24,6 +26,9 @@ struct caller {
        int Ctimescalled;
 };
 
+void logoff(int code) {
+       exit(code);
+       }
 
 void prompt(void)
 {
@@ -104,6 +109,7 @@ int main(int argc, char **argv)
        int pc_only = 0;
        char buf[256];
        FILE *logfp;
+       char *fakeargs[4];
 
        for (a = 0; a < argc; ++a) {
                if (!strcmp(argv[a], "-b"))
@@ -122,9 +128,6 @@ int main(int argc, char **argv)
        if (pc_only)
                goto PC_ONLY_HERE;
 
-       if (!batch_mode)
-               printf("Scanning call log, please wait...\n\n\n\n");
-
        from = 0;
        to = 0;
        for (a = 0; a < 72; ++a) {
@@ -312,26 +315,37 @@ int main(int argc, char **argv)
                                   statement. */
 
 
-/*
-   This report doesn't work anymore, because it requires reading the user
-   file directly, which can't happen.
-   printf ("Top 20 Contributing Users (post to call ratio)\n");
-   printf ("P/C Ratio Username\n");
-   printf ("--------- ------------------------------\n");
-   fflush (stdout);
-   sortpipe = (FILE *) popen ("sort |tail -20 |sort -r", "w");
-   fp = fopen ("usersupp", "r");
-   while ((fp != NULL)
-   && (fread ((char *) &usersupp, sizeof (struct usersupp), 1, fp) > 0))
-   {
-   fprintf (sortpipe, "%9.2f %-30s\n",
-   ((float) usersupp.posted / (float) usersupp.timescalled),
-   usersupp.fullname);
-   }
-   fclose (fp);
-   pclose (sortpipe);
-   exit (0);
- */
+               printf("Top 20 Contributing Users (post to call ratio)\n");
+               printf("P/C Ratio Username\n");
+               printf("--------- ------------------------------\n");
+               fflush(stdout);
+               sortpipe = (FILE *) popen("sort |tail -20 |sort -r", "w");
+
+
+
+               fakeargs[0] = "whobbs";
+               fakeargs[1] = "localhost";
+               fakeargs[2] = malloc(64);
+               sprintf(fakeargs[2], "%d", config.c_port_number);
+               fakeargs[3] = NULL;
+               attach_to_server(3, fakeargs);
+               free(fakeargs[2]);
+               serv_gets(buf);
+               if ((buf[0]!='2')&&(strncmp(buf,"551",3))) {
+                       fprintf(stderr,"%s: %s\n",argv[0],&buf[4]);
+                }
+               else {
+                       serv_puts("LIST");
+                       serv_gets(buf);
+                       if (buf[0]=='1') while (serv_gets(buf), 
+                                               strcmp(buf, "000")) {
+                               extract(LogName, buf, 0);
+                               fprintf(sortpipe, "%9.2f %-30s\n",
+                                       ((float) extract_int(buf,5) / (float) extract_int(buf,4)),
+                                       LogName);
+                       }
+               }
+               pclose(sortpipe);
        }
        return 0;
 }