micro-utils/scripts/musuid.c

35 lines
657 B
C
Raw Normal View History

2024-09-01 13:43:41 +00:00
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
2024-09-30 13:11:43 +00:00
#include <libgen.h>
2024-09-01 13:43:41 +00:00
#define _MUSUID_C
#include "config.h"
const char *progs[] = {"su", "ping"};
int main(int argc, char **argv) {
2024-09-30 13:11:43 +00:00
char *prog = basename(argv[0]);
if (argc == 1 && !strcmp(prog, "musuid")) {
2024-09-01 13:43:41 +00:00
fputs("musuid: missing operand\n", stderr);
return 1;
}
2024-09-30 13:11:43 +00:00
else if (!strcmp(prog, "musuid")) {
argv++;
argc--;
prog = argv[0];
}
2024-09-01 13:43:41 +00:00
/* RUN */
for (size_t i = 0; i < sizeof(progs) / sizeof(char *); i++)
2024-09-30 13:11:43 +00:00
if (!strcmp(prog, progs[i]))
2024-09-01 13:43:41 +00:00
execv(MUTILS_PATH, argv);
fprintf(stderr, "musuid: unknown command: %s\n", argv[0]);
return 1;
}