static int _StartBatch(MessageHandler *handler, char *name, char *param) { int (*apl)(char *); int rc; ValueStruct *val; char *arg; OpenCOBOL_Conv = NewConvOpt(); ConvSetSize(OpenCOBOL_Conv, ThisBD->textsize, ThisBD->arraysize); ConvSetCodeset(OpenCOBOL_Conv, ConvCodeset(handler->conv)); if (handler->conv != NULL) { OpenCOBOL_Conv->fBigEndian = handler->conv->fBigEndian; } else { Error("handler->conv is NULL"); } InitMONFUNC(OpenCOBOL_Conv, OpenCOBOL_PackValue, OpenCOBOL_UnPackValue, OpenCOBOL_SizeValue); #ifdef DEBUG printf("starting [%s][%s]\n", name, param); #endif if ((apl = cob_resolve(name)) != NULL) { val = NewValue(GL_TYPE_CHAR); SetValueStringWithLength(val, param, ThisBD->textsize, NULL); arg = StrnDup(ValueToString(val, "euc-jisx0213"), ThisBD->textsize); StringC2Cobol(arg, ThisBD->textsize); rc = apl(arg); FreeValueStruct(val); xfree(arg); } else { Warning("%s - %s is not found.", cob_resolve_error(), name); rc = -1; } return (rc); }
static void init( MessageHandler *handler) { VALUE load_path; InitMONFUNC(RubyConv, JSON_PackValue, JSON_UnPackValue, JSON_SizeValue); ruby_init(); ruby_init_loadpath(); load_path = rb_eval_string("$LOAD_PATH"); if (handler->loadpath == NULL) { handler->loadpath = getenv("APS_RUBY_PATH"); } if (handler->loadpath == NULL) { handler->loadpath = getenv("RUBYLIB"); } if (handler->loadpath == NULL) { handler->loadpath = MONTSUQI_LOAD_PATH; } rb_ary_push(load_path, rb_str_new2(handler->loadpath)); application_classes = rb_hash_new(); rb_gc_register_address(&application_classes); rb_global_variable(&application_classes); node_info = rb_hash_new(); rb_gc_register_address(&node_info); rb_global_variable(&node_info); rb_define_global_function("monfunc", monfunc, 2); rb_define_global_const("MCP_OK" ,INT2NUM(MCP_OK)); rb_define_global_const("MCP_EOF" ,INT2NUM(MCP_EOF)); rb_define_global_const("MCP_NONFATAL" ,INT2NUM(MCP_NONFATAL)); rb_define_global_const("MCP_BAD_ARG" ,INT2NUM(MCP_BAD_ARG)); rb_define_global_const("MCP_BAD_FUNC" ,INT2NUM(MCP_BAD_FUNC)); rb_define_global_const("MCP_BAD_OTHER" ,INT2NUM(MCP_BAD_OTHER)); rb_define_global_const("MCP_BAD_CONN" ,INT2NUM(MCP_BAD_CONN)); }
static void _ReadyDC(MessageHandler *handler) { int i; size_t scrsize; OpenCOBOL_Conv = NewConvOpt(); ConvSetSize(OpenCOBOL_Conv, ThisLD->textsize, ThisLD->arraysize); ConvSetCodeset(OpenCOBOL_Conv, ConvCodeset(handler->conv)); if (handler->conv != NULL) { OpenCOBOL_Conv->fBigEndian = handler->conv->fBigEndian; } else { Error("handler->conv is NULL"); } InitMONFUNC(OpenCOBOL_Conv, OpenCOBOL_PackValue, OpenCOBOL_UnPackValue, OpenCOBOL_SizeValue); if (ThisEnv->mcprec != NULL) { McpData = xmalloc(OpenCOBOL_SizeValue(OpenCOBOL_Conv, ThisEnv->mcprec->value)); OpenCOBOL_PackValue(OpenCOBOL_Conv, McpData, ThisEnv->mcprec->value); } else { McpData = NULL; } if (ThisEnv->linkrec != NULL) { LinkData = xmalloc(OpenCOBOL_SizeValue(OpenCOBOL_Conv, ThisEnv->linkrec->value)); } else { LinkData = NULL; } if (ThisLD->sparec != NULL) { SpaData = xmalloc(OpenCOBOL_SizeValue(OpenCOBOL_Conv, ThisLD->sparec->value)); } scrsize = 0; for (i = 0; i < ThisLD->cWindow; i++) { if (ThisLD->windows[i] != NULL) { scrsize += OpenCOBOL_SizeValue(OpenCOBOL_Conv, ThisLD->windows[i]->value); } } ScrData = xmalloc(scrsize); }