Lines Matching defs:datap
335 quote_string_ascii(pargs_data_t *datap, char *src)
392 quote_string(pargs_data_t *datap, char *src)
404 if (datap->pd_conv_flags & CONV_STRICT_ASCII)
405 return (quote_string_ascii(datap, src));
411 return (quote_string_ascii(datap, src));
471 * datap->pd_locale.
478 lookup_locale(pargs_data_t *datap)
490 for (i = 0; i < datap->pd_envc; i++) {
491 char *s = datap->pd_envp_strs[i];
544 datap->pd_locale = pd_locale;
552 extract_string(pargs_data_t *datap, uintptr_t addr)
560 if (Pread_string(datap->pd_proc, result, size, addr) < 0) {
579 read_ptr_array(pargs_data_t *datap, uintptr_t offset, uintptr_t *buf,
585 res = Pread(datap->pd_proc, buf, nelems * sizeof (uintptr_t),
591 res = Pread(datap->pd_proc, arr32, nelems * sizeof (uint32_t),
604 * datap->pd_argv and the extracted strings in datap->pd_argv_strs.
607 get_args(pargs_data_t *datap)
609 size_t argc = datap->pd_psinfo->pr_argc;
610 uintptr_t argvoff = datap->pd_psinfo->pr_argv;
613 datap->pd_argc = argc;
614 datap->pd_argv = safe_zalloc(argc * sizeof (uintptr_t));
616 if (read_ptr_array(datap, argvoff, datap->pd_argv, argc) <= 0) {
617 free(datap->pd_argv);
618 datap->pd_argv = NULL;
622 datap->pd_argv_strs = safe_zalloc(argc * sizeof (char *));
624 if (datap->pd_argv[i] == 0)
626 datap->pd_argv_strs[i] = extract_string(datap,
627 datap->pd_argv[i]);
635 pargs_data_t *datap = data;
637 if (datap->pd_envp != NULL) {
639 if (datap->pd_envc > datap->pd_envc_curr)
642 datap->pd_envp[datap->pd_envc] = addr;
644 datap->pd_envp_strs[datap->pd_envc] = NULL;
646 datap->pd_envp_strs[datap->pd_envc] = strdup(str);
649 datap->pd_envc++;
655 get_env(pargs_data_t *datap)
657 struct ps_prochandle *pr = datap->pd_proc;
659 datap->pd_envc = 0;
660 (void) Penv_iter(pr, build_env, datap);
661 datap->pd_envc_curr = datap->pd_envc;
663 datap->pd_envp = safe_zalloc(sizeof (uintptr_t) * datap->pd_envc);
664 datap->pd_envp_strs = safe_zalloc(sizeof (char *) * datap->pd_envc);
666 datap->pd_envc = 0;
667 (void) Penv_iter(pr, build_env, datap);
843 get_auxv(pargs_data_t *datap)
851 if (ps_pauxv(datap->pd_proc, &auxvp) != PS_OK)
857 datap->pd_auxc = i;
858 datap->pd_auxv = safe_zalloc(i * sizeof (auxv_t));
859 bcopy(auxvp, datap->pd_auxv, i * sizeof (auxv_t));
861 datap->pd_auxv_strs = safe_zalloc(datap->pd_auxc * sizeof (char *));
862 for (i = 0; i < datap->pd_auxc; i++) {
863 struct aux_id *aux = aux_find(datap->pd_auxv[i].a_type);
869 datap->pd_auxv_strs[i] =
870 extract_string(datap, datap->pd_auxv[i].a_un.a_val);
880 setup_conversions(pargs_data_t *datap, int *diflocale)
892 if (datap->pd_conv_flags & CONV_STRICT_ASCII)
898 if ((strcmp(datap->pd_locale, "C") == 0) ||
899 (strcmp(datap->pd_locale, "POSIX") == 0)) {
900 datap->pd_conv_flags |= CONV_STRICT_ASCII;
907 if (setlocale(LC_ALL, datap->pd_locale) == NULL) {
944 if ((datap->pd_iconv = iconv_open(mycharset, targetcharset))
956 datap->pd_conv_flags |= CONV_STRICT_ASCII;
958 datap->pd_conv_flags |= CONV_USE_ICONV;
968 cleanup_conversions(pargs_data_t *datap)
970 if (datap->pd_conv_flags & CONV_USE_ICONV) {
971 (void) iconv_close(datap->pd_iconv);
976 convert_run_iconv(pargs_data_t *datap, const char *str)
991 (void) iconv(datap->pd_iconv, NULL, &inleft,
996 if (iconv(datap->pd_iconv, &instrptr, &inleft, &outstrptr,
1030 convert_str(pargs_data_t *datap, const char *str, int *unprintable)
1034 if (datap->pd_conv_flags & CONV_STRICT_ASCII) {
1039 if ((datap->pd_conv_flags & CONV_USE_ICONV) == 0) {
1072 (void) setlocale(LC_ALL, datap->pd_locale);
1077 if ((retstr = convert_run_iconv(datap, retstr)) == NULL) {
1100 convert_array(pargs_data_t *datap, char **arr, size_t count, int *unprintable)
1111 arr[i] = convert_str(datap, arr[i], unprintable);
1120 free_data(pargs_data_t *datap)
1124 if (datap->pd_argv) {
1125 for (i = 0; i < datap->pd_argc; i++) {
1126 if (datap->pd_argv_strs[i] != NULL)
1127 free(datap->pd_argv_strs[i]);
1129 free(datap->pd_argv);
1130 free(datap->pd_argv_strs);
1133 if (datap->pd_envp) {
1134 for (i = 0; i < datap->pd_envc; i++) {
1135 if (datap->pd_envp_strs[i] != NULL)
1136 free(datap->pd_envp_strs[i]);
1138 free(datap->pd_envp);
1139 free(datap->pd_envp_strs);
1142 if (datap->pd_auxv) {
1143 for (i = 0; i < datap->pd_auxc; i++) {
1144 if (datap->pd_auxv_strs[i] != NULL)
1145 free(datap->pd_auxv_strs[i]);
1147 free(datap->pd_auxv);
1148 free(datap->pd_auxv_strs);
1153 print_args(pargs_data_t *datap)
1157 if (datap->pd_argv == NULL) {
1162 for (i = 0; i < datap->pd_argc; i++) {
1164 if (datap->pd_argv[i] == NULL) {
1166 } else if (datap->pd_argv_strs[i] == NULL) {
1169 (long)datap->pd_argv[i]);
1171 (void) printf("%s\n", datap->pd_argv_strs[i]);
1177 print_env(pargs_data_t *datap)
1181 if (datap->pd_envp == NULL) {
1186 for (i = 0; i < datap->pd_envc; i++) {
1188 if (datap->pd_envp[i] == 0) {
1190 } else if (datap->pd_envp_strs[i] == NULL) {
1193 (long)datap->pd_envp[i]);
1195 (void) printf("%s\n", datap->pd_envp_strs[i]);
1201 print_cmdline(pargs_data_t *datap)
1209 for (i = 0; i < datap->pd_argc; i++) {
1210 if (datap->pd_argv == NULL || datap->pd_argv[i] == NULL ||
1211 datap->pd_argv_strs[i] == NULL) {
1217 datap->pd_argv_strs[i] =
1218 quote_string(datap, datap->pd_argv_strs[i]);
1221 if (datap->pd_execname == NULL) {
1227 (void) printf("%s ", datap->pd_execname);
1229 for (i = 1; i < datap->pd_argc; i++)
1230 (void) printf("%s ", datap->pd_argv_strs[i]);
1238 print_auxv(pargs_data_t *datap)
1246 for (i = 0; i < datap->pd_auxc; i++) {
1251 pa = &datap->pd_auxv[i];
1262 aux->aux_decode(v, datap->pd_auxv_strs[i],
1358 pargs_data_t datap;
1446 bzero(&datap, sizeof (datap));
1448 datap.pd_proc = Pr;
1449 datap.pd_psinfo = &psinfo;
1452 datap.pd_conv_flags |= CONV_STRICT_ASCII;
1471 get_env(&datap);
1473 get_args(&datap);
1475 get_auxv(&datap);
1495 datap.pd_execname = Pexecname(Pr, execname,
1504 lookup_locale(&datap);
1506 setup_conversions(&datap, &diflocale);
1510 convert_array(&datap, datap.pd_argv_strs,
1511 datap.pd_argc, &unprintable);
1521 retc += print_cmdline(&datap);
1523 psargs_conv = convert_str(&datap, psinfo.pr_psargs,
1540 convert_array(&datap, datap.pd_argv_strs,
1541 datap.pd_argc, &unprintable);
1542 print_args(&datap);
1548 convert_array(&datap, datap.pd_envp_strs,
1549 datap.pd_envc, &unprintable);
1550 print_env(&datap);
1556 convert_array(&datap, datap.pd_auxv_strs,
1557 datap.pd_auxc, &unprintable);
1558 print_auxv(&datap);
1562 cleanup_conversions(&datap);
1563 free_data(&datap);