* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
-#include "libbb.h"
-#include <errno.h>
-#include <time.h>
-#include <pwd.h>
-#include <grp.h>
-
/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
/* X/OPEN tells us to use <sys/{types,ipc,shm}.h> for shmctl() */
#include <sys/msg.h>
#include <sys/shm.h>
-
+#include "libbb.h"
/*-------------------------------------------------------------------*/
/* SHM_DEST and SHM_LOCKED are defined in kernel headers,
union semun {
int val;
struct semid_ds *buf;
- unsigned short int *array;
+ unsigned short *array;
struct seminfo *__buf;
};
#endif
printf("%-10d %-10o", id, ipcp->mode & 0777);
- if ((pw = getpwuid(ipcp->cuid)))
- printf(" %-10s", pw->pw_name);
- else
- printf(" %-10d", ipcp->cuid);
- if ((gr = getgrgid(ipcp->cgid)))
- printf(" %-10s", gr->gr_name);
- else
- printf(" %-10d", ipcp->cgid);
-
- if ((pw = getpwuid(ipcp->uid)))
- printf(" %-10s", pw->pw_name);
- else
- printf(" %-10d", ipcp->uid);
- if ((gr = getgrgid(ipcp->gid)))
- printf(" %-10s\n", gr->gr_name);
- else
- printf(" %-10d\n", ipcp->gid);
+ pw = getpwuid(ipcp->cuid);
+ if (pw) printf(" %-10s", pw->pw_name);
+ else printf(" %-10d", ipcp->cuid);
+ gr = getgrgid(ipcp->cgid);
+ if (gr) printf(" %-10s", gr->gr_name);
+ else printf(" %-10d", ipcp->cgid);
+
+ pw = getpwuid(ipcp->uid);
+ if (pw) printf(" %-10s", pw->pw_name);
+ else printf(" %-10d", ipcp->uid);
+ gr = getgrgid(ipcp->gid);
+ if (gr) printf(" %-10s\n", gr->gr_name);
+ else printf(" %-10d\n", ipcp->gid);
}
}
printf("%-10d %-10d %-10d %-10d %-10d\n", i, val, ncnt, zcnt, pid);
}
- puts("");
+ bb_putchar('\n');
}
-int ipcs_main(int argc, char **argv);
-int ipcs_main(int argc, char **argv)
+int ipcs_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int ipcs_main(int argc UNUSED_PARAM, char **argv)
{
int id = 0;
unsigned flags = 0;
#define flag_sem (1<<2)
#define flag_shm (1<<3)
- opt = getopt32(argc, argv, "i:aqsmtcplu", &opt_i);
+ opt = getopt32(argv, "i:aqsmtcplu", &opt_i);
if (opt & 0x1) { // -i
id = xatoi(opt_i);
flags |= flag_print;
if (flags & flag_print) {
if (flags & flag_shm) {
print_shm(id);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
if (flags & flag_sem) {
print_sem(id);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
if (flags & flag_msg) {
print_msg(id);
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}
bb_show_usage();
}
if (!(flags & (flag_shm | flag_msg | flag_sem)))
flags |= flag_msg | flag_shm | flag_sem;
- puts("");
+ bb_putchar('\n');
if (flags & flag_shm) {
do_shm();
- puts("");
+ bb_putchar('\n');
}
if (flags & flag_sem) {
do_sem();
- puts("");
+ bb_putchar('\n');
}
if (flags & flag_msg) {
do_msg();
- puts("");
+ bb_putchar('\n');
}
- fflush_stdout_and_exit(0);
+ fflush_stdout_and_exit(EXIT_SUCCESS);
}