Fix signedness warnings

Further effort to make -Wall -Wextra more useful. This batch tries to deal with "comparison between signed and unsigned integer expressions" warning.

In the typical cases of iteration, counters are changed to match the type of bound. In a couple of cases of counter reuse with incompatible types, new variables were introduced instead.

Was found and fixed size discrepancy between various fields of MSG_DATA, and a new typedef MSG_IDX was introduced to keep them in check in the future. Hacky ~0 and 0xFFFF usage with them was replaced with MSG_IDX_MAX constant.

In the process, MSG_FILE and GROUPCHAT were moved from main.h and closer to a related stuff.