1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
// -*- Mode: c++ -*-
//
// SUMMARY:
// USAGE:
//
// ORG: Christophe Prud'homme
// AUTHOR: Christophe Prud'homme
// E-MAIL: Christophe.Prudhomme@ann.jussieu.fr
//
// DESCRIPTION:
//
// < description of the code here>
//
// DESCRIP-END.
//
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
// c++ include
#include <new>
#include <iostream>
// libfem
#include <femParser.hpp>
#ifdef HPPA
#ifndef __GNUC__
typedef char *caddr_t;
#endif
#endif
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
/*
* this is for HP workstations
* this allow to avoid including setjmp.h
*
* SEE THE FUNCTION ERREUR (INT)
*/
#if ( defined (__hp9000s700) )
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
# define _JBLEN 50
typedef double jmp_buf[_JBLEN/2];
extern void longjmp (jmp_buf,int);
extern int setjmp (jmp_buf);
# ifdef __cplusplus
}
# endif /* __cplusplus */
#else /* not __hp9000s700 */
# include <setjmp.h>
#endif /* defined (__hp9000s700) */
#define reel float
typedef enum {
NO_MESSAGE=-2,
STOP = -1,
ERROR = 0,
MESH = 1,
FUNCTION = 2
} compil_msg;
extern compil_msg cmsg;
void
out_of_memory ()
{
std::cerr << "FreeFEM error: operator new failed; not enough memory" << std::endl;
#if defined(XGFEM)
SlaveDeconnect ();
#endif /* XGFEM */
exit (-1);
}
void
NEW_HANDLER (void)
{
std::set_new_handler (&out_of_memory);
}
int getprog(char* fn,int argc, char **argv)
{
if (argc != 2) return 0;
strcpy(fn,argv[1]);
printf(" file : %s\n",fn);
return argc;
}
char *
readprog (char *path)
{
long count;
int l = 1;
FILE *f;
char *tmp = NULL;
if ((f = fopen (path, "r")) == NULL)
{
fprintf (stderr, "Freefem::readprog error : Cannot read %s\n", path);
exit(-1);
}
count = 0;
while (!feof (f))
{
fgetc (f);
count++;
}
rewind (f);
tmp = new char[count + 255];
memset(tmp, 0, (count + 255)*sizeof(char));
tmp[0] = '{'; /* place program between braces */
while (!feof (f))
{
fgets (tmp + l, 255, f);
/*fputs (tmp + l, stdout);*/
l = strlen (tmp);
}
tmp[l] = '}';
l++;
fclose (f);
return tmp;
}
int
main (int argc, char **argv)
{
#if 1
char *fname;
NEW_HANDLER (); // see dependent system files ({pc,x,mac}rgraph.{h,cpp})
fname = new char[256];
argc = getprog (fname, argc, argv);
if (argc == 2)
{
char* __prog = readprog (fname);
delete [] fname;
fem::femParser* parser = fem::femParser::New();
parser->setText( __prog );
parser->parse();
delete parser;
}
else
{
std::cerr << "Usage:\n"
<< " freefem filename.pde\n";
}
#endif
}
|