Move index.* to topology/

- Move index.h and index.c to topology/.
- Remove some unused and duplicate includes.
- Convert the source file to C++ (scanf issues suppressed for now).

Change-Id: I99374f5d2e53b6c26bf6441b630234177c83affb