コード例 #1
0
ファイル: sessionthread.c プロジェクト: authorNari/panda
extern	void
FreeSessionCtrl(
	SessionCtrl *ctrl)
{
	if (ctrl->sysdbval != NULL) {
		FreeValueStruct(ctrl->sysdbval);
	}
	if (ctrl->sysdbvals != NULL) {
		FreeValueStruct(ctrl->sysdbvals);
	}
	FreeQueue(ctrl->waitq);
	g_free(ctrl);
}
コード例 #2
0
ファイル: OpenCOBOL.c プロジェクト: montsuqi/panda
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);
}
コード例 #3
0
ファイル: ruby.c プロジェクト: ogochan/libmondai
static void
value_struct_free(value_struct_data *data)
{
ENTER_FUNC;
	FreeValueStruct(data->value);
	free(data);
LEAVE_FUNC;
}
コード例 #4
0
ファイル: monblobapi.c プロジェクト: montsuqi/panda
static char *file_export(DBG_Struct *dbg, char *id, char *socket) {
  static char *filename;
  char *str;
  json_object *obj;
  NETFILE *fp;
  ValueStruct *ret, *value;
  ValueStruct *retval;

  ret = monblob_export(dbg, id);
  obj = json_object_new_object();
  if (!ret) {
    fprintf(stderr, "[%s] is not registered\n", id);
    json_object_object_add(obj, "status", json_object_new_int(404));
    retval = NULL;
  } else {
    value = GetItemLongName(ret, "file_data");
    retval = unescape_bytea(dbg, value);
    char *id;
    id = ValueToString(GetItemLongName(ret, "id"), dbg->coding);
    json_object_object_add(obj, "id", json_object_new_string(id));
    filename = ValueToString(GetItemLongName(ret, "filename"), dbg->coding);
    json_object_object_add(obj, "filename", json_object_new_string(filename));
    char *content_type;
    content_type =
        ValueToString(GetItemLongName(ret, "content_type"), dbg->coding);
    if (content_type == NULL || strlen(content_type) == 0) {
      json_object_object_add(
          obj, "content-type",
          json_object_new_string("application/octet-stream"));
    } else {
      json_object_object_add(obj, "content-type",
                             json_object_new_string(content_type));
    }
    json_object_object_add(obj, "status", json_object_new_int(200));
  }
  str = (char *)json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN);
  fp = ConnectBlobAPI(socket);
  SendString(fp, str);
  SendValue(fp, retval);
  FreeValueStruct(retval);
  Flush(fp);
  DisconnectBlobAPI(fp);
  FreeValueStruct(ret);
  return filename;
}
コード例 #5
0
ファイル: dbgroup.c プロジェクト: montsuqi/panda
extern void AuditLog(ValueStruct *mcp) {
  int i;
  DBG_Struct *dbg;
  ValueStruct *ret;
  DB_FUNC func;
  RecordStruct *rec;
  rec = ThisEnv->auditrec;
  for (i = 0; i < ThisEnv->cDBG; i++) {
    dbg = ThisEnv->DBG[i];
    if (dbg->auditlog > 0) {
      rec = SetAuditRec(mcp, rec);
      if ((func = LookupFUNC(dbg, "DBAUDITLOG")) != NULL) {
        ret = (*func)(dbg, NULL, rec, rec->value);
        if (ret != NULL) {
          FreeValueStruct(ret);
        }
      }
    }
  }
}
コード例 #6
0
ファイル: dbutils.c プロジェクト: montsuqi/panda
static Bool rel_exist(DBG_Struct *dbg, char *name, char *relkind) {
  ValueStruct *ret;
  char *sql;
  sql = (char *)xmalloc(SIZE_SQL);
  Bool rc;

  snprintf(
      sql, SIZE_SQL,
      "SELECT 1 FROM  pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON "
      "n.oid = c.relnamespace WHERE c.relname = '%s' AND c.relkind = '%s';",
      name, relkind);
  ret = ExecDBQuery(dbg, sql, FALSE);
  xfree(sql);
  if (ret) {
    rc = TRUE;
    FreeValueStruct(ret);
  } else {
    rc = FALSE;
  }
  return rc;
}
コード例 #7
0
ファイル: termthread.c プロジェクト: authorNari/panda
static	void
FreeSessionData(
	SessionData	*data)
{
ENTER_FUNC;
	if (data->type != SESSION_TYPE_API) {
		MessageLogPrintf("[%s@%s] session end",data->hdr->user,data->hdr->uuid);
	}
	if (data->linkdata != NULL) {
		FreeLBS(data->linkdata);
	}
	xfree(data->hdr);
	g_hash_table_foreach_remove(data->spadata,(GHRFunc)FreeSpa,NULL);
	g_hash_table_destroy(data->spadata);
	g_hash_table_foreach_remove(data->scrpool,(GHRFunc)FreeScr,NULL);
	g_hash_table_destroy(data->scrpool);
	xfree(data->scrdata);
	FreeLBS(data->apidata->rec);
	xfree(data->apidata);
	FreeValueStruct(data->sysdbval);
	xfree(data);
LEAVE_FUNC;
}
コード例 #8
0
ファイル: dbutils.c プロジェクト: montsuqi/panda
extern Bool column_exist(DBG_Struct *dbg, char *table_name, char *column_name) {
  Bool rc;
  char *sql, *p;
  ValueStruct *ret;

  sql = (char *)xmalloc(SIZE_SQL);
  p = sql;
  p += sprintf(p, "SELECT 1");
  p += sprintf(p, " FROM pg_tables JOIN information_schema.columns on "
                  "pg_tables.tablename = columns.table_name ");
  p += sprintf(p, " WHERE table_name = '%s' AND column_name = '%s'", table_name,
               column_name);
  sprintf(p, ";");
  ret = ExecDBQuery(dbg, sql, FALSE);
  xfree(sql);
  if (ret) {
    rc = TRUE;
    FreeValueStruct(ret);
  } else {
    rc = FALSE;
  }
  return rc;
}
コード例 #9
0
ファイル: Resident.c プロジェクト: montsuqi/panda
static void ExecuteDB_Server(MessageHandler *handler) {
  RecordStruct *rec;
  ValueStruct *value, *ret;
  PathStruct *path;
  DB_Operation *op;
  size_t size;
  int rno, pno, ono;
  DBCOMM_CTRL ctrl;
  char *rname, *pname, *func;
  ConvFuncs *conv;

  InitializeCTRL(&ctrl);
  conv = handler->serialize;
  while (TRUE) {
    dbgmsg("read");
    LBS_EmitStart(dbbuff);
    RecvLargeString(fpDBR, dbbuff);
    ON_IO_ERROR(fpDBR, badio);
    ConvSetRecName(handler->conv, recDBCTRL->name);
    InitializeValue(recDBCTRL->value);
    conv->UnPackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value);
    rname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "rname"));
    strncpy(ctrl.rname, rname, SIZE_NAME);
    value = NULL;
    ret = NULL;
    if ((rname != NULL) &&
        ((rno = (int)(long)g_hash_table_lookup(DB_Table, rname)) != 0)) {
      ctrl.rno = rno - 1;
      rec = ThisDB[ctrl.rno];
      value = rec->value;
      pname = ValueStringPointer(GetItemLongName(recDBCTRL->value, "pname"));
      strncpy(ctrl.pname, pname, SIZE_NAME);
      if ((pno = (int)(long)g_hash_table_lookup(rec->opt.db->paths, pname)) !=
          0) {
        ctrl.pno = pno - 1;
        path = rec->opt.db->path[pno - 1];
        value = (path->args != NULL) ? path->args : value;
      } else {
        ctrl.pno = 0;
        path = NULL;
      }
    } else {
      rec = NULL;
      path = NULL;
    }
    func = ValueStringPointer(GetItemLongName(recDBCTRL->value, "func"));
    if (*func != 0) {
      if (path == NULL) {
        Error("path is NULL");
      } else if ((ono = (int)(long)g_hash_table_lookup(path->opHash, func)) != 0) {
        op = path->ops[ono - 1];
        value = (op->args != NULL) ? op->args : value;
      }
      if (rec != NULL) {
        ConvSetRecName(handler->conv, rec->name);
      } else {
        Error("rec is NULL");
      }
      InitializeValue(value);
      conv->UnPackValue(handler->conv, LBS_Body(dbbuff), value);
      strncpy(ctrl.func, func, SIZE_FUNC);
      ret = ExecDB_Process(&ctrl, rec, value);
    } else {
      ctrl.rc = 0;
    }
    dbgmsg("write");
    SetValueInteger(GetItemLongName(recDBCTRL->value, "rc"), ctrl.rc);
    ConvSetRecName(handler->conv, recDBCTRL->name);
    LBS_EmitStart(dbbuff);
    size = conv->SizeValue(handler->conv, recDBCTRL->value);
    LBS_ReserveSize(dbbuff, size, FALSE);
    conv->PackValue(handler->conv, LBS_Body(dbbuff), recDBCTRL->value);
    LBS_EmitEnd(dbbuff);
    SendLargeString(fpDBW, dbbuff);
    ON_IO_ERROR(fpDBW, badio);
    if (ret != NULL) {
      Send(fpDBW, conv->fsep, strlen(conv->fsep));
      ON_IO_ERROR(fpDBW, badio);
      LBS_EmitStart(dbbuff);
      if (rec != NULL) {
        ConvSetRecName(handler->conv, rec->name);
      }
      size = conv->SizeValue(handler->conv, ret);
      LBS_ReserveSize(dbbuff, size, FALSE);
      conv->PackValue(handler->conv, LBS_Body(dbbuff), ret);
      LBS_EmitEnd(dbbuff);
      SendLargeString(fpDBW, dbbuff);
      ON_IO_ERROR(fpDBW, badio);
      FreeValueStruct(ret);
    }
    Send(fpDBW, conv->bsep, strlen(conv->bsep));
    ON_IO_ERROR(fpDBW, badio);
  }
badio:
  return;
}