1 /*****************************************************************************
2  *
3  *  Elmer, A Finite Element Software for Multiphysical Problems
4  *
5  *  Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library (in file ../LGPL-2.1); if not, write
19  * to the Free Software Foundation, Inc., 51 Franklin Street,
20  * Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  *****************************************************************************/
23 
24 
25 #include <stdio.h>
26 #include <signal.h>
27 #include <string.h>
28 #include "../config.h"
29 
30 #ifdef USE_READLINE
31 # ifdef HAVE_READLINE_READLINE_H
32 #  include <readline/readline.h>
33 #  include <readline/history.h>
34 # else
35 #  ifdef HAVE_READLINE_H
36 #   include <readline.h>
37 #   include <history.h>
38 #  endif
39 # endif
40 #endif
41 
42 /* prototype */
43 char *mtc_domath(char *);
44 
main(int argc,char ** argv)45 int main( int argc, char **argv )
46 {
47   char strt[2000];
48   char *str;
49   char *ioptr;
50 
51 #ifdef _OPENMP
52   /* Set number of threads to 1, computations are single threaded anyway */
53   omp_set_num_threads(1);
54 #endif
55 
56   (void)mtc_init( stdin, stdout, stderr );
57   str = mtc_domath( "source(\"mc.ini\")" );
58 
59   signal( SIGINT, SIG_IGN );
60 
61   while( 1 )
62   {
63 #ifdef USE_READLINE
64       str = readline ("MATC> ");
65       /* add to history */
66       if (str && *str)
67 	add_history (str);
68 
69 #else
70       ioptr = fgets( strt,  2000 , stdin);
71       str = strt;
72 #endif
73 
74 /* kludge to enable exit. */
75 #if defined(WIN32) || defined(MINGW32)
76       if( stricmp(str,"exit") == 0  || stricmp(str,"quit") == 0 )
77 #else
78       if( strcasecmp(str,"exit") == 0  || strcasecmp(str,"quit") == 0 )
79 #endif
80       {
81 	return 0;
82       }
83       if ( *str ) fprintf( stdout, "%s\n", mtc_domath( str ) );
84 
85 #ifdef USE_READLINE
86       free(str);
87 #endif
88     }
89     return 0;
90 }
91