#!/usr/bin/perl

@f= qw(
       OK
       MovFeatTooLate
       MovFeatKindsCombination
       MovFeatReservationInapplicable
       MovFeatRouteNotFound
       BufferFull
       BadCmd
       InvalidState
       SignallingPredictedProblem
       SignallingHorizonReached
       CommandPreconditionsViolated

       LimitExceeded
       SystemFailed
       UnknownCommand
       PermissionDenied
       HostSupportSystemsProblem
       );


    
$decl= "const char *const errorcodelist[]";

print <<END
typedef enum {
END
    ."  ".(join ",\n  ", map {
	$f=$_; $f =~ s/\-//g; "EC_$f";
    } @f).<<END

} ErrorCode;

extern $decl;

#define ec2str(ec) (errorcodelist[(ec)])

#define DEFINE_ERRORCODELIST_DATA \\
$decl= { \\
END
    ."  ".(join ", \\\n  ", map {
	'"'.$_.'"';
    } @f).<<END
 \\
};
END
    or die $!;
