aboutsummaryrefslogtreecommitdiff
path: root/progs/mkcapshdoc.sh
blob: d2ee4bd6315cd8dc31b7f9abe97641311b52c05e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# This script generates some C code for inclusion in the capsh binary.
# The Makefile generally only generates the .c code and compares it
# with the checked in code in the progs directory.

cat<<EOF
#include <stdio.h>

#include "./capshdoc.h"

/*
 * A line by line explanation of each named capability value
 */
EOF

let x=0
while [ -f "../doc/values/${x}.txt" ]; do
    name=$(grep -F ",${x}}" ../libcap/cap_names.list.h|sed -e 's/{"//' -e 's/",/ = /' -e 's/},//')
    echo "static const char *explanation${x}[] = {  /* ${name} */"
    sed -e 's/"/\\"/g' -e 's/^/    "/' -e 's/$/",/' "../doc/values/${x}.txt"
    let x=1+${x}
    echo "    NULL"
    echo "};"
done

cat<<EOF
const char **explanations[] = {
EOF
let y=0
while [ "${y}" -lt "${x}" ]; do
    echo "    explanation${y},"
    let y=1+${y}
done
cat<<EOF
};

const int capsh_doc_limit = ${x};
EOF