EXPORT(sqInt) primitiveSetDisplayName(void) {
    extern char *displayName;
    sqInt name;
    static char nameBuffer[501];
    char * namePtr;


	/* Do not allow this if running in secure mode */

	if ((sandboxSecurity()) == 1) {
		interpreterProxy->pop(2);
		interpreterProxy->pushInteger(-1);
	} else {
		name = interpreterProxy->stackObjectValue(0);
		if (name == (interpreterProxy->nilObject())) {
			displayName = 0;
		} else {
			namePtr = transientCStringFromString(name);
			strncpy(nameBuffer, namePtr, 500);
			nameBuffer[500] = 0;
			displayName = nameBuffer;
		}
		interpreterProxy->pop(1);
	}
	return null;
}
EXPORT(sqInt) primitiveCanConnectToDisplay(void) {
    Display *d;
    sqInt name;
    char * namePtr;


	/* Do not allow this if running in secure mode */

	if ((sandboxSecurity()) == 1) {
		interpreterProxy->pop(2);
		interpreterProxy->push(interpreterProxy->falseObject());
	} else {
		name = interpreterProxy->stackObjectValue(0);
		namePtr = transientCStringFromString(name);
		d = XOpenDisplay(namePtr);
		if (d == 0) {

			/* Failed to make connection to server, answer false */

			interpreterProxy->pop(2);
			interpreterProxy->push(interpreterProxy->falseObject());
		} else {

			/* Successfully opened connection; close it and answer true */

			XCloseDisplay(d);
			interpreterProxy->pop(2);
			interpreterProxy->push(interpreterProxy->trueObject());
		}
	}
	return null;
}
EXPORT(sqInt) primitiveCanConnectToDisplay(void) {
    sqInt name;
    char * namePtr;
    Display *d;

	if ((sandboxSecurity()) == 1) {
		interpreterProxy->pop(2);
		interpreterProxy->push(interpreterProxy->falseObject());
	} else {
		name = interpreterProxy->stackObjectValue(0);
		namePtr = transientCStringFromString(name);
		d = XOpenDisplay(namePtr);
		if (d == 0) {
			interpreterProxy->pop(2);
			interpreterProxy->push(interpreterProxy->falseObject());
		} else {
			XCloseDisplay(d);
			interpreterProxy->pop(2);
			interpreterProxy->push(interpreterProxy->trueObject());
		}
	}
}