File: COCOAEVENTBRIDGEPathToBundle.c

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (97 lines) | stat: -rw-r--r-- 2,366 bytes parent folder | download | duplicates (4)
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
/*
	PsychSourceGL/Source/Common/CocoaEventBridge/COCOAEVENTBRIDGEPathToBundle.c		
  
	PROJECTS: 
  
		CocoaEventBridge only
  
	AUTHORS:
  
		Allen.Ingling@nyu.edu		awi 
  
	PLATFORMS:	
  
		Only OS X.
    
	HISTORY:

		9/20/05		awi		Wrote it .


*/

#include "EventBridgeBundleHeader.h"
//#include "CocoaEventBridgeHelpers.h"
#include "CocoaEventBridge.h"

//file static variables to retain the path name
static	char		*bundleFilePathNameStr=NULL;



static char useString[] = "oldPath=CocoaEventBridge(['PathToBundle']);";
static char synopsisString[] = 
        "Get and optionally set the path to the bundle \"GetCharWindow.bundle\"."
		"\n\n"
		"Do not call CocoaEventBridge('PathToBundle') directly.  It should be used by only the Psychtoolbox function \"InitCocoaEventBridge\"";
static char seeAlsoString[] = "GetChar";	

PsychError COCOAEVENTBRIDGEPathToBundle(void) 
{

	psych_bool						isNewArgThereFlag;
	int							newNameLength;
	char						*tempBundleFilePathNameStr, *localBundleFilePathNameStr;
	

	//all subfunctions should have these two lines.  
	PsychPushHelp(useString, synopsisString, seeAlsoString);
	if(PsychIsGiveHelp()){PsychGiveHelp();return(PsychError_none);};

    //check to see if the user supplied superfluous arguments
    PsychErrorExit(PsychCapNumOutputArgs(1));
    PsychErrorExit(PsychCapNumInputArgs(1));
	
	//first copy out the old path 
	GetPathToBundleString(&localBundleFilePathNameStr);
	PsychCopyOutCharArg(1, kPsychArgOptional, localBundleFilePathNameStr);
	
	//read in and retain the new name.  It arrives in a temporary variable
	isNewArgThereFlag=PsychAllocInCharArg(1, kPsychArgOptional, &tempBundleFilePathNameStr);
	if(isNewArgThereFlag){
		newNameLength=strlen(tempBundleFilePathNameStr);
		if(bundleFilePathNameStr != NULL)
			free((void*)bundleFilePathNameStr);
		bundleFilePathNameStr=(char*)malloc(sizeof(char) * (newNameLength + 1));
		strncpy(bundleFilePathNameStr, tempBundleFilePathNameStr, newNameLength + 1);
	}
		
    return(PsychError_none);	
}


void GetPathToBundleString(char **fPath)
{
	if(bundleFilePathNameStr==NULL){
			bundleFilePathNameStr=(char *)malloc(sizeof(char));
			bundleFilePathNameStr[0]='\0';
	}
	*fPath=bundleFilePathNameStr;

}


void FreePathToBundleString(void)
{
	if(bundleFilePathNameStr != NULL){
		free((void*)bundleFilePathNameStr);
		bundleFilePathNameStr=NULL;
	}
}