aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-09-13 21:48:24 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-09-13 21:48:24 +0200
commit4e8f7f93ee4387a5f49ebb01e0135c247aaa9094 (patch)
treef20e17b4ea8023f2eed1aa9d5b0d9e8468d146a9
parentbb6915834ba92f4148164725c4c27e38555c0685 (diff)
downloadrtty-master.tar.gz
Fix OS X compatibilityHEADmaster
As it turns out, dprintf is pretty new. WALLSIG seems unnecessary here and does not seem to be available on OS X (at least on 10.4).
-rw-r--r--rtty.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/rtty.c b/rtty.c
index 5d380c2..453f59e 100644
--- a/rtty.c
+++ b/rtty.c
@@ -11,6 +11,8 @@
#include <termios.h>
#include <unistd.h>
+#define DPUTS(d, s) write(d, s, strlen(s))
+
#define INIT "export TERM=tty43 EDITOR=ed PAGER=cat\n"
#define IINIT "export EDITOR=ed PAGER=ul\n"
@@ -105,9 +107,9 @@ main(int argc, char *argv[])
/* Initialize remote environment. */
if(interactive)
- dprintf(fdin, IINIT);
+ DPUTS(fdin, IINIT);
else
- dprintf(fdin, INIT);
+ DPUTS(fdin, INIT);
FD_ZERO(&rfds0);
FD_ZERO(&rfds1);
@@ -135,7 +137,7 @@ main(int argc, char *argv[])
|| strcmp(bufout+strlen(bufout)-2, "# ") == 0))
goto escape;
- dprintf(fdin, "%s", bufin);
+ DPUTS(fdin, bufin);
continue;
escape:
@@ -143,7 +145,7 @@ escape:
* Get remote working directory. (The response
* looks like "pwd\n(directory)\n(prompt)".)
*/
- dprintf(fdin, "pwd\n");
+ DPUTS(fdin, "pwd\n");
for(i = 0; i < MAXWD-1; i++){
read(fdout, wd, 1);
if(*wd == '\n') break;
@@ -199,7 +201,7 @@ found:
execlp("scp", "scp", p, ".", NULL);
err(1, "scp");
}
- waitpid(child, &s, WALLSIG);
+ waitpid(child, &s, 0);
if(WIFEXITED(s) && WEXITSTATUS(s)){
fprintf(stderr, "scp terminated abnormally\n");
fprintf(stderr, "file saved in %s\n", dir);
@@ -212,7 +214,7 @@ found:
execvp(eargv[0], eargv);
err(1, "%s", eargv[0]);
}
- waitpid(child, &s, WALLSIG);
+ waitpid(child, &s, 0);
if(WIFEXITED(s) && WEXITSTATUS(s)){
fprintf(stderr, "%s terminated abnormally\n",
eargv[0]);
@@ -225,7 +227,7 @@ found:
execlp("scp", "scp", eargv[i], p, NULL);
err(1, "scp");
}
- waitpid(child, &s, WALLSIG);
+ waitpid(child, &s, 0);
if(WIFEXITED(s) && WEXITSTATUS(s)){
fprintf(stderr, "scp terminated abnormally\n");
fprintf(stderr, "file saved in %s\n", dir);
@@ -240,7 +242,7 @@ done:
free(p);
/* Trigger new remote shell prompt. */
- dprintf(fdin, "\n");
+ DPUTS(fdin, "\n");
}
/*
@@ -299,12 +301,12 @@ done:
|| strstr(q, "pass phrase")
|| strstr(q, "Pass phrase")){
getpw(pw);
- dprintf(fdin, "%s\n", pw);
+ DPUTS(fdin, pw);
+ DPUTS(fdin, "\n");
}
}
}
}
-
}
char *