1 /* @(#) pf_main.c 98/01/26 1.2 */
2 /***************************************************************
5 ** main() routine that demonstrates how to call PForth as
6 ** a module from 'C' based application.
7 ** Customize this as needed for your application.
10 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
12 ** The pForth software code is dedicated to the public domain,
13 ** and any third party may reproduce, distribute and modify
14 ** the pForth software code or any derivative works thereof
15 ** without any compensation or license. The pForth software
16 ** code is provided on an "as is" basis without any warranty
17 ** of any kind, including, without limitation, the implied
18 ** warranties of merchantability and fitness for a particular
19 ** purpose and their equivalents under the laws of any jurisdiction.
21 ***************************************************************/
23 #if (defined(PF_NO_STDIO) || defined(PF_EMBEDDED))
24 #define NULL ((void *) 0)
25 #define ERR(msg) /* { printf msg; } */
28 #define ERR(msg) { printf msg; }
33 #ifndef PF_DEFAULT_DICTIONARY
34 #define PF_DEFAULT_DICTIONARY "pforth.dic"
51 const char *DicName = NULL;
52 const char *SourceName = NULL;
53 pfMessage("\npForth Embedded\n");
54 return pfDoForth( DicName, SourceName, IfInit);
58 int main( int argc, char **argv )
61 const char *DicName = NULL;
62 #else /* PF_STATIC_DIC */
63 const char *DicName = PF_DEFAULT_DICTIONARY;
64 #endif /* !PF_STATIC_DIC */
66 const char *SourceName = NULL;
72 /* For Metroworks on Mac */
74 argc = ccommand(&argv);
78 /* Parse command line. */
79 for( i=1; i<argc; i++ )
100 if( *s != '\0' ) DicName = s;
101 /* Allow space after -d (Thanks Aleksej Saushev) */
102 /* Make sure there is another argument. */
103 else if( (i+1) < argc )
107 if (DicName == NULL || *DicName == '\0')
109 DicName = PF_DEFAULT_DICTIONARY;
114 ERR(("Unrecognized option!\n"));
115 ERR(("pforth {-i} {-q} {-dfilename.dic} {sourcefilename}\n"));
133 if( (Result = pfUnitTest()) != 0 )
135 ERR(("pForth stopping on unit test failure.\n"));
140 Result = pfDoForth( DicName, SourceName, IfInit);
146 #endif /* PF_EMBEDDED */