750b43d854fc04de0ee9a2f45bea0d3990715651
[doldaconnect.git] / lib / makecmds
1 #!/usr/bin/perl
2
3 %keys =
4     (
5      "s" => "RESP_STR",
6      "d" => "RESP_DSC",
7      "i" => "RESP_INT",
8      "f" => "RESP_FLOAT"
9      );
10
11 print("
12 /* Do not modify this file - it is autogenerated by makecmds */
13
14 static void initcmds(void)
15 {
16     struct command *cmd;
17     
18 ");
19
20 while(<>)
21 {
22     ($comment) = /\s*;\s*(.*)$/;
23     s/\s*;.*$//;
24     if(($name) = /^:(\w*)/)
25     {
26         if($name)
27         {
28             print("    cmd = makecmd(L\"$name\");");
29         } else {
30             print("    cmd = makecmd(NULL);");
31         }
32         if($comment)
33         {
34             print("\t/* $comment */");
35         }
36         print("\n");
37     } elsif(/^([0-9]{3})\s+/g) {
38         print("    addresp(cmd, $1");
39         print(", " . $keys{$1}) while /\G(\S+)\s+/g;
40         print(", RESP_END);");
41         if($comment)
42         {
43             print("\t/* $comment */");
44         }
45         print("\n");
46     }
47 }
48
49 print("}\n");