Lines Matching full:pctl
103 #define DFLTPRTOP(pctl, type) \ argument
104 ((pctl)->nvprt_dfltops->print_##type.op)
106 #define DFLTPRTOPARG(pctl, type) \ argument
107 ((pctl)->nvprt_dfltops->print_##type.arg)
109 #define CUSTPRTOP(pctl, type) \ argument
110 ((pctl)->nvprt_custops->print_##type.op)
112 #define CUSTPRTOPARG(pctl, type) \ argument
113 ((pctl)->nvprt_custops->print_##type.arg)
115 #define RENDER(pctl, type, nvl, name, val) \ argument
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, "%s", pctl->nvprt_eomfmt); \
129 #define ARENDER(pctl, type, nvl, name, arrp, count) \ argument
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, "%s", pctl->nvprt_eomfmt); \
154 indent(nvlist_prtctl_t pctl, int onemore) in indent() argument
158 switch (pctl->nvprt_indent_mode) { in indent()
160 (void) fprintf(pctl->nvprt_fp, "%*s", in indent()
161 pctl->nvprt_indent + onemore * pctl->nvprt_indentinc, ""); in indent()
165 depth = pctl->nvprt_indent + onemore; in indent()
167 (void) fprintf(pctl->nvprt_fp, "\t"); in indent()
190 nvprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
195 FILE *fp = pctl->nvprt_fp; \
196 indent(pctl, 1); \
197 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
238 nvaprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
243 FILE *fp = pctl->nvprt_fp; \
246 if (i == 0 || pctl->nvprt_btwnarrfmt_nl) { \
247 indent(pctl, 1); \
248 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
249 if (pctl->nvprt_btwnarrfmt_nl) \
253 (void) fprintf(fp, "%s", pctl->nvprt_btwnarrfmt); \
272 nvprint_nvlist(nvlist_prtctl_t pctl, void *private, in nvprint_nvlist() argument
276 FILE *fp = pctl->nvprt_fp; in nvprint_nvlist()
278 indent(pctl, 1); in nvprint_nvlist()
281 pctl->nvprt_indent += pctl->nvprt_indentinc; in nvprint_nvlist()
282 nvlist_print_with_indent(value, pctl); in nvprint_nvlist()
283 pctl->nvprt_indent -= pctl->nvprt_indentinc; in nvprint_nvlist()
285 indent(pctl, 1); in nvprint_nvlist()
292 nvaprint_nvlist_array(nvlist_prtctl_t pctl, void *private, in nvaprint_nvlist_array() argument
296 FILE *fp = pctl->nvprt_fp; in nvaprint_nvlist_array()
299 indent(pctl, 1); in nvaprint_nvlist_array()
303 indent(pctl, 1); in nvaprint_nvlist_array()
306 pctl->nvprt_indent += pctl->nvprt_indentinc; in nvaprint_nvlist_array()
307 nvlist_print_with_indent(valuep[i], pctl); in nvaprint_nvlist_array()
308 pctl->nvprt_indent -= pctl->nvprt_indentinc; in nvaprint_nvlist_array()
310 indent(pctl, 1); in nvaprint_nvlist_array()
326 nvlist_prtctl_setdest(nvlist_prtctl_t pctl, FILE *fp) in nvlist_prtctl_setdest() argument
328 pctl->nvprt_fp = fp; in nvlist_prtctl_setdest()
332 nvlist_prtctl_getdest(nvlist_prtctl_t pctl) in nvlist_prtctl_getdest() argument
334 return (pctl->nvprt_fp); in nvlist_prtctl_getdest()
339 nvlist_prtctl_setindent(nvlist_prtctl_t pctl, enum nvlist_indent_mode mode, in nvlist_prtctl_setindent() argument
351 pctl->nvprt_indent_mode = mode; in nvlist_prtctl_setindent()
352 pctl->nvprt_indent = start; in nvlist_prtctl_setindent()
353 pctl->nvprt_indentinc = inc; in nvlist_prtctl_setindent()
357 nvlist_prtctl_doindent(nvlist_prtctl_t pctl, int onemore) in nvlist_prtctl_doindent() argument
359 indent(pctl, onemore); in nvlist_prtctl_doindent()
364 nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, in nvlist_prtctl_setfmt() argument
371 pctl->nvprt_nmfmt = fmt; in nvlist_prtctl_setfmt()
377 pctl->nvprt_eomfmt = fmt; in nvlist_prtctl_setfmt()
382 pctl->nvprt_btwnarrfmt = " "; in nvlist_prtctl_setfmt()
383 pctl->nvprt_btwnarrfmt_nl = 0; in nvlist_prtctl_setfmt()
385 pctl->nvprt_btwnarrfmt = fmt; in nvlist_prtctl_setfmt()
386 pctl->nvprt_btwnarrfmt_nl = (strchr(fmt, '\n') != NULL); in nvlist_prtctl_setfmt()
397 nvlist_prtctl_dofmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, ...) in nvlist_prtctl_dofmt() argument
399 FILE *fp = pctl->nvprt_fp; in nvlist_prtctl_dofmt()
408 (void) fprintf(fp, pctl->nvprt_nmfmt, name); in nvlist_prtctl_dofmt()
412 (void) fprintf(fp, "%s", pctl->nvprt_eomfmt); in nvlist_prtctl_dofmt()
416 (void) fprintf(fp, "%s", pctl->nvprt_btwnarrfmt); in nvlist_prtctl_dofmt()
436 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
440 CUSTPRTOP(pctl, type) = func; \
441 CUSTPRTOPARG(pctl, type) = private; \
462 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
466 CUSTPRTOP(pctl, type) = func; \
467 CUSTPRTOPARG(pctl, type) = private; \
524 prtctl_defaults(FILE *fp, struct nvlist_prtctl *pctl, in prtctl_defaults() argument
527 pctl->nvprt_fp = fp; in prtctl_defaults()
528 pctl->nvprt_indent_mode = NVLIST_INDENT_TABBED; in prtctl_defaults()
529 pctl->nvprt_indent = 0; in prtctl_defaults()
530 pctl->nvprt_indentinc = 1; in prtctl_defaults()
531 pctl->nvprt_nmfmt = "%s = "; in prtctl_defaults()
532 pctl->nvprt_eomfmt = "\n"; in prtctl_defaults()
533 pctl->nvprt_btwnarrfmt = " "; in prtctl_defaults()
534 pctl->nvprt_btwnarrfmt_nl = 0; in prtctl_defaults()
536 pctl->nvprt_dfltops = (struct nvlist_printops *)&defprtops; in prtctl_defaults()
537 pctl->nvprt_custops = ops; in prtctl_defaults()
543 struct nvlist_prtctl *pctl; in nvlist_prtctl_alloc() local
546 if ((pctl = malloc(sizeof (*pctl))) == NULL) in nvlist_prtctl_alloc()
550 free(pctl); in nvlist_prtctl_alloc()
554 prtctl_defaults(stdout, pctl, ops); in nvlist_prtctl_alloc()
556 return (pctl); in nvlist_prtctl_alloc()
560 nvlist_prtctl_free(nvlist_prtctl_t pctl) in nvlist_prtctl_free() argument
562 if (pctl != NULL) { in nvlist_prtctl_free()
563 free(pctl->nvprt_custops); in nvlist_prtctl_free()
564 free(pctl); in nvlist_prtctl_free()
580 nvlist_print_with_indent(nvlist_t *nvl, nvlist_prtctl_t pctl) in nvlist_print_with_indent() argument
582 FILE *fp = pctl->nvprt_fp; in nvlist_print_with_indent()
590 indent(pctl, 0); in nvlist_print_with_indent()
603 RENDER(pctl, boolean, nvl, name, 1); in nvlist_print_with_indent()
609 RENDER(pctl, boolean_value, nvl, name, val); in nvlist_print_with_indent()
615 RENDER(pctl, byte, nvl, name, val); in nvlist_print_with_indent()
621 RENDER(pctl, int8, nvl, name, val); in nvlist_print_with_indent()
627 RENDER(pctl, uint8, nvl, name, val); in nvlist_print_with_indent()
633 RENDER(pctl, int16, nvl, name, val); in nvlist_print_with_indent()
639 RENDER(pctl, uint16, nvl, name, val); in nvlist_print_with_indent()
645 RENDER(pctl, int32, nvl, name, val); in nvlist_print_with_indent()
651 RENDER(pctl, uint32, nvl, name, val); in nvlist_print_with_indent()
657 RENDER(pctl, int64, nvl, name, val); in nvlist_print_with_indent()
663 RENDER(pctl, uint64, nvl, name, val); in nvlist_print_with_indent()
669 RENDER(pctl, double, nvl, name, val); in nvlist_print_with_indent()
675 RENDER(pctl, string, nvl, name, val); in nvlist_print_with_indent()
681 ARENDER(pctl, boolean_array, nvl, name, val, nelem); in nvlist_print_with_indent()
687 ARENDER(pctl, byte_array, nvl, name, val, nelem); in nvlist_print_with_indent()
693 ARENDER(pctl, int8_array, nvl, name, val, nelem); in nvlist_print_with_indent()
699 ARENDER(pctl, uint8_array, nvl, name, val, nelem); in nvlist_print_with_indent()
705 ARENDER(pctl, int16_array, nvl, name, val, nelem); in nvlist_print_with_indent()
711 ARENDER(pctl, uint16_array, nvl, name, val, nelem); in nvlist_print_with_indent()
717 ARENDER(pctl, int32_array, nvl, name, val, nelem); in nvlist_print_with_indent()
723 ARENDER(pctl, uint32_array, nvl, name, val, nelem); in nvlist_print_with_indent()
729 ARENDER(pctl, int64_array, nvl, name, val, nelem); in nvlist_print_with_indent()
735 ARENDER(pctl, uint64_array, nvl, name, val, nelem); in nvlist_print_with_indent()
741 ARENDER(pctl, string_array, nvl, name, val, nelem); in nvlist_print_with_indent()
747 RENDER(pctl, hrtime, nvl, name, val); in nvlist_print_with_indent()
753 RENDER(pctl, nvlist, nvl, name, val); in nvlist_print_with_indent()
759 ARENDER(pctl, nvlist_array, nvl, name, val, nelem); in nvlist_print_with_indent()
780 nvlist_prt(nvlist_t *nvl, nvlist_prtctl_t pctl) in nvlist_prt() argument
782 nvlist_print_with_indent(nvl, pctl); in nvlist_prt()