summaryrefslogtreecommitdiffstats
path: root/mac/tkMacProlog.c
blob: 21cf67c5551f01e3a643c39ef60c30b0b7fad686 (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
/* 
 * tkMacProlog.c --
 *
 *	Implements a method on the Macintosh to get the prolog
 *	from the resource fork of our application (or the shared
 *	library).
 *
 * Copyright (c) 1996-1997 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * SCCS: @(#) tkMacProlog.c 1.6 97/05/21 10:01:07
 */

#include "tkInt.h"
#include "tclMacInt.h"
#include <Resources.h>

/*
 *--------------------------------------------------------------
 *
 * TkGetNativeProlog --
 *
 *	Locate and load the postscript prolog from the resource
 *	fork of the application.  If it can't be found then we
 *	will try looking for the file in the system folder.
 *
 * Results:
 *	A standard Tcl Result.  If everything is OK the prolog
 *	will be located in the result string of the interpreter.
 *
 * Side effects:
 *	None.
 *
 *--------------------------------------------------------------
 */

int
TkGetNativeProlog(
    Tcl_Interp *interp)		/* Places the prolog in the result. */
{
    Handle resource;
    char *stringPtr;
    int releaseIt;
    

    resource = Tcl_MacFindResource(interp, 'TEXT', "prolog", -1,
        NULL, &releaseIt);
			    
    if (resource != NULL) {
	stringPtr = Tcl_MacConvertTextResource(resource);
	Tcl_SetResult(interp, stringPtr, TCL_DYNAMIC);
        if (releaseIt) {            
            ReleaseResource(resource);
        }
        return TCL_OK;
    } else {
	return TkGetProlog(interp);
    }
}