Lines Matching refs:pctl
104 #define DFLTPRTOP(pctl, type) \ argument
105 ((pctl)->nvprt_dfltops->print_##type.op)
107 #define DFLTPRTOPARG(pctl, type) \ argument
108 ((pctl)->nvprt_dfltops->print_##type.arg)
110 #define CUSTPRTOP(pctl, type) \ argument
111 ((pctl)->nvprt_custops->print_##type.op)
113 #define CUSTPRTOPARG(pctl, type) \ argument
114 ((pctl)->nvprt_custops->print_##type.arg)
116 #define RENDER(pctl, type, nvl, name, val) \ argument
119 if ((pctl)->nvprt_custops && CUSTPRTOP(pctl, type)) { \
120 done = CUSTPRTOP(pctl, type)(pctl, \
121 CUSTPRTOPARG(pctl, type), nvl, name, val); \
124 (void) DFLTPRTOP(pctl, type)(pctl, \
125 DFLTPRTOPARG(pctl, type), nvl, name, val); \
127 (void) fprintf(pctl->nvprt_fp, "%s", pctl->nvprt_eomfmt); \
130 #define ARENDER(pctl, type, nvl, name, arrp, count) \ argument
133 if ((pctl)->nvprt_custops && CUSTPRTOP(pctl, type)) { \
134 done = CUSTPRTOP(pctl, type)(pctl, \
135 CUSTPRTOPARG(pctl, type), nvl, name, arrp, count); \
138 (void) DFLTPRTOP(pctl, type)(pctl, \
139 DFLTPRTOPARG(pctl, type), nvl, name, arrp, count); \
141 (void) fprintf(pctl->nvprt_fp, "%s", pctl->nvprt_eomfmt); \
155 indent(nvlist_prtctl_t pctl, int onemore) in indent() argument
159 switch (pctl->nvprt_indent_mode) { in indent()
161 (void) fprintf(pctl->nvprt_fp, "%*s", in indent()
162 pctl->nvprt_indent + onemore * pctl->nvprt_indentinc, ""); in indent()
166 depth = pctl->nvprt_indent + onemore; in indent()
168 (void) fprintf(pctl->nvprt_fp, "\t"); in indent()
191 nvprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
196 FILE *fp = pctl->nvprt_fp; \
197 indent(pctl, 1); \
198 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
239 nvaprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
244 FILE *fp = pctl->nvprt_fp; \
247 if (i == 0 || pctl->nvprt_btwnarrfmt_nl) { \
248 indent(pctl, 1); \
249 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
250 if (pctl->nvprt_btwnarrfmt_nl) \
254 (void) fprintf(fp, "%s", pctl->nvprt_btwnarrfmt); \
273 nvprint_nvlist(nvlist_prtctl_t pctl, void *private, in nvprint_nvlist() argument
277 FILE *fp = pctl->nvprt_fp; in nvprint_nvlist()
279 indent(pctl, 1); in nvprint_nvlist()
282 pctl->nvprt_indent += pctl->nvprt_indentinc; in nvprint_nvlist()
283 nvlist_print_with_indent(value, pctl); in nvprint_nvlist()
284 pctl->nvprt_indent -= pctl->nvprt_indentinc; in nvprint_nvlist()
286 indent(pctl, 1); in nvprint_nvlist()
293 nvaprint_nvlist_array(nvlist_prtctl_t pctl, void *private, in nvaprint_nvlist_array() argument
297 FILE *fp = pctl->nvprt_fp; in nvaprint_nvlist_array()
300 indent(pctl, 1); in nvaprint_nvlist_array()
304 indent(pctl, 1); in nvaprint_nvlist_array()
307 pctl->nvprt_indent += pctl->nvprt_indentinc; in nvaprint_nvlist_array()
308 nvlist_print_with_indent(valuep[i], pctl); in nvaprint_nvlist_array()
309 pctl->nvprt_indent -= pctl->nvprt_indentinc; in nvaprint_nvlist_array()
311 indent(pctl, 1); in nvaprint_nvlist_array()
327 nvlist_prtctl_setdest(nvlist_prtctl_t pctl, FILE *fp) in nvlist_prtctl_setdest() argument
329 pctl->nvprt_fp = fp; in nvlist_prtctl_setdest()
333 nvlist_prtctl_getdest(nvlist_prtctl_t pctl) in nvlist_prtctl_getdest() argument
335 return (pctl->nvprt_fp); in nvlist_prtctl_getdest()
340 nvlist_prtctl_setindent(nvlist_prtctl_t pctl, enum nvlist_indent_mode mode, in nvlist_prtctl_setindent() argument
352 pctl->nvprt_indent_mode = mode; in nvlist_prtctl_setindent()
353 pctl->nvprt_indent = start; in nvlist_prtctl_setindent()
354 pctl->nvprt_indentinc = inc; in nvlist_prtctl_setindent()
358 nvlist_prtctl_doindent(nvlist_prtctl_t pctl, int onemore) in nvlist_prtctl_doindent() argument
360 indent(pctl, onemore); in nvlist_prtctl_doindent()
365 nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, in nvlist_prtctl_setfmt() argument
372 pctl->nvprt_nmfmt = fmt; in nvlist_prtctl_setfmt()
378 pctl->nvprt_eomfmt = fmt; in nvlist_prtctl_setfmt()
383 pctl->nvprt_btwnarrfmt = " "; in nvlist_prtctl_setfmt()
384 pctl->nvprt_btwnarrfmt_nl = 0; in nvlist_prtctl_setfmt()
386 pctl->nvprt_btwnarrfmt = fmt; in nvlist_prtctl_setfmt()
387 pctl->nvprt_btwnarrfmt_nl = (strchr(fmt, '\n') != NULL); in nvlist_prtctl_setfmt()
398 nvlist_prtctl_dofmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, ...) in nvlist_prtctl_dofmt() argument
400 FILE *fp = pctl->nvprt_fp; in nvlist_prtctl_dofmt()
409 (void) fprintf(fp, pctl->nvprt_nmfmt, name); in nvlist_prtctl_dofmt()
413 (void) fprintf(fp, "%s", pctl->nvprt_eomfmt); in nvlist_prtctl_dofmt()
417 (void) fprintf(fp, "%s", pctl->nvprt_btwnarrfmt); in nvlist_prtctl_dofmt()
437 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
441 CUSTPRTOP(pctl, type) = func; \
442 CUSTPRTOPARG(pctl, type) = private; \
463 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
467 CUSTPRTOP(pctl, type) = func; \
468 CUSTPRTOPARG(pctl, type) = private; \
525 prtctl_defaults(FILE *fp, struct nvlist_prtctl *pctl, in prtctl_defaults() argument
528 pctl->nvprt_fp = fp; in prtctl_defaults()
529 pctl->nvprt_indent_mode = NVLIST_INDENT_TABBED; in prtctl_defaults()
530 pctl->nvprt_indent = 0; in prtctl_defaults()
531 pctl->nvprt_indentinc = 1; in prtctl_defaults()
532 pctl->nvprt_nmfmt = "%s = "; in prtctl_defaults()
533 pctl->nvprt_eomfmt = "\n"; in prtctl_defaults()
534 pctl->nvprt_btwnarrfmt = " "; in prtctl_defaults()
535 pctl->nvprt_btwnarrfmt_nl = 0; in prtctl_defaults()
537 pctl->nvprt_dfltops = (struct nvlist_printops *)&defprtops; in prtctl_defaults()
538 pctl->nvprt_custops = ops; in prtctl_defaults()
544 struct nvlist_prtctl *pctl; in nvlist_prtctl_alloc() local
547 if ((pctl = malloc(sizeof (*pctl))) == NULL) in nvlist_prtctl_alloc()
551 free(pctl); in nvlist_prtctl_alloc()
555 prtctl_defaults(stdout, pctl, ops); in nvlist_prtctl_alloc()
557 return (pctl); in nvlist_prtctl_alloc()
561 nvlist_prtctl_free(nvlist_prtctl_t pctl) in nvlist_prtctl_free() argument
563 if (pctl != NULL) { in nvlist_prtctl_free()
564 free(pctl->nvprt_custops); in nvlist_prtctl_free()
565 free(pctl); in nvlist_prtctl_free()
581 nvlist_print_with_indent(nvlist_t *nvl, nvlist_prtctl_t pctl) in nvlist_print_with_indent() argument
583 FILE *fp = pctl->nvprt_fp; in nvlist_print_with_indent()
591 indent(pctl, 0); in nvlist_print_with_indent()
604 RENDER(pctl, boolean, nvl, name, 1); in nvlist_print_with_indent()
610 RENDER(pctl, boolean_value, nvl, name, val); in nvlist_print_with_indent()
616 RENDER(pctl, byte, nvl, name, val); in nvlist_print_with_indent()
622 RENDER(pctl, int8, nvl, name, val); in nvlist_print_with_indent()
628 RENDER(pctl, uint8, nvl, name, val); in nvlist_print_with_indent()
634 RENDER(pctl, int16, nvl, name, val); in nvlist_print_with_indent()
640 RENDER(pctl, uint16, nvl, name, val); in nvlist_print_with_indent()
646 RENDER(pctl, int32, nvl, name, val); in nvlist_print_with_indent()
652 RENDER(pctl, uint32, nvl, name, val); in nvlist_print_with_indent()
658 RENDER(pctl, int64, nvl, name, val); in nvlist_print_with_indent()
664 RENDER(pctl, uint64, nvl, name, val); in nvlist_print_with_indent()
670 RENDER(pctl, double, nvl, name, val); in nvlist_print_with_indent()
676 RENDER(pctl, string, nvl, name, val); in nvlist_print_with_indent()
682 ARENDER(pctl, boolean_array, nvl, name, val, nelem); in nvlist_print_with_indent()
688 ARENDER(pctl, byte_array, nvl, name, val, nelem); in nvlist_print_with_indent()
694 ARENDER(pctl, int8_array, nvl, name, val, nelem); in nvlist_print_with_indent()
700 ARENDER(pctl, uint8_array, nvl, name, val, nelem); in nvlist_print_with_indent()
706 ARENDER(pctl, int16_array, nvl, name, val, nelem); in nvlist_print_with_indent()
712 ARENDER(pctl, uint16_array, nvl, name, val, nelem); in nvlist_print_with_indent()
718 ARENDER(pctl, int32_array, nvl, name, val, nelem); in nvlist_print_with_indent()
724 ARENDER(pctl, uint32_array, nvl, name, val, nelem); in nvlist_print_with_indent()
730 ARENDER(pctl, int64_array, nvl, name, val, nelem); in nvlist_print_with_indent()
736 ARENDER(pctl, uint64_array, nvl, name, val, nelem); in nvlist_print_with_indent()
742 ARENDER(pctl, string_array, nvl, name, val, nelem); in nvlist_print_with_indent()
748 RENDER(pctl, hrtime, nvl, name, val); in nvlist_print_with_indent()
754 RENDER(pctl, nvlist, nvl, name, val); in nvlist_print_with_indent()
760 ARENDER(pctl, nvlist_array, nvl, name, val, nelem); in nvlist_print_with_indent()
781 nvlist_prt(nvlist_t *nvl, nvlist_prtctl_t pctl) in nvlist_prt() argument
783 nvlist_print_with_indent(nvl, pctl); in nvlist_prt()