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/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

Also available in: Unified diff