#include "io_backend.h" #include static struct iob_context context; static FILE *input; int iob_init(struct iob_context *ctx) { context = *ctx; switch (context.mode) { case IOB_MODE_STDIN: input = stdin; return 0; case IOB_MODE_SCRIPT: if (context.args == NULL) return -2; input = fopen(context.args, "r"); if (input == NULL) return -4; return 0; case IOB_MODE_CMD: if (context.args != NULL) return -2; else return 0; default: return -1; } }