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 ** Permission to use, copy, modify, and/or distribute this
13 ** software for any purpose with or without fee is hereby granted.
15 ** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
16 ** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
17 ** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
18 ** THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
19 ** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
20 ** FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
21 ** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 ** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 ***************************************************************/
26 #if (defined(PF_NO_STDIO) || defined(PF_EMBEDDED))
27 #define NULL ((void *) 0)
28 #define ERR(msg) /* { printf msg; } */
31 #define ERR(msg) { printf msg; }
36 #ifndef PF_DEFAULT_DICTIONARY
37 #define PF_DEFAULT_DICTIONARY "pforth.dic"
54 const char *DicName = NULL;
55 const char *SourceName = NULL;
56 pfMessage("\npForth Embedded\n");
57 return pfDoForth( DicName, SourceName, IfInit);
61 int main( int argc, char **argv )
64 const char *DicName = NULL;
65 #else /* PF_STATIC_DIC */
66 const char *DicName = PF_DEFAULT_DICTIONARY;
67 #endif /* !PF_STATIC_DIC */
69 const char *SourceName = NULL;
75 /* For Metroworks on Mac */
77 argc = ccommand(&argv);
81 /* Parse command line. */
82 for( i=1; i<argc; i++ )
103 if( *s != '\0' ) DicName = s;
104 /* Allow space after -d (Thanks Aleksej Saushev) */
105 /* Make sure there is another argument. */
106 else if( (i+1) < argc )
110 if (DicName == NULL || *DicName == '\0')
112 DicName = PF_DEFAULT_DICTIONARY;
117 ERR(("Unrecognized option!\n"));
118 ERR(("pforth {-i} {-q} {-dfilename.dic} {sourcefilename}\n"));
136 if( (Result = pfUnitTest()) != 0 )
138 ERR(("pForth stopping on unit test failure.\n"));
143 Result = pfDoForth( DicName, SourceName, IfInit);
149 #endif /* PF_EMBEDDED */