| /*
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 );
}
|