head	1.2;
access;
symbols
	perseant-exfatfs-base-20250801:1.2
	perseant-exfatfs-base-20240630:1.2
	perseant-exfatfs:1.2.0.6
	perseant-exfatfs-base:1.2
	netbsd-8-3-RELEASE:1.1.1.2
	cjep_sun2x:1.2.0.4
	cjep_sun2x-base:1.2
	cjep_staticlib_x-base1:1.2
	cjep_staticlib_x:1.2.0.2
	cjep_staticlib_x-base:1.2
	phil-wifi-20200421:1.2
	phil-wifi-20200411:1.2
	phil-wifi-20200406:1.2
	netbsd-8-2-RELEASE:1.1.1.2
	netbsd-8-1-RELEASE:1.1.1.2
	netbsd-8-1-RC1:1.1.1.2
	pgoyette-compat-merge-20190127:1.1.1.2.32.1
	pgoyette-compat-20190127:1.2
	pgoyette-compat-20190118:1.2
	pgoyette-compat-1226:1.2
	pgoyette-compat-1126:1.2
	pgoyette-compat-1020:1.2
	pgoyette-compat-0930:1.2
	pgoyette-compat-0906:1.2
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.2
	netbsd-8-0-RELEASE:1.1.1.2
	pgoyette-compat-0625:1.2
	netbsd-8-0-RC2:1.1.1.2
	pgoyette-compat-0521:1.2
	pgoyette-compat-0502:1.2
	pgoyette-compat-0422:1.2
	netbsd-8-0-RC1:1.1.1.2
	pgoyette-compat-0415:1.2
	DHCP4_4_1:1.1.1.2
	pgoyette-compat-0407:1.1.1.2
	pgoyette-compat-0330:1.1.1.2
	pgoyette-compat-0322:1.1.1.2
	pgoyette-compat-0315:1.1.1.2
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.2.0.32
	pgoyette-compat-base:1.1.1.2
	netbsd-7-1-1-RELEASE:1.1.1.2
	matt-nb8-mediatek:1.1.1.2.0.30
	matt-nb8-mediatek-base:1.1.1.2
	perseant-stdc-iso10646:1.1.1.2.0.28
	perseant-stdc-iso10646-base:1.1.1.2
	netbsd-8:1.1.1.2.0.26
	netbsd-8-base:1.1.1.2
	prg-localcount2-base3:1.1.1.2
	prg-localcount2-base2:1.1.1.2
	prg-localcount2-base1:1.1.1.2
	prg-localcount2:1.1.1.2.0.24
	prg-localcount2-base:1.1.1.2
	pgoyette-localcount-20170426:1.1.1.2
	bouyer-socketcan-base1:1.1.1.2
	pgoyette-localcount-20170320:1.1.1.2
	netbsd-7-1:1.1.1.2.0.22
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.2.0.20
	bouyer-socketcan-base:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.2.0.18
	netbsd-7-nhusb-base:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.16
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.2
	DHCP4_3_3:1.1.1.2
	netbsd-7-0:1.1.1.2.0.14
	netbsd-7-0-RELEASE:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	netbsd-7:1.1.1.2.0.12
	netbsd-7-base:1.1.1.2
	DHCP4_3_0:1.1.1.2
	yamt-pagecache:1.1.1.2.0.10
	yamt-pagecache-base9:1.1.1.2
	tls-earlyentropy:1.1.1.2.0.8
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.2
	riastradh-drm2-base3:1.1.1.2
	riastradh-drm2-base2:1.1.1.2
	riastradh-drm2-base1:1.1.1.2
	riastradh-drm2:1.1.1.2.0.6
	riastradh-drm2-base:1.1.1.2
	tls-maxphys-base:1.1.1.2
	tls-maxphys:1.1.1.2.0.4
	khorben-n900:1.1.1.2.0.2
	DHCP4_2_5_P1:1.1.1.2
	DHCP4_2_5:1.1.1.2
	DHCP4_2_3:1.1.1.1
	ISC:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2018.04.07.22.39.56;	author christos;	state dead;
branches;
next	1.1;
commitid	GG8y5M7UQEDETyxA;

1.1
date	2013.03.24.15.45.47;	author christos;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2013.03.24.15.45.47;	author christos;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2013.03.24.22.50.33;	author christos;	state Exp;
branches
	1.1.1.2.4.1
	1.1.1.2.10.1
	1.1.1.2.32.1;
next	;

1.1.1.2.4.1
date	2013.03.24.22.50.33;	author tls;	state dead;
branches;
next	1.1.1.2.4.2;
commitid	OnlO1cBgtQRcIHUw;

1.1.1.2.4.2
date	2013.06.23.06.26.28;	author tls;	state Exp;
branches;
next	;
commitid	OnlO1cBgtQRcIHUw;

1.1.1.2.10.1
date	2013.03.24.22.50.33;	author yamt;	state dead;
branches;
next	1.1.1.2.10.2;
commitid	71DOv9lBdoc77yBx;

1.1.1.2.10.2
date	2014.05.22.15.44.32;	author yamt;	state Exp;
branches;
next	;
commitid	71DOv9lBdoc77yBx;

1.1.1.2.32.1
date	2018.04.16.01.58.08;	author pgoyette;	state dead;
branches;
next	;
commitid	qk3nktk0szmTIByA;


desc
@@


1.2
log
@moved dhcp to mpl
@
text
@#!/usr/bin/perl
#
# Start Date:   Mon, 26 Mar 2001 14:24:09 +0200
# Time-stamp:   <Monday, 26 March 2001 16:09:44 by brister>
# File:         leaseconvertor.pl
# RCSId:        Id: 3.0b1-lease-convert,v 1.1 2001-04-18 19:17:34 mellon Exp 
#
# Description:  Convert 3.0b1 to 3.0b2/final lease file format
#

require 5.004;

my $rcsID =<<'EOM';
Id: 3.0b1-lease-convert,v 1.1 2001-04-18 19:17:34 mellon Exp 
EOM

use strict;

my $revstatement =<<'EOS';
	  switch (ns-update (delete (1, 12, ddns-rev-name, null))) {
	    case 0:
	      unset ddns-rev-name;
	      break;
	  }
EOS

my $fwdstatement =<<'EOS';
	  switch (ns-update (delete (1, 1, ddns-fwd-name, leased-address))) {
	    case 0:
	      unset ddns-fwd-name;
	      break;
	  }
EOS


if (@@ARGV && $ARGV[0] =~ m!^-!) {
    usage();
}



# read stdin and write stdout.
while (<>) {
    if (! /^lease\s/) {
	print;
    } else {
	my $lease = $_;
	while (<>) {
	    $lease .= $_;
	    # in a b1 file we should only see a left curly brace on a lease
	    # lines. Seening it anywhere else means the user is probably
	    # running a b2 or later file through this.
	    # Ditto for a 'set' statement.
	    if (m!\{! || m!^\s*set\s!) {
		warn "this doesn't look like a 3.0b1 file. Ignoring rest.\n";
		print $lease;
		dumpRestAndExit();
	    }

	    last if m!^\}\s*$!;
	}

	# $lease contains all the lines for the lease entry.
	$lease = makeNewLease($lease);
	print $lease;
    }
}



sub usage {
    my $prog = $0;
    $prog =~ s!.*/!!;

    print STDERR <<EOM;
usage: $prog [ file ]

Reads from the lease file listed on the command line (or stdin if not filename
given) and writes to stdout.  Converts a 3.0b1-style leases file to a 3.0b2
style (for ad-hoc ddns updates).
EOM

    exit (0);
}



# takes a string that's the lines of a lease entry and converts it, if
# necessary to a b2 style lease entry. Returns the new lease in printable form.
sub makeNewLease {
    my ($lease) = @@_;

    my $convertedfwd;
    my $convertedrev;
    my $newlease = "";
    foreach (split "\n", $lease) {
	if (m!^(\s+)(ddns-fwd-name|ddns-rev-name)\s+(\"[^\"]+\"\s*;)!) {
	    $newlease .= $1 . "set " . $2 . " = " . $3 . "\n";

	    # If there's one of them, then it will always be the -fwd-. There
	    # may not always be a -rev-.
	    $convertedfwd++;
	    $convertedrev++ if ($2 eq "ddns-rev-name");
	} elsif (m!^\s*\}!) {
	    if ($convertedfwd) {
		$newlease .= "\ton expiry or release {\n";
		$newlease .= $revstatement if $convertedrev;
		$newlease .= $fwdstatement;
		$newlease .= "\t  on expiry or release;\n\t}\n";
	    }
	    $newlease .= "}\n";
	} else {
	    $newlease .= $_ . "\n";
	}
    }

    return $newlease;
}


sub dumpRestAndExit {
    while (<>) {
	print;
    }
    exit (0);
}
@


1.1
log
@Initial revision
@
text
@@


1.1.1.1
log
@from ftp.isc.org
@
text
@@


1.1.1.2
log
@updat to 4.2.5
@
text
@d6 1
a6 1
# RCSId:        Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp 
d14 1
a14 1
Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp 
@


1.1.1.2.32.1
log
@Sync with HEAD, resolve some conflicts
@
text
@@


1.1.1.2.10.1
log
@file 3.0b1-lease-convert was added on branch yamt-pagecache on 2014-05-22 15:44:32 +0000
@
text
@d1 126
@


1.1.1.2.10.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 126
#!/usr/bin/perl
#
# Start Date:   Mon, 26 Mar 2001 14:24:09 +0200
# Time-stamp:   <Monday, 26 March 2001 16:09:44 by brister>
# File:         leaseconvertor.pl
# RCSId:        Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp 
#
# Description:  Convert 3.0b1 to 3.0b2/final lease file format
#

require 5.004;

my $rcsID =<<'EOM';
Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp 
EOM

use strict;

my $revstatement =<<'EOS';
	  switch (ns-update (delete (1, 12, ddns-rev-name, null))) {
	    case 0:
	      unset ddns-rev-name;
	      break;
	  }
EOS

my $fwdstatement =<<'EOS';
	  switch (ns-update (delete (1, 1, ddns-fwd-name, leased-address))) {
	    case 0:
	      unset ddns-fwd-name;
	      break;
	  }
EOS


if (@@ARGV && $ARGV[0] =~ m!^-!) {
    usage();
}



# read stdin and write stdout.
while (<>) {
    if (! /^lease\s/) {
	print;
    } else {
	my $lease = $_;
	while (<>) {
	    $lease .= $_;
	    # in a b1 file we should only see a left curly brace on a lease
	    # lines. Seening it anywhere else means the user is probably
	    # running a b2 or later file through this.
	    # Ditto for a 'set' statement.
	    if (m!\{! || m!^\s*set\s!) {
		warn "this doesn't look like a 3.0b1 file. Ignoring rest.\n";
		print $lease;
		dumpRestAndExit();
	    }

	    last if m!^\}\s*$!;
	}

	# $lease contains all the lines for the lease entry.
	$lease = makeNewLease($lease);
	print $lease;
    }
}



sub usage {
    my $prog = $0;
    $prog =~ s!.*/!!;

    print STDERR <<EOM;
usage: $prog [ file ]

Reads from the lease file listed on the command line (or stdin if not filename
given) and writes to stdout.  Converts a 3.0b1-style leases file to a 3.0b2
style (for ad-hoc ddns updates).
EOM

    exit (0);
}



# takes a string that's the lines of a lease entry and converts it, if
# necessary to a b2 style lease entry. Returns the new lease in printable form.
sub makeNewLease {
    my ($lease) = @@_;

    my $convertedfwd;
    my $convertedrev;
    my $newlease = "";
    foreach (split "\n", $lease) {
	if (m!^(\s+)(ddns-fwd-name|ddns-rev-name)\s+(\"[^\"]+\"\s*;)!) {
	    $newlease .= $1 . "set " . $2 . " = " . $3 . "\n";

	    # If there's one of them, then it will always be the -fwd-. There
	    # may not always be a -rev-.
	    $convertedfwd++;
	    $convertedrev++ if ($2 eq "ddns-rev-name");
	} elsif (m!^\s*\}!) {
	    if ($convertedfwd) {
		$newlease .= "\ton expiry or release {\n";
		$newlease .= $revstatement if $convertedrev;
		$newlease .= $fwdstatement;
		$newlease .= "\t  on expiry or release;\n\t}\n";
	    }
	    $newlease .= "}\n";
	} else {
	    $newlease .= $_ . "\n";
	}
    }

    return $newlease;
}


sub dumpRestAndExit {
    while (<>) {
	print;
    }
    exit (0);
}
@


1.1.1.2.4.1
log
@file 3.0b1-lease-convert was added on branch tls-maxphys on 2013-06-23 06:26:28 +0000
@
text
@d1 126
@


1.1.1.2.4.2
log
@resync from head
@
text
@a0 126
#!/usr/bin/perl
#
# Start Date:   Mon, 26 Mar 2001 14:24:09 +0200
# Time-stamp:   <Monday, 26 March 2001 16:09:44 by brister>
# File:         leaseconvertor.pl
# RCSId:        Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp 
#
# Description:  Convert 3.0b1 to 3.0b2/final lease file format
#

require 5.004;

my $rcsID =<<'EOM';
Id: 3.0b1-lease-convert,v 1.1 2001/04/18 19:17:34 mellon Exp 
EOM

use strict;

my $revstatement =<<'EOS';
	  switch (ns-update (delete (1, 12, ddns-rev-name, null))) {
	    case 0:
	      unset ddns-rev-name;
	      break;
	  }
EOS

my $fwdstatement =<<'EOS';
	  switch (ns-update (delete (1, 1, ddns-fwd-name, leased-address))) {
	    case 0:
	      unset ddns-fwd-name;
	      break;
	  }
EOS


if (@@ARGV && $ARGV[0] =~ m!^-!) {
    usage();
}



# read stdin and write stdout.
while (<>) {
    if (! /^lease\s/) {
	print;
    } else {
	my $lease = $_;
	while (<>) {
	    $lease .= $_;
	    # in a b1 file we should only see a left curly brace on a lease
	    # lines. Seening it anywhere else means the user is probably
	    # running a b2 or later file through this.
	    # Ditto for a 'set' statement.
	    if (m!\{! || m!^\s*set\s!) {
		warn "this doesn't look like a 3.0b1 file. Ignoring rest.\n";
		print $lease;
		dumpRestAndExit();
	    }

	    last if m!^\}\s*$!;
	}

	# $lease contains all the lines for the lease entry.
	$lease = makeNewLease($lease);
	print $lease;
    }
}



sub usage {
    my $prog = $0;
    $prog =~ s!.*/!!;

    print STDERR <<EOM;
usage: $prog [ file ]

Reads from the lease file listed on the command line (or stdin if not filename
given) and writes to stdout.  Converts a 3.0b1-style leases file to a 3.0b2
style (for ad-hoc ddns updates).
EOM

    exit (0);
}



# takes a string that's the lines of a lease entry and converts it, if
# necessary to a b2 style lease entry. Returns the new lease in printable form.
sub makeNewLease {
    my ($lease) = @@_;

    my $convertedfwd;
    my $convertedrev;
    my $newlease = "";
    foreach (split "\n", $lease) {
	if (m!^(\s+)(ddns-fwd-name|ddns-rev-name)\s+(\"[^\"]+\"\s*;)!) {
	    $newlease .= $1 . "set " . $2 . " = " . $3 . "\n";

	    # If there's one of them, then it will always be the -fwd-. There
	    # may not always be a -rev-.
	    $convertedfwd++;
	    $convertedrev++ if ($2 eq "ddns-rev-name");
	} elsif (m!^\s*\}!) {
	    if ($convertedfwd) {
		$newlease .= "\ton expiry or release {\n";
		$newlease .= $revstatement if $convertedrev;
		$newlease .= $fwdstatement;
		$newlease .= "\t  on expiry or release;\n\t}\n";
	    }
	    $newlease .= "}\n";
	} else {
	    $newlease .= $_ . "\n";
	}
    }

    return $newlease;
}


sub dumpRestAndExit {
    while (<>) {
	print;
    }
    exit (0);
}
@


