1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
/*
* Copyright (c) 1999-2003 Smithsonian Astrophysical Observatory
*/
/*
*
* xpa.h - include file for the X Public Access mechanism
*
*/
#ifndef __xpap_h
#define __xpap_h
#if HAVE_CONFIG_H
#include <conf.h>
#endif
/* avoid use of system -- its not secure */
#if USE_SPAWN == 0
#define USE_LAUNCH 1
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_STRING_H
#include <string.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
#if HAVE_SETJMP_H
#include <setjmp.h>
#endif
#if HAVE_PWD_H
#include <pwd.h>
#endif
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <xport.h>
#include <tcp.h>
#include <word.h>
#include <xalloc.h>
#include <find.h>
#if USE_LAUNCH
#include <xlaunch.h>
#endif
#include <timedconn.h>
/* B.Schoenhammer@bit-field.de 2009-09-21 */
#if HAVE_MINGW32
#ifdef HAVE_ATEXIT
#undef HAVE_ATEXIT
#endif
#endif
/* make sure socklen_t is available, since some systems don't use it */
#ifndef HAVE_SOCKLEN_T
#define socklen_t int
#endif
/* the flag for setting non-blocking I/O varies a bit from Unix to Unix */
#ifndef O_NONBLOCK
#ifdef O_NDELAY
#define O_NONBLOCK O_NDELAY
#endif
#endif
#if HAVE_MINGW32==0
/* we always want to know about errors when a read/write would block */
#ifndef EWOULDBLOCK
#ifdef EAGAIN
#define EWOULDBLOCK EAGAIN
#endif
#else
#ifndef EAGAIN
#ifdef EWOULDBLOCK
#define EAGAIN EWOULDBLOCK
#endif
#endif
#endif
#endif
/* not all systems define shutdown() params */
#ifndef SHUT_RDWR
#define SHUT_RDWR 2
#endif
/* cisco routers can clear the URG flag by default, so use in-band */
#define USE_KA_OOB 0
/* KA_TYPE: 1->only access points, 2->only proxies 3->both */
#define DEF_KA_TYPE 2
/* for listen() routine */
#define XPA_MAXLISTEN 1000
/* status flags for xpa server */
#define XPA_STATUS_ACTIVE 1
#define XPA_STATUS_FREE 2
#define XPA_STATUS_READBUF 4
#define XPA_STATUS_ENDBUF 8
/* status flags for xpa clients */
#define XPA_CLIENT_IDLE 0
#define XPA_CLIENT_ACTIVE 1
#define XPA_CLIENT_PROCESSING 2
#define XPA_CLIENT_WAITING 3
/* server mode flags for receive, send, info */
/* crafted so that they are turned on by default */
#define XPA_MODE_BUF 1
#define XPA_MODE_FILLBUF 2
#define XPA_MODE_FREEBUF 4
#define XPA_MODE_ACL 8
/* default modes for receive, send, info */
#define XPA_DEF_MODE_REC (XPA_MODE_BUF|XPA_MODE_FILLBUF|XPA_MODE_FREEBUF|XPA_MODE_ACL)
#define XPA_DEF_MODE_SEND (XPA_MODE_BUF|XPA_MODE_FREEBUF|XPA_MODE_ACL)
#define XPA_DEF_MODE_INFO (XPA_MODE_ACL)
/* default client info string */
#define XPA_DEF_CLIENT_INFO "NONE"
/* client mode flags */
#define XPA_CLIENT_BUF 1
#define XPA_CLIENT_FD 2
#define XPA_CLIENT_ACK 4
#define XPA_CLIENT_VERIFY 8
/* client select mode flags */
#define XPA_CLIENT_SEL_XPA 1
#define XPA_CLIENT_SEL_FORK 2
/* error codes -- these must match the strings in xpaMessbuf in xpa.c */
/* always make 0 an OK return */
#define XPA_RTN_OK 0
#define XPA_RTN_NOAUTH 1
#define XPA_RTN_NOCONN 2
#define XPA_RTN_NOHOST 3
#define XPA_RTN_NOBUF 4
#define XPA_RTN_NOCMD 5
#define XPA_RTN_NOREC 6
#define XPA_RTN_NOSEND 7
#define XPA_RTN_NOINFO 8
#define XPA_RTN_UNCMD 9
#define XPA_RTN_NOCMD2 10
#define XPA_RTN_NOTARG 11
#define XPA_RTN_NOCMD3 12
#define XPA_RTN_NODATA 13
#define XPA_RTN_ILLCMD 14
/* connection methods */
#define XPA_INET 1
#define XPA_UNIX 2
/* select loop types */
#define XPA_XPA_LOOP 1
#define XPA_XT_LOOP 2
#define XPA_TCL_LOOP 3
/* name server management */
#define XPA_NSINET "$host:$port"
#define XPA_NSPORT 14285
#define XPA_NSUNIX "xpans_unix"
#define XPA_RETRIES 10
#define XPA_NSDELAY 150
/* access control */
#define XPA_ACLS "gisa"
#define XPA_ACLFILE "$HOME/acls.xpa"
#define XPA_DEFACL "*:* $host +; *:* $localhost +"
/* port management */
#define XPA_DEFPORT 28571
#define XPA_PORTFILE "$HOME/ports.xpa"
/* misc */
#define XPA_IOSIZE 4096
#define XPA_BIOSIZE 204800
#ifndef HAVE_CYGWIN
#define XPA_CONNECT_TIMEOUT_MODE 1
#else
/* cygwin does not support interruptible connect(), so we have
to use non-blocking connect, which is less portable in general */
#define XPA_CONNECT_TIMEOUT_MODE 2
#endif
/* these can be changed by user environment variable */
#define XPA_MAXHOSTS 100
#define XPA_SHORT_TIMEOUT 15
#define XPA_LONG_TIMEOUT 180
#define XPA_CONNECT_TIMEOUT 10
#define XPA_TMPDIR "/tmp/.xpa"
#define XPA_VERBOSITY 1
#define XPA_IOCALLSXPA 0
#define LOCALIP(ip) ((ip==gethostip("$localhost"))||(ip==gethostip("$host")))
#if HAVE_CYGWIN||HAVE_MINGW32
#define XPANSNAME "xpans.exe"
#else
#define XPANSNAME "xpans"
#endif
#define XPANS_CLASS "XPANS"
#define XPANS_NAME "xpans"
/* for debugging */
#define _sp XPALevelSpaces()
#include <xpa.h>
#endif /* __xpap.h */
|