ftmod_libpri: Fix channel iterator memory leak

Keep the original iterator around to be able to actually free it
after use.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
FreeTDM: Rewrite "ftdm core" print_* functions (to use new span iterator)

Simplify code by using shared string constants using bool (0/1) index,
!!-operator and negation-via-XOR.

Future optimization: Preallocate and re-use of iterators, to avoid
repeatedly allocating and freeing of memory.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
FreeTDM: Fix "ftdm core flags/spanflags" with flag names

"x >> 1" is _NOT_ the reverse of "1 << x"...

Use code from Sean Eron Andersen's "Bit Twiddling Hacks"
(=> http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog)
to compute the log2 value (= position in the enum) of the bitflag.

This preserves the current behaviour, which is rather odd because
it is based on the position of the value in the enum, not its
actual (bit flag) value.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>