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, 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, 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, \
194 FILE *fp = pctl->nvprt_fp; \
197 indent(pctl, 1); \
198 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
224 nvaprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
227 FILE *fp = pctl->nvprt_fp; \
232 if (i == 0 || pctl->nvprt_btwnarrfmt_nl) { \
233 indent(pctl, 1); \
234 (void) fprintf(fp, pctl->nvprt_nmfmt, name); \
235 if (pctl->nvprt_btwnarrfmt_nl) \
239 (void) fprintf(fp, pctl->nvprt_btwnarrfmt); \
259 nvprint_nvlist(nvlist_prtctl_t pctl, void *private, in nvprint_nvlist() argument
262 FILE *fp = pctl->nvprt_fp; in nvprint_nvlist()
264 indent(pctl, 1); in nvprint_nvlist()
267 pctl->nvprt_indent += pctl->nvprt_indentinc; in nvprint_nvlist()
268 nvlist_print_with_indent(value, pctl); in nvprint_nvlist()
269 pctl->nvprt_indent -= pctl->nvprt_indentinc; in nvprint_nvlist()
271 indent(pctl, 1); in nvprint_nvlist()
279 nvaprint_nvlist_array(nvlist_prtctl_t pctl, void *private, in nvaprint_nvlist_array() argument
282 FILE *fp = pctl->nvprt_fp; in nvaprint_nvlist_array()
285 indent(pctl, 1); in nvaprint_nvlist_array()
289 indent(pctl, 1); in nvaprint_nvlist_array()
292 pctl->nvprt_indent += pctl->nvprt_indentinc; in nvaprint_nvlist_array()
293 nvlist_print_with_indent(valuep[i], pctl); in nvaprint_nvlist_array()
294 pctl->nvprt_indent -= pctl->nvprt_indentinc; in nvaprint_nvlist_array()
296 indent(pctl, 1); in nvaprint_nvlist_array()
312 nvlist_prtctl_setdest(nvlist_prtctl_t pctl, FILE *fp) in nvlist_prtctl_setdest() argument
314 pctl->nvprt_fp = fp; in nvlist_prtctl_setdest()
318 nvlist_prtctl_getdest(nvlist_prtctl_t pctl) in nvlist_prtctl_getdest() argument
320 return (pctl->nvprt_fp); in nvlist_prtctl_getdest()
325 nvlist_prtctl_setindent(nvlist_prtctl_t pctl, enum nvlist_indent_mode mode, in nvlist_prtctl_setindent() argument
337 pctl->nvprt_indent_mode = mode; in nvlist_prtctl_setindent()
338 pctl->nvprt_indent = start; in nvlist_prtctl_setindent()
339 pctl->nvprt_indentinc = inc; in nvlist_prtctl_setindent()
343 nvlist_prtctl_doindent(nvlist_prtctl_t pctl, int onemore) in nvlist_prtctl_doindent() argument
345 indent(pctl, onemore); in nvlist_prtctl_doindent()
350 nvlist_prtctl_setfmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, in nvlist_prtctl_setfmt() argument
357 pctl->nvprt_nmfmt = fmt; in nvlist_prtctl_setfmt()
363 pctl->nvprt_eomfmt = fmt; in nvlist_prtctl_setfmt()
368 pctl->nvprt_btwnarrfmt = " "; in nvlist_prtctl_setfmt()
369 pctl->nvprt_btwnarrfmt_nl = 0; in nvlist_prtctl_setfmt()
371 pctl->nvprt_btwnarrfmt = fmt; in nvlist_prtctl_setfmt()
372 pctl->nvprt_btwnarrfmt_nl = (strstr(fmt, "\n") != NULL); in nvlist_prtctl_setfmt()
383 nvlist_prtctl_dofmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, ...) in nvlist_prtctl_dofmt() argument
385 FILE *fp = pctl->nvprt_fp; in nvlist_prtctl_dofmt()
394 (void) fprintf(fp, pctl->nvprt_nmfmt, name); in nvlist_prtctl_dofmt()
398 (void) fprintf(fp, pctl->nvprt_eomfmt); in nvlist_prtctl_dofmt()
402 (void) fprintf(fp, pctl->nvprt_btwnarrfmt); \ in nvlist_prtctl_dofmt()
422 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
426 CUSTPRTOP(pctl, type) = func; \
427 CUSTPRTOPARG(pctl, type) = private; \
448 nvlist_prtctlop_##type(nvlist_prtctl_t pctl, \
452 CUSTPRTOP(pctl, type) = func; \
453 CUSTPRTOPARG(pctl, type) = private; \
509 prtctl_defaults(FILE *fp, struct nvlist_prtctl *pctl, in prtctl_defaults() argument
512 pctl->nvprt_fp = fp; in prtctl_defaults()
513 pctl->nvprt_indent_mode = NVLIST_INDENT_TABBED; in prtctl_defaults()
514 pctl->nvprt_indent = 0; in prtctl_defaults()
515 pctl->nvprt_indentinc = 1; in prtctl_defaults()
516 pctl->nvprt_nmfmt = "%s = "; in prtctl_defaults()
517 pctl->nvprt_eomfmt = "\n"; in prtctl_defaults()
518 pctl->nvprt_btwnarrfmt = " "; in prtctl_defaults()
519 pctl->nvprt_btwnarrfmt_nl = 0; in prtctl_defaults()
521 pctl->nvprt_dfltops = (struct nvlist_printops *)&defprtops; in prtctl_defaults()
522 pctl->nvprt_custops = ops; in prtctl_defaults()
528 struct nvlist_prtctl *pctl; in nvlist_prtctl_alloc() local
531 if ((pctl = malloc(sizeof (*pctl))) == NULL) in nvlist_prtctl_alloc()
535 free(pctl); in nvlist_prtctl_alloc()
539 prtctl_defaults(stdout, pctl, ops); in nvlist_prtctl_alloc()
541 return (pctl); in nvlist_prtctl_alloc()
545 nvlist_prtctl_free(nvlist_prtctl_t pctl) in nvlist_prtctl_free() argument
547 if (pctl != NULL) { in nvlist_prtctl_free()
548 free(pctl->nvprt_custops); in nvlist_prtctl_free()
549 free(pctl); in nvlist_prtctl_free()
565 nvlist_print_with_indent(nvlist_t *nvl, nvlist_prtctl_t pctl) in nvlist_print_with_indent() argument
567 FILE *fp = pctl->nvprt_fp; in nvlist_print_with_indent()
575 indent(pctl, 0); in nvlist_print_with_indent()
588 RENDER(pctl, boolean, nvl, name, 1); in nvlist_print_with_indent()
594 RENDER(pctl, boolean_value, nvl, name, val); in nvlist_print_with_indent()
600 RENDER(pctl, byte, nvl, name, val); in nvlist_print_with_indent()
606 RENDER(pctl, int8, nvl, name, val); in nvlist_print_with_indent()
612 RENDER(pctl, uint8, nvl, name, val); in nvlist_print_with_indent()
618 RENDER(pctl, int16, nvl, name, val); in nvlist_print_with_indent()
624 RENDER(pctl, uint16, nvl, name, val); in nvlist_print_with_indent()
630 RENDER(pctl, int32, nvl, name, val); in nvlist_print_with_indent()
636 RENDER(pctl, uint32, nvl, name, val); in nvlist_print_with_indent()
642 RENDER(pctl, int64, nvl, name, val); in nvlist_print_with_indent()
648 RENDER(pctl, uint64, nvl, name, val); in nvlist_print_with_indent()
654 RENDER(pctl, double, nvl, name, val); in nvlist_print_with_indent()
660 RENDER(pctl, string, nvl, name, val); in nvlist_print_with_indent()
666 ARENDER(pctl, boolean_array, nvl, name, val, nelem); in nvlist_print_with_indent()
672 ARENDER(pctl, byte_array, nvl, name, val, nelem); in nvlist_print_with_indent()
678 ARENDER(pctl, int8_array, nvl, name, val, nelem); in nvlist_print_with_indent()
684 ARENDER(pctl, uint8_array, nvl, name, val, nelem); in nvlist_print_with_indent()
690 ARENDER(pctl, int16_array, nvl, name, val, nelem); in nvlist_print_with_indent()
696 ARENDER(pctl, uint16_array, nvl, name, val, nelem); in nvlist_print_with_indent()
702 ARENDER(pctl, int32_array, nvl, name, val, nelem); in nvlist_print_with_indent()
708 ARENDER(pctl, uint32_array, nvl, name, val, nelem); in nvlist_print_with_indent()
714 ARENDER(pctl, int64_array, nvl, name, val, nelem); in nvlist_print_with_indent()
720 ARENDER(pctl, uint64_array, nvl, name, val, nelem); in nvlist_print_with_indent()
726 ARENDER(pctl, string_array, nvl, name, val, nelem); in nvlist_print_with_indent()
732 RENDER(pctl, hrtime, nvl, name, val); in nvlist_print_with_indent()
738 RENDER(pctl, nvlist, nvl, name, val); in nvlist_print_with_indent()
744 ARENDER(pctl, nvlist_array, nvl, name, val, nelem); in nvlist_print_with_indent()
765 nvlist_prt(nvlist_t *nvl, nvlist_prtctl_t pctl) in nvlist_prt() argument
767 nvlist_print_with_indent(nvl, pctl); in nvlist_prt()