More Sun OS crap.

This commit is contained in:
Nicholas Marriott 2008-06-18 20:11:25 +00:00
parent 0d5ad358ae
commit be53d7f298
9 changed files with 82 additions and 53 deletions

View File

@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.23 2008-06-18 19:52:29 nicm Exp $
# $Id: GNUmakefile,v 1.24 2008-06-18 20:11:25 nicm Exp $
.PHONY: clean
@ -7,7 +7,7 @@ VERSION= 0.4
DATE= $(shell date +%Y%m%d-%H%M)
DEBUG= 1
#DEBUG= 1
META?= \002
@ -55,7 +55,9 @@ ifeq ($(shell uname),SunOS)
INCDIRS+= -Icompat
SRCS+= compat/strtonum.c compat/daemon.c compat/forkpty-sunos.c
CFLAGS+= -DNO_STRTONUM -DNO_TREE_H -DNO_PATHS_H -DNO_SETPROCTITLE \
-DNO_DAEMON -DNO_FORKPTY
-DNO_DAEMON -DNO_FORKPTY -DNO_PROGNAME
LDFLAGS+= -L/opt/csw/lib
LIBS+= -lsocket -lnsl
endif
ifeq ($(shell uname),Darwin)
@ -71,7 +73,7 @@ SRCS+= compat/strlcpy.c compat/strlcat.c compat/strtonum.c
CFLAGS+= $(shell getconf LFS_CFLAGS) -D_GNU_SOURCE \
-DNO_STRLCPY -DNO_STRLCAT -DNO_STRTONUM -DNO_SETPROCTITLE \
-DNO_QUEUE_H -DNO_TREE_H -DUSE_PTY_H
LDFLAGS+= -lrt -lutil
LIBS+= -lrt -lutil
# Required for LLONG_MAX and friends
CFLAGS+= -std=c99
endif

View File

@ -1,4 +1,4 @@
/* $Id: buffer-poll.c,v 1.5 2008-05-31 20:04:15 nicm Exp $ */
/* $Id: buffer-poll.c,v 1.6 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -42,7 +42,8 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
ssize_t n;
log_debug("buffer_poll (%d): fd=%d, revents=%d; out=%zu in=%zu",
getpid(), pfd->fd, pfd->revents, BUFFER_USED(out), BUFFER_USED(in));
(int) getpid(),
pfd->fd, pfd->revents, BUFFER_USED(out), BUFFER_USED(in));
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
return (-1);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-option.c,v 1.29 2008-06-18 18:52:44 nicm Exp $ */
/* $Id: cmd-set-option.c,v 1.30 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -105,7 +105,7 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
struct options *oo;
const char *errstr;
u_int i;
int number, bool, key;
int number, flag, key;
u_char colour;
if (data == NULL)
@ -128,15 +128,15 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
if (errstr != NULL)
number = 0;
bool = -1;
flag = -1;
if (number == 1 || strcasecmp(data->value, "on") == 0 ||
strcasecmp(data->value, "yes") == 0)
bool = 1;
flag = 1;
else if (number == 0 || strcasecmp(data->value, "off") == 0 ||
strcasecmp(data->value, "no") == 0)
bool = 0;
flag = 0;
} else
bool = -2;
flag = -2;
if (strcmp(data->option, "prefix") == 0) {
if (data->value == NULL) {
@ -150,13 +150,13 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
}
options_set_key(oo, "prefix-key", key);
} else if (strcmp(data->option, "status") == 0) {
if (bool == -1) {
if (flag == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
if (bool == -2)
bool = !options_get_number(oo, "status-lines");
options_set_number(oo, "status-lines", bool);
if (flag == -2)
flag = !options_get_number(oo, "status-lines");
options_set_number(oo, "status-lines", flag);
recalculate_sizes();
} else if (strcmp(data->option, "status-fg") == 0) {
if (data->value == NULL) {
@ -273,13 +273,13 @@ cmd_set_option_exec(struct cmd *self, unused struct cmd_ctx *ctx)
}
options_set_number(oo, "status-interval", number);
} else if (strcmp(data->option, "set-titles") == 0) {
if (bool == -1) {
if (flag == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
if (bool == -2)
bool = !options_get_number(oo, "set-titles");
options_set_number(oo, "set-titles", bool);
if (flag == -2)
flag = !options_get_number(oo, "set-titles");
options_set_number(oo, "set-titles", flag);
} else {
ctx->error(ctx, "unknown option: %s", data->option);
return;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-window-option.c,v 1.8 2008-06-16 17:35:40 nicm Exp $ */
/* $Id: cmd-set-window-option.c,v 1.9 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -101,7 +101,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
struct winlink *wl;
struct session *s;
const char *errstr;
int number, bool;
int number, flag;
u_int i;
if (data == NULL)
@ -120,26 +120,26 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
if (data->value != NULL) {
number = strtonum(data->value, 0, INT_MAX, &errstr);
bool = -1;
flag = -1;
if (number == 1 || strcasecmp(data->value, "on") == 0 ||
strcasecmp(data->value, "yes") == 0)
bool = 1;
flag = 1;
else if (number == 0 || strcasecmp(data->value, "off") == 0 ||
strcasecmp(data->value, "no") == 0)
bool = 0;
flag = 0;
} else
bool = -2;
flag = -2;
if (strcmp(data->option, "monitor-activity") == 0) {
if (bool == -1) {
if (flag == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
if (bool == -2)
if (flag == -2)
wl->window->flags ^= WINDOW_MONITOR;
else {
if (bool)
if (flag)
wl->window->flags |= WINDOW_MONITOR;
else
wl->window->flags &= ~WINDOW_MONITOR;
@ -159,15 +159,15 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
session_alert_cancel(s, wl);
}
} else if (strcmp(data->option, "aggressive-resize") == 0) {
if (bool == -1) {
if (flag == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
if (bool == -2)
if (flag == -2)
wl->window->flags ^= WINDOW_AGGRESSIVE;
else {
if (bool)
if (flag)
wl->window->flags |= WINDOW_AGGRESSIVE;
else
wl->window->flags &= ~WINDOW_AGGRESSIVE;

View File

@ -29,10 +29,13 @@
*/
#include <fcntl.h>
#include <paths.h>
#include <unistd.h>
#include <stdlib.h>
#ifndef NO_PATHS_H
#include <paths.h>
#endif
#include "tmux.h"
int

View File

@ -1,4 +1,4 @@
/* $Id: forkpty-sunos.c,v 1.1 2008-06-18 19:52:29 nicm Exp $ */
/* $Id: forkpty-sunos.c,v 1.2 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -18,15 +18,20 @@
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stropts.h>
#include <unistd.h>
#include "tmux.h"
pid_t
forkpty(int *master, int *slave,
char *name, struct termios *tio, struct winsize *ws)
forkpty(int *master,
unused char *name, unused struct termios *tio, struct winsize *ws)
{
int slave;
char *path;
pid_t pid;
if ((*master = open("/dev/ptmx", O_RDWR)) == -1)
return (-1);
@ -37,13 +42,16 @@ forkpty(int *master, int *slave,
if ((path = ptsname(*master)) == NULL)
goto out;
if ((*slave = open(path, O_RDWR)) == -1)
if ((slave = open(path, O_RDWR)) == -1)
goto out;
if (ioctl(*slave, I_PUSH, "ptem") == -1)
goto out;
if (ioctl(*slave, I_PUSH, "ldterm") == -1)
goto out;
if (ioctl(slave, I_PUSH, "ptem") == -1)
fatal("ioctl failed");
if (ioctl(slave, I_PUSH, "ldterm") == -1)
fatal("ioctl failed");
if (ioctl(slave, TIOCSWINSZ, ws) == -1)
fatal("ioctl failed");
switch (pid = fork()) {
case -1:
@ -53,13 +61,13 @@ forkpty(int *master, int *slave,
return (0);
}
close(*slave);
close(slave);
return (pid);
out:
if (*master != -1)
close(*master);
if (*slave != -1)
close(*slave);
if (slave != -1)
close(slave);
return (-1);
}

6
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.59 2008-06-18 19:34:50 nicm Exp $ */
/* $Id: tmux.c,v 1.60 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -56,6 +56,10 @@ int be_quiet;
void sighandler(int);
__dead void usage(void);
#ifdef NO_PROGNAME
const char *__progname = "tmux";
#endif
__dead void
usage(void)
{

21
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.148 2008-06-18 19:52:29 nicm Exp $ */
/* $Id: tmux.h,v 1.149 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -36,22 +36,31 @@
#include "compat/tree.h"
#endif
#include <curses.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <term.h>
#include "array.h"
extern char *__progname;
extern const char *__progname;
#ifndef INFTIM
#define INFTIM -1
#endif
#ifndef WAIT_ANY
#define WAIT_ANY -1
#endif
#ifndef SUN_LEN
#define SUN_LEN(sun) (sizeof (sun)->sun_path)
#endif
#ifndef __dead
#define __dead __attribute__ ((__noreturn__))
#endif
@ -73,6 +82,7 @@ extern char *__progname;
#ifdef NO_PATHS_H
#define _PATH_BSHELL "/bin/sh"
#define _PATH_TMP "/tmp/"
#define _PATH_DEVNULL "/dev/null"
#endif
/* Default configuration file. */
@ -762,13 +772,12 @@ size_t strlcat(char *, const char *, size_t);
#ifdef NO_DAEMON
/* daemon.c */
size_t daemon(int, int);
int daemon(int, int);
#endif
#ifdef NO_FORKPTY
/* forkpty.c */
pid_t forkpty(
int *, int *, char *, struct termios *, struct winsize *);
pid_t forkpty(int *, char *, struct termios *, struct winsize *);
#endif
/* tmux.c */

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.42 2008-06-18 19:34:50 nicm Exp $ */
/* $Id: window.c,v 1.43 2008-06-18 20:11:25 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -37,9 +37,11 @@
#ifdef USE_PTY_H
#include <pty.h>
#else
#ifndef NO_FORKPTY
#include <util.h>
#endif
#endif
#endif
#include "tmux.h"
@ -185,7 +187,7 @@ window_create(const char *name,
fatal("putenv failed");
}
sigreset();
log_debug("started child: cmd=%s; pid=%d", cmd, getpid());
log_debug("started child: cmd=%s; pid=%d", cmd, (int) getpid());
log_close();
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);