File: PsychHelp.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 (99 lines) | stat: -rwxr-xr-x 2,305 bytes parent folder | download | duplicates (3)
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
98
99
/*
 	PsychToolbox3/Source/Common/PsychHelp.c		
  
 	AUTHORS:
 
 		Allen.Ingling@nyu.edu		awi 
		mario.kleiner@tuebingen.mpg.de  mk
 
 	PLATFORMS: 
 	
 		All.

  	PROJECTS:
  
  		08/19/02	awi		Screen on OS X

  	HISTORY:
  
  		08/19/02  awi	
  		04/22/05  dgp Reduced right margin from 80 to 74.
  		10/11/05	awi Cosmetic.
  
  	DESCRIPTION:
  
  	TO DO: 
*/

#include "Psych.h"

//declare static variables for internal use by PsychHelp.cpp
static char *functionUseHELP = NULL; 
static char *functionSynopsisHELP = NULL;
static char *functionSeeAlsoHELP = NULL;
static psych_bool giveHelpHELP = FALSE;
static psych_bool oneShotReturnHelp = FALSE;

// functions for flipping a flag to indicate whether function help should be given.    
void PsychSetGiveHelp(void)
{
	giveHelpHELP = TRUE;
}

void PsychClearGiveHelp(void)
{
	giveHelpHELP = FALSE;
}

psych_bool PsychIsGiveHelp(void)
{
	return(giveHelpHELP);
}

// push the help strings onto a shallow stack 1 element deep
void PsychPushHelp(char *functionUse, char *functionSynopsis, char *functionSeeAlso)
{

	functionUseHELP = functionUse;
	functionSynopsisHELP = functionSynopsis;
        functionSeeAlsoHELP = functionSeeAlso;
}	

void PsychOneShotReturnHelp(void)
{
	oneShotReturnHelp = TRUE;
}

void PsychGiveHelp(void)
{  
    PsychGenericScriptType		*cellVector;

	// Special case: Asked to return help in a cell array of strings?
	if (oneShotReturnHelp) {
		// Yes. Return a 3 element cell array of strings, each containing one
		// of the three help text arguments:
		PsychAllocOutCellVector(1, FALSE, 3,  &cellVector);
		PsychSetCellVectorStringElement(0, functionUseHELP, cellVector);
		PsychSetCellVectorStringElement(1, BreakLines(functionSynopsisHELP, 80), cellVector);
		PsychSetCellVectorStringElement(2, functionSeeAlsoHELP, cellVector);
		oneShotReturnHelp = FALSE;

		return;
	}
	
	// No, standard path: Print to console of runtime system:
	printf("\nUsage:\n\n%s\n",functionUseHELP);
	if (functionSynopsisHELP != NULL) printf("\n%s\n", BreakLines(functionSynopsisHELP, 80));
	if (functionSeeAlsoHELP  != NULL) printf("\nSee also: %s\n", BreakLines(functionSeeAlsoHELP, 80));
}

void PsychGiveUsage(void)
{  
	printf("Usage:\n\n%s",functionUseHELP);
}


void PsychGiveUsageExit(void)
{  
	PrintfExit("Usage:\n\n%s",functionUseHELP);
}