Files
osmo-cbc/move-asn1-header-files.sh
Pau Espin Pedrol 4b8175d189 Add sbcap library
This commit adds initial support to encode/decode SBc-AP messages in the
form of a library, under src/sbcap/ (includes in
include/osmocom/sbcap/).
asn1c is used to generate all suport code and structures for ASN.1 APER
encoding/decoding, based on asn files obtained from 3GPP TS 29.168 and
stored under src/sbcap/asn1/.
Currently, mainstream asn1c doesn't yet support ASN.1 APER
encoding/decoding, hence mouse07410 's fork is used [1]. Furthermore,
several encdoing/decoding bugs where found during the process and fixed,
which means asn1.c git >= 30219de2d3da888b4f1eea0dd79f2a505000401a must
be used to generate proper code.

A new "make -C src/ gen" target is added which can be used to regenerate
all C code from the available ASN.1 files in src/sbcap/asn1/*.asn (after
properly setting configure.ac ASN_* variables if needed).

[1] https://github.com/mouse07410/asn1c

Related: OS#4945
Change-Id: If76f8619a9b2d46af6d94b8ae49348b8514e53aa
2022-07-15 15:53:35 +02:00

46 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
# Usage:
# ../../move-asn1-headers.sh subdir_name File1.h File2.h ...
# All .h and .c files in the current directory are edited to use #include <...>
# style for the .h files given on the cmdline. The given .h files are also
# moved to ../include/<subdir_name>/ so that #include <...> will work.
set -e
base_dir="$(dirname "$0")"
include_subdir="$1"
shift
include_dir="$base_dir/include/$include_subdir"
mkdir -p "$include_dir"
echo "$PWD/*.h --> $include_dir"
collect_sed_commands() {
while [ -n "$1" ]; do
fname="$1"
shift
echo "s,^#include \"$fname\"$,#include <$include_subdir/$fname>,"
echo "s, \* \tfound in \"${base_dir}, * \tfound in \"../..,"
done
}
move_headers() {
echo mv $@ "$include_dir/"
mv $@ "$include_dir/"
}
# Replace all `#include "foo.h"' with `#include <dir/foo.h>' locally
# - Collect sed commands to replace all header includes, for efficiency
cmds="$(mktemp)"
echo "collecting sed commands..."
collect_sed_commands $@ > "$cmds"
# - Run commands on all h and c files
echo "sed -i -f \"$cmds\" *.[hc]"
sed -i -f "$cmds" *.[hc]
rm "$cmds"
# Now move sed'ed *.h files to the proper ../include/dir
move_headers $@