File: pf_main.c

package info (click to toggle)
pforth 21-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 820 kB
  • ctags: 873
  • sloc: ansic: 5,050; makefile: 102
file content (102 lines) | stat: -rw-r--r-- 2,163 bytes parent folder | download | duplicates (5)
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
/* @(#) pf_main.c 98/01/26 1.2 */
/***************************************************************
** Forth based on 'C'
**
** main() routine that demonstrates how to call PForth as
** a module from 'C' based application.
** Customize this as needed for your application.
**
** Author: Phil Burk
** Copyright 1994 3DO, Phil Burk, Larry Polansky, Devid Rosenboom
**
** The pForth software code is dedicated to the public domain,
** and any third party may reproduce, distribute and modify
** the pForth software code or any derivative works thereof
** without any compensation or license.  The pForth software
** code is provided on an "as is" basis without any warranty
** of any kind, including, without limitation, the implied
** warranties of merchantability and fitness for a particular
** purpose and their equivalents under the laws of any jurisdiction.
**
***************************************************************/

#ifdef PF_NO_STDIO
	#define NULL  ((void *) 0)
	#define ERR(msg) /* { printf msg; } */
#else
	#include <stdio.h>
	#define ERR(msg) { printf msg; }
#endif

#include "pforth.h"
	
#ifdef __MWERKS__
	#include <console.h>
	#include <sioux.h>
#endif

#ifndef TRUE
#define TRUE (1)
#define FALSE (0)
#endif

int main( int argc, char **argv )
{
	const char *DicName = "/usr/lib/pforth/pforth.dic";
	const char *SourceName = NULL;
	char IfInit = FALSE;
	char *s;
	int32 i;
	int Result;

/* For Metroworks on Mac */
	#ifdef __MWERKS__
	argc = ccommand(&argv);
	#endif

/* Parse command line. */
	for( i=1; i<argc; i++ )
	{
		s = argv[i];

		if( *s == '-' )
		{
			char c;
			s++; /* past '-' */
			c = *s++;
			switch(c)
			{
			case 'i':
				IfInit = TRUE;
				DicName = NULL;
				break;
			case 'q':
				pfSetQuiet( TRUE );
				break;
			case 'd':
				DicName = s;
				break;
			default:
				ERR(("Unrecognized option!\n"));
				ERR(("pforth {-i} {-q} {-dfilename.dic} {sourcefilename}\n"));
				Result = 1;
				goto on_error;
				break;
			}
		}
		else
		{
			SourceName = s;
		}
	}
/* Force Init */
#ifdef PF_INIT_MODE
	IfInit = TRUE;
	DicName = NULL;
#endif

	Result = pfDoForth( DicName, SourceName, IfInit);

on_error:
	return Result;
}