gawk

[old] Sed-like interface to the Gopher protocol
Log | Files | Refs | LICENSE

commit 29329314b65b72acc8af86dd4fdae6dee2aeb78c
parent ceefd4c497c0cc8725e53fab381a90b56b6c97c7
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Tue,  5 Jan 2021 15:56:19 -0800

Add verbose print command

Instead of cluttering all output with the location only do so when
using the verbose command, I played with adding a flag for cprint
but it introduced alot more complexity.

Diffstat:
Mcommand.c | 12++++++++++--
Mcommand.h | 1+
Mconfig.def.h | 3++-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/command.c b/command.c @@ -124,12 +124,20 @@ cprint(int argc, char const **argv, int ino, char const **item) if (**item == 'i') printf(" %s\n", item[GI_INFO] + 1); else - printf("%4d [%c] %s [%s%s]\n", ino, item[GI_INFO][0], - item[GI_INFO] + 1, item[GI_HOST], item[GI_PATH]); + printf("%4d [%c] %s\n", ino, item[GI_INFO][0], + item[GI_INFO] + 1); return PASS; } int +cprintv(int argc, char const **argv, int ino, char const **item) +{ + if (**item != 'i') + printf("\n %s%s\n", item[GI_HOST], item[GI_PATH]); + return cprint(argc, argv, ino, item); +} + +int findex(int argc, char const **argv, int ino, char const **item) { int i; diff --git a/command.h b/command.h @@ -5,6 +5,7 @@ int cextern(int, char const **, int, char const **); int cfetch(int, char const **, int, char const **); int cgoto(int, char const **, int, char const **); int cprint(int, char const **, int, char const **); +int cprintv(int, char const **, int, char const **); int findex(int, char const **, int, char const **); int frange(int, char const **, int, char const **); int fstring(int, char const **, int, char const **); diff --git a/config.def.h b/config.def.h @@ -26,7 +26,8 @@ static const struct command item_commands[] = { { 'p', cprint }, { 'r', frange }, { 's', fstring }, - { 't', ftype } + { 't', ftype }, + { 'v', cprintv } }; static const struct command commands[] = {