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); }
int main (int argc, char **argv) { int pcl_return; union { int (*func)(); void *func_void; } unifunc; #ifdef HAVE_SETLOCALE setlocale (LC_ALL, ""); #endif pcl_return = process_command_line (argc, argv); if (pcl_return != 99) { return pcl_return; } if (strlen (argv[1]) > 31) { fprintf (stderr, "Invalid PROGRAM name\n"); return 1; } cob_init (argc - 1, &argv[1]); unifunc.func_void = cob_resolve (argv[1]); if (unifunc.func_void == NULL) { cob_call_error (); } cob_stop_run ( unifunc.func() ); }
static Bool _ExecuteProcess(MessageHandler *handler, ProcessNode *node) { int (*apl)(char *, char *, char *, char *); char *module; long start, end; Bool rc; module = ValueStringPointer(GetItemLongName(node->mcprec->value, "dc.module")); if ((apl = cob_resolve(module)) != NULL) { PutApplication(node); start = GetNowTime(); (void)apl(McpData, SpaData, LinkData, ScrData); end = GetNowTime(); TimerPrintf(start, end, "OpenCOBOL %s:%s:%s\n", module, node->widget, node->event); GetApplication(node); if (ValueInteger(GetItemLongName(node->mcprec->value, "rc")) < 0) { rc = FALSE; } else { rc = TRUE; } } else { Warning("%s - %s is not found.", cob_resolve_error(), module); rc = FALSE; } return (rc); }