Date: Mon, 01 Sep 1997 14:24:16 -0400 From: John Szumowski <harpo@javanet.com> To: freebsd-questions@freebsd.org Subject: Please help with compile of .c file for Apache Message-ID: <340B0832.41C67EA6@javanet.com>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------59E2B60015FB7483794BDF32 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I'm still in the process of learning about Apache, and decided to try and get a counter set up. I downloaded cgi-pack.tar.gz from ftp.apache.org- but when I tried to compile "counter.c", it bombs. Here's what I see: --- root@vger:/usr/local/src/apache_1.2.4/cgi-pack$ make count gcc -c -g count.c count.c: In function `main': count.c:98: incompatible types in assignment *** Error code 1 Stop. --- Because I really have very little C programming experience under Unix (that's something I'm working on ;-), I wasn't sure what to make of it. The only modifications I've made to the original count.c are changing the #include <dbm.h> to #include <ndbm.h> (I don't know if that was wise...but that seemed to be the file the mod_auth_dbm files in Apache's source directory were calling), and setting the COUNT_DIR to where I want the log files. This is probably pretty simple (I'm guessing!) but I'm not sure how to approach this. Alternatively, if anyone's happened across a good (+ simple) counter program that'll work under Apache 1.2.4, I'd appreciate an email. TIA, John Szumowski --------------59E2B60015FB7483794BDF32 Content-Type: text/plain; charset=us-ascii; name="count.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="count.c" /* * A simple WebPage counter * * Based on an original Perl script by Roman Czyborra * Script modified by Jim Jagielski (jim@jaguNET.com) * * Port to C by Jim Jagielski */ /* * Method of use: * Assuming that 'count' is placed in /cgi-bin, the CGI "script" * should be called as: * * <IMG SRC="/cgi-bin/count/pathname-of-webpage" * ALT="[some bitmapped number]"> * * Thus, a page in jim's directory would be refered to as: * * <IMG SRC="/cgi-bin/count/~jim/page.html" * ALT="[some bitmapped number]"> * */ /* * Program methodology: * o Open the lockfile (should exist first) * o and FLOCK it * o Now open and use the dbm file that contains the key and content * where the 'key' is the pathname included in the URL * o increment and store the counter * o return the x-bitmap that is the count */ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/file.h> #include <ndbm.h> #include <strings.h> #define COUNT_DIR "/usr/local/etc/httpd/counter" #define COUNT_LOCK "Count" #define COUNT_FILE "Count" main(argc, argv) int argc; char *argv[]; { datum key, content; int fd; char *path, *getenv(); int count, i, j; char cntstr[10]; char *iam; int bval; char reverse = 0; int bitmap[10][10] = { { 0x3c, 0x10, 0x3c, 0x3c, 0x60, 0x7e, 0x3c, 0x7e, 0x3c, 0x3c }, { 0x42, 0x1c, 0x42, 0x42, 0x50, 0x02, 0x42, 0x40, 0x42, 0x42 }, { 0x42, 0x10, 0x42, 0x42, 0x48, 0x02, 0x02, 0x20, 0x42, 0x42 }, { 0x42, 0x10, 0x20, 0x40, 0x48, 0x02, 0x02, 0x20, 0x42, 0x42 }, { 0x42, 0x10, 0x10, 0x38, 0x44, 0x3e, 0x3a, 0x10, 0x3c, 0x42 }, { 0x42, 0x10, 0x08, 0x40, 0x42, 0x40, 0x46, 0x10, 0x42, 0x7c }, { 0x42, 0x10, 0x04, 0x40, 0xfe, 0x40, 0x42, 0x08, 0x42, 0x40 }, { 0x42, 0x10, 0x02, 0x42, 0x40, 0x42, 0x42, 0x08, 0x42, 0x42 }, { 0x42, 0x10, 0x02, 0x42, 0x40, 0x42, 0x42, 0x04, 0x42, 0x42 }, { 0x3c, 0x10, 0x7e, 0x3c, 0x40, 0x3c, 0x3c, 0x04, 0x3c, 0x3c } }; if (!(iam = strrchr(argv[0], '/'))) iam = argv[0]; if (strcmp(iam, "ccount") == 0) reverse = 1; if ((path = getenv("PATH_INFO")) == NULL) exit(1); if (*path == '/') path++; key.dptr = path; key.dsize = strlen(path); if (chdir(COUNT_DIR) < 0) dodie("count chdir"); if ((fd = open(COUNT_LOCK, O_RDWR|O_CREAT, 0644)) < 0) dodie("count open"); if (flock(fd, LOCK_EX)) dodie("count flock"); if (dbminit(COUNT_FILE)) dodie("count dbminit"); content = fetch(key); if (!content.dptr) { count = 1; strcpy(cntstr, "1"); } else { count = (content.dsize < 9) ? content.dsize : 9; strncpy(cntstr, content.dptr, count); cntstr[count] = '\0'; count = atoi(cntstr); if (++count > 999999999) count = 1; sprintf(cntstr, "%d", count); } content.dptr = cntstr; content.dsize = strlen(cntstr); if (store(key, content)) dodie("count store"); if (flock(fd, LOCK_UN)) dodie("count unflock"); if (close(fd)) dodie("count close"); /* * Okey dokey... Got the count, so let's generate the bitmap */ count = strlen(cntstr); /* for later */ printf("Content-Type: image/x-xbitmap\n\n"); printf("#define count_width %d\n", 8*count--); printf("#define count_height 10\n"); printf("static char count_bits[] = {\n"); for (i=0; i<=9; i++) { for(j=0; j<=count; j++) { bval = bitmap[i][cntstr[j]-'0']; if (reverse) bval = 0xff - bval; printf(" 0x%02x,", bval); } printf("\n"); } printf("};\n"); exit(0); } dodie(what) char *what; { perror(what); exit(1); } --------------59E2B60015FB7483794BDF32--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?340B0832.41C67EA6>