Change session_open() signature.
Move platform-dependent routines to external.c