Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/matc/src/main.c
3196 views
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
void mtc_init( FILE *, FILE *, FILE *);
45
46
int main( int argc, char **argv )
47
{
48
char strt[2000];
49
char *str;
50
char *ioptr;
51
52
53
54
(void)mtc_init( stdin, stdout, stderr );
55
str = mtc_domath( "source(\"mc.ini\")" );
56
57
signal( SIGINT, SIG_IGN );
58
59
while( 1 )
60
{
61
#ifdef USE_READLINE
62
str = readline ("MATC> ");
63
/* add to history */
64
if (str && *str)
65
add_history (str);
66
67
#else
68
ioptr = fgets( strt, 2000 , stdin);
69
str = strt;
70
#endif
71
72
/* kludge to enable exit. */
73
#if defined(WIN32) || defined(MINGW32)
74
if( stricmp(str,"exit") == 0 || stricmp(str,"quit") == 0 ||
75
stricmp(str,"exit\n") == 0 || stricmp(str,"quit\n") == 0 )
76
#else
77
if( strcasecmp(str,"exit") == 0 || strcasecmp(str,"quit") == 0 ||
78
strcasecmp(str,"exit\n") == 0 || strcasecmp(str,"quit\n") == 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
92