FILE *NetTrace
= 0; /* Not in bss, since needs to stay */
* Upcase (in place) the argument.
while ((c
= *argument
) != 0) {
* Compensate for differences in 4.2 and 4.3 systems.
SetSockOpt(fd
, level
, option
, yesno
)
return setsockopt(fd
, level
, option
,
(char *)&yesno
, sizeof yesno
);
if (yesno
== 0) { /* Can't do that in 4.2! */
fprintf(stderr
, "Error: attempt to turn off an option 0x%x.\n",
return setsockopt(fd
, level
, option
, 0, 0);
* The following are routines used to print out debugging information.
Dump(direction
, buffer
, length
)
# define BYTES_PER_LINE 32
# define min(x,y) ((x<y)? x:y)
fprintf(NetTrace
, "%c 0x%x\t", direction
, offset
);
buffer
= buffer
+min(length
, BYTES_PER_LINE
);
fprintf(NetTrace
, "%.2x", (*pThis
)&0xff);
length
-= BYTES_PER_LINE
;
offset
+= BYTES_PER_LINE
;
/* find next unique line */
printoption(direction
, fmt
, option
, what
)
fprintf(NetTrace
, "%s ", direction
+1);
if (option
< (sizeof telopts
/sizeof telopts
[0]))
fprintf(NetTrace
, "%s %s", fmt
, telopts
[option
]);
fprintf(NetTrace
, "%s %d", fmt
, option
);
fprintf(NetTrace
, "\r\n");
fprintf(NetTrace
, " (%s)\r\n", what
? "reply" : "don't reply");
printsub(direction
, pointer
, length
)
char *direction
, /* "<" or ">" */
*pointer
; /* where suboption data sits */
int length
; /* length of suboption data */
fprintf(NetTrace
, "%s suboption ",
(direction
[0] == '<')? "Received":"Sent");
fprintf(NetTrace
, "Terminal type ");
char tmpbuf
[sizeof subbuffer
];
int minlen
= min(length
, sizeof tmpbuf
);
memcpy(tmpbuf
, pointer
+2, minlen
);
fprintf(NetTrace
, "is %s.\n", tmpbuf
);
fprintf(NetTrace
, "- request to send.\n");
"- unknown qualifier %d (0x%x).\n", pointer
[1]);
fprintf(NetTrace
, "Unknown option %d (0x%x)\n",