projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add some linger debugging
[spider.git]
/
src
/
client.c
diff --git
a/src/client.c
b/src/client.c
index 8df624494b3c7879cc60480458ff860369d4fe92..049d64f6a2fd9d833365b8d6340f3d2ac54cbace 100644
(file)
--- a/
src/client.c
+++ b/
src/client.c
@@
-16,9
+16,10
@@
* $Id$
*/
* $Id$
*/
+#include <sys/types.h>
#include <stdio.h>
#include <sys/time.h>
#include <stdio.h>
#include <sys/time.h>
-#include <sys/
types
.h>
+#include <sys/
wait
.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <stdlib.h>
@@
-96,6
+97,7
@@
int tabsize = 8; /* default tabsize for text messages */
char *connsort = "local"; /* the connection variety */
int state = 0; /* the current state of the connection */
int laststate = 0; /* the last state we were in */
char *connsort = "local"; /* the connection variety */
int state = 0; /* the current state of the connection */
int laststate = 0; /* the last state we were in */
+char echocancel = 1; /* echo cancelling */
reft echobase; /* the anti echo queue */
int maxecho = 5; /* the depth of the anti echo queue */
int echon; /* no of entries in the anti echo queue */
reft echobase; /* the anti echo queue */
int maxecho = 5; /* the depth of the anti echo queue */
int echon; /* no of entries in the anti echo queue */
@@
-104,7
+106,7
@@
int echon; /* no of entries in the anti echo queue */
#define WAITLOGIN 1
#define WAITPASSWD 2
#define WAITINPUT 10
#define WAITLOGIN 1
#define WAITPASSWD 2
#define WAITINPUT 10
-
+#define DOCHAT 20
myregex_t iscallreg[] = { /* regexes to determine whether this is a reasonable callsign */
{
myregex_t iscallreg[] = { /* regexes to determine whether this is a reasonable callsign */
{
@@
-203,6
+205,14
@@
int iscallsign(char *s)
return 0;
}
return 0;
}
+void reaper(int i)
+{
+ pid_t mypid;
+ while ((mypid = waitpid(-1, 0, WNOHANG)) > 0) {
+ ;
+ }
+}
+
/*
* higher level send and receive routines
*/
/*
* higher level send and receive routines
*/
@@
-231,10
+241,12
@@
void flush_text(fcb_t *f)
emp->size = size;
memcpy(emp->data, imp->data, size);
emp->inp = emp->data + size; /* just in case */
emp->size = size;
memcpy(emp->data, imp->data, size);
emp->inp = emp->data + size; /* just in case */
- chain_add(&echobase, emp);
- if (++echon > maxecho) {
- emp = cmsg_prev(&echobase);
- cmsg_free(emp);
+ if (echocancel) {
+ chain_add(&echobase, emp);
+ if (++echon > maxecho) {
+ emp = cmsg_prev(&echobase);
+ cmsg_free(emp);
+ }
}
/* queue it for sending */
}
/* queue it for sending */
@@
-562,7
+574,7
@@
lend:;
/*
* set up the various mode flags, NL endings and things
*/
/*
* set up the various mode flags, NL endings and things
*/
-void set
mod
e(char *m)
+void set
conntyp
e(char *m)
{
connsort = strlower(m);
if (eq(connsort, "telnet") || eq(connsort, "local") || eq(connsort, "nlonly")) {
{
connsort = strlower(m);
if (eq(connsort, "telnet") || eq(connsort, "local") || eq(connsort, "nlonly")) {
@@
-597,10
+609,12
@@
void process_stdin()
dbg(DMSG, "MSG size: %d", mp->size);
/* check for echos */
dbg(DMSG, "MSG size: %d", mp->size);
/* check for echos */
- for (wmp = 0; wmp = chain_get_next(&echobase, wmp); ) {
- if (!memcmp(wmp->data, mp->data, wmp->size)) {
- cmsg_callback(mp, 0);
- return;
+ if (echocancel) {
+ for (wmp = 0; wmp = chain_get_next(&echobase, wmp); ) {
+ if (!memcmp(wmp->data, mp->data, wmp->size)) {
+ cmsg_callback(mp, 0);
+ return;
+ }
}
}
}
}
@@
-652,6
+666,11
@@
void process_stdin()
chgstate(CONNECTED);
send_file("connected");
chgstate(CONNECTED);
send_file("connected");
+ break;
+
+ case DOCHAT:
+
+ break;
}
cmsg_callback(mp, 0);
}
cmsg_callback(mp, 0);
@@
-749,8
+768,11
@@
void initargs(int argc, char *argv[])
{
int i, c, err = 0;
{
int i, c, err = 0;
- while ((c = getopt(argc, argv, "
h
:p:x:")) > 0) {
+ while ((c = getopt(argc, argv, "
eh:l
:p:x:")) > 0) {
switch (c) {
switch (c) {
+ case 'e':
+ echocancel ^= 1;
+ break;
case 'h':
node_addr = optarg;
break;
case 'h':
node_addr = optarg;
break;
@@
-776,7
+798,7
@@
void initargs(int argc, char *argv[])
lerr:
if (err) {
lerr:
if (err) {
- die("usage: client [-x n|-h<host>|-p<port>|-l<paclen>] <call>|login [local|telnet|ax25]");
+ die("usage: client [-
e|-
x n|-h<host>|-p<port>|-l<paclen>] <call>|login [local|telnet|ax25]");
}
if (optind < argc) {
}
if (optind < argc) {
@@
-787,9
+809,9
@@
lerr:
die("Must have at least a callsign (for now)");
if (optind < argc) {
die("Must have at least a callsign (for now)");
if (optind < argc) {
- set
mode(argv[optind]);
+ set
conntype(argv[optind]);
} else {
} else {
- set
mod
e("local");
+ set
conntyp
e("local");
}
/* this is kludgy, but hey so is the rest of this! */
}
/* this is kludgy, but hey so is the rest of this! */
@@
-804,7
+826,8
@@
void connect_to_node()
struct sockaddr_in server;
int nodef;
sel_t *sp;
struct sockaddr_in server;
int nodef;
sel_t *sp;
-
+ struct linger lg;
+
if ((hp = gethostbyname(node_addr)) == 0)
die("Unknown host tcp host %s for printer", node_addr);
if ((hp = gethostbyname(node_addr)) == 0)
die("Unknown host tcp host %s for printer", node_addr);
@@
-820,6
+843,12
@@
void connect_to_node()
if (connect(nodef, (struct sockaddr *) &server, sizeof server) < 0) {
die("Error on connect to %s port %d (%d)", node_addr, node_port, errno);
}
if (connect(nodef, (struct sockaddr *) &server, sizeof server) < 0) {
die("Error on connect to %s port %d (%d)", node_addr, node_port, errno);
}
+
+ memset(&lg, 0, sizeof lg);
+ if (setsockopt(nodef, SOL_SOCKET, SO_LINGER, &lg, sizeof lg) < 0) {
+ die("Error on SO_LINGER to %s port %d (%d)", node_addr, node_port, errno);
+ }
+
node = fcb_new(nodef, MSG);
node->sp = sel_open(nodef, node, "Msg System", fcb_handler, MSG, SEL_INPUT);
node = fcb_new(nodef, MSG);
node->sp = sel_open(nodef, node, "Msg System", fcb_handler, MSG, SEL_INPUT);
@@
-879,6
+908,7
@@
main(int argc, char *argv[])
#ifdef SIGPWR
signal(SIGPWR, terminate);
#endif
#ifdef SIGPWR
signal(SIGPWR, terminate);
#endif
+
/* init a few things */
chain_init(&echobase);
/* init a few things */
chain_init(&echobase);