From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX"  5-JUN-1992 05:11:48.75
To:	info-vax@kl.sri.com
CC:	
Subj:	DECwindows Sesin Manager replacement (Summary)


In article <1992May27.001647.9699@magnus.acs.ohio-state.edu>, I wrote:

>
>	I would like to incorporate some code into a program which will notify
>the (VMS) DECwindows server that all process are to be terminated and that the
>login dialog box should be started.  If I just stop all the user's processes,
>the login box does not reappear.  Some time ago, someone had reported on an
>extension which the Session Manager uses to kill all the user's processes
>"properly" when the user Quits the session, such that the login dialog box
>(re)starts.  If anyone could supply more information, I'd really appreaciate
>it.
>

	Thanks go to Wolfgang J. Moeller ("GWDGV1::MOELLER"
<moeller@gwdgv1.dnet.gwdg.de>) who was the author of the code to take advantage
of the extension I mentioned.  I'll let him explain:

<It was me who wrote about the server extension that is used by the
<(old) DECW$SESSION to "reset" the server. This "reset" has the effect
<of killing all clients, but it does not cause a login window to appear.
<Code to the latter effect is available in DECW$STARTLOGIN.EXE, and it's
<also present in DECW$SESSION's exit handler - this means that if a server
<reset is performed while DECW$SESSION is running, its abort will implicitly
<restart the login process.
<The "reset" code follows below - note that it will be aborted like other
<server clients, so it'll terminate in error even when it has performed
<its intended purpose.

	As it turned out, all I really needed to do was kill all the user's
clients, then have the "controlling" process run SYS$SYSTEM:DECW$STARTLOGIN
to start the login dialog box.  Normally, this requires CMKRNL privilege, but
Wolfgang didn't believe there was any problem w/ installing DECW$STARTLOGIN
w/ CMKRNL privilege:

<Things may become easier when you simply install DECW$STARTLOGIN with
<CMKRNL privilege: believe it or not, DEC's EWS (VT1300-support) software
<does just that, and we've been running that for some time now.
<I do make use of this within DECW$SYLOGIN.COM, in order to undo
<a DECWindows login when certain site-specific access checks fail.
<Maybe you're trying to do the same??

	In fact, we want to pop up a message on the screen to alert a user if
his/her login device is not available for some reason.  We can now advise a
user of a problem and when the user has acknowledged the pop-up message, we
just terminate the DECwindows session and restart the login dialog.

	Wolfgang's code to "reset" the server is appended below my signature.
I haven't tried it as I found I didn't need it.

							Mike
--
 Internet: davism@kcgl1.eng.ohio-state.edu |
            -or- DAVISM+@osu.edu           |   These Thoughts, They Be Mine
   BITNET: DAVISM+@OHSTMAIL.BITNET         |

/* XSME example: reset DEC's Xwindow server
 *
 * bugs: horribly simplified, NOT reusable, NOT reentrant, VAXC dependent
 *
 * useful reference:
 *  A. Nye, "XLIB Pogramming Manual for Version 11", O'Reilly & Ass. 1990,
 *  ISBN 0-937175-11-0
 */

#include "DECW$INCLUDE:Xlib.h"


/* according to the above book, the following stuff ought to be found in
 * "XLIBINT.H" (which is not present on VMS). So fake it (VAXC specific) ...
 */

#define GetReq(name, req) \
	if ((dpy->bufptr + sizeof(x/**/name/**/Req)) > dpy->bufmax)\
		_XFlush(dpy);\
	req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
	req->reqType = X_/**/name;\
	req->length = sizeof(x/**/name/**/Req)>>2;\
	dpy->bufptr += sizeof(x/**/name/**/Req);\
	dpy->request++

#define SyncHandle() \
	if (dpy->synchandler) (*dpy->synchandler)(dpy)

/* end of fake <XLIBINT.H> */


/* XSME specific definitions */

#define SMEXTENSIONNAME	"ServerManagementExtension"

#define X_SMEResetServer       5

typedef struct {
    unsigned char reqType;
    unsigned char minor_opcode;
    unsigned short length;
} xSMEResetServerReq;


/*****/


static void XSMEResetServer(dpy)
Display *dpy;
{
	xSMEResetServerReq *req;
	XExtCodes *codes;

	codes = XInitExtension(dpy,SMEXTENSIONNAME);

	GetReq(SMEResetServer, req);
	req->reqType = codes->major_opcode;
	req->minor_opcode = X_SMEResetServer;

	SyncHandle();
}

main()
{
	Display *dpy;

	dpy = XOpenDisplay("");		/* open DECW$DISPLAY */
	XSMEResetServer(dpy);
	XCloseDisplay(dpy);		/* expect an error ... */
}

