#!/usr/bin/perl
# mod_auth_openidc_directives v1.0  (c) 15.3.2014 by Andreas Ley  (u) 9.8.2023
# Extract mod_auth_openidc directives from https://raw.githubusercontent.com/OpenIDC/mod_auth_openidc/master/auth_openidc.conf

use locale;
use Getopt::Std;

sub usage
{
	my $image = $0;
	$image =~ s!.*/!!;
	print STDERR "Usage: $image [-m module] [filename [...]]\n";
	exit(1);
}

getopts('DL:hxvm:') or &usage;

&usage if (defined($opt_h));

$opt_D = $opt_L if (defined($opt_L));
if (defined($opt_v) || defined($opt_D)) {
	$|=1;
	select((select(STDERR),$|=1)[0]);
}

my $module = "\t".$opt_m if (defined($opt_m));

while (<>) {
	chomp;
	print STDERR "\"$_\"\n" if ($opt_D>0);
	if (/^#(OIDC\S+)/) {
		print "$1$module\n";
	}
}
