summaryrefslogtreecommitdiffstats
path: root/Mac/Contrib/BBPy/source/BB-stuff/ExternalInterface.h
blob: 51d206dfc29e339b4f4b7ae208032f7c2788423f (plain)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
#pragma once

#include <MixedMode.h>
#include <Dialogs.h>
#include <Files.h>
#include <Windows.h>
#include <AppleEvents.h>
#include <StandardFile.h>

#if defined(powerc) || defined (__powerc)
#pragma options align=mac68k
#endif

typedef struct
{
	FSSpec	spec;	//	designates file on disk
	long	key;	//	reserved for future expansion

	char	tree;	//	0 for absolute, 1 for project, 2 for system
	Boolean	found;	//	FALSE if file couldn't be located; if so, all other info is moot

	OSType	type;	//	file type of found file
	OSType	crtr;	//	signature of found file's creator
	
	short	spare0;	//	reserved for future expansion
	long	spare1;
} ProjectEntry;

enum
{
	kNeitherTree,
	kProjectTree,
	kSystemTree
};

enum
{
	kTHINKCProject,
	kTHINKPascalProject,
	kCodeWarriorProject
};

//	masks for the "flags" argument to new-convention interfaces

#define xfWindowOpen		0x00000001
#define xfWindowChangeable	0x00000002
#define xfHasSelection		0x00000004
#define xfUseDefaults		0x00000008
#define xfIsBBEditLite		0x00000040
#define xfIsBBEditDemo		0x00000080

typedef struct
{
	FSSpec	spec;
	OSType	key;
	
	short	error_kind;
	long	line_number;
	
	Str255	message;
} ErrorEntry;

typedef enum
{
	kNote	= 0,
	kError,
	kWarning
} ErrorKind;

#define kCurrentExternalVersion		5	//	current version of callbacks

//	Universal callback interfaces

#if USESROUTINEDESCRIPTORS

#define ExtensionUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ExternalCallbackBlock *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr))))

#define NewExtensionUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ExternalCallbackBlock *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(AppleEvent *))) \
							| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(AppleEvent *))))

#define GetWindowContentsUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Handle))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))))
							
#define GetSelectionUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long *))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *))))
							
#define SetSelectionUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))))

#define GetDocInfoUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned char *))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short *))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long *))))

#define GetModDateUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))))
							
#define CopyUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Handle))))
							
#define PasteUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Handle))))
							
#define GetLastLineUPPInfo (kPascalStackBased | RESULT_SIZE(SIZE_CODE(sizeof(long))))

#define GetLineNumberUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
							
#define GetLineStartUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
							
#define GetLineEndUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))

#define GetLinePosUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))

#define InsertUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(char *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))))
							
#define DeleteUPPInfo (kPascalStackBased)

#define SetWindowContentsUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle))))
							
#define ContentsChangedUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))))
							
#define GetFileTextUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Handle))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned char *))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Boolean *))))
							
#define GetFolderUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned char *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short *))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *))))
							
#define OpenSeveralUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short *))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(StandardFileReply ***))))
							
#define CenterDialogUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(DialogPtr))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))))
							
#define StandardFilterUPPInfo uppModalFilterProcInfo
							
#define FrameDialogItemUPPInfo uppUserItemProcInfo

#define NewDocumentUPPInfo	(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(WindowPtr))))
							
#define OpenDocumentUPPInfo	(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(WindowPtr))))
							
#define AllocateUPPInfo		(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Handle))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean))))
							
#define FindPatternUPPInfo	(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(char *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(char *))) \
							| STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(Boolean))))

#define ReportOSErrorUPPInfo	(kPascalStackBased)

#define GetPreferenceUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ResType))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void *))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short *))))
							
#define SetPreferenceUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ResType))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void *))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short *))))

#define StartProgressUPPInfo (kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned char *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean))))
							
#define DoProgressUPPInfo	(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))

#define DoneProgressUPPInfo	(kPascalStackBased)

#define GetProjectListUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short *))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short *))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(ProjectEntry***))))
							
#define ProjectTextListUPPInfo (kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle *))))

#define PresetUndoUPPInfo	(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))))
							
#define SetUndoUPPInfo		(kPascalStackBased)

#define OpenFileUPPInfo		(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec *))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr *))))

#define PrepareUndoUPPInfo	(kPascalStackBased \
							| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) \
							| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))))
							
#define CommitUndoUPPInfo	(kPascalStackBased \
							| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))

#define CreateResultsUPPInfo	(kPascalStackBased \
								| RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
								| STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned char *))) \
								| STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
								| STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle))) \
								| STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(WindowPtr *))))
							
typedef	UniversalProcPtr	GetWindowContentsProc;
typedef	UniversalProcPtr	GetSelectionProc;
typedef	UniversalProcPtr	SetSelectionProc;
typedef	UniversalProcPtr	GetDocInfoProc;
typedef	UniversalProcPtr	GetModDateProc;
typedef	UniversalProcPtr	CopyProc;
typedef	UniversalProcPtr	PasteProc;
	
typedef	UniversalProcPtr	GetLastLineProc;
typedef	UniversalProcPtr	GetLineNumberProc;
typedef	UniversalProcPtr	GetLineStartProc;
typedef	UniversalProcPtr	GetLineEndProc;
typedef	UniversalProcPtr	GetLinePosProc;
	
typedef	UniversalProcPtr	InsertProc;
typedef	UniversalProcPtr	DeleteProc;
	
typedef	UniversalProcPtr	SetWindowContentsProc;
typedef	UniversalProcPtr	ContentsChangedProc;
	
typedef	UniversalProcPtr	GetFileTextProc;

typedef	UniversalProcPtr	GetFolderProc;
typedef	UniversalProcPtr	OpenSeveralProc;
	
typedef	UniversalProcPtr	CenterDialogProc;
typedef	UniversalProcPtr	StandardFilterProc;
typedef	UniversalProcPtr	FrameDialogItemProc;
	
typedef	UniversalProcPtr	NewDocumentProc;
typedef	UniversalProcPtr	OpenDocumentProc;

typedef	UniversalProcPtr	AllocateProc;
typedef	UniversalProcPtr	FindPatternProc;
	
typedef	UniversalProcPtr	ReportOSErrorProc;
	
typedef	UniversalProcPtr	GetPreferenceProc;
typedef	UniversalProcPtr	SetPreferenceProc;

typedef	UniversalProcPtr	StartProgressProc;
typedef	UniversalProcPtr	DoProgressProc;
typedef	UniversalProcPtr	DoneProgressProc;
	
typedef	UniversalProcPtr	GetProjectListProc;
typedef	UniversalProcPtr	ProjectTextListProc;
		
typedef	UniversalProcPtr	PresetUndoProc;
typedef	UniversalProcPtr	SetUndoProc;
	
typedef	UniversalProcPtr	OpenFileProc;

typedef UniversalProcPtr	PrepareUndoProc;
typedef UniversalProcPtr	CommitUndoProc;

typedef UniversalProcPtr	CreateResultsProc;

#define CallGetWindowContents(proc, w) \
	(Handle)(CallUniversalProc(proc, GetWindowContentsUPPInfo, (w)))
	
#define CallGetSelection(proc, selStart, selEnd, firstChar) \
	(CallUniversalProc(proc, GetSelectionUPPInfo, (selStart), (selEnd), (firstChar)))
	
#define CallSetSelection(proc, selStart, selEnd, firstChar) \
	(CallUniversalProc(proc, SetSelectionUPPInfo, (selStart), (selEnd), (firstChar)))
	
#define CallGetDocInfo(proc, w, name, vRefNum, dirID) \
	(CallUniversalProc(proc, GetDocInfoUPPInfo, (w), (name), (vRefNum), (dirID)))
	
#define CallGetModDate(proc, w) \
	(CallUniversalProc(proc, GetModDateUPPInfo, (w)))
	
#define CallCopy(proc) \
	(Handle)(CallUniversalProc(proc, CopyUPPInfo))
	
#define CallPaste(proc, h) \
	(CallUniversalProc(proc, PasteUPPInfo, (h)))
	
#define CallGetLastLine(proc) \
	(CallUniversalProc(proc, GetLastLineUPPInfo))
	
#define CallGetLineNumber(proc, sel) \
	(CallUniversalProc(proc, GetLineNumberUPPInfo, (sel)))
	
#define CallGetLineStart(proc, sel) \
	(CallUniversalProc(proc, GetLineStartUPPInfo, (sel)))

#define CallGetLineEnd(proc, sel) \
	(CallUniversalProc(proc, GetLineEndUPPInfo, (sel)))

#define CallGetLinePos(proc, sel) \
	(CallUniversalProc(proc, GetLinePosUPPInfo, (sel)))

#define CallInsert(proc, text, len) \
	(CallUniversalProc(proc, InsertUPPInfo, (text), (len)))
	
#define CallDelete(proc) \
	(CallUniversalProc(proc, DeleteUPPInfo))
	
#define CallSetWindowContents(proc, w, h) \
	(CallUniversalProc(proc, SetWindowContentsUPPInfo, (w), (h)))
	
#define CallContentsChanged(proc, w) \
	(CallUniversalProc(proc, ContentsChangedUPPInfo, (w)))
	
#define CallGetFileText(proc, vRefNum, dirID, name, canDispose) \
	(Handle)(CallUniversalProc(proc, GetFileTextUPPInfo, (vRefNum), (dirID), (name), (canDispose)))
	
#define CallGetFolder(proc, prompt, vRefNum, dirID) \
	(Boolean)(CallUniversalProc(proc, GetFolderUPPInfo, (prompt), (vRefNum), (dirID)))
	
#define CallOpenSeveral(proc, sort, file_count, files) \
	(Boolean)(CallUniversalProc(proc, OpenSeveralUPPInfo, (sort), (file_count), (files)))
	
#define CallCenterDialog(proc, dialogID) \
	(DialogPtr)(CallUniversalProc(proc, CenterDialogUPPInfo, (dialogID)))
	
#define CallStandardFilter(proc, d, event, item) \
	CallModalFilterProc(proc, (d), (event), (item))

#define CallFrameDialogItem(proc, d, item) \
	CallUserItemProc(proc, (d), (item))
	
#define CallNewDocument(proc) \
	(WindowPtr)(CallUniversalProc(proc, NewDocumentUPPInfo))
	
#define CallOpenDocument(proc) \
	(WindowPtr)(CallUniversalProc(proc, OpenDocumentUPPInfo))
	
#define CallAllocate(proc, size, clear) \
	(Handle)(CallUniversalProc(proc, AllocateUPPInfo, (size), (clear)))
	
#define CallFindPattern(proc, text, text_len, text_offset, pat, pat_len, case_sens) \
	(CallUniversalProc(proc, FindPatternUPPInfo, (text), (text_len), (text_offset), \
						(pat), (pat_len), (case_sens)))
						
#define CallReportOSError(proc, code) \
	(CallUniversalProc(proc, ReportOSErrorUPPInfo, (code)))
	
#define CallGetPreference(proc, prefType, req_len, buffer, act_len) \
	(CallUniversalProc(proc, GetPreferenceUPPInfo, (prefType), (req_len), (buffer), (act_len)))
	
#define CallSetPreference(proc, prefType, req_len, buffer, act_len) \
	(CallUniversalProc(proc, SetPreferenceUPPInfo, (prefType), (req_len), (buffer), (act_len)))

#define CallStartProgress(proc, str, total, cancel_allowed) \
	(CallUniversalProc(proc, StartProgressUPPInfo, (str), (total), (cancel_allowed)))
	
#define CallDoProgress(proc, done) \
	(Boolean)(CallUniversalProc(proc, DoProgressUPPInfo, (done)))
	
#define CallDoneProgress(proc) \
	(CallUniversalProc(proc, DoneProgressUPPInfo))
	
#define CallGetProjectList(proc, spec, kind, count, entries) \
	(Boolean)(CallUniversalProc(proc, GetProjectListUPPInfo, (spec), (kind), (count), (entries)))
	
#define CallProjectTextList(proc, spec, text) \
	(Boolean)(CallUniversalProc(proc, ProjectTextListUPPInfo, (spec), (text)))
	
#define CallPresetUndo(proc) \
	(Boolean)(CallUniversalProc(proc, PresetUndoUPPInfo))
	
#define CallSetUndo(proc) \
	(CallUniversalProc(proc, SetUndoUPPInfo))
	
#define CallOpenFile(proc, spec, w) \
	(Boolean)(CallUniversalProc(proc, OpenFileUPPInfo, (spec), (w)))

#define CallPrepareUndo(proc, undo_start, undo_end, sel_start, sel_end) \
	(Boolean)(CallUniversalProc(proc, PrepareUndoUPPInfo, (undo_start), (undo_end), \
								(sel_start), (sel_end)))
								
#define CallCommitUndo(proc, new_end) \
	(CallUniversalProc(proc, CommitUndoUPPInfo, (new_end)))

#define CallCreateResults(proc, title, count, results, w) \
	(Boolean)(CallUniversalProc(proc, CreateResultsUPPInfo, (title), (count), (results), (w)))
	
#else

typedef pascal	Handle	(*GetWindowContentsProc)(WindowPtr w);
typedef	pascal	void	(*GetSelectionProc)(long *selStart, long *selEnd, long *firstChar);
typedef	pascal	void	(*SetSelectionProc)(long selStart, long selEnd, long firstChar);
typedef	pascal	void	(*GetDocInfoProc)(WindowPtr w, Str255 fName, short *vRefNum, long *dirID);
typedef	pascal	long	(*GetModDateProc)(WindowPtr w);
typedef	pascal	Handle	(*CopyProc)(void);
typedef	pascal	void	(*PasteProc)(Handle pasteText);
	
typedef	pascal	long	(*GetLastLineProc)(void);
typedef	pascal	long	(*GetLineNumberProc)(long selection);
typedef	pascal	long	(*GetLineStartProc)(long selection);
typedef	pascal	long	(*GetLineEndProc)(long selection);
typedef	pascal	long	(*GetLinePosProc)(long line);
	
typedef	pascal	void	(*InsertProc)(char *text, long len);
typedef	pascal	void	(*DeleteProc)(void);
	
typedef	pascal	void	(*SetWindowContentsProc)(WindowPtr w, Handle h);
typedef	pascal	void	(*ContentsChangedProc)(WindowPtr w);
	
typedef	pascal	Handle		(*GetFileTextProc)(short vRefNum, long dirID, Str255 fName, Boolean *canDispose);

typedef	pascal	Boolean		(*GetFolderProc)(Str255 prompt, short *vRefNum, long *dirID);
typedef	pascal	Boolean		(*OpenSeveralProc)(Boolean sort, short *file_count, StandardFileReply ***files);
	
typedef	pascal	DialogPtr	(*CenterDialogProc)(short dialogID);
typedef	pascal	Boolean		(*StandardFilterProc)(DialogPtr d, EventRecord *event, short *item);
typedef	pascal	void		(*FrameDialogItemProc)(DialogPtr d, short item);
	
typedef	pascal	WindowPtr	(*NewDocumentProc)(void);
typedef	pascal	WindowPtr	(*OpenDocumentProc)(void);

typedef	pascal	Handle		(*AllocateProc)(long size, Boolean clear);
typedef	pascal	long		(*FindPatternProc)(char *text, long text_len, long text_offset, 
										char *pat, long pat_len,
										Boolean case_sensitive);
	
typedef	pascal	void		(*ReportOSErrorProc)(short code);
	
typedef	pascal	void		(*GetPreferenceProc)(ResType prefType, short req_len, void *buffer, short *act_len);
typedef	pascal	void		(*SetPreferenceProc)(ResType prefType, short req_len, void *buffer, short *act_len);

typedef	pascal	void		(*StartProgressProc)(Str255 str, long total, Boolean cancel_allowed);
typedef	pascal	Boolean		(*DoProgressProc)(long done);
typedef	pascal	void		(*DoneProgressProc)(void);
	
typedef	pascal	Boolean		(*GetProjectListProc)(FSSpec *spec, short *kind, short *count, ProjectEntry ***entries);
typedef	pascal	Boolean		(*ProjectTextListProc)(FSSpec *spec, Handle *text);
		
typedef	pascal	Boolean		(*PresetUndoProc)(void);
typedef	pascal	void		(*SetUndoProc)(void);
	
typedef	pascal	Boolean		(*OpenFileProc)(FSSpec *spec, WindowPtr *w);

typedef pascal	Boolean		(*PrepareUndoProc)(long undo_start, long undo_end,
												long sel_start, long sel_end);
typedef pascal	void		(*CommitUndoProc)(long new_end);

typedef pascal	Boolean		(*CreateResultsProc)(Str255 title, short count, Handle results, WindowPtr *w);

#define CallGetWindowContents(proc, w) \
	((proc))((w))
	
#define CallGetSelection(proc, selStart, selEnd, firstChar) \
	((proc))((selStart), (selEnd), (firstChar))
	
#define CallSetSelection(proc, selStart, selEnd, firstChar) \
	((proc))((selStart), (selEnd), (firstChar))
	
#define CallGetDocInfo(proc, w, name, vRefNum, dirID) \
	((proc))((w), (name), (vRefNum), (dirID))
	
#define CallGetModDate(proc, w) \
	((proc))((w))
	
#define CallCopy(proc) \
	((proc))()
	
#define CallPaste(proc, h) \
	((proc))((h))
	
#define CallGetLastLine(proc) \
	((proc))()
	
#define CallGetLineNumber(proc, sel) \
	((proc))((sel))
	
#define CallGetLineStart(proc, sel) \
	((proc))((sel))
	
#define CallGetLineEnd(proc, sel) \
	((proc))((sel))

#define CallGetLinePos(proc, sel) \
	((proc))((sel))

#define CallInsert(proc, text, len) \
	((proc))((text), (len))
	
#define CallDelete(proc) \
	((proc))()
	
#define CallSetWindowContents(proc, w, h) \
	((proc))((w), (h))
	
#define CallContentsChanged(proc, w) \
	((proc))((w))
	
#define CallGetFileText(proc, vRefNum, dirID, name, canDispose) \
	((proc))((vRefNum), (dirID), (name), (canDispose))
	
#define CallGetFolder(proc, prompt, vRefNum, dirID) \
	((proc))((prompt), (vRefNum), (dirID))
	
#define CallOpenSeveral(proc, sort, file_count, files) \
	((proc))((sort), (file_count), (files))
	
#define CallCenterDialog(proc, dialogID) \
	((proc))((dialogID))
	
#define CallStandardFilter(proc, d, event, item) \
	((proc))((d), (event), (item))

#define CallFrameDialogItem(proc, d, item) \
	((proc))((d), (item))
	
#define CallNewDocument(proc) \
	((proc))()
	
#define CallOpenDocument(proc) \
	((proc))()
	
#define CallAllocate(proc, size, clear) \
	((proc))((size), (clear))
	
#define CallFindPattern(proc, text, text_len, text_offset, pat, pat_len, case_sens) \
	((proc))((text), (text_len), (text_offset), (pat), (pat_len), (case_sens))
						
#define CallReportOSError(proc, code) \
	((proc))((code))
	
#define CallGetPreference(proc, prefType, req_len, buffer, act_len) \
	((proc))((prefType), (req_len), (buffer), (act_len))
	
#define CallSetPreference(proc, prefType, req_len, buffer, act_len) \
	((proc))((prefType), (req_len), (buffer), (act_len))

#define CallStartProgress(proc, str, total, cancel_allowed) \
	((proc))((str), (total), (cancel_allowed))
	
#define CallDoProgress(proc, done) \
	((proc))((done))
	
#define CallDoneProgress(proc) \
	((proc))()
	
#define CallGetProjectList(proc, spec, kind, count, entries) \
	((proc))((spec), (kind), (count), (entries))
	
#define CallProjectTextList(proc, spec, text) \
	((proc))((spec), (text))
	
#define CallPresetUndo(proc) \
	((proc))()
	
#define CallSetUndo(proc) \
	((proc))()
	
#define CallOpenFile(proc, spec, w) \
	((proc))((spec), (w))

#define CallPrepareUndo(proc, undo_start, undo_end, sel_start, sel_end) \
	((proc))((undo_start), (undo_end), (sel_start), (sel_end))
	
#define CallCommitUndo(proc, new_end) \
	((proc))((new_end))

#define CallCreateResults(proc, title, count, results, w) \
	((proc))((title), (count), (results), (w))
	
#endif


typedef struct
{
	short	version;
	
	//	version 1 callbacks
	
	GetWindowContentsProc	GetWindowContents;
	GetSelectionProc	GetSelection;
	SetSelectionProc	SetSelection;
	GetDocInfoProc	GetDocInfo;
	GetModDateProc	GetModDate;
	CopyProc	Copy;
	PasteProc	Paste;
	
	//	version 2 callbacks
	
	/*	Text-Editing stuff */
	GetLastLineProc	GetLastLine;
	GetLineNumberProc	GetLineNumber;
	GetLineStartProc	GetLineStart;
	GetLineEndProc	GetLineEnd;
	GetLinePosProc	GetLinePos;
	
	InsertProc	Insert;
	DeleteProc	Delete;
	
	/*	Getting and Setting window text */
	SetWindowContentsProc	SetWindowContents;
	ContentsChangedProc	ContentsChanged;
	
	/*	Reading file text */
	GetFileTextProc	GetFileText;

	/*	Direct user-interface calls */
	GetFolderProc	GetFolder;
	OpenSeveralProc	OpenSeveral;
	
	CenterDialogProc	CenterDialog;
	StandardFilterProc	StandardFilter;
	FrameDialogItemProc	FrameDialogItem;
	
	NewDocumentProc	NewDocument;
	OpenDocumentProc	OpenDocument;

	/*	Utility Routines */
	AllocateProc	Allocate;
	FindPatternProc	FindPattern;
	
	ReportOSErrorProc	ReportOSError;
	
	/*	Preference routines */
	GetPreferenceProc	GetPreference;
	SetPreferenceProc	SetPreference;

	/*	Progress routines */
	StartProgressProc	StartProgress;
	DoProgressProc	DoProgress;
	DoneProgressProc	DoneProgress;
	
	//	Version 3 callbacks
	GetProjectListProc	GetProjectList;
	ProjectTextListProc	ProjectTextList;
	
	//	version 4 callbacks
	
	PresetUndoProc	PresetUndo;
	SetUndoProc	SetUndo;
	
	OpenFileProc	OpenFile;
	
	//	version 5 callbacks
	
	PrepareUndoProc	PrepareUndo;
	CommitUndoProc	CommitUndo;
	
	CreateResultsProc	CreateResults;
	
} ExternalCallbackBlock;

#if defined(powerc) || defined (__powerc)
#pragma options align=reset
#endif

/*	
	'main' for a BBXT is declared:
	
pascal void main(ExternalCallbackBlock *callbacks, WindowPtr w);		[C]

	The 'new' calling convention, which passes more information
	and allows scriptability, is this:
	
pascal OSErr main(ExternalCallbackBlock *callbacks, WindowPtr w, long flags, AppleEvent *event, AppleEvent *reply);
*/