summaryrefslogtreecommitdiff
path: root/ruby_1_8_5/ext/syslog
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_5/ext/syslog')
-rw-r--r--ruby_1_8_5/ext/syslog/.cvsignore3
-rw-r--r--ruby_1_8_5/ext/syslog/depend2
-rw-r--r--ruby_1_8_5/ext/syslog/extconf.rb10
-rw-r--r--ruby_1_8_5/ext/syslog/syslog.c394
-rw-r--r--ruby_1_8_5/ext/syslog/syslog.txt121
-rw-r--r--ruby_1_8_5/ext/syslog/test.rb164
6 files changed, 0 insertions, 694 deletions
diff --git a/ruby_1_8_5/ext/syslog/.cvsignore b/ruby_1_8_5/ext/syslog/.cvsignore
deleted file mode 100644
index 4088712231..0000000000
--- a/ruby_1_8_5/ext/syslog/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-mkmf.log
-*.def
diff --git a/ruby_1_8_5/ext/syslog/depend b/ruby_1_8_5/ext/syslog/depend
deleted file mode 100644
index 45cbea293a..0000000000
--- a/ruby_1_8_5/ext/syslog/depend
+++ /dev/null
@@ -1,2 +0,0 @@
-syslog.o: syslog.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h \
- $(hdrdir)/intern.h
diff --git a/ruby_1_8_5/ext/syslog/extconf.rb b/ruby_1_8_5/ext/syslog/extconf.rb
deleted file mode 100644
index d47ed8fd61..0000000000
--- a/ruby_1_8_5/ext/syslog/extconf.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-# $RoughId: extconf.rb,v 1.3 2001/11/24 17:49:26 knu Exp $
-# $Id: extconf.rb,v 1.1 2001/11/26 12:00:40 knu Exp $
-
-require 'mkmf'
-
-have_header("syslog.h") &&
- have_func("openlog") &&
- have_func("setlogmask") &&
- create_makefile("syslog")
-
diff --git a/ruby_1_8_5/ext/syslog/syslog.c b/ruby_1_8_5/ext/syslog/syslog.c
deleted file mode 100644
index 99e4215a95..0000000000
--- a/ruby_1_8_5/ext/syslog/syslog.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * UNIX Syslog extension for Ruby
- * Amos Gouaux, University of Texas at Dallas
- * <amos+ruby@utdallas.edu>
- *
- * $RoughId: syslog.c,v 1.21 2002/02/25 12:21:17 knu Exp $
- * $Id: syslog.c,v 1.8.2.1 2004/04/05 07:45:24 matz Exp $
- */
-
-#include "ruby.h"
-#include "util.h"
-#include <syslog.h>
-
-/* Syslog class */
-static VALUE mSyslog, mSyslogConstants;
-static const char *syslog_ident = NULL;
-static int syslog_options = -1, syslog_facility = -1, syslog_mask = -1;
-static int syslog_opened = 0;
-
-/* Package helper routines */
-static void syslog_write(int pri, int argc, VALUE *argv)
-{
- VALUE str;
-
- if (argc < 1) {
- rb_raise(rb_eArgError, "no log message supplied");
- }
-
- if (!syslog_opened) {
- rb_raise(rb_eRuntimeError, "must open syslog before write");
- }
-
- str = rb_f_sprintf(argc, argv);
-
- syslog(pri, "%s", RSTRING(str)->ptr);
-}
-
-/* Syslog module methods */
-static VALUE mSyslog_close(VALUE self)
-{
- if (!syslog_opened) {
- rb_raise(rb_eRuntimeError, "syslog not opened");
- }
-
- closelog();
-
- free((void *)syslog_ident);
- syslog_ident = NULL;
- syslog_options = syslog_facility = syslog_mask = -1;
- syslog_opened = 0;
-
- return Qnil;
-}
-
-static VALUE mSyslog_open(int argc, VALUE *argv, VALUE self)
-{
- VALUE ident, opt, fac;
-
- if (syslog_opened) {
- rb_raise(rb_eRuntimeError, "syslog already open");
- }
-
- rb_scan_args(argc, argv, "03", &ident, &opt, &fac);
-
- if (NIL_P(ident)) {
- ident = rb_gv_get("$0");
- }
-#ifdef SafeStringValue
- SafeStringValue(ident);
-#else
- Check_SafeStr(ident);
-#endif
- syslog_ident = strdup(RSTRING(ident)->ptr);
-
- if (NIL_P(opt)) {
- syslog_options = LOG_PID | LOG_CONS;
- } else {
- syslog_options = NUM2INT(opt);
- }
-
- if (NIL_P(fac)) {
- syslog_facility = LOG_USER;
- } else {
- syslog_facility = NUM2INT(fac);
- }
-
- openlog(syslog_ident, syslog_options, syslog_facility);
-
- syslog_opened = 1;
-
- setlogmask(syslog_mask = setlogmask(0));
-
- /* be like File.new.open {...} */
- if (rb_block_given_p()) {
- rb_ensure(rb_yield, self, mSyslog_close, self);
- }
-
- return self;
-}
-
-static VALUE mSyslog_reopen(int argc, VALUE *argv, VALUE self)
-{
- mSyslog_close(self);
-
- return mSyslog_open(argc, argv, self);
-}
-
-static VALUE mSyslog_isopen(VALUE self)
-{
- return syslog_opened ? Qtrue : Qfalse;
-}
-
-static VALUE mSyslog_ident(VALUE self)
-{
- return syslog_opened ? rb_str_new2(syslog_ident) : Qnil;
-}
-
-static VALUE mSyslog_options(VALUE self)
-{
- return syslog_opened ? INT2NUM(syslog_options) : Qnil;
-}
-
-static VALUE mSyslog_facility(VALUE self)
-{
- return syslog_opened ? INT2NUM(syslog_facility) : Qnil;
-}
-
-static VALUE mSyslog_get_mask(VALUE self)
-{
- return syslog_opened ? INT2NUM(syslog_mask) : Qnil;
-}
-
-static VALUE mSyslog_set_mask(VALUE self, VALUE mask)
-{
- if (!syslog_opened) {
- rb_raise(rb_eRuntimeError, "must open syslog before setting log mask");
- }
-
- setlogmask(syslog_mask = NUM2INT(mask));
-
- return mask;
-}
-
-static VALUE mSyslog_log(int argc, VALUE *argv, VALUE self)
-{
- VALUE pri;
-
- if (argc < 2) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 2+)", argc);
- }
-
- argc--;
- pri = *argv++;
-
- if (!FIXNUM_P(pri)) {
- rb_raise(rb_eTypeError, "type mismatch: %s given", rb_class2name(CLASS_OF(pri)));
- }
-
- syslog_write(FIX2INT(pri), argc, argv);
-
- return self;
-}
-
-static VALUE mSyslog_inspect(VALUE self)
-{
- char buf[1024];
-
- if (syslog_opened) {
- snprintf(buf, sizeof(buf),
- "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>",
- rb_class2name(self),
- syslog_ident,
- syslog_options,
- syslog_facility,
- syslog_mask);
- } else {
- snprintf(buf, sizeof(buf),
- "<#%s: opened=false>", rb_class2name(self));
- }
-
- return rb_str_new2(buf);
-}
-
-static VALUE mSyslog_instance(VALUE self)
-{
- return self;
-}
-
-#define define_syslog_shortcut_method(pri, name) \
-static VALUE mSyslog_##name(int argc, VALUE *argv, VALUE self) \
-{ \
- syslog_write(pri, argc, argv); \
-\
- return self; \
-}
-
-#ifdef LOG_EMERG
-define_syslog_shortcut_method(LOG_EMERG, emerg)
-#endif
-#ifdef LOG_ALERT
-define_syslog_shortcut_method(LOG_ALERT, alert)
-#endif
-#ifdef LOG_CRIT
-define_syslog_shortcut_method(LOG_CRIT, crit)
-#endif
-#ifdef LOG_ERR
-define_syslog_shortcut_method(LOG_ERR, err)
-#endif
-#ifdef LOG_WARNING
-define_syslog_shortcut_method(LOG_WARNING, warning)
-#endif
-#ifdef LOG_NOTICE
-define_syslog_shortcut_method(LOG_NOTICE, notice)
-#endif
-#ifdef LOG_INFO
-define_syslog_shortcut_method(LOG_INFO, info)
-#endif
-#ifdef LOG_DEBUG
-define_syslog_shortcut_method(LOG_DEBUG, debug)
-#endif
-
-static VALUE mSyslogConstants_LOG_MASK(VALUE klass, VALUE pri)
-{
- return INT2FIX(LOG_MASK(FIX2INT(pri)));
-}
-
-static VALUE mSyslogConstants_LOG_UPTO(VALUE klass, VALUE pri)
-{
- return INT2FIX(LOG_UPTO(FIX2INT(pri)));
-}
-
-/* Init for package syslog */
-void Init_syslog()
-{
- mSyslog = rb_define_module("Syslog");
-
- mSyslogConstants = rb_define_module_under(mSyslog, "Constants");
-
- rb_include_module(mSyslog, mSyslogConstants);
-
- rb_define_module_function(mSyslog, "open", mSyslog_open, -1);
- rb_define_module_function(mSyslog, "reopen", mSyslog_reopen, -1);
- rb_define_module_function(mSyslog, "open!", mSyslog_reopen, -1);
- rb_define_module_function(mSyslog, "opened?", mSyslog_isopen, 0);
-
- rb_define_module_function(mSyslog, "ident", mSyslog_ident, 0);
- rb_define_module_function(mSyslog, "options", mSyslog_options, 0);
- rb_define_module_function(mSyslog, "facility", mSyslog_facility, 0);
-
- rb_define_module_function(mSyslog, "log", mSyslog_log, -1);
- rb_define_module_function(mSyslog, "close", mSyslog_close, 0);
- rb_define_module_function(mSyslog, "mask", mSyslog_get_mask, 0);
- rb_define_module_function(mSyslog, "mask=", mSyslog_set_mask, 1);
-
- rb_define_module_function(mSyslog, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
- rb_define_module_function(mSyslog, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);
-
- rb_define_module_function(mSyslog, "inspect", mSyslog_inspect, 0);
- rb_define_module_function(mSyslog, "instance", mSyslog_instance, 0);
-
- rb_define_module_function(mSyslogConstants, "LOG_MASK", mSyslogConstants_LOG_MASK, 1);
- rb_define_module_function(mSyslogConstants, "LOG_UPTO", mSyslogConstants_LOG_UPTO, 1);
-
-#define rb_define_syslog_const(id) \
- rb_define_const(mSyslogConstants, #id, INT2NUM(id))
-
- /* Various options when opening log */
-#ifdef LOG_PID
- rb_define_syslog_const(LOG_PID);
-#endif
-#ifdef LOG_CONS
- rb_define_syslog_const(LOG_CONS);
-#endif
-#ifdef LOG_ODELAY
- rb_define_syslog_const(LOG_ODELAY); /* deprecated */
-#endif
-#ifdef LOG_NDELAY
- rb_define_syslog_const(LOG_NDELAY);
-#endif
-#ifdef LOG_NOWAIT
- rb_define_syslog_const(LOG_NOWAIT); /* deprecated */
-#endif
-#ifdef LOG_PERROR
- rb_define_syslog_const(LOG_PERROR);
-#endif
-
- /* Various syslog facilities */
-#ifdef LOG_AUTH
- rb_define_syslog_const(LOG_AUTH);
-#endif
-#ifdef LOG_AUTHPRIV
- rb_define_syslog_const(LOG_AUTHPRIV);
-#endif
-#ifdef LOG_CONSOLE
- rb_define_syslog_const(LOG_CONSOLE);
-#endif
-#ifdef LOG_CRON
- rb_define_syslog_const(LOG_CRON);
-#endif
-#ifdef LOG_DAEMON
- rb_define_syslog_const(LOG_DAEMON);
-#endif
-#ifdef LOG_FTP
- rb_define_syslog_const(LOG_FTP);
-#endif
-#ifdef LOG_KERN
- rb_define_syslog_const(LOG_KERN);
-#endif
-#ifdef LOG_LPR
- rb_define_syslog_const(LOG_LPR);
-#endif
-#ifdef LOG_MAIL
- rb_define_syslog_const(LOG_MAIL);
-#endif
-#ifdef LOG_NEWS
- rb_define_syslog_const(LOG_NEWS);
-#endif
-#ifdef LOG_NTP
- rb_define_syslog_const(LOG_NTP);
-#endif
-#ifdef LOG_SECURITY
- rb_define_syslog_const(LOG_SECURITY);
-#endif
-#ifdef LOG_SYSLOG
- rb_define_syslog_const(LOG_SYSLOG);
-#endif
-#ifdef LOG_USER
- rb_define_syslog_const(LOG_USER);
-#endif
-#ifdef LOG_UUCP
- rb_define_syslog_const(LOG_UUCP);
-#endif
-#ifdef LOG_LOCAL0
- rb_define_syslog_const(LOG_LOCAL0);
-#endif
-#ifdef LOG_LOCAL1
- rb_define_syslog_const(LOG_LOCAL1);
-#endif
-#ifdef LOG_LOCAL2
- rb_define_syslog_const(LOG_LOCAL2);
-#endif
-#ifdef LOG_LOCAL3
- rb_define_syslog_const(LOG_LOCAL3);
-#endif
-#ifdef LOG_LOCAL4
- rb_define_syslog_const(LOG_LOCAL4);
-#endif
-#ifdef LOG_LOCAL5
- rb_define_syslog_const(LOG_LOCAL5);
-#endif
-#ifdef LOG_LOCAL6
- rb_define_syslog_const(LOG_LOCAL6);
-#endif
-#ifdef LOG_LOCAL7
- rb_define_syslog_const(LOG_LOCAL7);
-#endif
-
-#define rb_define_syslog_shortcut(name) \
- rb_define_module_function(mSyslog, #name, mSyslog_##name, -1)
-
- /* Various syslog priorities and the shortcut methods */
-#ifdef LOG_EMERG
- rb_define_syslog_const(LOG_EMERG);
- rb_define_syslog_shortcut(emerg);
-#endif
-#ifdef LOG_ALERT
- rb_define_syslog_const(LOG_ALERT);
- rb_define_syslog_shortcut(alert);
-#endif
-#ifdef LOG_CRIT
- rb_define_syslog_const(LOG_CRIT);
- rb_define_syslog_shortcut(crit);
-#endif
-#ifdef LOG_ERR
- rb_define_syslog_const(LOG_ERR);
- rb_define_syslog_shortcut(err);
-#endif
-#ifdef LOG_WARNING
- rb_define_syslog_const(LOG_WARNING);
- rb_define_syslog_shortcut(warning);
-#endif
-#ifdef LOG_NOTICE
- rb_define_syslog_const(LOG_NOTICE);
- rb_define_syslog_shortcut(notice);
-#endif
-#ifdef LOG_INFO
- rb_define_syslog_const(LOG_INFO);
- rb_define_syslog_shortcut(info);
-#endif
-#ifdef LOG_DEBUG
- rb_define_syslog_const(LOG_DEBUG);
- rb_define_syslog_shortcut(debug);
-#endif
-}
diff --git a/ruby_1_8_5/ext/syslog/syslog.txt b/ruby_1_8_5/ext/syslog/syslog.txt
deleted file mode 100644
index b134ed2a40..0000000000
--- a/ruby_1_8_5/ext/syslog/syslog.txt
+++ /dev/null
@@ -1,121 +0,0 @@
-.\" syslog.txt - -*- Indented-Text -*-
-$RoughId: syslog.txt,v 1.18 2002/02/25 08:20:14 knu Exp $
-$Id: syslog.txt,v 1.2 2002/02/25 12:13:30 knu Exp $
-
-UNIX Syslog extension for Ruby
-Amos Gouaux, University of Texas at Dallas
-<amos+ruby@utdallas.edu>
-&
-Akinori MUSHA
-<knu@ruby-lang.org>
-
-** Syslog(Module)
-
-Included Modules: Syslog::Constants
-
-require 'syslog'
-
-A Simple wrapper for the UNIX syslog system calls that might be handy
-if you're writing a server in Ruby. For the details of the syslog(8)
-architecture and constants, see the syslog(3) manual page of your
-platform.
-
-Module Methods:
-
- open(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
- facility = Syslog::LOG_USER) [{ |syslog| ... }]
-
- Opens syslog with the given options and returns the module
- itself. If a block is given, calls it with an argument of
- itself. If syslog is already opened, raises RuntimeError.
-
- Example:
- Syslog.open('ftpd', Syslog::LOG_PID | Syslog::LOG_NDELAY,
- Syslog::LOG_FTP)
-
- open!(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
- facility = Syslog::LOG_USER)
- reopen(ident = $0, logopt = Syslog::LOG_PID | Syslog::LOG_CONS,
- facility = Syslog::LOG_USER)
-
- Same as open, but does a close first.
-
- opened?
-
- Returns true if syslog opened, otherwise false.
-
- ident
- options
- facility
-
- Returns the parameters given in the last open, respectively.
- Every call of Syslog::open resets these values.
-
- log(pri, message, ...)
-
- Writes message to syslog.
-
- Example:
- Syslog.log(Syslog::LOG_CRIT, "the sky is falling in %d seconds!", 10)
-
- crit(message, ...)
- emerg(message, ...)
- alert(message, ...)
- err(message, ...)
- warning(message, ...)
- notice(message, ...)
- info(message, ...)
- debug(message, ...)
-
- These are shortcut methods of Syslog::log(). The lineup may
- vary depending on what priorities are defined on your system.
-
- Example:
- Syslog.crit("the sky is falling in %d seconds!", 5)
-
- mask
- mask=(mask)
-
- Returns or sets the log priority mask. The value of the mask
- is persistent and will not be reset by Syslog::open or
- Syslog::close.
-
- Example:
- Syslog.mask = Syslog::LOG_UPTO(Syslog::LOG_ERR)
-
- close
-
- Closes syslog.
-
- inspect
-
- Returns the "inspect" string of the Syslog module.
-
- instance
-
- Returns the module itself. (Just for backward compatibility)
-
- LOG_MASK(pri)
-
- Creates a mask for one priority.
-
- LOG_UPTO(pri)
-
- Creates a mask for all priorities up to pri.
-
-** Syslog::Constants(Module)
-
-require 'syslog'
-include Syslog::Constants
-
-This module includes the LOG_* constants available on the system.
-
-Module Methods:
-
- LOG_MASK(pri)
-
- Creates a mask for one priority.
-
- LOG_UPTO(pri)
-
- Creates a mask for all priorities up to pri.
diff --git a/ruby_1_8_5/ext/syslog/test.rb b/ruby_1_8_5/ext/syslog/test.rb
deleted file mode 100644
index 907602c21d..0000000000
--- a/ruby_1_8_5/ext/syslog/test.rb
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env ruby
-# $RoughId: test.rb,v 1.9 2002/02/25 08:20:14 knu Exp $
-# $Id: test.rb,v 1.4 2002/11/27 08:36:22 knu Exp $
-
-# Please only run this test on machines reasonable for testing.
-# If in doubt, ask your admin.
-
-require 'test/unit'
-
-# Prepend current directory to load path for testing.
-$:.unshift('.')
-
-require 'syslog'
-
-class TestSyslog < Test::Unit::TestCase
- def test_new
- assert_raises(NoMethodError) {
- Syslog.new
- }
- end
-
- def test_instance
- sl1 = Syslog.instance
- sl2 = Syslog.open
- sl3 = Syslog.instance
-
- assert_equal(Syslog, sl1)
- assert_equal(Syslog, sl2)
- assert_equal(Syslog, sl3)
- ensure
- Syslog.close if Syslog.opened?
- end
-
- def test_open
- # default parameters
- Syslog.open
-
- assert_equal($0, Syslog.ident)
- assert_equal(Syslog::LOG_PID | Syslog::LOG_CONS, Syslog.options)
- assert_equal(Syslog::LOG_USER, Syslog.facility)
-
- # open without close
- assert_raises(RuntimeError) {
- Syslog.open
- }
-
- Syslog.close
-
- # given parameters
- Syslog.open("foo", Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog::LOG_DAEMON)
-
- assert_equal('foo', Syslog.ident)
- assert_equal(Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog.options)
- assert_equal(Syslog::LOG_DAEMON, Syslog.facility)
-
- Syslog.close
-
- # default parameters again (after close)
- Syslog.open
- Syslog.close
-
- assert_equal(nil, Syslog.ident)
- assert_equal(nil, Syslog.options)
- assert_equal(nil, Syslog.facility)
-
- # block
- param = nil
- Syslog.open { |param| }
- assert_equal(Syslog, param)
- ensure
- Syslog.close if Syslog.opened?
- end
-
- def test_opened?
- assert_equal(false, Syslog.opened?)
-
- Syslog.open
- assert_equal(true, Syslog.opened?)
-
- Syslog.close
- assert_equal(false, Syslog.opened?)
-
- Syslog.open {
- assert_equal(true, Syslog.opened?)
- }
-
- assert_equal(false, Syslog.opened?)
- end
-
- def test_close
- assert_raises(RuntimeError) {
- Syslog.close
- }
- end
-
- def test_mask
- assert_equal(nil, Syslog.mask)
-
- Syslog.open
-
- orig = Syslog.mask
-
- Syslog.mask = Syslog.LOG_UPTO(Syslog::LOG_ERR)
- assert_equal(Syslog.LOG_UPTO(Syslog::LOG_ERR), Syslog.mask)
-
- Syslog.mask = Syslog.LOG_MASK(Syslog::LOG_CRIT)
- assert_equal(Syslog.LOG_MASK(Syslog::LOG_CRIT), Syslog.mask)
-
- Syslog.mask = orig
- ensure
- Syslog.close if Syslog.opened?
- end
-
- def test_log
- stderr = IO::pipe
-
- pid = fork {
- stderr[0].close
- STDERR.reopen(stderr[1])
- stderr[1].close
-
- options = Syslog::LOG_PERROR | Syslog::LOG_NDELAY
-
- Syslog.open("syslog_test", options) { |sl|
- sl.log(Syslog::LOG_NOTICE, "test1 - hello, %s!", "world")
- sl.notice("test1 - hello, %s!", "world")
- }
-
- Syslog.open("syslog_test", options | Syslog::LOG_PID) { |sl|
- sl.log(Syslog::LOG_CRIT, "test2 - pid")
- sl.crit("test2 - pid")
- }
- exit!
- }
-
- stderr[1].close
- Process.waitpid(pid)
-
- # LOG_PERROR is not yet implemented on Cygwin.
- return if RUBY_PLATFORM =~ /cygwin/
-
- 2.times {
- assert_equal("syslog_test: test1 - hello, world!\n", stderr[0].gets)
- }
-
- 2.times {
- assert_equal(format("syslog_test[%d]: test2 - pid\n", pid), stderr[0].gets)
- }
- end
-
- def test_inspect
- Syslog.open { |sl|
- assert_equal(format('<#%s: opened=true, ident="%s", options=%d, facility=%d, mask=%d>',
- Syslog,
- sl.ident,
- sl.options,
- sl.facility,
- sl.mask),
- sl.inspect)
- }
-
- assert_equal(format('<#%s: opened=false>', Syslog), Syslog.inspect)
- end
-end