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"
20 #ifdef lint /* "lint returns a value which is sometimes ignored" */
21 #define DONT_USE(x) x=x;
26 extern int ss_pager_create();
28 static char const twentyfive_spaces
[26] =
30 static char const NL
[2] = "\n";
33 ss_list_requests(argc
, argv
, sci_idx
, info_ptr
)
35 const char * const *argv
;
43 register ss_request_entry
*entry
;
44 register char const * const *name
;
46 register ss_request_table
**table
;
52 struct sigaction nsig
, osig
;
53 sigset_t nmask
, omask
;
69 sigaddset(&nmask
, SIGINT
);
70 sigprocmask(SIG_BLOCK
, &nmask
, &omask
);
72 nsig
.sa_handler
= SIG_IGN
;
73 sigemptyset(&nsig
.sa_mask
);
75 sigaction(SIGINT
, &nsig
, &osig
);
77 mask
= sigblock(sigmask(SIGINT
));
78 func
= signal(SIGINT
, SIG_IGN
);
81 fd
= ss_pager_create();
82 output
= fdopen(fd
, "w");
85 sigprocmask(SIG_SETMASK
, &omask
, (sigset_t
*)0);
90 fprintf (output
, dgettext(TEXT_DOMAIN
, "Available %s requests:\n\n"),
91 ss_info (sci_idx
) -> subsystem_name
);
93 for (table
= ss_info(sci_idx
)->rqt_tables
; *table
; table
++) {
94 entry
= (*table
)->requests
;
95 for (; entry
->command_names
; entry
++) {
98 if (entry
->flags
& SS_OPT_DONT_LIST
)
100 buffer
[sizeof(buffer
) - 1] = '\0';
101 for (name
= entry
->command_names
; *name
; name
++) {
102 register int len
= strlen(*name
);
103 strncat(buffer
, *name
, sizeof(buffer
) - 1 - strlen(buffer
));
106 strncat(buffer
, ", ", sizeof(buffer
) - 1 - strlen(buffer
));
110 strncat(buffer
, NL
, sizeof(buffer
) - 1 - strlen(buffer
));
111 fputs(buffer
, output
);
115 strncat(buffer
, twentyfive_spaces
, strlen(twentyfive_spaces
) - spacing
);
118 * Due to libss not knowing what TEXT_DOMAIN
119 * the calling application is using for its info_string
120 * messages, we know require the callers (ktutil,kadmin)
121 * to L10N the messages before calling libss.
123 strncat(buffer
, entry
->info_string
, sizeof(buffer
) -1 - strlen(buffer
));
124 strncat(buffer
, NL
, sizeof(buffer
) - 1 - strlen(buffer
));
125 fputs(buffer
, output
);
133 sigaction(SIGINT
, &osig
, (struct sigaction
*)0);
135 (void) signal(SIGINT
, func
);