From a24f31ec316a25bb1805d205b80b326098330086 Mon Sep 17 00:00:00 2001 From: fredrik Date: Tue, 29 May 2007 14:28:41 +0000 Subject: [PATCH] Add dcsh files. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@1044 959494ce-11ee-0310-bf91-de5d638817bd --- clients/Makefile.am | 2 +- clients/tty/Makefile.am | 6 +++ clients/tty/dcsh.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ configure.in | 3 +- lib/uilib.c | 1 + 5 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 clients/tty/Makefile.am create mode 100644 clients/tty/dcsh.c diff --git a/clients/Makefile.am b/clients/Makefile.am index 5c7dffc..742729f 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS=@clients@ -DIST_SUBDIRS=gtk2 gnome-trans-applet gaim +DIST_SUBDIRS=gtk2 tty gnome-trans-applet gaim EXTRA_DIST=hellodolda.png iconsdir = $(datadir)/pixmaps diff --git a/clients/tty/Makefile.am b/clients/tty/Makefile.am new file mode 100644 index 0000000..e8b7cd7 --- /dev/null +++ b/clients/tty/Makefile.am @@ -0,0 +1,6 @@ +noinst_PROGRAMS=dcsh + +dcsh_SOURCES=dcsh.c + +dcsh_LDADD=$(top_srcdir)/lib/libdcui.la +AM_CPPFLAGS=-I$(top_srcdir)/include diff --git a/clients/tty/dcsh.c b/clients/tty/dcsh.c new file mode 100644 index 0000000..2c35086 --- /dev/null +++ b/clients/tty/dcsh.c @@ -0,0 +1,106 @@ +/* + * Dolda Connect - Modular multiuser Direct Connect-style client + * Copyright (C) 2007 Fredrik Tolf (fredrik@dolda2000.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +int verbose = 0; +int dcfd; + +int main(int argc, char **argv) +{ + int c; + char *server; + char *username; + int authless, authia; + struct pollfd pfd[2]; + int done; + char cmdbuf[128]; + int cmddata; + + server = username = NULL; + authless = authia = 1; + while((c = getopt(argc, argv, "hvIAs:u:")) != -1) { + switch(c) { + case 's': + server = optarg; + break; + case 'u': + username = optarg; + break; + case 'I': + authia = 0; + break; + case 'A': + authless = 0; + break; + case 'v': + verbose++; + break; + default: + fprintf(stderr, "usage: dcsh [-AIhv] [-s SERVER] [-u USERNAME]\n"); + exit((c == 'h')?0:1); + } + } + dc_init(); + + if(verbose) + fprintf(stderr, "connecting...\n"); + if((dcfd = dc_connectsync2(server, 1)) < 0) { + perror("dcsh: could not connect to server"); + exit(1); + } + if(verbose) + fprintf(stderr, "authenticating...\n"); + if(dc_login(username, authless, authia?dc_convtty:dc_convnone, NULL) != DC_LOGIN_ERR_SUCCESS) { + fprintf(stderr, "dcsh: authentication unsuccessful\n"); + exit(1); + } + if(verbose) + fprintf(stderr, "done\n"); + done = 0; + cmddata = 0; + while(!done) { + pfd[0].fd = dcfd; + pfd[0].events = POLLIN; + if(dc_wantwrite()) + pfd[0].events |= POLLOUT; + pfd[1].fd = 0; + pfd[1].events = POLLIN; + pfd[1].revents = 0; + if(poll(pfd, (cmddata < sizeof(cmdbuf)) ? 2 : 1, -1) < 0) { + if(errno != EINTR) { + perror("dcsh: poll"); + exit(1); + } + } + + } + return(0); +} diff --git a/configure.in b/configure.in index 67dafb5..6d8ed05 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_CHECK_LIB(z, deflate, , AC_MSG_ERROR([*** must have zlib])) AC_CHECK_LIB(bz2, BZ2_bzWriteOpen, , AC_MSG_ERROR([*** must have bzlib])) AC_CHECK_LIB(gdbm, gdbm_open, , AC_MSG_ERROR([*** must have gdbm])) -clients= +clients=tty extlibs= experimental=no @@ -238,6 +238,7 @@ lib/guile/Makefile lib/guile/dolcon/Makefile clients/Makefile clients/gtk2/Makefile +clients/tty/Makefile clients/gnome-trans-applet/Makefile clients/gaim/Makefile include/Makefile diff --git a/lib/uilib.c b/lib/uilib.c index 356e41e..303ed0c 100644 --- a/lib/uilib.c +++ b/lib/uilib.c @@ -1238,6 +1238,7 @@ int dc_connectsync2(char *host, int rev) { dc_freeresp(resp); dc_disconnect(); + errno = EPROTONOSUPPORT; return(-1); } dc_freeresp(resp); -- 2.11.0