Use more standard formatting in src/print.c
Use a more standard formatting style when printing frame headers, similar to that of MONITOR mode of a Kantronics TNC, or direwolf
This commit is contained in:
parent
967f2f6830
commit
c7a51ff7f1
1 changed files with 17 additions and 11 deletions
28
src/print.c
28
src/print.c
|
@ -43,12 +43,14 @@ static char *version(enum patty_ax25_version version) {
|
|||
|
||||
static char *frame_cr(enum patty_ax25_frame_cr cr) {
|
||||
switch (cr) {
|
||||
case PATTY_AX25_FRAME_COMMAND: return "C";
|
||||
case PATTY_AX25_FRAME_RESPONSE: return "R";
|
||||
case PATTY_AX25_FRAME_OLD: return "?";
|
||||
case PATTY_AX25_FRAME_COMMAND: return "cmd";
|
||||
case PATTY_AX25_FRAME_RESPONSE: return "res";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
return "?";
|
||||
}
|
||||
|
||||
static int print_addr(FILE *fh, const patty_ax25_addr *addr) {
|
||||
|
@ -62,7 +64,7 @@ static int print_addr(FILE *fh, const patty_ax25_addr *addr) {
|
|||
fprintf(fh, "%s", buf);
|
||||
|
||||
if (ssid) {
|
||||
fprintf(fh, "/%d", ssid);
|
||||
fprintf(fh, "-%d", (int)ssid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -76,11 +78,11 @@ static int print_frame_addrs(FILE *fh, const patty_ax25_frame *frame) {
|
|||
|
||||
print_addr(fh, &frame->src);
|
||||
|
||||
fprintf(fh, " > ");
|
||||
fprintf(fh, ">");
|
||||
|
||||
for (i=0; i<frame->hops; i++) {
|
||||
print_addr(fh, &frame->repeaters[i]);
|
||||
fprintf(fh, " > ");
|
||||
fprintf(fh, ">");
|
||||
}
|
||||
|
||||
print_addr(fh, &frame->dest);
|
||||
|
@ -95,7 +97,7 @@ int patty_print_frame_header(FILE *fh,
|
|||
}
|
||||
|
||||
if (PATTY_AX25_FRAME_CONTROL_I(frame->control)) {
|
||||
if (fprintf(fh, " type I (%s) %s cr %s nr %d ns %d pf %d info %zu bytes",
|
||||
if (fprintf(fh, " (%s %s %s N(R)=%d N(S)=%d P/F=%d info=%zu)",
|
||||
frame_type(frame->type),
|
||||
version(frame->version),
|
||||
frame_cr(frame->cr),
|
||||
|
@ -106,7 +108,7 @@ int patty_print_frame_header(FILE *fh,
|
|||
goto error_io;
|
||||
}
|
||||
} else if (PATTY_AX25_FRAME_CONTROL_U(frame->control)) {
|
||||
if (fprintf(fh, " type U (%s) %s cr %s pf %d",
|
||||
if (fprintf(fh, " (%s %s %s P/F=%d",
|
||||
frame_type(frame->type),
|
||||
version(frame->version),
|
||||
frame_cr(frame->cr),
|
||||
|
@ -115,12 +117,16 @@ int patty_print_frame_header(FILE *fh,
|
|||
}
|
||||
|
||||
if (PATTY_AX25_FRAME_CONTROL_UI(frame->control)) {
|
||||
if (fprintf(fh, " info %zu bytes", frame->infolen) < 0) {
|
||||
if (fprintf(fh, " info=%zu", frame->infolen) < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
}
|
||||
|
||||
if (fprintf(fh, ")") < 0) {
|
||||
goto error_io;
|
||||
}
|
||||
} else if (PATTY_AX25_FRAME_CONTROL_S(frame->control)) {
|
||||
if (fprintf(fh, " type S (%s) %s cr %s nr %d pf %d",
|
||||
if (fprintf(fh, " (%s %s %s N(R)=%d P/F=%d)",
|
||||
frame_type(frame->type),
|
||||
version(frame->version),
|
||||
frame_cr(frame->cr),
|
||||
|
|
Loading…
Add table
Reference in a new issue