[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

3324.0. "How to find out if workstation is in PAUSED state" by UTRTSC::LAKENS () Mon Sep 10 1990 11:57

Hallo,


A customer wants to run a security program if the workstation is not 
in a PAUSED state and kill the session if it isn't PAUSED.  

Is there a way to  find out if a workstation is in a paused state
from a remote source ? 

Thanks 

Gerard Lakens SSO
 
T.RTitleUserPersonal
Name
DateLines
3324.1PSW::WINALSKICareful with that VAX, EugeneMon Sep 10 1990 15:017
First you open a DECwindows display on that node.  Then you call the
InPausedState() routine that you will find in
TLE::ULNK$:[WINALSKI.X.XNEKO]XNEKO.C.  You'll also need SMPAUSEWINDOW.C from
the same directory.  These routines work on VAX/VMS and on ULTRIX except for
ULTRIX V4.0.

--PSW
3324.2ispaused.c....AISG::COLLIERThu Sep 13 1990 14:17232
/*
ISPAUSED.C - check to see if a session manager is paused.

This is your basic hack.  Based on the decwindows notes conference, note
3324.1 (included below) I went and banged away at xneko and stripped it
down to a simple program that will just say yes or no to a workstation
being paused.  I have known of a number of requests for just this, so
what the hey...

You must have security access to the display, if there is no session manager
currently running i believe this will just bomb.

set up a sumbol...
   $  ispaused :== "$mumble:[mumble]ispaused.exe"
the use it by
   $  ispaused -display NODE::0

is you have access to that node's screen, then you will get a yes/no
answer to is it paused...

All due credit to the original authors of XNEKO and SMPAUSEWINDOW!!!  Compared
to the original work I did nothing at all except reorganize it a bit...

To build this...
extract this file to ispaused.c
$copy TLE::ULNK$:[WINALSKI.X.XNEKO]SMPAUSEWINDOW.C
$cc ispaused,smpausewindow
$link ispaused,smpausewindow,sys$input:/opt
sys$share:decw$dwtlibshr/share
sys$share:decw$xlibshr/share
sys$share:vaxcrtl.exe/share
^z



================================================================================
Note 3324.1     How to find out if workstation is in PAUSED state         1 of 1
PSW::WINALSKI "Careful with that VAX, Eugene"         7 lines  10-SEP-1990 14:01
--------------------------------------------------------------------------------
First you open a DECwindows display on that node.  Then you call the
InPausedState() routine that you will find in
TLE::ULNK$:[WINALSKI.X.XNEKO]XNEKO.C.  You'll also need SMPAUSEWINDOW.C from
the same directory.  These routines work on VAX/VMS and on ULTRIX except for
ULTRIX V4.0.

--PSW

*/


/*--------------------------------------------------------------
 *
 *      xneko  -  X11
 *
 *                      Original Writer: Masayuki Koba
 *                      Programmed by Masayuki Koba, 1990
 *
 *--------------------------------------------------------------
 */

#ifdef VMS

#include stdio
#include math
#include string
#include signal

#include "DECW$INCLUDE:Xlib.h"
#include "DECW$INCLUDE:Xutil.h"
#include "DECW$INCLUDE:Xatom.h"
#include "DECW$INCLUDE:keysym.h"

#else

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>

#include <stdio.h>
#include <string.h>

#include <signal.h>
#include <math.h>
#include <sys/time.h>
#endif


#define DIRNAMELEN              255
static char		*ProgramName;		/* ���ޥ��̾�� */
Display			*theDisplay;
int			theScreen;

extern Window SmPauseWindow();

Window			sWindow;

int InPausedState(dpy, root)
    Display *dpy;
    Window root;
{
    XWindowAttributes attr;
    int new_state;

    if (sWindow == 0)
        {
        sWindow = SmPauseWindow(dpy, root);
        if (sWindow == 0)
	    return 0;
	}

    if (!XGetWindowAttributes (dpy, sWindow, &attr))
	{
	fprintf (stderr, "XGetWindowAttributes on session manager pause window failed.\n");
	exit(1);
	}

    new_state = (attr.map_state == IsViewable);
    return new_state;
}

void
InitScreen( DisplayName)
    char	*DisplayName;
{
    if ( ( theDisplay = XOpenDisplay( DisplayName ) ) == NULL ) {
	fprintf( stderr, "%s: Can't open display", ProgramName );
	if ( DisplayName != NULL ) {
	    fprintf( stderr, " %s.\n", DisplayName );
	} else {
	    fprintf( stderr, ".\n" );
	}
	exit( 1 );
    }

    theScreen = DefaultScreen( theDisplay );
   }

void
Usage()
{
    /*
     * JH, added [-root] [-demo] [-pause] as option
     */

    fprintf( stderr,
	     "Usage: %s -display <display> \\\n",
	     ProgramName );
}


/*--------------------------------------------------------------
 *
 *	�إѥ�᡼��ɾ��
 *
 *--------------------------------------------------------------*/

Bool
GetArguments( argc, argv, theDisplayName)
    int		argc;
    char	*argv[];
    char	*theDisplayName;
{
    int		ArgCounter;

    theDisplayName[ 0 ] = '\0';


    /*
     * JH, hack adds demo and root as options
     */

    for ( ArgCounter = 0; ArgCounter < argc; ArgCounter++ ) {

	if ( strncmp( argv[ ArgCounter ], "-h", 2 ) == 0 ) {
	    Usage();
	    exit( 0 );
	} else if ( strcmp( argv[ ArgCounter ], "-display" ) == 0 ) {
	    ArgCounter++;
	    if ( ArgCounter < argc ) {
		strcpy( theDisplayName, argv[ ArgCounter ] );
	    } else {
		fprintf( stderr, "%s: -display option error.\n", ProgramName );
		exit( 1 );
	    }
	} 
        else {
	    fprintf( stderr,
		     "%s: Unknown option \"%s\".\n", ProgramName,
						     argv[ ArgCounter ] );
	    Usage();
	    exit( 1 );
	}
    }

    if ( strlen( theDisplayName ) < 1 ) {
	theDisplayName = NULL;
    }

    return;
}


/*--------------------------------------------------------------
 *
 *	�ᥤ��ؿ�
 *
 *--------------------------------------------------------------*/
int
main( argc, argv )
    int		argc;
    char	*argv[];
{
    char	theDisplayName[ DIRNAMELEN ];
    char	theGeometry[ DIRNAMELEN ];
    char	theTitle[ DIRNAMELEN ];

    ProgramName = argv[ 0 ];

    argc--;
    argv++;

    GetArguments( argc, argv, theDisplayName);

    InitScreen( theDisplayName);
    if (!InPausedState(theDisplay, RootWindow(theDisplay, theScreen)) )
        printf("screen is NOT in paused state\n");
    else
        printf("screen IS in paused state. \n");

    exit( 0 );
}