00001 /* 00002 This file is a part of the Dylp LP distribution. 00003 00004 Copyright (C) 2005 -- 2007 Lou Hafer 00005 00006 School of Computing Science 00007 Simon Fraser University 00008 Burnaby, B.C., V5A 1S6, Canada 00009 lou@cs.sfu.ca 00010 00011 This code is licensed under the terms of the Common Public License (CPL). 00012 */ 00013 00014 #ifndef _DY_CMDINT_H 00015 #define _DY_CMDINT_H 00016 00017 /* 00018 @(#)dy_cmdint.h 3.3 06/22/04 00019 svn/cvs: $Id: dy_cmdint.h 148 2007-06-09 03:15:30Z lou $ 00020 00021 Declarations specific to dylp's command interpreter. 00022 */ 00023 00024 #include "dylib_std.h" 00025 #include "dylib_io.h" 00026 #include "dylib_errs.h" 00027 00028 /* 00029 Globals for log stream and echo control, command input stream and echo 00030 control. These must be declared in a main program somewhere. 00031 00032 dy_cmdchn i/o id for command input 00033 dy_cmdecho controls echoing of command input to stdout 00034 00035 dy_logchn i/o id for log file 00036 dy_gtxecho controls echoing of generated text to stdout 00037 00038 dylp.h also contains extern declarations for dy_logchn and dy_gtxecho. Turns out 00039 that the files related to the command interpreter don't need the main dylp 00040 structures, so it's useful to duplicate the extern decl's in both .h files. 00041 */ 00042 00043 extern ioid dy_logchn,dy_cmdchn ; 00044 extern bool dy_gtxecho,dy_cmdecho ; 00045 00046 00047 /* 00048 cmdint.c 00049 */ 00050 00051 /* 00052 Return codes for command execution routines called from the command 00053 interpreter: 00054 00055 cmdOK execution of the command was adequately successful, further 00056 command interpretation should continue. 00057 cmdHALTNOERROR execution of the command was adequately successful, but break 00058 out of the command interpretation loop. 00059 cmdHALTERROR an error occurred during execution of the command, break 00060 out of the command interpretation loop. 00061 00062 As return codes for process_cmds, the interpretation is slightly different: 00063 cmdOK command interpretation was ended by an eof on the top level 00064 command channel (this is the normal case when command execution 00065 completes without error). 00066 cmdHALTNOERROR some command returned a cmdHALTNOERROR return code. 00067 cmdHALTERROR either a command returned a cmdHALTERROR return code, or a 00068 fatal error occurred in process_cmds. 00069 */ 00070 00071 typedef enum { cmdOK, cmdHALTERROR, cmdHALTNOERROR } cmd_retval ; 00072 00073 cmd_retval process_cmds(bool silent) ; 00074 00075 #endif /* _DY_CMDINT_H */