/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* winsysck - determine which window system protocols are available
*
* usage: winsysck [ -va ] [ -display display_name ] protocol [...]
*
* options:
* -a check every protocol listed, rather than stopping after
* the first one.
* -v print the first available protocol (or every available
* protocol, with the -a option) to stdout.
* -display display_name
* use the display display_name for X11 connections instead of
* the one specified by the $DISPLAY environment variable.
* -timeout seconds
* The timeout option sets the number of seconds before
* the winsysck will time out.
*
* protocols:
* x11
* The X11 protocol.
* news
* The NeWS protocol.
* x11news
* Both the X11 and the NeWS protocols, and both connect to
* the same server.
* sunview
* The SunView protocol.
*
* NOTE: Since news, x11news, and sunview have been unsupported for over
* a decade, we no longer actually check for them, but always return false.
*
* exit status:
* 0 if any listed protocols are available
* 1 if no listed protocols are available
* 2 usage error
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
static char* cmdname;
static void
usage (void) {
"[-va] [-display display_name] [-timeout seconds] protocol [...]",
"protocol can be one of: x11 news x11news sunview");
exit(2);
}
/*
* Keep track of what protocols we're checking, and in what order.
*/
#define PROTO_NONE 0
static void
{
int i;
for (i=0; i<N_PROTO; i++) {
if (proto_list[i]==proto) {
return;
}
}
}
/*
* Keep track of the options specified.
*/
/*
* Parse the options.
*/
static void
{
argv++;
argc--;
continue;
}
argv++;
argc--;
continue;
}
case 'a':
showall++;
break;
case 'v':
verbose++;
break;
default:
usage();
}
}
}
else {
} else {
usage();
}
}
}
if (!n_proto) {
cmdname);
usage();
}
}
/* Last remnants of x11-procs.c */
static void OnAlarm(int i)
{
exit(1);
}
static int
{
if(timeout > 0){
}
if(timeout > 0)
alarm(0);
}
static int
DisconnectFromX (void) {
return(1);
}
/*
* Try connecting via the specified protocols.
*/
static void
Probe(void)
{
int i, found=0;
switch (proto_list[i]) {
case PROTO_X11:
if (ConnectToX(display_name)) {
found++;
}
break;
case PROTO_NeWS:
case PROTO_X11NeWS:
case PROTO_SunView:
/* Don't even bother */
break;
default:
cmdname,i,proto_list[i]);
}
}
}
int
{
Probe();
exit(0);
}