#!/usr/bin/perl -wn
use strict;

BEGIN {
    print <<END or die $!;
// DO NOT EDIT - this file is autogenerated
//
// Regenerate by copying new pigpio.h and running `make` here
//
// SPDX-License-Identifier: AGPL-3.0-or-later
// There is NO WARRANTY.
// Generated from:
//   Makefile  esedder    Copyright 2020 Ian Jackson
//   pigpio.h             Copyright ...-2020 pigpio contributors
// The "Do not edit" statement above is advice, not a legal restriction!

//! pigpiod error codes, as values of type `PigpiodError`.

use crate::PigpiodError;
use crate::constants::*;
END
}

next unless m{^/\*DEF_S Error Codes\*/} .. m{^/\*DEF_E\*/};
next unless m/^pub const PI_(\w+) : i32/;
print <<END or die $!;
pub const ERR_PI_$1 : PigpiodError = PigpiodError(PI_$1);
END
