Project

Profile

Help

Revision f62330e8

Added by O'Neil Delpratt almost 6 years ago

Saxon/C bug fix and minor things

View differences:

latest9.6/hec/Saxon.C.API/EEC/SaxonCGlue.c
6 6
* If the SAXONC_HOME sxnc_environmental variable is set then use that as base.
7 7
*/
8 8
void setDllname(){
9
	if(getenv("SAXONC_HOME")!= NULL) {
10

  
11
		char * env = getenv("SAXONC_HOME");
12
		size_t env_len = strlen(env);
13
		size_t name_len =  15;
14
		size_t rDir_len = 11;
15
		//dllname =malloc(sizeof(char)*name_len);
16
		//resources_dir =malloc(sizeof(char)*rDir_len);
17
		memset(&dllname[0], 0, sizeof(dllname));
18
		memset(&resources_dir[0], 0, sizeof(resources_dir));
19
		strncat(resources_dir, env,  env_len);
20
		strncat(resources_dir, "/saxon-data", rDir_len);
21
		strncat(dllname, env, env_len);
22
		strncat(dllname, "/libsaxoneec.so", name_len); //rename according to product edition (-hec or -pec)
9
	size_t name_len  = strlen(tempDllname);
10
	size_t rDir_len  = strlen(tempResources_dir);
11
	char * env = getenv("SAXONC_HOME");
12
	size_t env_len;
13
	if(env!= NULL) {
14

  
15
		
16
		env_len = strlen(env);
17
		dllname =malloc(sizeof(char)*name_len+env_len+1);
18
		resources_dir =malloc(sizeof(char)*rDir_len+env_len+1);
19
		snprintf(dllname, env_len+name_len+1, "%s%s", env, tempDllname);
20
		snprintf(resources_dir, env_len+rDir_len+1, "%s%s", env, tempResources_dir);
21
		
23 22
#ifdef DEBUG	
24
		printf("resources_dir: %s\n", resources_dir);	
23
		
25 24
		printf("envDir: %s\n", env);
26
		printf("size of env %i\n", strlen(env));
27
		printf("size of dllname %i\n", strlen(dllname));
28
		printf("dllName: %s\n", dllname);
29
		printf("resources_dir: %s\n", resources_dir);
25
		
26
		
27
#endif
28

  
29
       } else {
30
		env_len = 8;
31
		dllname =malloc(sizeof(char)*name_len+env_len+1);
32
		resources_dir =malloc(sizeof(char)*rDir_len+env_len+1);
33
#ifdef DEBUG
34
		if(dllname == NULL || resources_dir == NULL)
35
		{
36
    		  // error
37
		  printf("Error in allocation of Dllname\n");
38
		}
30 39
#endif
40
		memset(&dllname[0], 0, sizeof(dllname));
41
		memset(&resources_dir[0], 0, sizeof(resources_dir));
42
#ifdef __linux__
43
		
44
       		snprintf(dllname, 8+name_len+1, "%s%s", "/usr/lib", tempDllname);
45
		snprintf(resources_dir, 8+rDir_len+1, "%s%s", "/usr/lib", tempResources_dir);
46
#elif  defined (__APPLE__) && defined(__MACH__)
47
       		snprintf(dllname, 8+name_len+1, "%s%s", "/usr/lib", tempDllname);
48
		snprintf(resources_dir, 8+rDir_len+1, "%s%s", "/usr/lib", tempResources_dir);
49
#else
50
		//TODO When windows version of Saxon/C is done we will have to fixup this
51
		strncpy(dllname, "C:\\Program Files\\Saxonica\\SaxonEEC1.0.1", 42);
52
		strncpy(resources_dir, "C:\\Program Files\\Saxonica\\SaxonEEC1.0.1", 42);
53
#endif
54

  
55
	
56

  
31 57
	}
58
		
59

  
32 60
#ifdef DEBUG	
33
		printf("resources_dir: %s\n", resources_dir);	
61

  
62
		printf("Library length: %i\n", name_len);
63
		printf("Env length: %i\n", env_len);
64
		printf("dllname length alloc: %i\n", (env_len+name_len+1));
65
		printf("resources length alloc: %i\n", (env_len+rDir_len+1));		
34 66
		printf("size of dllname %i\n", strlen(dllname));
35 67
		printf("dllName: %s\n", dllname);
36 68
		printf("resources_dir: %s\n", resources_dir);
......
43 75
	return dllname;
44 76
}
45 77

  
78
char * getResourceDirectory(){
79
	return resources_dir;
80
}
81

  
46 82
/*
47 83
 * Load dll using the default setting in Saxon/C
48 84
 * Recommended method to use to load library
latest9.6/hec/Saxon.C.API/EEC/SaxonCGlue.h
53 53

  
54 54
EXTERN_C
55 55

  
56
 
56 57

  
57

  
58

  
59
static char dllname[] =
60
    #ifdef __linux__
61
        "/usr/lib/libsaxoneec.so";  //rename according to product edition (hec or pec) Also make change in the c file
58
static char tempDllname[] =
59
#if defined (__linux__)
60
        "/libsaxoneec.so";  
62 61
    #elif  defined (__APPLE__) && defined(__MACH__)
63
        "/usr/lib/libsaxoneec.dylib";
62
        "/libsaxoneec.dylib";
64 63
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\libsaxoneec.dll";
64
         "\\libsaxoneec.dll";
66 65
    #endif
67 66

  
68
static char resources_dir[] = 
67
static char tempResources_dir[] = 
69 68
     #ifdef __linux__
70
        "/usr/lib/saxon-data";
69
        "/saxon-data";
71 70
    #elif  defined (__APPLE__) && defined(__MACH__)
72
        "/usr/lib/saxon-data";
71
        "/saxon-data";
73 72
    #else
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
73
         "\\saxon-data";
75 74
    #endif
76 75

  
76

  
77
static char * dllname;
78

  
79
static char *resources_dir;
80

  
77 81
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
78 82
static int jvmCreated =0;
79 83

  
......
126 130

  
127 131

  
128 132
/*
133
* Get Dll name.
134
*/
135

  
136
char * getResourceDirectory();
137

  
138
/*
129 139
* Set Dll name. Also set the saxon resources directory. 
130 140
* If the SAXON_HOME environmental variable is set then use that as base.
131 141
*/
latest9.6/hec/Saxon.C.API/HEC/SaxonCGlue.c
6 6
* If the SAXONC_HOME sxnc_environmental variable is set then use that as base.
7 7
*/
8 8
void setDllname(){
9
	if(getenv("SAXONC_HOME")!= NULL) {
10

  
11
		char * env = getenv("SAXONC_HOME");
12
		size_t env_len = strlen(env);
13
		size_t name_len =  15;
14
		size_t rDir_len = 11;
15
		//dllname =malloc(sizeof(char)*name_len);
16
		//resources_dir =malloc(sizeof(char)*rDir_len);
17
		memset(&dllname[0], 0, sizeof(dllname));
18
		memset(&resources_dir[0], 0, sizeof(resources_dir));
19
		strncat(resources_dir, env,  env_len);
20
		strncat(resources_dir, "/saxon-data", rDir_len);
21
		strncat(dllname, env, env_len);
22
		strncat(dllname, "/libsaxonhec.so", name_len); //rename according to product edition (-hec or -pec)
9
	size_t name_len  = strlen(tempDllname);
10
	size_t rDir_len  = strlen(tempResources_dir);
11
	char * env = getenv("SAXONC_HOME");
12
	size_t env_len;
13
	if(env!= NULL) {
14

  
15
		
16
		env_len = strlen(env);
17
		dllname =malloc(sizeof(char)*name_len+env_len+1);
18
		resources_dir =malloc(sizeof(char)*rDir_len+env_len+1);
19
		snprintf(dllname, env_len+name_len+1, "%s%s", env, tempDllname);
20
		snprintf(resources_dir, env_len+rDir_len+1, "%s%s", env, tempResources_dir);
21
		
23 22
#ifdef DEBUG	
24
		printf("resources_dir: %s\n", resources_dir);	
23
		
25 24
		printf("envDir: %s\n", env);
26
		printf("size of env %i\n", strlen(env));
27
		printf("size of dllname %i\n", strlen(dllname));
28
		printf("dllName: %s\n", dllname);
29
		printf("resources_dir: %s\n", resources_dir);
25
		
26
		
27
#endif
28

  
29
       } else {
30
		env_len = 8;
31
		dllname =malloc(sizeof(char)*name_len+env_len+1);
32
		resources_dir =malloc(sizeof(char)*rDir_len+env_len+1);
33
#ifdef DEBUG
34
		if(dllname == NULL || resources_dir == NULL)
35
		{
36
    		  // error
37
		  printf("Error in allocation of Dllname\n");
38
		}
30 39
#endif
40
		memset(&dllname[0], 0, sizeof(dllname));
41
		memset(&resources_dir[0], 0, sizeof(resources_dir));
42
#ifdef __linux__
43
		
44
       		snprintf(dllname, 8+name_len+1, "%s%s", "/usr/lib", tempDllname);
45
		snprintf(resources_dir, 8+rDir_len+1, "%s%s", "/usr/lib", tempResources_dir);
46
#elif  defined (__APPLE__) && defined(__MACH__)
47
       		snprintf(dllname, 8+name_len+1, "%s%s", "/usr/lib", tempDllname);
48
		snprintf(resources_dir, 8+rDir_len+1, "%s%s", "/usr/lib", tempResources_dir);
49
#else
50
		//TODO When windows version of Saxon/C is done we will have to fixup this
51
		strncpy(dllname, "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1", 42);
52
		strncpy(resources_dir, "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1", 42);
53
#endif
54

  
55
	
56

  
31 57
	}
58
		
59

  
32 60
#ifdef DEBUG	
33
		printf("resources_dir: %s\n", resources_dir);	
61

  
62
		printf("Library length: %i\n", name_len);
63
		printf("Env length: %i\n", env_len);
64
		printf("dllname length alloc: %i\n", (env_len+name_len+1));
65
		printf("resources length alloc: %i\n", (env_len+rDir_len+1));		
34 66
		printf("size of dllname %i\n", strlen(dllname));
35 67
		printf("dllName: %s\n", dllname);
36 68
		printf("resources_dir: %s\n", resources_dir);
......
43 75
	return dllname;
44 76
}
45 77

  
78
char * getResourceDirectory(){
79
	return resources_dir;
80
}
81

  
46 82
/*
47 83
 * Load dll using the default setting in Saxon/C
48 84
 * Recommended method to use to load library
latest9.6/hec/Saxon.C.API/HEC/SaxonCGlue.h
53 53

  
54 54
EXTERN_C
55 55

  
56
 
56 57

  
57

  
58

  
59
static char dllname[] =
60
    #ifdef __linux__
61
        "/usr/lib/libsaxonhec.so";  //rename according to product edition (hec or pec) Also make change in the c file
58
static char tempDllname[] =
59
#if defined (__linux__)
60
        "/libsaxonhec.so";  
62 61
    #elif  defined (__APPLE__) && defined(__MACH__)
63
        "/usr/lib/libsaxonhec.dylib";
62
        "/libsaxonhec.dylib";
64 63
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\libsaxonhec.dll";
64
         "\\libsaxonhec.dll";
66 65
    #endif
67 66

  
68
static char resources_dir[] = 
67
static char tempResources_dir[] = 
69 68
     #ifdef __linux__
70
        "/usr/lib/saxon-data";
69
        "/saxon-data";
71 70
    #elif  defined (__APPLE__) && defined(__MACH__)
72
        "/usr/lib/saxon-data";
71
        "/saxon-data";
73 72
    #else
74
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
73
         "\\saxon-data";
75 74
    #endif
76 75

  
76

  
77
static char * dllname;
78

  
79
static char *resources_dir;
80

  
77 81
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
78 82
static int jvmCreated =0;
79 83

  
......
126 130

  
127 131

  
128 132
/*
133
* Get Dll name.
134
*/
135

  
136
char * getResourceDirectory();
137

  
138
/*
129 139
* Set Dll name. Also set the saxon resources directory. 
130 140
* If the SAXON_HOME environmental variable is set then use that as base.
131 141
*/
latest9.6/hec/Saxon.C.API/PEC/SaxonCGlue.c
6 6
* If the SAXONC_HOME sxnc_environmental variable is set then use that as base.
7 7
*/
8 8
void setDllname(){
9
	if(getenv("SAXONC_HOME")!= NULL) {
10

  
11
		char * env = getenv("SAXONC_HOME");
12
		size_t env_len = strlen(env);
13
		size_t name_len =  15;
14
		size_t rDir_len = 11;
15
		//dllname =malloc(sizeof(char)*name_len);
16
		//resources_dir =malloc(sizeof(char)*rDir_len);
17
		memset(&dllname[0], 0, sizeof(dllname));
18
		memset(&resources_dir[0], 0, sizeof(resources_dir));
19
		strncat(resources_dir, env,  env_len);
20
		strncat(resources_dir, "/saxon-data", rDir_len);
21
		strncat(dllname, env, env_len);
22
		strncat(dllname, "/libsaxonpec.so", name_len); //rename according to product edition (-hec or -pec)
9
	size_t name_len  = strlen(tempDllname);
10
	size_t rDir_len  = strlen(tempResources_dir);
11
	char * env = getenv("SAXONC_HOME");
12
	size_t env_len;
13
	if(env!= NULL) {
14

  
15
		
16
		env_len = strlen(env);
17
		dllname =malloc(sizeof(char)*name_len+env_len+1);
18
		resources_dir =malloc(sizeof(char)*rDir_len+env_len+1);
19
		snprintf(dllname, env_len+name_len+1, "%s%s", env, tempDllname);
20
		snprintf(resources_dir, env_len+rDir_len+1, "%s%s", env, tempResources_dir);
21
		
23 22
#ifdef DEBUG	
24
		printf("resources_dir: %s\n", resources_dir);	
23
		
25 24
		printf("envDir: %s\n", env);
26
		printf("size of env %i\n", strlen(env));
27
		printf("size of dllname %i\n", strlen(dllname));
28
		printf("dllName: %s\n", dllname);
29
		printf("resources_dir: %s\n", resources_dir);
25
		
26
		
27
#endif
28

  
29
       } else {
30
		env_len = 8;
31
		dllname =malloc(sizeof(char)*name_len+env_len+1);
32
		resources_dir =malloc(sizeof(char)*rDir_len+env_len+1);
33
#ifdef DEBUG
34
		if(dllname == NULL || resources_dir == NULL)
35
		{
36
    		  // error
37
		  printf("Error in allocation of Dllname\n");
38
		}
30 39
#endif
40
		memset(&dllname[0], 0, sizeof(dllname));
41
		memset(&resources_dir[0], 0, sizeof(resources_dir));
42
#ifdef __linux__
43
		
44
       		snprintf(dllname, 8+name_len+1, "%s%s", "/usr/lib", tempDllname);
45
		snprintf(resources_dir, 8+rDir_len+1, "%s%s", "/usr/lib", tempResources_dir);
46
#elif  defined (__APPLE__) && defined(__MACH__)
47
       		snprintf(dllname, 8+name_len+1, "%s%s", "/usr/lib", tempDllname);
48
		snprintf(resources_dir, 8+rDir_len+1, "%s%s", "/usr/lib", tempResources_dir);
49
#else
50
		//TODO When windows version of Saxon/C is done we will have to fixup this
51
		strncpy(dllname, "C:\\Program Files\\Saxonica\\SaxonPEC1.0.1", 42);
52
		strncpy(resources_dir, "C:\\Program Files\\Saxonica\\SaxonPEC1.0.1", 42);
53
#endif
54

  
55
	
56

  
31 57
	}
58
		
59

  
32 60
#ifdef DEBUG	
33
		printf("resources_dir: %s\n", resources_dir);	
61

  
62
		printf("Library length: %i\n", name_len);
63
		printf("Env length: %i\n", env_len);
64
		printf("dllname length alloc: %i\n", (env_len+name_len+1));
65
		printf("resources length alloc: %i\n", (env_len+rDir_len+1));		
34 66
		printf("size of dllname %i\n", strlen(dllname));
35 67
		printf("dllName: %s\n", dllname);
36 68
		printf("resources_dir: %s\n", resources_dir);
......
43 75
	return dllname;
44 76
}
45 77

  
78
char * getResourceDirectory(){
79
	return resources_dir;
80
}
81

  
46 82
/*
47 83
 * Load dll using the default setting in Saxon/C
48 84
 * Recommended method to use to load library
latest9.6/hec/Saxon.C.API/PEC/SaxonCGlue.h
53 53

  
54 54
EXTERN_C
55 55

  
56
 
56 57

  
58
static char tempDllname[] =
59
#if defined (__linux__)
60
        "/libsaxonpec.so";  
61
    #elif  defined (__APPLE__) && defined(__MACH__)
62
        "/libsaxonpec.dylib";
63
    #else
64
         "\\libsaxonpec.dll";
65
    #endif
66

  
67
static char tempResources_dir[] = 
68
     #ifdef __linux__
69
        "/saxon-data";
70
    #elif  defined (__APPLE__) && defined(__MACH__)
71
        "/saxon-data";
72
    #else
73
         "\\saxon-data";
74
    #endif
57 75

  
58 76

  
59
static char dllname[] =
77
static char * dllname;/*[] =
60 78
    #ifdef __linux__
61
        "/usr/lib/libsaxonpec.so";  //rename according to product edition (hec or pec) Also make change in the c file
79
        "/usr/lib/libsaxonhec.so";  //rename according to product edition (hec or pec) Also make change in the c file
62 80
    #elif  defined (__APPLE__) && defined(__MACH__)
63
        "/usr/lib/libsaxonpec.dylib";
81
        "/usr/lib/libsaxoneec.dylib";
64 82
    #else
65
         "C:\\Program Files\\Saxonica\\SaxonPEC1.0.1\\libsaxonpec.dll";
66
    #endif
83
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\libsaxonhec.dll";
84
    #endif*/
67 85

  
68
static char resources_dir[] = 
86
static char *resources_dir;/*[] = 
69 87
     #ifdef __linux__
70 88
        "/usr/lib/saxon-data";
71 89
    #elif  defined (__APPLE__) && defined(__MACH__)
72 90
        "/usr/lib/saxon-data";
73 91
    #else
74 92
         "C:\\Program Files\\Saxonica\\SaxonHEC1.0.1\\saxon-data";
75
    #endif
93
    #endif*/
76 94

  
77 95
// Static variable used to track when jvm has been created. Used to prevent creation more than once.
78 96
static int jvmCreated =0;
......
126 144

  
127 145

  
128 146
/*
147
* Get Dll name.
148
*/
149

  
150
char * getResourceDirectory();
151

  
152
/*
129 153
* Set Dll name. Also set the saxon resources directory. 
130 154
* If the SAXON_HOME environmental variable is set then use that as base.
131 155
*/

Also available in: Unified diff