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