diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-18 20:11:25 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-18 20:11:25 +0000 |
commit | be53d7f298bb81297ff0d186f9ddb585a2e57198 (patch) | |
tree | f461c861805dc1694884e772a7c07bfe64f14a3d | |
parent | 0d5ad358ae3bc80cbf226f5aef5790ca1e1f430c (diff) |
More Sun OS crap.
-rw-r--r-- | GNUmakefile | 10 | ||||
-rw-r--r-- | buffer-poll.c | 5 | ||||
-rw-r--r-- | cmd-set-option.c | 28 | ||||
-rw-r--r-- | cmd-set-window-option.c | 24 | ||||
-rw-r--r-- | compat/daemon.c | 5 | ||||
-rw-r--r-- | compat/forkpty-sunos.c | 30 | ||||
-rw-r--r-- | tmux.c | 6 | ||||
-rw-r--r-- | tmux.h | 21 | ||||
-rw-r--r-- | window.c | 6 |
9 files changed, 82 insertions, 53 deletions
diff --git a/GNUmakefile b/GNUmakefile index 8d5b659e..52a30441 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 diff --git a/buffer-poll.c b/buffer-poll.c index 5e37bead..37a6b4c0 100644 --- a/buffer-poll.c +++ b/buffer-poll.c @@ -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); diff --git a/cmd-set-option.c b/cmd-set-option.c index f9242ae4..36e8fffd 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -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; diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c index f762c117..0565d892 100644 --- a/cmd-set-window-option.c +++ b/cmd-set-window-option.c @@ -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; diff --git a/compat/daemon.c b/compat/daemon.c index 420f58dc..06384ec8 100644 --- a/compat/daemon.c +++ b/compat/daemon.c @@ -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 diff --git a/compat/forkpty-sunos.c b/compat/forkpty-sunos.c index 115807d8..27a44bc2 100644 --- a/compat/forkpty-sunos.c +++ b/compat/forkpty-sunos.c @@ -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); } @@ -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) { @@ -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 */ @@ -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); |