ref: 90c298566b8e5672fe2baa522bd29122d485d69e
parent: 988845a13e6b254e79d602c6b154f46d7a4c41b4
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun May 28 12:31:54 EDT 2023
ndb/query, ndb/ipquery: use ndbvalfmt()
--- a/sys/src/cmd/ndb/ipquery.c
+++ b/sys/src/cmd/ndb/ipquery.c
@@ -1,3 +1,6 @@
+/*
+ * search the database for matches
+ */
#include <u.h>
#include <libc.h>
#include <bio.h>
@@ -4,10 +7,6 @@
#include <ndb.h>
#include <ip.h>
-/*
- * search the database for matches
- */
-
void
usage(void)
{
@@ -15,6 +14,9 @@
exits("usage");
}
+/* for ndbvalfmt */
+#pragma varargck type "$" char*
+
void
search(Ndb *db, char *attr, char *val, char **rattr, int nrattr)
{
@@ -22,7 +24,7 @@
tt = ndbipinfo(db, attr, val, rattr, nrattr);
for(t = tt; t; t = t->entry)
- print("%s=%s ", t->attr, t->val);
+ print("%s=%$ ", t->attr, t->val);
print("\n");
ndbfree(tt);
}
@@ -32,6 +34,8 @@
{
Ndb *db;
char *dbfile = 0;
+
+ fmtinstall('$', ndbvalfmt);
ARGBEGIN{
case 'f':
--- a/sys/src/cmd/ndb/query.c
+++ b/sys/src/cmd/ndb/query.c
@@ -26,6 +26,9 @@
Bprint(&bout, "%s\n", nt->val);
}
+/* for ndbvalfmt */
+#pragma varargck type "$" char*
+
void
search(Ndb *db, char *attr, char *val, char *rattr)
{
@@ -58,7 +61,7 @@
/* all entries */
for(t = ndbsearch(db, &s, attr, val); t; t = ndbsnext(&s, attr, val)){
for(nt = t; nt; nt = nt->entry)
- Bprint(&bout, "%s=%s ", nt->attr, nt->val);
+ Bprint(&bout, "%s=%$ ", nt->attr, nt->val);
Bprint(&bout, "\n");
ndbfree(t);
}
@@ -71,6 +74,8 @@
char *rattr = nil, *dbfile = nil;
Ndb *db;
+ fmtinstall('$', ndbvalfmt);
+
ARGBEGIN{
case 'a':
all++;