2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 #pragma ident "%Z%%M% %I% %E% SMI"
9 * Copyright 1987, 1988 by MIT Student Information Processing Board
11 * For copyright information, see copyright.h.
13 #include "copyright.h"
14 #include "ss_internal.h"
22 extern int ss_pager_create();
24 static char const twentyfive_spaces
[26] =
26 static char const NL
[2] = "\n";
29 ss_list_requests(argc
, argv
, sci_idx
, info_ptr
)
31 const char * const *argv
;
39 register ss_request_entry
*entry
;
40 register char const * const *name
;
42 register ss_request_table
**table
;
48 struct sigaction nsig
, osig
;
49 sigset_t nmask
, omask
;
65 sigaddset(&nmask
, SIGINT
);
66 sigprocmask(SIG_BLOCK
, &nmask
, &omask
);
68 nsig
.sa_handler
= SIG_IGN
;
69 sigemptyset(&nsig
.sa_mask
);
71 sigaction(SIGINT
, &nsig
, &osig
);
73 mask
= sigblock(sigmask(SIGINT
));
74 func
= signal(SIGINT
, SIG_IGN
);
77 fd
= ss_pager_create();
78 output
= fdopen(fd
, "w");
81 sigprocmask(SIG_SETMASK
, &omask
, (sigset_t
*)0);
86 fprintf (output
, dgettext(TEXT_DOMAIN
, "Available %s requests:\n\n"),
87 ss_info (sci_idx
) -> subsystem_name
);
89 for (table
= ss_info(sci_idx
)->rqt_tables
; *table
; table
++) {
90 entry
= (*table
)->requests
;
91 for (; entry
->command_names
; entry
++) {
94 if (entry
->flags
& SS_OPT_DONT_LIST
)
96 buffer
[sizeof(buffer
) - 1] = '\0';
97 for (name
= entry
->command_names
; *name
; name
++) {
98 register int len
= strlen(*name
);
99 strncat(buffer
, *name
, sizeof(buffer
) - 1 - strlen(buffer
));
102 strncat(buffer
, ", ", sizeof(buffer
) - 1 - strlen(buffer
));
106 strncat(buffer
, NL
, sizeof(buffer
) - 1 - strlen(buffer
));
107 fputs(buffer
, output
);
111 strncat(buffer
, twentyfive_spaces
, strlen(twentyfive_spaces
) - spacing
);
114 * Due to libss not knowing what TEXT_DOMAIN
115 * the calling application is using for its info_string
116 * messages, we know require the callers (ktutil,kadmin)
117 * to L10N the messages before calling libss.
119 strncat(buffer
, entry
->info_string
, sizeof(buffer
) -1 - strlen(buffer
));
120 strncat(buffer
, NL
, sizeof(buffer
) - 1 - strlen(buffer
));
121 fputs(buffer
, output
);
129 sigaction(SIGINT
, &osig
, NULL
);
131 (void) signal(SIGINT
, func
);