dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / krb5 / ss / list_rqs.c
blobc92c5ac22e7e8f096d1002cc18895b32b65206a8
1 /*
2 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 #pragma ident "%Z%%M% %I% %E% SMI"
8 /*
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"
15 #include <libintl.h>
16 #include <signal.h>
17 #include <setjmp.h>
18 #include <sys/wait.h>
20 #define DONT_USE(x) ;
22 extern int ss_pager_create();
24 static char const twentyfive_spaces[26] =
25 " ";
26 static char const NL[2] = "\n";
28 void
29 ss_list_requests(argc, argv, sci_idx, info_ptr)
30 int argc;
31 const char * const *argv;
32 int sci_idx;
33 #ifdef __STDC__
34 void *info_ptr;
35 #else
36 char *info_ptr;
37 #endif
39 register ss_request_entry *entry;
40 register char const * const *name;
41 register int spacing;
42 register ss_request_table **table;
44 char buffer[BUFSIZ];
45 FILE *output;
46 int fd;
47 #ifdef POSIX_SIGNALS
48 struct sigaction nsig, osig;
49 sigset_t nmask, omask;
50 #else
51 int mask;
52 RETSIGTYPE (*func)();
53 #endif
54 #ifndef WAIT_USES_INT
55 union wait waitb;
56 #else
57 int waitb;
58 #endif
60 DONT_USE(argc);
61 DONT_USE(argv);
63 #ifdef POSIX_SIGNALS
64 sigemptyset(&nmask);
65 sigaddset(&nmask, SIGINT);
66 sigprocmask(SIG_BLOCK, &nmask, &omask);
68 nsig.sa_handler = SIG_IGN;
69 sigemptyset(&nsig.sa_mask);
70 nsig.sa_flags = 0;
71 sigaction(SIGINT, &nsig, &osig);
72 #else
73 mask = sigblock(sigmask(SIGINT));
74 func = signal(SIGINT, SIG_IGN);
75 #endif
77 fd = ss_pager_create();
78 output = fdopen(fd, "w");
80 #ifdef POSIX_SIGNALS
81 sigprocmask(SIG_SETMASK, &omask, (sigset_t *)0);
82 #else
83 sigsetmask(mask);
84 #endif
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++) {
92 spacing = -2;
93 buffer[0] = '\0';
94 if (entry->flags & SS_OPT_DONT_LIST)
95 continue;
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));
100 spacing += len + 2;
101 if (name[1]) {
102 strncat(buffer, ", ", sizeof(buffer) - 1 - strlen(buffer));
105 if (spacing > 23) {
106 strncat(buffer, NL, sizeof(buffer) - 1 - strlen(buffer));
107 fputs(buffer, output);
108 spacing = 0;
109 buffer[0] = '\0';
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);
124 fclose(output);
125 #ifndef NO_FORK
126 wait(&waitb);
127 #endif
128 #ifdef POSIX_SIGNALS
129 sigaction(SIGINT, &osig, NULL);
130 #else
131 (void) signal(SIGINT, func);
132 #endif