aboutsummaryrefslogtreecommitdiff
path: root/src/pdj-osx.c
blob: bd2be187a67f8a38c100ee504eee93acbadb5ce4 (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
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <CoreFoundation/CoreFoundation.h>

#include "pdj.h"

int getuglylibpath(char *path) {
	char fullpath[MAXPDSTRING], *pfullpath;
	FILE *fd;
	
	fd = (FILE *) open_via_path("", "pdj.properties", "", fullpath, &pfullpath, MAXPDSTRING, 0);
	if ( fd != NULL ) {
		close(fd);
        if ( fullpath[0] != 0 ) {
        	if ( pfullpath == ((char *) &fullpath) ) {
        		getcwd(path, MAXPDSTRING);
        	} else {
            	strcpy(path, fullpath);
        	}
            return 0;
        }
    } 
    
    error("unable to find pdj directory, please add it in your pure-data path settings");
    return 1;
}

JNI_CreateJavaVM_func *linkjvm(char *vmtype) {
	char *jvmVersion = pdj_getProperty("pdj.osx.JAVA_JVM_VERSION");
	
	if ( jvmVersion != NULL ) {
		setenv("JAVA_JVM_VERSION", jvmVersion, 1);
	}

    return (JNI_CreateJavaVM_func *) &JNI_CreateJavaVM;
}