1 /***************************************************************************
5 copyright : (C) 2005 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
22 #include "search_gui.h"
24 void Engine::output(const char* fmt
, ...)
30 len
= MIN(vsnprintf( buf
, 4096, fmt
, va
), 4096);
33 fwrite(buf
, 1, len
, stdout
);
36 fwrite(buf
, 1, len
, log
);
41 void Engine::process_input()
49 search_gui
->wait_input();
50 argv
= get_tokenized(&argc
);
55 if(!argc
|| strlen(argv
[0])==0)
62 retv
= parse_move(&mv
, argv
[0]);
67 CmdSet::iterator it
= commands
.lower_bound(argv
[0]);
68 if( it
!= commands
.end() &&
69 it
->first
.compare(0, strlen(argv
[0]), argv
[0]) == 0 )
73 if(it
->first
!= argv
[0])
74 output("%s\n", it
->first
.c_str());
77 output("Error, not enough arguments (%d) for command '%s' (try 'help')\n", argc
-1, it
->first
.c_str() );
78 else if(argc
-1 > c
.max())
79 output("Error, too many arguments (%d) for command '%s' (try 'help')\n", argc
-1, it
->first
.c_str() );
81 c
.run(argc
-1, argv
+1);
84 output("Illegal command: '%s' (try 'help')\n", argv
[0]);
86 /* a legal valid move */
97 /* a move that is illegal or ambiguous */