🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
1 messages
1 total messages Started by Paul Martin Fri, 10 Sep 1999 00:00
dnewgroup: a diablo "newgroup" command
#39748
Author: Paul Martin
Date: Fri, 10 Sep 1999 00:00
110 lines
3294 bytes
After getting sick of doing this by hand, I coded.

#!/usr/bin/perl
# dnewgroup, create new newsgroups in diablo
#  Copyright 1999 Paul Martin <pm@zetnet.net>
# 
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#
#
use Getopt::Std;

# Constants
sub dkp { '/news/dbin/dkp' };
sub dactive { '/news/dactive.kp' };

# Convert string to escaped version
sub encode {
 my $return;
 $_ = shift;

 for (split //) {
  $return .= $_, next if /[a-zA-Z0-9.]/;
  $return .= sprintf("%%%02x",ord($_));
 }
 return $return;
}

# Exclude disallowed characters
sub sanitize {
 my $return;
 $_ = shift;

 for (split //) {
  $return .= $_, next if /[a-zA-Z0-9@+_., -]/;
  $return .= ' ', next if /\t/;
  $return .= '?';
 }
 return $return;
}

### main

my %opts;
getopts('mhud:n:',\%opts);

# It appears not to be good thing to be messing around with dactive.kp
# if you're not running as the news user

if ( ((getpwuid($<))[0] ne 'news') && !$opts{'u'} ) {
 print "Error! You are not running this as user 'news'.\n";
 exit;
}

# Dispense help

if ($opts{'h'} or !$opts{'n'}) {
 print <<EOF;
$0 [-h] [-u] [-d description] [-m] -n newsgroup
	-h help
	-d newsgroup description
	-n newsgroup name
	-m moderated
	-u no userid checks
EOF
 exit;
}

my ($status,$description);
my $tim=sprintf("%08x",time);
my $newsgroup = $opts{'n'};

# Status flag, y=posting allowed, m=moderated
if ($opts{'m'}) {
 $status = 'm';
} else {
 $status = 'y';
}

# Mangle the description field so Diablo likes it
$description = &encode(&sanitize($opts{'d'}));

# Modify the database
system dkp, '-w', dactive, $newsgroup, 'NB=0000000001';
system dkp, '-w', dactive, $newsgroup, 'NE=0000000000';
system dkp, '-w', dactive, $newsgroup, "CTS=$tim";
system dkp, '-w', dactive, $newsgroup, "LMTS=$tim";
system dkp, '-w', dactive, $newsgroup, "S=$status";
system dkp, '-w', dactive, $newsgroup, "GD=$description"
 if $opts{'d'};




-- 
Paul Martin <pm@zetnet.net>
at home, swap dash to dot to email.

Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads