#!/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: GPL-3.0-or-later
// There is NO WARRANTY.
// Generated from:
//   Makefile  esedder    Copyright Ian Jackson
//   pigpio.h             Copyright ...-2022 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
