Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
static	void
_ReadyDC(
	MessageHandler	*handler)
{
ENTER_FUNC;
	RubyConv = NewConvOpt();
	ConvSetSize(RubyConv,ThisLD->textsize,ThisLD->arraysize);
	ConvSetCodeset(RubyConv,ConvCodeset(handler->conv));
	init(handler);
LEAVE_FUNC;
}
Exemplo n.º 3
0
static	int
_StartBatch(
	MessageHandler	*handler,
	char	*name,
	char	*param)
{
	VALUE app_class;
	VALUE app;
	VALUE rc;
	int state;

ENTER_FUNC;
#ifdef	DEBUG
	printf("starting [%s][%s]\n",name,param);
#endif
	RubyConv = NewConvOpt();
	ConvSetSize(RubyConv,ThisBD->textsize,ThisBD->arraysize);
	ConvSetCodeset(RubyConv,ConvCodeset(handler->conv));
	init(handler);

	app_class = load_application(handler->loadpath,name);
	if (NIL_P(app_class)) {
		Warning("%s in not found.",name);
		return -1;
	}
	app = rb_protect_funcall(app_class,rb_intern("new"),&state,0);
	if (state && error_handle(state)) {
		return -1;
	}
	rc = rb_protect_funcall(app, rb_intern("start_batch"), &state,
		1, rb_str_new2(param));
	if (state && error_handle(state))
		Warning("eval start_batch failed");
		return -1;
	if (FIXNUM_P(rc)) {
		return NUM2INT(rc);
	} else {
		return -1;
	}
LEAVE_FUNC;
	return	(rc); 
}
Exemplo n.º 4
0
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);
}