#!/usr/bin/perl

%keys =
    (
     "s" => "RESP_STR",
     "d" => "RESP_DSC",
     "i" => "RESP_INT",
     "f" => "RESP_FLOAT"
     );

print("
/* Do not modify this file - it is autogenerated by makecmds */

static void initcmds(void)
{
    struct command *cmd;
    
");

while(<>)
{
    ($comment) = /\s*;\s*(.*)$/;
    s/\s*;.*$//;
    if(($name) = /^:(\w*)/)
    {
	if($name)
	{
	    print("    cmd = makecmd(L\"$name\");");
	} else {
	    print("    cmd = makecmd(NULL);");
	}
	if($comment)
	{
	    print("\t/* $comment */");
	}
	print("\n");
    } elsif(/^([0-9]{3})\s+/g) {
	print("    addresp(cmd, $1");
	print(", " . $keys{$1}) while /\G(\S+)\s+/g;
	print(", RESP_END);");
	if($comment)
	{
	    print("\t/* $comment */");
	}
	print("\n");
    }
}

print("}\n");
