]> wagner.pp.ru Git - oss/tclsyslog.git/commitdiff
Reappied changes from 2.0 BRANCH_2x
authorVictor Wagner <vitus@wagner.pp.ru>
Fri, 24 Feb 2006 14:14:08 +0000 (14:14 +0000)
committerVictor Wagner <vitus@wagner.pp.ru>
Fri, 24 Feb 2006 14:14:08 +0000 (14:14 +0000)
Makefile
syslog.n
tclsyslog.c

index fc32a3cb0fb7613cce99f32f716939018f5d2e9b..886af19bd7bf5c397740954f444252cb99e5482f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=2.0
+VERSION=2.1
 # This is root of installation tree
 PREFIX=/usr/local
 CC=gcc
@@ -43,4 +43,6 @@ install:
        ${INSTALL} -m 755 -c libsyslog.so.${VERSION} ${LIBDIR}/syslog 
        ${INSTALL} -m 644 -c pkgIndex.tcl ${LIBDIR}/syslog
        ${INSTALL} -m 644 -c syslog.n ${MANDIR}/syslog.${MANSUFFIX}
-
+tar:
+       
+       tar czfC ../tclsyslog-${VERSION}.tar.gz .. tclsyslog --exclude CVS
index b74903fa0be83b4e7f40c90ffaf67bf086b33e96..d46192433aba0394a9e14ce7f733fdef25020edd 100644 (file)
--- a/syslog.n
+++ b/syslog.n
@@ -2,7 +2,7 @@
 '\" Copyright (c) 1999 Victor B. Wagner
 '\"
 '\" 
-'\" RCS: @(#) $Id: syslog.n,v 1.2 2006-02-24 14:13:07 vitus Exp $
+'\" RCS: @(#) $Id: syslog.n,v 1.2.2.1 2006-02-24 14:14:08 vitus Exp $
 '\" 
 '\" The definitions below are for supplemental macros used in Tcl/Tk
 '\" manual entries.
@@ -65,7 +65,7 @@
 '\" .UL arg1 arg2
 '\"    Print arg1 underlined, then print arg2 normally.
 '\"
-'\" RCS: @(#) $Id: syslog.n,v 1.2 2006-02-24 14:13:07 vitus Exp $
+'\" RCS: @(#) $Id: syslog.n,v 1.2.2.1 2006-02-24 14:14:08 vitus Exp $
 '\"
 '\"    # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
 .if t .wh -1.3i ^B
@@ -267,20 +267,33 @@ specified before \fIpriority\fR to control these parameters:
 \fB\-facility\fR \fIvalue\fR
 Use specified facility instead of \fBuser\fR. Following facility are
 recognized:
+.RS
 .PP
 \fBauthpriv\fR, \fBcron\fR, \fBdaemon\fR, \fBkernel\fR, \fBlpr\fR, 
 \fBmail\fR, \fBnews\fR, \fBsyslog\fR, \fBuser\fR, \fBuucp\fR, \fBlocal0\fR,
 \fBlocal1\fR, \fBlocal2\fR.
+.RE
 .TP 20
 \fB\-ident\fR \fIstring\fR
 Use given \fIstring\fR instead of \fBargv0\fB variable for ident string.
 .TP 20
-\fB\-options\fR \fIinteger\fR
+\fB\-options\fR \fIlist\fR
 Set syslog options such as \fBLOG_CONS\fR, \fBLOG_NDELAY\fR
-You should user numeric values of those from your system \fBsyslog.h\fR
-file, becouse I haven't got time to implement yet another hash table.  
+List should contain one or more strings 
+\fBCONS\fR, \fBNDELAY\fR, \fBODELAY\fR, \fBPERROR\fR, \fBPID\fR, \fBNOWAIT\fR
+.RS
+.PP 
+Options \fBNDELAY\fR and \fBODELAY\fR are effectively no-op, becouse
+\fBopenlog\fR(3) call is only performed upon first message send. 
+.PP
+Numeric value of options can be specified instead of list for
+compatibility with older versions. Mixing of numeric and string
+constants are not allowed.
 .RE
-
+.PP
+If any options are specified, \fIpriority\fR and \fImessage\fR arguments 
+can be omitted. In this case \fBsyslog\fR command only sets logging
+parameters which would be used for subsequent calls.
 
 .SH KEYWORDS
 logging, syslog
index c2409058fdaa461119dcf70c5d73662c56b00b10..c636a34a69ac39c3f87234e8932c626a1eac46d8 100644 (file)
@@ -10,6 +10,7 @@ typedef struct {
                 char ident[32];
                 Tcl_HashTable *priorities;
                 Tcl_HashTable *facilities;
+               Tcl_HashTable *option_names;
                } SyslogInfo;
 
 void Syslog_ListHash(Tcl_Interp *interp,Tcl_HashTable *table);        
@@ -56,9 +57,30 @@ int Syslog_Log(ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj *CONST  ob
             info-> logOpened=0;
         }
      } else if (!strncmp(Tcl_GetString(objv[i]),"-options",9)) {
-         long tmp;
-        if (Tcl_GetLongFromObj(interp,objv[i+1],&tmp)==TCL_ERROR)
-             return TCL_ERROR;
+            int tmp;
+            int j,n;
+           Tcl_Obj *elem;
+           Tcl_HashEntry *entry;
+           Tcl_ResetResult(interp);
+           tmp=0;
+           if (Tcl_ListObjLength(interp,objv[i+1],&n)==TCL_ERROR) {
+               return TCL_ERROR;
+            }          
+           for (j=0;j<n;j++) {
+               Tcl_ListObjIndex(interp,objv[i+1],j,&elem);
+               entry=Tcl_FindHashEntry(info->option_names,Tcl_GetString(elem));
+               if (!entry) {
+                   if (n!=1 || Tcl_GetIntFromObj(interp,elem,&tmp)!=TCL_OK) {
+                       Tcl_AppendResult(interp,"Invalid option '",
+                               Tcl_GetString(elem),"' valid ones are:",NULL);
+                       Syslog_ListHash(interp,info->option_names);
+                       return TCL_ERROR;
+                   }
+               } else {         
+                   tmp |= (int) Tcl_GetHashValue(entry);
+               }    
+           }   
+           
         info->options=tmp;
         if (info->logOpened) {
             closelog();
@@ -219,6 +241,14 @@ int Syslog_Init(Tcl_Interp *interp)
    AddEntry(info->priorities,"notice",LOG_NOTICE);
    AddEntry(info->priorities,"info",LOG_INFO);
    AddEntry(info->priorities,"debug",LOG_DEBUG);
+   info->option_names=(Tcl_HashTable *) Tcl_Alloc(sizeof(Tcl_HashTable));
+   Tcl_InitHashTable(info->option_names,TCL_STRING_KEYS);
+   AddEntry(info->option_names,"CONS",LOG_CONS);
+   AddEntry(info->option_names,"NDELAY",LOG_NDELAY);
+   AddEntry(info->option_names,"PERROR",LOG_PERROR);
+   AddEntry(info->option_names,"PID",LOG_PID);
+   AddEntry(info->option_names,"ODELAY",LOG_ODELAY);
+   AddEntry(info->option_names,"NOWAIT",LOG_NOWAIT);
    Tcl_CreateObjCommand(interp,"syslog",Syslog_Log,(ClientData) info,
             Syslog_Delete); 
    return Tcl_PkgProvide(interp,"Syslog",VERSION);