Lines Matching defs:pctl

103 #define	DFLTPRTOP(pctl, type) \
104 ((pctl)->nvprt_dfltops->print_##type.op)
106 #define DFLTPRTOPARG(pctl, type) \
107 ((pctl)->nvprt_dfltops->print_##type.arg)
109 #define CUSTPRTOP(pctl, type) \
110 ((pctl)->nvprt_custops->print_##type.op)
112 #define CUSTPRTOPARG(pctl, type) \
113 ((pctl)->nvprt_custops->print_##type.arg)
115 #define RENDER(pctl, type, nvl, name, val) \
118 if ((pctl)->nvprt_custops && CUSTPRTOP(pctl, type)) { \
119 done = CUSTPRTOP(pctl, type)(pctl, \
120 CUSTPRTOPARG(pctl, type), nvl, name, val); \
123 (void) DFLTPRTOP(pctl, type)(pctl, \
124 DFLTPRTOPARG(pctl, type), nvl, name, val); \
126 (void) fprintf(pctl->nvprt_fp, pctl->nvprt_eomfmt); \
129 #define ARENDER(pctl, type, nvl, name, arrp, count) \
132 if ((pctl)->nvprt_custops && CUSTPRTOP(pctl, type)) { \
133 done = CUSTPRTOP(pctl, type)(pctl, \
134 CUSTPRTOPARG(pctl, type), nvl, name, arrp, count); \
137 (void) DFLTPRTOP(pctl, type)(pctl, \
138 DFLTPRTOPARG(pctl, type), nvl, name, arrp, count); \
140 (void) fprintf(pctl->nvprt_fp, pctl->nvprt_eomfmt); \
154 indent(nvlist_prtctl_t pctl, int onemore)
158 switch (pctl->nvprt_indent_mode) {
160 (void) fprintf(pctl->nvprt_fp, "%*s",
161 pctl->nvprt_indent + onemore * pctl->nvprt_indentinc, "");
165 depth = pctl->nvprt_indent + onemore;
167 (void) fprintf(pctl->nvprt_fp, "\t");
190 nvprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
193 FILE *fp = pctl->nvprt_fp; \
196 indent(pctl, 1); \
197 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
223 nvaprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
226 FILE *fp = pctl->nvprt_fp; \
231 if (i == 0 || pctl->nvprt_btwnarrfmt_nl) { \
232 indent(pctl, 1); \
233 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
234 if (pctl->nvprt_btwnarrfmt_nl) \
238 (void) fprintf(fp, pctl->nvprt_btwnarrfmt); \
258 nvprint_nvlist(nvlist_prtctl_t pctl, void *private,
261 FILE *fp = pctl->nvprt_fp;
263 indent(pctl, 1);
266 pctl->nvprt_indent += pctl->nvprt_indentinc;
267 nvlist_print_with_indent(value, pctl);
268 pctl->nvprt_indent -= pctl->nvprt_indentinc;
270 indent(pctl, 1);
278 nvaprint_nvlist_array(nvlist_prtctl_t pctl, void *private,
281 FILE *fp = pctl->nvprt_fp;
284 indent(pctl, 1);
288 indent(pctl, 1);
291 pctl->nvprt_indent += pctl->nvprt_indentinc;
292 nvlist_print_with_indent(valuep[i], pctl);
293 pctl->nvprt_indent -= pctl->nvprt_indentinc;
295 indent(pctl, 1);
311 nvlist_prtctl_setdest(nvlist_prtctl_t pctl, FILE *fp)
313 pctl->nvprt_fp = fp;
317 nvlist_prtctl_getdest(nvlist_prtctl_t pctl)
319 return (pctl->nvprt_fp);
324 nvlist_prtctl_setindent(nvlist_prtctl_t pctl, enum nvlist_indent_mode mode,
336 pctl->nvprt_indent_mode = mode;
337 pctl->nvprt_indent = start;
338 pctl->nvprt_indentinc = inc;
342 nvlist_prtctl_doindent(nvlist_prtctl_t pctl, int onemore)
344 indent(pctl, onemore);
349 nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which,
356 pctl->nvprt_nmfmt = fmt;
362 pctl->nvprt_eomfmt = fmt;
367 pctl->nvprt_btwnarrfmt = " ";
368 pctl->nvprt_btwnarrfmt_nl = 0;
370 pctl->nvprt_btwnarrfmt = fmt;
371 pctl->nvprt_btwnarrfmt_nl = (strstr(fmt, "\n") != NULL);
382 nvlist_prtctl_dofmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, ...)
384 FILE *fp = pctl->nvprt_fp;
393 (void) fprintf(fp, pctl->nvprt_nmfmt, name);
397 (void) fprintf(fp, pctl->nvprt_eomfmt);
401 (void) fprintf(fp, pctl->nvprt_btwnarrfmt); \
421 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
425 CUSTPRTOP(pctl, type) = func; \
426 CUSTPRTOPARG(pctl, type) = private; \
447 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
451 CUSTPRTOP(pctl, type) = func; \
452 CUSTPRTOPARG(pctl, type) = private; \
508 prtctl_defaults(FILE *fp, struct nvlist_prtctl *pctl,
511 pctl->nvprt_fp = fp;
512 pctl->nvprt_indent_mode = NVLIST_INDENT_TABBED;
513 pctl->nvprt_indent = 0;
514 pctl->nvprt_indentinc = 1;
515 pctl->nvprt_nmfmt = "%s = ";
516 pctl->nvprt_eomfmt = "\n";
517 pctl->nvprt_btwnarrfmt = " ";
518 pctl->nvprt_btwnarrfmt_nl = 0;
520 pctl->nvprt_dfltops = (struct nvlist_printops *)&defprtops;
521 pctl->nvprt_custops = ops;
527 struct nvlist_prtctl *pctl;
530 if ((pctl = malloc(sizeof (*pctl))) == NULL)
534 free(pctl);
538 prtctl_defaults(stdout, pctl, ops);
540 return (pctl);
544 nvlist_prtctl_free(nvlist_prtctl_t pctl)
546 if (pctl != NULL) {
547 free(pctl->nvprt_custops);
548 free(pctl);
564 nvlist_print_with_indent(nvlist_t *nvl, nvlist_prtctl_t pctl)
566 FILE *fp = pctl->nvprt_fp;
574 indent(pctl, 0);
587 RENDER(pctl, boolean, nvl, name, 1);
593 RENDER(pctl, boolean_value, nvl, name, val);
599 RENDER(pctl, byte, nvl, name, val);
605 RENDER(pctl, int8, nvl, name, val);
611 RENDER(pctl, uint8, nvl, name, val);
617 RENDER(pctl, int16, nvl, name, val);
623 RENDER(pctl, uint16, nvl, name, val);
629 RENDER(pctl, int32, nvl, name, val);
635 RENDER(pctl, uint32, nvl, name, val);
641 RENDER(pctl, int64, nvl, name, val);
647 RENDER(pctl, uint64, nvl, name, val);
653 RENDER(pctl, double, nvl, name, val);
659 RENDER(pctl, string, nvl, name, val);
665 ARENDER(pctl, boolean_array, nvl, name, val, nelem);
671 ARENDER(pctl, byte_array, nvl, name, val, nelem);
677 ARENDER(pctl, int8_array, nvl, name, val, nelem);
683 ARENDER(pctl, uint8_array, nvl, name, val, nelem);
689 ARENDER(pctl, int16_array, nvl, name, val, nelem);
695 ARENDER(pctl, uint16_array, nvl, name, val, nelem);
701 ARENDER(pctl, int32_array, nvl, name, val, nelem);
707 ARENDER(pctl, uint32_array, nvl, name, val, nelem);
713 ARENDER(pctl, int64_array, nvl, name, val, nelem);
719 ARENDER(pctl, uint64_array, nvl, name, val, nelem);
725 ARENDER(pctl, string_array, nvl, name, val, nelem);
731 RENDER(pctl, hrtime, nvl, name, val);
737 RENDER(pctl, nvlist, nvl, name, val);
743 ARENDER(pctl, nvlist_array, nvl, name, val, nelem);
764 nvlist_prt(nvlist_t *nvl, nvlist_prtctl_t pctl)
766 nvlist_print_with_indent(nvl, pctl);