Add "hamilton" protocol same as oxford with echo suppression
r3222 | dcl | 2011-06-20 11:54:20 +1000 (Mon, 20 Jun 2011) | 1 line
This commit is contained in:
@@ -25,6 +25,7 @@ struct OxfordProtocol_t {
|
||||
double last_char_time;
|
||||
double inter_line_time;
|
||||
double inter_char_time;
|
||||
int do_echo;
|
||||
};
|
||||
typedef struct OxfordProtocol_t OxfordProtocol;
|
||||
|
||||
@@ -116,6 +117,23 @@ int OxfordReading(Ascon *a) {
|
||||
DynStringConcatChar(a->rdBuffer, chr);
|
||||
}
|
||||
else {
|
||||
OxfordProtocol* private;
|
||||
private = (OxfordProtocol*) a->private;
|
||||
if (private->do_echo) {
|
||||
int ilen, olen;
|
||||
ilen = GetDynStringLength(a->rdBuffer);
|
||||
olen = GetDynStringLength(a->wrBuffer) - 1; /* omit CR */
|
||||
if (olen == ilen) {
|
||||
char *itext, *otext;
|
||||
itext = GetCharArray(a->rdBuffer);
|
||||
otext = GetCharArray(a->wrBuffer);
|
||||
if (memcmp(itext, otext, ilen) == 0) { /* echo? */
|
||||
DynStringClear(a->rdBuffer);
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
a->state = AsconReadDone;
|
||||
break;
|
||||
}
|
||||
@@ -224,6 +242,23 @@ int OxfordInit(Ascon *a, SConnection *con,
|
||||
private->parent = a;
|
||||
private->inter_line_time = 0.100;
|
||||
private->inter_char_time = 0.010;
|
||||
private->do_echo = 0;
|
||||
a->killPrivate = OxfordKillPrivate;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int HamiltonInit(Ascon *a, SConnection *con,
|
||||
int argc, char *argv[]) {
|
||||
OxfordProtocol *private;
|
||||
int ret;
|
||||
ret = AsconStdInit(a, con, argc, argv);
|
||||
private = calloc(sizeof(OxfordProtocol), 1);
|
||||
a->private = (void *) private;
|
||||
private->magic = 0xcafef00d;
|
||||
private->parent = a;
|
||||
private->inter_line_time = 0.100;
|
||||
private->inter_char_time = 0.010;
|
||||
private->do_echo = 1;
|
||||
a->killPrivate = OxfordKillPrivate;
|
||||
return ret;
|
||||
}
|
||||
@@ -252,6 +287,12 @@ void AddOxfordProtocoll(){
|
||||
prot->handler = OxfordProtHandler;
|
||||
AsconInsertProtocol(prot);
|
||||
|
||||
prot = calloc(sizeof(AsconProtocol), 1);
|
||||
prot->name = strdup("hamilton");
|
||||
prot->init = HamiltonInit;
|
||||
prot->handler = OxfordProtHandler;
|
||||
AsconInsertProtocol(prot);
|
||||
|
||||
prot = calloc(sizeof(AsconProtocol), 1);
|
||||
prot->name = strdup("oxfordq");
|
||||
prot->init = OxfordQInit;
|
||||
|
||||
Reference in New Issue
Block a user