| 1 |
#!/bin/bash |
| 2 |
# This script generates some C code for inclusion in the capsh binary. |
| 3 |
# The Makefile generally only generates the .c code and compares it |
| 4 |
# with the checked in code in the progs directory. |
| 5 |
|
| 6 |
cat<<EOF |
| 7 |
#include <stdio.h> |
| 8 |
|
| 9 |
#include "./capshdoc.h" |
| 10 |
|
| 11 |
/* |
| 12 |
* A line by line explanation of each named capability value |
| 13 |
*/ |
| 14 |
EOF |
| 15 |
|
| 16 |
let x=0 |
| 17 |
while [ -f "../doc/values/${x}.txt" ]; do |
| 18 |
name=$(grep -F ",${x}}" ../libcap/cap_names.list.h|sed -e 's/{"//' -e 's/",/ = /' -e 's/},//') |
| 19 |
echo "static const char *explanation${x}[] = { /* ${name} */" |
| 20 |
sed -e 's/"/\\"/g' -e 's/^/ "/' -e 's/$/",/' "../doc/values/${x}.txt" |
| 21 |
let x=1+${x} |
| 22 |
echo " NULL" |
| 23 |
echo "};" |
| 24 |
done |
| 25 |
|
| 26 |
cat<<EOF |
| 27 |
const char **explanations[] = { |
| 28 |
EOF |
| 29 |
let y=0 |
| 30 |
while [ "${y}" -lt "${x}" ]; do |
| 31 |
echo " explanation${y}," |
| 32 |
let y=1+${y} |
| 33 |
done |
| 34 |
cat<<EOF |
| 35 |
}; |
| 36 |
|
| 37 |
const int capsh_doc_limit = ${x}; |
| 38 |
EOF |