chiark / gitweb /
fishdescriptor: Utility for RTLD_NOW
[chiark-utils.git] / fishdescriptor / fishdescriptor.c
1 /*
2  *
3  * utility
4  *
5  */
6
7 #define _GNU_SOURCE
8
9 #include <unistd.h>
10 #include <getopt.h>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <dlfcn.h>
14
15 static const struct option longopts[] = {
16   { "print-rtld-now", 0, 0, '\1' },
17   { }
18 };
19
20 static void printusage(FILE *f) {
21   fputs("usage: fishdescriptor --print-rtld-now\n",f);
22 }
23
24 int main(int argc, char **argv) {
25   int o;
26
27   while ((o = getopt_long(argc, argv, "", longopts, 0)) != -1) {
28     switch (o) {
29     case '\1' /* --print-rtld-now */:
30       printf("%d\n", RTLD_NOW);
31       exit (0);
32     default:
33       fputs("bad usage: unknown option\n",stderr);
34       printusage(stderr);
35       exit(-1);
36     }
37   }
38
39   fputs("bad usage: XXX\n",stderr);
40   printusage(stderr);
41   exit(-1);
42 }