Discontinue HPUX support
This commit is contained in:
@@ -35,14 +35,6 @@
|
||||
|
||||
#define __need_fd_set
|
||||
|
||||
#if defined(hpux) || defined(_hpux) || defined(__hpux) || defined(hp)
|
||||
#define __hpux_pty
|
||||
#endif
|
||||
|
||||
#ifdef __hpux_pty
|
||||
#define __need_timeval /* need struct timeval */
|
||||
#endif
|
||||
|
||||
#include <bms/sbport.h> /* NOTE: sbport.h must be the first include. */
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
@@ -56,11 +48,6 @@
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#ifdef __hpux_pty
|
||||
#include <time.h>
|
||||
#include <sys/ptyio.h>
|
||||
#endif
|
||||
|
||||
#ifdef __bsd
|
||||
#include <sys/file.h>
|
||||
#include <sgtty.h>
|
||||
@@ -165,28 +152,6 @@ pty_channel_clasp pty_channel_class = &pty_channel_class_struct;
|
||||
/* Local variable */
|
||||
static XeChar *hexdigits = "0123456789abcdef";
|
||||
|
||||
#ifdef __hpux_pty
|
||||
/*----------------------------------------------------------------------+*/
|
||||
static SPC_Disable_Trapping(int fd)
|
||||
/*----------------------------------------------------------------------+*/
|
||||
{
|
||||
int flag=0;
|
||||
int disable=0;
|
||||
struct request_info req_info;
|
||||
|
||||
/* Disable trapping */
|
||||
ioctl(fd, TIOCTRAP, &disable);
|
||||
|
||||
/* Just in case, flush any queued requests */
|
||||
|
||||
while((ioctl(fd, TIOCTRAPSTATUS, &flag) != ERROR) && flag) {
|
||||
ioctl(fd, TIOCREQGET, &req_info);
|
||||
ioctl(fd, TIOCREQSET, &req_info);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
/*
|
||||
* Routines for opening pty master/slave devices
|
||||
*/
|
||||
@@ -384,14 +349,6 @@ int master_pty(int fd, struct termios *state)
|
||||
if (fd < 0)
|
||||
return(TRUE);
|
||||
|
||||
#ifdef __hpux_pty
|
||||
/* Enable trapping of ioctl/open/close (we care about close()) */
|
||||
if(ioctl(fd, TIOCTRAP, &enable)==ERROR) {
|
||||
SPC_Error(SPC_Bad_Ioctl);
|
||||
return(SPC_ERROR);
|
||||
}
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
set_pty_state(fd, state);
|
||||
|
||||
|
||||
@@ -510,91 +467,6 @@ int read_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
XeString buffer,
|
||||
int nbytes)
|
||||
/*----------------------------------------------------------------------+*/
|
||||
#ifdef __hpux_pty
|
||||
{
|
||||
|
||||
int result, select_value;
|
||||
struct fd_set read_mask, except_mask;
|
||||
int fd=channel->file_descs[connector];
|
||||
struct request_info req_info;
|
||||
struct timeval timeout, *timeptr;
|
||||
int i;
|
||||
|
||||
call_parent_method(channel,
|
||||
read,
|
||||
(channel, connector, buffer, nbytes),
|
||||
result);
|
||||
|
||||
if(result==SPC_ERROR)
|
||||
return(SPC_ERROR);
|
||||
|
||||
if(!IS_SPCIO_DATA(channel->wires[connector]->flags))
|
||||
return(0);
|
||||
|
||||
FD_ZERO(&read_mask);
|
||||
FD_ZERO(&except_mask);
|
||||
|
||||
FD_SET(fd, &read_mask);
|
||||
FD_SET(fd, &except_mask);
|
||||
|
||||
if(channel->close_timeout) {
|
||||
timeout.tv_sec=channel->close_timeout;
|
||||
timeout.tv_usec=0;
|
||||
timeptr = (&timeout);
|
||||
} else
|
||||
timeptr=NULL;
|
||||
|
||||
do
|
||||
select_value=select(fd+1, &read_mask, NULL, &except_mask, timeptr);
|
||||
while(select_value==ERROR && errno==EINTR);
|
||||
|
||||
if(select_value==ERROR) {
|
||||
SPC_Error(SPC_Bad_Select);
|
||||
return(SPC_ERROR);
|
||||
}
|
||||
|
||||
/* If there is anything to read, read it & return */
|
||||
IS_FD_SET(&read_mask, result);
|
||||
if(result) {
|
||||
do {
|
||||
result = read(fd, buffer, nbytes);
|
||||
} while (result<0 && errno == EINTR);
|
||||
if(result==ERROR) {
|
||||
SPC_Error(SPC_Reading);
|
||||
return(SPC_ERROR);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
/* Nothing to read. We either timed out or got an exception. */
|
||||
|
||||
if(select_value != 0) {
|
||||
|
||||
/* We got an exception */
|
||||
ioctl(fd, TIOCREQGET, &req_info);
|
||||
|
||||
/* Clear the request (Not really necessary in the case of a close,
|
||||
but do it anyway) */
|
||||
|
||||
ioctl(fd, TIOCREQSET, &req_info);
|
||||
}
|
||||
|
||||
if((select_value == 0) || (req_info.request == TIOCCLOSE)) {
|
||||
|
||||
/* Close, disable trapping on this fd & return EOF. We regard
|
||||
a timeout as being the same as a close. */
|
||||
|
||||
SPC_Disable_Trapping(fd);
|
||||
SPC_Change_State(channel, connector, 0, -1);
|
||||
return(0);
|
||||
|
||||
} else
|
||||
|
||||
/* Otherwise (open or IOCTL), return -1 */
|
||||
|
||||
return(EXCEPT_FLAG);
|
||||
}
|
||||
#else /* not __hpux_pty */
|
||||
{
|
||||
int result;
|
||||
int fd=channel->file_descs[connector];
|
||||
@@ -648,7 +520,6 @@ int read_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
|
||||
return(result);
|
||||
}
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
/*----------------------------------------------------------------------+*/
|
||||
int pre_fork_pty_channel_object(SPC_Channel_Ptr channel)
|
||||
@@ -671,38 +542,14 @@ int pre_fork_pty_channel_object(SPC_Channel_Ptr channel)
|
||||
result=SPC_ERROR;
|
||||
}
|
||||
|
||||
#ifndef __hpux_pty
|
||||
if(pipe(channel->sync_pipe) < 0) {
|
||||
SPC_Error(SPC_No_Pipe);
|
||||
return(SPC_ERROR);
|
||||
}
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
#ifdef __hpux_pty
|
||||
/*----------------------------------------------------------------------+*/
|
||||
/* clear_trap */
|
||||
/*----------------------------------------------------------------------+*/
|
||||
|
||||
/* I am not particularly enamored of this macro. However, the style of
|
||||
the SCANBITS macro kinda forces me to write it this way. In particular,
|
||||
I am a bit worried about the reference to except_mask, which is a
|
||||
"nonlocal reference" */
|
||||
|
||||
#define clear_trap(fd) {struct request_info req_info; \
|
||||
int my_fd=(fd); \
|
||||
ioctl(my_fd, TIOCREQGET, &req_info); \
|
||||
if(req_info.request != TIOCOPEN) { \
|
||||
SPC_Error(SPC_Bad_Ioctl); \
|
||||
return(SPC_ERROR); \
|
||||
} \
|
||||
ioctl(my_fd, TIOCREQSET, &req_info); \
|
||||
FD_CLR(my_fd, &except_mask); \
|
||||
}
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
/*----------------------------------------------------------------------+*/
|
||||
int post_fork_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
int parentp)
|
||||
@@ -714,9 +561,6 @@ int post_fork_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
int iomode=channel->IOMode;
|
||||
int fd=channel->file_descs[STDIN];
|
||||
int stdinfd, stdoutfd, stderrfd;
|
||||
#ifdef __hpux_pty
|
||||
struct fd_set except_mask, temp_mask;
|
||||
#endif
|
||||
int pid;
|
||||
char c;
|
||||
|
||||
@@ -726,40 +570,12 @@ int post_fork_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
return(SPC_ERROR);
|
||||
|
||||
if (parentp) { /* Master process */
|
||||
#ifdef __hpux_pty
|
||||
{ int i;
|
||||
int select_value;
|
||||
|
||||
stdinfd = channel->wires[STDIN]->fd[MASTER_SIDE];
|
||||
stdoutfd = channel->wires[STDOUT]->fd[MASTER_SIDE];
|
||||
stderrfd = channel->wires[STDERR]->fd[MASTER_SIDE];
|
||||
|
||||
FD_ZERO(&except_mask);
|
||||
|
||||
if(stdinfd >= 0)
|
||||
FD_SET(stdinfd, &except_mask);
|
||||
if(stdoutfd >= 0)
|
||||
FD_SET(stdoutfd, &except_mask);
|
||||
if(stderrfd >= 0)
|
||||
FD_SET(stderrfd, &except_mask);
|
||||
|
||||
IS_FD_SET(&except_mask, result);
|
||||
while (result) {
|
||||
temp_mask = except_mask;
|
||||
select_value=select(max_fds, NULL, NULL, &temp_mask, NULL);
|
||||
SCANBITS(&temp_mask, clear_trap);
|
||||
IS_FD_SET(&except_mask, result);
|
||||
}
|
||||
}
|
||||
#else /* not __hpux_pty */
|
||||
close(channel->sync_pipe[WRITE_SIDE]);
|
||||
read(channel->sync_pipe[READ_SIDE], &c, 1);
|
||||
close(channel->sync_pipe[READ_SIDE]);
|
||||
channel->sync_pipe[READ_SIDE] = -1;
|
||||
channel->sync_pipe[WRITE_SIDE] = -1;
|
||||
XeSPCAddInput(channel, NULL, NULL);
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
} else { /* Slave process */
|
||||
|
||||
/* Open the slave pty. Do it up to three times to set up
|
||||
@@ -811,14 +627,12 @@ int post_fork_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
stderrfd=stdoutfd;
|
||||
}
|
||||
|
||||
#ifndef __hpux_pty
|
||||
/* The pty trapping stuff handles EOF for us. Use the "sync" pipe */
|
||||
/* to inform the other side when we don't have that code. */
|
||||
c=040;
|
||||
write(channel->sync_pipe[WRITE_SIDE], &c, 1);
|
||||
close(channel->sync_pipe[READ_SIDE]);
|
||||
close(channel->sync_pipe[WRITE_SIDE]);
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
/* Duplicate these file descriptors to 3, 4, 5 so we don't have to
|
||||
worry about any of std[in|out|err]fd being 0, 1, or 2. */
|
||||
@@ -863,15 +677,6 @@ int reset_pty_channel_object(SPC_Channel_Ptr channel)
|
||||
|
||||
for(wirelist=channel->wire_list; wirelist; wirelist=wirelist->next) {
|
||||
|
||||
#ifdef __hpux_pty
|
||||
{
|
||||
int fd=wirelist->fd[MASTER_SIDE];
|
||||
/* Disable trapping of ioctl/open/close */
|
||||
if(SPC_Disable_Trapping(fd) == SPC_ERROR)
|
||||
result=SPC_ERROR;
|
||||
}
|
||||
#endif /* __hpux_pty */
|
||||
|
||||
wirelist->flags &= ~SPCIO_DATA;
|
||||
}
|
||||
|
||||
@@ -925,13 +730,6 @@ int add_input_pty_channel_object(SPC_Channel_Ptr channel,
|
||||
fd,
|
||||
channel->class_ptr->input,
|
||||
SPC_Input);
|
||||
#ifdef __hpux_pty
|
||||
SPC_XtAddInput(channel,
|
||||
&wirelist->except_toolkit_id,
|
||||
fd,
|
||||
channel->class_ptr->input,
|
||||
SPC_Exception);
|
||||
#endif /* __hpux_pty */
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
|
||||
@@ -603,11 +603,7 @@ int exec_proc_local_channel_object(SPC_Channel_Ptr channel)
|
||||
if(result!=SPC_ERROR) {
|
||||
/* Execute */
|
||||
/* Compiler barfs without cast ? */
|
||||
#if defined(__hpux_8_0) || defined(__aix)
|
||||
result=execvp(channel->path, channel->argv);
|
||||
#else
|
||||
result=execvp(channel->path, channel->argv);
|
||||
#endif
|
||||
/* If we return from exec, it failed */
|
||||
SPC_Error(SPC_Cannot_Exec, channel->path);
|
||||
}
|
||||
|
||||
@@ -90,55 +90,55 @@ static void Xe_init_sig_table(void)
|
||||
/* Now add signals that may or may not be around on a given platform */
|
||||
|
||||
# ifdef SIGIO
|
||||
Xe_addsig((XeString)"SIGIO", SIGIO); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGIO", SIGIO); /* sun */
|
||||
# else
|
||||
# ifdef SIGPOLL
|
||||
Xe_addsig((XeString)"SIGIO", SIGPOLL); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGIO", SIGPOLL); /* sun */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef SIGPOLL
|
||||
Xe_addsig((XeString)"SIGPOLL", SIGPOLL); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGPOLL", SIGPOLL); /* sun */
|
||||
# else
|
||||
# ifdef SIGIO
|
||||
Xe_addsig((XeString)"SIGPOLL", SIGIO); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGPOLL", SIGIO); /* sun */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef SIGEMT
|
||||
Xe_addsig((XeString)"SIGEMT", SIGEMT); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGEMT", SIGEMT); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGBUS
|
||||
Xe_addsig((XeString)"SIGBUS", SIGBUS); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGBUS", SIGBUS); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGIOT
|
||||
Xe_addsig((XeString)"SIGIOT", SIGIOT); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGIOT", SIGIOT); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGURG
|
||||
Xe_addsig((XeString)"SIGURG", SIGURG); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGURG", SIGURG); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGSYS
|
||||
Xe_addsig((XeString)"SIGSYS", SIGSYS); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGSYS", SIGSYS); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGTRAP
|
||||
Xe_addsig((XeString)"SIGTRAP", SIGTRAP); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGTRAP", SIGTRAP); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGPROF
|
||||
Xe_addsig((XeString)"SIGPROF", SIGPROF); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGPROF", SIGPROF); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGCLD
|
||||
Xe_addsig((XeString)"SIGCLD", SIGCLD); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGCLD", SIGCLD); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGVTALRM
|
||||
Xe_addsig((XeString)"SIGVTALRM", SIGVTALRM); /* hpux sun */
|
||||
Xe_addsig((XeString)"SIGVTALRM", SIGVTALRM); /* sun */
|
||||
# endif
|
||||
|
||||
# ifdef SIGWINCH
|
||||
@@ -204,56 +204,56 @@ XeString XeSignalToName(int sig)
|
||||
/* code to the stuff in Xe_init_sig_table() above, you see a one */
|
||||
/* to one correspondance. */
|
||||
|
||||
# ifdef SIGIO /* hpux sun */
|
||||
# ifdef SIGIO /* sun */
|
||||
/* (SIGPOLL, SIGTINT are aliases) */
|
||||
case SIGIO: return (XeString)"SIGIO";
|
||||
# endif
|
||||
|
||||
# ifdef SIGPOLL /* hpux sun */
|
||||
# ifdef SIGPOLL /* sun */
|
||||
/* ----> Duplicated by SIGIO above
|
||||
case SIGPOLL: return (XeString)"SIGPOLL";
|
||||
*/
|
||||
# endif
|
||||
|
||||
|
||||
# ifdef SIGEMT /* hpux sun */
|
||||
# ifdef SIGEMT /* sun */
|
||||
case SIGEMT: return (XeString)"SIGEMT";
|
||||
# endif
|
||||
|
||||
# ifdef SIGBUS /* hpux sun */
|
||||
# ifdef SIGBUS /* sun */
|
||||
case SIGBUS: return (XeString)"SIGBUS";
|
||||
# endif
|
||||
|
||||
# ifdef SIGIOT /* hpux sun */
|
||||
# ifdef SIGIOT /* sun */
|
||||
/* ----> Duplicated by SIGABRT above
|
||||
|
||||
case SIGIOT: return (XeString)"SIGIOT";
|
||||
*/
|
||||
# endif
|
||||
|
||||
# ifdef SIGURG /* hpux sun */
|
||||
# ifdef SIGURG /* sun */
|
||||
case SIGURG: return (XeString)"SIGURG";
|
||||
# endif
|
||||
|
||||
# ifdef SIGSYS /* hpux sun */
|
||||
# ifdef SIGSYS /* sun */
|
||||
case SIGSYS: return (XeString)"SIGSYS";
|
||||
# endif
|
||||
|
||||
# ifdef SIGTRAP /* hpux sun */
|
||||
# ifdef SIGTRAP /* sun */
|
||||
case SIGTRAP: return (XeString)"SIGTRAP";
|
||||
# endif
|
||||
|
||||
# ifdef SIGPROF /* hpux sun */
|
||||
# ifdef SIGPROF /* sun */
|
||||
case SIGPROF: return (XeString)"SIGPROF";
|
||||
# endif
|
||||
|
||||
# ifdef SIGCLD /* hpux sun */
|
||||
# ifdef SIGCLD /* sun */
|
||||
/* ----> Duplicated by SIGCHLD above
|
||||
case SIGCLD: return (XeString)"SIGCLD";
|
||||
*/
|
||||
# endif
|
||||
|
||||
# ifdef SIGVTALRM /* hpux sun */
|
||||
# ifdef SIGVTALRM /* sun */
|
||||
case SIGVTALRM: return (XeString)"SIGVTALRM";
|
||||
# endif
|
||||
|
||||
|
||||
@@ -73,14 +73,6 @@
|
||||
*/
|
||||
#define COMMAND_CHECK_FAILURE 1
|
||||
|
||||
#ifdef __hpux
|
||||
#ifdef hpV4
|
||||
#define INETD_SECURITY_FILE "/var/adm/inetd.sec"
|
||||
#else /* hpV4 */
|
||||
#define INETD_SECURITY_FILE "/usr/adm/inetd.sec"
|
||||
#endif /* hpV4 */
|
||||
#endif /* __hpux */
|
||||
|
||||
#define Cmd_FreeAllocatedStringVector(sv) \
|
||||
_DtCmdFreeStringVector(sv);\
|
||||
XtFree((char *)sv);
|
||||
@@ -337,24 +329,11 @@ _DtSPCOpen(
|
||||
SPC_BUFSIZ);
|
||||
break;
|
||||
case SPC_Connection_EOF:
|
||||
#ifdef __hpux
|
||||
(void) sprintf (errorMessage,
|
||||
errorInetSecurity,
|
||||
hostname,
|
||||
_cmdClientHost,
|
||||
SPC_SERVICE,
|
||||
_cmdClientHost,
|
||||
SPC_SERVICE,
|
||||
INETD_SECURITY_FILE,
|
||||
hostname);
|
||||
|
||||
#else /* __hpux */
|
||||
(void) sprintf (errorMessage,
|
||||
errorBadConnect,
|
||||
hostname,
|
||||
SPC_SERVICE,
|
||||
_cmdClientHost);
|
||||
#endif /* __hpux */
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
|
||||
@@ -45,10 +45,6 @@
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined(__hpux)
|
||||
#include <sys/getaccess.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
@@ -49,18 +49,12 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __hpux
|
||||
#include <ndir.h>
|
||||
#else
|
||||
|
||||
#if defined(sun) || defined(CSRG_BASED)
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif /* sun || CSRD_BASED */
|
||||
|
||||
#endif /* __hpux */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -54,12 +54,7 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#if defined (__hpux)
|
||||
/*
|
||||
* On HP MAXINT is defined in both <values.h> and <sys/param.h>
|
||||
*/
|
||||
#undef MAXINT
|
||||
#elif defined(CSRG_BASED)
|
||||
#if defined(CSRG_BASED)
|
||||
#define MAXINT INT_MAX
|
||||
#else
|
||||
#include <values.h>
|
||||
|
||||
@@ -47,18 +47,12 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __hpux
|
||||
#include <ndir.h>
|
||||
#else
|
||||
|
||||
#if defined(sun) || defined(CSRG_BASED)
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif /* sun || CSRG_BASED */
|
||||
|
||||
#endif /* __hpux */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -37,15 +37,11 @@
|
||||
#include <sys/param.h> /* MAXPATHLEN */
|
||||
#include <errno.h> /* errno(2) */
|
||||
|
||||
#ifdef __hpux
|
||||
#include <ndir.h> /* opendir(), directory(3C) */
|
||||
#else
|
||||
#if defined(sun) || defined(CSRG_BASED)
|
||||
#include <dirent.h> /* opendir(), directory(3C) */
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif /* sun || CSRG_BASED */
|
||||
#endif /* __hpux */
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Intrinsic.h> /* Xt stuff */
|
||||
|
||||
@@ -44,116 +44,10 @@
|
||||
#else
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <DtSvcLock.h>
|
||||
#endif /* NO_XLIB */
|
||||
#endif
|
||||
|
||||
#include <Dt/MsgCatP.h>
|
||||
|
||||
#if defined(hpV4) && !defined(NO_XLIB)
|
||||
typedef struct _dt_msg_cache
|
||||
{
|
||||
char ***cached_msgs;
|
||||
int nmsgs_per_set;
|
||||
int nsets;
|
||||
|
||||
nl_catd catd;
|
||||
struct _dt_msg_cache *next;
|
||||
} _DtMsgCache;
|
||||
|
||||
static _DtMsgCache *catalog_message_caches = NULL;
|
||||
|
||||
static _DtMsgCache *get_msg_cache(nl_catd catd)
|
||||
{
|
||||
const int initial_nmsgs_per_set = 300;
|
||||
const int initial_nsets = 50;
|
||||
|
||||
_DtMsgCache *c;
|
||||
|
||||
for (c=catalog_message_caches; NULL!=c; c=c->next)
|
||||
if (catd == c->catd) return c;
|
||||
|
||||
c = (_DtMsgCache*) XtMalloc(sizeof(_DtMsgCache));
|
||||
c->cached_msgs = NULL;
|
||||
c->nmsgs_per_set = initial_nmsgs_per_set;
|
||||
c->nsets = initial_nsets;
|
||||
c->catd = catd;
|
||||
c->next = catalog_message_caches;
|
||||
catalog_message_caches = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper around catgets -- this makes sure the message string is saved
|
||||
* in a safe location; so repeated calls to catgets() do not overwrite
|
||||
* the catgets() internal buffer. This has been a problem on HP systems.
|
||||
*/
|
||||
char *_DtCatgetsCached(nl_catd catd, int set, int num, const char *dflt)
|
||||
{
|
||||
char *message = NULL;
|
||||
_DtMsgCache *c;
|
||||
char **setptr;
|
||||
int i, multiplier;
|
||||
int size;
|
||||
|
||||
/* convert to a zero based index */
|
||||
int setIdx = set - 1;
|
||||
int numIdx = num - 1;
|
||||
|
||||
c = get_msg_cache(catd);
|
||||
if (NULL == c)
|
||||
{
|
||||
message = catgets(catd, set, num, dflt);
|
||||
return message;
|
||||
}
|
||||
|
||||
if (NULL == c->cached_msgs)
|
||||
{
|
||||
size = sizeof(char**) * c->nsets;
|
||||
c->cached_msgs = (char***) XtMalloc(size);
|
||||
memset((char*) c->cached_msgs, 0, size);
|
||||
}
|
||||
else if (setIdx >= c->nsets)
|
||||
{
|
||||
for (multiplier=2; setIdx > multiplier*c->nsets; multiplier++) {}
|
||||
size = sizeof(char**) * c->nsets;
|
||||
c->cached_msgs =
|
||||
(char***) XtRealloc((char*) c->cached_msgs, multiplier*size);
|
||||
memset((char*) (c->cached_msgs + size), 0, multiplier*size);
|
||||
c->nsets *= multiplier;
|
||||
}
|
||||
|
||||
if (NULL == c->cached_msgs[setIdx])
|
||||
{
|
||||
size = sizeof(char*) * c->nmsgs_per_set;
|
||||
c->cached_msgs[setIdx] = (char**) XtMalloc(size);
|
||||
memset((char*) c->cached_msgs[setIdx], 0, size);
|
||||
}
|
||||
else if (numIdx >= c->nmsgs_per_set)
|
||||
{
|
||||
for (multiplier=2; numIdx > multiplier*c->nsets; multiplier++) {}
|
||||
size = sizeof(char*) * c->nmsgs_per_set;
|
||||
|
||||
for (i=0; i<c->nmsgs_per_set; i++)
|
||||
{
|
||||
if (NULL != c->cached_msgs[i])
|
||||
{
|
||||
c->cached_msgs[i] =
|
||||
(char**) XtRealloc((char*)c->cached_msgs[i], multiplier*size);
|
||||
memset((char*) (c->cached_msgs[i] + size), 0, multiplier*size);
|
||||
}
|
||||
}
|
||||
c->nmsgs_per_set *= multiplier;
|
||||
}
|
||||
|
||||
setptr = c->cached_msgs[setIdx];
|
||||
if (NULL == setptr[numIdx])
|
||||
setptr[numIdx] = strdup(catgets(catd, set, num, dflt));
|
||||
|
||||
message = setptr[numIdx];
|
||||
|
||||
return message;
|
||||
}
|
||||
#endif /* hpV4 */
|
||||
|
||||
int _DtCatclose(nl_catd catd)
|
||||
{
|
||||
return (catd == (nl_catd) -1) ? 0 : catclose(catd);
|
||||
@@ -169,11 +63,7 @@ char *_DtCatgets(nl_catd catd, int set, int num, const char *dflt)
|
||||
} else {
|
||||
/* Per POSIX, we cannot assume catgets() is thread-safe. */
|
||||
_DtSvcProcessLock();
|
||||
#if defined(hpV4) && !defined(NO_XLIB)
|
||||
msg = _DtCatgetsCached(catd, set, num, dflt);
|
||||
#else
|
||||
msg = catgets(catd, set, num, dflt);
|
||||
#endif /* hpV4 */
|
||||
_DtSvcProcessUnlock();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,15 +35,11 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __hpux
|
||||
#include <ndir.h>
|
||||
#else
|
||||
#if defined(sun) || defined(CSRG_BASED)
|
||||
#include <dirent.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef NLS16
|
||||
|
||||
@@ -124,11 +124,11 @@ inline void strfree(const char *s)
|
||||
{ if (s != NULL) free((char *)s); }
|
||||
#else
|
||||
inline void strfree(const char *s)
|
||||
#if defined(__hpux) || defined(CSRG_BASED)
|
||||
#if defined(CSRG_BASED)
|
||||
{ if (s != NULL) free((void *)s); }
|
||||
#else
|
||||
{ if (s != NULL) free((void *)s); }
|
||||
#endif /* __hpux */
|
||||
#endif /* bsd */
|
||||
#endif
|
||||
#if defined(bsd)
|
||||
inline char *strdup(const char *s)
|
||||
|
||||
@@ -1106,10 +1106,7 @@ internalC++ xalloc::xalloc(const char*,unsigned int)
|
||||
#endif
|
||||
|
||||
/* This symbol does not get mangled consistently across platforms.
|
||||
#ifdef hpV4
|
||||
internalC++ shellscan_C_000046c7_parsemeta_:__std
|
||||
internal __link__std__shellscan_C_000046c7_parsemeta_
|
||||
#elif defined(sun)
|
||||
#if defined(sun)
|
||||
internalC++ shellscan_C:__std
|
||||
#elif defined(_AIX)
|
||||
internalC++ __sterm80000000_x_2fproj_2fcde_2flib_2fDtSvc_2fDtCodelibs_2fshellscan_2eC()
|
||||
|
||||
Reference in New Issue
Block a user