add bsd license

This commit is contained in:
Ward Wouts 2003-07-20 20:32:24 +00:00
parent dfd4648b01
commit d62c5c33e5
6 changed files with 130 additions and 33 deletions

View file

@ -1,13 +1,21 @@
################################# # $Dwarf: uuencode.rb,v 1.5 2003/04/20 20:15:34 ward Exp $
#
# $Dwarf: uuencode.rb,v 1.4 2003/04/20 18:02:51 ward Exp $
# $Source$ # $Source$
# #
# article.rb # Copyright (c) 2002, 2003 Ward Wouts <ward@wouts.nl>
# #
# (C) 2002, Ward Wouts # Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# #
#################################
require 'tempfile' require 'tempfile'

View file

@ -1,13 +1,21 @@
################################# # $Dwarf: yenc.rb,v 1.8 2003/04/22 19:25:57 ward Exp $
#
# $Dwarf: yenc.rb,v 1.7 2003/04/22 19:11:15 ward Exp $
# $Source$ # $Source$
# #
# article.rb # Copyright (c) 2002, 2003 Ward Wouts <ward@wouts.nl>
# #
# (C) 2002, Ward Wouts # Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# #
#################################
require 'tempfile' require 'tempfile'

View file

@ -1,13 +1,21 @@
################################# # $Dwarf: article.rb,v 1.74 2003/07/14 22:12:18 ward Exp $
#
# $Dwarf: article.rb,v 1.73 2003/07/13 11:28:32 ward Exp $
# $Source$ # $Source$
# #
# article.rb # Copyright (c) 2002, 2003 Ward Wouts <ward@wouts.nl>
# #
# (C) 2002, Ward Wouts # Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# #
#################################
require 'set/intspan' require 'set/intspan'
require 'net/nntp' require 'net/nntp'

View file

@ -1,14 +1,21 @@
################################# # $Dwarf: newsrc.rb,v 1.11 2002/11/05 09:33:41 ward Exp $
#
# $Dwarf: newsrc.rb,v 1.10 2002/08/01 11:50:09 ward Exp $
# $Source$ # $Source$
# #
# newsrc.rb # Copyright (c) 2002, 2003 Ward Wouts <ward@wouts.nl>
# ported from Perl code by Ward Wouts
# #
# (C) 2001, Ward Wouts # Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# #
#################################
require "set/intspan" require "set/intspan"
@ -78,6 +85,7 @@ def save
save_as(@newsrc["file"]) save_as(@newsrc["file"])
end end
# this is not thread safe!
def save_as(file) def save_as(file)
if FileTest.exists?("#{file}") if FileTest.exists?("#{file}")
begin begin
@ -100,6 +108,46 @@ def save_as(file)
newsrc.close newsrc.close
end end
def save_group(group)
unless @newsrc.has_key?("file")
@newsrc["file"] = "#{$ENV['HOME']}/.newsrc"
end
save_as(@newsrc["file"], group)
end
# this should be thread safe
def save_group_as(file, group)
if FileTest.exists?("#{file}")
if ( ! File.copy(file, "#{file}.bak") )
print "Can't copy #{file} to #{file}.bak: #{$!}\n"
end
end
begin
newsrc = File.new(file, "r+").flock(File::LOCK_EX)
rescue
print "Can't open ${file}: #{$!}\n"
exit
end
# read file
lines = newsrc.readlines
# pointer -> 0
newsrc.rewind
# write read stuff & replace group
for line in lines
if line =~ /^#{group}(:|!)/
newsrc.print line
else
newsrc.print format(group)
end
end
newsrc.flock(File::LOCK_UN) # what's the right order here?
newsrc.close
end
def format(group) def format(group)
name = group["name"] name = group["name"]
sub = group["subscribed"] ? ':' : '!' sub = group["subscribed"] ? ':' : '!'
@ -383,6 +431,8 @@ end # module
# [x] parse # parses a single line from a newsrc file # [x] parse # parses a single line from a newsrc file
# [x] save # [x] save
# [x] save_as # [x] save_as
# [ ] save_group
# [ ] save_group_as
# [x] format # [x] format
# [x] export_rc # [x] export_rc
# [ ] _dump # Formats a Newsrc object to a string. Used for testing # [ ] _dump # Formats a Newsrc object to a string. Used for testing

View file

@ -1,8 +1,24 @@
#!/usr/local/bin/ruby -w #!/usr/local/bin/ruby -w
# $Dwarf: ripnews.rb,v 1.74 2003/07/03 14:30:00 ward Exp $ # $Dwarf: ripnews.rb,v 1.75 2003/07/13 11:18:09 ward Exp $
# $Source$ # $Source$
#
# Copyright (c) 2002, 2003 Ward Wouts <ward@wouts.nl>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
require 'date' require 'date'
require 'ftools' require 'ftools'
require 'time' require 'time'

View file

@ -1,14 +1,21 @@
################################# # $Dwarf: intspan.rb,v 1.13 2002/11/05 09:33:41 ward Exp $
#
# $Dwarf: intspan.rb,v 1.12 2002/08/19 14:48:00 ward Exp $
# $Source$ # $Source$
# #
# intspan.rb # Copyright (c) 2002, 2003 Ward Wouts <ward@wouts.nl>
# ported from Perl code by Ward Wouts
# #
# (C) 2001, Ward Wouts # Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# #
#################################
module Set module Set