gonzui


Format: Advanced Search

t2ex/t2ex_source/kernel/sysmain/src/appl_main.cbare sourcepermlink (0.05 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T2EX Software Package
    4:  *
    5:  *    Copyright 2012 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2012/12/12.
   10:  *    Modified by T-Engine Forum at 2014/07/28.
   11:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/04.
   12:  *
   13:  *----------------------------------------------------------------------
   14:  */
   15: /*
   16:  * This software package is available for use, modification, 
   17:  * and redistribution in accordance with the terms of the attached 
   18:  * T-License 2.x.
   19:  * If you want to redistribute the source code, you need to attach 
   20:  * the T-License 2.x document.
   21:  * There's no obligation to publish the content, and no obligation 
   22:  * to disclose it to the TRON Forum if you have modified the 
   23:  * software package.
   24:  * You can also distribute the modified source code. In this case, 
   25:  * please register the modification to T-Kernel traceability service.
   26:  * People can know the history of modifications by the service, 
   27:  * and can be sure that the version you have inherited some 
   28:  * modification of a particular version or not.
   29:  *
   30:  *    http://trace.tron.org/tk/?lang=en
   31:  *    http://trace.tron.org/tk/?lang=ja
   32:  *
   33:  * As per the provisions of the T-License 2.x, TRON Forum ensures that 
   34:  * the portion of the software that is copyrighted by Ken Sakamura or 
   35:  * the TRON Forum does not infringe the copyrights of a third party.
   36:  * However, it does not make any warranty other than this.
   37:  * DISCLAIMER: TRON Forum and Ken Sakamura shall not be held
   38:  * responsible for any consequences or damages caused directly or
   39:  * indirectly by the use of this software package.
   40:  *
   41:  * The source codes in bsd_source.tar.gz in this software package are 
   42:  * derived from NetBSD or OpenBSD and not covered under T-License 2.x.
   43:  * They need to be changed or redistributed according to the 
   44:  * representation of each source header.
   45:  */
   46: 
   47: /*
   48:  *      @(#)appl_main.c
   49:  *
   50:  */
   51: #include <basic.h>
   52: #include <stdlib.h>
   53: #include <stdio.h>
   54: #include <string.h>
   55: #include <tk/tkernel.h>
   56: #include <tm/tmonitor.h>
   57: 
   58: #ifdef  USE_T2EX_FS
   59: #define P                       printf
   60: #define Gets(buf, bufsz)        fgets(buf, bufsz, stdin)
   61: #else
   62: #define P                       tm_printf
   63: #define Gets(buf, bufsz)        tm_getline(buf)
   64: #endif
   65: 
   66: /* Command functions */
   67: IMPORT  INT      exec_cmd(B *cmd);
   68: IMPORT  void     init_calendar_date(void);
   69: 
   70: /*
   71:  *      Application main entry
   72:  */
   73: EXPORT  void     appl_main( void )
   74: {
   75:         B      buf[256];
   76:         INT    fin, n;
   77: 
   78:         /* initialize calendar date */
   79:         init_calendar_date();
   80: 
   81:         /* command processing */
   82:         for (fin = 0; fin == 0; ) {
   83:                 P("T2EX >> ");
   84:                 Gets(buf, sizeof(buf));
   85:                 for (n = strlen(buf); --n >= 0 && buf[n] <= ' '; ) 
   86:                         buf[n] = '\0';
   87: 
   88:                 if (strncmp(buf, "quit", 1) == 0) {
   89:                         fin = 1;
   90: 
   91:                 /* t-monitor */
   92:                 } else if (strncmp(buf, "#", 1) == 0) {
   93:                         tm_command(&buf[1]);
   94: 
   95:                 /* misc. command */
   96:                 } else {
   97:                         if (exec_cmd(buf) == 0) {
   98:                                 P("q[uit]      quit\n");
   99:                                 P("# [cmd]     exec t-monitor command\n");
  100:                                 P("?           command help\n");
  101:                                 P("<command>   misc. command\n");
  102:                         }
  103:                 }
  104:         }
  105: }
  106: