From 4e8f7f93ee4387a5f49ebb01e0135c247aaa9094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Mon, 13 Sep 2021 21:48:24 +0200 Subject: Fix OS X compatibility 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). --- rtty.c | 22 ++++++++++++---------- 1 file 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 #include +#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 * -- cgit v1.2.3