Changeset 6

Show
Ignore:
Timestamp:
09/14/00 03:45:16 (14 years ago)
Author:
jesus
Message:

Updated regex support to use Solaris native regex's under Solaris and the
GNU regex under Linux. Fixed rejoin after disconnect bug.
Robustified makefile for Solaris.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README

    r2 r6  
    66there are a few tid bits of knowledge to know. 
    77 
    8 If you are running on Solaris you will most probably need to add 
    9 -lnsl -lsocket to the LIBS line in makefile
     8Edit the makefile and uncomment/comment the right parts in the architecture 
     9dependant sections
    1010 
    1111If you kill -HUP or kill the spreadlogd process, it will not actually 
  • trunk/config.c

    r2 r6  
    1414#include <sys/stat.h> 
    1515#include <fcntl.h> 
     16#include <sys/file.h> 
    1617#include <unistd.h> 
    1718 
     
    157158} 
    158159void config_add_logfacility_match(LogFacility *lf, char *nm) { 
     160#ifdef RE_SYNTAX_EGREP 
    159161  const char *ret; 
     162#else 
     163  int ret; 
     164#endif 
    160165  if(lf->nmatches>=10) { 
    161166    fprintf(stderr, "Already 10 regex's on group\n"); 
    162167    return; 
    163168  } 
     169#ifdef RE_SYNTAX_EGREP 
    164170  re_set_syntax(RE_SYNTAX_EGREP); 
    165171  if((ret = re_compile_pattern(nm, strlen(nm), 
    166172                              &lf->match_expression[lf->nmatches]))!=0) { 
    167173    fprintf(stderr, ret); 
     174#else 
     175 if((ret = regcomp(&lf->match_expression[lf->nmatches], nm, REG_EGREP))!=0) { 
     176   char errbuf[120]; 
     177   regerror(ret, &lf->match_expression[lf->nmatches], errbuf, sizeof errbuf); 
     178   fprintf(stderr, errbuf); 
     179#endif 
    168180  } else { 
    169181    lf->nmatches++; 
     
    282294  if(!lf->nmatches) return lf->logfile->fd; 
    283295  slen = strlen(message); 
    284   for(i=0; i<lf->nmatches; i++) 
     296  for(i=0; i<lf->nmatches; i++) { 
     297#ifdef RE_SYNTAX_EGREP 
    285298    if((ret = re_search(&lf->match_expression[i], 
    286299                        message, slen, 0, slen, NULL)) >= 0) 
     
    290303    else if(ret==-1 && verbose) 
    291304      fprintf(stderr, "Failed match!\n"); 
     305#else 
     306    if(!regexec(&lf->match_expression[i], message, 0, NULL, 0)) 
     307      return lf->logfile->fd; 
     308#endif 
     309  } 
    292310  return -1; 
    293311} 
  • trunk/makefile

    r2 r6  
    11CC=gcc 
    2 CFLAGS=-g -Wall -D__USE_LARGEFILE64 
     2CFLAGS=-g -D__USE_LARGEFILE64 
    33INCLUDES=-I/usr/local/include 
     4 
     5#### BEGIN ARCH DEPENDANT SECTION #### 
     6# For Linux 
    47LDFLAGS=-L/usr/local/lib -L. 
    58LIBS=-lsp -lskiplist 
     9 
     10# For Solaris 
     11#LIBS=-lsp -lskiplist -lnsl -lsocket -lucb 
     12#LDFLAGS=-L/usr/local/lib -L/usr/ucblib -R/usr/ucblib -L. 
     13#BSDINCLUDES=-I/usr/ucbinclude 
     14#### END ARCH DEPENDANT SECTION #### 
    615 
    716YACC=bison -y 
     
    2433        $(CC) $(CFLAGS) $(INCLUDES) -c y.tab.c 
    2534 
     35config.o:       config.c 
     36        $(CC) $(CFLAGS) $(BSDINCLUDES) $(INCLUDES) -c $< 
     37 
    2638.c.o:   $*.c 
    2739        $(CC) $(CFLAGS) $(INCLUDES) -c $< 
  • trunk/spreadlogd.c

    r2 r6  
    1919#include "config.h" 
    2020 
    21 #define SPREADLOGD_VERSION "1.2
     21#define SPREADLOGD_VERSION "1.3
    2222 
    2323extern char *optarg; 
     
    245245                /* So, let's try */ 
    246246                SpreadConfiguration *thissc = fds[fd]; 
     247                tojoin = 1; 
    247248                thissc->connected = 0; 
    248                 connectandjoin(thissc, NULL);           
     249                connectandjoin(thissc, &tojoin); 
    249250              } 
    250251            } else if(Is_regular_mess(mess_type)) {